@measured/puck 0.20.0-canary.7d869af1 → 0.20.0-canary.82bd49a3
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 +9 -9
- package/dist/{chunk-FNRZXWXT.mjs → chunk-AQUDTV7N.mjs} +2185 -461
- package/dist/chunk-HUKJ36SA.mjs +1064 -0
- package/dist/index.css +20 -18
- package/dist/index.js +223 -222
- package/dist/index.mjs +4 -4
- package/dist/no-external.css +20 -18
- package/dist/no-external.js +223 -222
- package/dist/no-external.mjs +4 -4
- package/dist/rsc.js +455 -1808
- package/dist/rsc.mjs +1 -1
- package/package.json +1 -1
- package/dist/chunk-IP64IXIP.mjs +0 -2820
- package/dist/rsc.css +0 -26
|
@@ -2,46 +2,91 @@ import {
|
|
|
2
2
|
SlotRender,
|
|
3
3
|
SlotRenderPure,
|
|
4
4
|
__async,
|
|
5
|
+
__commonJS,
|
|
5
6
|
__objRest,
|
|
6
7
|
__spreadProps,
|
|
7
8
|
__spreadValues,
|
|
8
|
-
|
|
9
|
-
createAppStore,
|
|
9
|
+
__toESM,
|
|
10
10
|
defaultAppState,
|
|
11
11
|
defaultSlots,
|
|
12
12
|
defaultViewports,
|
|
13
13
|
expandNode,
|
|
14
|
-
|
|
15
|
-
getBox,
|
|
16
|
-
getInlineTextTransform,
|
|
17
|
-
getItem,
|
|
14
|
+
getChanged,
|
|
18
15
|
getSlotTransform,
|
|
19
|
-
get_class_name_factory_default,
|
|
20
16
|
init_react_import,
|
|
21
|
-
|
|
22
|
-
insertAction,
|
|
23
|
-
makeStatePublic,
|
|
24
|
-
monitorHotkeys,
|
|
25
|
-
populateIds,
|
|
26
|
-
reorder,
|
|
27
|
-
replace,
|
|
17
|
+
resolveComponentData,
|
|
28
18
|
rootAreaId,
|
|
29
19
|
rootDroppableId,
|
|
30
20
|
rootZone,
|
|
31
21
|
setupZone,
|
|
32
|
-
useAppStore,
|
|
33
|
-
useAppStoreApi,
|
|
34
22
|
useFieldTransforms,
|
|
35
|
-
useHotkey,
|
|
36
|
-
useMonitorHotkeys,
|
|
37
|
-
useRegisterFieldsSlice,
|
|
38
|
-
useRegisterHistorySlice,
|
|
39
|
-
useRegisterPermissionsSlice,
|
|
40
|
-
useResetAutoZoom,
|
|
41
23
|
useSlots,
|
|
42
24
|
walkAppState,
|
|
43
|
-
walkField
|
|
44
|
-
|
|
25
|
+
walkField,
|
|
26
|
+
walkTree
|
|
27
|
+
} from "./chunk-HUKJ36SA.mjs";
|
|
28
|
+
|
|
29
|
+
// ../../node_modules/classnames/index.js
|
|
30
|
+
var require_classnames = __commonJS({
|
|
31
|
+
"../../node_modules/classnames/index.js"(exports, module) {
|
|
32
|
+
"use strict";
|
|
33
|
+
init_react_import();
|
|
34
|
+
(function() {
|
|
35
|
+
"use strict";
|
|
36
|
+
var hasOwn = {}.hasOwnProperty;
|
|
37
|
+
function classNames() {
|
|
38
|
+
var classes = "";
|
|
39
|
+
for (var i = 0; i < arguments.length; i++) {
|
|
40
|
+
var arg = arguments[i];
|
|
41
|
+
if (arg) {
|
|
42
|
+
classes = appendClass(classes, parseValue(arg));
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return classes;
|
|
46
|
+
}
|
|
47
|
+
function parseValue(arg) {
|
|
48
|
+
if (typeof arg === "string" || typeof arg === "number") {
|
|
49
|
+
return arg;
|
|
50
|
+
}
|
|
51
|
+
if (typeof arg !== "object") {
|
|
52
|
+
return "";
|
|
53
|
+
}
|
|
54
|
+
if (Array.isArray(arg)) {
|
|
55
|
+
return classNames.apply(null, arg);
|
|
56
|
+
}
|
|
57
|
+
if (arg.toString !== Object.prototype.toString && !arg.toString.toString().includes("[native code]")) {
|
|
58
|
+
return arg.toString();
|
|
59
|
+
}
|
|
60
|
+
var classes = "";
|
|
61
|
+
for (var key in arg) {
|
|
62
|
+
if (hasOwn.call(arg, key) && arg[key]) {
|
|
63
|
+
classes = appendClass(classes, key);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return classes;
|
|
67
|
+
}
|
|
68
|
+
function appendClass(value, newClass) {
|
|
69
|
+
if (!newClass) {
|
|
70
|
+
return value;
|
|
71
|
+
}
|
|
72
|
+
if (value) {
|
|
73
|
+
return value + " " + newClass;
|
|
74
|
+
}
|
|
75
|
+
return value + newClass;
|
|
76
|
+
}
|
|
77
|
+
if (typeof module !== "undefined" && module.exports) {
|
|
78
|
+
classNames.default = classNames;
|
|
79
|
+
module.exports = classNames;
|
|
80
|
+
} else if (typeof define === "function" && typeof define.amd === "object" && define.amd) {
|
|
81
|
+
define("classnames", [], function() {
|
|
82
|
+
return classNames;
|
|
83
|
+
});
|
|
84
|
+
} else {
|
|
85
|
+
window.classNames = classNames;
|
|
86
|
+
}
|
|
87
|
+
})();
|
|
88
|
+
}
|
|
89
|
+
});
|
|
45
90
|
|
|
46
91
|
// types/API/Overrides.ts
|
|
47
92
|
init_react_import();
|
|
@@ -61,6 +106,33 @@ var overrideKeys = [
|
|
|
61
106
|
// components/ActionBar/index.tsx
|
|
62
107
|
init_react_import();
|
|
63
108
|
|
|
109
|
+
// lib/get-class-name-factory.ts
|
|
110
|
+
init_react_import();
|
|
111
|
+
var import_classnames = __toESM(require_classnames());
|
|
112
|
+
var getClassNameFactory = (rootClass, styles2, config = { baseClass: "" }) => (options = {}) => {
|
|
113
|
+
if (typeof options === "string") {
|
|
114
|
+
const descendant = options;
|
|
115
|
+
const style = styles2[`${rootClass}-${descendant}`];
|
|
116
|
+
if (style) {
|
|
117
|
+
return config.baseClass + styles2[`${rootClass}-${descendant}`] || "";
|
|
118
|
+
}
|
|
119
|
+
return "";
|
|
120
|
+
} else if (typeof options === "object") {
|
|
121
|
+
const modifiers = options;
|
|
122
|
+
const prefixedModifiers = {};
|
|
123
|
+
for (let modifier in modifiers) {
|
|
124
|
+
prefixedModifiers[styles2[`${rootClass}--${modifier}`]] = modifiers[modifier];
|
|
125
|
+
}
|
|
126
|
+
const c = styles2[rootClass];
|
|
127
|
+
return config.baseClass + (0, import_classnames.default)(__spreadValues({
|
|
128
|
+
[c]: !!c
|
|
129
|
+
}, prefixedModifiers));
|
|
130
|
+
} else {
|
|
131
|
+
return config.baseClass + styles2[rootClass] || "";
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
var get_class_name_factory_default = getClassNameFactory;
|
|
135
|
+
|
|
64
136
|
// css-module:/home/runner/work/puck/puck/packages/core/components/ActionBar/styles.module.css#css-module
|
|
65
137
|
init_react_import();
|
|
66
138
|
var styles_module_default = { "ActionBar": "_ActionBar_rvadt_1", "ActionBar-label": "_ActionBar-label_rvadt_18", "ActionBar-action": "_ActionBar-action_rvadt_30", "ActionBar-group": "_ActionBar-group_rvadt_38" };
|
|
@@ -98,22 +170,1440 @@ var Action = ({
|
|
|
98
170
|
children
|
|
99
171
|
}
|
|
100
172
|
);
|
|
101
|
-
var Group = ({ children }) => /* @__PURE__ */ jsx("div", { className: getClassName("group"), children });
|
|
102
|
-
var Label = ({ label }) => /* @__PURE__ */ jsx("div", { className: getClassName("label"), children: label });
|
|
103
|
-
ActionBar.Action = Action;
|
|
104
|
-
ActionBar.Label = Label;
|
|
105
|
-
ActionBar.Group = Group;
|
|
173
|
+
var Group = ({ children }) => /* @__PURE__ */ jsx("div", { className: getClassName("group"), children });
|
|
174
|
+
var Label = ({ label }) => /* @__PURE__ */ jsx("div", { className: getClassName("label"), children: label });
|
|
175
|
+
ActionBar.Action = Action;
|
|
176
|
+
ActionBar.Label = Label;
|
|
177
|
+
ActionBar.Group = Group;
|
|
178
|
+
|
|
179
|
+
// components/IconButton/IconButton.tsx
|
|
180
|
+
init_react_import();
|
|
181
|
+
import { useState } from "react";
|
|
182
|
+
|
|
183
|
+
// css-module:/home/runner/work/puck/puck/packages/core/components/IconButton/IconButton.module.css#css-module
|
|
184
|
+
init_react_import();
|
|
185
|
+
var IconButton_module_default = { "IconButton": "_IconButton_swpni_1", "IconButton--disabled": "_IconButton--disabled_swpni_20", "IconButton-title": "_IconButton-title_swpni_33" };
|
|
186
|
+
|
|
187
|
+
// components/Loader/index.tsx
|
|
188
|
+
init_react_import();
|
|
189
|
+
|
|
190
|
+
// lib/index.ts
|
|
191
|
+
init_react_import();
|
|
192
|
+
|
|
193
|
+
// lib/filter.ts
|
|
194
|
+
init_react_import();
|
|
195
|
+
|
|
196
|
+
// lib/data/reorder.ts
|
|
197
|
+
init_react_import();
|
|
198
|
+
var reorder = (list, startIndex, endIndex) => {
|
|
199
|
+
const result = Array.from(list);
|
|
200
|
+
const [removed] = result.splice(startIndex, 1);
|
|
201
|
+
result.splice(endIndex, 0, removed);
|
|
202
|
+
return result;
|
|
203
|
+
};
|
|
204
|
+
|
|
205
|
+
// lib/data/replace.ts
|
|
206
|
+
init_react_import();
|
|
207
|
+
var replace = (list, index, newItem) => {
|
|
208
|
+
const result = Array.from(list);
|
|
209
|
+
result.splice(index, 1);
|
|
210
|
+
result.splice(index, 0, newItem);
|
|
211
|
+
return result;
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
// lib/use-reset-auto-zoom.ts
|
|
215
|
+
init_react_import();
|
|
216
|
+
|
|
217
|
+
// store/index.ts
|
|
218
|
+
init_react_import();
|
|
219
|
+
|
|
220
|
+
// reducer/index.ts
|
|
221
|
+
init_react_import();
|
|
222
|
+
|
|
223
|
+
// reducer/actions/set.ts
|
|
224
|
+
init_react_import();
|
|
225
|
+
var setAction = (state, action, appStore) => {
|
|
226
|
+
if (typeof action.state === "object") {
|
|
227
|
+
const newState = __spreadValues(__spreadValues({}, state), action.state);
|
|
228
|
+
if (action.state.indexes) {
|
|
229
|
+
return newState;
|
|
230
|
+
}
|
|
231
|
+
console.warn(
|
|
232
|
+
"`set` is expensive and may cause unnecessary re-renders. Consider using a more atomic action instead."
|
|
233
|
+
);
|
|
234
|
+
return walkAppState(newState, appStore.config);
|
|
235
|
+
}
|
|
236
|
+
return __spreadValues(__spreadValues({}, state), action.state(state));
|
|
237
|
+
};
|
|
238
|
+
|
|
239
|
+
// reducer/actions/insert.ts
|
|
240
|
+
init_react_import();
|
|
241
|
+
|
|
242
|
+
// lib/data/insert.ts
|
|
243
|
+
init_react_import();
|
|
244
|
+
var insert = (list, index, item) => {
|
|
245
|
+
const result = Array.from(list || []);
|
|
246
|
+
result.splice(index, 0, item);
|
|
247
|
+
return result;
|
|
248
|
+
};
|
|
249
|
+
|
|
250
|
+
// lib/generate-id.ts
|
|
251
|
+
init_react_import();
|
|
252
|
+
import { v4 as uuidv4 } from "uuid";
|
|
253
|
+
var generateId = (type) => type ? `${type}-${uuidv4()}` : uuidv4();
|
|
254
|
+
|
|
255
|
+
// lib/data/get-ids-for-parent.ts
|
|
256
|
+
init_react_import();
|
|
257
|
+
var getIdsForParent = (zoneCompound, state) => {
|
|
258
|
+
const [parentId] = zoneCompound.split(":");
|
|
259
|
+
const node = state.indexes.nodes[parentId];
|
|
260
|
+
return ((node == null ? void 0 : node.path) || []).map((p) => p.split(":")[0]);
|
|
261
|
+
};
|
|
262
|
+
|
|
263
|
+
// lib/data/populate-ids.ts
|
|
264
|
+
init_react_import();
|
|
265
|
+
var populateIds = (data, config, override = false) => {
|
|
266
|
+
const id = generateId(data.type);
|
|
267
|
+
return walkTree(
|
|
268
|
+
__spreadProps(__spreadValues({}, data), {
|
|
269
|
+
props: override ? __spreadProps(__spreadValues({}, data.props), { id }) : __spreadValues({}, data.props)
|
|
270
|
+
}),
|
|
271
|
+
config,
|
|
272
|
+
(contents) => contents.map((item) => {
|
|
273
|
+
const id2 = generateId(item.type);
|
|
274
|
+
return __spreadProps(__spreadValues({}, item), {
|
|
275
|
+
props: override ? __spreadProps(__spreadValues({}, item.props), { id: id2 }) : __spreadValues({ id: id2 }, item.props)
|
|
276
|
+
});
|
|
277
|
+
})
|
|
278
|
+
);
|
|
279
|
+
};
|
|
280
|
+
|
|
281
|
+
// reducer/actions/insert.ts
|
|
282
|
+
function insertAction(state, action, appStore) {
|
|
283
|
+
const id = action.id || generateId(action.componentType);
|
|
284
|
+
const emptyComponentData = populateIds(
|
|
285
|
+
{
|
|
286
|
+
type: action.componentType,
|
|
287
|
+
props: __spreadProps(__spreadValues({}, appStore.config.components[action.componentType].defaultProps || {}), {
|
|
288
|
+
id
|
|
289
|
+
})
|
|
290
|
+
},
|
|
291
|
+
appStore.config
|
|
292
|
+
);
|
|
293
|
+
const [parentId] = action.destinationZone.split(":");
|
|
294
|
+
const idsInPath = getIdsForParent(action.destinationZone, state);
|
|
295
|
+
return walkAppState(
|
|
296
|
+
state,
|
|
297
|
+
appStore.config,
|
|
298
|
+
(content, zoneCompound) => {
|
|
299
|
+
if (zoneCompound === action.destinationZone) {
|
|
300
|
+
return insert(
|
|
301
|
+
content || [],
|
|
302
|
+
action.destinationIndex,
|
|
303
|
+
emptyComponentData
|
|
304
|
+
);
|
|
305
|
+
}
|
|
306
|
+
return content;
|
|
307
|
+
},
|
|
308
|
+
(childItem, path) => {
|
|
309
|
+
if (childItem.props.id === id || childItem.props.id === parentId) {
|
|
310
|
+
return childItem;
|
|
311
|
+
} else if (idsInPath.includes(childItem.props.id)) {
|
|
312
|
+
return childItem;
|
|
313
|
+
} else if (path.includes(action.destinationZone)) {
|
|
314
|
+
return childItem;
|
|
315
|
+
}
|
|
316
|
+
return null;
|
|
317
|
+
}
|
|
318
|
+
);
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
// reducer/actions/replace.ts
|
|
322
|
+
init_react_import();
|
|
323
|
+
var replaceAction = (state, action, appStore) => {
|
|
324
|
+
const [parentId] = action.destinationZone.split(":");
|
|
325
|
+
const idsInPath = getIdsForParent(action.destinationZone, state);
|
|
326
|
+
const originalId = state.indexes.zones[action.destinationZone].contentIds[action.destinationIndex];
|
|
327
|
+
const idChanged = originalId !== action.data.props.id;
|
|
328
|
+
if (idChanged) {
|
|
329
|
+
throw new Error(
|
|
330
|
+
`Can't change the id during a replace action. Please us "remove" and "insert" to define a new node.`
|
|
331
|
+
);
|
|
332
|
+
}
|
|
333
|
+
const newSlotIds = [];
|
|
334
|
+
const data = walkTree(action.data, appStore.config, (contents, opts) => {
|
|
335
|
+
newSlotIds.push(`${opts.parentId}:${opts.propName}`);
|
|
336
|
+
return contents.map((item) => {
|
|
337
|
+
const id = generateId(item.type);
|
|
338
|
+
return __spreadProps(__spreadValues({}, item), {
|
|
339
|
+
props: __spreadValues({ id }, item.props)
|
|
340
|
+
});
|
|
341
|
+
});
|
|
342
|
+
});
|
|
343
|
+
const stateWithDeepSlotsRemoved = __spreadValues({}, state);
|
|
344
|
+
Object.keys(state.indexes.zones).forEach((zoneCompound) => {
|
|
345
|
+
const id = zoneCompound.split(":")[0];
|
|
346
|
+
if (id === originalId) {
|
|
347
|
+
if (!newSlotIds.includes(zoneCompound)) {
|
|
348
|
+
delete stateWithDeepSlotsRemoved.indexes.zones[zoneCompound];
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
});
|
|
352
|
+
return walkAppState(
|
|
353
|
+
stateWithDeepSlotsRemoved,
|
|
354
|
+
appStore.config,
|
|
355
|
+
(content, zoneCompound) => {
|
|
356
|
+
const newContent = [...content];
|
|
357
|
+
if (zoneCompound === action.destinationZone) {
|
|
358
|
+
newContent[action.destinationIndex] = data;
|
|
359
|
+
}
|
|
360
|
+
return newContent;
|
|
361
|
+
},
|
|
362
|
+
(childItem, path) => {
|
|
363
|
+
const pathIds = path.map((p) => p.split(":")[0]);
|
|
364
|
+
if (childItem.props.id === data.props.id) {
|
|
365
|
+
return data;
|
|
366
|
+
} else if (childItem.props.id === parentId) {
|
|
367
|
+
return childItem;
|
|
368
|
+
} else if (idsInPath.indexOf(childItem.props.id) > -1) {
|
|
369
|
+
return childItem;
|
|
370
|
+
} else if (pathIds.indexOf(data.props.id) > -1) {
|
|
371
|
+
return childItem;
|
|
372
|
+
}
|
|
373
|
+
return null;
|
|
374
|
+
}
|
|
375
|
+
);
|
|
376
|
+
};
|
|
377
|
+
|
|
378
|
+
// reducer/actions/replace-root.ts
|
|
379
|
+
init_react_import();
|
|
380
|
+
var replaceRootAction = (state, action, appStore) => {
|
|
381
|
+
return walkAppState(
|
|
382
|
+
state,
|
|
383
|
+
appStore.config,
|
|
384
|
+
(content) => content,
|
|
385
|
+
(childItem) => {
|
|
386
|
+
if (childItem.props.id === "root") {
|
|
387
|
+
return __spreadProps(__spreadValues({}, childItem), {
|
|
388
|
+
props: __spreadValues(__spreadValues({}, childItem.props), action.root.props),
|
|
389
|
+
readOnly: action.root.readOnly
|
|
390
|
+
});
|
|
391
|
+
}
|
|
392
|
+
return childItem;
|
|
393
|
+
}
|
|
394
|
+
);
|
|
395
|
+
};
|
|
396
|
+
|
|
397
|
+
// reducer/actions/duplicate.ts
|
|
398
|
+
init_react_import();
|
|
399
|
+
|
|
400
|
+
// lib/data/get-item.ts
|
|
401
|
+
init_react_import();
|
|
402
|
+
function getItem(selector, state) {
|
|
403
|
+
var _a, _b;
|
|
404
|
+
const zone = (_a = state.indexes.zones) == null ? void 0 : _a[selector.zone || rootDroppableId];
|
|
405
|
+
return zone ? (_b = state.indexes.nodes[zone.contentIds[selector.index]]) == null ? void 0 : _b.data : void 0;
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
// reducer/actions/duplicate.ts
|
|
409
|
+
function duplicateAction(state, action, appStore) {
|
|
410
|
+
const item = getItem(
|
|
411
|
+
{ index: action.sourceIndex, zone: action.sourceZone },
|
|
412
|
+
state
|
|
413
|
+
);
|
|
414
|
+
const idsInPath = getIdsForParent(action.sourceZone, state);
|
|
415
|
+
const newItem = __spreadProps(__spreadValues({}, item), {
|
|
416
|
+
props: __spreadProps(__spreadValues({}, item.props), {
|
|
417
|
+
id: generateId(item.type)
|
|
418
|
+
})
|
|
419
|
+
});
|
|
420
|
+
const modified = walkAppState(
|
|
421
|
+
state,
|
|
422
|
+
appStore.config,
|
|
423
|
+
(content, zoneCompound) => {
|
|
424
|
+
if (zoneCompound === action.sourceZone) {
|
|
425
|
+
return insert(content, action.sourceIndex + 1, item);
|
|
426
|
+
}
|
|
427
|
+
return content;
|
|
428
|
+
},
|
|
429
|
+
(childItem, path, index) => {
|
|
430
|
+
const zoneCompound = path[path.length - 1];
|
|
431
|
+
const parents = path.map((p) => p.split(":")[0]);
|
|
432
|
+
if (parents.indexOf(newItem.props.id) > -1) {
|
|
433
|
+
return __spreadProps(__spreadValues({}, childItem), {
|
|
434
|
+
props: __spreadProps(__spreadValues({}, childItem.props), {
|
|
435
|
+
id: generateId(childItem.type)
|
|
436
|
+
})
|
|
437
|
+
});
|
|
438
|
+
}
|
|
439
|
+
if (zoneCompound === action.sourceZone && index === action.sourceIndex + 1) {
|
|
440
|
+
return newItem;
|
|
441
|
+
}
|
|
442
|
+
const [sourceZoneParent] = action.sourceZone.split(":");
|
|
443
|
+
if (sourceZoneParent === childItem.props.id || idsInPath.indexOf(childItem.props.id) > -1) {
|
|
444
|
+
return childItem;
|
|
445
|
+
}
|
|
446
|
+
return null;
|
|
447
|
+
}
|
|
448
|
+
);
|
|
449
|
+
return __spreadProps(__spreadValues({}, modified), {
|
|
450
|
+
ui: __spreadProps(__spreadValues({}, modified.ui), {
|
|
451
|
+
itemSelector: {
|
|
452
|
+
index: action.sourceIndex + 1,
|
|
453
|
+
zone: action.sourceZone
|
|
454
|
+
}
|
|
455
|
+
})
|
|
456
|
+
});
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
// reducer/actions/reorder.ts
|
|
460
|
+
init_react_import();
|
|
461
|
+
|
|
462
|
+
// reducer/actions/move.ts
|
|
463
|
+
init_react_import();
|
|
464
|
+
|
|
465
|
+
// lib/data/remove.ts
|
|
466
|
+
init_react_import();
|
|
467
|
+
var remove = (list, index) => {
|
|
468
|
+
const result = Array.from(list);
|
|
469
|
+
result.splice(index, 1);
|
|
470
|
+
return result;
|
|
471
|
+
};
|
|
472
|
+
|
|
473
|
+
// reducer/actions/move.ts
|
|
474
|
+
var moveAction = (state, action, appStore) => {
|
|
475
|
+
if (action.sourceZone === action.destinationZone && action.sourceIndex === action.destinationIndex) {
|
|
476
|
+
return state;
|
|
477
|
+
}
|
|
478
|
+
const item = getItem(
|
|
479
|
+
{ zone: action.sourceZone, index: action.sourceIndex },
|
|
480
|
+
state
|
|
481
|
+
);
|
|
482
|
+
if (!item) return state;
|
|
483
|
+
const idsInSourcePath = getIdsForParent(action.sourceZone, state);
|
|
484
|
+
const idsInDestinationPath = getIdsForParent(action.destinationZone, state);
|
|
485
|
+
return walkAppState(
|
|
486
|
+
state,
|
|
487
|
+
appStore.config,
|
|
488
|
+
(content, zoneCompound) => {
|
|
489
|
+
if (zoneCompound === action.sourceZone && zoneCompound === action.destinationZone) {
|
|
490
|
+
return insert(
|
|
491
|
+
remove(content, action.sourceIndex),
|
|
492
|
+
action.destinationIndex,
|
|
493
|
+
item
|
|
494
|
+
);
|
|
495
|
+
} else if (zoneCompound === action.sourceZone) {
|
|
496
|
+
return remove(content, action.sourceIndex);
|
|
497
|
+
} else if (zoneCompound === action.destinationZone) {
|
|
498
|
+
return insert(content, action.destinationIndex, item);
|
|
499
|
+
}
|
|
500
|
+
return content;
|
|
501
|
+
},
|
|
502
|
+
(childItem, path) => {
|
|
503
|
+
const [sourceZoneParent] = action.sourceZone.split(":");
|
|
504
|
+
const [destinationZoneParent] = action.destinationZone.split(":");
|
|
505
|
+
const childId = childItem.props.id;
|
|
506
|
+
if (sourceZoneParent === childId || destinationZoneParent === childId || item.props.id === childId || idsInSourcePath.indexOf(childId) > -1 || idsInDestinationPath.indexOf(childId) > -1 || path.includes(action.destinationZone)) {
|
|
507
|
+
return childItem;
|
|
508
|
+
}
|
|
509
|
+
return null;
|
|
510
|
+
}
|
|
511
|
+
);
|
|
512
|
+
};
|
|
513
|
+
|
|
514
|
+
// reducer/actions/reorder.ts
|
|
515
|
+
var reorderAction = (state, action, appStore) => {
|
|
516
|
+
return moveAction(
|
|
517
|
+
state,
|
|
518
|
+
{
|
|
519
|
+
type: "move",
|
|
520
|
+
sourceIndex: action.sourceIndex,
|
|
521
|
+
sourceZone: action.destinationZone,
|
|
522
|
+
destinationIndex: action.destinationIndex,
|
|
523
|
+
destinationZone: action.destinationZone
|
|
524
|
+
},
|
|
525
|
+
appStore
|
|
526
|
+
);
|
|
527
|
+
};
|
|
528
|
+
|
|
529
|
+
// reducer/actions/remove.ts
|
|
530
|
+
init_react_import();
|
|
531
|
+
var removeAction = (state, action, appStore) => {
|
|
532
|
+
const item = getItem({ index: action.index, zone: action.zone }, state);
|
|
533
|
+
const nodesToDelete = Object.entries(state.indexes.nodes).reduce(
|
|
534
|
+
(acc, [nodeId, nodeData]) => {
|
|
535
|
+
const pathIds = nodeData.path.map((p) => p.split(":")[0]);
|
|
536
|
+
if (pathIds.includes(item.props.id)) {
|
|
537
|
+
return [...acc, nodeId];
|
|
538
|
+
}
|
|
539
|
+
return acc;
|
|
540
|
+
},
|
|
541
|
+
[item.props.id]
|
|
542
|
+
);
|
|
543
|
+
const newState = walkAppState(
|
|
544
|
+
state,
|
|
545
|
+
appStore.config,
|
|
546
|
+
(content, zoneCompound) => {
|
|
547
|
+
if (zoneCompound === action.zone) {
|
|
548
|
+
return remove(content, action.index);
|
|
549
|
+
}
|
|
550
|
+
return content;
|
|
551
|
+
}
|
|
552
|
+
);
|
|
553
|
+
Object.keys(newState.data.zones || {}).forEach((zoneCompound) => {
|
|
554
|
+
const parentId = zoneCompound.split(":")[0];
|
|
555
|
+
if (nodesToDelete.includes(parentId) && newState.data.zones) {
|
|
556
|
+
delete newState.data.zones[zoneCompound];
|
|
557
|
+
}
|
|
558
|
+
});
|
|
559
|
+
Object.keys(newState.indexes.zones).forEach((zoneCompound) => {
|
|
560
|
+
const parentId = zoneCompound.split(":")[0];
|
|
561
|
+
if (nodesToDelete.includes(parentId)) {
|
|
562
|
+
delete newState.indexes.zones[zoneCompound];
|
|
563
|
+
}
|
|
564
|
+
});
|
|
565
|
+
nodesToDelete.forEach((id) => {
|
|
566
|
+
delete newState.indexes.nodes[id];
|
|
567
|
+
});
|
|
568
|
+
return newState;
|
|
569
|
+
};
|
|
570
|
+
|
|
571
|
+
// reducer/actions/register-zone.ts
|
|
572
|
+
init_react_import();
|
|
573
|
+
var zoneCache = {};
|
|
574
|
+
function registerZoneAction(state, action) {
|
|
575
|
+
if (zoneCache[action.zone]) {
|
|
576
|
+
return __spreadProps(__spreadValues({}, state), {
|
|
577
|
+
data: __spreadProps(__spreadValues({}, state.data), {
|
|
578
|
+
zones: __spreadProps(__spreadValues({}, state.data.zones), {
|
|
579
|
+
[action.zone]: zoneCache[action.zone]
|
|
580
|
+
})
|
|
581
|
+
}),
|
|
582
|
+
indexes: __spreadProps(__spreadValues({}, state.indexes), {
|
|
583
|
+
zones: __spreadProps(__spreadValues({}, state.indexes.zones), {
|
|
584
|
+
[action.zone]: __spreadProps(__spreadValues({}, state.indexes.zones[action.zone]), {
|
|
585
|
+
contentIds: zoneCache[action.zone].map((item) => item.props.id),
|
|
586
|
+
type: "dropzone"
|
|
587
|
+
})
|
|
588
|
+
})
|
|
589
|
+
})
|
|
590
|
+
});
|
|
591
|
+
}
|
|
592
|
+
return __spreadProps(__spreadValues({}, state), { data: setupZone(state.data, action.zone) });
|
|
593
|
+
}
|
|
594
|
+
function unregisterZoneAction(state, action) {
|
|
595
|
+
const _zones = __spreadValues({}, state.data.zones || {});
|
|
596
|
+
const zoneIndex = __spreadValues({}, state.indexes.zones || {});
|
|
597
|
+
if (_zones[action.zone]) {
|
|
598
|
+
zoneCache[action.zone] = _zones[action.zone];
|
|
599
|
+
delete _zones[action.zone];
|
|
600
|
+
}
|
|
601
|
+
delete zoneIndex[action.zone];
|
|
602
|
+
return __spreadProps(__spreadValues({}, state), {
|
|
603
|
+
data: __spreadProps(__spreadValues({}, state.data), {
|
|
604
|
+
zones: _zones
|
|
605
|
+
}),
|
|
606
|
+
indexes: __spreadProps(__spreadValues({}, state.indexes), {
|
|
607
|
+
zones: zoneIndex
|
|
608
|
+
})
|
|
609
|
+
});
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
// reducer/actions/set-data.ts
|
|
613
|
+
init_react_import();
|
|
614
|
+
var setDataAction = (state, action, appStore) => {
|
|
615
|
+
if (typeof action.data === "object") {
|
|
616
|
+
console.warn(
|
|
617
|
+
"`setData` is expensive and may cause unnecessary re-renders. Consider using a more atomic action instead."
|
|
618
|
+
);
|
|
619
|
+
return walkAppState(
|
|
620
|
+
__spreadProps(__spreadValues({}, state), {
|
|
621
|
+
data: __spreadValues(__spreadValues({}, state.data), action.data)
|
|
622
|
+
}),
|
|
623
|
+
appStore.config
|
|
624
|
+
);
|
|
625
|
+
}
|
|
626
|
+
return walkAppState(
|
|
627
|
+
__spreadProps(__spreadValues({}, state), {
|
|
628
|
+
data: __spreadValues(__spreadValues({}, state.data), action.data(state.data))
|
|
629
|
+
}),
|
|
630
|
+
appStore.config
|
|
631
|
+
);
|
|
632
|
+
};
|
|
633
|
+
|
|
634
|
+
// reducer/actions/set-ui.ts
|
|
635
|
+
init_react_import();
|
|
636
|
+
var setUiAction = (state, action) => {
|
|
637
|
+
if (typeof action.ui === "object") {
|
|
638
|
+
return __spreadProps(__spreadValues({}, state), {
|
|
639
|
+
ui: __spreadValues(__spreadValues({}, state.ui), action.ui)
|
|
640
|
+
});
|
|
641
|
+
}
|
|
642
|
+
return __spreadProps(__spreadValues({}, state), {
|
|
643
|
+
ui: __spreadValues(__spreadValues({}, state.ui), action.ui(state.ui))
|
|
644
|
+
});
|
|
645
|
+
};
|
|
646
|
+
|
|
647
|
+
// lib/data/make-state-public.ts
|
|
648
|
+
init_react_import();
|
|
649
|
+
var makeStatePublic = (state) => {
|
|
650
|
+
const { data, ui } = state;
|
|
651
|
+
return { data, ui };
|
|
652
|
+
};
|
|
653
|
+
|
|
654
|
+
// reducer/actions.tsx
|
|
655
|
+
init_react_import();
|
|
656
|
+
|
|
657
|
+
// reducer/index.ts
|
|
658
|
+
function storeInterceptor(reducer, record, onAction) {
|
|
659
|
+
return (state, action) => {
|
|
660
|
+
const newAppState = reducer(state, action);
|
|
661
|
+
const isValidType = ![
|
|
662
|
+
"registerZone",
|
|
663
|
+
"unregisterZone",
|
|
664
|
+
"setData",
|
|
665
|
+
"setUi",
|
|
666
|
+
"set"
|
|
667
|
+
].includes(action.type);
|
|
668
|
+
if (typeof action.recordHistory !== "undefined" ? action.recordHistory : isValidType) {
|
|
669
|
+
if (record) record(newAppState);
|
|
670
|
+
}
|
|
671
|
+
onAction == null ? void 0 : onAction(action, makeStatePublic(newAppState), makeStatePublic(state));
|
|
672
|
+
return newAppState;
|
|
673
|
+
};
|
|
674
|
+
}
|
|
675
|
+
function createReducer({
|
|
676
|
+
record,
|
|
677
|
+
onAction,
|
|
678
|
+
appStore
|
|
679
|
+
}) {
|
|
680
|
+
return storeInterceptor(
|
|
681
|
+
(state, action) => {
|
|
682
|
+
if (action.type === "set") {
|
|
683
|
+
return setAction(state, action, appStore);
|
|
684
|
+
}
|
|
685
|
+
if (action.type === "insert") {
|
|
686
|
+
return insertAction(state, action, appStore);
|
|
687
|
+
}
|
|
688
|
+
if (action.type === "replace") {
|
|
689
|
+
return replaceAction(state, action, appStore);
|
|
690
|
+
}
|
|
691
|
+
if (action.type === "replaceRoot") {
|
|
692
|
+
return replaceRootAction(state, action, appStore);
|
|
693
|
+
}
|
|
694
|
+
if (action.type === "duplicate") {
|
|
695
|
+
return duplicateAction(state, action, appStore);
|
|
696
|
+
}
|
|
697
|
+
if (action.type === "reorder") {
|
|
698
|
+
return reorderAction(state, action, appStore);
|
|
699
|
+
}
|
|
700
|
+
if (action.type === "move") {
|
|
701
|
+
return moveAction(state, action, appStore);
|
|
702
|
+
}
|
|
703
|
+
if (action.type === "remove") {
|
|
704
|
+
return removeAction(state, action, appStore);
|
|
705
|
+
}
|
|
706
|
+
if (action.type === "registerZone") {
|
|
707
|
+
return registerZoneAction(state, action);
|
|
708
|
+
}
|
|
709
|
+
if (action.type === "unregisterZone") {
|
|
710
|
+
return unregisterZoneAction(state, action);
|
|
711
|
+
}
|
|
712
|
+
if (action.type === "setData") {
|
|
713
|
+
return setDataAction(state, action, appStore);
|
|
714
|
+
}
|
|
715
|
+
if (action.type === "setUi") {
|
|
716
|
+
return setUiAction(state, action);
|
|
717
|
+
}
|
|
718
|
+
return state;
|
|
719
|
+
},
|
|
720
|
+
record,
|
|
721
|
+
onAction
|
|
722
|
+
);
|
|
723
|
+
}
|
|
724
|
+
|
|
725
|
+
// store/index.ts
|
|
726
|
+
import { create as create2, useStore } from "zustand";
|
|
727
|
+
import { subscribeWithSelector as subscribeWithSelector2 } from "zustand/middleware";
|
|
728
|
+
import { createContext, useContext } from "react";
|
|
729
|
+
|
|
730
|
+
// store/slices/history.ts
|
|
731
|
+
init_react_import();
|
|
732
|
+
import { useEffect as useEffect2 } from "react";
|
|
733
|
+
|
|
734
|
+
// lib/use-hotkey.ts
|
|
735
|
+
init_react_import();
|
|
736
|
+
import { useEffect } from "react";
|
|
737
|
+
import { create } from "zustand";
|
|
738
|
+
import { subscribeWithSelector } from "zustand/middleware";
|
|
739
|
+
var keyCodeMap = {
|
|
740
|
+
ControlLeft: "ctrl",
|
|
741
|
+
ControlRight: "ctrl",
|
|
742
|
+
MetaLeft: "meta",
|
|
743
|
+
MetaRight: "meta",
|
|
744
|
+
ShiftLeft: "shift",
|
|
745
|
+
ShiftRight: "shift",
|
|
746
|
+
KeyA: "a",
|
|
747
|
+
KeyB: "b",
|
|
748
|
+
KeyC: "c",
|
|
749
|
+
KeyD: "d",
|
|
750
|
+
KeyE: "e",
|
|
751
|
+
KeyF: "f",
|
|
752
|
+
KeyG: "g",
|
|
753
|
+
KeyH: "h",
|
|
754
|
+
KeyI: "i",
|
|
755
|
+
KeyJ: "j",
|
|
756
|
+
KeyK: "k",
|
|
757
|
+
KeyL: "l",
|
|
758
|
+
KeyM: "m",
|
|
759
|
+
KeyN: "n",
|
|
760
|
+
KeyO: "o",
|
|
761
|
+
KeyP: "p",
|
|
762
|
+
KeyQ: "q",
|
|
763
|
+
KeyR: "r",
|
|
764
|
+
KeyS: "s",
|
|
765
|
+
KeyT: "t",
|
|
766
|
+
KeyU: "u",
|
|
767
|
+
KeyV: "v",
|
|
768
|
+
KeyW: "w",
|
|
769
|
+
KeyX: "x",
|
|
770
|
+
KeyY: "y",
|
|
771
|
+
KeyZ: "z"
|
|
772
|
+
};
|
|
773
|
+
var useHotkeyStore = create()(
|
|
774
|
+
subscribeWithSelector((set) => ({
|
|
775
|
+
held: {},
|
|
776
|
+
hold: (key) => set((s) => s.held[key] ? s : { held: __spreadProps(__spreadValues({}, s.held), { [key]: true }) }),
|
|
777
|
+
release: (key) => set((s) => s.held[key] ? { held: __spreadProps(__spreadValues({}, s.held), { [key]: false }) } : s),
|
|
778
|
+
reset: (held = {}) => set(() => ({ held })),
|
|
779
|
+
triggers: {}
|
|
780
|
+
}))
|
|
781
|
+
);
|
|
782
|
+
var monitorHotkeys = (doc) => {
|
|
783
|
+
const onKeyDown = (e) => {
|
|
784
|
+
const key = keyCodeMap[e.code];
|
|
785
|
+
if (key) {
|
|
786
|
+
useHotkeyStore.getState().hold(key);
|
|
787
|
+
const { held, triggers } = useHotkeyStore.getState();
|
|
788
|
+
Object.values(triggers).forEach(({ combo, cb }) => {
|
|
789
|
+
const conditionMet = Object.entries(combo).every(
|
|
790
|
+
([key2, value]) => value === !!held[key2]
|
|
791
|
+
) && Object.entries(held).every(
|
|
792
|
+
([key2, value]) => value === !!combo[key2]
|
|
793
|
+
);
|
|
794
|
+
if (conditionMet) {
|
|
795
|
+
e.preventDefault();
|
|
796
|
+
cb();
|
|
797
|
+
}
|
|
798
|
+
});
|
|
799
|
+
if (key !== "meta" && key !== "ctrl" && key !== "shift") {
|
|
800
|
+
useHotkeyStore.getState().release(key);
|
|
801
|
+
}
|
|
802
|
+
}
|
|
803
|
+
};
|
|
804
|
+
const onKeyUp = (e) => {
|
|
805
|
+
const key = keyCodeMap[e.code];
|
|
806
|
+
if (key) {
|
|
807
|
+
if (key === "meta") {
|
|
808
|
+
useHotkeyStore.getState().reset();
|
|
809
|
+
} else {
|
|
810
|
+
useHotkeyStore.getState().release(key);
|
|
811
|
+
}
|
|
812
|
+
}
|
|
813
|
+
};
|
|
814
|
+
const onVisibilityChanged = (e) => {
|
|
815
|
+
if (document.visibilityState === "hidden") {
|
|
816
|
+
useHotkeyStore.getState().reset();
|
|
817
|
+
}
|
|
818
|
+
};
|
|
819
|
+
doc.addEventListener("keydown", onKeyDown);
|
|
820
|
+
doc.addEventListener("keyup", onKeyUp);
|
|
821
|
+
doc.addEventListener("visibilitychange", onVisibilityChanged);
|
|
822
|
+
return () => {
|
|
823
|
+
doc.removeEventListener("keydown", onKeyDown);
|
|
824
|
+
doc.removeEventListener("keyup", onKeyUp);
|
|
825
|
+
doc.removeEventListener("visibilitychange", onVisibilityChanged);
|
|
826
|
+
};
|
|
827
|
+
};
|
|
828
|
+
var useMonitorHotkeys = () => {
|
|
829
|
+
useEffect(() => monitorHotkeys(document), []);
|
|
830
|
+
};
|
|
831
|
+
var useHotkey = (combo, cb) => {
|
|
832
|
+
useEffect(
|
|
833
|
+
() => useHotkeyStore.setState((s) => ({
|
|
834
|
+
triggers: __spreadProps(__spreadValues({}, s.triggers), {
|
|
835
|
+
[`${Object.keys(combo).join("+")}`]: { combo, cb }
|
|
836
|
+
})
|
|
837
|
+
})),
|
|
838
|
+
[]
|
|
839
|
+
);
|
|
840
|
+
};
|
|
841
|
+
|
|
842
|
+
// store/slices/history.ts
|
|
843
|
+
var EMPTY_HISTORY_INDEX = 0;
|
|
844
|
+
function debounce(func, timeout3 = 300) {
|
|
845
|
+
let timer;
|
|
846
|
+
return (...args) => {
|
|
847
|
+
clearTimeout(timer);
|
|
848
|
+
timer = setTimeout(() => {
|
|
849
|
+
func(...args);
|
|
850
|
+
}, timeout3);
|
|
851
|
+
};
|
|
852
|
+
}
|
|
853
|
+
var tidyState = (state) => {
|
|
854
|
+
return __spreadProps(__spreadValues({}, state), {
|
|
855
|
+
ui: __spreadProps(__spreadValues({}, state.ui), {
|
|
856
|
+
field: {
|
|
857
|
+
focus: null
|
|
858
|
+
}
|
|
859
|
+
})
|
|
860
|
+
});
|
|
861
|
+
};
|
|
862
|
+
var createHistorySlice = (set, get) => {
|
|
863
|
+
const record = debounce((state) => {
|
|
864
|
+
const { histories, index } = get().history;
|
|
865
|
+
const history = {
|
|
866
|
+
state,
|
|
867
|
+
id: generateId("history")
|
|
868
|
+
};
|
|
869
|
+
const newHistories = [...histories.slice(0, index + 1), history];
|
|
870
|
+
set({
|
|
871
|
+
history: __spreadProps(__spreadValues({}, get().history), {
|
|
872
|
+
histories: newHistories,
|
|
873
|
+
index: newHistories.length - 1
|
|
874
|
+
})
|
|
875
|
+
});
|
|
876
|
+
}, 250);
|
|
877
|
+
return {
|
|
878
|
+
initialAppState: {},
|
|
879
|
+
index: EMPTY_HISTORY_INDEX,
|
|
880
|
+
histories: [],
|
|
881
|
+
hasPast: () => get().history.index > EMPTY_HISTORY_INDEX,
|
|
882
|
+
hasFuture: () => get().history.index < get().history.histories.length - 1,
|
|
883
|
+
prevHistory: () => {
|
|
884
|
+
const { history } = get();
|
|
885
|
+
return history.hasPast() ? history.histories[history.index - 1] : null;
|
|
886
|
+
},
|
|
887
|
+
nextHistory: () => {
|
|
888
|
+
const s = get().history;
|
|
889
|
+
return s.hasFuture() ? s.histories[s.index + 1] : null;
|
|
890
|
+
},
|
|
891
|
+
currentHistory: () => get().history.histories[get().history.index],
|
|
892
|
+
back: () => {
|
|
893
|
+
var _a;
|
|
894
|
+
const { history, dispatch } = get();
|
|
895
|
+
if (history.hasPast()) {
|
|
896
|
+
const state = tidyState(
|
|
897
|
+
((_a = history.prevHistory()) == null ? void 0 : _a.state) || history.initialAppState
|
|
898
|
+
);
|
|
899
|
+
dispatch({
|
|
900
|
+
type: "set",
|
|
901
|
+
state
|
|
902
|
+
});
|
|
903
|
+
set({ history: __spreadProps(__spreadValues({}, history), { index: history.index - 1 }) });
|
|
904
|
+
}
|
|
905
|
+
},
|
|
906
|
+
forward: () => {
|
|
907
|
+
var _a;
|
|
908
|
+
const { history, dispatch } = get();
|
|
909
|
+
if (history.hasFuture()) {
|
|
910
|
+
const state = (_a = history.nextHistory()) == null ? void 0 : _a.state;
|
|
911
|
+
dispatch({ type: "set", state: state ? tidyState(state) : {} });
|
|
912
|
+
set({ history: __spreadProps(__spreadValues({}, history), { index: history.index + 1 }) });
|
|
913
|
+
}
|
|
914
|
+
},
|
|
915
|
+
setHistories: (histories) => {
|
|
916
|
+
var _a;
|
|
917
|
+
const { dispatch, history } = get();
|
|
918
|
+
dispatch({
|
|
919
|
+
type: "set",
|
|
920
|
+
state: ((_a = histories[histories.length - 1]) == null ? void 0 : _a.state) || history.initialAppState
|
|
921
|
+
});
|
|
922
|
+
set({ history: __spreadProps(__spreadValues({}, history), { histories, index: histories.length - 1 }) });
|
|
923
|
+
},
|
|
924
|
+
setHistoryIndex: (index) => {
|
|
925
|
+
var _a;
|
|
926
|
+
const { dispatch, history } = get();
|
|
927
|
+
dispatch({
|
|
928
|
+
type: "set",
|
|
929
|
+
state: ((_a = history.histories[index]) == null ? void 0 : _a.state) || history.initialAppState
|
|
930
|
+
});
|
|
931
|
+
set({ history: __spreadProps(__spreadValues({}, history), { index }) });
|
|
932
|
+
},
|
|
933
|
+
record
|
|
934
|
+
};
|
|
935
|
+
};
|
|
936
|
+
function useRegisterHistorySlice(appStore, {
|
|
937
|
+
histories,
|
|
938
|
+
index,
|
|
939
|
+
initialAppState
|
|
940
|
+
}) {
|
|
941
|
+
useEffect2(
|
|
942
|
+
() => appStore.setState({
|
|
943
|
+
history: __spreadProps(__spreadValues({}, appStore.getState().history), {
|
|
944
|
+
histories,
|
|
945
|
+
index,
|
|
946
|
+
initialAppState
|
|
947
|
+
})
|
|
948
|
+
}),
|
|
949
|
+
[histories, index, initialAppState]
|
|
950
|
+
);
|
|
951
|
+
const back = () => {
|
|
952
|
+
appStore.getState().history.back();
|
|
953
|
+
};
|
|
954
|
+
const forward = () => {
|
|
955
|
+
appStore.getState().history.forward();
|
|
956
|
+
};
|
|
957
|
+
useHotkey({ meta: true, z: true }, back);
|
|
958
|
+
useHotkey({ meta: true, shift: true, z: true }, forward);
|
|
959
|
+
useHotkey({ meta: true, y: true }, forward);
|
|
960
|
+
useHotkey({ ctrl: true, z: true }, back);
|
|
961
|
+
useHotkey({ ctrl: true, shift: true, z: true }, forward);
|
|
962
|
+
useHotkey({ ctrl: true, y: true }, forward);
|
|
963
|
+
}
|
|
964
|
+
|
|
965
|
+
// store/slices/nodes.ts
|
|
966
|
+
init_react_import();
|
|
967
|
+
var createNodesSlice = (set, get) => ({
|
|
968
|
+
nodes: {},
|
|
969
|
+
registerNode: (id, node) => {
|
|
970
|
+
const s = get().nodes;
|
|
971
|
+
const emptyNode = {
|
|
972
|
+
id,
|
|
973
|
+
methods: {
|
|
974
|
+
sync: () => null,
|
|
975
|
+
hideOverlay: () => null,
|
|
976
|
+
showOverlay: () => null
|
|
977
|
+
},
|
|
978
|
+
element: null
|
|
979
|
+
};
|
|
980
|
+
const existingNode = s.nodes[id];
|
|
981
|
+
set({
|
|
982
|
+
nodes: __spreadProps(__spreadValues({}, s), {
|
|
983
|
+
nodes: __spreadProps(__spreadValues({}, s.nodes), {
|
|
984
|
+
[id]: __spreadProps(__spreadValues(__spreadValues(__spreadValues({}, emptyNode), existingNode), node), {
|
|
985
|
+
id
|
|
986
|
+
})
|
|
987
|
+
})
|
|
988
|
+
})
|
|
989
|
+
});
|
|
990
|
+
},
|
|
991
|
+
unregisterNode: (id) => {
|
|
992
|
+
const s = get().nodes;
|
|
993
|
+
const existingNode = s.nodes[id];
|
|
994
|
+
if (existingNode) {
|
|
995
|
+
const newNodes = __spreadValues({}, s.nodes);
|
|
996
|
+
delete newNodes[id];
|
|
997
|
+
set({
|
|
998
|
+
nodes: __spreadProps(__spreadValues({}, s), {
|
|
999
|
+
nodes: newNodes
|
|
1000
|
+
})
|
|
1001
|
+
});
|
|
1002
|
+
}
|
|
1003
|
+
}
|
|
1004
|
+
});
|
|
1005
|
+
|
|
1006
|
+
// store/slices/permissions.ts
|
|
1007
|
+
init_react_import();
|
|
1008
|
+
import { useEffect as useEffect3 } from "react";
|
|
1009
|
+
|
|
1010
|
+
// lib/data/flatten-data.ts
|
|
1011
|
+
init_react_import();
|
|
1012
|
+
var flattenData = (state, config) => {
|
|
1013
|
+
const data = [];
|
|
1014
|
+
walkAppState(
|
|
1015
|
+
state,
|
|
1016
|
+
config,
|
|
1017
|
+
(content) => content,
|
|
1018
|
+
(item) => {
|
|
1019
|
+
data.push(item);
|
|
1020
|
+
return null;
|
|
1021
|
+
}
|
|
1022
|
+
);
|
|
1023
|
+
return data;
|
|
1024
|
+
};
|
|
1025
|
+
|
|
1026
|
+
// store/slices/permissions.ts
|
|
1027
|
+
var createPermissionsSlice = (set, get) => {
|
|
1028
|
+
const resolvePermissions = (..._0) => __async(void 0, [..._0], function* (params = {}, force) {
|
|
1029
|
+
const { state, permissions, config } = get();
|
|
1030
|
+
const { cache, globalPermissions } = permissions;
|
|
1031
|
+
const resolveDataForItem = (item2, force2 = false) => __async(void 0, null, function* () {
|
|
1032
|
+
var _a, _b, _c;
|
|
1033
|
+
const { config: config2, state: appState, setComponentLoading } = get();
|
|
1034
|
+
const componentConfig = item2.type === "root" ? config2.root : config2.components[item2.type];
|
|
1035
|
+
if (!componentConfig) {
|
|
1036
|
+
return;
|
|
1037
|
+
}
|
|
1038
|
+
const initialPermissions = __spreadValues(__spreadValues({}, globalPermissions), componentConfig.permissions);
|
|
1039
|
+
if (componentConfig.resolvePermissions) {
|
|
1040
|
+
const changed = getChanged(item2, (_a = cache[item2.props.id]) == null ? void 0 : _a.lastData);
|
|
1041
|
+
if (Object.values(changed).some((el) => el === true) || force2) {
|
|
1042
|
+
const clearTimeout2 = setComponentLoading(item2.props.id, true, 50);
|
|
1043
|
+
const resolvedPermissions = yield componentConfig.resolvePermissions(
|
|
1044
|
+
item2,
|
|
1045
|
+
{
|
|
1046
|
+
changed,
|
|
1047
|
+
lastPermissions: ((_b = cache[item2.props.id]) == null ? void 0 : _b.lastPermissions) || null,
|
|
1048
|
+
permissions: initialPermissions,
|
|
1049
|
+
appState: makeStatePublic(appState),
|
|
1050
|
+
lastData: ((_c = cache[item2.props.id]) == null ? void 0 : _c.lastData) || null
|
|
1051
|
+
}
|
|
1052
|
+
);
|
|
1053
|
+
const latest = get().permissions;
|
|
1054
|
+
set({
|
|
1055
|
+
permissions: __spreadProps(__spreadValues({}, latest), {
|
|
1056
|
+
cache: __spreadProps(__spreadValues({}, latest.cache), {
|
|
1057
|
+
[item2.props.id]: {
|
|
1058
|
+
lastData: item2,
|
|
1059
|
+
lastPermissions: resolvedPermissions
|
|
1060
|
+
}
|
|
1061
|
+
}),
|
|
1062
|
+
resolvedPermissions: __spreadProps(__spreadValues({}, latest.resolvedPermissions), {
|
|
1063
|
+
[item2.props.id]: resolvedPermissions
|
|
1064
|
+
})
|
|
1065
|
+
})
|
|
1066
|
+
});
|
|
1067
|
+
clearTimeout2();
|
|
1068
|
+
}
|
|
1069
|
+
}
|
|
1070
|
+
});
|
|
1071
|
+
const resolveDataForRoot = (force2 = false) => {
|
|
1072
|
+
const { state: appState } = get();
|
|
1073
|
+
resolveDataForItem(
|
|
1074
|
+
// Shim the root data in by conforming to component data shape
|
|
1075
|
+
{
|
|
1076
|
+
type: "root",
|
|
1077
|
+
props: __spreadProps(__spreadValues({}, appState.data.root.props), { id: "root" })
|
|
1078
|
+
},
|
|
1079
|
+
force2
|
|
1080
|
+
);
|
|
1081
|
+
};
|
|
1082
|
+
const { item, type, root } = params;
|
|
1083
|
+
if (item) {
|
|
1084
|
+
yield resolveDataForItem(item, force);
|
|
1085
|
+
} else if (type) {
|
|
1086
|
+
flattenData(state, config).filter((item2) => item2.type === type).map((item2) => __async(void 0, null, function* () {
|
|
1087
|
+
yield resolveDataForItem(item2, force);
|
|
1088
|
+
}));
|
|
1089
|
+
} else if (root) {
|
|
1090
|
+
resolveDataForRoot(force);
|
|
1091
|
+
} else {
|
|
1092
|
+
flattenData(state, config).map((item2) => __async(void 0, null, function* () {
|
|
1093
|
+
yield resolveDataForItem(item2, force);
|
|
1094
|
+
}));
|
|
1095
|
+
}
|
|
1096
|
+
});
|
|
1097
|
+
const refreshPermissions = (params) => resolvePermissions(params, true);
|
|
1098
|
+
return {
|
|
1099
|
+
cache: {},
|
|
1100
|
+
globalPermissions: {
|
|
1101
|
+
drag: true,
|
|
1102
|
+
edit: true,
|
|
1103
|
+
delete: true,
|
|
1104
|
+
duplicate: true,
|
|
1105
|
+
insert: true
|
|
1106
|
+
},
|
|
1107
|
+
resolvedPermissions: {},
|
|
1108
|
+
getPermissions: ({ item, type, root } = {}) => {
|
|
1109
|
+
const { config, permissions } = get();
|
|
1110
|
+
const { globalPermissions, resolvedPermissions } = permissions;
|
|
1111
|
+
if (item) {
|
|
1112
|
+
const componentConfig = config.components[item.type];
|
|
1113
|
+
const initialPermissions = __spreadValues(__spreadValues({}, globalPermissions), componentConfig == null ? void 0 : componentConfig.permissions);
|
|
1114
|
+
const resolvedForItem = resolvedPermissions[item.props.id];
|
|
1115
|
+
return resolvedForItem ? __spreadValues(__spreadValues({}, globalPermissions), resolvedForItem) : initialPermissions;
|
|
1116
|
+
} else if (type) {
|
|
1117
|
+
const componentConfig = config.components[type];
|
|
1118
|
+
return __spreadValues(__spreadValues({}, globalPermissions), componentConfig == null ? void 0 : componentConfig.permissions);
|
|
1119
|
+
} else if (root) {
|
|
1120
|
+
const rootConfig = config.root;
|
|
1121
|
+
const initialPermissions = __spreadValues(__spreadValues({}, globalPermissions), rootConfig == null ? void 0 : rootConfig.permissions);
|
|
1122
|
+
const resolvedForItem = resolvedPermissions["root"];
|
|
1123
|
+
return resolvedForItem ? __spreadValues(__spreadValues({}, globalPermissions), resolvedForItem) : initialPermissions;
|
|
1124
|
+
}
|
|
1125
|
+
return globalPermissions;
|
|
1126
|
+
},
|
|
1127
|
+
resolvePermissions,
|
|
1128
|
+
refreshPermissions
|
|
1129
|
+
};
|
|
1130
|
+
};
|
|
1131
|
+
var useRegisterPermissionsSlice = (appStore, globalPermissions) => {
|
|
1132
|
+
useEffect3(() => {
|
|
1133
|
+
const { permissions } = appStore.getState();
|
|
1134
|
+
const { globalPermissions: existingGlobalPermissions } = permissions;
|
|
1135
|
+
appStore.setState({
|
|
1136
|
+
permissions: __spreadProps(__spreadValues({}, permissions), {
|
|
1137
|
+
globalPermissions: __spreadValues(__spreadValues({}, existingGlobalPermissions), globalPermissions)
|
|
1138
|
+
})
|
|
1139
|
+
});
|
|
1140
|
+
permissions.resolvePermissions();
|
|
1141
|
+
}, [globalPermissions]);
|
|
1142
|
+
useEffect3(() => {
|
|
1143
|
+
return appStore.subscribe(
|
|
1144
|
+
(s) => s.state.data,
|
|
1145
|
+
() => {
|
|
1146
|
+
appStore.getState().permissions.resolvePermissions();
|
|
1147
|
+
}
|
|
1148
|
+
);
|
|
1149
|
+
}, []);
|
|
1150
|
+
useEffect3(() => {
|
|
1151
|
+
return appStore.subscribe(
|
|
1152
|
+
(s) => s.config,
|
|
1153
|
+
() => {
|
|
1154
|
+
appStore.getState().permissions.resolvePermissions();
|
|
1155
|
+
}
|
|
1156
|
+
);
|
|
1157
|
+
}, []);
|
|
1158
|
+
};
|
|
1159
|
+
|
|
1160
|
+
// store/slices/fields.ts
|
|
1161
|
+
init_react_import();
|
|
1162
|
+
import { useCallback, useEffect as useEffect4 } from "react";
|
|
1163
|
+
var createFieldsSlice = (_set, _get) => {
|
|
1164
|
+
return {
|
|
1165
|
+
fields: {},
|
|
1166
|
+
loading: false,
|
|
1167
|
+
lastResolvedData: {},
|
|
1168
|
+
id: void 0
|
|
1169
|
+
};
|
|
1170
|
+
};
|
|
1171
|
+
var useRegisterFieldsSlice = (appStore, id) => {
|
|
1172
|
+
const resolveFields = useCallback(
|
|
1173
|
+
(reset) => __async(void 0, null, function* () {
|
|
1174
|
+
var _a, _b;
|
|
1175
|
+
const { fields, lastResolvedData } = appStore.getState().fields;
|
|
1176
|
+
const nodes = appStore.getState().state.indexes.nodes;
|
|
1177
|
+
const node = nodes[id || "root"];
|
|
1178
|
+
const componentData = node == null ? void 0 : node.data;
|
|
1179
|
+
const parentNode = (node == null ? void 0 : node.parentId) ? nodes[node.parentId] : null;
|
|
1180
|
+
const parent = (parentNode == null ? void 0 : parentNode.data) || null;
|
|
1181
|
+
const { getComponentConfig, state } = appStore.getState();
|
|
1182
|
+
const componentConfig = getComponentConfig(componentData == null ? void 0 : componentData.type);
|
|
1183
|
+
if (!componentData || !componentConfig) return;
|
|
1184
|
+
const defaultFields = componentConfig.fields || {};
|
|
1185
|
+
const resolver = componentConfig.resolveFields;
|
|
1186
|
+
let lastFields = fields;
|
|
1187
|
+
if (reset) {
|
|
1188
|
+
appStore.setState((s) => ({
|
|
1189
|
+
fields: __spreadProps(__spreadValues({}, s.fields), { fields: defaultFields, id })
|
|
1190
|
+
}));
|
|
1191
|
+
lastFields = defaultFields;
|
|
1192
|
+
}
|
|
1193
|
+
if (resolver) {
|
|
1194
|
+
const timeout3 = setTimeout(() => {
|
|
1195
|
+
appStore.setState((s) => ({
|
|
1196
|
+
fields: __spreadProps(__spreadValues({}, s.fields), { loading: true })
|
|
1197
|
+
}));
|
|
1198
|
+
}, 50);
|
|
1199
|
+
const lastData = ((_a = lastResolvedData.props) == null ? void 0 : _a.id) === id ? lastResolvedData : null;
|
|
1200
|
+
const changed = getChanged(componentData, lastData);
|
|
1201
|
+
const newFields = yield resolver(componentData, {
|
|
1202
|
+
changed,
|
|
1203
|
+
fields: defaultFields,
|
|
1204
|
+
lastFields,
|
|
1205
|
+
lastData,
|
|
1206
|
+
appState: makeStatePublic(state),
|
|
1207
|
+
parent
|
|
1208
|
+
});
|
|
1209
|
+
clearTimeout(timeout3);
|
|
1210
|
+
if (((_b = appStore.getState().selectedItem) == null ? void 0 : _b.props.id) !== id) {
|
|
1211
|
+
return;
|
|
1212
|
+
}
|
|
1213
|
+
appStore.setState({
|
|
1214
|
+
fields: {
|
|
1215
|
+
fields: newFields,
|
|
1216
|
+
loading: false,
|
|
1217
|
+
lastResolvedData: componentData,
|
|
1218
|
+
id
|
|
1219
|
+
}
|
|
1220
|
+
});
|
|
1221
|
+
} else {
|
|
1222
|
+
appStore.setState((s) => ({
|
|
1223
|
+
fields: __spreadProps(__spreadValues({}, s.fields), { fields: defaultFields, id })
|
|
1224
|
+
}));
|
|
1225
|
+
}
|
|
1226
|
+
}),
|
|
1227
|
+
[id]
|
|
1228
|
+
);
|
|
1229
|
+
useEffect4(() => {
|
|
1230
|
+
resolveFields(true);
|
|
1231
|
+
return appStore.subscribe(
|
|
1232
|
+
(s) => s.state.indexes.nodes[id || "root"],
|
|
1233
|
+
() => resolveFields()
|
|
1234
|
+
);
|
|
1235
|
+
}, [id]);
|
|
1236
|
+
};
|
|
1237
|
+
|
|
1238
|
+
// lib/data/to-root.ts
|
|
1239
|
+
init_react_import();
|
|
1240
|
+
var toRoot = (item) => {
|
|
1241
|
+
if ("type" in item && item.type !== "root") {
|
|
1242
|
+
throw new Error("Converting non-root item to root.");
|
|
1243
|
+
}
|
|
1244
|
+
const { readOnly } = item;
|
|
1245
|
+
if (item.props) {
|
|
1246
|
+
if ("id" in item.props) {
|
|
1247
|
+
const _a = item.props, { id } = _a, props = __objRest(_a, ["id"]);
|
|
1248
|
+
return { props, readOnly };
|
|
1249
|
+
}
|
|
1250
|
+
return { props: item.props, readOnly };
|
|
1251
|
+
}
|
|
1252
|
+
return { props: {}, readOnly };
|
|
1253
|
+
};
|
|
1254
|
+
|
|
1255
|
+
// store/index.ts
|
|
1256
|
+
var defaultPageFields = {
|
|
1257
|
+
title: { type: "text" }
|
|
1258
|
+
};
|
|
1259
|
+
var createAppStore = (initialAppStore) => create2()(
|
|
1260
|
+
subscribeWithSelector2((set, get) => {
|
|
1261
|
+
var _a, _b;
|
|
1262
|
+
return __spreadProps(__spreadValues({
|
|
1263
|
+
state: defaultAppState,
|
|
1264
|
+
config: { components: {} },
|
|
1265
|
+
componentState: {},
|
|
1266
|
+
plugins: [],
|
|
1267
|
+
overrides: {},
|
|
1268
|
+
viewports: defaultViewports,
|
|
1269
|
+
zoomConfig: {
|
|
1270
|
+
autoZoom: 1,
|
|
1271
|
+
rootHeight: 0,
|
|
1272
|
+
zoom: 1
|
|
1273
|
+
},
|
|
1274
|
+
status: "LOADING",
|
|
1275
|
+
iframe: {},
|
|
1276
|
+
metadata: {},
|
|
1277
|
+
fieldTransforms: {}
|
|
1278
|
+
}, initialAppStore), {
|
|
1279
|
+
fields: createFieldsSlice(set, get),
|
|
1280
|
+
history: createHistorySlice(set, get),
|
|
1281
|
+
nodes: createNodesSlice(set, get),
|
|
1282
|
+
permissions: createPermissionsSlice(set, get),
|
|
1283
|
+
getComponentConfig: (type) => {
|
|
1284
|
+
var _a2;
|
|
1285
|
+
const { config, selectedItem } = get();
|
|
1286
|
+
const rootFields = ((_a2 = config.root) == null ? void 0 : _a2.fields) || defaultPageFields;
|
|
1287
|
+
return type && type !== "root" ? config.components[type] : selectedItem ? config.components[selectedItem.type] : __spreadProps(__spreadValues({}, config.root), { fields: rootFields });
|
|
1288
|
+
},
|
|
1289
|
+
selectedItem: ((_a = initialAppStore == null ? void 0 : initialAppStore.state) == null ? void 0 : _a.ui.itemSelector) ? getItem(
|
|
1290
|
+
(_b = initialAppStore == null ? void 0 : initialAppStore.state) == null ? void 0 : _b.ui.itemSelector,
|
|
1291
|
+
initialAppStore.state
|
|
1292
|
+
) : null,
|
|
1293
|
+
dispatch: (action) => set((s) => {
|
|
1294
|
+
var _a2, _b2;
|
|
1295
|
+
const { record } = get().history;
|
|
1296
|
+
const dispatch = createReducer({
|
|
1297
|
+
record,
|
|
1298
|
+
appStore: s
|
|
1299
|
+
});
|
|
1300
|
+
const state = dispatch(s.state, action);
|
|
1301
|
+
const selectedItem = state.ui.itemSelector ? getItem(state.ui.itemSelector, state) : null;
|
|
1302
|
+
(_b2 = (_a2 = get()).onAction) == null ? void 0 : _b2.call(_a2, action, state, get().state);
|
|
1303
|
+
return __spreadProps(__spreadValues({}, s), { state, selectedItem });
|
|
1304
|
+
}),
|
|
1305
|
+
setZoomConfig: (zoomConfig) => set({ zoomConfig }),
|
|
1306
|
+
setStatus: (status) => set({ status }),
|
|
1307
|
+
setComponentState: (componentState) => set({ componentState }),
|
|
1308
|
+
pendingLoadTimeouts: {},
|
|
1309
|
+
setComponentLoading: (id, loading = true, defer2 = 0) => {
|
|
1310
|
+
const { setComponentState, pendingLoadTimeouts } = get();
|
|
1311
|
+
const loadId = generateId();
|
|
1312
|
+
const setLoading = () => {
|
|
1313
|
+
var _a2;
|
|
1314
|
+
const { componentState } = get();
|
|
1315
|
+
setComponentState(__spreadProps(__spreadValues({}, componentState), {
|
|
1316
|
+
[id]: __spreadProps(__spreadValues({}, componentState[id]), {
|
|
1317
|
+
loadingCount: (((_a2 = componentState[id]) == null ? void 0 : _a2.loadingCount) || 0) + 1
|
|
1318
|
+
})
|
|
1319
|
+
}));
|
|
1320
|
+
};
|
|
1321
|
+
const unsetLoading = () => {
|
|
1322
|
+
var _a2;
|
|
1323
|
+
const { componentState } = get();
|
|
1324
|
+
clearTimeout(timeout3);
|
|
1325
|
+
delete pendingLoadTimeouts[loadId];
|
|
1326
|
+
set({ pendingLoadTimeouts });
|
|
1327
|
+
setComponentState(__spreadProps(__spreadValues({}, componentState), {
|
|
1328
|
+
[id]: __spreadProps(__spreadValues({}, componentState[id]), {
|
|
1329
|
+
loadingCount: Math.max(
|
|
1330
|
+
(((_a2 = componentState[id]) == null ? void 0 : _a2.loadingCount) || 0) - 1,
|
|
1331
|
+
0
|
|
1332
|
+
)
|
|
1333
|
+
})
|
|
1334
|
+
}));
|
|
1335
|
+
};
|
|
1336
|
+
const timeout3 = setTimeout(() => {
|
|
1337
|
+
if (loading) {
|
|
1338
|
+
setLoading();
|
|
1339
|
+
} else {
|
|
1340
|
+
unsetLoading();
|
|
1341
|
+
}
|
|
1342
|
+
delete pendingLoadTimeouts[loadId];
|
|
1343
|
+
set({ pendingLoadTimeouts });
|
|
1344
|
+
}, defer2);
|
|
1345
|
+
set({
|
|
1346
|
+
pendingLoadTimeouts: __spreadProps(__spreadValues({}, pendingLoadTimeouts), {
|
|
1347
|
+
[id]: timeout3
|
|
1348
|
+
})
|
|
1349
|
+
});
|
|
1350
|
+
return unsetLoading;
|
|
1351
|
+
},
|
|
1352
|
+
unsetComponentLoading: (id) => {
|
|
1353
|
+
const { setComponentLoading } = get();
|
|
1354
|
+
setComponentLoading(id, false);
|
|
1355
|
+
},
|
|
1356
|
+
// Helper
|
|
1357
|
+
setUi: (ui, recordHistory) => set((s) => {
|
|
1358
|
+
const dispatch = createReducer({
|
|
1359
|
+
record: () => {
|
|
1360
|
+
},
|
|
1361
|
+
appStore: s
|
|
1362
|
+
});
|
|
1363
|
+
const state = dispatch(s.state, {
|
|
1364
|
+
type: "setUi",
|
|
1365
|
+
ui,
|
|
1366
|
+
recordHistory
|
|
1367
|
+
});
|
|
1368
|
+
const selectedItem = state.ui.itemSelector ? getItem(state.ui.itemSelector, state) : null;
|
|
1369
|
+
return __spreadProps(__spreadValues({}, s), { state, selectedItem });
|
|
1370
|
+
}),
|
|
1371
|
+
resolveComponentData: (componentData, trigger) => __async(void 0, null, function* () {
|
|
1372
|
+
const { config, metadata, setComponentLoading, permissions } = get();
|
|
1373
|
+
const timeouts = {};
|
|
1374
|
+
return yield resolveComponentData(
|
|
1375
|
+
componentData,
|
|
1376
|
+
config,
|
|
1377
|
+
metadata,
|
|
1378
|
+
(item) => {
|
|
1379
|
+
const id = "id" in item.props ? item.props.id : "root";
|
|
1380
|
+
timeouts[id] = setComponentLoading(id, true, 50);
|
|
1381
|
+
},
|
|
1382
|
+
(item) => __async(void 0, null, function* () {
|
|
1383
|
+
const id = "id" in item.props ? item.props.id : "root";
|
|
1384
|
+
if ("type" in item) {
|
|
1385
|
+
yield permissions.refreshPermissions({ item });
|
|
1386
|
+
} else {
|
|
1387
|
+
yield permissions.refreshPermissions({ root: true });
|
|
1388
|
+
}
|
|
1389
|
+
timeouts[id]();
|
|
1390
|
+
}),
|
|
1391
|
+
trigger
|
|
1392
|
+
);
|
|
1393
|
+
}),
|
|
1394
|
+
resolveAndCommitData: () => __async(void 0, null, function* () {
|
|
1395
|
+
const { config, state, dispatch, resolveComponentData: resolveComponentData2 } = get();
|
|
1396
|
+
walkAppState(
|
|
1397
|
+
state,
|
|
1398
|
+
config,
|
|
1399
|
+
(content) => content,
|
|
1400
|
+
(childItem) => {
|
|
1401
|
+
resolveComponentData2(childItem, "load").then((resolved) => {
|
|
1402
|
+
const { state: state2 } = get();
|
|
1403
|
+
const node = state2.indexes.nodes[resolved.node.props.id];
|
|
1404
|
+
if (node && resolved.didChange) {
|
|
1405
|
+
if (resolved.node.props.id === "root") {
|
|
1406
|
+
dispatch({
|
|
1407
|
+
type: "replaceRoot",
|
|
1408
|
+
root: toRoot(resolved.node)
|
|
1409
|
+
});
|
|
1410
|
+
} else {
|
|
1411
|
+
const zoneCompound = `${node.parentId}:${node.zone}`;
|
|
1412
|
+
const parentZone = state2.indexes.zones[zoneCompound];
|
|
1413
|
+
const index = parentZone.contentIds.indexOf(
|
|
1414
|
+
resolved.node.props.id
|
|
1415
|
+
);
|
|
1416
|
+
dispatch({
|
|
1417
|
+
type: "replace",
|
|
1418
|
+
data: resolved.node,
|
|
1419
|
+
destinationIndex: index,
|
|
1420
|
+
destinationZone: zoneCompound
|
|
1421
|
+
});
|
|
1422
|
+
}
|
|
1423
|
+
}
|
|
1424
|
+
});
|
|
1425
|
+
return childItem;
|
|
1426
|
+
}
|
|
1427
|
+
);
|
|
1428
|
+
})
|
|
1429
|
+
});
|
|
1430
|
+
})
|
|
1431
|
+
);
|
|
1432
|
+
var appStoreContext = createContext(createAppStore());
|
|
1433
|
+
function useAppStore(selector) {
|
|
1434
|
+
const context = useContext(appStoreContext);
|
|
1435
|
+
return useStore(context, selector);
|
|
1436
|
+
}
|
|
1437
|
+
function useAppStoreApi() {
|
|
1438
|
+
return useContext(appStoreContext);
|
|
1439
|
+
}
|
|
106
1440
|
|
|
107
|
-
//
|
|
1441
|
+
// lib/get-zoom-config.ts
|
|
108
1442
|
init_react_import();
|
|
109
|
-
import { useState } from "react";
|
|
110
1443
|
|
|
111
|
-
// css-
|
|
1444
|
+
// ../../node_modules/css-box-model/dist/css-box-model.esm.js
|
|
112
1445
|
init_react_import();
|
|
113
|
-
var IconButton_module_default = { "IconButton": "_IconButton_swpni_1", "IconButton--disabled": "_IconButton--disabled_swpni_20", "IconButton-title": "_IconButton-title_swpni_33" };
|
|
114
1446
|
|
|
115
|
-
//
|
|
1447
|
+
// ../../node_modules/tiny-invariant/dist/esm/tiny-invariant.js
|
|
116
1448
|
init_react_import();
|
|
1449
|
+
var isProduction = process.env.NODE_ENV === "production";
|
|
1450
|
+
var prefix = "Invariant failed";
|
|
1451
|
+
function invariant(condition, message) {
|
|
1452
|
+
if (condition) {
|
|
1453
|
+
return;
|
|
1454
|
+
}
|
|
1455
|
+
if (isProduction) {
|
|
1456
|
+
throw new Error(prefix);
|
|
1457
|
+
}
|
|
1458
|
+
var provided = typeof message === "function" ? message() : message;
|
|
1459
|
+
var value = provided ? "".concat(prefix, ": ").concat(provided) : prefix;
|
|
1460
|
+
throw new Error(value);
|
|
1461
|
+
}
|
|
1462
|
+
|
|
1463
|
+
// ../../node_modules/css-box-model/dist/css-box-model.esm.js
|
|
1464
|
+
var getRect = function getRect2(_ref) {
|
|
1465
|
+
var top = _ref.top, right = _ref.right, bottom = _ref.bottom, left = _ref.left;
|
|
1466
|
+
var width = right - left;
|
|
1467
|
+
var height = bottom - top;
|
|
1468
|
+
var rect = {
|
|
1469
|
+
top,
|
|
1470
|
+
right,
|
|
1471
|
+
bottom,
|
|
1472
|
+
left,
|
|
1473
|
+
width,
|
|
1474
|
+
height,
|
|
1475
|
+
x: left,
|
|
1476
|
+
y: top,
|
|
1477
|
+
center: {
|
|
1478
|
+
x: (right + left) / 2,
|
|
1479
|
+
y: (bottom + top) / 2
|
|
1480
|
+
}
|
|
1481
|
+
};
|
|
1482
|
+
return rect;
|
|
1483
|
+
};
|
|
1484
|
+
var expand = function expand2(target, expandBy) {
|
|
1485
|
+
return {
|
|
1486
|
+
top: target.top - expandBy.top,
|
|
1487
|
+
left: target.left - expandBy.left,
|
|
1488
|
+
bottom: target.bottom + expandBy.bottom,
|
|
1489
|
+
right: target.right + expandBy.right
|
|
1490
|
+
};
|
|
1491
|
+
};
|
|
1492
|
+
var shrink = function shrink2(target, shrinkBy) {
|
|
1493
|
+
return {
|
|
1494
|
+
top: target.top + shrinkBy.top,
|
|
1495
|
+
left: target.left + shrinkBy.left,
|
|
1496
|
+
bottom: target.bottom - shrinkBy.bottom,
|
|
1497
|
+
right: target.right - shrinkBy.right
|
|
1498
|
+
};
|
|
1499
|
+
};
|
|
1500
|
+
var noSpacing = {
|
|
1501
|
+
top: 0,
|
|
1502
|
+
right: 0,
|
|
1503
|
+
bottom: 0,
|
|
1504
|
+
left: 0
|
|
1505
|
+
};
|
|
1506
|
+
var createBox = function createBox2(_ref2) {
|
|
1507
|
+
var borderBox = _ref2.borderBox, _ref2$margin = _ref2.margin, margin = _ref2$margin === void 0 ? noSpacing : _ref2$margin, _ref2$border = _ref2.border, border = _ref2$border === void 0 ? noSpacing : _ref2$border, _ref2$padding = _ref2.padding, padding = _ref2$padding === void 0 ? noSpacing : _ref2$padding;
|
|
1508
|
+
var marginBox = getRect(expand(borderBox, margin));
|
|
1509
|
+
var paddingBox = getRect(shrink(borderBox, border));
|
|
1510
|
+
var contentBox = getRect(shrink(paddingBox, padding));
|
|
1511
|
+
return {
|
|
1512
|
+
marginBox,
|
|
1513
|
+
borderBox: getRect(borderBox),
|
|
1514
|
+
paddingBox,
|
|
1515
|
+
contentBox,
|
|
1516
|
+
margin,
|
|
1517
|
+
border,
|
|
1518
|
+
padding
|
|
1519
|
+
};
|
|
1520
|
+
};
|
|
1521
|
+
var parse = function parse2(raw) {
|
|
1522
|
+
var value = raw.slice(0, -2);
|
|
1523
|
+
var suffix = raw.slice(-2);
|
|
1524
|
+
if (suffix !== "px") {
|
|
1525
|
+
return 0;
|
|
1526
|
+
}
|
|
1527
|
+
var result = Number(value);
|
|
1528
|
+
!!isNaN(result) ? process.env.NODE_ENV !== "production" ? invariant(false, "Could not parse value [raw: " + raw + ", without suffix: " + value + "]") : invariant(false) : void 0;
|
|
1529
|
+
return result;
|
|
1530
|
+
};
|
|
1531
|
+
var calculateBox = function calculateBox2(borderBox, styles2) {
|
|
1532
|
+
var margin = {
|
|
1533
|
+
top: parse(styles2.marginTop),
|
|
1534
|
+
right: parse(styles2.marginRight),
|
|
1535
|
+
bottom: parse(styles2.marginBottom),
|
|
1536
|
+
left: parse(styles2.marginLeft)
|
|
1537
|
+
};
|
|
1538
|
+
var padding = {
|
|
1539
|
+
top: parse(styles2.paddingTop),
|
|
1540
|
+
right: parse(styles2.paddingRight),
|
|
1541
|
+
bottom: parse(styles2.paddingBottom),
|
|
1542
|
+
left: parse(styles2.paddingLeft)
|
|
1543
|
+
};
|
|
1544
|
+
var border = {
|
|
1545
|
+
top: parse(styles2.borderTopWidth),
|
|
1546
|
+
right: parse(styles2.borderRightWidth),
|
|
1547
|
+
bottom: parse(styles2.borderBottomWidth),
|
|
1548
|
+
left: parse(styles2.borderLeftWidth)
|
|
1549
|
+
};
|
|
1550
|
+
return createBox({
|
|
1551
|
+
borderBox,
|
|
1552
|
+
margin,
|
|
1553
|
+
padding,
|
|
1554
|
+
border
|
|
1555
|
+
});
|
|
1556
|
+
};
|
|
1557
|
+
var getBox = function getBox2(el) {
|
|
1558
|
+
var borderBox = el.getBoundingClientRect();
|
|
1559
|
+
var styles2 = window.getComputedStyle(el);
|
|
1560
|
+
return calculateBox(borderBox, styles2);
|
|
1561
|
+
};
|
|
1562
|
+
|
|
1563
|
+
// lib/get-zoom-config.ts
|
|
1564
|
+
var RESET_ZOOM_SMALLER_THAN_FRAME = true;
|
|
1565
|
+
var getZoomConfig = (uiViewport, frame, zoom) => {
|
|
1566
|
+
const box = getBox(frame);
|
|
1567
|
+
const { width: frameWidth, height: frameHeight } = box.contentBox;
|
|
1568
|
+
const viewportHeight = uiViewport.height === "auto" ? frameHeight : uiViewport.height;
|
|
1569
|
+
let rootHeight = 0;
|
|
1570
|
+
let autoZoom = 1;
|
|
1571
|
+
if (uiViewport.width > frameWidth || viewportHeight > frameHeight) {
|
|
1572
|
+
const widthZoom = Math.min(frameWidth / uiViewport.width, 1);
|
|
1573
|
+
const heightZoom = Math.min(frameHeight / viewportHeight, 1);
|
|
1574
|
+
zoom = widthZoom;
|
|
1575
|
+
if (widthZoom < heightZoom) {
|
|
1576
|
+
rootHeight = viewportHeight / zoom;
|
|
1577
|
+
} else {
|
|
1578
|
+
rootHeight = viewportHeight;
|
|
1579
|
+
zoom = heightZoom;
|
|
1580
|
+
}
|
|
1581
|
+
autoZoom = zoom;
|
|
1582
|
+
} else {
|
|
1583
|
+
if (RESET_ZOOM_SMALLER_THAN_FRAME) {
|
|
1584
|
+
autoZoom = 1;
|
|
1585
|
+
zoom = 1;
|
|
1586
|
+
rootHeight = viewportHeight;
|
|
1587
|
+
}
|
|
1588
|
+
}
|
|
1589
|
+
return { autoZoom, rootHeight, zoom };
|
|
1590
|
+
};
|
|
1591
|
+
|
|
1592
|
+
// lib/use-reset-auto-zoom.ts
|
|
1593
|
+
var useResetAutoZoom = (frameRef) => {
|
|
1594
|
+
const appStoreApi = useAppStoreApi();
|
|
1595
|
+
const resetAutoZoom = (options) => {
|
|
1596
|
+
const { state, zoomConfig, setZoomConfig } = appStoreApi.getState();
|
|
1597
|
+
const { viewports } = state.ui;
|
|
1598
|
+
const newViewports = (options == null ? void 0 : options.viewports) || viewports;
|
|
1599
|
+
if (frameRef.current) {
|
|
1600
|
+
setZoomConfig(
|
|
1601
|
+
getZoomConfig(newViewports == null ? void 0 : newViewports.current, frameRef.current, zoomConfig.zoom)
|
|
1602
|
+
);
|
|
1603
|
+
}
|
|
1604
|
+
};
|
|
1605
|
+
return resetAutoZoom;
|
|
1606
|
+
};
|
|
117
1607
|
|
|
118
1608
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Loader/styles.module.css#css-module
|
|
119
1609
|
init_react_import();
|
|
@@ -199,7 +1689,7 @@ var IconButton = ({
|
|
|
199
1689
|
|
|
200
1690
|
// components/Button/Button.tsx
|
|
201
1691
|
init_react_import();
|
|
202
|
-
import { useEffect, useState as useState2 } from "react";
|
|
1692
|
+
import { useEffect as useEffect5, useState as useState2 } from "react";
|
|
203
1693
|
|
|
204
1694
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Button/Button.module.css#css-module
|
|
205
1695
|
init_react_import();
|
|
@@ -250,7 +1740,7 @@ var Button = (_a) => {
|
|
|
250
1740
|
"loading"
|
|
251
1741
|
]);
|
|
252
1742
|
const [loading, setLoading] = useState2(loadingProp);
|
|
253
|
-
|
|
1743
|
+
useEffect5(() => setLoading(loadingProp), [loadingProp]);
|
|
254
1744
|
const ElementType = href ? "a" : type ? "button" : "span";
|
|
255
1745
|
const dataAttrs = filterDataAttrs(props);
|
|
256
1746
|
const el = /* @__PURE__ */ jsxs3(
|
|
@@ -296,9 +1786,9 @@ var styles_module_default3 = { "InputWrapper": "_InputWrapper_bsxfo_1", "Input-l
|
|
|
296
1786
|
|
|
297
1787
|
// components/AutoField/index.tsx
|
|
298
1788
|
import {
|
|
299
|
-
useCallback as
|
|
300
|
-
useContext as
|
|
301
|
-
useEffect as
|
|
1789
|
+
useCallback as useCallback4,
|
|
1790
|
+
useContext as useContext3,
|
|
1791
|
+
useEffect as useEffect10,
|
|
302
1792
|
useMemo as useMemo3,
|
|
303
1793
|
useState as useState8
|
|
304
1794
|
} from "react";
|
|
@@ -644,7 +2134,7 @@ var ZoomOut = createLucideIcon("ZoomOut", [
|
|
|
644
2134
|
init_react_import();
|
|
645
2135
|
|
|
646
2136
|
// components/AutoField/fields/ArrayField/index.tsx
|
|
647
|
-
import { useCallback, useEffect as
|
|
2137
|
+
import { useCallback as useCallback2, useEffect as useEffect6, useRef, useState as useState4 } from "react";
|
|
648
2138
|
|
|
649
2139
|
// components/DragIcon/index.tsx
|
|
650
2140
|
init_react_import();
|
|
@@ -1094,11 +2584,11 @@ var Sortable = ({
|
|
|
1094
2584
|
|
|
1095
2585
|
// components/AutoField/context.tsx
|
|
1096
2586
|
init_react_import();
|
|
1097
|
-
import { createContext, useContext, useMemo } from "react";
|
|
2587
|
+
import { createContext as createContext2, useContext as useContext2, useMemo } from "react";
|
|
1098
2588
|
import { jsx as jsx7 } from "react/jsx-runtime";
|
|
1099
|
-
var NestedFieldContext =
|
|
2589
|
+
var NestedFieldContext = createContext2({});
|
|
1100
2590
|
var useNestedFieldContext = () => {
|
|
1101
|
-
const context =
|
|
2591
|
+
const context = useContext2(NestedFieldContext);
|
|
1102
2592
|
return __spreadProps(__spreadValues({}, context), {
|
|
1103
2593
|
readOnlyFields: context.readOnlyFields || {}
|
|
1104
2594
|
});
|
|
@@ -1166,13 +2656,13 @@ var ArrayField = ({
|
|
|
1166
2656
|
openId: ""
|
|
1167
2657
|
};
|
|
1168
2658
|
const [localState, setLocalState] = useState4({ arrayState, value });
|
|
1169
|
-
|
|
2659
|
+
useEffect6(() => {
|
|
1170
2660
|
var _a;
|
|
1171
2661
|
const _arrayState = (_a = appStore.getState().state.ui.arrayState[id]) != null ? _a : arrayState;
|
|
1172
2662
|
setLocalState({ arrayState: _arrayState, value });
|
|
1173
2663
|
}, [value]);
|
|
1174
2664
|
const appStore = useAppStoreApi();
|
|
1175
|
-
const mapArrayStateToUi =
|
|
2665
|
+
const mapArrayStateToUi = useCallback2(
|
|
1176
2666
|
(partialArrayState) => {
|
|
1177
2667
|
const state = appStore.getState().state;
|
|
1178
2668
|
return {
|
|
@@ -1183,13 +2673,13 @@ var ArrayField = ({
|
|
|
1183
2673
|
},
|
|
1184
2674
|
[arrayState, appStore]
|
|
1185
2675
|
);
|
|
1186
|
-
const getHighestIndex =
|
|
2676
|
+
const getHighestIndex = useCallback2(() => {
|
|
1187
2677
|
return arrayState.items.reduce(
|
|
1188
2678
|
(acc, item) => item._originalIndex > acc ? item._originalIndex : acc,
|
|
1189
2679
|
-1
|
|
1190
2680
|
);
|
|
1191
2681
|
}, [arrayState]);
|
|
1192
|
-
const regenerateArrayState =
|
|
2682
|
+
const regenerateArrayState = useCallback2(
|
|
1193
2683
|
(value2) => {
|
|
1194
2684
|
let highestIndex = getHighestIndex();
|
|
1195
2685
|
const newItems = Array.from(value2 || []).map((item, idx) => {
|
|
@@ -1208,7 +2698,7 @@ var ArrayField = ({
|
|
|
1208
2698
|
},
|
|
1209
2699
|
[arrayState]
|
|
1210
2700
|
);
|
|
1211
|
-
|
|
2701
|
+
useEffect6(() => {
|
|
1212
2702
|
if (arrayState.items.length > 0) {
|
|
1213
2703
|
setUi(mapArrayStateToUi(arrayState));
|
|
1214
2704
|
}
|
|
@@ -1220,7 +2710,7 @@ var ArrayField = ({
|
|
|
1220
2710
|
);
|
|
1221
2711
|
const forceReadOnly = !canEdit;
|
|
1222
2712
|
const valueRef = useRef(value);
|
|
1223
|
-
const uniqifyItem =
|
|
2713
|
+
const uniqifyItem = useCallback2(
|
|
1224
2714
|
(val) => {
|
|
1225
2715
|
if (field.type !== "array" || !field.arrayFields) return;
|
|
1226
2716
|
const config = appStore.getState().config;
|
|
@@ -1532,15 +3022,15 @@ var DefaultField = ({
|
|
|
1532
3022
|
|
|
1533
3023
|
// components/AutoField/fields/ExternalField/index.tsx
|
|
1534
3024
|
init_react_import();
|
|
1535
|
-
import { useEffect as
|
|
3025
|
+
import { useEffect as useEffect9 } from "react";
|
|
1536
3026
|
|
|
1537
3027
|
// components/ExternalInput/index.tsx
|
|
1538
3028
|
init_react_import();
|
|
1539
3029
|
import {
|
|
1540
3030
|
useMemo as useMemo2,
|
|
1541
|
-
useEffect as
|
|
3031
|
+
useEffect as useEffect8,
|
|
1542
3032
|
useState as useState6,
|
|
1543
|
-
useCallback as
|
|
3033
|
+
useCallback as useCallback3,
|
|
1544
3034
|
isValidElement
|
|
1545
3035
|
} from "react";
|
|
1546
3036
|
|
|
@@ -1550,7 +3040,7 @@ var styles_module_default6 = { "ExternalInput-actions": "_ExternalInput-actions_
|
|
|
1550
3040
|
|
|
1551
3041
|
// components/Modal/index.tsx
|
|
1552
3042
|
init_react_import();
|
|
1553
|
-
import { useEffect as
|
|
3043
|
+
import { useEffect as useEffect7, useState as useState5 } from "react";
|
|
1554
3044
|
|
|
1555
3045
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Modal/styles.module.css#css-module
|
|
1556
3046
|
init_react_import();
|
|
@@ -1566,7 +3056,7 @@ var Modal = ({
|
|
|
1566
3056
|
isOpen
|
|
1567
3057
|
}) => {
|
|
1568
3058
|
const [rootEl, setRootEl] = useState5(null);
|
|
1569
|
-
|
|
3059
|
+
useEffect7(() => {
|
|
1570
3060
|
setRootEl(document.getElementById("puck-portal-root"));
|
|
1571
3061
|
}, []);
|
|
1572
3062
|
if (!rootEl) {
|
|
@@ -1650,7 +3140,7 @@ var ExternalInput = ({
|
|
|
1650
3140
|
return Array.from(validKeys);
|
|
1651
3141
|
}, [mappedData]);
|
|
1652
3142
|
const [searchQuery, setSearchQuery] = useState6(field.initialQuery || "");
|
|
1653
|
-
const search =
|
|
3143
|
+
const search = useCallback3(
|
|
1654
3144
|
(query, filters2) => __async(void 0, null, function* () {
|
|
1655
3145
|
setIsLoading(true);
|
|
1656
3146
|
const cacheKey = `${id}-${query}-${JSON.stringify(filters2)}`;
|
|
@@ -1663,7 +3153,7 @@ var ExternalInput = ({
|
|
|
1663
3153
|
}),
|
|
1664
3154
|
[id, field]
|
|
1665
3155
|
);
|
|
1666
|
-
const Footer =
|
|
3156
|
+
const Footer = useCallback3(
|
|
1667
3157
|
(props) => field.renderFooter ? field.renderFooter(props) : /* @__PURE__ */ jsxs6("span", { className: getClassNameModal("footer"), children: [
|
|
1668
3158
|
props.items.length,
|
|
1669
3159
|
" result",
|
|
@@ -1671,7 +3161,7 @@ var ExternalInput = ({
|
|
|
1671
3161
|
] }),
|
|
1672
3162
|
[field.renderFooter]
|
|
1673
3163
|
);
|
|
1674
|
-
|
|
3164
|
+
useEffect8(() => {
|
|
1675
3165
|
search(searchQuery, filters);
|
|
1676
3166
|
}, []);
|
|
1677
3167
|
return /* @__PURE__ */ jsxs6(
|
|
@@ -1844,7 +3334,7 @@ var ExternalField = ({
|
|
|
1844
3334
|
var _a, _b, _c;
|
|
1845
3335
|
const validField = field;
|
|
1846
3336
|
const deprecatedField = field;
|
|
1847
|
-
|
|
3337
|
+
useEffect9(() => {
|
|
1848
3338
|
if (deprecatedField.adaptor) {
|
|
1849
3339
|
console.error(
|
|
1850
3340
|
"Warning: The `adaptor` API is deprecated. Please use updated APIs on the `external` field instead. This will be a breaking change in a future release."
|
|
@@ -2172,7 +3662,7 @@ function AutoFieldInternal(props) {
|
|
|
2172
3662
|
var _a2;
|
|
2173
3663
|
return (_a2 = s.selectedItem) == null ? void 0 : _a2.readOnly;
|
|
2174
3664
|
});
|
|
2175
|
-
const nestedFieldContext =
|
|
3665
|
+
const nestedFieldContext = useContext3(NestedFieldContext);
|
|
2176
3666
|
const { id, Label: Label2 = FieldLabelInternal } = props;
|
|
2177
3667
|
const field = props.field;
|
|
2178
3668
|
const label = field.label;
|
|
@@ -2206,7 +3696,7 @@ function AutoFieldInternal(props) {
|
|
|
2206
3696
|
Label: Label2,
|
|
2207
3697
|
id: resolvedId
|
|
2208
3698
|
});
|
|
2209
|
-
const onFocus =
|
|
3699
|
+
const onFocus = useCallback4(
|
|
2210
3700
|
(e) => {
|
|
2211
3701
|
if (mergedProps.name && (e.target.nodeName === "INPUT" || e.target.nodeName === "TEXTAREA")) {
|
|
2212
3702
|
e.stopPropagation();
|
|
@@ -2220,7 +3710,7 @@ function AutoFieldInternal(props) {
|
|
|
2220
3710
|
},
|
|
2221
3711
|
[mergedProps.name]
|
|
2222
3712
|
);
|
|
2223
|
-
const onBlur =
|
|
3713
|
+
const onBlur = useCallback4((e) => {
|
|
2224
3714
|
if ("name" in e.target) {
|
|
2225
3715
|
dispatch({
|
|
2226
3716
|
type: "setUi",
|
|
@@ -2274,19 +3764,19 @@ function AutoFieldPrivate(props) {
|
|
|
2274
3764
|
const isFocused = useAppStore((s) => s.state.ui.field.focus === props.name);
|
|
2275
3765
|
const { value, onChange } = props;
|
|
2276
3766
|
const [localValue, setLocalValue] = useState8(value);
|
|
2277
|
-
const onChangeLocal =
|
|
3767
|
+
const onChangeLocal = useCallback4(
|
|
2278
3768
|
(val, ui) => {
|
|
2279
3769
|
setLocalValue(val);
|
|
2280
3770
|
onChange(val, ui);
|
|
2281
3771
|
},
|
|
2282
3772
|
[onChange]
|
|
2283
3773
|
);
|
|
2284
|
-
|
|
3774
|
+
useEffect10(() => {
|
|
2285
3775
|
if (!isFocused) {
|
|
2286
3776
|
setLocalValue(value);
|
|
2287
3777
|
}
|
|
2288
3778
|
}, [value]);
|
|
2289
|
-
|
|
3779
|
+
useEffect10(() => {
|
|
2290
3780
|
if (!isFocused) {
|
|
2291
3781
|
if (value !== localValue) {
|
|
2292
3782
|
setLocalValue(value);
|
|
@@ -2322,20 +3812,20 @@ init_react_import();
|
|
|
2322
3812
|
init_react_import();
|
|
2323
3813
|
import {
|
|
2324
3814
|
forwardRef as forwardRef3,
|
|
2325
|
-
memo,
|
|
2326
|
-
useCallback as
|
|
2327
|
-
useContext as
|
|
2328
|
-
useEffect as
|
|
3815
|
+
memo as memo2,
|
|
3816
|
+
useCallback as useCallback11,
|
|
3817
|
+
useContext as useContext8,
|
|
3818
|
+
useEffect as useEffect18,
|
|
2329
3819
|
useMemo as useMemo8,
|
|
2330
|
-
useRef as
|
|
3820
|
+
useRef as useRef6
|
|
2331
3821
|
} from "react";
|
|
2332
3822
|
|
|
2333
3823
|
// components/DraggableComponent/index.tsx
|
|
2334
3824
|
init_react_import();
|
|
2335
3825
|
import {
|
|
2336
|
-
useCallback as
|
|
2337
|
-
useContext as
|
|
2338
|
-
useEffect as
|
|
3826
|
+
useCallback as useCallback7,
|
|
3827
|
+
useContext as useContext5,
|
|
3828
|
+
useEffect as useEffect12,
|
|
2339
3829
|
useMemo as useMemo5,
|
|
2340
3830
|
useRef as useRef2,
|
|
2341
3831
|
useState as useState10,
|
|
@@ -2371,14 +3861,14 @@ function getDeepScrollPosition(element) {
|
|
|
2371
3861
|
// components/DropZone/context.tsx
|
|
2372
3862
|
init_react_import();
|
|
2373
3863
|
import {
|
|
2374
|
-
createContext as
|
|
2375
|
-
useCallback as
|
|
3864
|
+
createContext as createContext3,
|
|
3865
|
+
useCallback as useCallback5,
|
|
2376
3866
|
useMemo as useMemo4
|
|
2377
3867
|
} from "react";
|
|
2378
3868
|
import { createStore as createStore2 } from "zustand";
|
|
2379
3869
|
import { Fragment as Fragment5, jsx as jsx19 } from "react/jsx-runtime";
|
|
2380
|
-
var dropZoneContext =
|
|
2381
|
-
var ZoneStoreContext =
|
|
3870
|
+
var dropZoneContext = createContext3(null);
|
|
3871
|
+
var ZoneStoreContext = createContext3(
|
|
2382
3872
|
createStore2(() => ({
|
|
2383
3873
|
zoneDepthIndex: {},
|
|
2384
3874
|
nextZoneDepthIndex: {},
|
|
@@ -2401,7 +3891,7 @@ var DropZoneProvider = ({
|
|
|
2401
3891
|
value
|
|
2402
3892
|
}) => {
|
|
2403
3893
|
const dispatch = useAppStore((s) => s.dispatch);
|
|
2404
|
-
const registerZone =
|
|
3894
|
+
const registerZone = useCallback5(
|
|
2405
3895
|
(zoneCompound) => {
|
|
2406
3896
|
dispatch({
|
|
2407
3897
|
type: "registerZone",
|
|
@@ -2440,23 +3930,23 @@ function accumulateTransform(el) {
|
|
|
2440
3930
|
|
|
2441
3931
|
// lib/use-context-store.ts
|
|
2442
3932
|
init_react_import();
|
|
2443
|
-
import { useContext as
|
|
2444
|
-
import { useStore } from "zustand";
|
|
3933
|
+
import { useContext as useContext4 } from "react";
|
|
3934
|
+
import { useStore as useStore2 } from "zustand";
|
|
2445
3935
|
import { useShallow } from "zustand/react/shallow";
|
|
2446
3936
|
function useContextStore(context, selector) {
|
|
2447
|
-
const store =
|
|
3937
|
+
const store = useContext4(context);
|
|
2448
3938
|
if (!store) {
|
|
2449
3939
|
throw new Error("useContextStore must be used inside context");
|
|
2450
3940
|
}
|
|
2451
|
-
return
|
|
3941
|
+
return useStore2(store, useShallow(selector));
|
|
2452
3942
|
}
|
|
2453
3943
|
|
|
2454
3944
|
// lib/dnd/use-on-drag-finished.ts
|
|
2455
3945
|
init_react_import();
|
|
2456
|
-
import { useCallback as
|
|
3946
|
+
import { useCallback as useCallback6 } from "react";
|
|
2457
3947
|
var useOnDragFinished = (cb, deps = []) => {
|
|
2458
3948
|
const appStore = useAppStoreApi();
|
|
2459
|
-
return
|
|
3949
|
+
return useCallback6(() => {
|
|
2460
3950
|
let dispose = () => {
|
|
2461
3951
|
};
|
|
2462
3952
|
const processDragging = (isDragging2) => {
|
|
@@ -2529,9 +4019,9 @@ var DraggableComponent = ({
|
|
|
2529
4019
|
const overrides = useAppStore((s) => s.overrides);
|
|
2530
4020
|
const dispatch = useAppStore((s) => s.dispatch);
|
|
2531
4021
|
const iframe = useAppStore((s) => s.iframe);
|
|
2532
|
-
const ctx =
|
|
4022
|
+
const ctx = useContext5(dropZoneContext);
|
|
2533
4023
|
const [localZones, setLocalZones] = useState10({});
|
|
2534
|
-
const registerLocalZone =
|
|
4024
|
+
const registerLocalZone = useCallback7(
|
|
2535
4025
|
(zoneCompound2, active) => {
|
|
2536
4026
|
var _a;
|
|
2537
4027
|
(_a = ctx == null ? void 0 : ctx.registerLocalZone) == null ? void 0 : _a.call(ctx, zoneCompound2, active);
|
|
@@ -2541,7 +4031,7 @@ var DraggableComponent = ({
|
|
|
2541
4031
|
},
|
|
2542
4032
|
[setLocalZones]
|
|
2543
4033
|
);
|
|
2544
|
-
const unregisterLocalZone =
|
|
4034
|
+
const unregisterLocalZone = useCallback7(
|
|
2545
4035
|
(zoneCompound2) => {
|
|
2546
4036
|
var _a;
|
|
2547
4037
|
(_a = ctx == null ? void 0 : ctx.unregisterLocalZone) == null ? void 0 : _a.call(ctx, zoneCompound2);
|
|
@@ -2564,7 +4054,7 @@ var DraggableComponent = ({
|
|
|
2564
4054
|
return s.permissions.getPermissions({ item });
|
|
2565
4055
|
})
|
|
2566
4056
|
);
|
|
2567
|
-
const zoneStore =
|
|
4057
|
+
const zoneStore = useContext5(ZoneStoreContext);
|
|
2568
4058
|
const [dragAxis, setDragAxis] = useState10(userDragAxis || autoDragAxis);
|
|
2569
4059
|
const dynamicCollisionDetector = useMemo5(
|
|
2570
4060
|
() => createDynamicCollisionDetector(dragAxis),
|
|
@@ -2598,7 +4088,7 @@ var DraggableComponent = ({
|
|
|
2598
4088
|
},
|
|
2599
4089
|
feedback: "clone"
|
|
2600
4090
|
});
|
|
2601
|
-
|
|
4091
|
+
useEffect12(() => {
|
|
2602
4092
|
const isEnabled = zoneStore.getState().enabledIndex[zoneCompound];
|
|
2603
4093
|
sortable.droppable.disabled = !isEnabled;
|
|
2604
4094
|
sortable.draggable.disabled = !permissions.drag;
|
|
@@ -2616,7 +4106,7 @@ var DraggableComponent = ({
|
|
|
2616
4106
|
return cleanup;
|
|
2617
4107
|
}, [permissions.drag, zoneCompound]);
|
|
2618
4108
|
const ref = useRef2(null);
|
|
2619
|
-
const refSetter =
|
|
4109
|
+
const refSetter = useCallback7(
|
|
2620
4110
|
(el) => {
|
|
2621
4111
|
sortableRef(el);
|
|
2622
4112
|
if (el) {
|
|
@@ -2626,13 +4116,13 @@ var DraggableComponent = ({
|
|
|
2626
4116
|
[sortableRef]
|
|
2627
4117
|
);
|
|
2628
4118
|
const [portalEl, setPortalEl] = useState10();
|
|
2629
|
-
|
|
4119
|
+
useEffect12(() => {
|
|
2630
4120
|
var _a, _b, _c;
|
|
2631
4121
|
setPortalEl(
|
|
2632
4122
|
iframe.enabled ? (_a = ref.current) == null ? void 0 : _a.ownerDocument.body : (_c = (_b = ref.current) == null ? void 0 : _b.closest("[data-puck-preview]")) != null ? _c : document.body
|
|
2633
4123
|
);
|
|
2634
4124
|
}, [iframe.enabled, ref.current]);
|
|
2635
|
-
const getStyle =
|
|
4125
|
+
const getStyle = useCallback7(() => {
|
|
2636
4126
|
var _a, _b, _c;
|
|
2637
4127
|
if (!ref.current) return;
|
|
2638
4128
|
const rect = ref.current.getBoundingClientRect();
|
|
@@ -2658,10 +4148,10 @@ var DraggableComponent = ({
|
|
|
2658
4148
|
return style2;
|
|
2659
4149
|
}, [ref.current]);
|
|
2660
4150
|
const [style, setStyle] = useState10();
|
|
2661
|
-
const sync =
|
|
4151
|
+
const sync = useCallback7(() => {
|
|
2662
4152
|
setStyle(getStyle());
|
|
2663
4153
|
}, [ref.current, iframe]);
|
|
2664
|
-
|
|
4154
|
+
useEffect12(() => {
|
|
2665
4155
|
if (ref.current) {
|
|
2666
4156
|
const observer = new ResizeObserver(sync);
|
|
2667
4157
|
observer.observe(ref.current);
|
|
@@ -2671,13 +4161,13 @@ var DraggableComponent = ({
|
|
|
2671
4161
|
}
|
|
2672
4162
|
}, [ref.current]);
|
|
2673
4163
|
const registerNode = useAppStore((s) => s.nodes.registerNode);
|
|
2674
|
-
const hideOverlay =
|
|
4164
|
+
const hideOverlay = useCallback7(() => {
|
|
2675
4165
|
setIsVisible(false);
|
|
2676
4166
|
}, []);
|
|
2677
|
-
const showOverlay =
|
|
4167
|
+
const showOverlay = useCallback7(() => {
|
|
2678
4168
|
setIsVisible(true);
|
|
2679
4169
|
}, []);
|
|
2680
|
-
|
|
4170
|
+
useEffect12(() => {
|
|
2681
4171
|
var _a;
|
|
2682
4172
|
registerNode(id, {
|
|
2683
4173
|
methods: { sync, showOverlay, hideOverlay },
|
|
@@ -2702,7 +4192,7 @@ var DraggableComponent = ({
|
|
|
2702
4192
|
() => overrides.componentOverlay || DefaultOverlay,
|
|
2703
4193
|
[overrides.componentOverlay]
|
|
2704
4194
|
);
|
|
2705
|
-
const onClick =
|
|
4195
|
+
const onClick = useCallback7(
|
|
2706
4196
|
(e) => {
|
|
2707
4197
|
const el = e.target;
|
|
2708
4198
|
if (!el.closest("[data-puck-overlay-portal]")) {
|
|
@@ -2718,7 +4208,7 @@ var DraggableComponent = ({
|
|
|
2718
4208
|
[index, zoneCompound, id]
|
|
2719
4209
|
);
|
|
2720
4210
|
const appStore = useAppStoreApi();
|
|
2721
|
-
const onSelectParent =
|
|
4211
|
+
const onSelectParent = useCallback7(() => {
|
|
2722
4212
|
const { nodes, zones } = appStore.getState().state.indexes;
|
|
2723
4213
|
const node = nodes[id];
|
|
2724
4214
|
const parentNode = (node == null ? void 0 : node.parentId) ? nodes[node == null ? void 0 : node.parentId] : null;
|
|
@@ -2739,14 +4229,14 @@ var DraggableComponent = ({
|
|
|
2739
4229
|
}
|
|
2740
4230
|
});
|
|
2741
4231
|
}, [ctx, path]);
|
|
2742
|
-
const onDuplicate =
|
|
4232
|
+
const onDuplicate = useCallback7(() => {
|
|
2743
4233
|
dispatch({
|
|
2744
4234
|
type: "duplicate",
|
|
2745
4235
|
sourceIndex: index,
|
|
2746
4236
|
sourceZone: zoneCompound
|
|
2747
4237
|
});
|
|
2748
4238
|
}, [index, zoneCompound]);
|
|
2749
|
-
const onDelete =
|
|
4239
|
+
const onDelete = useCallback7(() => {
|
|
2750
4240
|
dispatch({
|
|
2751
4241
|
type: "remove",
|
|
2752
4242
|
index,
|
|
@@ -2758,7 +4248,7 @@ var DraggableComponent = ({
|
|
|
2758
4248
|
ZoneStoreContext,
|
|
2759
4249
|
(s) => s.hoveringComponent === id
|
|
2760
4250
|
);
|
|
2761
|
-
|
|
4251
|
+
useEffect12(() => {
|
|
2762
4252
|
if (!ref.current) {
|
|
2763
4253
|
return;
|
|
2764
4254
|
}
|
|
@@ -2806,7 +4296,7 @@ var DraggableComponent = ({
|
|
|
2806
4296
|
const [isVisible, setIsVisible] = useState10(false);
|
|
2807
4297
|
const [dragFinished, setDragFinished] = useState10(true);
|
|
2808
4298
|
const [_, startTransition] = useTransition();
|
|
2809
|
-
|
|
4299
|
+
useEffect12(() => {
|
|
2810
4300
|
startTransition(() => {
|
|
2811
4301
|
if (hover || indicativeHover || isSelected) {
|
|
2812
4302
|
sync();
|
|
@@ -2828,15 +4318,15 @@ var DraggableComponent = ({
|
|
|
2828
4318
|
setDragFinished(false);
|
|
2829
4319
|
}
|
|
2830
4320
|
});
|
|
2831
|
-
|
|
4321
|
+
useEffect12(() => {
|
|
2832
4322
|
if (thisIsDragging) {
|
|
2833
4323
|
setThisWasDragging(true);
|
|
2834
4324
|
}
|
|
2835
4325
|
}, [thisIsDragging]);
|
|
2836
|
-
|
|
4326
|
+
useEffect12(() => {
|
|
2837
4327
|
if (thisWasDragging) return onDragFinished();
|
|
2838
4328
|
}, [thisWasDragging, onDragFinished]);
|
|
2839
|
-
const syncActionsPosition =
|
|
4329
|
+
const syncActionsPosition = useCallback7(
|
|
2840
4330
|
(el) => {
|
|
2841
4331
|
if (el) {
|
|
2842
4332
|
const view = el.ownerDocument.defaultView;
|
|
@@ -2861,7 +4351,7 @@ var DraggableComponent = ({
|
|
|
2861
4351
|
},
|
|
2862
4352
|
[zoom]
|
|
2863
4353
|
);
|
|
2864
|
-
|
|
4354
|
+
useEffect12(() => {
|
|
2865
4355
|
if (userDragAxis) {
|
|
2866
4356
|
setDragAxis(userDragAxis);
|
|
2867
4357
|
return;
|
|
@@ -2987,10 +4477,10 @@ import { useMemo as useMemo7, useState as useState12 } from "react";
|
|
|
2987
4477
|
init_react_import();
|
|
2988
4478
|
import { DragDropProvider as DragDropProvider2 } from "@dnd-kit/react";
|
|
2989
4479
|
import {
|
|
2990
|
-
createContext as
|
|
2991
|
-
useCallback as
|
|
2992
|
-
useContext as
|
|
2993
|
-
useEffect as
|
|
4480
|
+
createContext as createContext4,
|
|
4481
|
+
useCallback as useCallback8,
|
|
4482
|
+
useContext as useContext6,
|
|
4483
|
+
useEffect as useEffect13,
|
|
2994
4484
|
useMemo as useMemo6,
|
|
2995
4485
|
useRef as useRef3,
|
|
2996
4486
|
useState as useState11
|
|
@@ -3284,7 +4774,7 @@ var insertComponent = (componentType, zone, index, appStore) => __async(void 0,
|
|
|
3284
4774
|
destinationZone: zone,
|
|
3285
4775
|
id
|
|
3286
4776
|
};
|
|
3287
|
-
const { state, dispatch, resolveComponentData } = appStore;
|
|
4777
|
+
const { state, dispatch, resolveComponentData: resolveComponentData2 } = appStore;
|
|
3288
4778
|
const insertedState = insertAction(state, insertActionData, appStore);
|
|
3289
4779
|
dispatch(__spreadProps(__spreadValues({}, insertActionData), {
|
|
3290
4780
|
// Dispatch insert rather set, as user's may rely on this via onAction
|
|
@@ -3300,7 +4790,7 @@ var insertComponent = (componentType, zone, index, appStore) => __async(void 0,
|
|
|
3300
4790
|
dispatch({ type: "setUi", ui: { itemSelector } });
|
|
3301
4791
|
const itemData = getItem(itemSelector, insertedState);
|
|
3302
4792
|
if (itemData) {
|
|
3303
|
-
const resolved = yield
|
|
4793
|
+
const resolved = yield resolveComponentData2(itemData, "insert");
|
|
3304
4794
|
if (resolved.didChange) {
|
|
3305
4795
|
dispatch({
|
|
3306
4796
|
type: "replace",
|
|
@@ -3331,12 +4821,12 @@ function getDeepDir(el) {
|
|
|
3331
4821
|
import { effect } from "@dnd-kit/state";
|
|
3332
4822
|
import { jsx as jsx21 } from "react/jsx-runtime";
|
|
3333
4823
|
var DEBUG3 = false;
|
|
3334
|
-
var dragListenerContext =
|
|
4824
|
+
var dragListenerContext = createContext4({
|
|
3335
4825
|
dragListeners: {}
|
|
3336
4826
|
});
|
|
3337
4827
|
function useDragListener(type, fn, deps = []) {
|
|
3338
|
-
const { setDragListeners } =
|
|
3339
|
-
|
|
4828
|
+
const { setDragListeners } = useContext6(dragListenerContext);
|
|
4829
|
+
useEffect13(() => {
|
|
3340
4830
|
if (setDragListeners) {
|
|
3341
4831
|
setDragListeners((old) => __spreadProps(__spreadValues({}, old), {
|
|
3342
4832
|
[type]: [...old[type] || [], fn]
|
|
@@ -3347,7 +4837,7 @@ function useDragListener(type, fn, deps = []) {
|
|
|
3347
4837
|
var AREA_CHANGE_DEBOUNCE_MS = 100;
|
|
3348
4838
|
var useTempDisableFallback = (timeout3) => {
|
|
3349
4839
|
const lastFallbackDisable = useRef3(null);
|
|
3350
|
-
return
|
|
4840
|
+
return useCallback8((manager) => {
|
|
3351
4841
|
collisionStore.setState({ fallbackEnabled: false });
|
|
3352
4842
|
const fallbackId = generateId();
|
|
3353
4843
|
lastFallbackDisable.current = fallbackId;
|
|
@@ -3380,7 +4870,7 @@ var DragDropContextClient = ({
|
|
|
3380
4870
|
hoveringComponent: null
|
|
3381
4871
|
}))
|
|
3382
4872
|
);
|
|
3383
|
-
const
|
|
4873
|
+
const getChanged2 = useCallback8(
|
|
3384
4874
|
(params, id2) => {
|
|
3385
4875
|
const { zoneDepthIndex = {}, areaDepthIndex = {} } = zoneStore.getState() || {};
|
|
3386
4876
|
const stateHasZone = Object.keys(zoneDepthIndex).length > 0;
|
|
@@ -3401,9 +4891,9 @@ var DragDropContextClient = ({
|
|
|
3401
4891
|
},
|
|
3402
4892
|
[zoneStore]
|
|
3403
4893
|
);
|
|
3404
|
-
const setDeepestAndCollide =
|
|
4894
|
+
const setDeepestAndCollide = useCallback8(
|
|
3405
4895
|
(params, manager) => {
|
|
3406
|
-
const { zoneChanged, areaChanged } =
|
|
4896
|
+
const { zoneChanged, areaChanged } = getChanged2(params, id);
|
|
3407
4897
|
if (!zoneChanged && !areaChanged) return;
|
|
3408
4898
|
zoneStore.setState({
|
|
3409
4899
|
zoneDepthIndex: params.zone ? { [params.zone]: true } : {},
|
|
@@ -3425,7 +4915,7 @@ var DragDropContextClient = ({
|
|
|
3425
4915
|
setDeepestDb.cancel();
|
|
3426
4916
|
debouncedParamsRef.current = null;
|
|
3427
4917
|
};
|
|
3428
|
-
|
|
4918
|
+
useEffect13(() => {
|
|
3429
4919
|
if (DEBUG3) {
|
|
3430
4920
|
zoneStore.subscribe(
|
|
3431
4921
|
(s) => {
|
|
@@ -3445,7 +4935,7 @@ var DragDropContextClient = ({
|
|
|
3445
4935
|
{
|
|
3446
4936
|
onChange: (params, manager) => {
|
|
3447
4937
|
const state = zoneStore.getState();
|
|
3448
|
-
const { zoneChanged, areaChanged } =
|
|
4938
|
+
const { zoneChanged, areaChanged } = getChanged2(params, id);
|
|
3449
4939
|
const isDragging = manager.dragOperation.status.dragging;
|
|
3450
4940
|
if (areaChanged || zoneChanged) {
|
|
3451
4941
|
let nextZoneDepthIndex = {};
|
|
@@ -3867,7 +5357,7 @@ Drawer.Item = DrawerItem;
|
|
|
3867
5357
|
|
|
3868
5358
|
// components/DropZone/lib/use-min-empty-height.ts
|
|
3869
5359
|
init_react_import();
|
|
3870
|
-
import { useEffect as
|
|
5360
|
+
import { useEffect as useEffect14, useRef as useRef4, useState as useState13 } from "react";
|
|
3871
5361
|
var getNumItems = (appStore, zoneCompound) => appStore.getState().state.indexes.zones[zoneCompound].contentIds.length;
|
|
3872
5362
|
var useMinEmptyHeight = ({
|
|
3873
5363
|
zoneCompound,
|
|
@@ -3919,7 +5409,7 @@ var useMinEmptyHeight = ({
|
|
|
3919
5409
|
},
|
|
3920
5410
|
[appStore, prevHeight, zoneCompound]
|
|
3921
5411
|
);
|
|
3922
|
-
|
|
5412
|
+
useEffect14(() => {
|
|
3923
5413
|
if (draggedItem && ref.current) {
|
|
3924
5414
|
if (isZone) {
|
|
3925
5415
|
const rect = ref.current.getBoundingClientRect();
|
|
@@ -3950,15 +5440,15 @@ function assignRefs(refs, node) {
|
|
|
3950
5440
|
|
|
3951
5441
|
// components/DropZone/lib/use-content-with-preview.ts
|
|
3952
5442
|
init_react_import();
|
|
3953
|
-
import { useContext as
|
|
5443
|
+
import { useContext as useContext7, useEffect as useEffect15, useState as useState14 } from "react";
|
|
3954
5444
|
|
|
3955
5445
|
// lib/dnd/use-rendered-callback.ts
|
|
3956
5446
|
init_react_import();
|
|
3957
5447
|
import { useDragDropManager } from "@dnd-kit/react";
|
|
3958
|
-
import { useCallback as
|
|
5448
|
+
import { useCallback as useCallback9 } from "react";
|
|
3959
5449
|
function useRenderedCallback(callback, deps) {
|
|
3960
5450
|
const manager = useDragDropManager();
|
|
3961
|
-
return
|
|
5451
|
+
return useCallback9(
|
|
3962
5452
|
(...args) => __async(this, null, function* () {
|
|
3963
5453
|
yield manager == null ? void 0 : manager.renderer.rendering;
|
|
3964
5454
|
return callback(...args);
|
|
@@ -3969,7 +5459,7 @@ function useRenderedCallback(callback, deps) {
|
|
|
3969
5459
|
|
|
3970
5460
|
// components/DropZone/lib/use-content-with-preview.ts
|
|
3971
5461
|
var useContentIdsWithPreview = (contentIds, zoneCompound) => {
|
|
3972
|
-
const zoneStore =
|
|
5462
|
+
const zoneStore = useContext7(ZoneStoreContext);
|
|
3973
5463
|
const preview = useContextStore(
|
|
3974
5464
|
ZoneStoreContext,
|
|
3975
5465
|
(s) => s.previewIndex[zoneCompound]
|
|
@@ -4011,7 +5501,7 @@ var useContentIdsWithPreview = (contentIds, zoneCompound) => {
|
|
|
4011
5501
|
},
|
|
4012
5502
|
[]
|
|
4013
5503
|
);
|
|
4014
|
-
|
|
5504
|
+
useEffect15(() => {
|
|
4015
5505
|
var _a;
|
|
4016
5506
|
const s = zoneStore.getState();
|
|
4017
5507
|
const draggedItemId = (_a = s.draggedItem) == null ? void 0 : _a.id;
|
|
@@ -4029,7 +5519,7 @@ var useContentIdsWithPreview = (contentIds, zoneCompound) => {
|
|
|
4029
5519
|
|
|
4030
5520
|
// components/DropZone/lib/use-drag-axis.ts
|
|
4031
5521
|
init_react_import();
|
|
4032
|
-
import { useCallback as
|
|
5522
|
+
import { useCallback as useCallback10, useEffect as useEffect16, useState as useState15 } from "react";
|
|
4033
5523
|
var GRID_DRAG_AXIS = "dynamic";
|
|
4034
5524
|
var FLEX_ROW_DRAG_AXIS = "x";
|
|
4035
5525
|
var DEFAULT_DRAG_AXIS = "y";
|
|
@@ -4038,7 +5528,7 @@ var useDragAxis = (ref, collisionAxis) => {
|
|
|
4038
5528
|
const [dragAxis, setDragAxis] = useState15(
|
|
4039
5529
|
collisionAxis || DEFAULT_DRAG_AXIS
|
|
4040
5530
|
);
|
|
4041
|
-
const calculateDragAxis =
|
|
5531
|
+
const calculateDragAxis = useCallback10(() => {
|
|
4042
5532
|
if (ref.current) {
|
|
4043
5533
|
const computedStyle = window.getComputedStyle(ref.current);
|
|
4044
5534
|
if (computedStyle.display === "grid") {
|
|
@@ -4050,7 +5540,7 @@ var useDragAxis = (ref, collisionAxis) => {
|
|
|
4050
5540
|
}
|
|
4051
5541
|
}
|
|
4052
5542
|
}, [ref.current]);
|
|
4053
|
-
|
|
5543
|
+
useEffect16(() => {
|
|
4054
5544
|
const onViewportChange = () => {
|
|
4055
5545
|
calculateDragAxis();
|
|
4056
5546
|
};
|
|
@@ -4059,7 +5549,7 @@ var useDragAxis = (ref, collisionAxis) => {
|
|
|
4059
5549
|
window.removeEventListener("viewportchange", onViewportChange);
|
|
4060
5550
|
};
|
|
4061
5551
|
}, []);
|
|
4062
|
-
|
|
5552
|
+
useEffect16(calculateDragAxis, [status, collisionAxis]);
|
|
4063
5553
|
return [dragAxis, calculateDragAxis];
|
|
4064
5554
|
};
|
|
4065
5555
|
|
|
@@ -4095,12 +5585,239 @@ var ContextSlotRender = ({
|
|
|
4095
5585
|
);
|
|
4096
5586
|
};
|
|
4097
5587
|
|
|
5588
|
+
// lib/field-transforms/default-transforms/inline-text-transform.tsx
|
|
5589
|
+
init_react_import();
|
|
5590
|
+
|
|
5591
|
+
// components/InlineTextField/index.tsx
|
|
5592
|
+
init_react_import();
|
|
5593
|
+
import { memo, useEffect as useEffect17, useRef as useRef5, useState as useState16 } from "react";
|
|
5594
|
+
|
|
5595
|
+
// lib/overlay-portal/index.tsx
|
|
5596
|
+
init_react_import();
|
|
5597
|
+
var registerOverlayPortal = (el, opts = {}) => {
|
|
5598
|
+
if (!el) return;
|
|
5599
|
+
const { disableDrag = false, disableDragOnFocus = true } = opts;
|
|
5600
|
+
const stopPropagation = (e) => {
|
|
5601
|
+
e.stopPropagation();
|
|
5602
|
+
};
|
|
5603
|
+
el.addEventListener("mouseover", stopPropagation, {
|
|
5604
|
+
capture: true
|
|
5605
|
+
});
|
|
5606
|
+
const onFocus = () => {
|
|
5607
|
+
setTimeout(() => {
|
|
5608
|
+
el.addEventListener("pointerdown", stopPropagation, {
|
|
5609
|
+
capture: true
|
|
5610
|
+
});
|
|
5611
|
+
}, 200);
|
|
5612
|
+
};
|
|
5613
|
+
const onBlur = () => {
|
|
5614
|
+
el.removeEventListener("pointerdown", stopPropagation, {
|
|
5615
|
+
capture: true
|
|
5616
|
+
});
|
|
5617
|
+
};
|
|
5618
|
+
if (disableDragOnFocus) {
|
|
5619
|
+
el.addEventListener("focus", onFocus, { capture: true });
|
|
5620
|
+
el.addEventListener("blur", onBlur, { capture: true });
|
|
5621
|
+
} else if (disableDrag) {
|
|
5622
|
+
el.addEventListener("pointerdown", stopPropagation, {
|
|
5623
|
+
capture: true
|
|
5624
|
+
});
|
|
5625
|
+
}
|
|
5626
|
+
el.setAttribute("data-puck-overlay-portal", "true");
|
|
5627
|
+
return () => {
|
|
5628
|
+
el.removeEventListener("mouseover", stopPropagation, {
|
|
5629
|
+
capture: true
|
|
5630
|
+
});
|
|
5631
|
+
if (disableDragOnFocus) {
|
|
5632
|
+
el.removeEventListener("focus", onFocus, { capture: true });
|
|
5633
|
+
el.removeEventListener("blur", onFocus, { capture: true });
|
|
5634
|
+
} else if (disableDrag) {
|
|
5635
|
+
el.removeEventListener("pointerdown", stopPropagation, {
|
|
5636
|
+
capture: true
|
|
5637
|
+
});
|
|
5638
|
+
}
|
|
5639
|
+
el.removeAttribute("data-puck-overlay-portal");
|
|
5640
|
+
};
|
|
5641
|
+
};
|
|
5642
|
+
|
|
5643
|
+
// css-module:/home/runner/work/puck/puck/packages/core/components/InlineTextField/styles.module.css#css-module
|
|
5644
|
+
init_react_import();
|
|
5645
|
+
var styles_module_default13 = { "InlineTextField": "_InlineTextField_ilw2a_1" };
|
|
5646
|
+
|
|
5647
|
+
// lib/data/set-deep.ts
|
|
5648
|
+
init_react_import();
|
|
5649
|
+
function setDeep(node, path, newVal) {
|
|
5650
|
+
const parts = path.split(".");
|
|
5651
|
+
const newNode = __spreadValues({}, node);
|
|
5652
|
+
let cur = newNode;
|
|
5653
|
+
for (let i = 0; i < parts.length; i++) {
|
|
5654
|
+
const [prop, idxStr] = parts[i].replace("]", "").split("[");
|
|
5655
|
+
const isLast = i === parts.length - 1;
|
|
5656
|
+
if (idxStr !== void 0) {
|
|
5657
|
+
if (!Array.isArray(cur[prop])) {
|
|
5658
|
+
cur[prop] = [];
|
|
5659
|
+
}
|
|
5660
|
+
const idx = Number(idxStr);
|
|
5661
|
+
if (isLast) {
|
|
5662
|
+
cur[prop][idx] = newVal;
|
|
5663
|
+
continue;
|
|
5664
|
+
}
|
|
5665
|
+
if (cur[prop][idx] === void 0) cur[prop][idx] = {};
|
|
5666
|
+
cur = cur[prop][idx];
|
|
5667
|
+
continue;
|
|
5668
|
+
}
|
|
5669
|
+
if (isLast) {
|
|
5670
|
+
cur[prop] = newVal;
|
|
5671
|
+
continue;
|
|
5672
|
+
}
|
|
5673
|
+
if (cur[prop] === void 0) {
|
|
5674
|
+
cur[prop] = {};
|
|
5675
|
+
}
|
|
5676
|
+
cur = cur[prop];
|
|
5677
|
+
}
|
|
5678
|
+
return __spreadValues(__spreadValues({}, node), newNode);
|
|
5679
|
+
}
|
|
5680
|
+
|
|
5681
|
+
// components/InlineTextField/index.tsx
|
|
5682
|
+
import { jsx as jsx24 } from "react/jsx-runtime";
|
|
5683
|
+
var getClassName18 = get_class_name_factory_default("InlineTextField", styles_module_default13);
|
|
5684
|
+
var InlineTextFieldInternal = ({
|
|
5685
|
+
propPath,
|
|
5686
|
+
componentId,
|
|
5687
|
+
value,
|
|
5688
|
+
isReadOnly,
|
|
5689
|
+
opts = {}
|
|
5690
|
+
}) => {
|
|
5691
|
+
var _a;
|
|
5692
|
+
const ref = useRef5(null);
|
|
5693
|
+
const appStoreApi = useAppStoreApi();
|
|
5694
|
+
const disableLineBreaks = (_a = opts.disableLineBreaks) != null ? _a : false;
|
|
5695
|
+
useEffect17(() => {
|
|
5696
|
+
const appStore = appStoreApi.getState();
|
|
5697
|
+
const data = appStore.state.indexes.nodes[componentId].data;
|
|
5698
|
+
const componentConfig = appStore.getComponentConfig(data.type);
|
|
5699
|
+
if (!componentConfig) {
|
|
5700
|
+
throw new Error(
|
|
5701
|
+
`InlineTextField Error: No config defined for ${data.type}`
|
|
5702
|
+
);
|
|
5703
|
+
}
|
|
5704
|
+
if (ref.current) {
|
|
5705
|
+
if (value !== ref.current.innerText) {
|
|
5706
|
+
ref.current.replaceChildren(value);
|
|
5707
|
+
}
|
|
5708
|
+
const cleanupPortal = registerOverlayPortal(ref.current);
|
|
5709
|
+
const handleInput = (e) => __async(void 0, null, function* () {
|
|
5710
|
+
var _a2;
|
|
5711
|
+
const appStore2 = appStoreApi.getState();
|
|
5712
|
+
const node = appStore2.state.indexes.nodes[componentId];
|
|
5713
|
+
const zoneCompound = `${node.parentId}:${node.zone}`;
|
|
5714
|
+
const index = (_a2 = appStore2.state.indexes.zones[zoneCompound]) == null ? void 0 : _a2.contentIds.indexOf(
|
|
5715
|
+
componentId
|
|
5716
|
+
);
|
|
5717
|
+
const newProps = setDeep(node.data.props, propPath, e.target.innerText);
|
|
5718
|
+
const resolvedData = yield appStore2.resolveComponentData(
|
|
5719
|
+
__spreadProps(__spreadValues({}, node.data), { props: newProps }),
|
|
5720
|
+
"replace"
|
|
5721
|
+
);
|
|
5722
|
+
appStore2.dispatch({
|
|
5723
|
+
type: "replace",
|
|
5724
|
+
data: resolvedData.node,
|
|
5725
|
+
destinationIndex: index,
|
|
5726
|
+
destinationZone: zoneCompound
|
|
5727
|
+
});
|
|
5728
|
+
});
|
|
5729
|
+
ref.current.addEventListener("input", handleInput);
|
|
5730
|
+
return () => {
|
|
5731
|
+
var _a2;
|
|
5732
|
+
(_a2 = ref.current) == null ? void 0 : _a2.removeEventListener("input", handleInput);
|
|
5733
|
+
cleanupPortal == null ? void 0 : cleanupPortal();
|
|
5734
|
+
};
|
|
5735
|
+
}
|
|
5736
|
+
}, [appStoreApi, ref.current, value]);
|
|
5737
|
+
const [isHovering, setIsHovering] = useState16(false);
|
|
5738
|
+
const [isFocused, setIsFocused] = useState16(false);
|
|
5739
|
+
return /* @__PURE__ */ jsx24(
|
|
5740
|
+
"span",
|
|
5741
|
+
{
|
|
5742
|
+
className: getClassName18(),
|
|
5743
|
+
ref,
|
|
5744
|
+
contentEditable: isHovering || isFocused ? "plaintext-only" : "false",
|
|
5745
|
+
onClick: (e) => {
|
|
5746
|
+
e.preventDefault();
|
|
5747
|
+
e.stopPropagation();
|
|
5748
|
+
},
|
|
5749
|
+
onClickCapture: (e) => {
|
|
5750
|
+
e.preventDefault();
|
|
5751
|
+
e.stopPropagation();
|
|
5752
|
+
},
|
|
5753
|
+
onKeyDown: (e) => {
|
|
5754
|
+
if (disableLineBreaks && e.key === "Enter" || isReadOnly) {
|
|
5755
|
+
e.preventDefault();
|
|
5756
|
+
}
|
|
5757
|
+
},
|
|
5758
|
+
onMouseOverCapture: () => setIsHovering(true),
|
|
5759
|
+
onMouseOutCapture: () => setIsHovering(false),
|
|
5760
|
+
onFocus: () => setIsFocused(true),
|
|
5761
|
+
onBlur: () => setIsFocused(false)
|
|
5762
|
+
}
|
|
5763
|
+
);
|
|
5764
|
+
};
|
|
5765
|
+
var InlineTextField = memo(InlineTextFieldInternal);
|
|
5766
|
+
|
|
5767
|
+
// lib/field-transforms/default-transforms/inline-text-transform.tsx
|
|
5768
|
+
import { jsx as jsx25 } from "react/jsx-runtime";
|
|
5769
|
+
var getInlineTextTransform = () => ({
|
|
5770
|
+
text: ({ value, componentId, field, propPath, isReadOnly }) => {
|
|
5771
|
+
if (field.contentEditable) {
|
|
5772
|
+
return /* @__PURE__ */ jsx25(
|
|
5773
|
+
InlineTextField,
|
|
5774
|
+
{
|
|
5775
|
+
propPath,
|
|
5776
|
+
componentId,
|
|
5777
|
+
value,
|
|
5778
|
+
opts: { disableLineBreaks: true },
|
|
5779
|
+
isReadOnly
|
|
5780
|
+
}
|
|
5781
|
+
);
|
|
5782
|
+
}
|
|
5783
|
+
return value;
|
|
5784
|
+
},
|
|
5785
|
+
textarea: ({ value, componentId, field, propPath, isReadOnly }) => {
|
|
5786
|
+
if (field.contentEditable) {
|
|
5787
|
+
return /* @__PURE__ */ jsx25(
|
|
5788
|
+
InlineTextField,
|
|
5789
|
+
{
|
|
5790
|
+
propPath,
|
|
5791
|
+
componentId,
|
|
5792
|
+
value,
|
|
5793
|
+
isReadOnly
|
|
5794
|
+
}
|
|
5795
|
+
);
|
|
5796
|
+
}
|
|
5797
|
+
return value;
|
|
5798
|
+
},
|
|
5799
|
+
custom: ({ value, componentId, field, propPath, isReadOnly }) => {
|
|
5800
|
+
if (field.contentEditable && typeof value === "string") {
|
|
5801
|
+
return /* @__PURE__ */ jsx25(
|
|
5802
|
+
InlineTextField,
|
|
5803
|
+
{
|
|
5804
|
+
propPath,
|
|
5805
|
+
componentId,
|
|
5806
|
+
value,
|
|
5807
|
+
isReadOnly
|
|
5808
|
+
}
|
|
5809
|
+
);
|
|
5810
|
+
}
|
|
5811
|
+
return value;
|
|
5812
|
+
}
|
|
5813
|
+
});
|
|
5814
|
+
|
|
4098
5815
|
// components/DropZone/index.tsx
|
|
4099
|
-
import { Fragment as Fragment7, jsx as
|
|
4100
|
-
var
|
|
5816
|
+
import { Fragment as Fragment7, jsx as jsx26, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
5817
|
+
var getClassName19 = get_class_name_factory_default("DropZone", styles_module_default11);
|
|
4101
5818
|
var getRandomColor = () => `#${Math.floor(Math.random() * 16777215).toString(16)}`;
|
|
4102
5819
|
var RENDER_DEBUG = false;
|
|
4103
|
-
var DropZoneEditPure = (props) => /* @__PURE__ */
|
|
5820
|
+
var DropZoneEditPure = (props) => /* @__PURE__ */ jsx26(DropZoneEdit, __spreadValues({}, props));
|
|
4104
5821
|
var DropZoneChild = ({
|
|
4105
5822
|
zoneCompound,
|
|
4106
5823
|
componentId,
|
|
@@ -4111,9 +5828,9 @@ var DropZoneChild = ({
|
|
|
4111
5828
|
}) => {
|
|
4112
5829
|
var _a, _b;
|
|
4113
5830
|
const metadata = useAppStore((s) => s.metadata);
|
|
4114
|
-
const ctx =
|
|
5831
|
+
const ctx = useContext8(dropZoneContext);
|
|
4115
5832
|
const { depth = 1 } = ctx != null ? ctx : {};
|
|
4116
|
-
const zoneStore =
|
|
5833
|
+
const zoneStore = useContext8(ZoneStoreContext);
|
|
4117
5834
|
const nodeProps = useAppStore(
|
|
4118
5835
|
useShallow4((s) => {
|
|
4119
5836
|
var _a2;
|
|
@@ -4184,10 +5901,10 @@ var DropZoneChild = ({
|
|
|
4184
5901
|
if (item && "element" in item && item.element) {
|
|
4185
5902
|
return (
|
|
4186
5903
|
// Safe to use this since the HTML is set by the user
|
|
4187
|
-
/* @__PURE__ */
|
|
5904
|
+
/* @__PURE__ */ jsx26("div", { dangerouslySetInnerHTML: { __html: item.element.outerHTML } })
|
|
4188
5905
|
);
|
|
4189
5906
|
}
|
|
4190
|
-
return /* @__PURE__ */
|
|
5907
|
+
return /* @__PURE__ */ jsx26(DrawerItemInner, { name: label, children: (_a2 = overrides.componentItem) != null ? _a2 : overrides.drawerItem });
|
|
4191
5908
|
},
|
|
4192
5909
|
[componentId, label, overrides]
|
|
4193
5910
|
);
|
|
@@ -4210,7 +5927,7 @@ var DropZoneChild = ({
|
|
|
4210
5927
|
const plugins = useAppStore((s) => s.plugins);
|
|
4211
5928
|
const userFieldTransforms = useAppStore((s) => s.fieldTransforms);
|
|
4212
5929
|
const combinedFieldTransforms = useMemo8(
|
|
4213
|
-
() => __spreadValues(__spreadValues(__spreadValues(__spreadValues({}, getSlotTransform(DropZoneEditPure, (slotProps) => /* @__PURE__ */
|
|
5930
|
+
() => __spreadValues(__spreadValues(__spreadValues(__spreadValues({}, getSlotTransform(DropZoneEditPure, (slotProps) => /* @__PURE__ */ jsx26(ContextSlotRender, { componentId, zone: slotProps.zone }))), getInlineTextTransform()), plugins.reduce(
|
|
4214
5931
|
(acc, plugin) => __spreadValues(__spreadValues({}, acc), plugin.fieldTransforms),
|
|
4215
5932
|
{}
|
|
4216
5933
|
)), userFieldTransforms),
|
|
@@ -4233,7 +5950,7 @@ var DropZoneChild = ({
|
|
|
4233
5950
|
if (isInserting) {
|
|
4234
5951
|
Render2 = renderPreview;
|
|
4235
5952
|
}
|
|
4236
|
-
return /* @__PURE__ */
|
|
5953
|
+
return /* @__PURE__ */ jsx26(
|
|
4237
5954
|
DraggableComponent,
|
|
4238
5955
|
{
|
|
4239
5956
|
id: componentId,
|
|
@@ -4247,18 +5964,18 @@ var DropZoneChild = ({
|
|
|
4247
5964
|
autoDragAxis: dragAxis,
|
|
4248
5965
|
userDragAxis: collisionAxis,
|
|
4249
5966
|
inDroppableZone,
|
|
4250
|
-
children: (dragRef) => (componentConfig == null ? void 0 : componentConfig.inline) && !isInserting ? /* @__PURE__ */
|
|
5967
|
+
children: (dragRef) => (componentConfig == null ? void 0 : componentConfig.inline) && !isInserting ? /* @__PURE__ */ jsx26(Fragment7, { children: /* @__PURE__ */ jsx26(
|
|
4251
5968
|
Render2,
|
|
4252
5969
|
__spreadProps(__spreadValues({}, transformedProps), {
|
|
4253
5970
|
puck: __spreadProps(__spreadValues({}, transformedProps.puck), {
|
|
4254
5971
|
dragRef
|
|
4255
5972
|
})
|
|
4256
5973
|
})
|
|
4257
|
-
) }) : /* @__PURE__ */
|
|
5974
|
+
) }) : /* @__PURE__ */ jsx26("div", { ref: dragRef, children: /* @__PURE__ */ jsx26(Render2, __spreadValues({}, transformedProps)) })
|
|
4258
5975
|
}
|
|
4259
5976
|
);
|
|
4260
5977
|
};
|
|
4261
|
-
var DropZoneChildMemo =
|
|
5978
|
+
var DropZoneChildMemo = memo2(DropZoneChild);
|
|
4262
5979
|
var DropZoneEdit = forwardRef3(
|
|
4263
5980
|
function DropZoneEditInternal({
|
|
4264
5981
|
zone,
|
|
@@ -4269,7 +5986,7 @@ var DropZoneEdit = forwardRef3(
|
|
|
4269
5986
|
minEmptyHeight: userMinEmptyHeight = 128,
|
|
4270
5987
|
collisionAxis
|
|
4271
5988
|
}, userRef) {
|
|
4272
|
-
const ctx =
|
|
5989
|
+
const ctx = useContext8(dropZoneContext);
|
|
4273
5990
|
const appStoreApi = useAppStoreApi();
|
|
4274
5991
|
const {
|
|
4275
5992
|
// These all need setting via context
|
|
@@ -4307,14 +6024,14 @@ var DropZoneEdit = forwardRef3(
|
|
|
4307
6024
|
return (_a = s.state.indexes.zones[zoneCompound]) == null ? void 0 : _a.type;
|
|
4308
6025
|
})
|
|
4309
6026
|
);
|
|
4310
|
-
|
|
6027
|
+
useEffect18(() => {
|
|
4311
6028
|
if (!zoneType || zoneType === "dropzone") {
|
|
4312
6029
|
if (ctx == null ? void 0 : ctx.registerZone) {
|
|
4313
6030
|
ctx == null ? void 0 : ctx.registerZone(zoneCompound);
|
|
4314
6031
|
}
|
|
4315
6032
|
}
|
|
4316
6033
|
}, [zoneType, appStoreApi]);
|
|
4317
|
-
|
|
6034
|
+
useEffect18(() => {
|
|
4318
6035
|
if (zoneType === "dropzone") {
|
|
4319
6036
|
if (zoneCompound !== rootDroppableId) {
|
|
4320
6037
|
console.warn(
|
|
@@ -4326,8 +6043,8 @@ var DropZoneEdit = forwardRef3(
|
|
|
4326
6043
|
const contentIds = useMemo8(() => {
|
|
4327
6044
|
return zoneContentIds || [];
|
|
4328
6045
|
}, [zoneContentIds]);
|
|
4329
|
-
const ref =
|
|
4330
|
-
const acceptsTarget =
|
|
6046
|
+
const ref = useRef6(null);
|
|
6047
|
+
const acceptsTarget = useCallback11(
|
|
4331
6048
|
(componentType) => {
|
|
4332
6049
|
if (!componentType) {
|
|
4333
6050
|
return true;
|
|
@@ -4365,7 +6082,7 @@ var DropZoneEdit = forwardRef3(
|
|
|
4365
6082
|
}
|
|
4366
6083
|
return _isEnabled;
|
|
4367
6084
|
});
|
|
4368
|
-
|
|
6085
|
+
useEffect18(() => {
|
|
4369
6086
|
if (registerLocalZone) {
|
|
4370
6087
|
registerLocalZone(zoneCompound, targetAccepted || isEnabled);
|
|
4371
6088
|
}
|
|
@@ -4380,8 +6097,8 @@ var DropZoneEdit = forwardRef3(
|
|
|
4380
6097
|
zoneCompound
|
|
4381
6098
|
);
|
|
4382
6099
|
const isDropEnabled = isEnabled && (preview ? contentIdsWithPreview.length === 1 : contentIdsWithPreview.length === 0);
|
|
4383
|
-
const zoneStore =
|
|
4384
|
-
|
|
6100
|
+
const zoneStore = useContext8(ZoneStoreContext);
|
|
6101
|
+
useEffect18(() => {
|
|
4385
6102
|
const { enabledIndex } = zoneStore.getState();
|
|
4386
6103
|
zoneStore.setState({
|
|
4387
6104
|
enabledIndex: __spreadProps(__spreadValues({}, enabledIndex), { [zoneCompound]: isEnabled })
|
|
@@ -4410,10 +6127,10 @@ var DropZoneEdit = forwardRef3(
|
|
|
4410
6127
|
userMinEmptyHeight,
|
|
4411
6128
|
ref
|
|
4412
6129
|
});
|
|
4413
|
-
return /* @__PURE__ */
|
|
6130
|
+
return /* @__PURE__ */ jsx26(
|
|
4414
6131
|
"div",
|
|
4415
6132
|
{
|
|
4416
|
-
className: `${
|
|
6133
|
+
className: `${getClassName19({
|
|
4417
6134
|
isRootZone,
|
|
4418
6135
|
hoveringOverArea,
|
|
4419
6136
|
isEnabled,
|
|
@@ -4431,7 +6148,7 @@ var DropZoneEdit = forwardRef3(
|
|
|
4431
6148
|
backgroundColor: RENDER_DEBUG ? getRandomColor() : style == null ? void 0 : style.backgroundColor
|
|
4432
6149
|
}),
|
|
4433
6150
|
children: contentIdsWithPreview.map((componentId, i) => {
|
|
4434
|
-
return /* @__PURE__ */
|
|
6151
|
+
return /* @__PURE__ */ jsx26(
|
|
4435
6152
|
DropZoneChildMemo,
|
|
4436
6153
|
{
|
|
4437
6154
|
zoneCompound,
|
|
@@ -4454,7 +6171,7 @@ var DropZoneRenderItem = ({
|
|
|
4454
6171
|
metadata
|
|
4455
6172
|
}) => {
|
|
4456
6173
|
const Component = config.components[item.type];
|
|
4457
|
-
const props = useSlots(config, item, (slotProps) => /* @__PURE__ */
|
|
6174
|
+
const props = useSlots(config, item, (slotProps) => /* @__PURE__ */ jsx26(SlotRenderPure, __spreadProps(__spreadValues({}, slotProps), { config, metadata })));
|
|
4458
6175
|
const nextContextValue = useMemo8(
|
|
4459
6176
|
() => ({
|
|
4460
6177
|
areaId: props.id,
|
|
@@ -4462,7 +6179,7 @@ var DropZoneRenderItem = ({
|
|
|
4462
6179
|
}),
|
|
4463
6180
|
[props]
|
|
4464
6181
|
);
|
|
4465
|
-
return /* @__PURE__ */
|
|
6182
|
+
return /* @__PURE__ */ jsx26(DropZoneProvider, { value: nextContextValue, children: /* @__PURE__ */ jsx26(
|
|
4466
6183
|
Component.render,
|
|
4467
6184
|
__spreadProps(__spreadValues({}, props), {
|
|
4468
6185
|
puck: __spreadProps(__spreadValues({}, props.puck), {
|
|
@@ -4472,15 +6189,15 @@ var DropZoneRenderItem = ({
|
|
|
4472
6189
|
})
|
|
4473
6190
|
) }, props.id);
|
|
4474
6191
|
};
|
|
4475
|
-
var DropZoneRenderPure = (props) => /* @__PURE__ */
|
|
6192
|
+
var DropZoneRenderPure = (props) => /* @__PURE__ */ jsx26(DropZoneRender, __spreadValues({}, props));
|
|
4476
6193
|
var DropZoneRender = forwardRef3(
|
|
4477
6194
|
function DropZoneRenderInternal({ className, style, zone }, ref) {
|
|
4478
|
-
const ctx =
|
|
6195
|
+
const ctx = useContext8(dropZoneContext);
|
|
4479
6196
|
const { areaId = "root" } = ctx || {};
|
|
4480
|
-
const { config, data, metadata } =
|
|
6197
|
+
const { config, data, metadata } = useContext8(renderContext);
|
|
4481
6198
|
let zoneCompound = `${areaId}:${zone}`;
|
|
4482
6199
|
let content = (data == null ? void 0 : data.content) || [];
|
|
4483
|
-
|
|
6200
|
+
useEffect18(() => {
|
|
4484
6201
|
if (!content) {
|
|
4485
6202
|
if (ctx == null ? void 0 : ctx.registerZone) {
|
|
4486
6203
|
ctx == null ? void 0 : ctx.registerZone(zoneCompound);
|
|
@@ -4493,10 +6210,10 @@ var DropZoneRender = forwardRef3(
|
|
|
4493
6210
|
if (zoneCompound !== rootDroppableId) {
|
|
4494
6211
|
content = setupZone(data, zoneCompound).zones[zoneCompound];
|
|
4495
6212
|
}
|
|
4496
|
-
return /* @__PURE__ */
|
|
6213
|
+
return /* @__PURE__ */ jsx26("div", { className, style, ref, children: content.map((item) => {
|
|
4497
6214
|
const Component = config.components[item.type];
|
|
4498
6215
|
if (Component) {
|
|
4499
|
-
return /* @__PURE__ */
|
|
6216
|
+
return /* @__PURE__ */ jsx26(
|
|
4500
6217
|
DropZoneRenderItem,
|
|
4501
6218
|
{
|
|
4502
6219
|
config,
|
|
@@ -4510,20 +6227,20 @@ var DropZoneRender = forwardRef3(
|
|
|
4510
6227
|
}) });
|
|
4511
6228
|
}
|
|
4512
6229
|
);
|
|
4513
|
-
var DropZonePure = (props) => /* @__PURE__ */
|
|
6230
|
+
var DropZonePure = (props) => /* @__PURE__ */ jsx26(DropZone, __spreadValues({}, props));
|
|
4514
6231
|
var DropZone = forwardRef3(
|
|
4515
6232
|
function DropZone2(props, ref) {
|
|
4516
|
-
const ctx =
|
|
6233
|
+
const ctx = useContext8(dropZoneContext);
|
|
4517
6234
|
if ((ctx == null ? void 0 : ctx.mode) === "edit") {
|
|
4518
|
-
return /* @__PURE__ */
|
|
6235
|
+
return /* @__PURE__ */ jsx26(Fragment7, { children: /* @__PURE__ */ jsx26(DropZoneEdit, __spreadProps(__spreadValues({}, props), { ref })) });
|
|
4519
6236
|
}
|
|
4520
|
-
return /* @__PURE__ */
|
|
6237
|
+
return /* @__PURE__ */ jsx26(Fragment7, { children: /* @__PURE__ */ jsx26(DropZoneRender, __spreadProps(__spreadValues({}, props), { ref })) });
|
|
4521
6238
|
}
|
|
4522
6239
|
);
|
|
4523
6240
|
|
|
4524
6241
|
// components/Render/index.tsx
|
|
4525
6242
|
import React3, { useMemo as useMemo9 } from "react";
|
|
4526
|
-
import { jsx as
|
|
6243
|
+
import { jsx as jsx27 } from "react/jsx-runtime";
|
|
4527
6244
|
var renderContext = React3.createContext({
|
|
4528
6245
|
config: { components: {} },
|
|
4529
6246
|
data: { root: {}, content: [] },
|
|
@@ -4555,7 +6272,7 @@ function Render({
|
|
|
4555
6272
|
const propsWithSlots = useSlots(
|
|
4556
6273
|
config,
|
|
4557
6274
|
{ type: "root", props: pageProps },
|
|
4558
|
-
(props) => /* @__PURE__ */
|
|
6275
|
+
(props) => /* @__PURE__ */ jsx27(SlotRender, __spreadProps(__spreadValues({}, props), { config, metadata }))
|
|
4559
6276
|
);
|
|
4560
6277
|
const nextContextValue = useMemo9(
|
|
4561
6278
|
() => ({
|
|
@@ -4565,15 +6282,15 @@ function Render({
|
|
|
4565
6282
|
[]
|
|
4566
6283
|
);
|
|
4567
6284
|
if ((_a = config.root) == null ? void 0 : _a.render) {
|
|
4568
|
-
return /* @__PURE__ */
|
|
6285
|
+
return /* @__PURE__ */ jsx27(renderContext.Provider, { value: { config, data: defaultedData, metadata }, children: /* @__PURE__ */ jsx27(DropZoneProvider, { value: nextContextValue, children: /* @__PURE__ */ jsx27(config.root.render, __spreadProps(__spreadValues({}, propsWithSlots), { children: /* @__PURE__ */ jsx27(DropZoneRenderPure, { zone: rootZone }) })) }) });
|
|
4569
6286
|
}
|
|
4570
|
-
return /* @__PURE__ */
|
|
6287
|
+
return /* @__PURE__ */ jsx27(renderContext.Provider, { value: { config, data: defaultedData, metadata }, children: /* @__PURE__ */ jsx27(DropZoneProvider, { value: nextContextValue, children: /* @__PURE__ */ jsx27(DropZoneRenderPure, { zone: rootZone }) }) });
|
|
4571
6288
|
}
|
|
4572
6289
|
|
|
4573
6290
|
// lib/use-puck.ts
|
|
4574
6291
|
init_react_import();
|
|
4575
|
-
import { createContext as
|
|
4576
|
-
import { createStore as createStore4, useStore as
|
|
6292
|
+
import { createContext as createContext5, useContext as useContext9, useEffect as useEffect19, useState as useState17 } from "react";
|
|
6293
|
+
import { createStore as createStore4, useStore as useStore3 } from "zustand";
|
|
4577
6294
|
var generateUsePuck = (store) => {
|
|
4578
6295
|
const history = {
|
|
4579
6296
|
back: store.history.back,
|
|
@@ -4605,7 +6322,7 @@ var generateUsePuck = (store) => {
|
|
|
4605
6322
|
};
|
|
4606
6323
|
return storeData;
|
|
4607
6324
|
};
|
|
4608
|
-
var UsePuckStoreContext =
|
|
6325
|
+
var UsePuckStoreContext = createContext5(
|
|
4609
6326
|
null
|
|
4610
6327
|
);
|
|
4611
6328
|
var convertToPickedStore = (store) => {
|
|
@@ -4619,12 +6336,12 @@ var convertToPickedStore = (store) => {
|
|
|
4619
6336
|
};
|
|
4620
6337
|
};
|
|
4621
6338
|
var useRegisterUsePuckStore = (appStore) => {
|
|
4622
|
-
const [usePuckStore] =
|
|
6339
|
+
const [usePuckStore] = useState17(
|
|
4623
6340
|
() => createStore4(
|
|
4624
6341
|
() => generateUsePuck(convertToPickedStore(appStore.getState()))
|
|
4625
6342
|
)
|
|
4626
6343
|
);
|
|
4627
|
-
|
|
6344
|
+
useEffect19(() => {
|
|
4628
6345
|
return appStore.subscribe(
|
|
4629
6346
|
(store) => convertToPickedStore(store),
|
|
4630
6347
|
(pickedStore) => {
|
|
@@ -4636,11 +6353,11 @@ var useRegisterUsePuckStore = (appStore) => {
|
|
|
4636
6353
|
};
|
|
4637
6354
|
function createUsePuck() {
|
|
4638
6355
|
return function usePuck2(selector) {
|
|
4639
|
-
const usePuckApi =
|
|
6356
|
+
const usePuckApi = useContext9(UsePuckStoreContext);
|
|
4640
6357
|
if (!usePuckApi) {
|
|
4641
6358
|
throw new Error("usePuck must be used inside <Puck>.");
|
|
4642
6359
|
}
|
|
4643
|
-
const result =
|
|
6360
|
+
const result = useStore3(
|
|
4644
6361
|
usePuckApi,
|
|
4645
6362
|
selector != null ? selector : (s) => s
|
|
4646
6363
|
);
|
|
@@ -4648,7 +6365,7 @@ function createUsePuck() {
|
|
|
4648
6365
|
};
|
|
4649
6366
|
}
|
|
4650
6367
|
function usePuck() {
|
|
4651
|
-
|
|
6368
|
+
useEffect19(() => {
|
|
4652
6369
|
console.warn(
|
|
4653
6370
|
"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."
|
|
4654
6371
|
);
|
|
@@ -4656,7 +6373,7 @@ function usePuck() {
|
|
|
4656
6373
|
return createUsePuck()((s) => s);
|
|
4657
6374
|
}
|
|
4658
6375
|
function useGetPuck() {
|
|
4659
|
-
const usePuckApi =
|
|
6376
|
+
const usePuckApi = useContext9(UsePuckStoreContext);
|
|
4660
6377
|
if (!usePuckApi) {
|
|
4661
6378
|
throw new Error("usePuckGet must be used inside <Puck>.");
|
|
4662
6379
|
}
|
|
@@ -4666,13 +6383,13 @@ function useGetPuck() {
|
|
|
4666
6383
|
// components/Puck/index.tsx
|
|
4667
6384
|
init_react_import();
|
|
4668
6385
|
import {
|
|
4669
|
-
createContext as
|
|
4670
|
-
useCallback as
|
|
4671
|
-
useContext as
|
|
4672
|
-
useEffect as
|
|
6386
|
+
createContext as createContext8,
|
|
6387
|
+
useCallback as useCallback20,
|
|
6388
|
+
useContext as useContext13,
|
|
6389
|
+
useEffect as useEffect29,
|
|
4673
6390
|
useMemo as useMemo20,
|
|
4674
|
-
useRef as
|
|
4675
|
-
useState as
|
|
6391
|
+
useRef as useRef12,
|
|
6392
|
+
useState as useState25
|
|
4676
6393
|
} from "react";
|
|
4677
6394
|
|
|
4678
6395
|
// components/SidebarSection/index.tsx
|
|
@@ -4680,7 +6397,7 @@ init_react_import();
|
|
|
4680
6397
|
|
|
4681
6398
|
// css-module:/home/runner/work/puck/puck/packages/core/components/SidebarSection/styles.module.css#css-module
|
|
4682
6399
|
init_react_import();
|
|
4683
|
-
var
|
|
6400
|
+
var styles_module_default14 = { "SidebarSection": "_SidebarSection_8boj8_1", "SidebarSection-title": "_SidebarSection-title_8boj8_12", "SidebarSection--noBorderTop": "_SidebarSection--noBorderTop_8boj8_20", "SidebarSection-content": "_SidebarSection-content_8boj8_24", "SidebarSection--noPadding": "_SidebarSection--noPadding_8boj8_28", "SidebarSection-breadcrumbLabel": "_SidebarSection-breadcrumbLabel_8boj8_41", "SidebarSection-breadcrumbs": "_SidebarSection-breadcrumbs_8boj8_70", "SidebarSection-breadcrumb": "_SidebarSection-breadcrumb_8boj8_41", "SidebarSection-heading": "_SidebarSection-heading_8boj8_82", "SidebarSection-loadingOverlay": "_SidebarSection-loadingOverlay_8boj8_86" };
|
|
4684
6401
|
|
|
4685
6402
|
// lib/use-breadcrumbs.ts
|
|
4686
6403
|
init_react_import();
|
|
@@ -4727,8 +6444,8 @@ var useBreadcrumbs = (renderCount) => {
|
|
|
4727
6444
|
};
|
|
4728
6445
|
|
|
4729
6446
|
// components/SidebarSection/index.tsx
|
|
4730
|
-
import { jsx as
|
|
4731
|
-
var
|
|
6447
|
+
import { jsx as jsx28, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
6448
|
+
var getClassName20 = get_class_name_factory_default("SidebarSection", styles_module_default14);
|
|
4732
6449
|
var SidebarSection = ({
|
|
4733
6450
|
children,
|
|
4734
6451
|
title,
|
|
@@ -4743,26 +6460,26 @@ var SidebarSection = ({
|
|
|
4743
6460
|
return /* @__PURE__ */ jsxs12(
|
|
4744
6461
|
"div",
|
|
4745
6462
|
{
|
|
4746
|
-
className:
|
|
6463
|
+
className: getClassName20({ noBorderTop, noPadding }),
|
|
4747
6464
|
style: { background },
|
|
4748
6465
|
children: [
|
|
4749
|
-
/* @__PURE__ */
|
|
4750
|
-
showBreadcrumbs ? breadcrumbs.map((breadcrumb, i) => /* @__PURE__ */ jsxs12("div", { className:
|
|
4751
|
-
/* @__PURE__ */
|
|
6466
|
+
/* @__PURE__ */ jsx28("div", { className: getClassName20("title"), children: /* @__PURE__ */ jsxs12("div", { className: getClassName20("breadcrumbs"), children: [
|
|
6467
|
+
showBreadcrumbs ? breadcrumbs.map((breadcrumb, i) => /* @__PURE__ */ jsxs12("div", { className: getClassName20("breadcrumb"), children: [
|
|
6468
|
+
/* @__PURE__ */ jsx28(
|
|
4752
6469
|
"button",
|
|
4753
6470
|
{
|
|
4754
6471
|
type: "button",
|
|
4755
|
-
className:
|
|
6472
|
+
className: getClassName20("breadcrumbLabel"),
|
|
4756
6473
|
onClick: () => setUi({ itemSelector: breadcrumb.selector }),
|
|
4757
6474
|
children: breadcrumb.label
|
|
4758
6475
|
}
|
|
4759
6476
|
),
|
|
4760
|
-
/* @__PURE__ */
|
|
6477
|
+
/* @__PURE__ */ jsx28(ChevronRight, { size: 16 })
|
|
4761
6478
|
] }, i)) : null,
|
|
4762
|
-
/* @__PURE__ */
|
|
6479
|
+
/* @__PURE__ */ jsx28("div", { className: getClassName20("heading"), children: /* @__PURE__ */ jsx28(Heading, { rank: "2", size: "xs", children: title }) })
|
|
4763
6480
|
] }) }),
|
|
4764
|
-
/* @__PURE__ */
|
|
4765
|
-
isLoading && /* @__PURE__ */
|
|
6481
|
+
/* @__PURE__ */ jsx28("div", { className: getClassName20("content"), children }),
|
|
6482
|
+
isLoading && /* @__PURE__ */ jsx28("div", { className: getClassName20("loadingOverlay"), children: /* @__PURE__ */ jsx28(Loader, { size: 32 }) })
|
|
4766
6483
|
]
|
|
4767
6484
|
}
|
|
4768
6485
|
);
|
|
@@ -4770,28 +6487,28 @@ var SidebarSection = ({
|
|
|
4770
6487
|
|
|
4771
6488
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/styles.module.css#css-module
|
|
4772
6489
|
init_react_import();
|
|
4773
|
-
var
|
|
6490
|
+
var styles_module_default15 = { "Puck": "_Puck_a45x1_19", "Puck-portal": "_Puck-portal_a45x1_31", "PuckLayout-inner": "_PuckLayout-inner_a45x1_38", "PuckLayout--mounted": "_PuckLayout--mounted_a45x1_59", "PuckLayout--leftSideBarVisible": "_PuckLayout--leftSideBarVisible_a45x1_63", "PuckLayout--rightSideBarVisible": "_PuckLayout--rightSideBarVisible_a45x1_69", "PuckLayout-mounted": "_PuckLayout-mounted_a45x1_83", "PuckLayout": "_PuckLayout_a45x1_38" };
|
|
4774
6491
|
|
|
4775
6492
|
// components/Puck/components/Fields/index.tsx
|
|
4776
6493
|
init_react_import();
|
|
4777
6494
|
|
|
4778
6495
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Fields/styles.module.css#css-module
|
|
4779
6496
|
init_react_import();
|
|
4780
|
-
var
|
|
6497
|
+
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" };
|
|
4781
6498
|
|
|
4782
6499
|
// components/Puck/components/Fields/index.tsx
|
|
4783
|
-
import { memo as
|
|
6500
|
+
import { memo as memo3, useCallback as useCallback12, useMemo as useMemo11 } from "react";
|
|
4784
6501
|
import { useShallow as useShallow5 } from "zustand/react/shallow";
|
|
4785
|
-
import { Fragment as Fragment8, jsx as
|
|
4786
|
-
var
|
|
6502
|
+
import { Fragment as Fragment8, jsx as jsx29, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
6503
|
+
var getClassName21 = get_class_name_factory_default("PuckFields", styles_module_default16);
|
|
4787
6504
|
var DefaultFields = ({
|
|
4788
6505
|
children
|
|
4789
6506
|
}) => {
|
|
4790
|
-
return /* @__PURE__ */
|
|
6507
|
+
return /* @__PURE__ */ jsx29(Fragment8, { children });
|
|
4791
6508
|
};
|
|
4792
6509
|
var createOnChange = (fieldName, appStore) => (value, updatedUi) => __async(void 0, null, function* () {
|
|
4793
6510
|
let currentProps;
|
|
4794
|
-
const { dispatch, state, selectedItem, resolveComponentData } = appStore.getState();
|
|
6511
|
+
const { dispatch, state, selectedItem, resolveComponentData: resolveComponentData2 } = appStore.getState();
|
|
4795
6512
|
const { data, ui } = state;
|
|
4796
6513
|
const { itemSelector } = ui;
|
|
4797
6514
|
const rootProps = data.root.props || data.root;
|
|
@@ -4808,7 +6525,7 @@ var createOnChange = (fieldName, appStore) => (value, updatedUi) => __async(void
|
|
|
4808
6525
|
type: "replace",
|
|
4809
6526
|
destinationIndex: itemSelector.index,
|
|
4810
6527
|
destinationZone: itemSelector.zone || rootDroppableId,
|
|
4811
|
-
data: (yield
|
|
6528
|
+
data: (yield resolveComponentData2(
|
|
4812
6529
|
__spreadProps(__spreadValues({}, selectedItem), { props: newProps }),
|
|
4813
6530
|
"replace"
|
|
4814
6531
|
)).node,
|
|
@@ -4818,7 +6535,7 @@ var createOnChange = (fieldName, appStore) => (value, updatedUi) => __async(void
|
|
|
4818
6535
|
if (data.root.props) {
|
|
4819
6536
|
dispatch({
|
|
4820
6537
|
type: "replaceRoot",
|
|
4821
|
-
root: (yield
|
|
6538
|
+
root: (yield resolveComponentData2(
|
|
4822
6539
|
__spreadProps(__spreadValues({}, data.root), { props: newProps }),
|
|
4823
6540
|
"replace"
|
|
4824
6541
|
)).node,
|
|
@@ -4853,13 +6570,13 @@ var FieldsChild = ({ fieldName }) => {
|
|
|
4853
6570
|
})
|
|
4854
6571
|
);
|
|
4855
6572
|
const appStore = useAppStoreApi();
|
|
4856
|
-
const onChange =
|
|
6573
|
+
const onChange = useCallback12(createOnChange(fieldName, appStore), [
|
|
4857
6574
|
fieldName
|
|
4858
6575
|
]);
|
|
4859
6576
|
const { visible = true } = field != null ? field : {};
|
|
4860
6577
|
if (!field || !id || !visible) return null;
|
|
4861
6578
|
if (field.type === "slot") return null;
|
|
4862
|
-
return /* @__PURE__ */
|
|
6579
|
+
return /* @__PURE__ */ jsx29("div", { className: getClassName21("field"), children: /* @__PURE__ */ jsx29(
|
|
4863
6580
|
AutoFieldPrivate,
|
|
4864
6581
|
{
|
|
4865
6582
|
field,
|
|
@@ -4871,7 +6588,7 @@ var FieldsChild = ({ fieldName }) => {
|
|
|
4871
6588
|
}
|
|
4872
6589
|
) }, id);
|
|
4873
6590
|
};
|
|
4874
|
-
var FieldsChildMemo =
|
|
6591
|
+
var FieldsChildMemo = memo3(FieldsChild);
|
|
4875
6592
|
var FieldsInternal = ({ wrapFields = true }) => {
|
|
4876
6593
|
const overrides = useAppStore((s) => s.overrides);
|
|
4877
6594
|
const componentResolving = useAppStore((s) => {
|
|
@@ -4900,37 +6617,37 @@ var FieldsInternal = ({ wrapFields = true }) => {
|
|
|
4900
6617
|
return /* @__PURE__ */ jsxs13(
|
|
4901
6618
|
"form",
|
|
4902
6619
|
{
|
|
4903
|
-
className:
|
|
6620
|
+
className: getClassName21({ wrapFields }),
|
|
4904
6621
|
onSubmit: (e) => {
|
|
4905
6622
|
e.preventDefault();
|
|
4906
6623
|
},
|
|
4907
6624
|
children: [
|
|
4908
|
-
/* @__PURE__ */
|
|
4909
|
-
isLoading && /* @__PURE__ */
|
|
6625
|
+
/* @__PURE__ */ jsx29(Wrapper, { isLoading, itemSelector, children: fieldNames.map((fieldName) => /* @__PURE__ */ jsx29(FieldsChildMemo, { fieldName }, fieldName)) }),
|
|
6626
|
+
isLoading && /* @__PURE__ */ jsx29("div", { className: getClassName21("loadingOverlay"), children: /* @__PURE__ */ jsx29("div", { className: getClassName21("loadingOverlayInner"), children: /* @__PURE__ */ jsx29(Loader, { size: 16 }) }) })
|
|
4910
6627
|
]
|
|
4911
6628
|
}
|
|
4912
6629
|
);
|
|
4913
6630
|
};
|
|
4914
|
-
var Fields =
|
|
6631
|
+
var Fields = memo3(FieldsInternal);
|
|
4915
6632
|
|
|
4916
6633
|
// components/Puck/components/Components/index.tsx
|
|
4917
6634
|
init_react_import();
|
|
4918
6635
|
|
|
4919
6636
|
// lib/use-component-list.tsx
|
|
4920
6637
|
init_react_import();
|
|
4921
|
-
import { useEffect as
|
|
6638
|
+
import { useEffect as useEffect21, useState as useState18 } from "react";
|
|
4922
6639
|
|
|
4923
6640
|
// components/ComponentList/index.tsx
|
|
4924
6641
|
init_react_import();
|
|
4925
6642
|
|
|
4926
6643
|
// css-module:/home/runner/work/puck/puck/packages/core/components/ComponentList/styles.module.css#css-module
|
|
4927
6644
|
init_react_import();
|
|
4928
|
-
var
|
|
6645
|
+
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" };
|
|
4929
6646
|
|
|
4930
6647
|
// components/ComponentList/index.tsx
|
|
4931
|
-
import { useEffect as
|
|
4932
|
-
import { jsx as
|
|
4933
|
-
var
|
|
6648
|
+
import { useEffect as useEffect20 } from "react";
|
|
6649
|
+
import { jsx as jsx30, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
6650
|
+
var getClassName22 = get_class_name_factory_default("ComponentList", styles_module_default17);
|
|
4934
6651
|
var ComponentListItem = ({
|
|
4935
6652
|
name,
|
|
4936
6653
|
label
|
|
@@ -4942,14 +6659,14 @@ var ComponentListItem = ({
|
|
|
4942
6659
|
type: name
|
|
4943
6660
|
}).insert
|
|
4944
6661
|
);
|
|
4945
|
-
|
|
6662
|
+
useEffect20(() => {
|
|
4946
6663
|
if (overrides.componentItem) {
|
|
4947
6664
|
console.warn(
|
|
4948
6665
|
"The `componentItem` override has been deprecated and renamed to `drawerItem`"
|
|
4949
6666
|
);
|
|
4950
6667
|
}
|
|
4951
6668
|
}, [overrides]);
|
|
4952
|
-
return /* @__PURE__ */
|
|
6669
|
+
return /* @__PURE__ */ jsx30(Drawer.Item, { label, name, isDragDisabled: !canInsert, children: (_a = overrides.componentItem) != null ? _a : overrides.drawerItem });
|
|
4953
6670
|
};
|
|
4954
6671
|
var ComponentList = ({
|
|
4955
6672
|
children,
|
|
@@ -4960,12 +6677,12 @@ var ComponentList = ({
|
|
|
4960
6677
|
const setUi = useAppStore((s) => s.setUi);
|
|
4961
6678
|
const componentList = useAppStore((s) => s.state.ui.componentList);
|
|
4962
6679
|
const { expanded = true } = componentList[id] || {};
|
|
4963
|
-
return /* @__PURE__ */ jsxs14("div", { className:
|
|
6680
|
+
return /* @__PURE__ */ jsxs14("div", { className: getClassName22({ isExpanded: expanded }), children: [
|
|
4964
6681
|
title && /* @__PURE__ */ jsxs14(
|
|
4965
6682
|
"button",
|
|
4966
6683
|
{
|
|
4967
6684
|
type: "button",
|
|
4968
|
-
className:
|
|
6685
|
+
className: getClassName22("title"),
|
|
4969
6686
|
onClick: () => setUi({
|
|
4970
6687
|
componentList: __spreadProps(__spreadValues({}, componentList), {
|
|
4971
6688
|
[id]: __spreadProps(__spreadValues({}, componentList[id]), {
|
|
@@ -4975,14 +6692,14 @@ var ComponentList = ({
|
|
|
4975
6692
|
}),
|
|
4976
6693
|
title: expanded ? `Collapse${title ? ` ${title}` : ""}` : `Expand${title ? ` ${title}` : ""}`,
|
|
4977
6694
|
children: [
|
|
4978
|
-
/* @__PURE__ */
|
|
4979
|
-
/* @__PURE__ */
|
|
6695
|
+
/* @__PURE__ */ jsx30("div", { children: title }),
|
|
6696
|
+
/* @__PURE__ */ jsx30("div", { className: getClassName22("titleIcon"), children: expanded ? /* @__PURE__ */ jsx30(ChevronUp, { size: 12 }) : /* @__PURE__ */ jsx30(ChevronDown, { size: 12 }) })
|
|
4980
6697
|
]
|
|
4981
6698
|
}
|
|
4982
6699
|
),
|
|
4983
|
-
/* @__PURE__ */
|
|
6700
|
+
/* @__PURE__ */ jsx30("div", { className: getClassName22("content"), children: /* @__PURE__ */ jsx30(Drawer, { children: children || Object.keys(config.components).map((componentKey) => {
|
|
4984
6701
|
var _a;
|
|
4985
|
-
return /* @__PURE__ */
|
|
6702
|
+
return /* @__PURE__ */ jsx30(
|
|
4986
6703
|
ComponentListItem,
|
|
4987
6704
|
{
|
|
4988
6705
|
label: (_a = config.components[componentKey]["label"]) != null ? _a : componentKey,
|
|
@@ -4996,12 +6713,12 @@ var ComponentList = ({
|
|
|
4996
6713
|
ComponentList.Item = ComponentListItem;
|
|
4997
6714
|
|
|
4998
6715
|
// lib/use-component-list.tsx
|
|
4999
|
-
import { jsx as
|
|
6716
|
+
import { jsx as jsx31 } from "react/jsx-runtime";
|
|
5000
6717
|
var useComponentList = () => {
|
|
5001
|
-
const [componentList, setComponentList] =
|
|
6718
|
+
const [componentList, setComponentList] = useState18();
|
|
5002
6719
|
const config = useAppStore((s) => s.config);
|
|
5003
6720
|
const uiComponentList = useAppStore((s) => s.state.ui.componentList);
|
|
5004
|
-
|
|
6721
|
+
useEffect21(() => {
|
|
5005
6722
|
var _a, _b, _c;
|
|
5006
6723
|
if (Object.keys(uiComponentList).length > 0) {
|
|
5007
6724
|
const matchedComponents = [];
|
|
@@ -5011,7 +6728,7 @@ var useComponentList = () => {
|
|
|
5011
6728
|
if (category.visible === false || !category.components) {
|
|
5012
6729
|
return null;
|
|
5013
6730
|
}
|
|
5014
|
-
return /* @__PURE__ */
|
|
6731
|
+
return /* @__PURE__ */ jsx31(
|
|
5015
6732
|
ComponentList,
|
|
5016
6733
|
{
|
|
5017
6734
|
id: categoryKey,
|
|
@@ -5020,7 +6737,7 @@ var useComponentList = () => {
|
|
|
5020
6737
|
var _a2;
|
|
5021
6738
|
matchedComponents.push(componentName);
|
|
5022
6739
|
const componentConf = config.components[componentName] || {};
|
|
5023
|
-
return /* @__PURE__ */
|
|
6740
|
+
return /* @__PURE__ */ jsx31(
|
|
5024
6741
|
ComponentList.Item,
|
|
5025
6742
|
{
|
|
5026
6743
|
label: (_a2 = componentConf["label"]) != null ? _a2 : componentName,
|
|
@@ -5040,7 +6757,7 @@ var useComponentList = () => {
|
|
|
5040
6757
|
);
|
|
5041
6758
|
if (remainingComponents.length > 0 && !((_a = uiComponentList.other) == null ? void 0 : _a.components) && ((_b = uiComponentList.other) == null ? void 0 : _b.visible) !== false) {
|
|
5042
6759
|
_componentList.push(
|
|
5043
|
-
/* @__PURE__ */
|
|
6760
|
+
/* @__PURE__ */ jsx31(
|
|
5044
6761
|
ComponentList,
|
|
5045
6762
|
{
|
|
5046
6763
|
id: "other",
|
|
@@ -5048,7 +6765,7 @@ var useComponentList = () => {
|
|
|
5048
6765
|
children: remainingComponents.map((componentName, i) => {
|
|
5049
6766
|
var _a2;
|
|
5050
6767
|
const componentConf = config.components[componentName] || {};
|
|
5051
|
-
return /* @__PURE__ */
|
|
6768
|
+
return /* @__PURE__ */ jsx31(
|
|
5052
6769
|
ComponentList.Item,
|
|
5053
6770
|
{
|
|
5054
6771
|
name: componentName,
|
|
@@ -5071,7 +6788,7 @@ var useComponentList = () => {
|
|
|
5071
6788
|
|
|
5072
6789
|
// components/Puck/components/Components/index.tsx
|
|
5073
6790
|
import { useMemo as useMemo12 } from "react";
|
|
5074
|
-
import { jsx as
|
|
6791
|
+
import { jsx as jsx32 } from "react/jsx-runtime";
|
|
5075
6792
|
var Components = () => {
|
|
5076
6793
|
const overrides = useAppStore((s) => s.overrides);
|
|
5077
6794
|
const componentList = useComponentList();
|
|
@@ -5083,24 +6800,24 @@ var Components = () => {
|
|
|
5083
6800
|
}
|
|
5084
6801
|
return overrides.components || overrides.drawer || "div";
|
|
5085
6802
|
}, [overrides]);
|
|
5086
|
-
return /* @__PURE__ */
|
|
6803
|
+
return /* @__PURE__ */ jsx32(Wrapper, { children: componentList ? componentList : /* @__PURE__ */ jsx32(ComponentList, { id: "all" }) });
|
|
5087
6804
|
};
|
|
5088
6805
|
|
|
5089
6806
|
// components/Puck/components/Preview/index.tsx
|
|
5090
6807
|
init_react_import();
|
|
5091
|
-
import { useCallback as
|
|
6808
|
+
import { useCallback as useCallback13, useEffect as useEffect23, useRef as useRef7, useMemo as useMemo13 } from "react";
|
|
5092
6809
|
|
|
5093
6810
|
// components/AutoFrame/index.tsx
|
|
5094
6811
|
init_react_import();
|
|
5095
6812
|
import {
|
|
5096
|
-
createContext as
|
|
5097
|
-
useContext as
|
|
5098
|
-
useEffect as
|
|
5099
|
-
useState as
|
|
6813
|
+
createContext as createContext6,
|
|
6814
|
+
useContext as useContext10,
|
|
6815
|
+
useEffect as useEffect22,
|
|
6816
|
+
useState as useState19
|
|
5100
6817
|
} from "react";
|
|
5101
6818
|
import hash from "object-hash";
|
|
5102
6819
|
import { createPortal as createPortal3 } from "react-dom";
|
|
5103
|
-
import { Fragment as Fragment9, jsx as
|
|
6820
|
+
import { Fragment as Fragment9, jsx as jsx33 } from "react/jsx-runtime";
|
|
5104
6821
|
var styleSelector = 'style, link[rel="stylesheet"]';
|
|
5105
6822
|
var collectStyles = (doc) => {
|
|
5106
6823
|
const collected = [];
|
|
@@ -5150,7 +6867,7 @@ var CopyHostStyles = ({
|
|
|
5150
6867
|
onStylesLoaded = () => null
|
|
5151
6868
|
}) => {
|
|
5152
6869
|
const { document: doc, window: win } = useFrame();
|
|
5153
|
-
|
|
6870
|
+
useEffect22(() => {
|
|
5154
6871
|
if (!win || !doc) {
|
|
5155
6872
|
return () => {
|
|
5156
6873
|
};
|
|
@@ -5307,10 +7024,10 @@ var CopyHostStyles = ({
|
|
|
5307
7024
|
observer.disconnect();
|
|
5308
7025
|
};
|
|
5309
7026
|
}, []);
|
|
5310
|
-
return /* @__PURE__ */
|
|
7027
|
+
return /* @__PURE__ */ jsx33(Fragment9, { children });
|
|
5311
7028
|
};
|
|
5312
|
-
var autoFrameContext =
|
|
5313
|
-
var useFrame = () =>
|
|
7029
|
+
var autoFrameContext = createContext6({});
|
|
7030
|
+
var useFrame = () => useContext10(autoFrameContext);
|
|
5314
7031
|
function AutoFrame(_a) {
|
|
5315
7032
|
var _b = _a, {
|
|
5316
7033
|
children,
|
|
@@ -5331,11 +7048,11 @@ function AutoFrame(_a) {
|
|
|
5331
7048
|
"onNotReady",
|
|
5332
7049
|
"frameRef"
|
|
5333
7050
|
]);
|
|
5334
|
-
const [loaded, setLoaded] =
|
|
5335
|
-
const [ctx, setCtx] =
|
|
5336
|
-
const [mountTarget, setMountTarget] =
|
|
5337
|
-
const [stylesLoaded, setStylesLoaded] =
|
|
5338
|
-
|
|
7051
|
+
const [loaded, setLoaded] = useState19(false);
|
|
7052
|
+
const [ctx, setCtx] = useState19({});
|
|
7053
|
+
const [mountTarget, setMountTarget] = useState19();
|
|
7054
|
+
const [stylesLoaded, setStylesLoaded] = useState19(false);
|
|
7055
|
+
useEffect22(() => {
|
|
5339
7056
|
var _a2;
|
|
5340
7057
|
if (frameRef.current) {
|
|
5341
7058
|
const doc = frameRef.current.contentDocument;
|
|
@@ -5354,7 +7071,7 @@ function AutoFrame(_a) {
|
|
|
5354
7071
|
}
|
|
5355
7072
|
}
|
|
5356
7073
|
}, [frameRef, loaded, stylesLoaded]);
|
|
5357
|
-
return /* @__PURE__ */
|
|
7074
|
+
return /* @__PURE__ */ jsx33(
|
|
5358
7075
|
"iframe",
|
|
5359
7076
|
__spreadProps(__spreadValues({}, props), {
|
|
5360
7077
|
className,
|
|
@@ -5364,7 +7081,7 @@ function AutoFrame(_a) {
|
|
|
5364
7081
|
onLoad: () => {
|
|
5365
7082
|
setLoaded(true);
|
|
5366
7083
|
},
|
|
5367
|
-
children: /* @__PURE__ */
|
|
7084
|
+
children: /* @__PURE__ */ jsx33(autoFrameContext.Provider, { value: ctx, children: loaded && mountTarget && /* @__PURE__ */ jsx33(
|
|
5368
7085
|
CopyHostStyles,
|
|
5369
7086
|
{
|
|
5370
7087
|
debug,
|
|
@@ -5380,14 +7097,14 @@ var AutoFrame_default = AutoFrame;
|
|
|
5380
7097
|
|
|
5381
7098
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Preview/styles.module.css#css-module
|
|
5382
7099
|
init_react_import();
|
|
5383
|
-
var
|
|
7100
|
+
var styles_module_default18 = { "PuckPreview": "_PuckPreview_z2rgu_1", "PuckPreview-frame": "_PuckPreview-frame_z2rgu_6" };
|
|
5384
7101
|
|
|
5385
7102
|
// components/Puck/components/Preview/index.tsx
|
|
5386
|
-
import { Fragment as Fragment10, jsx as
|
|
5387
|
-
var
|
|
7103
|
+
import { Fragment as Fragment10, jsx as jsx34 } from "react/jsx-runtime";
|
|
7104
|
+
var getClassName23 = get_class_name_factory_default("PuckPreview", styles_module_default18);
|
|
5388
7105
|
var useBubbleIframeEvents = (ref) => {
|
|
5389
7106
|
const status = useAppStore((s) => s.status);
|
|
5390
|
-
|
|
7107
|
+
useEffect23(() => {
|
|
5391
7108
|
if (ref.current && status === "READY") {
|
|
5392
7109
|
const iframe = ref.current;
|
|
5393
7110
|
const handlePointerMove = (event) => {
|
|
@@ -5436,7 +7153,7 @@ var Preview2 = ({ id = "puck-preview" }) => {
|
|
|
5436
7153
|
const renderData = useAppStore(
|
|
5437
7154
|
(s) => s.state.ui.previewMode === "edit" ? null : s.state.data
|
|
5438
7155
|
);
|
|
5439
|
-
const Page =
|
|
7156
|
+
const Page = useCallback13(
|
|
5440
7157
|
(pageProps) => {
|
|
5441
7158
|
var _a, _b;
|
|
5442
7159
|
const propsWithSlots = useSlots(
|
|
@@ -5446,15 +7163,15 @@ var Preview2 = ({ id = "puck-preview" }) => {
|
|
|
5446
7163
|
);
|
|
5447
7164
|
return ((_a = config.root) == null ? void 0 : _a.render) ? (_b = config.root) == null ? void 0 : _b.render(__spreadValues({
|
|
5448
7165
|
id: "puck-root"
|
|
5449
|
-
}, propsWithSlots)) : /* @__PURE__ */
|
|
7166
|
+
}, propsWithSlots)) : /* @__PURE__ */ jsx34(Fragment10, { children: propsWithSlots.children });
|
|
5450
7167
|
},
|
|
5451
7168
|
[config]
|
|
5452
7169
|
);
|
|
5453
7170
|
const Frame = useMemo13(() => overrides.iframe, [overrides]);
|
|
5454
7171
|
const rootProps = root.props || root;
|
|
5455
|
-
const ref =
|
|
7172
|
+
const ref = useRef7(null);
|
|
5456
7173
|
useBubbleIframeEvents(ref);
|
|
5457
|
-
const inner = !renderData ? /* @__PURE__ */
|
|
7174
|
+
const inner = !renderData ? /* @__PURE__ */ jsx34(
|
|
5458
7175
|
Page,
|
|
5459
7176
|
__spreadProps(__spreadValues({}, rootProps), {
|
|
5460
7177
|
puck: {
|
|
@@ -5464,18 +7181,18 @@ var Preview2 = ({ id = "puck-preview" }) => {
|
|
|
5464
7181
|
metadata
|
|
5465
7182
|
},
|
|
5466
7183
|
editMode: true,
|
|
5467
|
-
children: /* @__PURE__ */
|
|
7184
|
+
children: /* @__PURE__ */ jsx34(DropZonePure, { zone: rootDroppableId })
|
|
5468
7185
|
})
|
|
5469
|
-
) : /* @__PURE__ */
|
|
5470
|
-
|
|
7186
|
+
) : /* @__PURE__ */ jsx34(Render, { data: renderData, config, metadata });
|
|
7187
|
+
useEffect23(() => {
|
|
5471
7188
|
if (!iframe.enabled) {
|
|
5472
7189
|
setStatus("READY");
|
|
5473
7190
|
}
|
|
5474
7191
|
}, [iframe.enabled]);
|
|
5475
|
-
return /* @__PURE__ */
|
|
7192
|
+
return /* @__PURE__ */ jsx34(
|
|
5476
7193
|
"div",
|
|
5477
7194
|
{
|
|
5478
|
-
className:
|
|
7195
|
+
className: getClassName23(),
|
|
5479
7196
|
id,
|
|
5480
7197
|
"data-puck-preview": true,
|
|
5481
7198
|
onClick: (e) => {
|
|
@@ -5484,11 +7201,11 @@ var Preview2 = ({ id = "puck-preview" }) => {
|
|
|
5484
7201
|
dispatch({ type: "setUi", ui: { itemSelector: null } });
|
|
5485
7202
|
}
|
|
5486
7203
|
},
|
|
5487
|
-
children: iframe.enabled ? /* @__PURE__ */
|
|
7204
|
+
children: iframe.enabled ? /* @__PURE__ */ jsx34(
|
|
5488
7205
|
AutoFrame_default,
|
|
5489
7206
|
{
|
|
5490
7207
|
id: "preview-frame",
|
|
5491
|
-
className:
|
|
7208
|
+
className: getClassName23("frame"),
|
|
5492
7209
|
"data-rfd-iframe": true,
|
|
5493
7210
|
onReady: () => {
|
|
5494
7211
|
setStatus("READY");
|
|
@@ -5497,18 +7214,18 @@ var Preview2 = ({ id = "puck-preview" }) => {
|
|
|
5497
7214
|
setStatus("MOUNTED");
|
|
5498
7215
|
},
|
|
5499
7216
|
frameRef: ref,
|
|
5500
|
-
children: /* @__PURE__ */
|
|
7217
|
+
children: /* @__PURE__ */ jsx34(autoFrameContext.Consumer, { children: ({ document: document2 }) => {
|
|
5501
7218
|
if (Frame) {
|
|
5502
|
-
return /* @__PURE__ */
|
|
7219
|
+
return /* @__PURE__ */ jsx34(Frame, { document: document2, children: inner });
|
|
5503
7220
|
}
|
|
5504
7221
|
return inner;
|
|
5505
7222
|
} })
|
|
5506
7223
|
}
|
|
5507
|
-
) : /* @__PURE__ */
|
|
7224
|
+
) : /* @__PURE__ */ jsx34(
|
|
5508
7225
|
"div",
|
|
5509
7226
|
{
|
|
5510
7227
|
id: "preview-frame",
|
|
5511
|
-
className:
|
|
7228
|
+
className: getClassName23("frame"),
|
|
5512
7229
|
ref,
|
|
5513
7230
|
"data-puck-entry": true,
|
|
5514
7231
|
children: inner
|
|
@@ -5526,7 +7243,7 @@ init_react_import();
|
|
|
5526
7243
|
|
|
5527
7244
|
// css-module:/home/runner/work/puck/puck/packages/core/components/LayerTree/styles.module.css#css-module
|
|
5528
7245
|
init_react_import();
|
|
5529
|
-
var
|
|
7246
|
+
var styles_module_default19 = { "LayerTree": "_LayerTree_7rx04_1", "LayerTree-zoneTitle": "_LayerTree-zoneTitle_7rx04_11", "LayerTree-helper": "_LayerTree-helper_7rx04_17", "Layer": "_Layer_7rx04_1", "Layer-inner": "_Layer-inner_7rx04_29", "Layer--containsZone": "_Layer--containsZone_7rx04_35", "Layer-clickable": "_Layer-clickable_7rx04_39", "Layer--isSelected": "_Layer--isSelected_7rx04_61", "Layer-chevron": "_Layer-chevron_7rx04_77", "Layer--childIsSelected": "_Layer--childIsSelected_7rx04_78", "Layer-zones": "_Layer-zones_7rx04_82", "Layer-title": "_Layer-title_7rx04_96", "Layer-name": "_Layer-name_7rx04_105", "Layer-icon": "_Layer-icon_7rx04_111", "Layer-zoneIcon": "_Layer-zoneIcon_7rx04_116" };
|
|
5530
7247
|
|
|
5531
7248
|
// lib/scroll-into-view.ts
|
|
5532
7249
|
init_react_import();
|
|
@@ -5540,7 +7257,7 @@ var scrollIntoView = (el) => {
|
|
|
5540
7257
|
};
|
|
5541
7258
|
|
|
5542
7259
|
// components/LayerTree/index.tsx
|
|
5543
|
-
import { useCallback as
|
|
7260
|
+
import { useCallback as useCallback14, useContext as useContext11 } from "react";
|
|
5544
7261
|
|
|
5545
7262
|
// lib/on-scroll-end.ts
|
|
5546
7263
|
init_react_import();
|
|
@@ -5563,9 +7280,9 @@ var onScrollEnd = (frame, cb) => {
|
|
|
5563
7280
|
|
|
5564
7281
|
// components/LayerTree/index.tsx
|
|
5565
7282
|
import { useShallow as useShallow6 } from "zustand/react/shallow";
|
|
5566
|
-
import { Fragment as Fragment11, jsx as
|
|
5567
|
-
var
|
|
5568
|
-
var getClassNameLayer = get_class_name_factory_default("Layer",
|
|
7283
|
+
import { Fragment as Fragment11, jsx as jsx35, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
7284
|
+
var getClassName24 = get_class_name_factory_default("LayerTree", styles_module_default19);
|
|
7285
|
+
var getClassNameLayer = get_class_name_factory_default("Layer", styles_module_default19);
|
|
5569
7286
|
var Layer = ({
|
|
5570
7287
|
index,
|
|
5571
7288
|
itemId,
|
|
@@ -5575,7 +7292,7 @@ var Layer = ({
|
|
|
5575
7292
|
const config = useAppStore((s) => s.config);
|
|
5576
7293
|
const itemSelector = useAppStore((s) => s.state.ui.itemSelector);
|
|
5577
7294
|
const dispatch = useAppStore((s) => s.dispatch);
|
|
5578
|
-
const setItemSelector =
|
|
7295
|
+
const setItemSelector = useCallback14(
|
|
5579
7296
|
(itemSelector2) => {
|
|
5580
7297
|
dispatch({ type: "setUi", ui: { itemSelector: itemSelector2 } });
|
|
5581
7298
|
},
|
|
@@ -5595,7 +7312,7 @@ var Layer = ({
|
|
|
5595
7312
|
)
|
|
5596
7313
|
);
|
|
5597
7314
|
const containsZone = zonesForItem.length > 0;
|
|
5598
|
-
const zoneStore =
|
|
7315
|
+
const zoneStore = useContext11(ZoneStoreContext);
|
|
5599
7316
|
const isHovering = useContextStore(
|
|
5600
7317
|
ZoneStoreContext,
|
|
5601
7318
|
(s) => s.hoveringComponent === itemId
|
|
@@ -5620,7 +7337,7 @@ var Layer = ({
|
|
|
5620
7337
|
childIsSelected
|
|
5621
7338
|
}),
|
|
5622
7339
|
children: [
|
|
5623
|
-
/* @__PURE__ */
|
|
7340
|
+
/* @__PURE__ */ jsx35("div", { className: getClassNameLayer("inner"), children: /* @__PURE__ */ jsxs15(
|
|
5624
7341
|
"button",
|
|
5625
7342
|
{
|
|
5626
7343
|
type: "button",
|
|
@@ -5658,22 +7375,22 @@ var Layer = ({
|
|
|
5658
7375
|
zoneStore.setState({ hoveringComponent: null });
|
|
5659
7376
|
},
|
|
5660
7377
|
children: [
|
|
5661
|
-
containsZone && /* @__PURE__ */
|
|
7378
|
+
containsZone && /* @__PURE__ */ jsx35(
|
|
5662
7379
|
"div",
|
|
5663
7380
|
{
|
|
5664
7381
|
className: getClassNameLayer("chevron"),
|
|
5665
7382
|
title: isSelected ? "Collapse" : "Expand",
|
|
5666
|
-
children: /* @__PURE__ */
|
|
7383
|
+
children: /* @__PURE__ */ jsx35(ChevronDown, { size: "12" })
|
|
5667
7384
|
}
|
|
5668
7385
|
),
|
|
5669
7386
|
/* @__PURE__ */ jsxs15("div", { className: getClassNameLayer("title"), children: [
|
|
5670
|
-
/* @__PURE__ */
|
|
5671
|
-
/* @__PURE__ */
|
|
7387
|
+
/* @__PURE__ */ jsx35("div", { className: getClassNameLayer("icon"), children: nodeData.data.type === "Text" || nodeData.data.type === "Heading" ? /* @__PURE__ */ jsx35(Type, { size: "16" }) : /* @__PURE__ */ jsx35(LayoutGrid, { size: "16" }) }),
|
|
7388
|
+
/* @__PURE__ */ jsx35("div", { className: getClassNameLayer("name"), children: label })
|
|
5672
7389
|
] })
|
|
5673
7390
|
]
|
|
5674
7391
|
}
|
|
5675
7392
|
) }),
|
|
5676
|
-
containsZone && zonesForItem.map((subzone) => /* @__PURE__ */
|
|
7393
|
+
containsZone && zonesForItem.map((subzone) => /* @__PURE__ */ jsx35("div", { className: getClassNameLayer("zones"), children: /* @__PURE__ */ jsx35(LayerTree, { zoneCompound: subzone }) }, subzone))
|
|
5677
7394
|
]
|
|
5678
7395
|
}
|
|
5679
7396
|
);
|
|
@@ -5700,14 +7417,14 @@ var LayerTree = ({
|
|
|
5700
7417
|
)
|
|
5701
7418
|
);
|
|
5702
7419
|
return /* @__PURE__ */ jsxs15(Fragment11, { children: [
|
|
5703
|
-
label && /* @__PURE__ */ jsxs15("div", { className:
|
|
5704
|
-
/* @__PURE__ */
|
|
7420
|
+
label && /* @__PURE__ */ jsxs15("div", { className: getClassName24("zoneTitle"), children: [
|
|
7421
|
+
/* @__PURE__ */ jsx35("div", { className: getClassName24("zoneIcon"), children: /* @__PURE__ */ jsx35(Layers, { size: "16" }) }),
|
|
5705
7422
|
label
|
|
5706
7423
|
] }),
|
|
5707
|
-
/* @__PURE__ */ jsxs15("ul", { className:
|
|
5708
|
-
contentIds.length === 0 && /* @__PURE__ */
|
|
7424
|
+
/* @__PURE__ */ jsxs15("ul", { className: getClassName24(), children: [
|
|
7425
|
+
contentIds.length === 0 && /* @__PURE__ */ jsx35("div", { className: getClassName24("helper"), children: "No items" }),
|
|
5709
7426
|
contentIds.map((itemId, i) => {
|
|
5710
|
-
return /* @__PURE__ */
|
|
7427
|
+
return /* @__PURE__ */ jsx35(
|
|
5711
7428
|
Layer,
|
|
5712
7429
|
{
|
|
5713
7430
|
index: i,
|
|
@@ -5734,14 +7451,14 @@ var findZonesForArea = (state, area) => {
|
|
|
5734
7451
|
|
|
5735
7452
|
// components/Puck/components/Outline/index.tsx
|
|
5736
7453
|
import { useShallow as useShallow7 } from "zustand/react/shallow";
|
|
5737
|
-
import { jsx as
|
|
7454
|
+
import { jsx as jsx36 } from "react/jsx-runtime";
|
|
5738
7455
|
var Outline = () => {
|
|
5739
7456
|
const outlineOverride = useAppStore((s) => s.overrides.outline);
|
|
5740
7457
|
const rootZones = useAppStore(
|
|
5741
7458
|
useShallow7((s) => findZonesForArea(s.state, "root"))
|
|
5742
7459
|
);
|
|
5743
7460
|
const Wrapper = useMemo14(() => outlineOverride || "div", [outlineOverride]);
|
|
5744
|
-
return /* @__PURE__ */
|
|
7461
|
+
return /* @__PURE__ */ jsx36(Wrapper, { children: rootZones.map((zoneCompound) => /* @__PURE__ */ jsx36(
|
|
5745
7462
|
LayerTree,
|
|
5746
7463
|
{
|
|
5747
7464
|
label: rootZones.length === 1 ? "" : zoneCompound.split(":")[1],
|
|
@@ -5754,30 +7471,30 @@ var Outline = () => {
|
|
|
5754
7471
|
// components/Puck/components/Canvas/index.tsx
|
|
5755
7472
|
init_react_import();
|
|
5756
7473
|
import {
|
|
5757
|
-
useCallback as
|
|
5758
|
-
useEffect as
|
|
7474
|
+
useCallback as useCallback15,
|
|
7475
|
+
useEffect as useEffect25,
|
|
5759
7476
|
useMemo as useMemo17,
|
|
5760
|
-
useRef as
|
|
5761
|
-
useState as
|
|
7477
|
+
useRef as useRef9,
|
|
7478
|
+
useState as useState21
|
|
5762
7479
|
} from "react";
|
|
5763
7480
|
|
|
5764
7481
|
// components/ViewportControls/index.tsx
|
|
5765
7482
|
init_react_import();
|
|
5766
|
-
import { useEffect as
|
|
7483
|
+
import { useEffect as useEffect24, useMemo as useMemo15, useState as useState20 } from "react";
|
|
5767
7484
|
|
|
5768
7485
|
// css-module:/home/runner/work/puck/puck/packages/core/components/ViewportControls/styles.module.css#css-module
|
|
5769
7486
|
init_react_import();
|
|
5770
|
-
var
|
|
7487
|
+
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" };
|
|
5771
7488
|
|
|
5772
7489
|
// components/ViewportControls/index.tsx
|
|
5773
|
-
import { jsx as
|
|
7490
|
+
import { jsx as jsx37, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
5774
7491
|
var icons = {
|
|
5775
|
-
Smartphone: /* @__PURE__ */
|
|
5776
|
-
Tablet: /* @__PURE__ */
|
|
5777
|
-
Monitor: /* @__PURE__ */
|
|
7492
|
+
Smartphone: /* @__PURE__ */ jsx37(Smartphone, { size: 16 }),
|
|
7493
|
+
Tablet: /* @__PURE__ */ jsx37(Tablet, { size: 16 }),
|
|
7494
|
+
Monitor: /* @__PURE__ */ jsx37(Monitor, { size: 16 })
|
|
5778
7495
|
};
|
|
5779
|
-
var
|
|
5780
|
-
var getClassNameButton = get_class_name_factory_default("ViewportButton",
|
|
7496
|
+
var getClassName25 = get_class_name_factory_default("ViewportControls", styles_module_default20);
|
|
7497
|
+
var getClassNameButton = get_class_name_factory_default("ViewportButton", styles_module_default20);
|
|
5781
7498
|
var ViewportButton = ({
|
|
5782
7499
|
children,
|
|
5783
7500
|
height = "auto",
|
|
@@ -5786,11 +7503,11 @@ var ViewportButton = ({
|
|
|
5786
7503
|
onClick
|
|
5787
7504
|
}) => {
|
|
5788
7505
|
const viewports = useAppStore((s) => s.state.ui.viewports);
|
|
5789
|
-
const [isActive, setIsActive] =
|
|
5790
|
-
|
|
7506
|
+
const [isActive, setIsActive] = useState20(false);
|
|
7507
|
+
useEffect24(() => {
|
|
5791
7508
|
setIsActive(width === viewports.current.width);
|
|
5792
7509
|
}, [width, viewports.current.width]);
|
|
5793
|
-
return /* @__PURE__ */
|
|
7510
|
+
return /* @__PURE__ */ jsx37("span", { className: getClassNameButton({ isActive }), children: /* @__PURE__ */ jsx37(
|
|
5794
7511
|
IconButton,
|
|
5795
7512
|
{
|
|
5796
7513
|
type: "button",
|
|
@@ -5800,7 +7517,7 @@ var ViewportButton = ({
|
|
|
5800
7517
|
e.stopPropagation();
|
|
5801
7518
|
onClick({ width, height });
|
|
5802
7519
|
},
|
|
5803
|
-
children: /* @__PURE__ */
|
|
7520
|
+
children: /* @__PURE__ */ jsx37("span", { className: getClassNameButton("inner"), children })
|
|
5804
7521
|
}
|
|
5805
7522
|
) });
|
|
5806
7523
|
};
|
|
@@ -5836,8 +7553,8 @@ var ViewportControls = ({
|
|
|
5836
7553
|
].filter((a) => a.value <= autoZoom).sort((a, b) => a.value > b.value ? 1 : -1),
|
|
5837
7554
|
[autoZoom]
|
|
5838
7555
|
);
|
|
5839
|
-
return /* @__PURE__ */ jsxs16("div", { className:
|
|
5840
|
-
viewports.map((viewport, i) => /* @__PURE__ */
|
|
7556
|
+
return /* @__PURE__ */ jsxs16("div", { className: getClassName25(), children: [
|
|
7557
|
+
viewports.map((viewport, i) => /* @__PURE__ */ jsx37(
|
|
5841
7558
|
ViewportButton,
|
|
5842
7559
|
{
|
|
5843
7560
|
height: viewport.height,
|
|
@@ -5848,8 +7565,8 @@ var ViewportControls = ({
|
|
|
5848
7565
|
},
|
|
5849
7566
|
i
|
|
5850
7567
|
)),
|
|
5851
|
-
/* @__PURE__ */
|
|
5852
|
-
/* @__PURE__ */
|
|
7568
|
+
/* @__PURE__ */ jsx37("div", { className: getClassName25("divider") }),
|
|
7569
|
+
/* @__PURE__ */ jsx37(
|
|
5853
7570
|
IconButton,
|
|
5854
7571
|
{
|
|
5855
7572
|
type: "button",
|
|
@@ -5864,10 +7581,10 @@ var ViewportControls = ({
|
|
|
5864
7581
|
)].value
|
|
5865
7582
|
);
|
|
5866
7583
|
},
|
|
5867
|
-
children: /* @__PURE__ */
|
|
7584
|
+
children: /* @__PURE__ */ jsx37(ZoomOut, { size: 16 })
|
|
5868
7585
|
}
|
|
5869
7586
|
),
|
|
5870
|
-
/* @__PURE__ */
|
|
7587
|
+
/* @__PURE__ */ jsx37(
|
|
5871
7588
|
IconButton,
|
|
5872
7589
|
{
|
|
5873
7590
|
type: "button",
|
|
@@ -5882,19 +7599,19 @@ var ViewportControls = ({
|
|
|
5882
7599
|
)].value
|
|
5883
7600
|
);
|
|
5884
7601
|
},
|
|
5885
|
-
children: /* @__PURE__ */
|
|
7602
|
+
children: /* @__PURE__ */ jsx37(ZoomIn, { size: 16 })
|
|
5886
7603
|
}
|
|
5887
7604
|
),
|
|
5888
|
-
/* @__PURE__ */
|
|
5889
|
-
/* @__PURE__ */
|
|
7605
|
+
/* @__PURE__ */ jsx37("div", { className: getClassName25("divider") }),
|
|
7606
|
+
/* @__PURE__ */ jsx37(
|
|
5890
7607
|
"select",
|
|
5891
7608
|
{
|
|
5892
|
-
className:
|
|
7609
|
+
className: getClassName25("zoomSelect"),
|
|
5893
7610
|
value: zoom.toString(),
|
|
5894
7611
|
onChange: (e) => {
|
|
5895
7612
|
onZoom(parseFloat(e.currentTarget.value));
|
|
5896
7613
|
},
|
|
5897
|
-
children: zoomOptions.map((option) => /* @__PURE__ */
|
|
7614
|
+
children: zoomOptions.map((option) => /* @__PURE__ */ jsx37(
|
|
5898
7615
|
"option",
|
|
5899
7616
|
{
|
|
5900
7617
|
value: option.value,
|
|
@@ -5909,7 +7626,7 @@ var ViewportControls = ({
|
|
|
5909
7626
|
|
|
5910
7627
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Canvas/styles.module.css#css-module
|
|
5911
7628
|
init_react_import();
|
|
5912
|
-
var
|
|
7629
|
+
var styles_module_default21 = { "PuckCanvas": "_PuckCanvas_18jay_1", "PuckCanvas-controls": "_PuckCanvas-controls_18jay_16", "PuckCanvas-inner": "_PuckCanvas-inner_18jay_21", "PuckCanvas-root": "_PuckCanvas-root_18jay_30", "PuckCanvas--ready": "_PuckCanvas--ready_18jay_55", "PuckCanvas-loader": "_PuckCanvas-loader_18jay_60", "PuckCanvas--showLoader": "_PuckCanvas--showLoader_18jay_70" };
|
|
5913
7630
|
|
|
5914
7631
|
// components/Puck/components/Canvas/index.tsx
|
|
5915
7632
|
import { useShallow as useShallow8 } from "zustand/react/shallow";
|
|
@@ -5917,27 +7634,27 @@ import { useShallow as useShallow8 } from "zustand/react/shallow";
|
|
|
5917
7634
|
// lib/frame-context.tsx
|
|
5918
7635
|
init_react_import();
|
|
5919
7636
|
import {
|
|
5920
|
-
createContext as
|
|
5921
|
-
useContext as
|
|
5922
|
-
useRef as
|
|
7637
|
+
createContext as createContext7,
|
|
7638
|
+
useContext as useContext12,
|
|
7639
|
+
useRef as useRef8,
|
|
5923
7640
|
useMemo as useMemo16
|
|
5924
7641
|
} from "react";
|
|
5925
|
-
import { jsx as
|
|
5926
|
-
var FrameContext =
|
|
7642
|
+
import { jsx as jsx38 } from "react/jsx-runtime";
|
|
7643
|
+
var FrameContext = createContext7(null);
|
|
5927
7644
|
var FrameProvider = ({
|
|
5928
7645
|
children
|
|
5929
7646
|
}) => {
|
|
5930
|
-
const frameRef =
|
|
7647
|
+
const frameRef = useRef8(null);
|
|
5931
7648
|
const value = useMemo16(
|
|
5932
7649
|
() => ({
|
|
5933
7650
|
frameRef
|
|
5934
7651
|
}),
|
|
5935
7652
|
[]
|
|
5936
7653
|
);
|
|
5937
|
-
return /* @__PURE__ */
|
|
7654
|
+
return /* @__PURE__ */ jsx38(FrameContext.Provider, { value, children });
|
|
5938
7655
|
};
|
|
5939
7656
|
var useCanvasFrame = () => {
|
|
5940
|
-
const context =
|
|
7657
|
+
const context = useContext12(FrameContext);
|
|
5941
7658
|
if (context === null) {
|
|
5942
7659
|
throw new Error("useCanvasFrame must be used within a FrameProvider");
|
|
5943
7660
|
}
|
|
@@ -5945,8 +7662,8 @@ var useCanvasFrame = () => {
|
|
|
5945
7662
|
};
|
|
5946
7663
|
|
|
5947
7664
|
// components/Puck/components/Canvas/index.tsx
|
|
5948
|
-
import { Fragment as Fragment12, jsx as
|
|
5949
|
-
var
|
|
7665
|
+
import { Fragment as Fragment12, jsx as jsx39, jsxs as jsxs17 } from "react/jsx-runtime";
|
|
7666
|
+
var getClassName26 = get_class_name_factory_default("PuckCanvas", styles_module_default21);
|
|
5950
7667
|
var ZOOM_ON_CHANGE = true;
|
|
5951
7668
|
var TRANSITION_DURATION = 150;
|
|
5952
7669
|
var Canvas = () => {
|
|
@@ -5986,17 +7703,17 @@ var Canvas = () => {
|
|
|
5986
7703
|
viewports: s.state.ui.viewports
|
|
5987
7704
|
}))
|
|
5988
7705
|
);
|
|
5989
|
-
const [showTransition, setShowTransition] =
|
|
5990
|
-
const isResizingRef =
|
|
7706
|
+
const [showTransition, setShowTransition] = useState21(false);
|
|
7707
|
+
const isResizingRef = useRef9(false);
|
|
5991
7708
|
const defaultRender = useMemo17(() => {
|
|
5992
|
-
const PuckDefault = ({ children }) => /* @__PURE__ */
|
|
7709
|
+
const PuckDefault = ({ children }) => /* @__PURE__ */ jsx39(Fragment12, { children });
|
|
5993
7710
|
return PuckDefault;
|
|
5994
7711
|
}, []);
|
|
5995
7712
|
const CustomPreview = useMemo17(
|
|
5996
7713
|
() => overrides.preview || defaultRender,
|
|
5997
7714
|
[overrides]
|
|
5998
7715
|
);
|
|
5999
|
-
const getFrameDimensions =
|
|
7716
|
+
const getFrameDimensions = useCallback15(() => {
|
|
6000
7717
|
if (frameRef.current) {
|
|
6001
7718
|
const frame = frameRef.current;
|
|
6002
7719
|
const box = getBox(frame);
|
|
@@ -6004,7 +7721,7 @@ var Canvas = () => {
|
|
|
6004
7721
|
}
|
|
6005
7722
|
return { width: 0, height: 0 };
|
|
6006
7723
|
}, [frameRef]);
|
|
6007
|
-
|
|
7724
|
+
useEffect25(() => {
|
|
6008
7725
|
resetAutoZoom();
|
|
6009
7726
|
}, [
|
|
6010
7727
|
frameRef,
|
|
@@ -6014,7 +7731,7 @@ var Canvas = () => {
|
|
|
6014
7731
|
rightSideBarWidth,
|
|
6015
7732
|
viewports
|
|
6016
7733
|
]);
|
|
6017
|
-
|
|
7734
|
+
useEffect25(() => {
|
|
6018
7735
|
const { height: frameHeight } = getFrameDimensions();
|
|
6019
7736
|
if (viewports.current.height === "auto") {
|
|
6020
7737
|
setZoomConfig(__spreadProps(__spreadValues({}, zoomConfig), {
|
|
@@ -6022,12 +7739,12 @@ var Canvas = () => {
|
|
|
6022
7739
|
}));
|
|
6023
7740
|
}
|
|
6024
7741
|
}, [zoomConfig.zoom, getFrameDimensions, setZoomConfig]);
|
|
6025
|
-
|
|
7742
|
+
useEffect25(() => {
|
|
6026
7743
|
if (ZOOM_ON_CHANGE) {
|
|
6027
7744
|
resetAutoZoom();
|
|
6028
7745
|
}
|
|
6029
7746
|
}, [viewports.current.width, viewports]);
|
|
6030
|
-
|
|
7747
|
+
useEffect25(() => {
|
|
6031
7748
|
if (!frameRef.current) return;
|
|
6032
7749
|
const resizeObserver = new ResizeObserver(() => {
|
|
6033
7750
|
if (!isResizingRef.current) {
|
|
@@ -6039,8 +7756,8 @@ var Canvas = () => {
|
|
|
6039
7756
|
resizeObserver.disconnect();
|
|
6040
7757
|
};
|
|
6041
7758
|
}, [frameRef.current]);
|
|
6042
|
-
const [showLoader, setShowLoader] =
|
|
6043
|
-
|
|
7759
|
+
const [showLoader, setShowLoader] = useState21(false);
|
|
7760
|
+
useEffect25(() => {
|
|
6044
7761
|
setTimeout(() => {
|
|
6045
7762
|
setShowLoader(true);
|
|
6046
7763
|
}, 500);
|
|
@@ -6048,7 +7765,7 @@ var Canvas = () => {
|
|
|
6048
7765
|
return /* @__PURE__ */ jsxs17(
|
|
6049
7766
|
"div",
|
|
6050
7767
|
{
|
|
6051
|
-
className:
|
|
7768
|
+
className: getClassName26({
|
|
6052
7769
|
ready: status === "READY" || !iframe.enabled || !iframe.waitForStyles,
|
|
6053
7770
|
showLoader
|
|
6054
7771
|
}),
|
|
@@ -6063,7 +7780,7 @@ var Canvas = () => {
|
|
|
6063
7780
|
}
|
|
6064
7781
|
},
|
|
6065
7782
|
children: [
|
|
6066
|
-
viewports.controlsVisible && iframe.enabled && /* @__PURE__ */
|
|
7783
|
+
viewports.controlsVisible && iframe.enabled && /* @__PURE__ */ jsx39("div", { className: getClassName26("controls"), children: /* @__PURE__ */ jsx39(
|
|
6067
7784
|
ViewportControls,
|
|
6068
7785
|
{
|
|
6069
7786
|
autoZoom: zoomConfig.autoZoom,
|
|
@@ -6093,11 +7810,11 @@ var Canvas = () => {
|
|
|
6093
7810
|
}
|
|
6094
7811
|
}
|
|
6095
7812
|
) }),
|
|
6096
|
-
/* @__PURE__ */ jsxs17("div", { className:
|
|
6097
|
-
/* @__PURE__ */
|
|
7813
|
+
/* @__PURE__ */ jsxs17("div", { className: getClassName26("inner"), ref: frameRef, children: [
|
|
7814
|
+
/* @__PURE__ */ jsx39(
|
|
6098
7815
|
"div",
|
|
6099
7816
|
{
|
|
6100
|
-
className:
|
|
7817
|
+
className: getClassName26("root"),
|
|
6101
7818
|
style: {
|
|
6102
7819
|
width: iframe.enabled ? viewports.current.width : "100%",
|
|
6103
7820
|
height: zoomConfig.rootHeight,
|
|
@@ -6111,10 +7828,10 @@ var Canvas = () => {
|
|
|
6111
7828
|
setShowTransition(false);
|
|
6112
7829
|
isResizingRef.current = false;
|
|
6113
7830
|
},
|
|
6114
|
-
children: /* @__PURE__ */
|
|
7831
|
+
children: /* @__PURE__ */ jsx39(CustomPreview, { children: /* @__PURE__ */ jsx39(Preview2, {}) })
|
|
6115
7832
|
}
|
|
6116
7833
|
),
|
|
6117
|
-
/* @__PURE__ */
|
|
7834
|
+
/* @__PURE__ */ jsx39("div", { className: getClassName26("loader"), children: /* @__PURE__ */ jsx39(Loader, { size: 24 }) })
|
|
6118
7835
|
] })
|
|
6119
7836
|
]
|
|
6120
7837
|
}
|
|
@@ -6172,19 +7889,19 @@ var useLoadedOverrides = ({
|
|
|
6172
7889
|
|
|
6173
7890
|
// components/DefaultOverride/index.tsx
|
|
6174
7891
|
init_react_import();
|
|
6175
|
-
import { Fragment as Fragment13, jsx as
|
|
6176
|
-
var DefaultOverride = ({ children }) => /* @__PURE__ */
|
|
7892
|
+
import { Fragment as Fragment13, jsx as jsx40 } from "react/jsx-runtime";
|
|
7893
|
+
var DefaultOverride = ({ children }) => /* @__PURE__ */ jsx40(Fragment13, { children });
|
|
6177
7894
|
|
|
6178
7895
|
// lib/use-inject-css.ts
|
|
6179
7896
|
init_react_import();
|
|
6180
|
-
import { useEffect as
|
|
7897
|
+
import { useEffect as useEffect26, useState as useState22 } from "react";
|
|
6181
7898
|
var styles = ``;
|
|
6182
7899
|
var useInjectStyleSheet = (initialStyles, iframeEnabled) => {
|
|
6183
|
-
const [el, setEl] =
|
|
6184
|
-
|
|
7900
|
+
const [el, setEl] = useState22();
|
|
7901
|
+
useEffect26(() => {
|
|
6185
7902
|
setEl(document.createElement("style"));
|
|
6186
7903
|
}, []);
|
|
6187
|
-
|
|
7904
|
+
useEffect26(() => {
|
|
6188
7905
|
var _a;
|
|
6189
7906
|
if (!el || typeof window === "undefined") {
|
|
6190
7907
|
return;
|
|
@@ -6204,10 +7921,10 @@ var useInjectGlobalCss = (iframeEnabled) => {
|
|
|
6204
7921
|
|
|
6205
7922
|
// lib/use-preview-mode-hotkeys.ts
|
|
6206
7923
|
init_react_import();
|
|
6207
|
-
import { useCallback as
|
|
7924
|
+
import { useCallback as useCallback16 } from "react";
|
|
6208
7925
|
var usePreviewModeHotkeys = () => {
|
|
6209
7926
|
const appStore = useAppStoreApi();
|
|
6210
|
-
const toggleInteractive =
|
|
7927
|
+
const toggleInteractive = useCallback16(() => {
|
|
6211
7928
|
const dispatch = appStore.getState().dispatch;
|
|
6212
7929
|
dispatch({
|
|
6213
7930
|
type: "setUi",
|
|
@@ -6225,18 +7942,18 @@ import fdeq from "fast-deep-equal";
|
|
|
6225
7942
|
|
|
6226
7943
|
// components/Puck/components/Header/index.tsx
|
|
6227
7944
|
init_react_import();
|
|
6228
|
-
import { memo as
|
|
7945
|
+
import { memo as memo4, useCallback as useCallback17, useMemo as useMemo19, useState as useState23 } from "react";
|
|
6229
7946
|
|
|
6230
7947
|
// components/MenuBar/index.tsx
|
|
6231
7948
|
init_react_import();
|
|
6232
7949
|
|
|
6233
7950
|
// css-module:/home/runner/work/puck/puck/packages/core/components/MenuBar/styles.module.css#css-module
|
|
6234
7951
|
init_react_import();
|
|
6235
|
-
var
|
|
7952
|
+
var styles_module_default22 = { "MenuBar": "_MenuBar_8pf8c_1", "MenuBar--menuOpen": "_MenuBar--menuOpen_8pf8c_14", "MenuBar-inner": "_MenuBar-inner_8pf8c_29", "MenuBar-history": "_MenuBar-history_8pf8c_45" };
|
|
6236
7953
|
|
|
6237
7954
|
// components/MenuBar/index.tsx
|
|
6238
|
-
import { Fragment as Fragment14, jsx as
|
|
6239
|
-
var
|
|
7955
|
+
import { Fragment as Fragment14, jsx as jsx41, jsxs as jsxs18 } from "react/jsx-runtime";
|
|
7956
|
+
var getClassName27 = get_class_name_factory_default("MenuBar", styles_module_default22);
|
|
6240
7957
|
function MenuBar({
|
|
6241
7958
|
menuOpen = false,
|
|
6242
7959
|
renderHeaderActions,
|
|
@@ -6246,10 +7963,10 @@ function MenuBar({
|
|
|
6246
7963
|
const forward = useAppStore((s) => s.history.forward);
|
|
6247
7964
|
const hasFuture = useAppStore((s) => s.history.hasFuture());
|
|
6248
7965
|
const hasPast = useAppStore((s) => s.history.hasPast());
|
|
6249
|
-
return /* @__PURE__ */
|
|
7966
|
+
return /* @__PURE__ */ jsx41(
|
|
6250
7967
|
"div",
|
|
6251
7968
|
{
|
|
6252
|
-
className:
|
|
7969
|
+
className: getClassName27({ menuOpen }),
|
|
6253
7970
|
onClick: (event) => {
|
|
6254
7971
|
var _a;
|
|
6255
7972
|
const element = event.target;
|
|
@@ -6260,30 +7977,30 @@ function MenuBar({
|
|
|
6260
7977
|
setMenuOpen(false);
|
|
6261
7978
|
}
|
|
6262
7979
|
},
|
|
6263
|
-
children: /* @__PURE__ */ jsxs18("div", { className:
|
|
6264
|
-
/* @__PURE__ */ jsxs18("div", { className:
|
|
6265
|
-
/* @__PURE__ */
|
|
7980
|
+
children: /* @__PURE__ */ jsxs18("div", { className: getClassName27("inner"), children: [
|
|
7981
|
+
/* @__PURE__ */ jsxs18("div", { className: getClassName27("history"), children: [
|
|
7982
|
+
/* @__PURE__ */ jsx41(
|
|
6266
7983
|
IconButton,
|
|
6267
7984
|
{
|
|
6268
7985
|
type: "button",
|
|
6269
7986
|
title: "undo",
|
|
6270
7987
|
disabled: !hasPast,
|
|
6271
7988
|
onClick: back,
|
|
6272
|
-
children: /* @__PURE__ */
|
|
7989
|
+
children: /* @__PURE__ */ jsx41(Undo2, { size: 21 })
|
|
6273
7990
|
}
|
|
6274
7991
|
),
|
|
6275
|
-
/* @__PURE__ */
|
|
7992
|
+
/* @__PURE__ */ jsx41(
|
|
6276
7993
|
IconButton,
|
|
6277
7994
|
{
|
|
6278
7995
|
type: "button",
|
|
6279
7996
|
title: "redo",
|
|
6280
7997
|
disabled: !hasFuture,
|
|
6281
7998
|
onClick: forward,
|
|
6282
|
-
children: /* @__PURE__ */
|
|
7999
|
+
children: /* @__PURE__ */ jsx41(Redo2, { size: 21 })
|
|
6283
8000
|
}
|
|
6284
8001
|
)
|
|
6285
8002
|
] }),
|
|
6286
|
-
/* @__PURE__ */
|
|
8003
|
+
/* @__PURE__ */ jsx41(Fragment14, { children: renderHeaderActions && renderHeaderActions() })
|
|
6287
8004
|
] })
|
|
6288
8005
|
}
|
|
6289
8006
|
);
|
|
@@ -6291,11 +8008,11 @@ function MenuBar({
|
|
|
6291
8008
|
|
|
6292
8009
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Header/styles.module.css#css-module
|
|
6293
8010
|
init_react_import();
|
|
6294
|
-
var
|
|
8011
|
+
var styles_module_default23 = { "PuckHeader": "_PuckHeader_15xnq_1", "PuckHeader-inner": "_PuckHeader-inner_15xnq_10", "PuckHeader-toggle": "_PuckHeader-toggle_15xnq_20", "PuckHeader--rightSideBarVisible": "_PuckHeader--rightSideBarVisible_15xnq_27", "PuckHeader-rightSideBarToggle": "_PuckHeader-rightSideBarToggle_15xnq_27", "PuckHeader--leftSideBarVisible": "_PuckHeader--leftSideBarVisible_15xnq_28", "PuckHeader-leftSideBarToggle": "_PuckHeader-leftSideBarToggle_15xnq_28", "PuckHeader-title": "_PuckHeader-title_15xnq_32", "PuckHeader-path": "_PuckHeader-path_15xnq_36", "PuckHeader-tools": "_PuckHeader-tools_15xnq_43", "PuckHeader-menuButton": "_PuckHeader-menuButton_15xnq_49", "PuckHeader--menuOpen": "_PuckHeader--menuOpen_15xnq_54" };
|
|
6295
8012
|
|
|
6296
8013
|
// components/Puck/components/Header/index.tsx
|
|
6297
|
-
import { Fragment as Fragment15, jsx as
|
|
6298
|
-
var
|
|
8014
|
+
import { Fragment as Fragment15, jsx as jsx42, jsxs as jsxs19 } from "react/jsx-runtime";
|
|
8015
|
+
var getClassName28 = get_class_name_factory_default("PuckHeader", styles_module_default23);
|
|
6299
8016
|
var HeaderInner = () => {
|
|
6300
8017
|
const {
|
|
6301
8018
|
onPublish,
|
|
@@ -6316,7 +8033,7 @@ var HeaderInner = () => {
|
|
|
6316
8033
|
var _b = _a, { actions } = _b, props = __objRest(_b, ["actions"]);
|
|
6317
8034
|
const Comp = renderHeader;
|
|
6318
8035
|
const appState = useAppStore((s) => s.state);
|
|
6319
|
-
return /* @__PURE__ */
|
|
8036
|
+
return /* @__PURE__ */ jsx42(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState, children: actions }));
|
|
6320
8037
|
};
|
|
6321
8038
|
return RenderHeader;
|
|
6322
8039
|
}
|
|
@@ -6330,19 +8047,19 @@ var HeaderInner = () => {
|
|
|
6330
8047
|
const RenderHeader = (props) => {
|
|
6331
8048
|
const Comp = renderHeaderActions;
|
|
6332
8049
|
const appState = useAppStore((s) => s.state);
|
|
6333
|
-
return /* @__PURE__ */
|
|
8050
|
+
return /* @__PURE__ */ jsx42(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState }));
|
|
6334
8051
|
};
|
|
6335
8052
|
return RenderHeader;
|
|
6336
8053
|
}
|
|
6337
8054
|
return DefaultOverride;
|
|
6338
|
-
}, [
|
|
8055
|
+
}, [renderHeaderActions]);
|
|
6339
8056
|
const CustomHeader = useAppStore(
|
|
6340
8057
|
(s) => s.overrides.header || defaultHeaderRender
|
|
6341
8058
|
);
|
|
6342
8059
|
const CustomHeaderActions = useAppStore(
|
|
6343
8060
|
(s) => s.overrides.headerActions || defaultHeaderActionsRender
|
|
6344
8061
|
);
|
|
6345
|
-
const [menuOpen, setMenuOpen] =
|
|
8062
|
+
const [menuOpen, setMenuOpen] = useState23(false);
|
|
6346
8063
|
const rootTitle = useAppStore((s) => {
|
|
6347
8064
|
var _a, _b;
|
|
6348
8065
|
const rootData = (_a = s.state.indexes.nodes["root"]) == null ? void 0 : _a.data;
|
|
@@ -6352,7 +8069,7 @@ var HeaderInner = () => {
|
|
|
6352
8069
|
const rightSideBarVisible = useAppStore(
|
|
6353
8070
|
(s) => s.state.ui.rightSideBarVisible
|
|
6354
8071
|
);
|
|
6355
|
-
const toggleSidebars =
|
|
8072
|
+
const toggleSidebars = useCallback17(
|
|
6356
8073
|
(sidebar) => {
|
|
6357
8074
|
const widerViewport = window.matchMedia("(min-width: 638px)").matches;
|
|
6358
8075
|
const sideBarVisible = sidebar === "left" ? leftSideBarVisible : rightSideBarVisible;
|
|
@@ -6366,27 +8083,27 @@ var HeaderInner = () => {
|
|
|
6366
8083
|
},
|
|
6367
8084
|
[dispatch, leftSideBarVisible, rightSideBarVisible]
|
|
6368
8085
|
);
|
|
6369
|
-
return /* @__PURE__ */
|
|
8086
|
+
return /* @__PURE__ */ jsx42(
|
|
6370
8087
|
CustomHeader,
|
|
6371
8088
|
{
|
|
6372
|
-
actions: /* @__PURE__ */
|
|
8089
|
+
actions: /* @__PURE__ */ jsx42(Fragment15, { children: /* @__PURE__ */ jsx42(CustomHeaderActions, { children: /* @__PURE__ */ jsx42(
|
|
6373
8090
|
Button,
|
|
6374
8091
|
{
|
|
6375
8092
|
onClick: () => {
|
|
6376
8093
|
const data = appStore.getState().state.data;
|
|
6377
8094
|
onPublish && onPublish(data);
|
|
6378
8095
|
},
|
|
6379
|
-
icon: /* @__PURE__ */
|
|
8096
|
+
icon: /* @__PURE__ */ jsx42(Globe, { size: "14px" }),
|
|
6380
8097
|
children: "Publish"
|
|
6381
8098
|
}
|
|
6382
8099
|
) }) }),
|
|
6383
|
-
children: /* @__PURE__ */
|
|
8100
|
+
children: /* @__PURE__ */ jsx42(
|
|
6384
8101
|
"header",
|
|
6385
8102
|
{
|
|
6386
|
-
className:
|
|
6387
|
-
children: /* @__PURE__ */ jsxs19("div", { className:
|
|
6388
|
-
/* @__PURE__ */ jsxs19("div", { className:
|
|
6389
|
-
/* @__PURE__ */
|
|
8103
|
+
className: getClassName28({ leftSideBarVisible, rightSideBarVisible }),
|
|
8104
|
+
children: /* @__PURE__ */ jsxs19("div", { className: getClassName28("inner"), children: [
|
|
8105
|
+
/* @__PURE__ */ jsxs19("div", { className: getClassName28("toggle"), children: [
|
|
8106
|
+
/* @__PURE__ */ jsx42("div", { className: getClassName28("leftSideBarToggle"), children: /* @__PURE__ */ jsx42(
|
|
6390
8107
|
IconButton,
|
|
6391
8108
|
{
|
|
6392
8109
|
type: "button",
|
|
@@ -6394,10 +8111,10 @@ var HeaderInner = () => {
|
|
|
6394
8111
|
toggleSidebars("left");
|
|
6395
8112
|
},
|
|
6396
8113
|
title: "Toggle left sidebar",
|
|
6397
|
-
children: /* @__PURE__ */
|
|
8114
|
+
children: /* @__PURE__ */ jsx42(PanelLeft, { focusable: "false" })
|
|
6398
8115
|
}
|
|
6399
8116
|
) }),
|
|
6400
|
-
/* @__PURE__ */
|
|
8117
|
+
/* @__PURE__ */ jsx42("div", { className: getClassName28("rightSideBarToggle"), children: /* @__PURE__ */ jsx42(
|
|
6401
8118
|
IconButton,
|
|
6402
8119
|
{
|
|
6403
8120
|
type: "button",
|
|
@@ -6405,19 +8122,19 @@ var HeaderInner = () => {
|
|
|
6405
8122
|
toggleSidebars("right");
|
|
6406
8123
|
},
|
|
6407
8124
|
title: "Toggle right sidebar",
|
|
6408
|
-
children: /* @__PURE__ */
|
|
8125
|
+
children: /* @__PURE__ */ jsx42(PanelRight, { focusable: "false" })
|
|
6409
8126
|
}
|
|
6410
8127
|
) })
|
|
6411
8128
|
] }),
|
|
6412
|
-
/* @__PURE__ */
|
|
8129
|
+
/* @__PURE__ */ jsx42("div", { className: getClassName28("title"), children: /* @__PURE__ */ jsxs19(Heading, { rank: "2", size: "xs", children: [
|
|
6413
8130
|
headerTitle || rootTitle || "Page",
|
|
6414
8131
|
headerPath && /* @__PURE__ */ jsxs19(Fragment15, { children: [
|
|
6415
8132
|
" ",
|
|
6416
|
-
/* @__PURE__ */
|
|
8133
|
+
/* @__PURE__ */ jsx42("code", { className: getClassName28("path"), children: headerPath })
|
|
6417
8134
|
] })
|
|
6418
8135
|
] }) }),
|
|
6419
|
-
/* @__PURE__ */ jsxs19("div", { className:
|
|
6420
|
-
/* @__PURE__ */
|
|
8136
|
+
/* @__PURE__ */ jsxs19("div", { className: getClassName28("tools"), children: [
|
|
8137
|
+
/* @__PURE__ */ jsx42("div", { className: getClassName28("menuButton"), children: /* @__PURE__ */ jsx42(
|
|
6421
8138
|
IconButton,
|
|
6422
8139
|
{
|
|
6423
8140
|
type: "button",
|
|
@@ -6425,23 +8142,23 @@ var HeaderInner = () => {
|
|
|
6425
8142
|
return setMenuOpen(!menuOpen);
|
|
6426
8143
|
},
|
|
6427
8144
|
title: "Toggle menu bar",
|
|
6428
|
-
children: menuOpen ? /* @__PURE__ */
|
|
8145
|
+
children: menuOpen ? /* @__PURE__ */ jsx42(ChevronUp, { focusable: "false" }) : /* @__PURE__ */ jsx42(ChevronDown, { focusable: "false" })
|
|
6429
8146
|
}
|
|
6430
8147
|
) }),
|
|
6431
|
-
/* @__PURE__ */
|
|
8148
|
+
/* @__PURE__ */ jsx42(
|
|
6432
8149
|
MenuBar,
|
|
6433
8150
|
{
|
|
6434
8151
|
dispatch,
|
|
6435
8152
|
onPublish,
|
|
6436
8153
|
menuOpen,
|
|
6437
|
-
renderHeaderActions: () => /* @__PURE__ */
|
|
8154
|
+
renderHeaderActions: () => /* @__PURE__ */ jsx42(CustomHeaderActions, { children: /* @__PURE__ */ jsx42(
|
|
6438
8155
|
Button,
|
|
6439
8156
|
{
|
|
6440
8157
|
onClick: () => {
|
|
6441
8158
|
const data = appStore.getState().state.data;
|
|
6442
8159
|
onPublish && onPublish(data);
|
|
6443
8160
|
},
|
|
6444
|
-
icon: /* @__PURE__ */
|
|
8161
|
+
icon: /* @__PURE__ */ jsx42(Globe, { size: "14px" }),
|
|
6445
8162
|
children: "Publish"
|
|
6446
8163
|
}
|
|
6447
8164
|
) }),
|
|
@@ -6455,22 +8172,22 @@ var HeaderInner = () => {
|
|
|
6455
8172
|
}
|
|
6456
8173
|
);
|
|
6457
8174
|
};
|
|
6458
|
-
var Header =
|
|
8175
|
+
var Header = memo4(HeaderInner);
|
|
6459
8176
|
|
|
6460
8177
|
// components/Puck/components/Sidebar/index.tsx
|
|
6461
8178
|
init_react_import();
|
|
6462
8179
|
|
|
6463
8180
|
// components/Puck/components/ResizeHandle/index.tsx
|
|
6464
8181
|
init_react_import();
|
|
6465
|
-
import { useCallback as
|
|
8182
|
+
import { useCallback as useCallback18, useRef as useRef10 } from "react";
|
|
6466
8183
|
|
|
6467
8184
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/ResizeHandle/styles.module.css#css-module
|
|
6468
8185
|
init_react_import();
|
|
6469
|
-
var
|
|
8186
|
+
var styles_module_default24 = { "ResizeHandle": "_ResizeHandle_144bf_2", "ResizeHandle--left": "_ResizeHandle--left_144bf_16", "ResizeHandle--right": "_ResizeHandle--right_144bf_20" };
|
|
6470
8187
|
|
|
6471
8188
|
// components/Puck/components/ResizeHandle/index.tsx
|
|
6472
|
-
import { jsx as
|
|
6473
|
-
var
|
|
8189
|
+
import { jsx as jsx43 } from "react/jsx-runtime";
|
|
8190
|
+
var getClassName29 = get_class_name_factory_default("ResizeHandle", styles_module_default24);
|
|
6474
8191
|
var ResizeHandle = ({
|
|
6475
8192
|
position,
|
|
6476
8193
|
sidebarRef,
|
|
@@ -6479,11 +8196,11 @@ var ResizeHandle = ({
|
|
|
6479
8196
|
}) => {
|
|
6480
8197
|
const { frameRef } = useCanvasFrame();
|
|
6481
8198
|
const resetAutoZoom = useResetAutoZoom(frameRef);
|
|
6482
|
-
const handleRef =
|
|
6483
|
-
const isDragging =
|
|
6484
|
-
const startX =
|
|
6485
|
-
const startWidth =
|
|
6486
|
-
const handleMouseMove =
|
|
8199
|
+
const handleRef = useRef10(null);
|
|
8200
|
+
const isDragging = useRef10(false);
|
|
8201
|
+
const startX = useRef10(0);
|
|
8202
|
+
const startWidth = useRef10(0);
|
|
8203
|
+
const handleMouseMove = useCallback18(
|
|
6487
8204
|
(e) => {
|
|
6488
8205
|
if (!isDragging.current) return;
|
|
6489
8206
|
const delta = e.clientX - startX.current;
|
|
@@ -6494,7 +8211,7 @@ var ResizeHandle = ({
|
|
|
6494
8211
|
},
|
|
6495
8212
|
[onResize, position]
|
|
6496
8213
|
);
|
|
6497
|
-
const handleMouseUp =
|
|
8214
|
+
const handleMouseUp = useCallback18(() => {
|
|
6498
8215
|
var _a;
|
|
6499
8216
|
if (!isDragging.current) return;
|
|
6500
8217
|
isDragging.current = false;
|
|
@@ -6510,7 +8227,7 @@ var ResizeHandle = ({
|
|
|
6510
8227
|
onResizeEnd(finalWidth);
|
|
6511
8228
|
resetAutoZoom();
|
|
6512
8229
|
}, [onResizeEnd]);
|
|
6513
|
-
const handleMouseDown =
|
|
8230
|
+
const handleMouseDown = useCallback18(
|
|
6514
8231
|
(e) => {
|
|
6515
8232
|
var _a;
|
|
6516
8233
|
isDragging.current = true;
|
|
@@ -6528,11 +8245,11 @@ var ResizeHandle = ({
|
|
|
6528
8245
|
},
|
|
6529
8246
|
[position, handleMouseMove, handleMouseUp]
|
|
6530
8247
|
);
|
|
6531
|
-
return /* @__PURE__ */
|
|
8248
|
+
return /* @__PURE__ */ jsx43(
|
|
6532
8249
|
"div",
|
|
6533
8250
|
{
|
|
6534
8251
|
ref: handleRef,
|
|
6535
|
-
className:
|
|
8252
|
+
className: getClassName29({ [position]: true }),
|
|
6536
8253
|
onMouseDown: handleMouseDown
|
|
6537
8254
|
}
|
|
6538
8255
|
);
|
|
@@ -6540,24 +8257,23 @@ var ResizeHandle = ({
|
|
|
6540
8257
|
|
|
6541
8258
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Sidebar/styles.module.css#css-module
|
|
6542
8259
|
init_react_import();
|
|
6543
|
-
var
|
|
8260
|
+
var styles_module_default25 = { "Sidebar": "_Sidebar_1xksb_1", "Sidebar--left": "_Sidebar--left_1xksb_8", "Sidebar--right": "_Sidebar--right_1xksb_14", "Sidebar-resizeHandle": "_Sidebar-resizeHandle_1xksb_20" };
|
|
6544
8261
|
|
|
6545
8262
|
// components/Puck/components/Sidebar/index.tsx
|
|
6546
|
-
import { Fragment as Fragment16, jsx as
|
|
6547
|
-
var
|
|
8263
|
+
import { Fragment as Fragment16, jsx as jsx44, jsxs as jsxs20 } from "react/jsx-runtime";
|
|
8264
|
+
var getClassName30 = get_class_name_factory_default("Sidebar", styles_module_default25);
|
|
6548
8265
|
var Sidebar = ({
|
|
6549
8266
|
position,
|
|
6550
8267
|
sidebarRef,
|
|
6551
8268
|
isVisible,
|
|
6552
|
-
width,
|
|
6553
8269
|
onResize,
|
|
6554
8270
|
onResizeEnd,
|
|
6555
8271
|
children
|
|
6556
8272
|
}) => {
|
|
6557
8273
|
if (!isVisible) return null;
|
|
6558
8274
|
return /* @__PURE__ */ jsxs20(Fragment16, { children: [
|
|
6559
|
-
/* @__PURE__ */
|
|
6560
|
-
/* @__PURE__ */
|
|
8275
|
+
/* @__PURE__ */ jsx44("div", { ref: sidebarRef, className: getClassName30({ [position]: true }), children }),
|
|
8276
|
+
/* @__PURE__ */ jsx44("div", { className: `${getClassName30("resizeHandle")}`, children: /* @__PURE__ */ jsx44(
|
|
6561
8277
|
ResizeHandle,
|
|
6562
8278
|
{
|
|
6563
8279
|
position,
|
|
@@ -6571,14 +8287,14 @@ var Sidebar = ({
|
|
|
6571
8287
|
|
|
6572
8288
|
// lib/use-sidebar-resize.ts
|
|
6573
8289
|
init_react_import();
|
|
6574
|
-
import { useCallback as
|
|
8290
|
+
import { useCallback as useCallback19, useEffect as useEffect28, useRef as useRef11, useState as useState24 } from "react";
|
|
6575
8291
|
function useSidebarResize(position, dispatch) {
|
|
6576
|
-
const [width, setWidth] =
|
|
6577
|
-
const sidebarRef =
|
|
8292
|
+
const [width, setWidth] = useState24(null);
|
|
8293
|
+
const sidebarRef = useRef11(null);
|
|
6578
8294
|
const storeWidth = useAppStore(
|
|
6579
8295
|
(s) => position === "left" ? s.state.ui.leftSideBarWidth : s.state.ui.rightSideBarWidth
|
|
6580
8296
|
);
|
|
6581
|
-
|
|
8297
|
+
useEffect28(() => {
|
|
6582
8298
|
if (typeof window !== "undefined" && !storeWidth) {
|
|
6583
8299
|
try {
|
|
6584
8300
|
const savedWidths = localStorage.getItem("puck-sidebar-widths");
|
|
@@ -6603,12 +8319,12 @@ function useSidebarResize(position, dispatch) {
|
|
|
6603
8319
|
}
|
|
6604
8320
|
}
|
|
6605
8321
|
}, [dispatch, position, storeWidth]);
|
|
6606
|
-
|
|
8322
|
+
useEffect28(() => {
|
|
6607
8323
|
if (storeWidth !== void 0) {
|
|
6608
8324
|
setWidth(storeWidth);
|
|
6609
8325
|
}
|
|
6610
8326
|
}, [storeWidth]);
|
|
6611
|
-
const handleResizeEnd =
|
|
8327
|
+
const handleResizeEnd = useCallback19(
|
|
6612
8328
|
(width2) => {
|
|
6613
8329
|
dispatch({
|
|
6614
8330
|
type: "setUi",
|
|
@@ -6651,9 +8367,9 @@ function useSidebarResize(position, dispatch) {
|
|
|
6651
8367
|
}
|
|
6652
8368
|
|
|
6653
8369
|
// components/Puck/index.tsx
|
|
6654
|
-
import { jsx as
|
|
6655
|
-
var
|
|
6656
|
-
var getLayoutClassName = get_class_name_factory_default("PuckLayout",
|
|
8370
|
+
import { jsx as jsx45, jsxs as jsxs21 } from "react/jsx-runtime";
|
|
8371
|
+
var getClassName31 = get_class_name_factory_default("Puck", styles_module_default15);
|
|
8372
|
+
var getLayoutClassName = get_class_name_factory_default("PuckLayout", styles_module_default15);
|
|
6657
8373
|
var FieldSideBar = () => {
|
|
6658
8374
|
const title = useAppStore(
|
|
6659
8375
|
(s) => {
|
|
@@ -6661,13 +8377,13 @@ var FieldSideBar = () => {
|
|
|
6661
8377
|
return s.selectedItem ? (_b = (_a = s.config.components[s.selectedItem.type]) == null ? void 0 : _a["label"]) != null ? _b : s.selectedItem.type.toString() : "Page";
|
|
6662
8378
|
}
|
|
6663
8379
|
);
|
|
6664
|
-
return /* @__PURE__ */
|
|
8380
|
+
return /* @__PURE__ */ jsx45(SidebarSection, { noPadding: true, noBorderTop: true, showBreadcrumbs: true, title, children: /* @__PURE__ */ jsx45(Fields, {}) });
|
|
6665
8381
|
};
|
|
6666
|
-
var propsContext =
|
|
8382
|
+
var propsContext = createContext8({});
|
|
6667
8383
|
function PropsProvider(props) {
|
|
6668
|
-
return /* @__PURE__ */
|
|
8384
|
+
return /* @__PURE__ */ jsx45(propsContext.Provider, { value: props, children: props.children });
|
|
6669
8385
|
}
|
|
6670
|
-
var usePropsContext = () =>
|
|
8386
|
+
var usePropsContext = () => useContext13(propsContext);
|
|
6671
8387
|
function PuckProvider({ children }) {
|
|
6672
8388
|
const {
|
|
6673
8389
|
config,
|
|
@@ -6691,7 +8407,7 @@ function PuckProvider({ children }) {
|
|
|
6691
8407
|
}, _iframe),
|
|
6692
8408
|
[_iframe]
|
|
6693
8409
|
);
|
|
6694
|
-
const [generatedAppState] =
|
|
8410
|
+
const [generatedAppState] = useState25(() => {
|
|
6695
8411
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
6696
8412
|
const initial = __spreadValues(__spreadValues({}, defaultAppState.ui), initialUi);
|
|
6697
8413
|
let clientUiState = {};
|
|
@@ -6751,7 +8467,7 @@ function PuckProvider({ children }) {
|
|
|
6751
8467
|
return walkAppState(newAppState, config);
|
|
6752
8468
|
});
|
|
6753
8469
|
const { appendData = true } = _initialHistory || {};
|
|
6754
|
-
const [blendedHistories] =
|
|
8470
|
+
const [blendedHistories] = useState25(
|
|
6755
8471
|
[
|
|
6756
8472
|
...(_initialHistory == null ? void 0 : _initialHistory.histories) || [],
|
|
6757
8473
|
...appendData ? [{ state: generatedAppState }] : []
|
|
@@ -6779,7 +8495,7 @@ function PuckProvider({ children }) {
|
|
|
6779
8495
|
);
|
|
6780
8496
|
return __spreadValues(__spreadValues({}, pluginFieldTransforms), fieldTransforms);
|
|
6781
8497
|
}, [fieldTransforms, plugins]);
|
|
6782
|
-
const generateAppStore =
|
|
8498
|
+
const generateAppStore = useCallback20(
|
|
6783
8499
|
(state) => {
|
|
6784
8500
|
return {
|
|
6785
8501
|
state,
|
|
@@ -6805,15 +8521,15 @@ function PuckProvider({ children }) {
|
|
|
6805
8521
|
loadedFieldTransforms
|
|
6806
8522
|
]
|
|
6807
8523
|
);
|
|
6808
|
-
const [appStore] =
|
|
8524
|
+
const [appStore] = useState25(
|
|
6809
8525
|
() => createAppStore(generateAppStore(initialAppState))
|
|
6810
8526
|
);
|
|
6811
|
-
|
|
8527
|
+
useEffect29(() => {
|
|
6812
8528
|
if (process.env.NODE_ENV !== "production") {
|
|
6813
8529
|
window.__PUCK_INTERNAL_DO_NOT_USE = { appStore };
|
|
6814
8530
|
}
|
|
6815
8531
|
}, [appStore]);
|
|
6816
|
-
|
|
8532
|
+
useEffect29(() => {
|
|
6817
8533
|
const state = appStore.getState().state;
|
|
6818
8534
|
appStore.setState(__spreadValues({}, generateAppStore(state)));
|
|
6819
8535
|
}, [config, plugins, loadedOverrides, viewports, iframe, onAction, metadata]);
|
|
@@ -6822,8 +8538,8 @@ function PuckProvider({ children }) {
|
|
|
6822
8538
|
index: initialHistoryIndex,
|
|
6823
8539
|
initialAppState
|
|
6824
8540
|
});
|
|
6825
|
-
const previousData =
|
|
6826
|
-
|
|
8541
|
+
const previousData = useRef12(null);
|
|
8542
|
+
useEffect29(() => {
|
|
6827
8543
|
appStore.subscribe(
|
|
6828
8544
|
(s) => s.state.data,
|
|
6829
8545
|
(data) => {
|
|
@@ -6837,11 +8553,11 @@ function PuckProvider({ children }) {
|
|
|
6837
8553
|
}, []);
|
|
6838
8554
|
useRegisterPermissionsSlice(appStore, permissions);
|
|
6839
8555
|
const uPuckStore = useRegisterUsePuckStore(appStore);
|
|
6840
|
-
|
|
8556
|
+
useEffect29(() => {
|
|
6841
8557
|
const { resolveAndCommitData } = appStore.getState();
|
|
6842
8558
|
resolveAndCommitData();
|
|
6843
8559
|
}, []);
|
|
6844
|
-
return /* @__PURE__ */
|
|
8560
|
+
return /* @__PURE__ */ jsx45(appStoreContext.Provider, { value: appStore, children: /* @__PURE__ */ jsx45(UsePuckStoreContext.Provider, { value: uPuckStore, children }) });
|
|
6845
8561
|
}
|
|
6846
8562
|
function PuckLayout({ children }) {
|
|
6847
8563
|
const {
|
|
@@ -6874,7 +8590,7 @@ function PuckLayout({ children }) {
|
|
|
6874
8590
|
sidebarRef: rightSidebarRef,
|
|
6875
8591
|
handleResizeEnd: handleRightSidebarResizeEnd
|
|
6876
8592
|
} = useSidebarResize("right", dispatch);
|
|
6877
|
-
|
|
8593
|
+
useEffect29(() => {
|
|
6878
8594
|
if (!window.matchMedia("(min-width: 638px)").matches) {
|
|
6879
8595
|
dispatch({
|
|
6880
8596
|
type: "setUi",
|
|
@@ -6902,13 +8618,13 @@ function PuckLayout({ children }) {
|
|
|
6902
8618
|
() => overrides.puck || DefaultOverride,
|
|
6903
8619
|
[overrides]
|
|
6904
8620
|
);
|
|
6905
|
-
const [mounted, setMounted] =
|
|
6906
|
-
|
|
8621
|
+
const [mounted, setMounted] = useState25(false);
|
|
8622
|
+
useEffect29(() => {
|
|
6907
8623
|
setMounted(true);
|
|
6908
8624
|
}, []);
|
|
6909
8625
|
const ready = useAppStore((s) => s.status === "READY");
|
|
6910
8626
|
useMonitorHotkeys();
|
|
6911
|
-
|
|
8627
|
+
useEffect29(() => {
|
|
6912
8628
|
if (ready && iframe.enabled) {
|
|
6913
8629
|
const frameDoc = getFrame();
|
|
6914
8630
|
if (frameDoc) {
|
|
@@ -6917,8 +8633,15 @@ function PuckLayout({ children }) {
|
|
|
6917
8633
|
}
|
|
6918
8634
|
}, [ready, iframe.enabled]);
|
|
6919
8635
|
usePreviewModeHotkeys();
|
|
6920
|
-
|
|
6921
|
-
|
|
8636
|
+
const layoutOptions = {};
|
|
8637
|
+
if (leftWidth) {
|
|
8638
|
+
layoutOptions["--puck-user-left-side-bar-width"] = `${leftWidth}px`;
|
|
8639
|
+
}
|
|
8640
|
+
if (rightWidth) {
|
|
8641
|
+
layoutOptions["--puck-user-right-side-bar-width"] = `${rightWidth}px`;
|
|
8642
|
+
}
|
|
8643
|
+
return /* @__PURE__ */ jsxs21("div", { className: `Puck ${getClassName31()}`, children: [
|
|
8644
|
+
/* @__PURE__ */ jsx45(DragDropContext, { disableAutoScroll: dnd == null ? void 0 : dnd.disableAutoScroll, children: /* @__PURE__ */ jsx45(CustomPuck, { children: children || /* @__PURE__ */ jsx45(FrameProvider, { children: /* @__PURE__ */ jsx45(
|
|
6922
8645
|
"div",
|
|
6923
8646
|
{
|
|
6924
8647
|
className: getLayoutClassName({
|
|
@@ -6930,41 +8653,33 @@ function PuckLayout({ children }) {
|
|
|
6930
8653
|
"div",
|
|
6931
8654
|
{
|
|
6932
8655
|
className: getLayoutClassName("inner"),
|
|
6933
|
-
style:
|
|
6934
|
-
gridTemplateColumns: `
|
|
6935
|
-
${leftSideBarVisible ? leftWidth ? `${leftWidth}px` : "var(--puck-side-bar-width)" : "0"}
|
|
6936
|
-
var(--puck-frame-width)
|
|
6937
|
-
${rightSideBarVisible ? rightWidth ? `${rightWidth}px` : "var(--puck-side-bar-width)" : "0"}
|
|
6938
|
-
`
|
|
6939
|
-
},
|
|
8656
|
+
style: layoutOptions,
|
|
6940
8657
|
children: [
|
|
6941
|
-
/* @__PURE__ */
|
|
8658
|
+
/* @__PURE__ */ jsx45(Header, {}),
|
|
6942
8659
|
/* @__PURE__ */ jsxs21(
|
|
6943
8660
|
Sidebar,
|
|
6944
8661
|
{
|
|
6945
8662
|
position: "left",
|
|
6946
8663
|
sidebarRef: leftSidebarRef,
|
|
6947
8664
|
isVisible: leftSideBarVisible,
|
|
6948
|
-
width: leftWidth,
|
|
6949
8665
|
onResize: setLeftWidth,
|
|
6950
8666
|
onResizeEnd: handleLeftSidebarResizeEnd,
|
|
6951
8667
|
children: [
|
|
6952
|
-
/* @__PURE__ */
|
|
6953
|
-
/* @__PURE__ */
|
|
8668
|
+
/* @__PURE__ */ jsx45(SidebarSection, { title: "Components", noBorderTop: true, children: /* @__PURE__ */ jsx45(Components, {}) }),
|
|
8669
|
+
/* @__PURE__ */ jsx45(SidebarSection, { title: "Outline", children: /* @__PURE__ */ jsx45(Outline, {}) })
|
|
6954
8670
|
]
|
|
6955
8671
|
}
|
|
6956
8672
|
),
|
|
6957
|
-
/* @__PURE__ */
|
|
6958
|
-
/* @__PURE__ */
|
|
8673
|
+
/* @__PURE__ */ jsx45(Canvas, {}),
|
|
8674
|
+
/* @__PURE__ */ jsx45(
|
|
6959
8675
|
Sidebar,
|
|
6960
8676
|
{
|
|
6961
8677
|
position: "right",
|
|
6962
8678
|
sidebarRef: rightSidebarRef,
|
|
6963
8679
|
isVisible: rightSideBarVisible,
|
|
6964
|
-
width: rightWidth,
|
|
6965
8680
|
onResize: setRightWidth,
|
|
6966
8681
|
onResizeEnd: handleRightSidebarResizeEnd,
|
|
6967
|
-
children: /* @__PURE__ */
|
|
8682
|
+
children: /* @__PURE__ */ jsx45(FieldSideBar, {})
|
|
6968
8683
|
}
|
|
6969
8684
|
)
|
|
6970
8685
|
]
|
|
@@ -6972,11 +8687,11 @@ function PuckLayout({ children }) {
|
|
|
6972
8687
|
)
|
|
6973
8688
|
}
|
|
6974
8689
|
) }) }) }),
|
|
6975
|
-
/* @__PURE__ */
|
|
8690
|
+
/* @__PURE__ */ jsx45("div", { id: "puck-portal-root", className: getClassName31("portal") })
|
|
6976
8691
|
] });
|
|
6977
8692
|
}
|
|
6978
8693
|
function Puck(props) {
|
|
6979
|
-
return /* @__PURE__ */
|
|
8694
|
+
return /* @__PURE__ */ jsx45(PropsProvider, __spreadProps(__spreadValues({}, props), { children: /* @__PURE__ */ jsx45(PuckProvider, __spreadProps(__spreadValues({}, props), { children: /* @__PURE__ */ jsx45(PuckLayout, __spreadValues({}, props)) })) }));
|
|
6980
8695
|
}
|
|
6981
8696
|
Puck.Components = Components;
|
|
6982
8697
|
Puck.Fields = Fields;
|
|
@@ -7031,6 +8746,8 @@ export {
|
|
|
7031
8746
|
AutoField,
|
|
7032
8747
|
renderContext,
|
|
7033
8748
|
Render,
|
|
8749
|
+
registerOverlayPortal,
|
|
8750
|
+
setDeep,
|
|
7034
8751
|
DropZone,
|
|
7035
8752
|
Drawer,
|
|
7036
8753
|
createUsePuck,
|
|
@@ -7040,6 +8757,13 @@ export {
|
|
|
7040
8757
|
};
|
|
7041
8758
|
/*! Bundled license information:
|
|
7042
8759
|
|
|
8760
|
+
classnames/index.js:
|
|
8761
|
+
(*!
|
|
8762
|
+
Copyright (c) 2018 Jed Watson.
|
|
8763
|
+
Licensed under the MIT License (MIT), see
|
|
8764
|
+
http://jedwatson.github.io/classnames
|
|
8765
|
+
*)
|
|
8766
|
+
|
|
7043
8767
|
lucide-react/dist/esm/shared/src/utils.js:
|
|
7044
8768
|
(**
|
|
7045
8769
|
* @license lucide-react v0.468.0 - ISC
|