@measured/puck 0.19.0-canary.765b5e2b → 0.19.0-canary.7a515f67
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-44RES7IE.mjs +566 -0
- package/dist/index.css +14 -16
- package/dist/index.d.mts +5 -10
- package/dist/index.d.ts +5 -10
- package/dist/index.js +610 -811
- package/dist/index.mjs +6215 -1632
- package/dist/rsc.d.mts +2 -2
- package/dist/rsc.d.ts +2 -2
- package/dist/rsc.js +255 -3766
- package/dist/rsc.mjs +5 -103
- package/dist/{resolve-all-data-DgtDFF0E.d.mts → walk-tree-CM-cu7GU.d.mts} +42 -20
- package/dist/{resolve-all-data-DgtDFF0E.d.ts → walk-tree-CM-cu7GU.d.ts} +42 -20
- 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,13 @@ __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
|
-
usePuck: () => usePuck
|
177
|
+
usePuck: () => usePuck,
|
178
|
+
walkTree: () => walkTree
|
186
179
|
});
|
187
180
|
module.exports = __toCommonJS(core_exports);
|
188
181
|
init_react_import();
|
@@ -795,7 +788,7 @@ init_react_import();
|
|
795
788
|
// reducer/actions/set.ts
|
796
789
|
init_react_import();
|
797
790
|
|
798
|
-
// lib/data/walk-
|
791
|
+
// lib/data/walk-app-state.ts
|
799
792
|
init_react_import();
|
800
793
|
|
801
794
|
// lib/data/for-each-slot.ts
|
@@ -884,8 +877,8 @@ var stripSlots = (data) => {
|
|
884
877
|
});
|
885
878
|
};
|
886
879
|
|
887
|
-
// lib/data/walk-
|
888
|
-
function
|
880
|
+
// lib/data/walk-app-state.ts
|
881
|
+
function walkAppState(state, config, mapContent = (content) => content, mapNodeOrSkip = (item) => item) {
|
889
882
|
var _a;
|
890
883
|
let newZones = {};
|
891
884
|
const newZoneIndex = {};
|
@@ -1018,7 +1011,7 @@ var setAction = (state, action, appStore) => {
|
|
1018
1011
|
console.warn(
|
1019
1012
|
"`set` is expensive and may cause unnecessary re-renders. Consider using a more atomic action instead."
|
1020
1013
|
);
|
1021
|
-
return
|
1014
|
+
return walkAppState(newState, appStore.config);
|
1022
1015
|
}
|
1023
1016
|
return __spreadValues(__spreadValues({}, state), action.state(state));
|
1024
1017
|
};
|
@@ -1047,18 +1040,116 @@ var getIdsForParent = (zoneCompound, state) => {
|
|
1047
1040
|
return ((node == null ? void 0 : node.path) || []).map((p) => p.split(":")[0]);
|
1048
1041
|
};
|
1049
1042
|
|
1043
|
+
// lib/data/populate-ids.ts
|
1044
|
+
init_react_import();
|
1045
|
+
|
1046
|
+
// lib/data/walk-tree.ts
|
1047
|
+
init_react_import();
|
1048
|
+
|
1049
|
+
// lib/data/map-slots.ts
|
1050
|
+
init_react_import();
|
1051
|
+
function mapSlotsAsync(_0, _1) {
|
1052
|
+
return __async(this, arguments, function* (item, map, recursive = true, isSlot2 = isSlot) {
|
1053
|
+
const props = __spreadValues({}, item.props);
|
1054
|
+
const propKeys = Object.keys(props);
|
1055
|
+
for (let i = 0; i < propKeys.length; i++) {
|
1056
|
+
const propKey = propKeys[i];
|
1057
|
+
const itemType = "type" in item ? item.type : "root";
|
1058
|
+
if (isSlot2(itemType, propKey, props[propKey])) {
|
1059
|
+
const content = props[propKey];
|
1060
|
+
const mappedContent = recursive ? yield Promise.all(
|
1061
|
+
content.map((item2) => __async(this, null, function* () {
|
1062
|
+
return yield mapSlotsAsync(item2, map, recursive, isSlot2);
|
1063
|
+
}))
|
1064
|
+
) : content;
|
1065
|
+
props[propKey] = yield map(mappedContent, propKey);
|
1066
|
+
}
|
1067
|
+
}
|
1068
|
+
return __spreadProps(__spreadValues({}, item), { props });
|
1069
|
+
});
|
1070
|
+
}
|
1071
|
+
function mapSlotsSync(item, map, isSlot2 = isSlot) {
|
1072
|
+
var _a, _b;
|
1073
|
+
const props = __spreadValues({}, item.props);
|
1074
|
+
const propKeys = Object.keys(props);
|
1075
|
+
for (let i = 0; i < propKeys.length; i++) {
|
1076
|
+
const propKey = propKeys[i];
|
1077
|
+
const itemType = "type" in item ? item.type : "root";
|
1078
|
+
if (isSlot2(itemType, propKey, props[propKey])) {
|
1079
|
+
const content = props[propKey];
|
1080
|
+
const mappedContent = content.map((item2) => {
|
1081
|
+
return mapSlotsSync(item2, map, isSlot2);
|
1082
|
+
});
|
1083
|
+
props[propKey] = (_b = map(mappedContent, (_a = props.id) != null ? _a : "root", propKey)) != null ? _b : mappedContent;
|
1084
|
+
}
|
1085
|
+
}
|
1086
|
+
return __spreadProps(__spreadValues({}, item), { props });
|
1087
|
+
}
|
1088
|
+
|
1089
|
+
// lib/data/walk-tree.ts
|
1090
|
+
function walkTree(data, config, callbackFn) {
|
1091
|
+
var _a, _b;
|
1092
|
+
const isSlot2 = createIsSlotConfig(config);
|
1093
|
+
const walkItem = (item) => {
|
1094
|
+
return mapSlotsSync(
|
1095
|
+
item,
|
1096
|
+
(content, parentId, propName) => callbackFn(content, { parentId, propName }),
|
1097
|
+
isSlot2
|
1098
|
+
);
|
1099
|
+
};
|
1100
|
+
if ("props" in data) {
|
1101
|
+
return walkItem(data);
|
1102
|
+
}
|
1103
|
+
const _data = data;
|
1104
|
+
const zones = (_a = _data.zones) != null ? _a : {};
|
1105
|
+
const mappedContent = _data.content.map(walkItem);
|
1106
|
+
return {
|
1107
|
+
root: walkItem(_data.root),
|
1108
|
+
content: (_b = callbackFn(mappedContent, {
|
1109
|
+
parentId: "root",
|
1110
|
+
propName: "default-zone"
|
1111
|
+
})) != null ? _b : mappedContent,
|
1112
|
+
zones: Object.keys(zones).reduce(
|
1113
|
+
(acc, zoneCompound) => __spreadProps(__spreadValues({}, acc), {
|
1114
|
+
[zoneCompound]: zones[zoneCompound].map(walkItem)
|
1115
|
+
}),
|
1116
|
+
{}
|
1117
|
+
)
|
1118
|
+
};
|
1119
|
+
}
|
1120
|
+
|
1121
|
+
// lib/data/populate-ids.ts
|
1122
|
+
var populateIds = (data, config, override = false) => {
|
1123
|
+
const id = generateId(data.type);
|
1124
|
+
return walkTree(
|
1125
|
+
__spreadProps(__spreadValues({}, data), {
|
1126
|
+
props: override ? __spreadProps(__spreadValues({}, data.props), { id }) : __spreadValues({ id }, data.props)
|
1127
|
+
}),
|
1128
|
+
config,
|
1129
|
+
(contents) => contents.map((item) => {
|
1130
|
+
const id2 = generateId(item.type);
|
1131
|
+
return __spreadProps(__spreadValues({}, item), {
|
1132
|
+
props: override ? __spreadProps(__spreadValues({}, item.props), { id: id2 }) : __spreadValues({ id: id2 }, item.props)
|
1133
|
+
});
|
1134
|
+
})
|
1135
|
+
);
|
1136
|
+
};
|
1137
|
+
|
1050
1138
|
// reducer/actions/insert.ts
|
1051
1139
|
function insertAction(state, action, appStore) {
|
1052
1140
|
const id = action.id || generateId(action.componentType);
|
1053
|
-
const emptyComponentData =
|
1054
|
-
|
1055
|
-
|
1056
|
-
|
1057
|
-
|
1058
|
-
|
1141
|
+
const emptyComponentData = populateIds(
|
1142
|
+
{
|
1143
|
+
type: action.componentType,
|
1144
|
+
props: __spreadProps(__spreadValues({}, appStore.config.components[action.componentType].defaultProps || {}), {
|
1145
|
+
id
|
1146
|
+
})
|
1147
|
+
},
|
1148
|
+
appStore.config
|
1149
|
+
);
|
1059
1150
|
const [parentId] = action.destinationZone.split(":");
|
1060
1151
|
const idsInPath = getIdsForParent(action.destinationZone, state);
|
1061
|
-
return
|
1152
|
+
return walkAppState(
|
1062
1153
|
state,
|
1063
1154
|
appStore.config,
|
1064
1155
|
(content, zoneCompound) => {
|
@@ -1096,25 +1187,26 @@ var replaceAction = (state, action, appStore) => {
|
|
1096
1187
|
`Can't change the id during a replace action. Please us "remove" and "insert" to define a new node.`
|
1097
1188
|
);
|
1098
1189
|
}
|
1099
|
-
|
1190
|
+
const data = populateIds(action.data, appStore.config);
|
1191
|
+
return walkAppState(
|
1100
1192
|
state,
|
1101
1193
|
appStore.config,
|
1102
1194
|
(content, zoneCompound) => {
|
1103
1195
|
const newContent = [...content];
|
1104
1196
|
if (zoneCompound === action.destinationZone) {
|
1105
|
-
newContent[action.destinationIndex] =
|
1197
|
+
newContent[action.destinationIndex] = data;
|
1106
1198
|
}
|
1107
1199
|
return newContent;
|
1108
1200
|
},
|
1109
1201
|
(childItem, path) => {
|
1110
1202
|
const pathIds = path.map((p) => p.split(":")[0]);
|
1111
|
-
if (childItem.props.id ===
|
1112
|
-
return
|
1203
|
+
if (childItem.props.id === data.props.id) {
|
1204
|
+
return data;
|
1113
1205
|
} else if (childItem.props.id === parentId) {
|
1114
1206
|
return childItem;
|
1115
1207
|
} else if (idsInPath.indexOf(childItem.props.id) > -1) {
|
1116
1208
|
return childItem;
|
1117
|
-
} else if (pathIds.indexOf(
|
1209
|
+
} else if (pathIds.indexOf(data.props.id) > -1) {
|
1118
1210
|
return childItem;
|
1119
1211
|
}
|
1120
1212
|
return null;
|
@@ -1125,7 +1217,7 @@ var replaceAction = (state, action, appStore) => {
|
|
1125
1217
|
// reducer/actions/replace-root.ts
|
1126
1218
|
init_react_import();
|
1127
1219
|
var replaceRootAction = (state, action, appStore) => {
|
1128
|
-
return
|
1220
|
+
return walkAppState(
|
1129
1221
|
state,
|
1130
1222
|
appStore.config,
|
1131
1223
|
(content) => content,
|
@@ -1164,7 +1256,7 @@ function duplicateAction(state, action, appStore) {
|
|
1164
1256
|
id: generateId(item.type)
|
1165
1257
|
})
|
1166
1258
|
});
|
1167
|
-
const modified =
|
1259
|
+
const modified = walkAppState(
|
1168
1260
|
state,
|
1169
1261
|
appStore.config,
|
1170
1262
|
(content, zoneCompound) => {
|
@@ -1229,7 +1321,7 @@ var moveAction = (state, action, appStore) => {
|
|
1229
1321
|
if (!item) return state;
|
1230
1322
|
const idsInSourcePath = getIdsForParent(action.sourceZone, state);
|
1231
1323
|
const idsInDestinationPath = getIdsForParent(action.destinationZone, state);
|
1232
|
-
return
|
1324
|
+
return walkAppState(
|
1233
1325
|
state,
|
1234
1326
|
appStore.config,
|
1235
1327
|
(content, zoneCompound) => {
|
@@ -1287,7 +1379,7 @@ var removeAction = (state, action, appStore) => {
|
|
1287
1379
|
},
|
1288
1380
|
[item.props.id]
|
1289
1381
|
);
|
1290
|
-
const newState =
|
1382
|
+
const newState = walkAppState(
|
1291
1383
|
state,
|
1292
1384
|
appStore.config,
|
1293
1385
|
(content, zoneCompound) => {
|
@@ -1378,14 +1470,14 @@ var setDataAction = (state, action, appStore) => {
|
|
1378
1470
|
console.warn(
|
1379
1471
|
"`setData` is expensive and may cause unnecessary re-renders. Consider using a more atomic action instead."
|
1380
1472
|
);
|
1381
|
-
return
|
1473
|
+
return walkAppState(
|
1382
1474
|
__spreadProps(__spreadValues({}, state), {
|
1383
1475
|
data: __spreadValues(__spreadValues({}, state.data), action.data)
|
1384
1476
|
}),
|
1385
1477
|
appStore.config
|
1386
1478
|
);
|
1387
1479
|
}
|
1388
|
-
return
|
1480
|
+
return walkAppState(
|
1389
1481
|
__spreadProps(__spreadValues({}, state), {
|
1390
1482
|
data: __spreadValues(__spreadValues({}, state.data), action.data(state.data))
|
1391
1483
|
}),
|
@@ -1770,7 +1862,7 @@ var import_react7 = require("react");
|
|
1770
1862
|
init_react_import();
|
1771
1863
|
var flattenData = (state, config) => {
|
1772
1864
|
const data = [];
|
1773
|
-
|
1865
|
+
walkAppState(
|
1774
1866
|
state,
|
1775
1867
|
config,
|
1776
1868
|
(content) => content,
|
@@ -1935,7 +2027,8 @@ var createFieldsSlice = (_set, _get) => {
|
|
1935
2027
|
return {
|
1936
2028
|
fields: {},
|
1937
2029
|
loading: false,
|
1938
|
-
lastResolvedData: {}
|
2030
|
+
lastResolvedData: {},
|
2031
|
+
id: void 0
|
1939
2032
|
};
|
1940
2033
|
};
|
1941
2034
|
var useRegisterFieldsSlice = (appStore, id) => {
|
@@ -1956,7 +2049,7 @@ var useRegisterFieldsSlice = (appStore, id) => {
|
|
1956
2049
|
let lastFields = fields;
|
1957
2050
|
if (reset) {
|
1958
2051
|
appStore.setState((s) => ({
|
1959
|
-
fields: __spreadProps(__spreadValues({}, s.fields), { fields: defaultFields })
|
2052
|
+
fields: __spreadProps(__spreadValues({}, s.fields), { fields: defaultFields, id })
|
1960
2053
|
}));
|
1961
2054
|
lastFields = defaultFields;
|
1962
2055
|
}
|
@@ -1984,12 +2077,13 @@ var useRegisterFieldsSlice = (appStore, id) => {
|
|
1984
2077
|
fields: {
|
1985
2078
|
fields: newFields,
|
1986
2079
|
loading: false,
|
1987
|
-
lastResolvedData: componentData
|
2080
|
+
lastResolvedData: componentData,
|
2081
|
+
id
|
1988
2082
|
}
|
1989
2083
|
});
|
1990
2084
|
} else {
|
1991
2085
|
appStore.setState((s) => ({
|
1992
|
-
fields: __spreadProps(__spreadValues({}, s.fields), { fields: defaultFields })
|
2086
|
+
fields: __spreadProps(__spreadValues({}, s.fields), { fields: defaultFields, id })
|
1993
2087
|
}));
|
1994
2088
|
}
|
1995
2089
|
}),
|
@@ -2006,55 +2100,6 @@ var useRegisterFieldsSlice = (appStore, id) => {
|
|
2006
2100
|
|
2007
2101
|
// lib/resolve-component-data.ts
|
2008
2102
|
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
2103
|
var import_fast_deep_equal = __toESM(require("fast-deep-equal"));
|
2059
2104
|
var cache = { lastChange: {} };
|
2060
2105
|
var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (item, config, metadata = {}, onResolveStart, onResolveEnd, trigger = "replace", recursive = true) {
|
@@ -2299,7 +2344,7 @@ var createAppStore = (initialAppStore) => (0, import_zustand2.create)()(
|
|
2299
2344
|
}),
|
2300
2345
|
resolveAndCommitData: () => __async(void 0, null, function* () {
|
2301
2346
|
const { config, state, dispatch, resolveComponentData: resolveComponentData2 } = get();
|
2302
|
-
|
2347
|
+
walkAppState(
|
2303
2348
|
state,
|
2304
2349
|
config,
|
2305
2350
|
(content) => content,
|
@@ -2348,314 +2393,11 @@ function useAppStoreApi() {
|
|
2348
2393
|
init_react_import();
|
2349
2394
|
var import_react12 = require("@dnd-kit/react");
|
2350
2395
|
|
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
2396
|
// lib/dnd/use-sensors.ts
|
2379
2397
|
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");
|
2398
|
+
var import_react10 = require("react");
|
2399
|
+
var import_react11 = require("@dnd-kit/react");
|
2387
2400
|
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
2401
|
var useSensors = ({
|
2660
2402
|
other,
|
2661
2403
|
mouse,
|
@@ -2664,12 +2406,12 @@ var useSensors = ({
|
|
2664
2406
|
touch: { delay: { value: 200, tolerance: 10 } },
|
2665
2407
|
other: { delay: { value: 200, tolerance: 10 }, distance: { value: 5 } }
|
2666
2408
|
}) => {
|
2667
|
-
const [sensors] = (0,
|
2668
|
-
PointerSensor.configure({
|
2409
|
+
const [sensors] = (0, import_react10.useState)(() => [
|
2410
|
+
import_react11.PointerSensor.configure({
|
2669
2411
|
activationConstraints(event, source) {
|
2670
2412
|
var _a;
|
2671
2413
|
const { pointerType, target } = event;
|
2672
|
-
if (pointerType === "mouse" && (0,
|
2414
|
+
if (pointerType === "mouse" && (0, import_utilities.isElement)(target) && (source.handle === target || ((_a = source.handle) == null ? void 0 : _a.contains(target)))) {
|
2673
2415
|
return mouse;
|
2674
2416
|
}
|
2675
2417
|
if (pointerType === "touch") {
|
@@ -2684,11 +2426,11 @@ var useSensors = ({
|
|
2684
2426
|
|
2685
2427
|
// lib/dnd/collision/dynamic/index.ts
|
2686
2428
|
init_react_import();
|
2687
|
-
var
|
2429
|
+
var import_abstract8 = require("@dnd-kit/abstract");
|
2688
2430
|
|
2689
2431
|
// lib/dnd/collision/directional/index.ts
|
2690
2432
|
init_react_import();
|
2691
|
-
var
|
2433
|
+
var import_abstract = require("@dnd-kit/abstract");
|
2692
2434
|
|
2693
2435
|
// lib/dnd/collision/collision-debug.ts
|
2694
2436
|
init_react_import();
|
@@ -2766,7 +2508,7 @@ var directionalCollision = (input, previous) => {
|
|
2766
2508
|
return {
|
2767
2509
|
id: droppable.id,
|
2768
2510
|
value: 1,
|
2769
|
-
type:
|
2511
|
+
type: import_abstract.CollisionType.Collision
|
2770
2512
|
};
|
2771
2513
|
}
|
2772
2514
|
return null;
|
@@ -2808,7 +2550,7 @@ var getMidpointImpact = (dragShape, dropShape, direction, offsetMultiplier = 0)
|
|
2808
2550
|
|
2809
2551
|
// lib/dnd/collision/dynamic/track-movement-interval.ts
|
2810
2552
|
init_react_import();
|
2811
|
-
var
|
2553
|
+
var import_geometry = require("@dnd-kit/geometry");
|
2812
2554
|
var INTERVAL_SENSITIVITY = 10;
|
2813
2555
|
var intervalCache = {
|
2814
2556
|
current: { x: 0, y: 0 },
|
@@ -2824,13 +2566,15 @@ var trackMovementInterval = (point, dragAxis = "dynamic") => {
|
|
2824
2566
|
};
|
2825
2567
|
intervalCache.direction = getDirection(dragAxis, intervalCache.delta) || intervalCache.direction;
|
2826
2568
|
if (Math.abs(intervalCache.delta.x) > INTERVAL_SENSITIVITY || Math.abs(intervalCache.delta.y) > INTERVAL_SENSITIVITY) {
|
2827
|
-
intervalCache.previous =
|
2569
|
+
intervalCache.previous = import_geometry.Point.from(point);
|
2828
2570
|
}
|
2829
2571
|
return intervalCache;
|
2830
2572
|
};
|
2831
2573
|
|
2832
2574
|
// ../../node_modules/@dnd-kit/collision/dist/index.js
|
2833
2575
|
init_react_import();
|
2576
|
+
var import_abstract2 = require("@dnd-kit/abstract");
|
2577
|
+
var import_geometry2 = require("@dnd-kit/geometry");
|
2834
2578
|
var import_abstract3 = require("@dnd-kit/abstract");
|
2835
2579
|
var import_geometry3 = require("@dnd-kit/geometry");
|
2836
2580
|
var import_abstract4 = require("@dnd-kit/abstract");
|
@@ -2841,8 +2585,6 @@ var import_abstract6 = require("@dnd-kit/abstract");
|
|
2841
2585
|
var import_geometry6 = require("@dnd-kit/geometry");
|
2842
2586
|
var import_abstract7 = require("@dnd-kit/abstract");
|
2843
2587
|
var import_geometry7 = require("@dnd-kit/geometry");
|
2844
|
-
var import_abstract8 = require("@dnd-kit/abstract");
|
2845
|
-
var import_geometry8 = require("@dnd-kit/geometry");
|
2846
2588
|
var pointerIntersection = ({
|
2847
2589
|
dragOperation,
|
2848
2590
|
droppable
|
@@ -2856,12 +2598,12 @@ var pointerIntersection = ({
|
|
2856
2598
|
return null;
|
2857
2599
|
}
|
2858
2600
|
if (droppable.shape.containsPoint(pointerCoordinates)) {
|
2859
|
-
const distance =
|
2601
|
+
const distance = import_geometry2.Point.distance(droppable.shape.center, pointerCoordinates);
|
2860
2602
|
return {
|
2861
2603
|
id,
|
2862
2604
|
value: 1 / distance,
|
2863
|
-
type:
|
2864
|
-
priority:
|
2605
|
+
type: import_abstract2.CollisionType.PointerIntersection,
|
2606
|
+
priority: import_abstract2.CollisionPriority.High
|
2865
2607
|
};
|
2866
2608
|
}
|
2867
2609
|
return null;
|
@@ -2872,31 +2614,15 @@ var closestCorners = (input) => {
|
|
2872
2614
|
if (!droppable.shape) {
|
2873
2615
|
return null;
|
2874
2616
|
}
|
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) => {
|
2617
|
+
const shapeCorners = shape ? import_geometry4.Rectangle.from(shape.current.boundingRectangle).corners : void 0;
|
2618
|
+
const distance = import_geometry4.Rectangle.from(
|
2619
|
+
droppable.shape.boundingRectangle
|
2620
|
+
).corners.reduce(
|
2621
|
+
(acc, corner, index) => {
|
2896
2622
|
var _a;
|
2897
|
-
return acc +
|
2898
|
-
|
2899
|
-
(_a =
|
2623
|
+
return acc + import_geometry4.Point.distance(
|
2624
|
+
import_geometry4.Point.from(corner),
|
2625
|
+
(_a = shapeCorners == null ? void 0 : shapeCorners[index]) != null ? _a : position.current
|
2900
2626
|
);
|
2901
2627
|
},
|
2902
2628
|
0
|
@@ -2905,8 +2631,8 @@ var closestCorners = (input) => {
|
|
2905
2631
|
return {
|
2906
2632
|
id: droppable.id,
|
2907
2633
|
value: 1 / value,
|
2908
|
-
type:
|
2909
|
-
priority:
|
2634
|
+
type: import_abstract4.CollisionType.Collision,
|
2635
|
+
priority: import_abstract4.CollisionPriority.Normal
|
2910
2636
|
};
|
2911
2637
|
};
|
2912
2638
|
|
@@ -2931,12 +2657,7 @@ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input
|
|
2931
2657
|
const { center: dragCenter } = dragShape;
|
2932
2658
|
const { fallbackEnabled } = collisionStore.getState();
|
2933
2659
|
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] = {
|
2660
|
+
const data = {
|
2940
2661
|
direction: interval.direction
|
2941
2662
|
};
|
2942
2663
|
const { center: dropCenter } = dropShape;
|
@@ -2951,7 +2672,8 @@ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input
|
|
2951
2672
|
collisionDebug(dragCenter, dropCenter, droppable.id.toString(), "yellow");
|
2952
2673
|
if (collision) {
|
2953
2674
|
return __spreadProps(__spreadValues({}, collision), {
|
2954
|
-
priority:
|
2675
|
+
priority: import_abstract8.CollisionPriority.Highest,
|
2676
|
+
data
|
2955
2677
|
});
|
2956
2678
|
}
|
2957
2679
|
}
|
@@ -2968,12 +2690,12 @@ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input
|
|
2968
2690
|
const collision = {
|
2969
2691
|
id: droppable.id,
|
2970
2692
|
value: intersectionRatio,
|
2971
|
-
priority:
|
2972
|
-
type:
|
2693
|
+
priority: import_abstract8.CollisionPriority.High,
|
2694
|
+
type: import_abstract8.CollisionType.Collision
|
2973
2695
|
};
|
2974
2696
|
const shouldFlushId = flushNext === droppable.id;
|
2975
2697
|
flushNext = "";
|
2976
|
-
return __spreadProps(__spreadValues({}, collision), { id: shouldFlushId ? "flush" : collision.id });
|
2698
|
+
return __spreadProps(__spreadValues({}, collision), { id: shouldFlushId ? "flush" : collision.id, data });
|
2977
2699
|
}
|
2978
2700
|
if (fallbackEnabled && ((_c = dragOperation.source) == null ? void 0 : _c.id) !== droppable.id) {
|
2979
2701
|
const xAxisIntersection = dropShape.boundingRectangle.right > dragShape.boundingRectangle.left && dropShape.boundingRectangle.left < dragShape.boundingRectangle.right;
|
@@ -2985,9 +2707,7 @@ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input
|
|
2985
2707
|
x: dragShape.center.x - (((_d = droppable.shape) == null ? void 0 : _d.center.x) || 0),
|
2986
2708
|
y: dragShape.center.y - (((_e = droppable.shape) == null ? void 0 : _e.center.y) || 0)
|
2987
2709
|
});
|
2988
|
-
|
2989
|
-
direction
|
2990
|
-
};
|
2710
|
+
data.direction = direction;
|
2991
2711
|
if (intersectionArea) {
|
2992
2712
|
collisionDebug(
|
2993
2713
|
dragCenter,
|
@@ -2998,7 +2718,8 @@ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input
|
|
2998
2718
|
);
|
2999
2719
|
flushNext = droppable.id;
|
3000
2720
|
return __spreadProps(__spreadValues({}, fallbackCollision), {
|
3001
|
-
priority:
|
2721
|
+
priority: import_abstract8.CollisionPriority.Low,
|
2722
|
+
data
|
3002
2723
|
});
|
3003
2724
|
}
|
3004
2725
|
collisionDebug(
|
@@ -3008,16 +2729,19 @@ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input
|
|
3008
2729
|
"orange",
|
3009
2730
|
direction || ""
|
3010
2731
|
);
|
3011
|
-
return __spreadProps(__spreadValues({}, fallbackCollision), {
|
2732
|
+
return __spreadProps(__spreadValues({}, fallbackCollision), {
|
2733
|
+
priority: import_abstract8.CollisionPriority.Lowest,
|
2734
|
+
data
|
2735
|
+
});
|
3012
2736
|
}
|
3013
2737
|
}
|
3014
2738
|
}
|
3015
2739
|
collisionDebug(dragCenter, dropCenter, droppable.id.toString(), "hotpink");
|
3016
|
-
delete collisionMap[droppable.id];
|
3017
2740
|
return null;
|
3018
2741
|
};
|
3019
2742
|
|
3020
2743
|
// components/Sortable/index.tsx
|
2744
|
+
var import_sortable = require("@dnd-kit/react/sortable");
|
3021
2745
|
var import_jsx_runtime5 = require("react/jsx-runtime");
|
3022
2746
|
var SortableProvider = ({
|
3023
2747
|
children,
|
@@ -3037,16 +2761,16 @@ var SortableProvider = ({
|
|
3037
2761
|
return onDragStart((_b = (_a = event.operation.source) == null ? void 0 : _a.id.toString()) != null ? _b : "");
|
3038
2762
|
},
|
3039
2763
|
onDragOver: (event, manager) => {
|
3040
|
-
var _a
|
2764
|
+
var _a;
|
3041
2765
|
event.preventDefault();
|
3042
2766
|
const { operation } = event;
|
3043
2767
|
const { source, target } = operation;
|
3044
2768
|
if (!source || !target) return;
|
3045
2769
|
let sourceIndex = source.data.index;
|
3046
2770
|
let targetIndex = target.data.index;
|
3047
|
-
const collisionData = (
|
2771
|
+
const collisionData = (_a = manager.collisionObserver.collisions[0]) == null ? void 0 : _a.data;
|
3048
2772
|
if (sourceIndex !== targetIndex && source.id !== target.id) {
|
3049
|
-
const collisionPosition = collisionData.direction === "up" ? "before" : "after";
|
2773
|
+
const collisionPosition = (collisionData == null ? void 0 : collisionData.direction) === "up" ? "before" : "after";
|
3050
2774
|
if (targetIndex >= sourceIndex) {
|
3051
2775
|
targetIndex = targetIndex - 1;
|
3052
2776
|
}
|
@@ -3077,9 +2801,10 @@ var Sortable = ({
|
|
3077
2801
|
}) => {
|
3078
2802
|
const {
|
3079
2803
|
ref: sortableRef,
|
3080
|
-
|
2804
|
+
isDragging,
|
2805
|
+
isDropping,
|
3081
2806
|
handleRef
|
3082
|
-
} =
|
2807
|
+
} = (0, import_sortable.useSortable)({
|
3083
2808
|
id,
|
3084
2809
|
type,
|
3085
2810
|
index,
|
@@ -3087,7 +2812,7 @@ var Sortable = ({
|
|
3087
2812
|
data: { index },
|
3088
2813
|
collisionDetector: createDynamicCollisionDetector("y")
|
3089
2814
|
});
|
3090
|
-
return children({
|
2815
|
+
return children({ isDragging, isDropping, ref: sortableRef, handleRef });
|
3091
2816
|
};
|
3092
2817
|
|
3093
2818
|
// components/AutoField/context.tsx
|
@@ -3212,7 +2937,7 @@ var ArrayField = ({
|
|
3212
2937
|
}
|
3213
2938
|
}, []);
|
3214
2939
|
const [draggedItem, setDraggedItem] = (0, import_react14.useState)("");
|
3215
|
-
const
|
2940
|
+
const isDraggingAny = !!draggedItem;
|
3216
2941
|
const canEdit = useAppStore(
|
3217
2942
|
(s) => s.permissions.getPermissions({ item: s.selectedItem }).edit
|
3218
2943
|
);
|
@@ -3277,13 +3002,13 @@ var ArrayField = ({
|
|
3277
3002
|
id: _arrayId,
|
3278
3003
|
index: i,
|
3279
3004
|
disabled: readOnly,
|
3280
|
-
children: ({
|
3005
|
+
children: ({ isDragging, ref, handleRef }) => /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
3281
3006
|
"div",
|
3282
3007
|
{
|
3283
3008
|
ref,
|
3284
3009
|
className: getClassNameItem({
|
3285
3010
|
isExpanded: arrayState.openId === _arrayId,
|
3286
|
-
isDragging
|
3011
|
+
isDragging,
|
3287
3012
|
readOnly
|
3288
3013
|
}),
|
3289
3014
|
children: [
|
@@ -3424,7 +3149,7 @@ var ArrayField = ({
|
|
3424
3149
|
type: "button",
|
3425
3150
|
className: getClassName5("addButton"),
|
3426
3151
|
onClick: () => {
|
3427
|
-
if (
|
3152
|
+
if (isDraggingAny) return;
|
3428
3153
|
const existingValue = value || [];
|
3429
3154
|
const newValue = [
|
3430
3155
|
...existingValue,
|
@@ -4407,15 +4132,15 @@ init_react_import();
|
|
4407
4132
|
|
4408
4133
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Drawer/styles.module.css#css-module
|
4409
4134
|
init_react_import();
|
4410
|
-
var styles_module_default10 = { "Drawer": "
|
4135
|
+
var styles_module_default10 = { "Drawer": "_Drawer_pl7z0_1", "Drawer-draggable": "_Drawer-draggable_pl7z0_8", "Drawer-draggableBg": "_Drawer-draggableBg_pl7z0_12", "DrawerItem-draggable": "_DrawerItem-draggable_pl7z0_22", "DrawerItem--disabled": "_DrawerItem--disabled_pl7z0_35", "DrawerItem": "_DrawerItem_pl7z0_22", "Drawer--isDraggingFrom": "_Drawer--isDraggingFrom_pl7z0_45", "DrawerItem-name": "_DrawerItem-name_pl7z0_63" };
|
4411
4136
|
|
4412
4137
|
// components/Drawer/index.tsx
|
4413
|
-
var
|
4138
|
+
var import_react38 = require("react");
|
4414
4139
|
|
4415
4140
|
// components/DragDropContext/index.tsx
|
4416
4141
|
init_react_import();
|
4417
|
-
var
|
4418
|
-
var
|
4142
|
+
var import_react36 = require("@dnd-kit/react");
|
4143
|
+
var import_react37 = require("react");
|
4419
4144
|
var import_dom = require("@dnd-kit/dom");
|
4420
4145
|
|
4421
4146
|
// components/DropZone/index.tsx
|
@@ -4525,6 +4250,7 @@ function useContextStore(context, selector) {
|
|
4525
4250
|
|
4526
4251
|
// components/DraggableComponent/index.tsx
|
4527
4252
|
var import_shallow2 = require("zustand/react/shallow");
|
4253
|
+
var import_sortable2 = require("@dnd-kit/react/sortable");
|
4528
4254
|
var import_jsx_runtime20 = require("react/jsx-runtime");
|
4529
4255
|
var getClassName16 = get_class_name_factory_default("DraggableComponent", styles_module_default11);
|
4530
4256
|
var DEBUG2 = false;
|
@@ -4610,7 +4336,7 @@ var DraggableComponent = ({
|
|
4610
4336
|
const canCollide = permissions.drag || userIsDragging;
|
4611
4337
|
const disabled = !isEnabled || !canCollide;
|
4612
4338
|
const [dragAxis, setDragAxis] = (0, import_react25.useState)(userDragAxis || autoDragAxis);
|
4613
|
-
const { ref: sortableRef,
|
4339
|
+
const { ref: sortableRef, isDragging: thisIsDragging } = (0, import_sortable2.useSortable)({
|
4614
4340
|
id,
|
4615
4341
|
index,
|
4616
4342
|
group: zoneCompound,
|
@@ -4632,9 +4358,9 @@ var DraggableComponent = ({
|
|
4632
4358
|
transition: {
|
4633
4359
|
duration: 200,
|
4634
4360
|
easing: "cubic-bezier(0.2, 0, 0, 1)"
|
4635
|
-
}
|
4361
|
+
},
|
4362
|
+
feedback: "clone"
|
4636
4363
|
});
|
4637
|
-
const thisIsDragging = status === "dragging";
|
4638
4364
|
const ref = (0, import_react25.useRef)(null);
|
4639
4365
|
const refSetter = (0, import_react25.useCallback)(
|
4640
4366
|
(el) => {
|
@@ -4774,18 +4500,12 @@ var DraggableComponent = ({
|
|
4774
4500
|
el.addEventListener("click", onClick);
|
4775
4501
|
el.addEventListener("mouseover", _onMouseOver);
|
4776
4502
|
el.addEventListener("mouseout", _onMouseOut);
|
4777
|
-
if (thisIsDragging) {
|
4778
|
-
el.setAttribute("data-puck-dragging", "");
|
4779
|
-
} else {
|
4780
|
-
el.removeAttribute("data-puck-dragging");
|
4781
|
-
}
|
4782
4503
|
return () => {
|
4783
4504
|
el.removeAttribute("data-puck-component");
|
4784
4505
|
el.removeAttribute("data-puck-dnd");
|
4785
4506
|
el.removeEventListener("click", onClick);
|
4786
4507
|
el.removeEventListener("mouseover", _onMouseOver);
|
4787
4508
|
el.removeEventListener("mouseout", _onMouseOut);
|
4788
|
-
el.removeAttribute("data-puck-dragging");
|
4789
4509
|
};
|
4790
4510
|
}, [
|
4791
4511
|
ref,
|
@@ -4937,6 +4657,9 @@ var DraggableComponent = ({
|
|
4937
4657
|
init_react_import();
|
4938
4658
|
var styles_module_default12 = { "DropZone": "_DropZone_3dmev_1", "DropZone--hasChildren": "_DropZone--hasChildren_3dmev_11", "DropZone--userIsDragging": "_DropZone--userIsDragging_3dmev_19", "DropZone--isAreaSelected": "_DropZone--isAreaSelected_3dmev_23", "DropZone--hoveringOverArea": "_DropZone--hoveringOverArea_3dmev_24", "DropZone--isRootZone": "_DropZone--isRootZone_3dmev_24", "DropZone--isDestination": "_DropZone--isDestination_3dmev_34", "DropZone-item": "_DropZone-item_3dmev_46", "DropZone-hitbox": "_DropZone-hitbox_3dmev_50", "DropZone--isEnabled": "_DropZone--isEnabled_3dmev_58", "DropZone--isAnimating": "_DropZone--isAnimating_3dmev_67" };
|
4939
4659
|
|
4660
|
+
// components/DropZone/index.tsx
|
4661
|
+
var import_react35 = require("@dnd-kit/react");
|
4662
|
+
|
4940
4663
|
// components/DropZone/lib/use-min-empty-height.ts
|
4941
4664
|
init_react_import();
|
4942
4665
|
var import_react26 = require("react");
|
@@ -5150,43 +4873,70 @@ var import_react33 = __toESM(require("react"));
|
|
5150
4873
|
|
5151
4874
|
// components/SlotRender/index.tsx
|
5152
4875
|
init_react_import();
|
4876
|
+
|
4877
|
+
// components/SlotRender/server.tsx
|
4878
|
+
init_react_import();
|
5153
4879
|
var import_react32 = require("react");
|
4880
|
+
|
4881
|
+
// components/ServerRender/index.tsx
|
4882
|
+
init_react_import();
|
5154
4883
|
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
|
-
|
4884
|
+
function DropZoneRender({
|
4885
|
+
zone,
|
4886
|
+
data,
|
4887
|
+
areaId = "root",
|
4888
|
+
config,
|
4889
|
+
metadata = {}
|
4890
|
+
}) {
|
4891
|
+
let zoneCompound = rootDroppableId;
|
4892
|
+
let content = (data == null ? void 0 : data.content) || [];
|
4893
|
+
if (!data || !config) {
|
4894
|
+
return null;
|
4895
|
+
}
|
4896
|
+
if (areaId !== rootAreaId && zone !== rootZone) {
|
4897
|
+
zoneCompound = `${areaId}:${zone}`;
|
4898
|
+
content = setupZone(data, zoneCompound).zones[zoneCompound];
|
4899
|
+
}
|
4900
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_jsx_runtime21.Fragment, { children: content.map((item) => {
|
4901
|
+
const Component = config.components[item.type];
|
4902
|
+
const props = __spreadProps(__spreadValues({}, item.props), {
|
4903
|
+
puck: {
|
4904
|
+
renderDropZone: ({ zone: zone2 }) => /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
4905
|
+
DropZoneRender,
|
4906
|
+
{
|
4907
|
+
zone: zone2,
|
4908
|
+
data,
|
4909
|
+
areaId: item.props.id,
|
4910
|
+
config,
|
4911
|
+
metadata
|
4912
|
+
}
|
4913
|
+
),
|
4914
|
+
metadata
|
4915
|
+
}
|
4916
|
+
});
|
4917
|
+
const propsWithSlots = useSlots(Component, props, (props2) => /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(SlotRenderPure, __spreadProps(__spreadValues({}, props2), { config, metadata })));
|
4918
|
+
if (Component) {
|
4919
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Component.render, __spreadValues({}, propsWithSlots), item.props.id);
|
5175
4920
|
}
|
5176
|
-
|
5177
|
-
};
|
4921
|
+
return null;
|
4922
|
+
}) });
|
4923
|
+
}
|
4924
|
+
|
4925
|
+
// components/SlotRender/server.tsx
|
4926
|
+
var import_jsx_runtime22 = require("react/jsx-runtime");
|
4927
|
+
var SlotRenderPure = (props) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(SlotRender, __spreadValues({}, props));
|
5178
4928
|
var Item = ({
|
5179
4929
|
config,
|
5180
4930
|
item,
|
5181
4931
|
metadata
|
5182
4932
|
}) => {
|
5183
4933
|
const Component = config.components[item.type];
|
5184
|
-
const props = useSlots(Component, item.props, (slotProps) => /* @__PURE__ */ (0,
|
5185
|
-
return /* @__PURE__ */ (0,
|
4934
|
+
const props = useSlots(Component, item.props, (slotProps) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(SlotRenderPure, __spreadProps(__spreadValues({}, slotProps), { config, metadata })));
|
4935
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
5186
4936
|
Component.render,
|
5187
4937
|
__spreadProps(__spreadValues({}, props), {
|
5188
4938
|
puck: __spreadProps(__spreadValues({}, props.puck), {
|
5189
|
-
renderDropZone:
|
4939
|
+
renderDropZone: DropZoneRender,
|
5190
4940
|
metadata: metadata || {}
|
5191
4941
|
})
|
5192
4942
|
})
|
@@ -5194,11 +4944,11 @@ var Item = ({
|
|
5194
4944
|
};
|
5195
4945
|
var SlotRender = (0, import_react32.forwardRef)(
|
5196
4946
|
function SlotRenderInternal({ className, style, content, config, metadata }, ref) {
|
5197
|
-
return /* @__PURE__ */ (0,
|
4947
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className, style, ref, children: content.map((item) => {
|
5198
4948
|
if (!config.components[item.type]) {
|
5199
4949
|
return null;
|
5200
4950
|
}
|
5201
|
-
return /* @__PURE__ */ (0,
|
4951
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
5202
4952
|
Item,
|
5203
4953
|
{
|
5204
4954
|
config,
|
@@ -5211,8 +4961,33 @@ var SlotRender = (0, import_react32.forwardRef)(
|
|
5211
4961
|
}
|
5212
4962
|
);
|
5213
4963
|
|
4964
|
+
// components/SlotRender/index.tsx
|
4965
|
+
var import_jsx_runtime23 = require("react/jsx-runtime");
|
4966
|
+
var ContextSlotRender = ({
|
4967
|
+
componentId,
|
4968
|
+
zone
|
4969
|
+
}) => {
|
4970
|
+
const config = useAppStore((s) => s.config);
|
4971
|
+
const metadata = useAppStore((s) => s.metadata);
|
4972
|
+
const slotContent = useAppStore(
|
4973
|
+
(s) => {
|
4974
|
+
var _a, _b;
|
4975
|
+
return (_b = (_a = s.state.indexes.nodes[componentId]) == null ? void 0 : _a.data.props[zone]) != null ? _b : null;
|
4976
|
+
}
|
4977
|
+
);
|
4978
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
4979
|
+
SlotRenderPure,
|
4980
|
+
{
|
4981
|
+
content: slotContent,
|
4982
|
+
zone,
|
4983
|
+
config,
|
4984
|
+
metadata
|
4985
|
+
}
|
4986
|
+
);
|
4987
|
+
};
|
4988
|
+
|
5214
4989
|
// components/Render/index.tsx
|
5215
|
-
var
|
4990
|
+
var import_jsx_runtime24 = require("react/jsx-runtime");
|
5216
4991
|
var renderContext = import_react33.default.createContext({
|
5217
4992
|
config: { components: {} },
|
5218
4993
|
data: { root: {}, content: [] },
|
@@ -5241,7 +5016,7 @@ function Render({
|
|
5241
5016
|
editMode: false,
|
5242
5017
|
id: "puck-root"
|
5243
5018
|
});
|
5244
|
-
const propsWithSlots = useSlots(config.root, pageProps, (props) => /* @__PURE__ */ (0,
|
5019
|
+
const propsWithSlots = useSlots(config.root, pageProps, (props) => /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(SlotRender, __spreadProps(__spreadValues({}, props), { config, metadata })));
|
5245
5020
|
const nextContextValue = (0, import_react33.useMemo)(
|
5246
5021
|
() => ({
|
5247
5022
|
mode: "render",
|
@@ -5250,17 +5025,17 @@ function Render({
|
|
5250
5025
|
[]
|
5251
5026
|
);
|
5252
5027
|
if ((_a = config.root) == null ? void 0 : _a.render) {
|
5253
|
-
return /* @__PURE__ */ (0,
|
5028
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(renderContext.Provider, { value: { config, data: defaultedData, metadata }, children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(DropZoneProvider, { value: nextContextValue, children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(config.root.render, __spreadProps(__spreadValues({}, propsWithSlots), { children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(DropZoneRenderPure, { zone: rootZone }) })) }) });
|
5254
5029
|
}
|
5255
|
-
return /* @__PURE__ */ (0,
|
5030
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(renderContext.Provider, { value: { config, data: defaultedData, metadata }, children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(DropZoneProvider, { value: nextContextValue, children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(DropZoneRenderPure, { zone: rootZone }) }) });
|
5256
5031
|
}
|
5257
5032
|
|
5258
5033
|
// components/DropZone/index.tsx
|
5259
|
-
var
|
5034
|
+
var import_jsx_runtime25 = require("react/jsx-runtime");
|
5260
5035
|
var getClassName17 = get_class_name_factory_default("DropZone", styles_module_default12);
|
5261
5036
|
var getRandomColor = () => `#${Math.floor(Math.random() * 16777215).toString(16)}`;
|
5262
5037
|
var RENDER_DEBUG = false;
|
5263
|
-
var DropZoneEditPure = (props) => /* @__PURE__ */ (0,
|
5038
|
+
var DropZoneEditPure = (props) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(DropZoneEdit, __spreadValues({}, props));
|
5264
5039
|
var DropZoneChild = ({
|
5265
5040
|
zoneCompound,
|
5266
5041
|
componentId,
|
@@ -5320,7 +5095,7 @@ var DropZoneChild = ({
|
|
5320
5095
|
let label = (_b = (_a = componentConfig == null ? void 0 : componentConfig.label) != null ? _a : item == null ? void 0 : item.type.toString()) != null ? _b : "Component";
|
5321
5096
|
const renderPreview = (0, import_react34.useMemo)(
|
5322
5097
|
() => function Preview4() {
|
5323
|
-
return /* @__PURE__ */ (0,
|
5098
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(DrawerItemInner, { name: label, children: overrides.componentItem });
|
5324
5099
|
},
|
5325
5100
|
[componentId, label, overrides]
|
5326
5101
|
);
|
@@ -5336,12 +5111,12 @@ var DropZoneChild = ({
|
|
5336
5111
|
componentConfig,
|
5337
5112
|
defaultsProps,
|
5338
5113
|
DropZoneEditPure,
|
5339
|
-
(slotProps) => /* @__PURE__ */ (0,
|
5114
|
+
(slotProps) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(ContextSlotRender, { componentId, zone: slotProps.zone }),
|
5340
5115
|
nodeReadOnly,
|
5341
5116
|
isLoading
|
5342
5117
|
);
|
5343
5118
|
if (!item) return;
|
5344
|
-
let Render2 = componentConfig ? componentConfig.render : () => /* @__PURE__ */ (0,
|
5119
|
+
let Render2 = componentConfig ? componentConfig.render : () => /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { style: { padding: 48, textAlign: "center" }, children: [
|
5345
5120
|
"No configuration for ",
|
5346
5121
|
item.type
|
5347
5122
|
] });
|
@@ -5350,7 +5125,7 @@ var DropZoneChild = ({
|
|
5350
5125
|
if (isPreview) {
|
5351
5126
|
Render2 = renderPreview;
|
5352
5127
|
}
|
5353
|
-
return /* @__PURE__ */ (0,
|
5128
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
5354
5129
|
DraggableComponent,
|
5355
5130
|
{
|
5356
5131
|
id: componentId,
|
@@ -5365,14 +5140,14 @@ var DropZoneChild = ({
|
|
5365
5140
|
autoDragAxis: dragAxis,
|
5366
5141
|
userDragAxis: collisionAxis,
|
5367
5142
|
inDroppableZone,
|
5368
|
-
children: (dragRef) => (componentConfig == null ? void 0 : componentConfig.inline) && !isPreview ? /* @__PURE__ */ (0,
|
5143
|
+
children: (dragRef) => (componentConfig == null ? void 0 : componentConfig.inline) && !isPreview ? /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_jsx_runtime25.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
5369
5144
|
Render2,
|
5370
5145
|
__spreadProps(__spreadValues({}, defaultedPropsWithSlots), {
|
5371
5146
|
puck: __spreadProps(__spreadValues({}, defaultedPropsWithSlots.puck), {
|
5372
5147
|
dragRef
|
5373
5148
|
})
|
5374
5149
|
})
|
5375
|
-
) }) : /* @__PURE__ */ (0,
|
5150
|
+
) }) : /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { ref: dragRef, children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Render2, __spreadValues({}, defaultedPropsWithSlots)) })
|
5376
5151
|
}
|
5377
5152
|
);
|
5378
5153
|
};
|
@@ -5436,11 +5211,6 @@ var DropZoneEdit = (0, import_react34.forwardRef)(
|
|
5436
5211
|
);
|
5437
5212
|
(0, import_react34.useEffect)(() => {
|
5438
5213
|
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
5214
|
if (ctx == null ? void 0 : ctx.registerZone) {
|
5445
5215
|
ctx == null ? void 0 : ctx.registerZone(zoneCompound);
|
5446
5216
|
}
|
@@ -5451,6 +5221,15 @@ var DropZoneEdit = (0, import_react34.forwardRef)(
|
|
5451
5221
|
};
|
5452
5222
|
}
|
5453
5223
|
}, [zoneType]);
|
5224
|
+
(0, import_react34.useEffect)(() => {
|
5225
|
+
if (zoneType === "dropzone") {
|
5226
|
+
if (zoneCompound !== rootDroppableId) {
|
5227
|
+
console.warn(
|
5228
|
+
"DropZones have been deprecated in favor of slot fields and will be removed in a future version of Puck. Please see the migration guide: https://www.puckeditor.com/docs/guides/migrations/dropzones-to-slots"
|
5229
|
+
);
|
5230
|
+
}
|
5231
|
+
}
|
5232
|
+
}, [zoneType]);
|
5454
5233
|
const contentIds = (0, import_react34.useMemo)(() => {
|
5455
5234
|
return zoneContentIds || [];
|
5456
5235
|
}, [zoneContentIds]);
|
@@ -5513,7 +5292,7 @@ var DropZoneEdit = (0, import_react34.forwardRef)(
|
|
5513
5292
|
path: path || []
|
5514
5293
|
}
|
5515
5294
|
};
|
5516
|
-
const { ref: dropRef } =
|
5295
|
+
const { ref: dropRef } = (0, import_react35.useDroppable)(droppableConfig);
|
5517
5296
|
const isAreaSelected = useAppStore(
|
5518
5297
|
(s) => (s == null ? void 0 : s.selectedItem) && areaId === (s == null ? void 0 : s.selectedItem.props.id)
|
5519
5298
|
);
|
@@ -5523,7 +5302,7 @@ var DropZoneEdit = (0, import_react34.forwardRef)(
|
|
5523
5302
|
userMinEmptyHeight,
|
5524
5303
|
ref
|
5525
5304
|
});
|
5526
|
-
return /* @__PURE__ */ (0,
|
5305
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
5527
5306
|
"div",
|
5528
5307
|
{
|
5529
5308
|
className: `${getClassName17({
|
@@ -5545,7 +5324,7 @@ var DropZoneEdit = (0, import_react34.forwardRef)(
|
|
5545
5324
|
backgroundColor: RENDER_DEBUG ? getRandomColor() : style == null ? void 0 : style.backgroundColor
|
5546
5325
|
}),
|
5547
5326
|
children: contentIdsWithPreview.map((componentId, i) => {
|
5548
|
-
return /* @__PURE__ */ (0,
|
5327
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
5549
5328
|
DropZoneChildMemo,
|
5550
5329
|
{
|
5551
5330
|
zoneCompound,
|
@@ -5570,7 +5349,7 @@ var DropZoneRenderItem = ({
|
|
5570
5349
|
metadata
|
5571
5350
|
}) => {
|
5572
5351
|
const Component = config.components[item.type];
|
5573
|
-
const props = useSlots(Component, item.props, (slotProps) => /* @__PURE__ */ (0,
|
5352
|
+
const props = useSlots(Component, item.props, (slotProps) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(SlotRenderPure, __spreadProps(__spreadValues({}, slotProps), { config, metadata })));
|
5574
5353
|
const nextContextValue = (0, import_react34.useMemo)(
|
5575
5354
|
() => ({
|
5576
5355
|
areaId: props.id,
|
@@ -5578,7 +5357,7 @@ var DropZoneRenderItem = ({
|
|
5578
5357
|
}),
|
5579
5358
|
[props]
|
5580
5359
|
);
|
5581
|
-
return /* @__PURE__ */ (0,
|
5360
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(DropZoneProvider, { value: nextContextValue, children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
5582
5361
|
Component.render,
|
5583
5362
|
__spreadProps(__spreadValues({}, props), {
|
5584
5363
|
puck: __spreadProps(__spreadValues({}, props.puck), {
|
@@ -5588,8 +5367,8 @@ var DropZoneRenderItem = ({
|
|
5588
5367
|
})
|
5589
5368
|
) }, props.id);
|
5590
5369
|
};
|
5591
|
-
var DropZoneRenderPure = (props) => /* @__PURE__ */ (0,
|
5592
|
-
var
|
5370
|
+
var DropZoneRenderPure = (props) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(DropZoneRender2, __spreadValues({}, props));
|
5371
|
+
var DropZoneRender2 = (0, import_react34.forwardRef)(
|
5593
5372
|
function DropZoneRenderInternal({ className, style, zone }, ref) {
|
5594
5373
|
const ctx = (0, import_react34.useContext)(dropZoneContext);
|
5595
5374
|
const { areaId = "root" } = ctx || {};
|
@@ -5615,10 +5394,10 @@ var DropZoneRender = (0, import_react34.forwardRef)(
|
|
5615
5394
|
zoneCompound = `${areaId}:${zone}`;
|
5616
5395
|
content = setupZone(data, zoneCompound).zones[zoneCompound];
|
5617
5396
|
}
|
5618
|
-
return /* @__PURE__ */ (0,
|
5397
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className, style, ref, children: content.map((item) => {
|
5619
5398
|
const Component = config.components[item.type];
|
5620
5399
|
if (Component) {
|
5621
|
-
return /* @__PURE__ */ (0,
|
5400
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
5622
5401
|
DropZoneRenderItem,
|
5623
5402
|
{
|
5624
5403
|
config,
|
@@ -5632,21 +5411,20 @@ var DropZoneRender = (0, import_react34.forwardRef)(
|
|
5632
5411
|
}) });
|
5633
5412
|
}
|
5634
5413
|
);
|
5635
|
-
var DropZonePure = (props) => /* @__PURE__ */ (0,
|
5414
|
+
var DropZonePure = (props) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(DropZone, __spreadValues({}, props));
|
5636
5415
|
var DropZone = (0, import_react34.forwardRef)(
|
5637
5416
|
function DropZone2(props, ref) {
|
5638
5417
|
const ctx = (0, import_react34.useContext)(dropZoneContext);
|
5639
5418
|
if ((ctx == null ? void 0 : ctx.mode) === "edit") {
|
5640
|
-
return /* @__PURE__ */ (0,
|
5419
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_jsx_runtime25.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(DropZoneEdit, __spreadProps(__spreadValues({}, props), { ref })) });
|
5641
5420
|
}
|
5642
|
-
return /* @__PURE__ */ (0,
|
5421
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_jsx_runtime25.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(DropZoneRender2, __spreadProps(__spreadValues({}, props), { ref })) });
|
5643
5422
|
}
|
5644
5423
|
);
|
5645
5424
|
|
5646
5425
|
// lib/dnd/NestedDroppablePlugin.ts
|
5647
5426
|
init_react_import();
|
5648
|
-
var
|
5649
|
-
var import_state2 = require("@dnd-kit/state");
|
5427
|
+
var import_abstract9 = require("@dnd-kit/abstract");
|
5650
5428
|
|
5651
5429
|
// lib/throttle.ts
|
5652
5430
|
init_react_import();
|
@@ -5695,7 +5473,7 @@ var GlobalPosition = class {
|
|
5695
5473
|
var _a;
|
5696
5474
|
this.target = target;
|
5697
5475
|
this.original = original;
|
5698
|
-
this.frameEl = document.querySelector("iframe");
|
5476
|
+
this.frameEl = document.querySelector("iframe#preview-frame");
|
5699
5477
|
if (this.frameEl) {
|
5700
5478
|
this.frameRect = this.frameEl.getBoundingClientRect();
|
5701
5479
|
this.scaleFactor = this.frameRect.width / (((_a = this.frameEl.contentWindow) == null ? void 0 : _a.innerWidth) || 1);
|
@@ -5775,6 +5553,7 @@ var getZoneId2 = (candidate) => {
|
|
5775
5553
|
}
|
5776
5554
|
return id;
|
5777
5555
|
};
|
5556
|
+
var BUFFER = 6;
|
5778
5557
|
var getPointerCollisions = (position, manager) => {
|
5779
5558
|
const candidates = [];
|
5780
5559
|
let elements = position.target.ownerDocument.elementsFromPoint(
|
@@ -5798,13 +5577,26 @@ var getPointerCollisions = (position, manager) => {
|
|
5798
5577
|
for (let i = 0; i < elements.length; i++) {
|
5799
5578
|
const element = elements[i];
|
5800
5579
|
const dropzoneId = element.getAttribute("data-puck-dropzone");
|
5580
|
+
const id = element.getAttribute("data-puck-dnd");
|
5581
|
+
const isVoid = element.hasAttribute("data-puck-dnd-void");
|
5582
|
+
if (BUFFER && (dropzoneId || id) && !isVoid) {
|
5583
|
+
const box = element.getBoundingClientRect();
|
5584
|
+
const contractedBox = {
|
5585
|
+
left: box.left + BUFFER,
|
5586
|
+
right: box.right - BUFFER,
|
5587
|
+
top: box.top + BUFFER,
|
5588
|
+
bottom: box.bottom - BUFFER
|
5589
|
+
};
|
5590
|
+
if (position.frame.x < contractedBox.left || position.frame.x > contractedBox.right || position.frame.y > contractedBox.bottom || position.frame.y < contractedBox.top) {
|
5591
|
+
continue;
|
5592
|
+
}
|
5593
|
+
}
|
5801
5594
|
if (dropzoneId) {
|
5802
5595
|
const droppable = manager.registry.droppables.get(dropzoneId);
|
5803
5596
|
if (droppable) {
|
5804
5597
|
candidates.push(droppable);
|
5805
5598
|
}
|
5806
5599
|
}
|
5807
|
-
const id = element.getAttribute("data-puck-dnd");
|
5808
5600
|
if (id) {
|
5809
5601
|
const droppable = manager.registry.droppables.get(id);
|
5810
5602
|
if (droppable) {
|
@@ -5858,17 +5650,17 @@ var findDeepestCandidate = (position, manager) => {
|
|
5858
5650
|
return { zone, area };
|
5859
5651
|
}
|
5860
5652
|
return {
|
5861
|
-
zone:
|
5862
|
-
area:
|
5653
|
+
zone: rootDroppableId,
|
5654
|
+
area: rootAreaId
|
5863
5655
|
};
|
5864
5656
|
};
|
5865
|
-
var createNestedDroppablePlugin = ({ onChange }, id) => class NestedDroppablePlugin extends
|
5657
|
+
var createNestedDroppablePlugin = ({ onChange }, id) => class NestedDroppablePlugin extends import_abstract9.Plugin {
|
5866
5658
|
constructor(manager, options) {
|
5867
5659
|
super(manager);
|
5868
5660
|
if (typeof window === "undefined") {
|
5869
5661
|
return;
|
5870
5662
|
}
|
5871
|
-
|
5663
|
+
this.registerEffect(() => {
|
5872
5664
|
const handleMove = (event) => {
|
5873
5665
|
const target = event instanceof BubbledPointerEvent ? event.originalTarget || event.target : event.target;
|
5874
5666
|
const position = new GlobalPosition(target, {
|
@@ -5892,12 +5684,12 @@ var createNestedDroppablePlugin = ({ onChange }, id) => class NestedDroppablePlu
|
|
5892
5684
|
capture: true
|
5893
5685
|
// dndkit's PointerSensor prevents propagation during drag
|
5894
5686
|
});
|
5895
|
-
|
5687
|
+
const cleanup = () => {
|
5896
5688
|
document.body.removeEventListener("pointermove", handlePointerMove, {
|
5897
5689
|
capture: true
|
5898
5690
|
});
|
5899
|
-
cleanupEffect();
|
5900
5691
|
};
|
5692
|
+
return cleanup;
|
5901
5693
|
});
|
5902
5694
|
}
|
5903
5695
|
};
|
@@ -5957,14 +5749,14 @@ function getDeepDir(el) {
|
|
5957
5749
|
}
|
5958
5750
|
|
5959
5751
|
// components/DragDropContext/index.tsx
|
5960
|
-
var
|
5752
|
+
var import_jsx_runtime26 = require("react/jsx-runtime");
|
5961
5753
|
var DEBUG3 = false;
|
5962
|
-
var dragListenerContext = (0,
|
5754
|
+
var dragListenerContext = (0, import_react37.createContext)({
|
5963
5755
|
dragListeners: {}
|
5964
5756
|
});
|
5965
5757
|
function useDragListener(type, fn, deps = []) {
|
5966
|
-
const { setDragListeners } = (0,
|
5967
|
-
(0,
|
5758
|
+
const { setDragListeners } = (0, import_react37.useContext)(dragListenerContext);
|
5759
|
+
(0, import_react37.useEffect)(() => {
|
5968
5760
|
if (setDragListeners) {
|
5969
5761
|
setDragListeners((old) => __spreadProps(__spreadValues({}, old), {
|
5970
5762
|
[type]: [...old[type] || [], fn]
|
@@ -5974,8 +5766,8 @@ function useDragListener(type, fn, deps = []) {
|
|
5974
5766
|
}
|
5975
5767
|
var AREA_CHANGE_DEBOUNCE_MS = 100;
|
5976
5768
|
var useTempDisableFallback = (timeout3) => {
|
5977
|
-
const lastFallbackDisable = (0,
|
5978
|
-
return (0,
|
5769
|
+
const lastFallbackDisable = (0, import_react37.useRef)(null);
|
5770
|
+
return (0, import_react37.useCallback)((manager) => {
|
5979
5771
|
collisionStore.setState({ fallbackEnabled: false });
|
5980
5772
|
const fallbackId = generateId();
|
5981
5773
|
lastFallbackDisable.current = fallbackId;
|
@@ -5994,9 +5786,9 @@ var DragDropContextClient = ({
|
|
5994
5786
|
const dispatch = useAppStore((s) => s.dispatch);
|
5995
5787
|
const appStore = useAppStoreApi();
|
5996
5788
|
const id = useSafeId();
|
5997
|
-
const debouncedParamsRef = (0,
|
5789
|
+
const debouncedParamsRef = (0, import_react37.useRef)(null);
|
5998
5790
|
const tempDisableFallback = useTempDisableFallback(100);
|
5999
|
-
const [zoneStore] = (0,
|
5791
|
+
const [zoneStore] = (0, import_react37.useState)(
|
6000
5792
|
() => (0, import_zustand5.createStore)(() => ({
|
6001
5793
|
zoneDepthIndex: {},
|
6002
5794
|
nextZoneDepthIndex: {},
|
@@ -6006,7 +5798,7 @@ var DragDropContextClient = ({
|
|
6006
5798
|
previewIndex: {}
|
6007
5799
|
}))
|
6008
5800
|
);
|
6009
|
-
const getChanged2 = (0,
|
5801
|
+
const getChanged2 = (0, import_react37.useCallback)(
|
6010
5802
|
(params, id2) => {
|
6011
5803
|
const { zoneDepthIndex = {}, areaDepthIndex = {} } = zoneStore.getState() || {};
|
6012
5804
|
const stateHasZone = Object.keys(zoneDepthIndex).length > 0;
|
@@ -6027,7 +5819,7 @@ var DragDropContextClient = ({
|
|
6027
5819
|
},
|
6028
5820
|
[zoneStore]
|
6029
5821
|
);
|
6030
|
-
const setDeepestAndCollide = (0,
|
5822
|
+
const setDeepestAndCollide = (0, import_react37.useCallback)(
|
6031
5823
|
(params, manager) => {
|
6032
5824
|
const { zoneChanged, areaChanged } = getChanged2(params, id);
|
6033
5825
|
if (!zoneChanged && !areaChanged) return;
|
@@ -6051,7 +5843,7 @@ var DragDropContextClient = ({
|
|
6051
5843
|
setDeepestDb.cancel();
|
6052
5844
|
debouncedParamsRef.current = null;
|
6053
5845
|
};
|
6054
|
-
(0,
|
5846
|
+
(0, import_react37.useEffect)(() => {
|
6055
5847
|
if (DEBUG3) {
|
6056
5848
|
zoneStore.subscribe(
|
6057
5849
|
(s) => {
|
@@ -6065,7 +5857,7 @@ var DragDropContextClient = ({
|
|
6065
5857
|
);
|
6066
5858
|
}
|
6067
5859
|
}, []);
|
6068
|
-
const [plugins] = (0,
|
5860
|
+
const [plugins] = (0, import_react37.useState)(() => [
|
6069
5861
|
...disableAutoScroll ? import_dom.defaultPreset.plugins.filter((plugin) => plugin !== import_dom.AutoScroller) : import_dom.defaultPreset.plugins,
|
6070
5862
|
createNestedDroppablePlugin(
|
6071
5863
|
{
|
@@ -6113,10 +5905,10 @@ var DragDropContextClient = ({
|
|
6113
5905
|
)
|
6114
5906
|
]);
|
6115
5907
|
const sensors = useSensors();
|
6116
|
-
const [dragListeners, setDragListeners] = (0,
|
6117
|
-
const dragMode = (0,
|
6118
|
-
const initialSelector = (0,
|
6119
|
-
const nextContextValue = (0,
|
5908
|
+
const [dragListeners, setDragListeners] = (0, import_react37.useState)({});
|
5909
|
+
const dragMode = (0, import_react37.useRef)(null);
|
5910
|
+
const initialSelector = (0, import_react37.useRef)(void 0);
|
5911
|
+
const nextContextValue = (0, import_react37.useMemo)(
|
6120
5912
|
() => ({
|
6121
5913
|
mode: "edit",
|
6122
5914
|
areaId: "root",
|
@@ -6124,15 +5916,15 @@ var DragDropContextClient = ({
|
|
6124
5916
|
}),
|
6125
5917
|
[]
|
6126
5918
|
);
|
6127
|
-
return /* @__PURE__ */ (0,
|
5919
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { id, children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
6128
5920
|
dragListenerContext.Provider,
|
6129
5921
|
{
|
6130
5922
|
value: {
|
6131
5923
|
dragListeners,
|
6132
5924
|
setDragListeners
|
6133
5925
|
},
|
6134
|
-
children: /* @__PURE__ */ (0,
|
6135
|
-
|
5926
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
5927
|
+
import_react36.DragDropProvider,
|
6136
5928
|
{
|
6137
5929
|
plugins,
|
6138
5930
|
sensors,
|
@@ -6199,7 +5991,7 @@ var DragDropContextClient = ({
|
|
6199
5991
|
}, 250);
|
6200
5992
|
},
|
6201
5993
|
onDragOver: (event, manager) => {
|
6202
|
-
var _a, _b, _c, _d
|
5994
|
+
var _a, _b, _c, _d;
|
6203
5995
|
event.preventDefault();
|
6204
5996
|
const draggedItem = (_a = zoneStore.getState()) == null ? void 0 : _a.draggedItem;
|
6205
5997
|
if (!draggedItem) return;
|
@@ -6217,7 +6009,7 @@ var DragDropContextClient = ({
|
|
6217
6009
|
const targetData = target.data;
|
6218
6010
|
targetZone = targetData.zone;
|
6219
6011
|
targetIndex = targetData.index;
|
6220
|
-
const collisionData = (
|
6012
|
+
const collisionData = (_b = manager.collisionObserver.collisions[0]) == null ? void 0 : _b.data;
|
6221
6013
|
const dir = getDeepDir(target.element);
|
6222
6014
|
const collisionPosition = (collisionData == null ? void 0 : collisionData.direction) === "up" || dir === "ltr" && (collisionData == null ? void 0 : collisionData.direction) === "left" || dir === "rtl" && (collisionData == null ? void 0 : collisionData.direction) === "right" ? "before" : "after";
|
6223
6015
|
if (targetIndex >= sourceIndex && sourceZone === targetZone) {
|
@@ -6230,7 +6022,7 @@ var DragDropContextClient = ({
|
|
6230
6022
|
targetZone = target.id.toString();
|
6231
6023
|
targetIndex = 0;
|
6232
6024
|
}
|
6233
|
-
const path = ((
|
6025
|
+
const path = ((_c = appStore.getState().state.indexes.nodes[target.id]) == null ? void 0 : _c.path) || [];
|
6234
6026
|
if (targetId === sourceId || path.find((path2) => {
|
6235
6027
|
const [pathId] = path2.split(":");
|
6236
6028
|
return pathId === sourceId;
|
@@ -6276,16 +6068,12 @@ var DragDropContextClient = ({
|
|
6276
6068
|
});
|
6277
6069
|
}
|
6278
6070
|
}
|
6279
|
-
(
|
6071
|
+
(_d = dragListeners.dragover) == null ? void 0 : _d.forEach((fn) => {
|
6280
6072
|
fn(event, manager);
|
6281
6073
|
});
|
6282
6074
|
},
|
6283
6075
|
onDragStart: (event, manager) => {
|
6284
6076
|
var _a;
|
6285
|
-
dispatch({
|
6286
|
-
type: "setUi",
|
6287
|
-
ui: { itemSelector: null, isDragging: true }
|
6288
|
-
});
|
6289
6077
|
const { source } = event.operation;
|
6290
6078
|
if (source && source.type !== "void") {
|
6291
6079
|
const sourceData = source.data;
|
@@ -6316,12 +6104,12 @@ var DragDropContextClient = ({
|
|
6316
6104
|
},
|
6317
6105
|
onBeforeDragStart: (event) => {
|
6318
6106
|
var _a;
|
6319
|
-
const isNewComponent = ((_a = event.operation.source) == null ? void 0 : _a.
|
6107
|
+
const isNewComponent = ((_a = event.operation.source) == null ? void 0 : _a.type) === "drawer";
|
6320
6108
|
dragMode.current = isNewComponent ? "new" : "existing";
|
6321
6109
|
initialSelector.current = void 0;
|
6322
6110
|
zoneStore.setState({ draggedItem: event.operation.source });
|
6323
6111
|
},
|
6324
|
-
children: /* @__PURE__ */ (0,
|
6112
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(ZoneStoreProvider, { store: zoneStore, children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(DropZoneProvider, { value: nextContextValue, children }) })
|
6325
6113
|
}
|
6326
6114
|
)
|
6327
6115
|
}
|
@@ -6335,11 +6123,12 @@ var DragDropContext = ({
|
|
6335
6123
|
if (status === "LOADING") {
|
6336
6124
|
return children;
|
6337
6125
|
}
|
6338
|
-
return /* @__PURE__ */ (0,
|
6126
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(DragDropContextClient, { disableAutoScroll, children });
|
6339
6127
|
};
|
6340
6128
|
|
6341
6129
|
// components/Drawer/index.tsx
|
6342
|
-
var
|
6130
|
+
var import_react39 = require("@dnd-kit/react");
|
6131
|
+
var import_jsx_runtime27 = require("react/jsx-runtime");
|
6343
6132
|
var getClassName18 = get_class_name_factory_default("Drawer", styles_module_default10);
|
6344
6133
|
var getClassNameItem2 = get_class_name_factory_default("DrawerItem", styles_module_default10);
|
6345
6134
|
var DrawerItemInner = ({
|
@@ -6349,11 +6138,11 @@ var DrawerItemInner = ({
|
|
6349
6138
|
dragRef,
|
6350
6139
|
isDragDisabled
|
6351
6140
|
}) => {
|
6352
|
-
const CustomInner = (0,
|
6353
|
-
() => children || (({ children: children2 }) => /* @__PURE__ */ (0,
|
6141
|
+
const CustomInner = (0, import_react38.useMemo)(
|
6142
|
+
() => children || (({ children: children2 }) => /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: getClassNameItem2("default"), children: children2 })),
|
6354
6143
|
[children]
|
6355
6144
|
);
|
6356
|
-
return /* @__PURE__ */ (0,
|
6145
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
6357
6146
|
"div",
|
6358
6147
|
{
|
6359
6148
|
className: getClassNameItem2({ disabled: isDragDisabled }),
|
@@ -6361,9 +6150,9 @@ var DrawerItemInner = ({
|
|
6361
6150
|
onMouseDown: (e) => e.preventDefault(),
|
6362
6151
|
"data-testid": dragRef ? `drawer-item:${name}` : "",
|
6363
6152
|
"data-puck-drawer-item": true,
|
6364
|
-
children: /* @__PURE__ */ (0,
|
6365
|
-
/* @__PURE__ */ (0,
|
6366
|
-
/* @__PURE__ */ (0,
|
6153
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(CustomInner, { name, children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: getClassNameItem2("draggableWrapper"), children: /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { className: getClassNameItem2("draggable"), children: [
|
6154
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: getClassNameItem2("name"), children: label != null ? label : name }),
|
6155
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: getClassNameItem2("icon"), children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(DragIcon, {}) })
|
6367
6156
|
] }) }) })
|
6368
6157
|
}
|
6369
6158
|
);
|
@@ -6375,14 +6164,15 @@ var DrawerItemDraggable = ({
|
|
6375
6164
|
id,
|
6376
6165
|
isDragDisabled
|
6377
6166
|
}) => {
|
6378
|
-
const { ref } =
|
6167
|
+
const { ref } = (0, import_react39.useDraggable)({
|
6379
6168
|
id,
|
6380
|
-
data: {
|
6381
|
-
disabled: isDragDisabled
|
6169
|
+
data: { componentType: name },
|
6170
|
+
disabled: isDragDisabled,
|
6171
|
+
type: "drawer"
|
6382
6172
|
});
|
6383
|
-
return /* @__PURE__ */ (0,
|
6384
|
-
/* @__PURE__ */ (0,
|
6385
|
-
/* @__PURE__ */ (0,
|
6173
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { className: getClassName18("draggable"), children: [
|
6174
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: getClassName18("draggableBg"), children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(DrawerItemInner, { name, label, children }) }),
|
6175
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: getClassName18("draggableFg"), children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
6386
6176
|
DrawerItemInner,
|
6387
6177
|
{
|
6388
6178
|
name,
|
@@ -6403,7 +6193,7 @@ var DrawerItem = ({
|
|
6403
6193
|
isDragDisabled
|
6404
6194
|
}) => {
|
6405
6195
|
const resolvedId = id || name;
|
6406
|
-
const [dynamicId, setDynamicId] = (0,
|
6196
|
+
const [dynamicId, setDynamicId] = (0, import_react38.useState)(generateId(resolvedId));
|
6407
6197
|
if (typeof index !== "undefined") {
|
6408
6198
|
console.error(
|
6409
6199
|
"Warning: The `index` prop on Drawer.Item is deprecated and no longer required."
|
@@ -6416,7 +6206,7 @@ var DrawerItem = ({
|
|
6416
6206
|
},
|
6417
6207
|
[resolvedId]
|
6418
6208
|
);
|
6419
|
-
return /* @__PURE__ */ (0,
|
6209
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
6420
6210
|
DrawerItemDraggable,
|
6421
6211
|
{
|
6422
6212
|
name,
|
@@ -6443,19 +6233,20 @@ var Drawer = ({
|
|
6443
6233
|
);
|
6444
6234
|
}
|
6445
6235
|
const id = useSafeId();
|
6446
|
-
const { ref } =
|
6236
|
+
const { ref } = (0, import_react39.useDroppable)({
|
6447
6237
|
id,
|
6448
6238
|
type: "void",
|
6449
6239
|
collisionPriority: 0
|
6450
6240
|
// Never collide with this, but we use it so NestedDroppablePlugin respects the Drawer
|
6451
6241
|
});
|
6452
|
-
return /* @__PURE__ */ (0,
|
6242
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
6453
6243
|
"div",
|
6454
6244
|
{
|
6455
6245
|
className: getClassName18(),
|
6456
6246
|
ref,
|
6457
6247
|
"data-puck-dnd": id,
|
6458
6248
|
"data-puck-drawer": true,
|
6249
|
+
"data-puck-dnd-void": true,
|
6459
6250
|
children
|
6460
6251
|
}
|
6461
6252
|
);
|
@@ -6464,7 +6255,7 @@ Drawer.Item = DrawerItem;
|
|
6464
6255
|
|
6465
6256
|
// components/Puck/index.tsx
|
6466
6257
|
init_react_import();
|
6467
|
-
var
|
6258
|
+
var import_react54 = require("react");
|
6468
6259
|
|
6469
6260
|
// components/SidebarSection/index.tsx
|
6470
6261
|
init_react_import();
|
@@ -6475,7 +6266,7 @@ var styles_module_default13 = { "SidebarSection": "_SidebarSection_8boj8_1", "Si
|
|
6475
6266
|
|
6476
6267
|
// lib/use-breadcrumbs.ts
|
6477
6268
|
init_react_import();
|
6478
|
-
var
|
6269
|
+
var import_react40 = require("react");
|
6479
6270
|
var useBreadcrumbs = (renderCount) => {
|
6480
6271
|
const selectedId = useAppStore((s) => {
|
6481
6272
|
var _a;
|
@@ -6487,7 +6278,7 @@ var useBreadcrumbs = (renderCount) => {
|
|
6487
6278
|
return (_a = s.state.indexes.nodes[selectedId]) == null ? void 0 : _a.path;
|
6488
6279
|
});
|
6489
6280
|
const appStore = useAppStoreApi();
|
6490
|
-
return (0,
|
6281
|
+
return (0, import_react40.useMemo)(() => {
|
6491
6282
|
const breadcrumbs = (path == null ? void 0 : path.map((zoneCompound) => {
|
6492
6283
|
var _a, _b, _c;
|
6493
6284
|
const [componentId] = zoneCompound.split(":");
|
@@ -6518,7 +6309,7 @@ var useBreadcrumbs = (renderCount) => {
|
|
6518
6309
|
};
|
6519
6310
|
|
6520
6311
|
// components/SidebarSection/index.tsx
|
6521
|
-
var
|
6312
|
+
var import_jsx_runtime28 = require("react/jsx-runtime");
|
6522
6313
|
var getClassName19 = get_class_name_factory_default("SidebarSection", styles_module_default13);
|
6523
6314
|
var SidebarSection = ({
|
6524
6315
|
children,
|
@@ -6531,15 +6322,15 @@ var SidebarSection = ({
|
|
6531
6322
|
}) => {
|
6532
6323
|
const setUi = useAppStore((s) => s.setUi);
|
6533
6324
|
const breadcrumbs = useBreadcrumbs(1);
|
6534
|
-
return /* @__PURE__ */ (0,
|
6325
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(
|
6535
6326
|
"div",
|
6536
6327
|
{
|
6537
6328
|
className: getClassName19({ noBorderTop, noPadding }),
|
6538
6329
|
style: { background },
|
6539
6330
|
children: [
|
6540
|
-
/* @__PURE__ */ (0,
|
6541
|
-
showBreadcrumbs ? breadcrumbs.map((breadcrumb, i) => /* @__PURE__ */ (0,
|
6542
|
-
/* @__PURE__ */ (0,
|
6331
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: getClassName19("title"), children: /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: getClassName19("breadcrumbs"), children: [
|
6332
|
+
showBreadcrumbs ? breadcrumbs.map((breadcrumb, i) => /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: getClassName19("breadcrumb"), children: [
|
6333
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
6543
6334
|
"button",
|
6544
6335
|
{
|
6545
6336
|
type: "button",
|
@@ -6548,12 +6339,12 @@ var SidebarSection = ({
|
|
6548
6339
|
children: breadcrumb.label
|
6549
6340
|
}
|
6550
6341
|
),
|
6551
|
-
/* @__PURE__ */ (0,
|
6342
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)(ChevronRight, { size: 16 })
|
6552
6343
|
] }, i)) : null,
|
6553
|
-
/* @__PURE__ */ (0,
|
6344
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: getClassName19("heading"), children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(Heading, { rank: "2", size: "xs", children: title }) })
|
6554
6345
|
] }) }),
|
6555
|
-
/* @__PURE__ */ (0,
|
6556
|
-
isLoading && /* @__PURE__ */ (0,
|
6346
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: getClassName19("content"), children }),
|
6347
|
+
isLoading && /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: getClassName19("loadingOverlay"), children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(Loader, { size: 32 }) })
|
6557
6348
|
]
|
6558
6349
|
}
|
6559
6350
|
);
|
@@ -6567,7 +6358,7 @@ init_react_import();
|
|
6567
6358
|
var styles_module_default14 = { "MenuBar": "_MenuBar_8pf8c_1", "MenuBar--menuOpen": "_MenuBar--menuOpen_8pf8c_14", "MenuBar-inner": "_MenuBar-inner_8pf8c_29", "MenuBar-history": "_MenuBar-history_8pf8c_45" };
|
6568
6359
|
|
6569
6360
|
// components/MenuBar/index.tsx
|
6570
|
-
var
|
6361
|
+
var import_jsx_runtime29 = require("react/jsx-runtime");
|
6571
6362
|
var getClassName20 = get_class_name_factory_default("MenuBar", styles_module_default14);
|
6572
6363
|
function MenuBar({
|
6573
6364
|
menuOpen = false,
|
@@ -6578,7 +6369,7 @@ function MenuBar({
|
|
6578
6369
|
const forward = useAppStore((s) => s.history.forward);
|
6579
6370
|
const hasFuture = useAppStore((s) => s.history.hasFuture());
|
6580
6371
|
const hasPast = useAppStore((s) => s.history.hasPast());
|
6581
|
-
return /* @__PURE__ */ (0,
|
6372
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
6582
6373
|
"div",
|
6583
6374
|
{
|
6584
6375
|
className: getClassName20({ menuOpen }),
|
@@ -6592,12 +6383,12 @@ function MenuBar({
|
|
6592
6383
|
setMenuOpen(false);
|
6593
6384
|
}
|
6594
6385
|
},
|
6595
|
-
children: /* @__PURE__ */ (0,
|
6596
|
-
/* @__PURE__ */ (0,
|
6597
|
-
/* @__PURE__ */ (0,
|
6598
|
-
/* @__PURE__ */ (0,
|
6386
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: getClassName20("inner"), children: [
|
6387
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: getClassName20("history"), children: [
|
6388
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(IconButton, { title: "undo", disabled: !hasPast, onClick: back, children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(Undo2, { size: 21 }) }),
|
6389
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(IconButton, { title: "redo", disabled: !hasFuture, onClick: forward, children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(Redo2, { size: 21 }) })
|
6599
6390
|
] }),
|
6600
|
-
/* @__PURE__ */ (0,
|
6391
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_jsx_runtime29.Fragment, { children: renderHeaderActions && renderHeaderActions() })
|
6601
6392
|
] })
|
6602
6393
|
}
|
6603
6394
|
);
|
@@ -6615,14 +6406,14 @@ init_react_import();
|
|
6615
6406
|
var styles_module_default16 = { "PuckFields": "_PuckFields_10bh7_1", "PuckFields--isLoading": "_PuckFields--isLoading_10bh7_6", "PuckFields-loadingOverlay": "_PuckFields-loadingOverlay_10bh7_10", "PuckFields-loadingOverlayInner": "_PuckFields-loadingOverlayInner_10bh7_25", "PuckFields-field": "_PuckFields-field_10bh7_32", "PuckFields--wrapFields": "_PuckFields--wrapFields_10bh7_36" };
|
6616
6407
|
|
6617
6408
|
// components/Puck/components/Fields/index.tsx
|
6618
|
-
var
|
6409
|
+
var import_react41 = require("react");
|
6619
6410
|
var import_shallow4 = require("zustand/react/shallow");
|
6620
|
-
var
|
6411
|
+
var import_jsx_runtime30 = require("react/jsx-runtime");
|
6621
6412
|
var getClassName21 = get_class_name_factory_default("PuckFields", styles_module_default16);
|
6622
6413
|
var DefaultFields = ({
|
6623
6414
|
children
|
6624
6415
|
}) => {
|
6625
|
-
return /* @__PURE__ */ (0,
|
6416
|
+
return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_jsx_runtime30.Fragment, { children });
|
6626
6417
|
};
|
6627
6418
|
var createOnChange = (fieldName, appStore) => (value, updatedUi) => __async(void 0, null, function* () {
|
6628
6419
|
let currentProps;
|
@@ -6688,12 +6479,12 @@ var FieldsChild = ({ fieldName }) => {
|
|
6688
6479
|
})
|
6689
6480
|
);
|
6690
6481
|
const appStore = useAppStoreApi();
|
6691
|
-
const onChange = (0,
|
6482
|
+
const onChange = (0, import_react41.useCallback)(createOnChange(fieldName, appStore), [
|
6692
6483
|
fieldName
|
6693
6484
|
]);
|
6694
6485
|
if (!field || !id) return null;
|
6695
6486
|
if (field.type === "slot") return null;
|
6696
|
-
return /* @__PURE__ */ (0,
|
6487
|
+
return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("div", { className: getClassName21("field"), children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
6697
6488
|
AutoFieldPrivate,
|
6698
6489
|
{
|
6699
6490
|
field,
|
@@ -6721,11 +6512,16 @@ var Fields = ({ wrapFields = true }) => {
|
|
6721
6512
|
useRegisterFieldsSlice(appStore, id);
|
6722
6513
|
const fieldsLoading = useAppStore((s) => s.fields.loading);
|
6723
6514
|
const fieldNames = useAppStore(
|
6724
|
-
(0, import_shallow4.useShallow)((s) =>
|
6515
|
+
(0, import_shallow4.useShallow)((s) => {
|
6516
|
+
if (s.fields.id === id) {
|
6517
|
+
return Object.keys(s.fields.fields);
|
6518
|
+
}
|
6519
|
+
return [];
|
6520
|
+
})
|
6725
6521
|
);
|
6726
6522
|
const isLoading = fieldsLoading || componentResolving;
|
6727
|
-
const Wrapper = (0,
|
6728
|
-
return /* @__PURE__ */ (0,
|
6523
|
+
const Wrapper = (0, import_react41.useMemo)(() => overrides.fields || DefaultFields, [overrides]);
|
6524
|
+
return /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(
|
6729
6525
|
"form",
|
6730
6526
|
{
|
6731
6527
|
className: getClassName21({ wrapFields }),
|
@@ -6733,8 +6529,8 @@ var Fields = ({ wrapFields = true }) => {
|
|
6733
6529
|
e.preventDefault();
|
6734
6530
|
},
|
6735
6531
|
children: [
|
6736
|
-
/* @__PURE__ */ (0,
|
6737
|
-
isLoading && /* @__PURE__ */ (0,
|
6532
|
+
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Wrapper, { isLoading, itemSelector, children: fieldNames.map((fieldName) => /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(FieldsChild, { fieldName }, fieldName)) }),
|
6533
|
+
isLoading && /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("div", { className: getClassName21("loadingOverlay"), children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("div", { className: getClassName21("loadingOverlayInner"), children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Loader, { size: 16 }) }) })
|
6738
6534
|
]
|
6739
6535
|
}
|
6740
6536
|
);
|
@@ -6745,7 +6541,7 @@ init_react_import();
|
|
6745
6541
|
|
6746
6542
|
// lib/use-component-list.tsx
|
6747
6543
|
init_react_import();
|
6748
|
-
var
|
6544
|
+
var import_react42 = require("react");
|
6749
6545
|
|
6750
6546
|
// components/ComponentList/index.tsx
|
6751
6547
|
init_react_import();
|
@@ -6755,7 +6551,7 @@ init_react_import();
|
|
6755
6551
|
var styles_module_default17 = { "ComponentList": "_ComponentList_1rrlt_1", "ComponentList--isExpanded": "_ComponentList--isExpanded_1rrlt_5", "ComponentList-content": "_ComponentList-content_1rrlt_9", "ComponentList-title": "_ComponentList-title_1rrlt_17", "ComponentList-titleIcon": "_ComponentList-titleIcon_1rrlt_53" };
|
6756
6552
|
|
6757
6553
|
// components/ComponentList/index.tsx
|
6758
|
-
var
|
6554
|
+
var import_jsx_runtime31 = require("react/jsx-runtime");
|
6759
6555
|
var getClassName22 = get_class_name_factory_default("ComponentList", styles_module_default17);
|
6760
6556
|
var ComponentListItem = ({
|
6761
6557
|
name,
|
@@ -6767,7 +6563,7 @@ var ComponentListItem = ({
|
|
6767
6563
|
type: name
|
6768
6564
|
}).insert
|
6769
6565
|
);
|
6770
|
-
return /* @__PURE__ */ (0,
|
6566
|
+
return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(Drawer.Item, { label, name, isDragDisabled: !canInsert, children: overrides.componentItem });
|
6771
6567
|
};
|
6772
6568
|
var ComponentList = ({
|
6773
6569
|
children,
|
@@ -6778,8 +6574,8 @@ var ComponentList = ({
|
|
6778
6574
|
const setUi = useAppStore((s) => s.setUi);
|
6779
6575
|
const componentList = useAppStore((s) => s.state.ui.componentList);
|
6780
6576
|
const { expanded = true } = componentList[id] || {};
|
6781
|
-
return /* @__PURE__ */ (0,
|
6782
|
-
title && /* @__PURE__ */ (0,
|
6577
|
+
return /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("div", { className: getClassName22({ isExpanded: expanded }), children: [
|
6578
|
+
title && /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(
|
6783
6579
|
"button",
|
6784
6580
|
{
|
6785
6581
|
type: "button",
|
@@ -6793,14 +6589,14 @@ var ComponentList = ({
|
|
6793
6589
|
}),
|
6794
6590
|
title: expanded ? `Collapse${title ? ` ${title}` : ""}` : `Expand${title ? ` ${title}` : ""}`,
|
6795
6591
|
children: [
|
6796
|
-
/* @__PURE__ */ (0,
|
6797
|
-
/* @__PURE__ */ (0,
|
6592
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", { children: title }),
|
6593
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", { className: getClassName22("titleIcon"), children: expanded ? /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(ChevronUp, { size: 12 }) : /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(ChevronDown, { size: 12 }) })
|
6798
6594
|
]
|
6799
6595
|
}
|
6800
6596
|
),
|
6801
|
-
/* @__PURE__ */ (0,
|
6597
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", { className: getClassName22("content"), children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(Drawer, { children: children || Object.keys(config.components).map((componentKey) => {
|
6802
6598
|
var _a;
|
6803
|
-
return /* @__PURE__ */ (0,
|
6599
|
+
return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
6804
6600
|
ComponentListItem,
|
6805
6601
|
{
|
6806
6602
|
label: (_a = config.components[componentKey]["label"]) != null ? _a : componentKey,
|
@@ -6814,12 +6610,12 @@ var ComponentList = ({
|
|
6814
6610
|
ComponentList.Item = ComponentListItem;
|
6815
6611
|
|
6816
6612
|
// lib/use-component-list.tsx
|
6817
|
-
var
|
6613
|
+
var import_jsx_runtime32 = require("react/jsx-runtime");
|
6818
6614
|
var useComponentList = () => {
|
6819
|
-
const [componentList, setComponentList] = (0,
|
6615
|
+
const [componentList, setComponentList] = (0, import_react42.useState)();
|
6820
6616
|
const config = useAppStore((s) => s.config);
|
6821
6617
|
const uiComponentList = useAppStore((s) => s.state.ui.componentList);
|
6822
|
-
(0,
|
6618
|
+
(0, import_react42.useEffect)(() => {
|
6823
6619
|
var _a, _b, _c;
|
6824
6620
|
if (Object.keys(uiComponentList).length > 0) {
|
6825
6621
|
const matchedComponents = [];
|
@@ -6829,7 +6625,7 @@ var useComponentList = () => {
|
|
6829
6625
|
if (category.visible === false || !category.components) {
|
6830
6626
|
return null;
|
6831
6627
|
}
|
6832
|
-
return /* @__PURE__ */ (0,
|
6628
|
+
return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
6833
6629
|
ComponentList,
|
6834
6630
|
{
|
6835
6631
|
id: categoryKey,
|
@@ -6838,7 +6634,7 @@ var useComponentList = () => {
|
|
6838
6634
|
var _a2;
|
6839
6635
|
matchedComponents.push(componentName);
|
6840
6636
|
const componentConf = config.components[componentName] || {};
|
6841
|
-
return /* @__PURE__ */ (0,
|
6637
|
+
return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
6842
6638
|
ComponentList.Item,
|
6843
6639
|
{
|
6844
6640
|
label: (_a2 = componentConf["label"]) != null ? _a2 : componentName,
|
@@ -6858,7 +6654,7 @@ var useComponentList = () => {
|
|
6858
6654
|
);
|
6859
6655
|
if (remainingComponents.length > 0 && !((_a = uiComponentList.other) == null ? void 0 : _a.components) && ((_b = uiComponentList.other) == null ? void 0 : _b.visible) !== false) {
|
6860
6656
|
_componentList.push(
|
6861
|
-
/* @__PURE__ */ (0,
|
6657
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
6862
6658
|
ComponentList,
|
6863
6659
|
{
|
6864
6660
|
id: "other",
|
@@ -6866,7 +6662,7 @@ var useComponentList = () => {
|
|
6866
6662
|
children: remainingComponents.map((componentName, i) => {
|
6867
6663
|
var _a2;
|
6868
6664
|
const componentConf = config.components[componentName] || {};
|
6869
|
-
return /* @__PURE__ */ (0,
|
6665
|
+
return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
6870
6666
|
ComponentList.Item,
|
6871
6667
|
{
|
6872
6668
|
name: componentName,
|
@@ -6888,25 +6684,25 @@ var useComponentList = () => {
|
|
6888
6684
|
};
|
6889
6685
|
|
6890
6686
|
// components/Puck/components/Components/index.tsx
|
6891
|
-
var
|
6892
|
-
var
|
6687
|
+
var import_react43 = require("react");
|
6688
|
+
var import_jsx_runtime33 = require("react/jsx-runtime");
|
6893
6689
|
var Components = () => {
|
6894
6690
|
const overrides = useAppStore((s) => s.overrides);
|
6895
6691
|
const componentList = useComponentList();
|
6896
|
-
const Wrapper = (0,
|
6897
|
-
return /* @__PURE__ */ (0,
|
6692
|
+
const Wrapper = (0, import_react43.useMemo)(() => overrides.components || "div", [overrides]);
|
6693
|
+
return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Wrapper, { children: componentList ? componentList : /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(ComponentList, { id: "all" }) });
|
6898
6694
|
};
|
6899
6695
|
|
6900
6696
|
// components/Puck/components/Preview/index.tsx
|
6901
6697
|
init_react_import();
|
6902
|
-
var
|
6698
|
+
var import_react45 = require("react");
|
6903
6699
|
|
6904
6700
|
// components/AutoFrame/index.tsx
|
6905
6701
|
init_react_import();
|
6906
|
-
var
|
6702
|
+
var import_react44 = require("react");
|
6907
6703
|
var import_object_hash = __toESM(require("object-hash"));
|
6908
6704
|
var import_react_dom3 = require("react-dom");
|
6909
|
-
var
|
6705
|
+
var import_jsx_runtime34 = require("react/jsx-runtime");
|
6910
6706
|
var styleSelector = 'style, link[rel="stylesheet"]';
|
6911
6707
|
var collectStyles = (doc) => {
|
6912
6708
|
const collected = [];
|
@@ -6949,7 +6745,7 @@ var CopyHostStyles = ({
|
|
6949
6745
|
onStylesLoaded = () => null
|
6950
6746
|
}) => {
|
6951
6747
|
const { document: doc, window: win } = useFrame();
|
6952
|
-
(0,
|
6748
|
+
(0, import_react44.useEffect)(() => {
|
6953
6749
|
if (!win || !doc) {
|
6954
6750
|
return () => {
|
6955
6751
|
};
|
@@ -7106,10 +6902,10 @@ var CopyHostStyles = ({
|
|
7106
6902
|
observer.disconnect();
|
7107
6903
|
};
|
7108
6904
|
}, []);
|
7109
|
-
return /* @__PURE__ */ (0,
|
6905
|
+
return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_jsx_runtime34.Fragment, { children });
|
7110
6906
|
};
|
7111
|
-
var autoFrameContext = (0,
|
7112
|
-
var useFrame = () => (0,
|
6907
|
+
var autoFrameContext = (0, import_react44.createContext)({});
|
6908
|
+
var useFrame = () => (0, import_react44.useContext)(autoFrameContext);
|
7113
6909
|
function AutoFrame(_a) {
|
7114
6910
|
var _b = _a, {
|
7115
6911
|
children,
|
@@ -7130,11 +6926,11 @@ function AutoFrame(_a) {
|
|
7130
6926
|
"onNotReady",
|
7131
6927
|
"frameRef"
|
7132
6928
|
]);
|
7133
|
-
const [loaded, setLoaded] = (0,
|
7134
|
-
const [ctx, setCtx] = (0,
|
7135
|
-
const [mountTarget, setMountTarget] = (0,
|
7136
|
-
const [stylesLoaded, setStylesLoaded] = (0,
|
7137
|
-
(0,
|
6929
|
+
const [loaded, setLoaded] = (0, import_react44.useState)(false);
|
6930
|
+
const [ctx, setCtx] = (0, import_react44.useState)({});
|
6931
|
+
const [mountTarget, setMountTarget] = (0, import_react44.useState)();
|
6932
|
+
const [stylesLoaded, setStylesLoaded] = (0, import_react44.useState)(false);
|
6933
|
+
(0, import_react44.useEffect)(() => {
|
7138
6934
|
var _a2;
|
7139
6935
|
if (frameRef.current) {
|
7140
6936
|
const doc = frameRef.current.contentDocument;
|
@@ -7153,7 +6949,7 @@ function AutoFrame(_a) {
|
|
7153
6949
|
}
|
7154
6950
|
}
|
7155
6951
|
}, [frameRef, loaded, stylesLoaded]);
|
7156
|
-
return /* @__PURE__ */ (0,
|
6952
|
+
return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
7157
6953
|
"iframe",
|
7158
6954
|
__spreadProps(__spreadValues({}, props), {
|
7159
6955
|
className,
|
@@ -7163,7 +6959,7 @@ function AutoFrame(_a) {
|
|
7163
6959
|
onLoad: () => {
|
7164
6960
|
setLoaded(true);
|
7165
6961
|
},
|
7166
|
-
children: /* @__PURE__ */ (0,
|
6962
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(autoFrameContext.Provider, { value: ctx, children: loaded && mountTarget && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
7167
6963
|
CopyHostStyles,
|
7168
6964
|
{
|
7169
6965
|
debug,
|
@@ -7182,11 +6978,11 @@ init_react_import();
|
|
7182
6978
|
var styles_module_default18 = { "PuckPreview": "_PuckPreview_z2rgu_1", "PuckPreview-frame": "_PuckPreview-frame_z2rgu_6" };
|
7183
6979
|
|
7184
6980
|
// components/Puck/components/Preview/index.tsx
|
7185
|
-
var
|
6981
|
+
var import_jsx_runtime35 = require("react/jsx-runtime");
|
7186
6982
|
var getClassName23 = get_class_name_factory_default("PuckPreview", styles_module_default18);
|
7187
6983
|
var useBubbleIframeEvents = (ref) => {
|
7188
6984
|
const status = useAppStore((s) => s.status);
|
7189
|
-
(0,
|
6985
|
+
(0, import_react45.useEffect)(() => {
|
7190
6986
|
if (ref.current && status === "READY") {
|
7191
6987
|
const iframe = ref.current;
|
7192
6988
|
const handlePointerMove = (event) => {
|
@@ -7235,22 +7031,22 @@ var Preview3 = ({ id = "puck-preview" }) => {
|
|
7235
7031
|
const renderData = useAppStore(
|
7236
7032
|
(s) => s.state.ui.previewMode === "edit" ? null : s.state.data
|
7237
7033
|
);
|
7238
|
-
const Page = (0,
|
7034
|
+
const Page = (0, import_react45.useCallback)(
|
7239
7035
|
(pageProps) => {
|
7240
7036
|
var _a, _b;
|
7241
7037
|
const rootConfig = config.root;
|
7242
7038
|
const propsWithSlots = useSlots(rootConfig, pageProps, DropZoneEditPure);
|
7243
7039
|
return ((_a = config.root) == null ? void 0 : _a.render) ? (_b = config.root) == null ? void 0 : _b.render(__spreadValues({
|
7244
7040
|
id: "puck-root"
|
7245
|
-
}, propsWithSlots)) : /* @__PURE__ */ (0,
|
7041
|
+
}, propsWithSlots)) : /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(import_jsx_runtime35.Fragment, { children: propsWithSlots.children });
|
7246
7042
|
},
|
7247
7043
|
[config.root]
|
7248
7044
|
);
|
7249
|
-
const Frame = (0,
|
7045
|
+
const Frame = (0, import_react45.useMemo)(() => overrides.iframe, [overrides]);
|
7250
7046
|
const rootProps = root.props || root;
|
7251
|
-
const ref = (0,
|
7047
|
+
const ref = (0, import_react45.useRef)(null);
|
7252
7048
|
useBubbleIframeEvents(ref);
|
7253
|
-
const inner = !renderData ? /* @__PURE__ */ (0,
|
7049
|
+
const inner = !renderData ? /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
7254
7050
|
Page,
|
7255
7051
|
__spreadProps(__spreadValues({}, rootProps), {
|
7256
7052
|
puck: {
|
@@ -7260,15 +7056,15 @@ var Preview3 = ({ id = "puck-preview" }) => {
|
|
7260
7056
|
metadata
|
7261
7057
|
},
|
7262
7058
|
editMode: true,
|
7263
|
-
children: /* @__PURE__ */ (0,
|
7059
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(DropZonePure, { zone: rootDroppableId })
|
7264
7060
|
})
|
7265
|
-
) : /* @__PURE__ */ (0,
|
7266
|
-
(0,
|
7061
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Render, { data: renderData, config });
|
7062
|
+
(0, import_react45.useEffect)(() => {
|
7267
7063
|
if (!iframe.enabled) {
|
7268
7064
|
setStatus("READY");
|
7269
7065
|
}
|
7270
7066
|
}, [iframe.enabled]);
|
7271
|
-
return /* @__PURE__ */ (0,
|
7067
|
+
return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
7272
7068
|
"div",
|
7273
7069
|
{
|
7274
7070
|
className: getClassName23(),
|
@@ -7277,7 +7073,7 @@ var Preview3 = ({ id = "puck-preview" }) => {
|
|
7277
7073
|
onClick: () => {
|
7278
7074
|
dispatch({ type: "setUi", ui: { itemSelector: null } });
|
7279
7075
|
},
|
7280
|
-
children: iframe.enabled ? /* @__PURE__ */ (0,
|
7076
|
+
children: iframe.enabled ? /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
7281
7077
|
AutoFrame_default,
|
7282
7078
|
{
|
7283
7079
|
id: "preview-frame",
|
@@ -7290,14 +7086,14 @@ var Preview3 = ({ id = "puck-preview" }) => {
|
|
7290
7086
|
setStatus("MOUNTED");
|
7291
7087
|
},
|
7292
7088
|
frameRef: ref,
|
7293
|
-
children: /* @__PURE__ */ (0,
|
7089
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(autoFrameContext.Consumer, { children: ({ document: document2 }) => {
|
7294
7090
|
if (Frame) {
|
7295
|
-
return /* @__PURE__ */ (0,
|
7091
|
+
return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Frame, { document: document2, children: inner });
|
7296
7092
|
}
|
7297
7093
|
return inner;
|
7298
7094
|
} })
|
7299
7095
|
}
|
7300
|
-
) : /* @__PURE__ */ (0,
|
7096
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
7301
7097
|
"div",
|
7302
7098
|
{
|
7303
7099
|
id: "preview-frame",
|
@@ -7333,7 +7129,7 @@ var scrollIntoView = (el) => {
|
|
7333
7129
|
};
|
7334
7130
|
|
7335
7131
|
// components/LayerTree/index.tsx
|
7336
|
-
var
|
7132
|
+
var import_react46 = require("react");
|
7337
7133
|
|
7338
7134
|
// lib/on-scroll-end.ts
|
7339
7135
|
init_react_import();
|
@@ -7356,7 +7152,7 @@ var onScrollEnd = (frame, cb) => {
|
|
7356
7152
|
|
7357
7153
|
// components/LayerTree/index.tsx
|
7358
7154
|
var import_shallow5 = require("zustand/react/shallow");
|
7359
|
-
var
|
7155
|
+
var import_jsx_runtime36 = require("react/jsx-runtime");
|
7360
7156
|
var getClassName24 = get_class_name_factory_default("LayerTree", styles_module_default19);
|
7361
7157
|
var getClassNameLayer = get_class_name_factory_default("Layer", styles_module_default19);
|
7362
7158
|
var Layer = ({
|
@@ -7365,11 +7161,11 @@ var Layer = ({
|
|
7365
7161
|
zoneCompound
|
7366
7162
|
}) => {
|
7367
7163
|
var _a;
|
7368
|
-
const ctx = (0,
|
7164
|
+
const ctx = (0, import_react46.useContext)(dropZoneContext);
|
7369
7165
|
const config = useAppStore((s) => s.config);
|
7370
7166
|
const itemSelector = useAppStore((s) => s.state.ui.itemSelector);
|
7371
7167
|
const dispatch = useAppStore((s) => s.dispatch);
|
7372
|
-
const setItemSelector = (0,
|
7168
|
+
const setItemSelector = (0, import_react46.useCallback)(
|
7373
7169
|
(itemSelector2) => {
|
7374
7170
|
dispatch({ type: "setUi", ui: { itemSelector: itemSelector2 } });
|
7375
7171
|
},
|
@@ -7402,7 +7198,7 @@ var Layer = ({
|
|
7402
7198
|
});
|
7403
7199
|
const componentConfig = config.components[nodeData.data.type];
|
7404
7200
|
const label = (_a = componentConfig == null ? void 0 : componentConfig["label"]) != null ? _a : nodeData.data.type.toString();
|
7405
|
-
return /* @__PURE__ */ (0,
|
7201
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(
|
7406
7202
|
"li",
|
7407
7203
|
{
|
7408
7204
|
className: getClassNameLayer({
|
@@ -7412,7 +7208,7 @@ var Layer = ({
|
|
7412
7208
|
childIsSelected
|
7413
7209
|
}),
|
7414
7210
|
children: [
|
7415
|
-
/* @__PURE__ */ (0,
|
7211
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: getClassNameLayer("inner"), children: /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(
|
7416
7212
|
"button",
|
7417
7213
|
{
|
7418
7214
|
type: "button",
|
@@ -7447,22 +7243,22 @@ var Layer = ({
|
|
7447
7243
|
setHoveringComponent(null);
|
7448
7244
|
},
|
7449
7245
|
children: [
|
7450
|
-
containsZone && /* @__PURE__ */ (0,
|
7246
|
+
containsZone && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
7451
7247
|
"div",
|
7452
7248
|
{
|
7453
7249
|
className: getClassNameLayer("chevron"),
|
7454
7250
|
title: isSelected ? "Collapse" : "Expand",
|
7455
|
-
children: /* @__PURE__ */ (0,
|
7251
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(ChevronDown, { size: "12" })
|
7456
7252
|
}
|
7457
7253
|
),
|
7458
|
-
/* @__PURE__ */ (0,
|
7459
|
-
/* @__PURE__ */ (0,
|
7460
|
-
/* @__PURE__ */ (0,
|
7254
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { className: getClassNameLayer("title"), children: [
|
7255
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: getClassNameLayer("icon"), children: nodeData.data.type === "Text" || nodeData.data.type === "Heading" ? /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Type, { size: "16" }) : /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(LayoutGrid, { size: "16" }) }),
|
7256
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: getClassNameLayer("name"), children: label })
|
7461
7257
|
] })
|
7462
7258
|
]
|
7463
7259
|
}
|
7464
7260
|
) }),
|
7465
|
-
containsZone && zonesForItem.map((subzone) => /* @__PURE__ */ (0,
|
7261
|
+
containsZone && zonesForItem.map((subzone) => /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: getClassNameLayer("zones"), children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(LayerTree, { zoneCompound: subzone }) }, subzone))
|
7466
7262
|
]
|
7467
7263
|
}
|
7468
7264
|
);
|
@@ -7480,15 +7276,15 @@ var LayerTree = ({
|
|
7480
7276
|
}
|
7481
7277
|
)
|
7482
7278
|
);
|
7483
|
-
return /* @__PURE__ */ (0,
|
7484
|
-
label && /* @__PURE__ */ (0,
|
7485
|
-
/* @__PURE__ */ (0,
|
7279
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(import_jsx_runtime36.Fragment, { children: [
|
7280
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { className: getClassName24("zoneTitle"), children: [
|
7281
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: getClassName24("zoneIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Layers, { size: "16" }) }),
|
7486
7282
|
label
|
7487
7283
|
] }),
|
7488
|
-
/* @__PURE__ */ (0,
|
7489
|
-
contentIds.length === 0 && /* @__PURE__ */ (0,
|
7284
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("ul", { className: getClassName24(), children: [
|
7285
|
+
contentIds.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: getClassName24("helper"), children: "No items" }),
|
7490
7286
|
contentIds.map((itemId, i) => {
|
7491
|
-
return /* @__PURE__ */ (0,
|
7287
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
7492
7288
|
Layer,
|
7493
7289
|
{
|
7494
7290
|
index: i,
|
@@ -7503,7 +7299,7 @@ var LayerTree = ({
|
|
7503
7299
|
};
|
7504
7300
|
|
7505
7301
|
// components/Puck/components/Outline/index.tsx
|
7506
|
-
var
|
7302
|
+
var import_react47 = require("react");
|
7507
7303
|
|
7508
7304
|
// lib/data/find-zones-for-area.ts
|
7509
7305
|
init_react_import();
|
@@ -7515,14 +7311,14 @@ var findZonesForArea = (state, area) => {
|
|
7515
7311
|
|
7516
7312
|
// components/Puck/components/Outline/index.tsx
|
7517
7313
|
var import_shallow6 = require("zustand/react/shallow");
|
7518
|
-
var
|
7314
|
+
var import_jsx_runtime37 = require("react/jsx-runtime");
|
7519
7315
|
var Outline = () => {
|
7520
7316
|
const outlineOverride = useAppStore((s) => s.overrides.outline);
|
7521
7317
|
const rootZones = useAppStore(
|
7522
7318
|
(0, import_shallow6.useShallow)((s) => findZonesForArea(s.state, "root"))
|
7523
7319
|
);
|
7524
|
-
const Wrapper = (0,
|
7525
|
-
return /* @__PURE__ */ (0,
|
7320
|
+
const Wrapper = (0, import_react47.useMemo)(() => outlineOverride || "div", [outlineOverride]);
|
7321
|
+
return /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(Wrapper, { children: rootZones.map((zoneCompound) => /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
|
7526
7322
|
LayerTree,
|
7527
7323
|
{
|
7528
7324
|
label: rootZones.length === 1 ? "" : zoneCompound.split(":")[1],
|
@@ -7655,22 +7451,22 @@ var getBox = function getBox2(el) {
|
|
7655
7451
|
};
|
7656
7452
|
|
7657
7453
|
// components/Puck/components/Canvas/index.tsx
|
7658
|
-
var
|
7454
|
+
var import_react49 = require("react");
|
7659
7455
|
|
7660
7456
|
// components/ViewportControls/index.tsx
|
7661
7457
|
init_react_import();
|
7662
|
-
var
|
7458
|
+
var import_react48 = require("react");
|
7663
7459
|
|
7664
7460
|
// css-module:/home/runner/work/puck/puck/packages/core/components/ViewportControls/styles.module.css#css-module
|
7665
7461
|
init_react_import();
|
7666
7462
|
var styles_module_default20 = { "ViewportControls": "_ViewportControls_gejzr_1", "ViewportControls-divider": "_ViewportControls-divider_gejzr_15", "ViewportControls-zoomSelect": "_ViewportControls-zoomSelect_gejzr_21", "ViewportButton--isActive": "_ViewportButton--isActive_gejzr_38", "ViewportButton-inner": "_ViewportButton-inner_gejzr_38" };
|
7667
7463
|
|
7668
7464
|
// components/ViewportControls/index.tsx
|
7669
|
-
var
|
7465
|
+
var import_jsx_runtime38 = require("react/jsx-runtime");
|
7670
7466
|
var icons = {
|
7671
|
-
Smartphone: /* @__PURE__ */ (0,
|
7672
|
-
Tablet: /* @__PURE__ */ (0,
|
7673
|
-
Monitor: /* @__PURE__ */ (0,
|
7467
|
+
Smartphone: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(Smartphone, { size: 16 }),
|
7468
|
+
Tablet: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(Tablet, { size: 16 }),
|
7469
|
+
Monitor: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(Monitor, { size: 16 })
|
7674
7470
|
};
|
7675
7471
|
var getClassName25 = get_class_name_factory_default("ViewportControls", styles_module_default20);
|
7676
7472
|
var getClassNameButton = get_class_name_factory_default("ViewportButton", styles_module_default20);
|
@@ -7682,11 +7478,11 @@ var ViewportButton = ({
|
|
7682
7478
|
onClick
|
7683
7479
|
}) => {
|
7684
7480
|
const viewports = useAppStore((s) => s.state.ui.viewports);
|
7685
|
-
const [isActive, setIsActive] = (0,
|
7686
|
-
(0,
|
7481
|
+
const [isActive, setIsActive] = (0, import_react48.useState)(false);
|
7482
|
+
(0, import_react48.useEffect)(() => {
|
7687
7483
|
setIsActive(width === viewports.current.width);
|
7688
7484
|
}, [width, viewports.current.width]);
|
7689
|
-
return /* @__PURE__ */ (0,
|
7485
|
+
return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("span", { className: getClassNameButton({ isActive }), children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
|
7690
7486
|
IconButton,
|
7691
7487
|
{
|
7692
7488
|
title,
|
@@ -7695,7 +7491,7 @@ var ViewportButton = ({
|
|
7695
7491
|
e.stopPropagation();
|
7696
7492
|
onClick({ width, height });
|
7697
7493
|
},
|
7698
|
-
children: /* @__PURE__ */ (0,
|
7494
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("span", { className: getClassNameButton("inner"), children })
|
7699
7495
|
}
|
7700
7496
|
) });
|
7701
7497
|
};
|
@@ -7719,7 +7515,7 @@ var ViewportControls = ({
|
|
7719
7515
|
const defaultsContainAutoZoom = defaultZoomOptions.find(
|
7720
7516
|
(option) => option.value === autoZoom
|
7721
7517
|
);
|
7722
|
-
const zoomOptions = (0,
|
7518
|
+
const zoomOptions = (0, import_react48.useMemo)(
|
7723
7519
|
() => [
|
7724
7520
|
...defaultZoomOptions,
|
7725
7521
|
...defaultsContainAutoZoom ? [] : [
|
@@ -7731,8 +7527,8 @@ var ViewportControls = ({
|
|
7731
7527
|
].filter((a) => a.value <= autoZoom).sort((a, b) => a.value > b.value ? 1 : -1),
|
7732
7528
|
[autoZoom]
|
7733
7529
|
);
|
7734
|
-
return /* @__PURE__ */ (0,
|
7735
|
-
viewports.map((viewport, i) => /* @__PURE__ */ (0,
|
7530
|
+
return /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("div", { className: getClassName25(), children: [
|
7531
|
+
viewports.map((viewport, i) => /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
|
7736
7532
|
ViewportButton,
|
7737
7533
|
{
|
7738
7534
|
height: viewport.height,
|
@@ -7743,8 +7539,8 @@ var ViewportControls = ({
|
|
7743
7539
|
},
|
7744
7540
|
i
|
7745
7541
|
)),
|
7746
|
-
/* @__PURE__ */ (0,
|
7747
|
-
/* @__PURE__ */ (0,
|
7542
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)("div", { className: getClassName25("divider") }),
|
7543
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
|
7748
7544
|
IconButton,
|
7749
7545
|
{
|
7750
7546
|
title: "Zoom viewport out",
|
@@ -7758,10 +7554,10 @@ var ViewportControls = ({
|
|
7758
7554
|
)].value
|
7759
7555
|
);
|
7760
7556
|
},
|
7761
|
-
children: /* @__PURE__ */ (0,
|
7557
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(ZoomOut, { size: 16 })
|
7762
7558
|
}
|
7763
7559
|
),
|
7764
|
-
/* @__PURE__ */ (0,
|
7560
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
|
7765
7561
|
IconButton,
|
7766
7562
|
{
|
7767
7563
|
title: "Zoom viewport in",
|
@@ -7775,11 +7571,11 @@ var ViewportControls = ({
|
|
7775
7571
|
)].value
|
7776
7572
|
);
|
7777
7573
|
},
|
7778
|
-
children: /* @__PURE__ */ (0,
|
7574
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(ZoomIn, { size: 16 })
|
7779
7575
|
}
|
7780
7576
|
),
|
7781
|
-
/* @__PURE__ */ (0,
|
7782
|
-
/* @__PURE__ */ (0,
|
7577
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)("div", { className: getClassName25("divider") }),
|
7578
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
|
7783
7579
|
"select",
|
7784
7580
|
{
|
7785
7581
|
className: getClassName25("zoomSelect"),
|
@@ -7787,7 +7583,7 @@ var ViewportControls = ({
|
|
7787
7583
|
onChange: (e) => {
|
7788
7584
|
onZoom(parseFloat(e.currentTarget.value));
|
7789
7585
|
},
|
7790
|
-
children: zoomOptions.map((option) => /* @__PURE__ */ (0,
|
7586
|
+
children: zoomOptions.map((option) => /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
|
7791
7587
|
"option",
|
7792
7588
|
{
|
7793
7589
|
value: option.value,
|
@@ -7836,7 +7632,7 @@ var getZoomConfig = (uiViewport, frame, zoom) => {
|
|
7836
7632
|
|
7837
7633
|
// components/Puck/components/Canvas/index.tsx
|
7838
7634
|
var import_shallow7 = require("zustand/react/shallow");
|
7839
|
-
var
|
7635
|
+
var import_jsx_runtime39 = require("react/jsx-runtime");
|
7840
7636
|
var getClassName26 = get_class_name_factory_default("PuckCanvas", styles_module_default21);
|
7841
7637
|
var ZOOM_ON_CHANGE = true;
|
7842
7638
|
var Canvas = () => {
|
@@ -7866,17 +7662,17 @@ var Canvas = () => {
|
|
7866
7662
|
viewports: s.state.ui.viewports
|
7867
7663
|
}))
|
7868
7664
|
);
|
7869
|
-
const frameRef = (0,
|
7870
|
-
const [showTransition, setShowTransition] = (0,
|
7871
|
-
const defaultRender = (0,
|
7872
|
-
const PuckDefault = ({ children }) => /* @__PURE__ */ (0,
|
7665
|
+
const frameRef = (0, import_react49.useRef)(null);
|
7666
|
+
const [showTransition, setShowTransition] = (0, import_react49.useState)(false);
|
7667
|
+
const defaultRender = (0, import_react49.useMemo)(() => {
|
7668
|
+
const PuckDefault = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(import_jsx_runtime39.Fragment, { children });
|
7873
7669
|
return PuckDefault;
|
7874
7670
|
}, []);
|
7875
|
-
const CustomPreview = (0,
|
7671
|
+
const CustomPreview = (0, import_react49.useMemo)(
|
7876
7672
|
() => overrides.preview || defaultRender,
|
7877
7673
|
[overrides]
|
7878
7674
|
);
|
7879
|
-
const getFrameDimensions = (0,
|
7675
|
+
const getFrameDimensions = (0, import_react49.useCallback)(() => {
|
7880
7676
|
if (frameRef.current) {
|
7881
7677
|
const frame = frameRef.current;
|
7882
7678
|
const box = getBox(frame);
|
@@ -7884,7 +7680,7 @@ var Canvas = () => {
|
|
7884
7680
|
}
|
7885
7681
|
return { width: 0, height: 0 };
|
7886
7682
|
}, [frameRef]);
|
7887
|
-
const resetAutoZoom = (0,
|
7683
|
+
const resetAutoZoom = (0, import_react49.useCallback)(
|
7888
7684
|
(newViewports = viewports) => {
|
7889
7685
|
if (frameRef.current) {
|
7890
7686
|
setZoomConfig(
|
@@ -7898,11 +7694,11 @@ var Canvas = () => {
|
|
7898
7694
|
},
|
7899
7695
|
[frameRef, zoomConfig, viewports]
|
7900
7696
|
);
|
7901
|
-
(0,
|
7697
|
+
(0, import_react49.useEffect)(() => {
|
7902
7698
|
setShowTransition(false);
|
7903
7699
|
resetAutoZoom(viewports);
|
7904
7700
|
}, [frameRef, leftSideBarVisible, rightSideBarVisible]);
|
7905
|
-
(0,
|
7701
|
+
(0, import_react49.useEffect)(() => {
|
7906
7702
|
const { height: frameHeight } = getFrameDimensions();
|
7907
7703
|
if (viewports.current.height === "auto") {
|
7908
7704
|
setZoomConfig(__spreadProps(__spreadValues({}, zoomConfig), {
|
@@ -7910,13 +7706,13 @@ var Canvas = () => {
|
|
7910
7706
|
}));
|
7911
7707
|
}
|
7912
7708
|
}, [zoomConfig.zoom]);
|
7913
|
-
(0,
|
7709
|
+
(0, import_react49.useEffect)(() => {
|
7914
7710
|
if (ZOOM_ON_CHANGE) {
|
7915
7711
|
setShowTransition(true);
|
7916
7712
|
resetAutoZoom(viewports);
|
7917
7713
|
}
|
7918
7714
|
}, [viewports.current.width]);
|
7919
|
-
(0,
|
7715
|
+
(0, import_react49.useEffect)(() => {
|
7920
7716
|
const cb = () => {
|
7921
7717
|
setShowTransition(false);
|
7922
7718
|
resetAutoZoom();
|
@@ -7926,13 +7722,13 @@ var Canvas = () => {
|
|
7926
7722
|
window.removeEventListener("resize", cb);
|
7927
7723
|
};
|
7928
7724
|
}, []);
|
7929
|
-
const [showLoader, setShowLoader] = (0,
|
7930
|
-
(0,
|
7725
|
+
const [showLoader, setShowLoader] = (0, import_react49.useState)(false);
|
7726
|
+
(0, import_react49.useEffect)(() => {
|
7931
7727
|
setTimeout(() => {
|
7932
7728
|
setShowLoader(true);
|
7933
7729
|
}, 500);
|
7934
7730
|
}, []);
|
7935
|
-
return /* @__PURE__ */ (0,
|
7731
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(
|
7936
7732
|
"div",
|
7937
7733
|
{
|
7938
7734
|
className: getClassName26({
|
@@ -7945,7 +7741,7 @@ var Canvas = () => {
|
|
7945
7741
|
recordHistory: true
|
7946
7742
|
}),
|
7947
7743
|
children: [
|
7948
|
-
viewports.controlsVisible && iframe.enabled && /* @__PURE__ */ (0,
|
7744
|
+
viewports.controlsVisible && iframe.enabled && /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { className: getClassName26("controls"), children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
7949
7745
|
ViewportControls,
|
7950
7746
|
{
|
7951
7747
|
autoZoom: zoomConfig.autoZoom,
|
@@ -7971,8 +7767,8 @@ var Canvas = () => {
|
|
7971
7767
|
}
|
7972
7768
|
}
|
7973
7769
|
) }),
|
7974
|
-
/* @__PURE__ */ (0,
|
7975
|
-
/* @__PURE__ */ (0,
|
7770
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: getClassName26("inner"), ref: frameRef, children: [
|
7771
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
7976
7772
|
"div",
|
7977
7773
|
{
|
7978
7774
|
className: getClassName26("root"),
|
@@ -7993,10 +7789,10 @@ var Canvas = () => {
|
|
7993
7789
|
})
|
7994
7790
|
);
|
7995
7791
|
},
|
7996
|
-
children: /* @__PURE__ */ (0,
|
7792
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(CustomPreview, { children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Preview3, {}) })
|
7997
7793
|
}
|
7998
7794
|
),
|
7999
|
-
/* @__PURE__ */ (0,
|
7795
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { className: getClassName26("loader"), children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Loader, { size: 24 }) })
|
8000
7796
|
] })
|
8001
7797
|
]
|
8002
7798
|
}
|
@@ -8005,7 +7801,7 @@ var Canvas = () => {
|
|
8005
7801
|
|
8006
7802
|
// lib/use-loaded-overrides.ts
|
8007
7803
|
init_react_import();
|
8008
|
-
var
|
7804
|
+
var import_react50 = require("react");
|
8009
7805
|
|
8010
7806
|
// lib/load-overrides.ts
|
8011
7807
|
init_react_import();
|
@@ -8044,26 +7840,26 @@ var useLoadedOverrides = ({
|
|
8044
7840
|
overrides,
|
8045
7841
|
plugins
|
8046
7842
|
}) => {
|
8047
|
-
return (0,
|
7843
|
+
return (0, import_react50.useMemo)(() => {
|
8048
7844
|
return loadOverrides({ overrides, plugins });
|
8049
7845
|
}, [plugins, overrides]);
|
8050
7846
|
};
|
8051
7847
|
|
8052
7848
|
// components/DefaultOverride/index.tsx
|
8053
7849
|
init_react_import();
|
8054
|
-
var
|
8055
|
-
var DefaultOverride = ({ children }) => /* @__PURE__ */ (0,
|
7850
|
+
var import_jsx_runtime40 = require("react/jsx-runtime");
|
7851
|
+
var DefaultOverride = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(import_jsx_runtime40.Fragment, { children });
|
8056
7852
|
|
8057
7853
|
// lib/use-inject-css.ts
|
8058
7854
|
init_react_import();
|
8059
|
-
var
|
7855
|
+
var import_react51 = require("react");
|
8060
7856
|
var styles = ``;
|
8061
7857
|
var useInjectStyleSheet = (initialStyles, iframeEnabled) => {
|
8062
|
-
const [el, setEl] = (0,
|
8063
|
-
(0,
|
7858
|
+
const [el, setEl] = (0, import_react51.useState)();
|
7859
|
+
(0, import_react51.useEffect)(() => {
|
8064
7860
|
setEl(document.createElement("style"));
|
8065
7861
|
}, []);
|
8066
|
-
(0,
|
7862
|
+
(0, import_react51.useEffect)(() => {
|
8067
7863
|
var _a;
|
8068
7864
|
if (!el || typeof window === "undefined") {
|
8069
7865
|
return;
|
@@ -8083,10 +7879,10 @@ var useInjectGlobalCss = (iframeEnabled) => {
|
|
8083
7879
|
|
8084
7880
|
// lib/use-preview-mode-hotkeys.ts
|
8085
7881
|
init_react_import();
|
8086
|
-
var
|
7882
|
+
var import_react52 = require("react");
|
8087
7883
|
var usePreviewModeHotkeys = () => {
|
8088
7884
|
const appStore = useAppStoreApi();
|
8089
|
-
const toggleInteractive = (0,
|
7885
|
+
const toggleInteractive = (0, import_react52.useCallback)(() => {
|
8090
7886
|
const dispatch = appStore.getState().dispatch;
|
8091
7887
|
dispatch({
|
8092
7888
|
type: "setUi",
|
@@ -8101,7 +7897,7 @@ var usePreviewModeHotkeys = () => {
|
|
8101
7897
|
|
8102
7898
|
// lib/use-puck.ts
|
8103
7899
|
init_react_import();
|
8104
|
-
var
|
7900
|
+
var import_react53 = require("react");
|
8105
7901
|
var import_zustand6 = require("zustand");
|
8106
7902
|
var generateUsePuck = (store) => {
|
8107
7903
|
const history = {
|
@@ -8135,7 +7931,7 @@ var generateUsePuck = (store) => {
|
|
8135
7931
|
const get = () => storeData;
|
8136
7932
|
return __spreadProps(__spreadValues({}, storeData), { get });
|
8137
7933
|
};
|
8138
|
-
var UsePuckStoreContext = (0,
|
7934
|
+
var UsePuckStoreContext = (0, import_react53.createContext)(
|
8139
7935
|
null
|
8140
7936
|
);
|
8141
7937
|
var convertToPickedStore = (store) => {
|
@@ -8149,12 +7945,12 @@ var convertToPickedStore = (store) => {
|
|
8149
7945
|
};
|
8150
7946
|
};
|
8151
7947
|
var useRegisterUsePuckStore = (appStore) => {
|
8152
|
-
const [usePuckStore] = (0,
|
7948
|
+
const [usePuckStore] = (0, import_react53.useState)(
|
8153
7949
|
() => (0, import_zustand6.createStore)(
|
8154
7950
|
() => generateUsePuck(convertToPickedStore(appStore.getState()))
|
8155
7951
|
)
|
8156
7952
|
);
|
8157
|
-
(0,
|
7953
|
+
(0, import_react53.useEffect)(() => {
|
8158
7954
|
return appStore.subscribe(
|
8159
7955
|
(store) => convertToPickedStore(store),
|
8160
7956
|
(pickedStore) => {
|
@@ -8166,7 +7962,7 @@ var useRegisterUsePuckStore = (appStore) => {
|
|
8166
7962
|
};
|
8167
7963
|
function createUsePuck() {
|
8168
7964
|
return function usePuck2(selector) {
|
8169
|
-
const usePuckApi = (0,
|
7965
|
+
const usePuckApi = (0, import_react53.useContext)(UsePuckStoreContext);
|
8170
7966
|
if (!usePuckApi) {
|
8171
7967
|
throw new Error("usePuck must be used inside <Puck>.");
|
8172
7968
|
}
|
@@ -8178,7 +7974,7 @@ function createUsePuck() {
|
|
8178
7974
|
};
|
8179
7975
|
}
|
8180
7976
|
function usePuck() {
|
8181
|
-
(0,
|
7977
|
+
(0, import_react53.useEffect)(() => {
|
8182
7978
|
console.warn(
|
8183
7979
|
"You're using the `usePuck` method without a selector, which may cause unnecessary re-renders. Replace with `createUsePuck` and provide a selector for improved performance."
|
8184
7980
|
);
|
@@ -8187,7 +7983,8 @@ function usePuck() {
|
|
8187
7983
|
}
|
8188
7984
|
|
8189
7985
|
// components/Puck/index.tsx
|
8190
|
-
var
|
7986
|
+
var import_fast_deep_equal2 = __toESM(require("fast-deep-equal"));
|
7987
|
+
var import_jsx_runtime41 = require("react/jsx-runtime");
|
8191
7988
|
var getClassName27 = get_class_name_factory_default("Puck", styles_module_default15);
|
8192
7989
|
var getLayoutClassName = get_class_name_factory_default("PuckLayout", styles_module_default15);
|
8193
7990
|
var FieldSideBar = () => {
|
@@ -8197,13 +7994,13 @@ var FieldSideBar = () => {
|
|
8197
7994
|
return s.selectedItem ? (_b = (_a = s.config.components[s.selectedItem.type]) == null ? void 0 : _a["label"]) != null ? _b : s.selectedItem.type.toString() : "Page";
|
8198
7995
|
}
|
8199
7996
|
);
|
8200
|
-
return /* @__PURE__ */ (0,
|
7997
|
+
return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(SidebarSection, { noPadding: true, noBorderTop: true, showBreadcrumbs: true, title, children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Fields, {}) });
|
8201
7998
|
};
|
8202
|
-
var propsContext = (0,
|
7999
|
+
var propsContext = (0, import_react54.createContext)({});
|
8203
8000
|
function PropsProvider(props) {
|
8204
|
-
return /* @__PURE__ */ (0,
|
8001
|
+
return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(propsContext.Provider, { value: props, children: props.children });
|
8205
8002
|
}
|
8206
|
-
var usePropsContext = () => (0,
|
8003
|
+
var usePropsContext = () => (0, import_react54.useContext)(propsContext);
|
8207
8004
|
function PuckProvider({ children }) {
|
8208
8005
|
const {
|
8209
8006
|
config,
|
@@ -8223,7 +8020,7 @@ function PuckProvider({ children }) {
|
|
8223
8020
|
enabled: true,
|
8224
8021
|
waitForStyles: true
|
8225
8022
|
}, _iframe);
|
8226
|
-
const [generatedAppState] = (0,
|
8023
|
+
const [generatedAppState] = (0, import_react54.useState)(() => {
|
8227
8024
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
8228
8025
|
const initial = __spreadValues(__spreadValues({}, defaultAppState.ui), initialUi);
|
8229
8026
|
let clientUiState = {};
|
@@ -8280,17 +8077,17 @@ function PuckProvider({ children }) {
|
|
8280
8077
|
) : {}
|
8281
8078
|
})
|
8282
8079
|
});
|
8283
|
-
return
|
8080
|
+
return walkAppState(newAppState, config);
|
8284
8081
|
});
|
8285
8082
|
const { appendData = true } = _initialHistory || {};
|
8286
|
-
const [blendedHistories] = (0,
|
8083
|
+
const [blendedHistories] = (0, import_react54.useState)(
|
8287
8084
|
[
|
8288
8085
|
...(_initialHistory == null ? void 0 : _initialHistory.histories) || [],
|
8289
8086
|
...appendData ? [{ state: generatedAppState }] : []
|
8290
8087
|
].map((history) => {
|
8291
8088
|
let newState = __spreadValues(__spreadValues({}, generatedAppState), history.state);
|
8292
8089
|
if (!history.state.indexes) {
|
8293
|
-
newState =
|
8090
|
+
newState = walkAppState(newState, config);
|
8294
8091
|
}
|
8295
8092
|
return __spreadProps(__spreadValues({}, history), {
|
8296
8093
|
state: newState
|
@@ -8303,7 +8100,7 @@ function PuckProvider({ children }) {
|
|
8303
8100
|
overrides,
|
8304
8101
|
plugins
|
8305
8102
|
});
|
8306
|
-
const generateAppStore = (0,
|
8103
|
+
const generateAppStore = (0, import_react54.useCallback)(
|
8307
8104
|
(state) => {
|
8308
8105
|
return {
|
8309
8106
|
state,
|
@@ -8327,10 +8124,10 @@ function PuckProvider({ children }) {
|
|
8327
8124
|
metadata
|
8328
8125
|
]
|
8329
8126
|
);
|
8330
|
-
const [appStore] = (0,
|
8127
|
+
const [appStore] = (0, import_react54.useState)(
|
8331
8128
|
() => createAppStore(generateAppStore(initialAppState))
|
8332
8129
|
);
|
8333
|
-
(0,
|
8130
|
+
(0, import_react54.useEffect)(() => {
|
8334
8131
|
const state = appStore.getState().state;
|
8335
8132
|
appStore.setState(__spreadValues({}, generateAppStore(state)));
|
8336
8133
|
}, [config, plugins, loadedOverrides, viewports, iframe, onAction, metadata]);
|
@@ -8339,22 +8136,29 @@ function PuckProvider({ children }) {
|
|
8339
8136
|
index: initialHistoryIndex,
|
8340
8137
|
initialAppState
|
8341
8138
|
});
|
8342
|
-
(0,
|
8343
|
-
|
8344
|
-
|
8345
|
-
|
8139
|
+
const previousData = (0, import_react54.useRef)(null);
|
8140
|
+
(0, import_react54.useEffect)(() => {
|
8141
|
+
appStore.subscribe(
|
8142
|
+
(s) => s.state.data,
|
8143
|
+
(data) => {
|
8144
|
+
if (onChange) {
|
8145
|
+
if ((0, import_fast_deep_equal2.default)(data, previousData.current)) return;
|
8146
|
+
onChange(data);
|
8147
|
+
previousData.current = data;
|
8148
|
+
}
|
8149
|
+
}
|
8150
|
+
);
|
8346
8151
|
}, []);
|
8347
8152
|
useRegisterPermissionsSlice(appStore, permissions);
|
8348
8153
|
const uPuckStore = useRegisterUsePuckStore(appStore);
|
8349
|
-
(0,
|
8154
|
+
(0, import_react54.useEffect)(() => {
|
8350
8155
|
const { resolveAndCommitData } = appStore.getState();
|
8351
8156
|
resolveAndCommitData();
|
8352
8157
|
}, []);
|
8353
|
-
return /* @__PURE__ */ (0,
|
8158
|
+
return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(appStoreContext.Provider, { value: appStore, children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(UsePuckStoreContext.Provider, { value: uPuckStore, children }) });
|
8354
8159
|
}
|
8355
8160
|
function PuckLayout({ children }) {
|
8356
8161
|
const {
|
8357
|
-
onChange,
|
8358
8162
|
onPublish,
|
8359
8163
|
renderHeader,
|
8360
8164
|
renderHeaderActions,
|
@@ -8373,18 +8177,13 @@ function PuckLayout({ children }) {
|
|
8373
8177
|
const rightSideBarVisible = useAppStore(
|
8374
8178
|
(s) => s.state.ui.rightSideBarVisible
|
8375
8179
|
);
|
8376
|
-
const [menuOpen, setMenuOpen] = (0,
|
8180
|
+
const [menuOpen, setMenuOpen] = (0, import_react54.useState)(false);
|
8377
8181
|
const appStore = useAppStoreApi();
|
8378
|
-
(0, import_react52.useEffect)(() => {
|
8379
|
-
return appStore.subscribe((s) => {
|
8380
|
-
if (onChange) onChange(s.state.data);
|
8381
|
-
});
|
8382
|
-
}, [appStore]);
|
8383
8182
|
const rootProps = useAppStore(
|
8384
8183
|
(s) => s.state.data.root.props || s.state.data.root.props
|
8385
8184
|
);
|
8386
8185
|
const dispatch = useAppStore((s) => s.dispatch);
|
8387
|
-
const toggleSidebars = (0,
|
8186
|
+
const toggleSidebars = (0, import_react54.useCallback)(
|
8388
8187
|
(sidebar) => {
|
8389
8188
|
const widerViewport = window.matchMedia("(min-width: 638px)").matches;
|
8390
8189
|
const sideBarVisible = sidebar === "left" ? leftSideBarVisible : rightSideBarVisible;
|
@@ -8398,7 +8197,7 @@ function PuckLayout({ children }) {
|
|
8398
8197
|
},
|
8399
8198
|
[dispatch, leftSideBarVisible, rightSideBarVisible]
|
8400
8199
|
);
|
8401
|
-
(0,
|
8200
|
+
(0, import_react54.useEffect)(() => {
|
8402
8201
|
if (!window.matchMedia("(min-width: 638px)").matches) {
|
8403
8202
|
dispatch({
|
8404
8203
|
type: "setUi",
|
@@ -8421,7 +8220,7 @@ function PuckLayout({ children }) {
|
|
8421
8220
|
window.removeEventListener("resize", handleResize);
|
8422
8221
|
};
|
8423
8222
|
}, []);
|
8424
|
-
const defaultHeaderRender = (0,
|
8223
|
+
const defaultHeaderRender = (0, import_react54.useMemo)(() => {
|
8425
8224
|
if (renderHeader) {
|
8426
8225
|
console.warn(
|
8427
8226
|
"`renderHeader` is deprecated. Please use `overrides.header` and the `usePuck` hook instead"
|
@@ -8430,13 +8229,13 @@ function PuckLayout({ children }) {
|
|
8430
8229
|
var _b = _a, { actions } = _b, props = __objRest(_b, ["actions"]);
|
8431
8230
|
const Comp = renderHeader;
|
8432
8231
|
const appState = useAppStore((s) => s.state);
|
8433
|
-
return /* @__PURE__ */ (0,
|
8232
|
+
return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState, children: actions }));
|
8434
8233
|
};
|
8435
8234
|
return RenderHeader;
|
8436
8235
|
}
|
8437
8236
|
return DefaultOverride;
|
8438
8237
|
}, [renderHeader]);
|
8439
|
-
const defaultHeaderActionsRender = (0,
|
8238
|
+
const defaultHeaderActionsRender = (0, import_react54.useMemo)(() => {
|
8440
8239
|
if (renderHeaderActions) {
|
8441
8240
|
console.warn(
|
8442
8241
|
"`renderHeaderActions` is deprecated. Please use `overrides.headerActions` and the `usePuck` hook instead."
|
@@ -8444,32 +8243,32 @@ function PuckLayout({ children }) {
|
|
8444
8243
|
const RenderHeader = (props) => {
|
8445
8244
|
const Comp = renderHeaderActions;
|
8446
8245
|
const appState = useAppStore((s) => s.state);
|
8447
|
-
return /* @__PURE__ */ (0,
|
8246
|
+
return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState }));
|
8448
8247
|
};
|
8449
8248
|
return RenderHeader;
|
8450
8249
|
}
|
8451
8250
|
return DefaultOverride;
|
8452
8251
|
}, [renderHeader]);
|
8453
8252
|
const overrides = useAppStore((s) => s.overrides);
|
8454
|
-
const CustomPuck = (0,
|
8253
|
+
const CustomPuck = (0, import_react54.useMemo)(
|
8455
8254
|
() => overrides.puck || DefaultOverride,
|
8456
8255
|
[overrides]
|
8457
8256
|
);
|
8458
|
-
const CustomHeader = (0,
|
8257
|
+
const CustomHeader = (0, import_react54.useMemo)(
|
8459
8258
|
() => overrides.header || defaultHeaderRender,
|
8460
8259
|
[overrides]
|
8461
8260
|
);
|
8462
|
-
const CustomHeaderActions = (0,
|
8261
|
+
const CustomHeaderActions = (0, import_react54.useMemo)(
|
8463
8262
|
() => overrides.headerActions || defaultHeaderActionsRender,
|
8464
8263
|
[overrides]
|
8465
8264
|
);
|
8466
|
-
const [mounted, setMounted] = (0,
|
8467
|
-
(0,
|
8265
|
+
const [mounted, setMounted] = (0, import_react54.useState)(false);
|
8266
|
+
(0, import_react54.useEffect)(() => {
|
8468
8267
|
setMounted(true);
|
8469
8268
|
}, []);
|
8470
8269
|
const ready = useAppStore((s) => s.status === "READY");
|
8471
8270
|
useMonitorHotkeys();
|
8472
|
-
(0,
|
8271
|
+
(0, import_react54.useEffect)(() => {
|
8473
8272
|
if (ready && iframe.enabled) {
|
8474
8273
|
const frameDoc = getFrame();
|
8475
8274
|
if (frameDoc) {
|
@@ -8478,8 +8277,8 @@ function PuckLayout({ children }) {
|
|
8478
8277
|
}
|
8479
8278
|
}, [ready, iframe.enabled]);
|
8480
8279
|
usePreviewModeHotkeys();
|
8481
|
-
return /* @__PURE__ */ (0,
|
8482
|
-
/* @__PURE__ */ (0,
|
8280
|
+
return /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: `Puck ${getClassName27()}`, children: [
|
8281
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)(DragDropContext, { disableAutoScroll: dnd == null ? void 0 : dnd.disableAutoScroll, children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(CustomPuck, { children: children || /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
|
8483
8282
|
"div",
|
8484
8283
|
{
|
8485
8284
|
className: getLayoutClassName({
|
@@ -8488,61 +8287,61 @@ function PuckLayout({ children }) {
|
|
8488
8287
|
mounted,
|
8489
8288
|
rightSideBarVisible
|
8490
8289
|
}),
|
8491
|
-
children: /* @__PURE__ */ (0,
|
8492
|
-
/* @__PURE__ */ (0,
|
8290
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: getLayoutClassName("inner"), children: [
|
8291
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
|
8493
8292
|
CustomHeader,
|
8494
8293
|
{
|
8495
|
-
actions: /* @__PURE__ */ (0,
|
8294
|
+
actions: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(import_jsx_runtime41.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(CustomHeaderActions, { children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
|
8496
8295
|
Button,
|
8497
8296
|
{
|
8498
8297
|
onClick: () => {
|
8499
8298
|
const data = appStore.getState().state.data;
|
8500
8299
|
onPublish && onPublish(data);
|
8501
8300
|
},
|
8502
|
-
icon: /* @__PURE__ */ (0,
|
8301
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Globe, { size: "14px" }),
|
8503
8302
|
children: "Publish"
|
8504
8303
|
}
|
8505
8304
|
) }) }),
|
8506
|
-
children: /* @__PURE__ */ (0,
|
8507
|
-
/* @__PURE__ */ (0,
|
8508
|
-
/* @__PURE__ */ (0,
|
8305
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("header", { className: getLayoutClassName("header"), children: /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: getLayoutClassName("headerInner"), children: [
|
8306
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: getLayoutClassName("headerToggle"), children: [
|
8307
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
|
8509
8308
|
"div",
|
8510
8309
|
{
|
8511
8310
|
className: getLayoutClassName("leftSideBarToggle"),
|
8512
|
-
children: /* @__PURE__ */ (0,
|
8311
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
|
8513
8312
|
IconButton,
|
8514
8313
|
{
|
8515
8314
|
onClick: () => {
|
8516
8315
|
toggleSidebars("left");
|
8517
8316
|
},
|
8518
8317
|
title: "Toggle left sidebar",
|
8519
|
-
children: /* @__PURE__ */ (0,
|
8318
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(PanelLeft, { focusable: "false" })
|
8520
8319
|
}
|
8521
8320
|
)
|
8522
8321
|
}
|
8523
8322
|
),
|
8524
|
-
/* @__PURE__ */ (0,
|
8323
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
|
8525
8324
|
"div",
|
8526
8325
|
{
|
8527
8326
|
className: getLayoutClassName("rightSideBarToggle"),
|
8528
|
-
children: /* @__PURE__ */ (0,
|
8327
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
|
8529
8328
|
IconButton,
|
8530
8329
|
{
|
8531
8330
|
onClick: () => {
|
8532
8331
|
toggleSidebars("right");
|
8533
8332
|
},
|
8534
8333
|
title: "Toggle right sidebar",
|
8535
|
-
children: /* @__PURE__ */ (0,
|
8334
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(PanelRight, { focusable: "false" })
|
8536
8335
|
}
|
8537
8336
|
)
|
8538
8337
|
}
|
8539
8338
|
)
|
8540
8339
|
] }),
|
8541
|
-
/* @__PURE__ */ (0,
|
8340
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { className: getLayoutClassName("headerTitle"), children: /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(Heading, { rank: "2", size: "xs", children: [
|
8542
8341
|
headerTitle || (rootProps == null ? void 0 : rootProps.title) || "Page",
|
8543
|
-
headerPath && /* @__PURE__ */ (0,
|
8342
|
+
headerPath && /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(import_jsx_runtime41.Fragment, { children: [
|
8544
8343
|
" ",
|
8545
|
-
/* @__PURE__ */ (0,
|
8344
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
|
8546
8345
|
"code",
|
8547
8346
|
{
|
8548
8347
|
className: getLayoutClassName("headerPath"),
|
@@ -8551,31 +8350,31 @@ function PuckLayout({ children }) {
|
|
8551
8350
|
)
|
8552
8351
|
] })
|
8553
8352
|
] }) }),
|
8554
|
-
/* @__PURE__ */ (0,
|
8555
|
-
/* @__PURE__ */ (0,
|
8353
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: getLayoutClassName("headerTools"), children: [
|
8354
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { className: getLayoutClassName("menuButton"), children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
|
8556
8355
|
IconButton,
|
8557
8356
|
{
|
8558
8357
|
onClick: () => {
|
8559
8358
|
return setMenuOpen(!menuOpen);
|
8560
8359
|
},
|
8561
8360
|
title: "Toggle menu bar",
|
8562
|
-
children: menuOpen ? /* @__PURE__ */ (0,
|
8361
|
+
children: menuOpen ? /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(ChevronUp, { focusable: "false" }) : /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(ChevronDown, { focusable: "false" })
|
8563
8362
|
}
|
8564
8363
|
) }),
|
8565
|
-
/* @__PURE__ */ (0,
|
8364
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
|
8566
8365
|
MenuBar,
|
8567
8366
|
{
|
8568
8367
|
dispatch,
|
8569
8368
|
onPublish,
|
8570
8369
|
menuOpen,
|
8571
|
-
renderHeaderActions: () => /* @__PURE__ */ (0,
|
8370
|
+
renderHeaderActions: () => /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(CustomHeaderActions, { children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
|
8572
8371
|
Button,
|
8573
8372
|
{
|
8574
8373
|
onClick: () => {
|
8575
8374
|
const data = appStore.getState().state.data;
|
8576
8375
|
onPublish && onPublish(data);
|
8577
8376
|
},
|
8578
|
-
icon: /* @__PURE__ */ (0,
|
8377
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Globe, { size: "14px" }),
|
8579
8378
|
children: "Publish"
|
8580
8379
|
}
|
8581
8380
|
) }),
|
@@ -8586,20 +8385,20 @@ function PuckLayout({ children }) {
|
|
8586
8385
|
] }) })
|
8587
8386
|
}
|
8588
8387
|
),
|
8589
|
-
/* @__PURE__ */ (0,
|
8590
|
-
/* @__PURE__ */ (0,
|
8591
|
-
/* @__PURE__ */ (0,
|
8388
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: getLayoutClassName("leftSideBar"), children: [
|
8389
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)(SidebarSection, { title: "Components", noBorderTop: true, children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Components, {}) }),
|
8390
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)(SidebarSection, { title: "Outline", children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Outline, {}) })
|
8592
8391
|
] }),
|
8593
|
-
/* @__PURE__ */ (0,
|
8594
|
-
/* @__PURE__ */ (0,
|
8392
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Canvas, {}),
|
8393
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { className: getLayoutClassName("rightSideBar"), children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(FieldSideBar, {}) })
|
8595
8394
|
] })
|
8596
8395
|
}
|
8597
8396
|
) }) }),
|
8598
|
-
/* @__PURE__ */ (0,
|
8397
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { id: "puck-portal-root", className: getClassName27("portal") })
|
8599
8398
|
] });
|
8600
8399
|
}
|
8601
8400
|
function Puck(props) {
|
8602
|
-
return /* @__PURE__ */ (0,
|
8401
|
+
return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(PropsProvider, __spreadProps(__spreadValues({}, props), { children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(PuckProvider, __spreadProps(__spreadValues({}, props), { children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(PuckLayout, __spreadValues({}, props)) })) }));
|
8603
8402
|
}
|
8604
8403
|
Puck.Components = Components;
|
8605
8404
|
Puck.Fields = Fields;
|
@@ -8631,9 +8430,9 @@ var migrations = [
|
|
8631
8430
|
console.log("Migrating DropZones to slots...");
|
8632
8431
|
const updatedItems = {};
|
8633
8432
|
const appState = __spreadProps(__spreadValues({}, defaultAppState), { data });
|
8634
|
-
const { indexes } =
|
8433
|
+
const { indexes } = walkAppState(appState, config);
|
8635
8434
|
const deletedCompounds = [];
|
8636
|
-
|
8435
|
+
walkAppState(appState, config, (content, zoneCompound, zoneType) => {
|
8637
8436
|
var _a2, _b;
|
8638
8437
|
if (zoneType === "dropzone") {
|
8639
8438
|
const [id, slotName] = zoneCompound.split(":");
|
@@ -8652,7 +8451,7 @@ var migrations = [
|
|
8652
8451
|
}
|
8653
8452
|
return content;
|
8654
8453
|
});
|
8655
|
-
const updated =
|
8454
|
+
const updated = walkAppState(
|
8656
8455
|
appState,
|
8657
8456
|
config,
|
8658
8457
|
(content) => content,
|
@@ -8806,13 +8605,13 @@ function resolveAllData(_0, _1) {
|
|
8806
8605
|
Puck,
|
8807
8606
|
Render,
|
8808
8607
|
createUsePuck,
|
8809
|
-
mapSlots,
|
8810
8608
|
migrate,
|
8811
8609
|
overrideKeys,
|
8812
8610
|
renderContext,
|
8813
8611
|
resolveAllData,
|
8814
8612
|
transformProps,
|
8815
|
-
usePuck
|
8613
|
+
usePuck,
|
8614
|
+
walkTree
|
8816
8615
|
});
|
8817
8616
|
/*! Bundled license information:
|
8818
8617
|
|