@measured/puck 0.17.0-canary.35170f8 → 0.17.0-canary.6e568de
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-7IH6SUIT.mjs → chunk-EXKSBUY5.mjs} +10 -0
- package/dist/index.css +83 -96
- package/dist/index.d.mts +24 -15
- package/dist/index.d.ts +24 -15
- package/dist/index.js +2654 -1268
- package/dist/index.mjs +2624 -1219
- package/dist/{resolve-all-data-Ch-Pcasj.d.mts → resolve-all-data-Fx9YY5bj.d.mts} +11 -1
- package/dist/{resolve-all-data-Ch-Pcasj.d.ts → resolve-all-data-Fx9YY5bj.d.ts} +11 -1
- package/dist/rsc.d.mts +2 -2
- package/dist/rsc.d.ts +2 -2
- package/dist/rsc.mjs +1 -1
- package/package.json +4 -2
package/dist/index.mjs
CHANGED
@@ -2,6 +2,9 @@ import {
|
|
2
2
|
__async,
|
3
3
|
__commonJS,
|
4
4
|
__objRest,
|
5
|
+
__privateAdd,
|
6
|
+
__privateGet,
|
7
|
+
__privateSet,
|
5
8
|
__spreadProps,
|
6
9
|
__spreadValues,
|
7
10
|
__toESM,
|
@@ -13,7 +16,7 @@ import {
|
|
13
16
|
resolveRootData,
|
14
17
|
rootDroppableId,
|
15
18
|
setupZone
|
16
|
-
} from "./chunk-
|
19
|
+
} from "./chunk-EXKSBUY5.mjs";
|
17
20
|
|
18
21
|
// ../../node_modules/classnames/index.js
|
19
22
|
var require_classnames = __commonJS({
|
@@ -73,6 +76,9 @@ init_react_import();
|
|
73
76
|
// types/API/index.ts
|
74
77
|
init_react_import();
|
75
78
|
|
79
|
+
// types/API/DropZone.ts
|
80
|
+
init_react_import();
|
81
|
+
|
76
82
|
// types/API/Viewports.ts
|
77
83
|
init_react_import();
|
78
84
|
|
@@ -117,26 +123,26 @@ init_react_import();
|
|
117
123
|
// lib/get-class-name-factory.ts
|
118
124
|
init_react_import();
|
119
125
|
var import_classnames = __toESM(require_classnames());
|
120
|
-
var getClassNameFactory = (rootClass,
|
126
|
+
var getClassNameFactory = (rootClass, styles2, config = { baseClass: "" }) => (options = {}) => {
|
121
127
|
if (typeof options === "string") {
|
122
128
|
const descendant = options;
|
123
|
-
const style =
|
129
|
+
const style = styles2[`${rootClass}-${descendant}`];
|
124
130
|
if (style) {
|
125
|
-
return config.baseClass +
|
131
|
+
return config.baseClass + styles2[`${rootClass}-${descendant}`] || "";
|
126
132
|
}
|
127
133
|
return "";
|
128
134
|
} else if (typeof options === "object") {
|
129
135
|
const modifiers = options;
|
130
136
|
const prefixedModifiers = {};
|
131
137
|
for (let modifier in modifiers) {
|
132
|
-
prefixedModifiers[
|
138
|
+
prefixedModifiers[styles2[`${rootClass}--${modifier}`]] = modifiers[modifier];
|
133
139
|
}
|
134
|
-
const c =
|
140
|
+
const c = styles2[rootClass];
|
135
141
|
return config.baseClass + (0, import_classnames.default)(__spreadValues({
|
136
142
|
[c]: !!c
|
137
143
|
}, prefixedModifiers));
|
138
144
|
} else {
|
139
|
-
return config.baseClass +
|
145
|
+
return config.baseClass + styles2[rootClass] || "";
|
140
146
|
}
|
141
147
|
};
|
142
148
|
var get_class_name_factory_default = getClassNameFactory;
|
@@ -588,7 +594,7 @@ var IconButton = ({
|
|
588
594
|
return el;
|
589
595
|
};
|
590
596
|
|
591
|
-
// components/Droppable/index.tsx
|
597
|
+
// components/LegacyDnd/Droppable/index.tsx
|
592
598
|
init_react_import();
|
593
599
|
import {
|
594
600
|
Droppable as DndDroppable
|
@@ -622,9 +628,6 @@ var defaultViewports = [
|
|
622
628
|
{ width: 1280, height: "auto", icon: "Monitor", label: "Large" }
|
623
629
|
];
|
624
630
|
|
625
|
-
// components/Puck/context.tsx
|
626
|
-
import { UAParser } from "ua-parser-js";
|
627
|
-
|
628
631
|
// lib/use-resolved-permissions.ts
|
629
632
|
init_react_import();
|
630
633
|
import { useCallback, useEffect, useState as useState2 } from "react";
|
@@ -905,7 +908,6 @@ var defaultContext = {
|
|
905
908
|
status: "LOADING",
|
906
909
|
setStatus: () => null,
|
907
910
|
iframe: {},
|
908
|
-
safariFallbackMode: false,
|
909
911
|
globalPermissions: {},
|
910
912
|
getPermissions: () => ({}),
|
911
913
|
refreshPermissions: () => null
|
@@ -920,24 +922,6 @@ var AppProvider = ({
|
|
920
922
|
useEffect3(() => {
|
921
923
|
setStatus("MOUNTED");
|
922
924
|
}, []);
|
923
|
-
const [safariFallbackMode, setSafariFallbackMode] = useState4(false);
|
924
|
-
useEffect3(() => {
|
925
|
-
var _a, _b, _c;
|
926
|
-
const ua = new UAParser(navigator.userAgent);
|
927
|
-
const { browser } = ua.getResult();
|
928
|
-
if (browser.name === "Safari" && (((_a = browser.version) == null ? void 0 : _a.indexOf("17.2.")) || ((_b = browser.version) == null ? void 0 : _b.indexOf("17.3.")) || ((_c = browser.version) == null ? void 0 : _c.indexOf("17.4.")))) {
|
929
|
-
if (process.env.NODE_ENV !== "production" && value.iframe.enabled) {
|
930
|
-
console.warn(
|
931
|
-
`Detected Safari ${browser.version}, which contains a bug that prevents Puck DropZones from detecting a mouseover event within an iframe. This affects Safari versions 17.2, 17.3 and 17.4.
|
932
|
-
|
933
|
-
Running in compatibility mode, which may have some DropZone side-effects. Alternatively, consider disabling iframes: https://puckeditor.com/docs/integrating-puck/viewports#opting-out-of-iframes.
|
934
|
-
|
935
|
-
See https://github.com/measuredco/puck/issues/411 for more information. This message will not show in production.`
|
936
|
-
);
|
937
|
-
}
|
938
|
-
setSafariFallbackMode(true);
|
939
|
-
}
|
940
|
-
}, []);
|
941
925
|
const selectedItem = value.state.ui.itemSelector ? getItem(value.state.ui.itemSelector, value.state.data) : void 0;
|
942
926
|
const [componentState, setComponentState] = useState4({});
|
943
927
|
const setComponentLoading = (id) => {
|
@@ -984,7 +968,6 @@ See https://github.com/measuredco/puck/issues/411 for more information. This mes
|
|
984
968
|
setZoomConfig,
|
985
969
|
status,
|
986
970
|
setStatus,
|
987
|
-
safariFallbackMode,
|
988
971
|
getPermissions,
|
989
972
|
refreshPermissions,
|
990
973
|
componentState,
|
@@ -1009,7 +992,7 @@ function useAppContext() {
|
|
1009
992
|
});
|
1010
993
|
}
|
1011
994
|
|
1012
|
-
// components/Droppable/index.tsx
|
995
|
+
// components/LegacyDnd/Droppable/index.tsx
|
1013
996
|
import { Fragment as Fragment2, jsx as jsx5 } from "react/jsx-runtime";
|
1014
997
|
var defaultProvided = {
|
1015
998
|
droppableProps: {
|
@@ -1032,7 +1015,7 @@ var Droppable = (props) => {
|
|
1032
1015
|
return /* @__PURE__ */ jsx5(El, __spreadValues({}, props));
|
1033
1016
|
};
|
1034
1017
|
|
1035
|
-
// components/Draggable/index.tsx
|
1018
|
+
// components/LegacyDnd/Draggable/index.tsx
|
1036
1019
|
init_react_import();
|
1037
1020
|
import {
|
1038
1021
|
Draggable as DndDraggable
|
@@ -1116,7 +1099,7 @@ import { jsx as jsx7 } from "react/jsx-runtime";
|
|
1116
1099
|
var getClassName4 = get_class_name_factory_default("DragIcon", styles_module_default5);
|
1117
1100
|
var DragIcon = ({ isDragDisabled }) => /* @__PURE__ */ jsx7("div", { className: getClassName4({ disabled: isDragDisabled }), children: /* @__PURE__ */ jsx7("svg", { viewBox: "0 0 20 20", width: "12", fill: "currentColor", children: /* @__PURE__ */ jsx7("path", { d: "M7 2a2 2 0 1 0 .001 4.001A2 2 0 0 0 7 2zm0 6a2 2 0 1 0 .001 4.001A2 2 0 0 0 7 8zm0 6a2 2 0 1 0 .001 4.001A2 2 0 0 0 7 14zm6-8a2 2 0 1 0-.001-4.001A2 2 0 0 0 13 6zm0 2a2 2 0 1 0 .001 4.001A2 2 0 0 0 13 8zm0 6a2 2 0 1 0 .001 4.001A2 2 0 0 0 13 14z" }) }) });
|
1118
1101
|
|
1119
|
-
// components/DragDropContext/index.tsx
|
1102
|
+
// components/LegacyDnd/DragDropContext/index.tsx
|
1120
1103
|
init_react_import();
|
1121
1104
|
import {
|
1122
1105
|
DragDropContext as DndDragDropContext
|
@@ -2249,105 +2232,49 @@ init_react_import();
|
|
2249
2232
|
|
2250
2233
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Drawer/styles.module.css#css-module
|
2251
2234
|
init_react_import();
|
2252
|
-
var styles_module_default10 = { "Drawer": "
|
2235
|
+
var styles_module_default10 = { "Drawer": "_Drawer_1ob9x_1", "DrawerItem-draggable": "_DrawerItem-draggable_1ob9x_8", "DrawerItem--disabled": "_DrawerItem--disabled_1ob9x_21", "DrawerItem": "_DrawerItem_1ob9x_8", "Drawer--isDraggingFrom": "_Drawer--isDraggingFrom_1ob9x_31", "DrawerItem-name": "_DrawerItem-name_1ob9x_49" };
|
2253
2236
|
|
2254
2237
|
// components/Drawer/index.tsx
|
2238
|
+
import { useMemo as useMemo5, useState as useState16 } from "react";
|
2239
|
+
|
2240
|
+
// components/DragDropContext/index.tsx
|
2241
|
+
init_react_import();
|
2242
|
+
import { DragDropProvider } from "@dnd-kit/react";
|
2255
2243
|
import {
|
2256
|
-
createContext as
|
2257
|
-
|
2258
|
-
|
2244
|
+
createContext as createContext3,
|
2245
|
+
useCallback as useCallback9,
|
2246
|
+
useContext as useContext4,
|
2247
|
+
useEffect as useEffect13,
|
2248
|
+
useRef as useRef5,
|
2249
|
+
useState as useState15
|
2259
2250
|
} from "react";
|
2260
|
-
import {
|
2261
|
-
var getClassName16 = get_class_name_factory_default("Drawer", styles_module_default10);
|
2262
|
-
var getClassNameItem2 = get_class_name_factory_default("DrawerItem", styles_module_default10);
|
2263
|
-
var drawerContext = createContext2({
|
2264
|
-
droppableId: ""
|
2265
|
-
});
|
2266
|
-
var DrawerDraggable = ({
|
2267
|
-
children,
|
2268
|
-
id,
|
2269
|
-
index,
|
2270
|
-
isDragDisabled
|
2271
|
-
}) => {
|
2272
|
-
return /* @__PURE__ */ jsx21(
|
2273
|
-
Draggable,
|
2274
|
-
{
|
2275
|
-
id,
|
2276
|
-
index,
|
2277
|
-
isDragDisabled,
|
2278
|
-
showShadow: true,
|
2279
|
-
disableAnimations: true,
|
2280
|
-
className: () => getClassNameItem2({ disabled: isDragDisabled }),
|
2281
|
-
children: () => children
|
2282
|
-
},
|
2283
|
-
id
|
2284
|
-
);
|
2285
|
-
};
|
2286
|
-
var DrawerItem = ({
|
2287
|
-
name,
|
2288
|
-
children,
|
2289
|
-
id,
|
2290
|
-
label,
|
2291
|
-
index,
|
2292
|
-
isDragDisabled
|
2293
|
-
}) => {
|
2294
|
-
const ctx = useContext2(drawerContext);
|
2295
|
-
const resolvedId = `${ctx.droppableId}::${id || name}`;
|
2296
|
-
const CustomInner = useMemo3(
|
2297
|
-
() => children || (({ children: children2, name: name2 }) => /* @__PURE__ */ jsx21("div", { className: getClassNameItem2("default"), children: children2 })),
|
2298
|
-
[children]
|
2299
|
-
);
|
2300
|
-
return /* @__PURE__ */ jsx21(
|
2301
|
-
DrawerDraggable,
|
2302
|
-
{
|
2303
|
-
id: resolvedId,
|
2304
|
-
index,
|
2305
|
-
isDragDisabled,
|
2306
|
-
children: /* @__PURE__ */ jsx21(CustomInner, { name, children: /* @__PURE__ */ jsx21("div", { className: getClassNameItem2("draggableWrapper"), children: /* @__PURE__ */ jsxs10("div", { className: getClassNameItem2("draggable"), children: [
|
2307
|
-
/* @__PURE__ */ jsx21("div", { className: getClassNameItem2("name"), children: label != null ? label : name }),
|
2308
|
-
/* @__PURE__ */ jsx21("div", { className: getClassNameItem2("icon"), children: /* @__PURE__ */ jsx21(DragIcon, { isDragDisabled }) })
|
2309
|
-
] }) }) })
|
2310
|
-
}
|
2311
|
-
);
|
2312
|
-
};
|
2313
|
-
var Drawer = ({
|
2314
|
-
children,
|
2315
|
-
droppableId: _droppableId = "default",
|
2316
|
-
direction = "vertical"
|
2317
|
-
}) => {
|
2318
|
-
const droppableId = `component-list:${_droppableId}`;
|
2319
|
-
return /* @__PURE__ */ jsx21(drawerContext.Provider, { value: { droppableId }, children: /* @__PURE__ */ jsx21(Droppable, { droppableId, isDropDisabled: true, direction, children: (provided, snapshot) => /* @__PURE__ */ jsxs10(
|
2320
|
-
"div",
|
2321
|
-
__spreadProps(__spreadValues({}, provided.droppableProps), {
|
2322
|
-
ref: provided.innerRef,
|
2323
|
-
className: getClassName16({
|
2324
|
-
isDraggingFrom: !!snapshot.draggingFromThisWith
|
2325
|
-
}),
|
2326
|
-
children: [
|
2327
|
-
children,
|
2328
|
-
/* @__PURE__ */ jsx21("span", { style: { display: "none" }, children: provided.placeholder })
|
2329
|
-
]
|
2330
|
-
})
|
2331
|
-
) }) });
|
2332
|
-
};
|
2333
|
-
Drawer.Item = DrawerItem;
|
2251
|
+
import { defaultPreset } from "@dnd-kit/dom";
|
2334
2252
|
|
2335
2253
|
// components/DropZone/index.tsx
|
2336
2254
|
init_react_import();
|
2337
|
-
import {
|
2255
|
+
import {
|
2256
|
+
useCallback as useCallback8,
|
2257
|
+
useContext as useContext3,
|
2258
|
+
useEffect as useEffect12,
|
2259
|
+
useMemo as useMemo4,
|
2260
|
+
useRef as useRef4,
|
2261
|
+
useState as useState14
|
2262
|
+
} from "react";
|
2338
2263
|
|
2339
2264
|
// components/DraggableComponent/index.tsx
|
2340
2265
|
init_react_import();
|
2341
2266
|
import {
|
2267
|
+
useCallback as useCallback6,
|
2268
|
+
useContext as useContext2,
|
2342
2269
|
useEffect as useEffect11,
|
2343
|
-
useMemo as
|
2270
|
+
useMemo as useMemo3,
|
2271
|
+
useRef as useRef3,
|
2344
2272
|
useState as useState12
|
2345
2273
|
} from "react";
|
2346
|
-
import { Draggable as Draggable2 } from "@measured/dnd";
|
2347
2274
|
|
2348
2275
|
// css-module:/home/runner/work/puck/puck/packages/core/components/DraggableComponent/styles.module.css#css-module
|
2349
2276
|
init_react_import();
|
2350
|
-
var styles_module_default11 = { "DraggableComponent": "
|
2277
|
+
var styles_module_default11 = { "DraggableComponent": "_DraggableComponent_1uqah_1", "DraggableComponent-overlay": "_DraggableComponent-overlay_1uqah_12", "DraggableComponent-loadingOverlay": "_DraggableComponent-loadingOverlay_1uqah_29", "DraggableComponent--hover": "_DraggableComponent--hover_1uqah_45", "DraggableComponent--isLocked": "_DraggableComponent--isLocked_1uqah_45", "DraggableComponent--isSelected": "_DraggableComponent--isSelected_1uqah_54", "DraggableComponent-actionsOverlay": "_DraggableComponent-actionsOverlay_1uqah_66", "DraggableComponent-actions": "_DraggableComponent-actions_1uqah_66" };
|
2351
2278
|
|
2352
2279
|
// lib/use-modifier-held.ts
|
2353
2280
|
init_react_import();
|
@@ -2375,183 +2302,768 @@ var useModifierHeld = (modifier) => {
|
|
2375
2302
|
return modifierHeld;
|
2376
2303
|
};
|
2377
2304
|
|
2378
|
-
//
|
2305
|
+
// components/DraggableComponent/index.tsx
|
2306
|
+
import { createPortal as createPortal2 } from "react-dom";
|
2307
|
+
|
2308
|
+
// components/DraggableComponent/collision/dynamic/index.ts
|
2309
|
+
init_react_import();
|
2310
|
+
import {
|
2311
|
+
CollisionPriority as CollisionPriority7,
|
2312
|
+
CollisionType as CollisionType7
|
2313
|
+
} from "@dnd-kit/abstract";
|
2314
|
+
|
2315
|
+
// components/DraggableComponent/collision/directional/index.ts
|
2316
|
+
init_react_import();
|
2317
|
+
import { CollisionType } from "@dnd-kit/abstract";
|
2318
|
+
|
2319
|
+
// components/DraggableComponent/collision/collision-debug.ts
|
2320
|
+
init_react_import();
|
2321
|
+
var DEBUG = false;
|
2322
|
+
var debugElements = {};
|
2323
|
+
var timeout;
|
2324
|
+
var collisionDebug = (a, b, id, color, label) => {
|
2325
|
+
if (!DEBUG) return;
|
2326
|
+
const debugId = `${id}-debug`;
|
2327
|
+
clearTimeout(timeout);
|
2328
|
+
timeout = setTimeout(() => {
|
2329
|
+
Object.entries(debugElements).forEach(([id2, { svg }]) => {
|
2330
|
+
svg.remove();
|
2331
|
+
delete debugElements[id2];
|
2332
|
+
});
|
2333
|
+
}, 1e3);
|
2334
|
+
requestAnimationFrame(() => {
|
2335
|
+
var _a, _b;
|
2336
|
+
const existingEl = debugElements[debugId];
|
2337
|
+
let line = (_a = debugElements[debugId]) == null ? void 0 : _a.line;
|
2338
|
+
let text = (_b = debugElements[debugId]) == null ? void 0 : _b.text;
|
2339
|
+
if (!existingEl) {
|
2340
|
+
const svgNs = "http://www.w3.org/2000/svg";
|
2341
|
+
const svg = document.createElementNS(svgNs, "svg");
|
2342
|
+
line = document.createElementNS(svgNs, "line");
|
2343
|
+
text = document.createElementNS(svgNs, "text");
|
2344
|
+
svg.setAttribute("id", debugId);
|
2345
|
+
svg.setAttribute(
|
2346
|
+
"style",
|
2347
|
+
"position: fixed; height: 100%; width: 100%; pointer-events: none;"
|
2348
|
+
);
|
2349
|
+
svg.appendChild(line);
|
2350
|
+
svg.appendChild(text);
|
2351
|
+
text.setAttribute("fill", `black`);
|
2352
|
+
document.body.appendChild(svg);
|
2353
|
+
debugElements[debugId] = { svg, line, text };
|
2354
|
+
}
|
2355
|
+
line.setAttribute("x1", a.x.toString());
|
2356
|
+
line.setAttribute("x2", b.x.toString());
|
2357
|
+
line.setAttribute("y1", a.y.toString());
|
2358
|
+
line.setAttribute("y2", b.y.toString());
|
2359
|
+
line.setAttribute("style", `stroke:${color};stroke-width:2`);
|
2360
|
+
text.setAttribute("x", (a.x - (a.x - b.x) / 2).toString());
|
2361
|
+
text.setAttribute("y", (a.y - (a.y - b.y) / 2).toString());
|
2362
|
+
if (label) {
|
2363
|
+
text.innerHTML = label;
|
2364
|
+
}
|
2365
|
+
});
|
2366
|
+
};
|
2367
|
+
|
2368
|
+
// components/DraggableComponent/collision/directional/index.ts
|
2369
|
+
var distanceChange = "increasing";
|
2370
|
+
var directionalCollision = (input, previous) => {
|
2371
|
+
var _a;
|
2372
|
+
const { dragOperation, droppable } = input;
|
2373
|
+
const { shape: dropShape } = droppable;
|
2374
|
+
const { position } = dragOperation;
|
2375
|
+
const dragShape = (_a = dragOperation.shape) == null ? void 0 : _a.current;
|
2376
|
+
if (!dragShape || !dropShape) return null;
|
2377
|
+
const dropCenter = dropShape.center;
|
2378
|
+
const distanceToPrevious = Math.sqrt(
|
2379
|
+
Math.pow(dropCenter.x - previous.x, 2) + Math.pow(dropCenter.y - previous.y, 2)
|
2380
|
+
);
|
2381
|
+
const distanceToCurrent = Math.sqrt(
|
2382
|
+
Math.pow(dropCenter.x - position.current.x, 2) + Math.pow(dropCenter.y - position.current.y, 2)
|
2383
|
+
);
|
2384
|
+
distanceChange = distanceToCurrent === distanceToPrevious ? distanceChange : distanceToCurrent < distanceToPrevious ? "decreasing" : "increasing";
|
2385
|
+
collisionDebug(
|
2386
|
+
dragShape.center,
|
2387
|
+
dropCenter,
|
2388
|
+
droppable.id.toString(),
|
2389
|
+
"rebeccapurple"
|
2390
|
+
);
|
2391
|
+
if (distanceChange === "decreasing") {
|
2392
|
+
return {
|
2393
|
+
id: droppable.id,
|
2394
|
+
value: 1,
|
2395
|
+
type: CollisionType.Collision
|
2396
|
+
};
|
2397
|
+
}
|
2398
|
+
return null;
|
2399
|
+
};
|
2400
|
+
|
2401
|
+
// components/DraggableComponent/collision/dynamic/get-direction.ts
|
2402
|
+
init_react_import();
|
2403
|
+
var getDirection = (dragAxis, delta) => {
|
2404
|
+
if (dragAxis === "dynamic") {
|
2405
|
+
if (Math.abs(delta.y) > Math.abs(delta.x)) {
|
2406
|
+
return delta.y === 0 ? null : delta.y > 0 ? "down" : "up";
|
2407
|
+
} else {
|
2408
|
+
return delta.x === 0 ? null : delta.x > 0 ? "right" : "left";
|
2409
|
+
}
|
2410
|
+
} else if (dragAxis === "x") {
|
2411
|
+
return delta.x === 0 ? null : delta.x > 0 ? "right" : "left";
|
2412
|
+
}
|
2413
|
+
return delta.y === 0 ? null : delta.y > 0 ? "down" : "up";
|
2414
|
+
};
|
2415
|
+
|
2416
|
+
// components/DraggableComponent/collision/dynamic/get-midpoint-impact.ts
|
2417
|
+
init_react_import();
|
2418
|
+
var getMidpointImpact = (dragShape, dropShape, direction, offsetMultiplier = 0) => {
|
2419
|
+
const dragRect = dragShape.boundingRectangle;
|
2420
|
+
const dropCenter = dropShape.center;
|
2421
|
+
if (direction === "down") {
|
2422
|
+
const offset2 = offsetMultiplier * dropShape.boundingRectangle.height;
|
2423
|
+
return dragRect.bottom >= dropCenter.y + offset2;
|
2424
|
+
} else if (direction === "up") {
|
2425
|
+
const offset2 = offsetMultiplier * dropShape.boundingRectangle.height;
|
2426
|
+
return dragRect.top < dropCenter.y - offset2;
|
2427
|
+
} else if (direction === "left") {
|
2428
|
+
const offset2 = offsetMultiplier * dropShape.boundingRectangle.width;
|
2429
|
+
return dropCenter.x - offset2 >= dragRect.left;
|
2430
|
+
}
|
2431
|
+
const offset = offsetMultiplier * dropShape.boundingRectangle.width;
|
2432
|
+
return dragRect.right - offset >= dropCenter.x;
|
2433
|
+
};
|
2434
|
+
|
2435
|
+
// components/DraggableComponent/collision/dynamic/track-movement-interval.ts
|
2436
|
+
init_react_import();
|
2437
|
+
import { Point } from "@dnd-kit/geometry";
|
2438
|
+
var INTERVAL_SENSITIVITY = 10;
|
2439
|
+
var intervalCache = {
|
2440
|
+
current: { x: 0, y: 0 },
|
2441
|
+
delta: { x: 0, y: 0 },
|
2442
|
+
previous: { x: 0, y: 0 },
|
2443
|
+
direction: null
|
2444
|
+
};
|
2445
|
+
var trackMovementInterval = (point, dragAxis = "dynamic") => {
|
2446
|
+
intervalCache.current = point;
|
2447
|
+
intervalCache.delta = {
|
2448
|
+
x: point.x - intervalCache.previous.x,
|
2449
|
+
y: point.y - intervalCache.previous.y
|
2450
|
+
};
|
2451
|
+
intervalCache.direction = getDirection(dragAxis, intervalCache.delta) || intervalCache.direction;
|
2452
|
+
if (Math.abs(intervalCache.delta.x) > INTERVAL_SENSITIVITY || Math.abs(intervalCache.delta.y) > INTERVAL_SENSITIVITY) {
|
2453
|
+
intervalCache.previous = Point.from(point);
|
2454
|
+
}
|
2455
|
+
return intervalCache;
|
2456
|
+
};
|
2457
|
+
|
2458
|
+
// ../../node_modules/@dnd-kit/collision/dist/index.js
|
2459
|
+
init_react_import();
|
2460
|
+
import { CollisionPriority, CollisionType as CollisionType2 } from "@dnd-kit/abstract";
|
2461
|
+
import { Point as Point2 } from "@dnd-kit/geometry";
|
2462
|
+
import { CollisionPriority as CollisionPriority2, CollisionType as CollisionType22 } from "@dnd-kit/abstract";
|
2463
|
+
import { Point as Point22 } from "@dnd-kit/geometry";
|
2464
|
+
import { CollisionPriority as CollisionPriority3, CollisionType as CollisionType3 } from "@dnd-kit/abstract";
|
2465
|
+
import { Point as Point3 } from "@dnd-kit/geometry";
|
2466
|
+
import { CollisionPriority as CollisionPriority4, CollisionType as CollisionType4 } from "@dnd-kit/abstract";
|
2467
|
+
import { Point as Point4 } from "@dnd-kit/geometry";
|
2468
|
+
import { CollisionPriority as CollisionPriority5, CollisionType as CollisionType5 } from "@dnd-kit/abstract";
|
2469
|
+
import { Point as Point5 } from "@dnd-kit/geometry";
|
2470
|
+
import { CollisionPriority as CollisionPriority6, CollisionType as CollisionType6 } from "@dnd-kit/abstract";
|
2471
|
+
import { Point as Point6 } from "@dnd-kit/geometry";
|
2472
|
+
var pointerIntersection = ({
|
2473
|
+
dragOperation,
|
2474
|
+
droppable
|
2475
|
+
}) => {
|
2476
|
+
const pointerCoordinates = dragOperation.position.current;
|
2477
|
+
if (!pointerCoordinates) {
|
2478
|
+
return null;
|
2479
|
+
}
|
2480
|
+
const { id } = droppable;
|
2481
|
+
if (!droppable.shape) {
|
2482
|
+
return null;
|
2483
|
+
}
|
2484
|
+
if (droppable.shape.containsPoint(pointerCoordinates)) {
|
2485
|
+
const distance = Point2.distance(droppable.shape.center, pointerCoordinates);
|
2486
|
+
return {
|
2487
|
+
id,
|
2488
|
+
value: 1 / distance,
|
2489
|
+
type: CollisionType2.PointerIntersection,
|
2490
|
+
priority: CollisionPriority.High
|
2491
|
+
};
|
2492
|
+
}
|
2493
|
+
return null;
|
2494
|
+
};
|
2495
|
+
var closestCorners = (input) => {
|
2496
|
+
const { dragOperation, droppable } = input;
|
2497
|
+
const { shape, position } = dragOperation;
|
2498
|
+
if (!droppable.shape) {
|
2499
|
+
return null;
|
2500
|
+
}
|
2501
|
+
const { left, top, right, bottom } = droppable.shape.boundingRectangle;
|
2502
|
+
const corners = [
|
2503
|
+
{
|
2504
|
+
x: left,
|
2505
|
+
y: top
|
2506
|
+
},
|
2507
|
+
{
|
2508
|
+
x: right,
|
2509
|
+
y: top
|
2510
|
+
},
|
2511
|
+
{
|
2512
|
+
x: left,
|
2513
|
+
y: bottom
|
2514
|
+
},
|
2515
|
+
{
|
2516
|
+
x: right,
|
2517
|
+
y: bottom
|
2518
|
+
}
|
2519
|
+
];
|
2520
|
+
const distance = corners.reduce(
|
2521
|
+
(acc, corner) => {
|
2522
|
+
var _a;
|
2523
|
+
return acc + Point3.distance(
|
2524
|
+
Point3.from(corner),
|
2525
|
+
(_a = shape == null ? void 0 : shape.current.center) != null ? _a : position.current
|
2526
|
+
);
|
2527
|
+
},
|
2528
|
+
0
|
2529
|
+
);
|
2530
|
+
const value = distance / 4;
|
2531
|
+
return {
|
2532
|
+
id: droppable.id,
|
2533
|
+
value: 1 / value,
|
2534
|
+
type: CollisionType3.Collision,
|
2535
|
+
priority: CollisionPriority3.Normal
|
2536
|
+
};
|
2537
|
+
};
|
2538
|
+
|
2539
|
+
// components/DraggableComponent/collision/dynamic/index.ts
|
2540
|
+
var flushNext = "";
|
2541
|
+
var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input) => {
|
2542
|
+
var _a, _b, _c, _d, _e;
|
2543
|
+
const { dragOperation, droppable } = input;
|
2544
|
+
const { position } = dragOperation;
|
2545
|
+
const dragShape = (_a = dragOperation.shape) == null ? void 0 : _a.current;
|
2546
|
+
const { shape: dropShape } = droppable;
|
2547
|
+
if (!dragShape || !dropShape) {
|
2548
|
+
return null;
|
2549
|
+
}
|
2550
|
+
const { center: dragCenter } = dragShape;
|
2551
|
+
const interval = trackMovementInterval(position.current, dragAxis);
|
2552
|
+
dragOperation.data = __spreadProps(__spreadValues({}, dragOperation.data), {
|
2553
|
+
direction: interval.direction
|
2554
|
+
});
|
2555
|
+
const collisionMap = dragOperation.data.collisionMap || {};
|
2556
|
+
dragOperation.data.collisionMap = collisionMap;
|
2557
|
+
collisionMap[droppable.id] = {
|
2558
|
+
direction: interval.direction
|
2559
|
+
};
|
2560
|
+
const { center: dropCenter } = dropShape;
|
2561
|
+
const overMidpoint = getMidpointImpact(
|
2562
|
+
dragShape,
|
2563
|
+
dropShape,
|
2564
|
+
interval.direction,
|
2565
|
+
midpointOffset
|
2566
|
+
);
|
2567
|
+
if (((_b = dragOperation.source) == null ? void 0 : _b.id) === droppable.id) {
|
2568
|
+
const collision = directionalCollision(input, interval.previous);
|
2569
|
+
collisionDebug(dragCenter, dropCenter, droppable.id.toString(), "yellow");
|
2570
|
+
if (collision) {
|
2571
|
+
return __spreadProps(__spreadValues({}, collision), {
|
2572
|
+
priority: CollisionPriority7.Highest
|
2573
|
+
});
|
2574
|
+
}
|
2575
|
+
}
|
2576
|
+
const intersectionArea = dragShape.intersectionArea(dropShape);
|
2577
|
+
const intersectionRatio = intersectionArea / dropShape.area;
|
2578
|
+
if (intersectionArea && overMidpoint) {
|
2579
|
+
collisionDebug(
|
2580
|
+
dragCenter,
|
2581
|
+
dropCenter,
|
2582
|
+
droppable.id.toString(),
|
2583
|
+
"green",
|
2584
|
+
interval.direction
|
2585
|
+
);
|
2586
|
+
const collision = {
|
2587
|
+
id: droppable.id,
|
2588
|
+
value: intersectionRatio,
|
2589
|
+
priority: CollisionPriority7.High,
|
2590
|
+
type: CollisionType7.Collision
|
2591
|
+
};
|
2592
|
+
const shouldFlushId = flushNext === droppable.id;
|
2593
|
+
flushNext = "";
|
2594
|
+
return __spreadProps(__spreadValues({}, collision), { id: shouldFlushId ? "flush" : collision.id });
|
2595
|
+
}
|
2596
|
+
if (((_c = dragOperation.source) == null ? void 0 : _c.id) !== droppable.id) {
|
2597
|
+
const xAxisIntersection = dropShape.boundingRectangle.right > dragShape.boundingRectangle.left && dropShape.boundingRectangle.left < dragShape.boundingRectangle.right;
|
2598
|
+
const yAxisIntersection = dropShape.boundingRectangle.bottom > dragShape.boundingRectangle.top && dropShape.boundingRectangle.top < dragShape.boundingRectangle.bottom;
|
2599
|
+
if (dragAxis === "y" && xAxisIntersection || yAxisIntersection) {
|
2600
|
+
const fallbackCollision = closestCorners(input);
|
2601
|
+
if (fallbackCollision) {
|
2602
|
+
const direction = getDirection(dragAxis, {
|
2603
|
+
x: dragShape.center.x - (((_d = droppable.shape) == null ? void 0 : _d.center.x) || 0),
|
2604
|
+
y: dragShape.center.y - (((_e = droppable.shape) == null ? void 0 : _e.center.y) || 0)
|
2605
|
+
});
|
2606
|
+
collisionMap[droppable.id] = {
|
2607
|
+
direction
|
2608
|
+
};
|
2609
|
+
if (intersectionArea) {
|
2610
|
+
collisionDebug(
|
2611
|
+
dragCenter,
|
2612
|
+
dropCenter,
|
2613
|
+
droppable.id.toString(),
|
2614
|
+
"red",
|
2615
|
+
direction || ""
|
2616
|
+
);
|
2617
|
+
flushNext = droppable.id;
|
2618
|
+
return __spreadProps(__spreadValues({}, fallbackCollision), {
|
2619
|
+
priority: CollisionPriority7.Low
|
2620
|
+
});
|
2621
|
+
}
|
2622
|
+
collisionDebug(
|
2623
|
+
dragCenter,
|
2624
|
+
dropCenter,
|
2625
|
+
droppable.id.toString(),
|
2626
|
+
"orange",
|
2627
|
+
direction || ""
|
2628
|
+
);
|
2629
|
+
return __spreadProps(__spreadValues({}, fallbackCollision), { priority: CollisionPriority7.Lowest });
|
2630
|
+
}
|
2631
|
+
}
|
2632
|
+
}
|
2633
|
+
collisionDebug(dragCenter, dropCenter, droppable.id.toString(), "hotpink");
|
2634
|
+
delete collisionMap[droppable.id];
|
2635
|
+
return null;
|
2636
|
+
};
|
2637
|
+
|
2638
|
+
// lib/dnd-kit/safe.ts
|
2639
|
+
init_react_import();
|
2640
|
+
import {
|
2641
|
+
useDraggable,
|
2642
|
+
useDroppable
|
2643
|
+
} from "@dnd-kit/react";
|
2644
|
+
import { useSortable } from "@dnd-kit/react/sortable";
|
2645
|
+
function useDroppableSafe(input) {
|
2646
|
+
if (typeof window === "undefined") {
|
2647
|
+
return { ref: () => {
|
2648
|
+
} };
|
2649
|
+
}
|
2650
|
+
return useDroppable(input);
|
2651
|
+
}
|
2652
|
+
function useDraggableSafe(input) {
|
2653
|
+
if (typeof window === "undefined") {
|
2654
|
+
return { ref: () => {
|
2655
|
+
} };
|
2656
|
+
}
|
2657
|
+
return useDraggable(input);
|
2658
|
+
}
|
2659
|
+
function useSortableSafe(input) {
|
2660
|
+
if (typeof window === "undefined") {
|
2661
|
+
return { ref: () => {
|
2662
|
+
}, status: "idle" };
|
2663
|
+
}
|
2664
|
+
return useSortable(input);
|
2665
|
+
}
|
2666
|
+
|
2667
|
+
// lib/get-deep-scroll-position.ts
|
2379
2668
|
init_react_import();
|
2380
|
-
|
2381
|
-
|
2382
|
-
|
2383
|
-
|
2384
|
-
|
2385
|
-
|
2386
|
-
|
2387
|
-
|
2388
|
-
|
2669
|
+
function getDeepScrollPosition(element) {
|
2670
|
+
let totalScroll = {
|
2671
|
+
x: 0,
|
2672
|
+
y: 0
|
2673
|
+
};
|
2674
|
+
let current = element;
|
2675
|
+
while (current && current !== document.documentElement) {
|
2676
|
+
const parent = current.parentElement;
|
2677
|
+
if (parent) {
|
2678
|
+
totalScroll.x += parent.scrollLeft;
|
2679
|
+
totalScroll.y += parent.scrollTop;
|
2680
|
+
}
|
2681
|
+
current = parent;
|
2682
|
+
}
|
2683
|
+
return totalScroll;
|
2684
|
+
}
|
2389
2685
|
|
2390
2686
|
// components/DraggableComponent/index.tsx
|
2391
|
-
import { jsx as
|
2392
|
-
var
|
2687
|
+
import { jsx as jsx21, jsxs as jsxs10 } from "react/jsx-runtime";
|
2688
|
+
var getClassName16 = get_class_name_factory_default("DraggableComponent", styles_module_default11);
|
2689
|
+
var DEBUG2 = false;
|
2393
2690
|
var space = 8;
|
2394
2691
|
var actionsOverlayTop = space * 6.5;
|
2395
2692
|
var actionsTop = -(actionsOverlayTop - 8);
|
2396
|
-
var
|
2693
|
+
var actionsSide = space;
|
2397
2694
|
var DefaultActionBar = ({
|
2398
2695
|
label,
|
2399
2696
|
children
|
2400
|
-
}) => /* @__PURE__ */
|
2697
|
+
}) => /* @__PURE__ */ jsx21(ActionBar, { label, children: /* @__PURE__ */ jsx21(ActionBar.Group, { children }) });
|
2401
2698
|
var DraggableComponent = ({
|
2402
2699
|
children,
|
2700
|
+
depth,
|
2701
|
+
componentType,
|
2403
2702
|
id,
|
2404
2703
|
index,
|
2704
|
+
zoneCompound,
|
2405
2705
|
isLoading = false,
|
2406
2706
|
isSelected = false,
|
2407
|
-
onClick = () => null,
|
2408
|
-
onMount = () => null,
|
2409
|
-
onMouseDown = () => null,
|
2410
|
-
onMouseUp = () => null,
|
2411
|
-
onMouseOver = () => null,
|
2412
|
-
onMouseOut = () => null,
|
2413
|
-
onDelete = () => null,
|
2414
|
-
onDuplicate = () => null,
|
2415
2707
|
debug,
|
2416
2708
|
label,
|
2417
|
-
|
2418
|
-
|
2419
|
-
|
2420
|
-
|
2421
|
-
style
|
2709
|
+
isEnabled,
|
2710
|
+
autoDragAxis,
|
2711
|
+
userDragAxis,
|
2712
|
+
inDroppableZone = true
|
2422
2713
|
}) => {
|
2423
|
-
const {
|
2714
|
+
const {
|
2715
|
+
zoomConfig,
|
2716
|
+
overrides,
|
2717
|
+
selectedItem,
|
2718
|
+
getPermissions,
|
2719
|
+
dispatch,
|
2720
|
+
iframe,
|
2721
|
+
state
|
2722
|
+
} = useAppContext();
|
2424
2723
|
const isModifierHeld = useModifierHeld("Alt");
|
2425
|
-
const
|
2426
|
-
|
2427
|
-
const
|
2724
|
+
const ctx = useContext2(dropZoneContext);
|
2725
|
+
const [localZones, setLocalZones] = useState12({});
|
2726
|
+
const registerLocalZone = useCallback6(
|
2727
|
+
(zoneCompound2, active) => {
|
2728
|
+
var _a;
|
2729
|
+
(_a = ctx == null ? void 0 : ctx.registerLocalZone) == null ? void 0 : _a.call(ctx, zoneCompound2, active);
|
2730
|
+
setLocalZones((obj) => __spreadProps(__spreadValues({}, obj), {
|
2731
|
+
[zoneCompound2]: active
|
2732
|
+
}));
|
2733
|
+
},
|
2734
|
+
[setLocalZones]
|
2735
|
+
);
|
2736
|
+
const containsActiveZone = Object.values(localZones).filter(Boolean).length > 0;
|
2737
|
+
const { path = [] } = ctx || {};
|
2738
|
+
const [canDrag, setCanDrag] = useState12(false);
|
2428
2739
|
useEffect11(() => {
|
2429
|
-
|
2430
|
-
|
2740
|
+
var _a;
|
2741
|
+
const item = getItem({ index, zone: zoneCompound }, state.data);
|
2742
|
+
if (item) {
|
2743
|
+
const perms = getPermissions({
|
2744
|
+
item
|
2745
|
+
});
|
2746
|
+
setCanDrag((_a = perms.drag) != null ? _a : true);
|
2431
2747
|
}
|
2432
|
-
}, []);
|
2433
|
-
const
|
2748
|
+
}, [state, index, zoneCompound, getPermissions]);
|
2749
|
+
const userIsDragging = !!(ctx == null ? void 0 : ctx.draggedItem);
|
2750
|
+
const canCollide = canDrag || userIsDragging;
|
2751
|
+
const disabled = !isEnabled || !canCollide;
|
2752
|
+
const [dragAxis, setDragAxis] = useState12(userDragAxis || autoDragAxis);
|
2753
|
+
const { ref: sortableRef, status } = useSortableSafe({
|
2754
|
+
id,
|
2755
|
+
index,
|
2756
|
+
group: zoneCompound,
|
2757
|
+
type: "component",
|
2758
|
+
data: {
|
2759
|
+
zone: zoneCompound,
|
2760
|
+
index,
|
2761
|
+
componentType,
|
2762
|
+
containsActiveZone,
|
2763
|
+
depth,
|
2764
|
+
path,
|
2765
|
+
inDroppableZone
|
2766
|
+
},
|
2767
|
+
collisionPriority: isEnabled ? depth : 0,
|
2768
|
+
collisionDetector: createDynamicCollisionDetector(dragAxis),
|
2769
|
+
disabled,
|
2770
|
+
// "Out of the way" transition from react-beautiful-dnd
|
2771
|
+
transition: {
|
2772
|
+
duration: 200,
|
2773
|
+
easing: "cubic-bezier(0.2, 0, 0, 1)"
|
2774
|
+
}
|
2775
|
+
});
|
2776
|
+
const thisIsDragging = status === "dragging";
|
2777
|
+
const ref = useRef3();
|
2778
|
+
const refSetter = useCallback6(
|
2779
|
+
(el) => {
|
2780
|
+
sortableRef(el);
|
2781
|
+
if (el) {
|
2782
|
+
ref.current = el;
|
2783
|
+
}
|
2784
|
+
},
|
2785
|
+
[sortableRef]
|
2786
|
+
);
|
2787
|
+
const [portalEl, setPortalEl] = useState12();
|
2788
|
+
useEffect11(() => {
|
2789
|
+
var _a, _b, _c;
|
2790
|
+
setPortalEl(
|
2791
|
+
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
|
2792
|
+
);
|
2793
|
+
}, [iframe.enabled, ref.current]);
|
2794
|
+
const getStyle = useCallback6(() => {
|
2795
|
+
var _a, _b, _c;
|
2796
|
+
if (!ref.current) return;
|
2797
|
+
const rect = ref.current.getBoundingClientRect();
|
2798
|
+
const deepScrollPosition = getDeepScrollPosition(ref.current);
|
2799
|
+
const portalContainerEl = iframe.enabled ? null : (_a = ref.current) == null ? void 0 : _a.closest("[data-puck-preview]");
|
2800
|
+
const portalContainerRect = portalContainerEl == null ? void 0 : portalContainerEl.getBoundingClientRect();
|
2801
|
+
const portalScroll = portalContainerEl ? getDeepScrollPosition(portalContainerEl) : { x: 0, y: 0 };
|
2802
|
+
const scroll = {
|
2803
|
+
x: deepScrollPosition.x - portalScroll.x - ((_b = portalContainerRect == null ? void 0 : portalContainerRect.left) != null ? _b : 0),
|
2804
|
+
y: deepScrollPosition.y - portalScroll.y - ((_c = portalContainerRect == null ? void 0 : portalContainerRect.top) != null ? _c : 0)
|
2805
|
+
};
|
2806
|
+
const style2 = {
|
2807
|
+
left: `${rect.left + scroll.x}px`,
|
2808
|
+
top: `${rect.top + scroll.y}px`,
|
2809
|
+
height: `${rect.height}px`,
|
2810
|
+
width: `${rect.width}px`
|
2811
|
+
};
|
2812
|
+
return style2;
|
2813
|
+
}, [ref.current]);
|
2814
|
+
const [style, setStyle] = useState12();
|
2815
|
+
const sync = useCallback6(() => {
|
2816
|
+
setStyle(getStyle());
|
2817
|
+
}, [ref.current, iframe]);
|
2818
|
+
useEffect11(() => {
|
2819
|
+
if (ref.current) {
|
2820
|
+
const observer = new ResizeObserver(sync);
|
2821
|
+
observer.observe(ref.current);
|
2822
|
+
return () => {
|
2823
|
+
observer.disconnect();
|
2824
|
+
};
|
2825
|
+
}
|
2826
|
+
}, [ref.current]);
|
2827
|
+
useEffect11(() => {
|
2828
|
+
ctx == null ? void 0 : ctx.registerPath({
|
2829
|
+
index,
|
2830
|
+
zone: zoneCompound
|
2831
|
+
});
|
2832
|
+
}, [isSelected]);
|
2833
|
+
const CustomActionBar = useMemo3(
|
2434
2834
|
() => overrides.actionBar || DefaultActionBar,
|
2435
2835
|
[overrides.actionBar]
|
2436
2836
|
);
|
2437
2837
|
const permissions = getPermissions({
|
2438
2838
|
item: selectedItem
|
2439
2839
|
});
|
2440
|
-
|
2441
|
-
|
2442
|
-
|
2443
|
-
|
2444
|
-
|
2445
|
-
|
2446
|
-
|
2447
|
-
|
2448
|
-
|
2449
|
-
__spreadProps(__spreadValues(__spreadValues({
|
2450
|
-
ref: provided.innerRef
|
2451
|
-
}, provided.draggableProps), provided.dragHandleProps), {
|
2452
|
-
className: getClassName17({
|
2453
|
-
isSelected,
|
2454
|
-
isModifierHeld,
|
2455
|
-
isDragging: snapshot.isDragging,
|
2456
|
-
isLocked,
|
2457
|
-
forceHover,
|
2458
|
-
indicativeHover
|
2459
|
-
}),
|
2460
|
-
style: __spreadProps(__spreadValues(__spreadValues({}, style), provided.draggableProps.style), {
|
2461
|
-
cursor: isModifierHeld || isDragDisabled ? "pointer" : "grab"
|
2462
|
-
}),
|
2463
|
-
onMouseOver,
|
2464
|
-
onMouseOut,
|
2465
|
-
onMouseDown,
|
2466
|
-
onMouseUp,
|
2467
|
-
onClick,
|
2468
|
-
children: [
|
2469
|
-
debug,
|
2470
|
-
isLoading && /* @__PURE__ */ jsx22("div", { className: getClassName17("loadingOverlay"), children: /* @__PURE__ */ jsx22(Loader, {}) }),
|
2471
|
-
isSelected && /* @__PURE__ */ jsx22(
|
2472
|
-
"div",
|
2473
|
-
{
|
2474
|
-
className: getClassName17("actionsOverlay"),
|
2475
|
-
style: {
|
2476
|
-
top: actionsOverlayTop / zoomConfig.zoom
|
2477
|
-
},
|
2478
|
-
children: /* @__PURE__ */ jsx22(
|
2479
|
-
"div",
|
2480
|
-
{
|
2481
|
-
className: getClassName17("actions"),
|
2482
|
-
style: {
|
2483
|
-
transform: `scale(${1 / zoomConfig.zoom}`,
|
2484
|
-
top: actionsTop / zoomConfig.zoom,
|
2485
|
-
right: actionsRight / zoomConfig.zoom
|
2486
|
-
},
|
2487
|
-
children: /* @__PURE__ */ jsxs11(CustomActionBar, { label, children: [
|
2488
|
-
permissions.duplicate && /* @__PURE__ */ jsx22(ActionBar.Action, { onClick: onDuplicate, label: "Duplicate", children: /* @__PURE__ */ jsx22(Copy, { size: 16 }) }),
|
2489
|
-
permissions.delete && /* @__PURE__ */ jsx22(ActionBar.Action, { onClick: onDelete, label: "Delete", children: /* @__PURE__ */ jsx22(Trash, { size: 16 }) })
|
2490
|
-
] })
|
2491
|
-
}
|
2492
|
-
)
|
2493
|
-
}
|
2494
|
-
),
|
2495
|
-
/* @__PURE__ */ jsx22("div", { className: getClassName17("overlay") }),
|
2496
|
-
/* @__PURE__ */ jsx22("div", { className: getClassName17("contents"), children })
|
2497
|
-
]
|
2498
|
-
})
|
2499
|
-
)
|
2840
|
+
const onClick = useCallback6(
|
2841
|
+
(e) => {
|
2842
|
+
e.stopPropagation();
|
2843
|
+
dispatch({
|
2844
|
+
type: "setUi",
|
2845
|
+
ui: {
|
2846
|
+
itemSelector: { index, zone: zoneCompound }
|
2847
|
+
}
|
2848
|
+
});
|
2500
2849
|
},
|
2501
|
-
id
|
2850
|
+
[index, zoneCompound, id]
|
2851
|
+
);
|
2852
|
+
const onDuplicate = useCallback6(
|
2853
|
+
(e) => {
|
2854
|
+
e.stopPropagation();
|
2855
|
+
dispatch({
|
2856
|
+
type: "duplicate",
|
2857
|
+
sourceIndex: index,
|
2858
|
+
sourceZone: zoneCompound
|
2859
|
+
});
|
2860
|
+
},
|
2861
|
+
[index, zoneCompound]
|
2862
|
+
);
|
2863
|
+
const onDelete = useCallback6(
|
2864
|
+
(e) => {
|
2865
|
+
e.stopPropagation();
|
2866
|
+
dispatch({
|
2867
|
+
type: "remove",
|
2868
|
+
index,
|
2869
|
+
zone: zoneCompound
|
2870
|
+
});
|
2871
|
+
},
|
2872
|
+
[index, zoneCompound]
|
2873
|
+
);
|
2874
|
+
const [hover, setHover] = useState12(false);
|
2875
|
+
const indicativeHover = (ctx == null ? void 0 : ctx.hoveringComponent) === id;
|
2876
|
+
useEffect11(() => {
|
2877
|
+
if (!ref.current) {
|
2878
|
+
return;
|
2879
|
+
}
|
2880
|
+
const el = ref.current;
|
2881
|
+
const _onMouseOver = (e) => {
|
2882
|
+
if (userIsDragging) {
|
2883
|
+
if (thisIsDragging) {
|
2884
|
+
setHover(true);
|
2885
|
+
} else {
|
2886
|
+
setHover(false);
|
2887
|
+
}
|
2888
|
+
} else {
|
2889
|
+
setHover(true);
|
2890
|
+
}
|
2891
|
+
e.stopPropagation();
|
2892
|
+
};
|
2893
|
+
const _onMouseOut = (e) => {
|
2894
|
+
e.stopPropagation();
|
2895
|
+
setHover(false);
|
2896
|
+
};
|
2897
|
+
el.setAttribute("data-puck-component", id);
|
2898
|
+
el.style.position = "relative";
|
2899
|
+
el.addEventListener("click", onClick);
|
2900
|
+
el.addEventListener("mouseover", _onMouseOver);
|
2901
|
+
el.addEventListener("mouseout", _onMouseOut);
|
2902
|
+
if (thisIsDragging) {
|
2903
|
+
el.setAttribute("data-puck-dragging", "");
|
2904
|
+
} else {
|
2905
|
+
el.removeAttribute("data-puck-dragging");
|
2906
|
+
}
|
2907
|
+
return () => {
|
2908
|
+
el.removeAttribute("data-puck-component");
|
2909
|
+
el.removeEventListener("click", onClick);
|
2910
|
+
el.removeEventListener("mouseover", _onMouseOver);
|
2911
|
+
el.removeEventListener("mouseout", _onMouseOut);
|
2912
|
+
el.removeAttribute("data-puck-dragging");
|
2913
|
+
};
|
2914
|
+
}, [
|
2915
|
+
ref,
|
2916
|
+
onClick,
|
2917
|
+
containsActiveZone,
|
2918
|
+
zoneCompound,
|
2919
|
+
id,
|
2920
|
+
userIsDragging,
|
2921
|
+
thisIsDragging,
|
2922
|
+
inDroppableZone
|
2923
|
+
]);
|
2924
|
+
useEffect11(() => {
|
2925
|
+
if (ref.current && disabled) {
|
2926
|
+
ref.current.setAttribute("data-puck-disabled", "");
|
2927
|
+
return () => {
|
2928
|
+
var _a;
|
2929
|
+
(_a = ref.current) == null ? void 0 : _a.removeAttribute("data-puck-disabled");
|
2930
|
+
};
|
2931
|
+
}
|
2932
|
+
}, [disabled, ref]);
|
2933
|
+
const [isVisible, setIsVisible] = useState12(false);
|
2934
|
+
useEffect11(() => {
|
2935
|
+
sync();
|
2936
|
+
if ((isSelected || hover || indicativeHover) && !userIsDragging) {
|
2937
|
+
setIsVisible(true);
|
2938
|
+
} else {
|
2939
|
+
setIsVisible(false);
|
2940
|
+
}
|
2941
|
+
}, [isSelected, hover, indicativeHover, iframe, state.data, userIsDragging]);
|
2942
|
+
const syncActionsPosition = useCallback6(
|
2943
|
+
(el) => {
|
2944
|
+
if (el) {
|
2945
|
+
const view = el.ownerDocument.defaultView;
|
2946
|
+
if (view) {
|
2947
|
+
const rect = el.getBoundingClientRect();
|
2948
|
+
const diffLeft = rect.x;
|
2949
|
+
const exceedsBoundsLeft = diffLeft < 0;
|
2950
|
+
if (exceedsBoundsLeft) {
|
2951
|
+
el.style.transformOrigin = "left top";
|
2952
|
+
el.style.left = "0px";
|
2953
|
+
} else {
|
2954
|
+
el.style.transformOrigin = "right top";
|
2955
|
+
el.style.left = "";
|
2956
|
+
}
|
2957
|
+
}
|
2958
|
+
}
|
2959
|
+
},
|
2960
|
+
[zoomConfig]
|
2961
|
+
);
|
2962
|
+
useEffect11(() => {
|
2963
|
+
if (userDragAxis) {
|
2964
|
+
setDragAxis(userDragAxis);
|
2965
|
+
return;
|
2966
|
+
}
|
2967
|
+
if (ref.current) {
|
2968
|
+
const computedStyle = window.getComputedStyle(ref.current);
|
2969
|
+
if (computedStyle.display === "inline" || computedStyle.display === "inline-block") {
|
2970
|
+
setDragAxis("x");
|
2971
|
+
return;
|
2972
|
+
}
|
2973
|
+
}
|
2974
|
+
setDragAxis(autoDragAxis);
|
2975
|
+
}, [ref, userDragAxis, autoDragAxis]);
|
2976
|
+
return /* @__PURE__ */ jsxs10(
|
2977
|
+
DropZoneProvider,
|
2978
|
+
{
|
2979
|
+
value: __spreadProps(__spreadValues({}, ctx), {
|
2980
|
+
areaId: id,
|
2981
|
+
zoneCompound,
|
2982
|
+
index,
|
2983
|
+
depth: depth + 1,
|
2984
|
+
registerLocalZone,
|
2985
|
+
path: [...path, id]
|
2986
|
+
}),
|
2987
|
+
children: [
|
2988
|
+
isVisible && createPortal2(
|
2989
|
+
/* @__PURE__ */ jsxs10(
|
2990
|
+
"div",
|
2991
|
+
{
|
2992
|
+
className: getClassName16({
|
2993
|
+
isSelected,
|
2994
|
+
isDragging: thisIsDragging,
|
2995
|
+
isModifierHeld,
|
2996
|
+
hover: hover || indicativeHover
|
2997
|
+
}),
|
2998
|
+
style: __spreadValues({}, style),
|
2999
|
+
children: [
|
3000
|
+
debug,
|
3001
|
+
isLoading && /* @__PURE__ */ jsx21("div", { className: getClassName16("loadingOverlay"), children: /* @__PURE__ */ jsx21(Loader, {}) }),
|
3002
|
+
/* @__PURE__ */ jsx21(
|
3003
|
+
"div",
|
3004
|
+
{
|
3005
|
+
className: getClassName16("actionsOverlay"),
|
3006
|
+
style: {
|
3007
|
+
top: actionsOverlayTop / zoomConfig.zoom
|
3008
|
+
},
|
3009
|
+
children: /* @__PURE__ */ jsx21(
|
3010
|
+
"div",
|
3011
|
+
{
|
3012
|
+
className: getClassName16("actions"),
|
3013
|
+
style: {
|
3014
|
+
transform: `scale(${1 / zoomConfig.zoom}`,
|
3015
|
+
top: actionsTop / zoomConfig.zoom,
|
3016
|
+
right: 0,
|
3017
|
+
paddingLeft: actionsSide,
|
3018
|
+
paddingRight: actionsSide
|
3019
|
+
},
|
3020
|
+
ref: syncActionsPosition,
|
3021
|
+
children: /* @__PURE__ */ jsxs10(CustomActionBar, { label: DEBUG2 ? id : label, children: [
|
3022
|
+
permissions.duplicate && /* @__PURE__ */ jsx21(ActionBar.Action, { onClick: onDuplicate, label: "Duplicate", children: /* @__PURE__ */ jsx21(Copy, { size: 16 }) }),
|
3023
|
+
permissions.delete && /* @__PURE__ */ jsx21(ActionBar.Action, { onClick: onDelete, label: "Delete", children: /* @__PURE__ */ jsx21(Trash, { size: 16 }) })
|
3024
|
+
] })
|
3025
|
+
}
|
3026
|
+
)
|
3027
|
+
}
|
3028
|
+
),
|
3029
|
+
/* @__PURE__ */ jsx21("div", { className: getClassName16("overlay") })
|
3030
|
+
]
|
3031
|
+
}
|
3032
|
+
),
|
3033
|
+
portalEl || document.body
|
3034
|
+
),
|
3035
|
+
children(refSetter)
|
3036
|
+
]
|
3037
|
+
}
|
2502
3038
|
);
|
2503
3039
|
};
|
2504
|
-
|
2505
|
-
// css-module:/home/runner/work/puck/puck/packages/core/components/DropZone/styles.module.css#css-module
|
2506
|
-
init_react_import();
|
2507
|
-
var styles_module_default12 = { "DropZone": "
|
2508
|
-
|
2509
|
-
// components/DropZone/context.tsx
|
2510
|
-
init_react_import();
|
2511
|
-
import {
|
2512
|
-
createContext as createContext3,
|
2513
|
-
useCallback as useCallback6,
|
2514
|
-
useState as useState13
|
2515
|
-
} from "react";
|
2516
|
-
import { useDebounce } from "use-debounce";
|
2517
|
-
|
2518
|
-
// lib/get-zone-id.ts
|
2519
|
-
init_react_import();
|
2520
|
-
var getZoneId = (zoneCompound) => {
|
2521
|
-
if (!zoneCompound) {
|
2522
|
-
return [];
|
2523
|
-
}
|
2524
|
-
if (zoneCompound && zoneCompound.indexOf(":") > -1) {
|
2525
|
-
return zoneCompound.split(":");
|
2526
|
-
}
|
2527
|
-
return [rootDroppableId, zoneCompound];
|
2528
|
-
};
|
3040
|
+
|
3041
|
+
// css-module:/home/runner/work/puck/puck/packages/core/components/DropZone/styles.module.css#css-module
|
3042
|
+
init_react_import();
|
3043
|
+
var styles_module_default12 = { "DropZone": "_DropZone_74ebh_1", "DropZone--hasChildren": "_DropZone--hasChildren_74ebh_12", "DropZone--userIsDragging": "_DropZone--userIsDragging_74ebh_20", "DropZone--isAreaSelected": "_DropZone--isAreaSelected_74ebh_29", "DropZone--hoveringOverArea": "_DropZone--hoveringOverArea_74ebh_30", "DropZone--isRootZone": "_DropZone--isRootZone_74ebh_30", "DropZone--isDestination": "_DropZone--isDestination_74ebh_40", "DropZone-item": "_DropZone-item_74ebh_52", "DropZone-hitbox": "_DropZone-hitbox_74ebh_56", "DropZone--isEnabled": "_DropZone--isEnabled_74ebh_64" };
|
2529
3044
|
|
2530
3045
|
// components/DropZone/context.tsx
|
2531
|
-
|
2532
|
-
|
3046
|
+
init_react_import();
|
3047
|
+
import { createContext as createContext2, useCallback as useCallback7, useState as useState13 } from "react";
|
3048
|
+
import { Fragment as Fragment9, jsx as jsx22 } from "react/jsx-runtime";
|
3049
|
+
var dropZoneContext = createContext2(null);
|
2533
3050
|
var DropZoneProvider = ({
|
2534
3051
|
children,
|
2535
3052
|
value
|
2536
3053
|
}) => {
|
2537
|
-
const [hoveringArea, setHoveringArea] = useState13(null);
|
2538
|
-
const [hoveringZone, setHoveringZone] = useState13(
|
2539
|
-
rootDroppableId
|
2540
|
-
);
|
2541
3054
|
const [hoveringComponent, setHoveringComponent] = useState13();
|
2542
|
-
const [hoveringAreaDb] = useDebounce(hoveringArea, 75, { leading: false });
|
2543
3055
|
const [areasWithZones, setAreasWithZones] = useState13(
|
2544
3056
|
{}
|
2545
3057
|
);
|
2546
3058
|
const [activeZones, setActiveZones] = useState13({});
|
2547
3059
|
const { dispatch = null } = value ? value : {};
|
2548
|
-
const registerZoneArea =
|
3060
|
+
const registerZoneArea = useCallback7(
|
2549
3061
|
(area) => {
|
2550
3062
|
setAreasWithZones((latest) => __spreadProps(__spreadValues({}, latest), { [area]: true }));
|
2551
3063
|
},
|
2552
3064
|
[setAreasWithZones]
|
2553
3065
|
);
|
2554
|
-
const registerZone =
|
3066
|
+
const registerZone = useCallback7(
|
2555
3067
|
(zoneCompound) => {
|
2556
3068
|
if (!dispatch) {
|
2557
3069
|
return;
|
@@ -2564,7 +3076,7 @@ var DropZoneProvider = ({
|
|
2564
3076
|
},
|
2565
3077
|
[setActiveZones, dispatch]
|
2566
3078
|
);
|
2567
|
-
const unregisterZone =
|
3079
|
+
const unregisterZone = useCallback7(
|
2568
3080
|
(zoneCompound) => {
|
2569
3081
|
if (!dispatch) {
|
2570
3082
|
return;
|
@@ -2579,81 +3091,65 @@ var DropZoneProvider = ({
|
|
2579
3091
|
},
|
2580
3092
|
[setActiveZones, dispatch]
|
2581
3093
|
);
|
2582
|
-
|
2583
|
-
const registerPath = useCallback6(
|
2584
|
-
(selector) => {
|
2585
|
-
if (!(value == null ? void 0 : value.data)) {
|
2586
|
-
return;
|
2587
|
-
}
|
2588
|
-
const item = getItem(selector, value.data);
|
2589
|
-
if (!item) {
|
2590
|
-
return;
|
2591
|
-
}
|
2592
|
-
const [area] = getZoneId(selector.zone);
|
2593
|
-
setPathData((latestPathData = {}) => {
|
2594
|
-
const parentPathData = latestPathData[area] || { path: [] };
|
2595
|
-
return __spreadProps(__spreadValues({}, latestPathData), {
|
2596
|
-
[item.props.id]: {
|
2597
|
-
path: [
|
2598
|
-
...parentPathData.path,
|
2599
|
-
...selector.zone ? [selector.zone] : []
|
2600
|
-
],
|
2601
|
-
label: item.type
|
2602
|
-
}
|
2603
|
-
});
|
2604
|
-
});
|
2605
|
-
},
|
2606
|
-
[value, setPathData]
|
2607
|
-
);
|
2608
|
-
const [zoneWillDrag, setZoneWillDrag] = useState13("");
|
2609
|
-
return /* @__PURE__ */ jsx23(Fragment9, { children: value && /* @__PURE__ */ jsx23(
|
3094
|
+
return /* @__PURE__ */ jsx22(Fragment9, { children: value && /* @__PURE__ */ jsx22(
|
2610
3095
|
dropZoneContext.Provider,
|
2611
3096
|
{
|
2612
3097
|
value: __spreadValues({
|
2613
|
-
hoveringArea: value.draggedItem ? hoveringAreaDb : hoveringArea,
|
2614
|
-
setHoveringArea,
|
2615
|
-
hoveringZone,
|
2616
|
-
setHoveringZone,
|
2617
3098
|
hoveringComponent,
|
2618
3099
|
setHoveringComponent,
|
2619
3100
|
registerZoneArea,
|
2620
3101
|
areasWithZones,
|
2621
3102
|
registerZone,
|
2622
3103
|
unregisterZone,
|
2623
|
-
activeZones
|
2624
|
-
registerPath,
|
2625
|
-
pathData,
|
2626
|
-
zoneWillDrag,
|
2627
|
-
setZoneWillDrag
|
3104
|
+
activeZones
|
2628
3105
|
}, value),
|
2629
3106
|
children
|
2630
3107
|
}
|
2631
3108
|
) });
|
2632
3109
|
};
|
2633
3110
|
|
3111
|
+
// lib/insert.ts
|
3112
|
+
init_react_import();
|
3113
|
+
var insert = (list, index, item) => {
|
3114
|
+
const result = Array.from(list);
|
3115
|
+
result.splice(index, 0, item);
|
3116
|
+
return result;
|
3117
|
+
};
|
3118
|
+
|
2634
3119
|
// components/DropZone/index.tsx
|
2635
|
-
import { Fragment as Fragment10, jsx as
|
2636
|
-
var
|
2637
|
-
|
2638
|
-
|
3120
|
+
import { Fragment as Fragment10, jsx as jsx23, jsxs as jsxs11 } from "react/jsx-runtime";
|
3121
|
+
var getClassName17 = get_class_name_factory_default("DropZone", styles_module_default12);
|
3122
|
+
var DEBUG3 = false;
|
3123
|
+
var GRID_DRAG_AXIS = "dynamic";
|
3124
|
+
var FLEX_ROW_DRAG_AXIS = "x";
|
3125
|
+
var DEFAULT_DRAG_AXIS = "y";
|
3126
|
+
function DropZoneEdit({
|
3127
|
+
zone,
|
3128
|
+
allow,
|
3129
|
+
disallow,
|
3130
|
+
style,
|
3131
|
+
className,
|
3132
|
+
minEmptyHeight = 128,
|
3133
|
+
dragRef,
|
3134
|
+
collisionAxis
|
3135
|
+
}) {
|
2639
3136
|
const appContext2 = useAppContext();
|
2640
3137
|
const ctx = useContext3(dropZoneContext);
|
2641
3138
|
const {
|
2642
3139
|
// These all need setting via context
|
2643
3140
|
data,
|
2644
|
-
dispatch = () => null,
|
2645
3141
|
config,
|
2646
|
-
itemSelector,
|
2647
|
-
setItemSelector = () => null,
|
2648
3142
|
areaId,
|
2649
3143
|
draggedItem,
|
2650
|
-
placeholderStyle,
|
2651
3144
|
registerZoneArea,
|
2652
|
-
|
2653
|
-
|
2654
|
-
|
2655
|
-
|
2656
|
-
|
3145
|
+
depth,
|
3146
|
+
registerLocalZone,
|
3147
|
+
deepestZone = rootDroppableId,
|
3148
|
+
deepestArea,
|
3149
|
+
nextDeepestArea,
|
3150
|
+
path = []
|
3151
|
+
} = ctx;
|
3152
|
+
const { itemSelector } = appContext2.state.ui;
|
2657
3153
|
let content = data.content || [];
|
2658
3154
|
let zoneCompound = rootDroppableId;
|
2659
3155
|
useEffect12(() => {
|
@@ -2662,6 +3158,9 @@ function DropZoneEdit({ zone, allow, disallow, style }) {
|
|
2662
3158
|
}
|
2663
3159
|
}, [areaId]);
|
2664
3160
|
useEffect12(() => {
|
3161
|
+
if (registerLocalZone) {
|
3162
|
+
registerLocalZone(zoneCompound, isDroppableTarget());
|
3163
|
+
}
|
2665
3164
|
if (ctx == null ? void 0 : ctx.registerZone) {
|
2666
3165
|
ctx == null ? void 0 : ctx.registerZone(zoneCompound);
|
2667
3166
|
}
|
@@ -2677,246 +3176,198 @@ function DropZoneEdit({ zone, allow, disallow, style }) {
|
|
2677
3176
|
content = setupZone(data, zoneCompound).zones[zoneCompound];
|
2678
3177
|
}
|
2679
3178
|
}
|
2680
|
-
const
|
2681
|
-
const
|
2682
|
-
|
2683
|
-
|
2684
|
-
const [draggedSourceArea] = getZoneId(draggedSourceId);
|
2685
|
-
const userWillDrag = zoneWillDrag === zone;
|
2686
|
-
const userIsDragging = !!draggedItem;
|
2687
|
-
const draggingOverArea = userIsDragging && zoneArea === draggedSourceArea;
|
2688
|
-
const draggingNewComponent = draggedSourceId == null ? void 0 : draggedSourceId.startsWith("component-list");
|
2689
|
-
if (!(ctx == null ? void 0 : ctx.config) || !ctx.setHoveringArea || !ctx.setHoveringZone || !ctx.setHoveringComponent || !ctx.setItemSelector || !ctx.registerPath || !ctx.dispatch) {
|
2690
|
-
return /* @__PURE__ */ jsx24("div", { children: "DropZone requires context to work." });
|
2691
|
-
}
|
2692
|
-
const {
|
2693
|
-
hoveringArea = "root",
|
2694
|
-
setHoveringArea,
|
2695
|
-
hoveringZone,
|
2696
|
-
setHoveringZone,
|
2697
|
-
setHoveringComponent
|
2698
|
-
} = ctx;
|
2699
|
-
const hoveringOverArea = hoveringArea ? hoveringArea === zoneArea : isRootZone;
|
2700
|
-
const hoveringOverZone = hoveringZone === zoneCompound;
|
2701
|
-
let isEnabled = userWillDrag;
|
2702
|
-
if (userIsDragging) {
|
2703
|
-
if (draggingNewComponent) {
|
2704
|
-
if (appContext2.safariFallbackMode) {
|
2705
|
-
isEnabled = true;
|
2706
|
-
} else {
|
2707
|
-
isEnabled = hoveringOverArea;
|
2708
|
-
}
|
2709
|
-
} else {
|
2710
|
-
isEnabled = draggingOverArea && hoveringOverZone;
|
3179
|
+
const ref = useRef4();
|
3180
|
+
const isDroppableTarget = useCallback8(() => {
|
3181
|
+
if (!draggedItem) {
|
3182
|
+
return true;
|
2711
3183
|
}
|
2712
|
-
|
2713
|
-
if (isEnabled && userIsDragging && (allow || disallow)) {
|
2714
|
-
const [_, componentType] = draggedItem.draggableId.split("::");
|
3184
|
+
const { componentType } = draggedItem.data;
|
2715
3185
|
if (disallow) {
|
2716
3186
|
const defaultedAllow = allow || [];
|
2717
3187
|
const filteredDisallow = (disallow || []).filter(
|
2718
3188
|
(item) => defaultedAllow.indexOf(item) === -1
|
2719
3189
|
);
|
2720
3190
|
if (filteredDisallow.indexOf(componentType) !== -1) {
|
2721
|
-
|
3191
|
+
return false;
|
2722
3192
|
}
|
2723
3193
|
} else if (allow) {
|
2724
3194
|
if (allow.indexOf(componentType) === -1) {
|
2725
|
-
|
3195
|
+
return false;
|
2726
3196
|
}
|
2727
3197
|
}
|
3198
|
+
return true;
|
3199
|
+
}, [draggedItem]);
|
3200
|
+
useEffect12(() => {
|
3201
|
+
if (registerLocalZone) {
|
3202
|
+
registerLocalZone(zoneCompound, isDroppableTarget());
|
3203
|
+
}
|
3204
|
+
}, [draggedItem, zoneCompound]);
|
3205
|
+
const isRootZone = zoneCompound === rootDroppableId || zone === rootDroppableId || areaId === "root";
|
3206
|
+
const hoveringOverArea = nextDeepestArea ? nextDeepestArea === areaId : isRootZone;
|
3207
|
+
const userIsDragging = !!draggedItem;
|
3208
|
+
let isEnabled = true;
|
3209
|
+
if (draggedItem) {
|
3210
|
+
isEnabled = deepestZone === zoneCompound;
|
3211
|
+
}
|
3212
|
+
if (isEnabled) {
|
3213
|
+
isEnabled = isDroppableTarget();
|
2728
3214
|
}
|
3215
|
+
const preview = useContext3(previewContext);
|
3216
|
+
const previewInZone = (preview == null ? void 0 : preview.zone) === zoneCompound;
|
3217
|
+
const contentWithPreview = useMemo4(() => {
|
3218
|
+
let contentWithPreview2 = preview ? content.filter((item) => item.props.id !== preview.props.id) : content;
|
3219
|
+
if (previewInZone) {
|
3220
|
+
contentWithPreview2 = content.filter(
|
3221
|
+
(item) => item.props.id !== preview.props.id
|
3222
|
+
);
|
3223
|
+
if (preview.type === "insert") {
|
3224
|
+
contentWithPreview2 = insert(contentWithPreview2, preview.index, {
|
3225
|
+
type: "preview",
|
3226
|
+
props: { id: preview.props.id }
|
3227
|
+
});
|
3228
|
+
} else {
|
3229
|
+
contentWithPreview2 = insert(contentWithPreview2, preview.index, {
|
3230
|
+
type: preview.componentType,
|
3231
|
+
props: preview.props
|
3232
|
+
});
|
3233
|
+
}
|
3234
|
+
}
|
3235
|
+
return contentWithPreview2;
|
3236
|
+
}, [preview, content]);
|
3237
|
+
const isDropEnabled = isEnabled && (previewInZone ? contentWithPreview.length === 1 : contentWithPreview.length === 0);
|
3238
|
+
const droppableConfig = {
|
3239
|
+
id: zoneCompound,
|
3240
|
+
collisionPriority: isEnabled ? depth : 0,
|
3241
|
+
disabled: !isDropEnabled,
|
3242
|
+
collisionDetector: pointerIntersection,
|
3243
|
+
type: "dropzone",
|
3244
|
+
data: {
|
3245
|
+
areaId,
|
3246
|
+
depth,
|
3247
|
+
isDroppableTarget: isDroppableTarget(),
|
3248
|
+
path
|
3249
|
+
}
|
3250
|
+
};
|
3251
|
+
const { ref: dropRef } = useDroppableSafe(droppableConfig);
|
2729
3252
|
const selectedItem = itemSelector ? getItem(itemSelector, data) : null;
|
2730
|
-
const isAreaSelected = selectedItem &&
|
2731
|
-
|
3253
|
+
const isAreaSelected = selectedItem && areaId === selectedItem.props.id;
|
3254
|
+
const [dragAxis, setDragAxis] = useState14(
|
3255
|
+
collisionAxis || DEFAULT_DRAG_AXIS
|
3256
|
+
);
|
3257
|
+
const calculateDragAxis = useCallback8(() => {
|
3258
|
+
if (ref.current) {
|
3259
|
+
const computedStyle = window.getComputedStyle(ref.current);
|
3260
|
+
if (computedStyle.display === "grid") {
|
3261
|
+
setDragAxis(GRID_DRAG_AXIS);
|
3262
|
+
} else if (computedStyle.display === "flex" && computedStyle.flexDirection === "row") {
|
3263
|
+
setDragAxis(FLEX_ROW_DRAG_AXIS);
|
3264
|
+
} else {
|
3265
|
+
setDragAxis(DEFAULT_DRAG_AXIS);
|
3266
|
+
}
|
3267
|
+
}
|
3268
|
+
}, [ref.current]);
|
3269
|
+
useEffect12(calculateDragAxis, [appContext2.status, collisionAxis]);
|
3270
|
+
useEffect12(() => {
|
3271
|
+
const onViewportChange = () => {
|
3272
|
+
calculateDragAxis();
|
3273
|
+
};
|
3274
|
+
window.addEventListener("viewportchange", onViewportChange);
|
3275
|
+
return () => {
|
3276
|
+
window.removeEventListener("viewportchange", onViewportChange);
|
3277
|
+
};
|
3278
|
+
}, []);
|
3279
|
+
return /* @__PURE__ */ jsxs11(
|
2732
3280
|
"div",
|
2733
3281
|
{
|
2734
|
-
className:
|
3282
|
+
className: `${getClassName17({
|
2735
3283
|
isRootZone,
|
2736
3284
|
userIsDragging,
|
2737
|
-
draggingOverArea,
|
2738
3285
|
hoveringOverArea,
|
2739
|
-
|
2740
|
-
isDestination: draggedDestinationId === zoneCompound,
|
2741
|
-
isDisabled: !isEnabled,
|
3286
|
+
isEnabled,
|
2742
3287
|
isAreaSelected,
|
2743
3288
|
hasChildren: content.length > 0
|
2744
|
-
})
|
2745
|
-
|
2746
|
-
|
3289
|
+
})}${className ? ` ${className}` : ""}`,
|
3290
|
+
ref: (node) => {
|
3291
|
+
ref.current = node;
|
3292
|
+
dropRef(node);
|
3293
|
+
if (dragRef) dragRef(node);
|
2747
3294
|
},
|
2748
|
-
|
2749
|
-
|
2750
|
-
|
2751
|
-
|
2752
|
-
|
2753
|
-
|
2754
|
-
|
2755
|
-
|
2756
|
-
|
2757
|
-
|
2758
|
-
|
2759
|
-
|
2760
|
-
|
2761
|
-
|
2762
|
-
|
2763
|
-
|
2764
|
-
|
2765
|
-
|
2766
|
-
|
2767
|
-
|
2768
|
-
|
2769
|
-
|
2770
|
-
|
2771
|
-
|
2772
|
-
|
2773
|
-
|
2774
|
-
|
2775
|
-
|
2776
|
-
|
2777
|
-
|
2778
|
-
|
2779
|
-
|
2780
|
-
|
2781
|
-
|
2782
|
-
|
2783
|
-
|
2784
|
-
|
2785
|
-
const Render2 = config.components[item.type] ? config.components[item.type].render : () => /* @__PURE__ */ jsxs12("div", { style: { padding: 48, textAlign: "center" }, children: [
|
2786
|
-
"No configuration for ",
|
2787
|
-
item.type
|
2788
|
-
] });
|
2789
|
-
const componentConfig = config.components[item.type];
|
2790
|
-
const label = (_b = componentConfig == null ? void 0 : componentConfig["label"]) != null ? _b : item.type.toString();
|
2791
|
-
const canDrag = appContext2.getPermissions({
|
2792
|
-
item: getItem(
|
2793
|
-
{ index: i, zone: zoneCompound },
|
2794
|
-
appContext2.state.data
|
2795
|
-
)
|
2796
|
-
}).drag;
|
2797
|
-
return /* @__PURE__ */ jsxs12(
|
2798
|
-
"div",
|
2799
|
-
{
|
2800
|
-
className: getClassName18("item"),
|
2801
|
-
style: { zIndex: isDragging ? 1 : void 0 },
|
2802
|
-
children: [
|
2803
|
-
/* @__PURE__ */ jsx24(
|
2804
|
-
DropZoneProvider,
|
2805
|
-
{
|
2806
|
-
value: __spreadProps(__spreadValues({}, ctx), {
|
2807
|
-
areaId: componentId
|
2808
|
-
}),
|
2809
|
-
children: /* @__PURE__ */ jsx24(
|
2810
|
-
DraggableComponent,
|
2811
|
-
{
|
2812
|
-
label,
|
2813
|
-
id: `draggable-${componentId}`,
|
2814
|
-
index: i,
|
2815
|
-
isSelected,
|
2816
|
-
isLocked: userIsDragging,
|
2817
|
-
forceHover: hoveringComponent === componentId && !userIsDragging,
|
2818
|
-
isDragDisabled: !canDrag,
|
2819
|
-
indicativeHover: userIsDragging && containsZone && hoveringArea === componentId,
|
2820
|
-
isLoading: ((_c = appContext2.componentState[componentId]) == null ? void 0 : _c.loadingCount) > 0,
|
2821
|
-
onMount: () => {
|
2822
|
-
ctx.registerPath({
|
2823
|
-
index: i,
|
2824
|
-
zone: zoneCompound
|
2825
|
-
});
|
2826
|
-
},
|
2827
|
-
onClick: (e) => {
|
2828
|
-
setItemSelector({
|
2829
|
-
index: i,
|
2830
|
-
zone: zoneCompound
|
2831
|
-
});
|
2832
|
-
e.stopPropagation();
|
2833
|
-
},
|
2834
|
-
onMouseDown: (e) => {
|
2835
|
-
e.stopPropagation();
|
2836
|
-
setZoneWillDrag(zone);
|
2837
|
-
},
|
2838
|
-
onMouseOver: (e) => {
|
2839
|
-
e.stopPropagation();
|
2840
|
-
if (containsZone) {
|
2841
|
-
setHoveringArea(componentId);
|
2842
|
-
} else {
|
2843
|
-
setHoveringArea(zoneArea);
|
2844
|
-
}
|
2845
|
-
setHoveringComponent(componentId);
|
2846
|
-
setHoveringZone(zoneCompound);
|
2847
|
-
},
|
2848
|
-
onMouseOut: () => {
|
2849
|
-
setHoveringArea(null);
|
2850
|
-
setHoveringZone(null);
|
2851
|
-
setHoveringComponent(null);
|
2852
|
-
},
|
2853
|
-
onDelete: (e) => {
|
2854
|
-
dispatch({
|
2855
|
-
type: "remove",
|
2856
|
-
index: i,
|
2857
|
-
zone: zoneCompound
|
2858
|
-
});
|
2859
|
-
setItemSelector(null);
|
2860
|
-
e.stopPropagation();
|
2861
|
-
},
|
2862
|
-
onDuplicate: (e) => {
|
2863
|
-
dispatch({
|
2864
|
-
type: "duplicate",
|
2865
|
-
sourceIndex: i,
|
2866
|
-
sourceZone: zoneCompound
|
2867
|
-
});
|
2868
|
-
setItemSelector({
|
2869
|
-
zone: zoneCompound,
|
2870
|
-
index: i + 1
|
2871
|
-
});
|
2872
|
-
e.stopPropagation();
|
2873
|
-
},
|
2874
|
-
style: {
|
2875
|
-
pointerEvents: userIsDragging && draggingNewComponent ? "all" : void 0
|
2876
|
-
},
|
2877
|
-
children: /* @__PURE__ */ jsx24("div", { className: getClassName18("renderWrapper"), children: /* @__PURE__ */ jsx24(Render2, __spreadValues({}, defaultedProps)) })
|
2878
|
-
}
|
2879
|
-
)
|
2880
|
-
}
|
2881
|
-
),
|
2882
|
-
userIsDragging && /* @__PURE__ */ jsx24(
|
2883
|
-
"div",
|
2884
|
-
{
|
2885
|
-
className: getClassName18("hitbox"),
|
2886
|
-
onMouseOver: (e) => {
|
2887
|
-
e.stopPropagation();
|
2888
|
-
setHoveringArea(zoneArea);
|
2889
|
-
setHoveringZone(zoneCompound);
|
2890
|
-
}
|
2891
|
-
}
|
2892
|
-
)
|
2893
|
-
]
|
2894
|
-
},
|
2895
|
-
item.props.id
|
2896
|
-
);
|
2897
|
-
}),
|
2898
|
-
provided == null ? void 0 : provided.placeholder,
|
2899
|
-
(snapshot == null ? void 0 : snapshot.isDraggingOver) && /* @__PURE__ */ jsx24(
|
2900
|
-
"div",
|
2901
|
-
{
|
2902
|
-
"data-puck-placeholder": true,
|
2903
|
-
style: __spreadProps(__spreadValues({}, placeholderStyle), {
|
2904
|
-
background: "var(--puck-color-azure-06)",
|
2905
|
-
opacity: 0.3,
|
2906
|
-
zIndex: 0
|
2907
|
-
})
|
2908
|
-
}
|
2909
|
-
)
|
2910
|
-
]
|
2911
|
-
})
|
2912
|
-
);
|
3295
|
+
style: __spreadProps(__spreadValues({}, style), {
|
3296
|
+
"--min-empty-height": `${minEmptyHeight}px`
|
3297
|
+
}),
|
3298
|
+
children: [
|
3299
|
+
isRootZone && DEBUG3 && /* @__PURE__ */ jsxs11(Fragment10, { children: [
|
3300
|
+
/* @__PURE__ */ jsx23("p", { children: deepestZone || rootDroppableId }),
|
3301
|
+
/* @__PURE__ */ jsx23("p", { children: deepestArea || "No area" })
|
3302
|
+
] }),
|
3303
|
+
contentWithPreview.map((item, i) => {
|
3304
|
+
var _a, _b, _c, _d, _e;
|
3305
|
+
const componentId = item.props.id;
|
3306
|
+
const puckProps = {
|
3307
|
+
renderDropZone: DropZone,
|
3308
|
+
isEditing: true,
|
3309
|
+
dragRef: null
|
3310
|
+
};
|
3311
|
+
const defaultedProps = __spreadProps(__spreadValues(__spreadValues({}, (_a = config.components[item.type]) == null ? void 0 : _a.defaultProps), item.props), {
|
3312
|
+
puck: puckProps,
|
3313
|
+
editMode: true
|
3314
|
+
// DEPRECATED
|
3315
|
+
});
|
3316
|
+
const isSelected = (selectedItem == null ? void 0 : selectedItem.props.id) === componentId || false;
|
3317
|
+
let Render2 = config.components[item.type] ? config.components[item.type].render : () => /* @__PURE__ */ jsxs11("div", { style: { padding: 48, textAlign: "center" }, children: [
|
3318
|
+
"No configuration for ",
|
3319
|
+
item.type
|
3320
|
+
] });
|
3321
|
+
const componentConfig = config.components[item.type];
|
3322
|
+
let componentType = item.type;
|
3323
|
+
let label = (_b = componentConfig == null ? void 0 : componentConfig["label"]) != null ? _b : item.type.toString();
|
3324
|
+
if (item.type === "preview") {
|
3325
|
+
let Preview3 = function() {
|
3326
|
+
return /* @__PURE__ */ jsx23(DrawerItemInner, { name: label });
|
3327
|
+
};
|
3328
|
+
var Preview2 = Preview3;
|
3329
|
+
componentType = preview.componentType;
|
3330
|
+
label = (_d = (_c = config.components[componentType]) == null ? void 0 : _c.label) != null ? _d : preview.componentType;
|
3331
|
+
Render2 = Preview3;
|
2913
3332
|
}
|
2914
|
-
|
2915
|
-
|
3333
|
+
return /* @__PURE__ */ jsx23(
|
3334
|
+
DropZoneProvider,
|
3335
|
+
{
|
3336
|
+
value: __spreadProps(__spreadValues({}, ctx), { path: [...path, zoneCompound] }),
|
3337
|
+
children: /* @__PURE__ */ jsx23(
|
3338
|
+
DraggableComponent,
|
3339
|
+
{
|
3340
|
+
id: componentId,
|
3341
|
+
componentType,
|
3342
|
+
zoneCompound,
|
3343
|
+
depth: depth + 1,
|
3344
|
+
index: i,
|
3345
|
+
isLoading: ((_e = appContext2.componentState[componentId]) == null ? void 0 : _e.loadingCount) > 0,
|
3346
|
+
isSelected,
|
3347
|
+
label,
|
3348
|
+
isEnabled,
|
3349
|
+
autoDragAxis: dragAxis,
|
3350
|
+
userDragAxis: collisionAxis,
|
3351
|
+
inDroppableZone: isDroppableTarget(),
|
3352
|
+
children: (dragRef2) => (componentConfig == null ? void 0 : componentConfig.inline) ? /* @__PURE__ */ jsx23(
|
3353
|
+
Render2,
|
3354
|
+
__spreadProps(__spreadValues({}, defaultedProps), {
|
3355
|
+
puck: __spreadProps(__spreadValues({}, defaultedProps.puck), {
|
3356
|
+
dragRef: dragRef2
|
3357
|
+
})
|
3358
|
+
})
|
3359
|
+
) : /* @__PURE__ */ jsx23("div", { ref: dragRef2, children: /* @__PURE__ */ jsx23(Render2, __spreadValues({}, defaultedProps)) })
|
3360
|
+
}
|
3361
|
+
)
|
3362
|
+
},
|
3363
|
+
componentId
|
3364
|
+
);
|
3365
|
+
})
|
3366
|
+
]
|
2916
3367
|
}
|
2917
3368
|
);
|
2918
3369
|
}
|
2919
|
-
function DropZoneRender({ zone }) {
|
3370
|
+
function DropZoneRender({ className, style, zone }) {
|
2920
3371
|
const ctx = useContext3(dropZoneContext);
|
2921
3372
|
const { data, areaId = "root", config } = ctx || {};
|
2922
3373
|
let zoneCompound = rootDroppableId;
|
@@ -2928,17 +3379,23 @@ function DropZoneRender({ zone }) {
|
|
2928
3379
|
zoneCompound = `${areaId}:${zone}`;
|
2929
3380
|
content = setupZone(data, zoneCompound).zones[zoneCompound];
|
2930
3381
|
}
|
2931
|
-
return /* @__PURE__ */
|
3382
|
+
return /* @__PURE__ */ jsx23("div", { className, style, children: content.map((item) => {
|
2932
3383
|
const Component = config.components[item.type];
|
2933
3384
|
if (Component) {
|
2934
|
-
return /* @__PURE__ */
|
3385
|
+
return /* @__PURE__ */ jsx23(
|
2935
3386
|
DropZoneProvider,
|
2936
3387
|
{
|
2937
|
-
value: {
|
2938
|
-
|
3388
|
+
value: {
|
3389
|
+
data,
|
3390
|
+
config,
|
3391
|
+
areaId: item.props.id,
|
3392
|
+
depth: 1,
|
3393
|
+
path: []
|
3394
|
+
},
|
3395
|
+
children: /* @__PURE__ */ jsx23(
|
2939
3396
|
Component.render,
|
2940
3397
|
__spreadProps(__spreadValues({}, item.props), {
|
2941
|
-
puck: { renderDropZone:
|
3398
|
+
puck: { renderDropZone: DropZoneRender }
|
2942
3399
|
})
|
2943
3400
|
)
|
2944
3401
|
},
|
@@ -2951,196 +3408,222 @@ function DropZoneRender({ zone }) {
|
|
2951
3408
|
function DropZone(props) {
|
2952
3409
|
const ctx = useContext3(dropZoneContext);
|
2953
3410
|
if ((ctx == null ? void 0 : ctx.mode) === "edit") {
|
2954
|
-
return /* @__PURE__ */
|
3411
|
+
return /* @__PURE__ */ jsx23(Fragment10, { children: /* @__PURE__ */ jsx23(DropZoneEdit, __spreadValues({}, props)) });
|
2955
3412
|
}
|
2956
|
-
return /* @__PURE__ */
|
3413
|
+
return /* @__PURE__ */ jsx23(Fragment10, { children: /* @__PURE__ */ jsx23(DropZoneRender, __spreadValues({}, props)) });
|
2957
3414
|
}
|
2958
3415
|
|
2959
|
-
//
|
3416
|
+
// lib/get-zone-id.ts
|
2960
3417
|
init_react_import();
|
2961
|
-
|
2962
|
-
|
2963
|
-
|
2964
|
-
|
2965
|
-
|
2966
|
-
|
2967
|
-
}
|
3418
|
+
var getZoneId = (zoneCompound) => {
|
3419
|
+
if (!zoneCompound) {
|
3420
|
+
return [];
|
3421
|
+
}
|
3422
|
+
if (zoneCompound && zoneCompound.indexOf(":") > -1) {
|
3423
|
+
return zoneCompound.split(":");
|
3424
|
+
}
|
3425
|
+
return [rootDroppableId, zoneCompound];
|
3426
|
+
};
|
2968
3427
|
|
2969
|
-
//
|
3428
|
+
// components/DragDropContext/NestedDroppablePlugin.ts
|
2970
3429
|
init_react_import();
|
2971
|
-
import {
|
3430
|
+
import { Plugin } from "@dnd-kit/abstract";
|
3431
|
+
import { effects } from "@dnd-kit/state";
|
2972
3432
|
|
2973
|
-
// lib/
|
3433
|
+
// lib/throttle.ts
|
2974
3434
|
init_react_import();
|
2975
|
-
|
2976
|
-
|
2977
|
-
|
2978
|
-
|
3435
|
+
function timeout2(callback, duration) {
|
3436
|
+
const id = setTimeout(callback, duration);
|
3437
|
+
return () => clearTimeout(id);
|
3438
|
+
}
|
3439
|
+
function throttle(func, limit) {
|
3440
|
+
const time = () => performance.now();
|
3441
|
+
let cancel;
|
3442
|
+
let lastRan = 0;
|
3443
|
+
return function(...args) {
|
3444
|
+
const now = time();
|
3445
|
+
const context = this;
|
3446
|
+
if (now - lastRan >= limit) {
|
3447
|
+
func.apply(context, args);
|
3448
|
+
lastRan = now;
|
3449
|
+
} else {
|
3450
|
+
cancel == null ? void 0 : cancel();
|
3451
|
+
cancel = timeout2(() => {
|
3452
|
+
func.apply(context, args);
|
3453
|
+
lastRan = time();
|
3454
|
+
}, limit - (now - lastRan));
|
3455
|
+
}
|
3456
|
+
};
|
3457
|
+
}
|
3458
|
+
|
3459
|
+
// components/DragDropContext/NestedDroppablePlugin.ts
|
3460
|
+
function isPositionInsideRect(position, rect) {
|
3461
|
+
return position.x >= rect.left && position.x <= rect.right && position.y >= rect.top && position.y <= rect.bottom;
|
3462
|
+
}
|
3463
|
+
var BUFFER_ZONE = 8;
|
3464
|
+
var REFRESH_ON_MOVE = true;
|
3465
|
+
var depthSort = (candidates) => {
|
3466
|
+
return candidates.sort((a, b) => {
|
3467
|
+
const aData = a.data;
|
3468
|
+
const bData = b.data;
|
3469
|
+
if (aData.depth > bData.depth) {
|
3470
|
+
return 1;
|
3471
|
+
}
|
3472
|
+
if (bData.depth > aData.depth) {
|
3473
|
+
return -1;
|
3474
|
+
}
|
3475
|
+
return 0;
|
3476
|
+
});
|
3477
|
+
};
|
3478
|
+
var getZoneId2 = (candidate) => {
|
3479
|
+
let id = candidate == null ? void 0 : candidate.id;
|
3480
|
+
if (!candidate) return null;
|
3481
|
+
if (candidate.type === "component") {
|
3482
|
+
const data = candidate.data;
|
3483
|
+
if (data.containsActiveZone) {
|
3484
|
+
id = null;
|
3485
|
+
} else {
|
3486
|
+
id = data.zone;
|
3487
|
+
}
|
3488
|
+
} else if (candidate.type === "void") {
|
3489
|
+
return "void";
|
2979
3490
|
}
|
2980
|
-
return
|
3491
|
+
return id;
|
2981
3492
|
};
|
2982
|
-
|
2983
|
-
|
2984
|
-
|
2985
|
-
|
2986
|
-
|
2987
|
-
const onDragStartOrUpdate = (draggedItem) => {
|
2988
|
-
var _a;
|
2989
|
-
const draggableId = draggedItem.draggableId;
|
2990
|
-
const destinationIndex = (draggedItem.destination || draggedItem.source).index;
|
2991
|
-
const droppableId = (draggedItem.destination || draggedItem.source).droppableId;
|
2992
|
-
const domQuery = `[${queryAttr}='${draggableId}']`;
|
2993
|
-
const frame = getFrame();
|
2994
|
-
const draggedDOM = document.querySelector(domQuery) || (frame == null ? void 0 : frame.querySelector(domQuery));
|
2995
|
-
if (!draggedDOM) {
|
2996
|
-
return;
|
3493
|
+
var getAreaId = (candidate) => {
|
3494
|
+
if (candidate.type === "component") {
|
3495
|
+
const data = candidate.data;
|
3496
|
+
if (data.containsActiveZone) {
|
3497
|
+
return candidate.id;
|
2997
3498
|
}
|
2998
|
-
|
2999
|
-
|
3000
|
-
|
3001
|
-
|
3002
|
-
|
3003
|
-
|
3499
|
+
}
|
3500
|
+
return null;
|
3501
|
+
};
|
3502
|
+
var getDeepestId = (candidates, idFn) => {
|
3503
|
+
let id = null;
|
3504
|
+
for (let i = 0; i < candidates.length; i++) {
|
3505
|
+
const candidate = candidates[i];
|
3506
|
+
id = idFn(candidate);
|
3507
|
+
if (id) break;
|
3508
|
+
}
|
3509
|
+
return id;
|
3510
|
+
};
|
3511
|
+
var expandHitBox = (rect) => {
|
3512
|
+
return {
|
3513
|
+
bottom: rect.bottom + BUFFER_ZONE,
|
3514
|
+
top: rect.top - BUFFER_ZONE,
|
3515
|
+
width: rect.width + BUFFER_ZONE * 2,
|
3516
|
+
height: rect.height + BUFFER_ZONE * 2,
|
3517
|
+
left: rect.left - BUFFER_ZONE,
|
3518
|
+
right: rect.right + BUFFER_ZONE
|
3519
|
+
};
|
3520
|
+
};
|
3521
|
+
var getPointerCollisions = (position, manager) => {
|
3522
|
+
var _a;
|
3523
|
+
const candidates = [];
|
3524
|
+
const source = (_a = manager.dragOperation) == null ? void 0 : _a.source;
|
3525
|
+
const sourceData = source ? source.data : void 0;
|
3526
|
+
for (const droppable of manager.registry.droppables.value) {
|
3527
|
+
if (droppable.shape) {
|
3528
|
+
let rect = droppable.shape.boundingRectangle;
|
3529
|
+
const isNotSourceZone = droppable.id !== ((sourceData == null ? void 0 : sourceData.zone) || (source == null ? void 0 : source.id));
|
3530
|
+
const isNotTargetZone = droppable.id !== ((sourceData == null ? void 0 : sourceData.zone) || (source == null ? void 0 : source.id));
|
3531
|
+
if (droppable.type === "dropzone" && isNotSourceZone && isNotTargetZone) {
|
3532
|
+
rect = expandHitBox(rect);
|
3533
|
+
}
|
3534
|
+
if (isPositionInsideRect(position, rect)) {
|
3535
|
+
candidates.push(droppable);
|
3536
|
+
}
|
3004
3537
|
}
|
3005
|
-
|
3006
|
-
|
3007
|
-
|
3008
|
-
|
3009
|
-
|
3010
|
-
|
3011
|
-
|
3012
|
-
|
3013
|
-
|
3014
|
-
|
3015
|
-
|
3016
|
-
|
3017
|
-
|
3538
|
+
}
|
3539
|
+
return candidates;
|
3540
|
+
};
|
3541
|
+
var findDeepestCandidate = (position, manager) => {
|
3542
|
+
const candidates = getPointerCollisions(position, manager);
|
3543
|
+
if (candidates.length > 0) {
|
3544
|
+
const sortedCandidates = depthSort(candidates);
|
3545
|
+
const draggable = manager.dragOperation.source;
|
3546
|
+
const draggedCandidateIndex = sortedCandidates.findIndex(
|
3547
|
+
(candidate) => candidate.id === (draggable == null ? void 0 : draggable.id)
|
3548
|
+
);
|
3549
|
+
const draggedCandidateId = draggable == null ? void 0 : draggable.id;
|
3550
|
+
let filteredCandidates = [...sortedCandidates];
|
3551
|
+
if (draggedCandidateId && draggedCandidateIndex > -1) {
|
3552
|
+
filteredCandidates.splice(draggedCandidateIndex, 1);
|
3018
3553
|
}
|
3019
|
-
|
3020
|
-
|
3021
|
-
|
3022
|
-
|
3023
|
-
|
3024
|
-
|
3554
|
+
filteredCandidates = filteredCandidates.filter((candidate) => {
|
3555
|
+
const candidateData = candidate.data;
|
3556
|
+
if (draggedCandidateId && draggedCandidateIndex > -1) {
|
3557
|
+
if (candidateData.path.indexOf(draggedCandidateId) > -1) {
|
3558
|
+
return false;
|
3559
|
+
}
|
3560
|
+
}
|
3561
|
+
if (candidate.type === "dropzone") {
|
3562
|
+
const candidateData2 = candidate.data;
|
3563
|
+
if (!candidateData2.isDroppableTarget) {
|
3564
|
+
return false;
|
3565
|
+
}
|
3566
|
+
if (candidateData2.areaId === draggedCandidateId) {
|
3567
|
+
return false;
|
3568
|
+
}
|
3569
|
+
} else if (candidate.type === "component") {
|
3570
|
+
const candidateData2 = candidate.data;
|
3571
|
+
if (!candidateData2.inDroppableZone) {
|
3572
|
+
return false;
|
3573
|
+
}
|
3574
|
+
}
|
3575
|
+
return true;
|
3025
3576
|
});
|
3577
|
+
filteredCandidates.reverse();
|
3578
|
+
const zone = getZoneId2(filteredCandidates[0]);
|
3579
|
+
const area = getDeepestId(filteredCandidates, getAreaId);
|
3580
|
+
return { zone, area };
|
3581
|
+
}
|
3582
|
+
return {
|
3583
|
+
zone: "default-zone",
|
3584
|
+
area: null
|
3026
3585
|
};
|
3027
|
-
return { onDragStartOrUpdate, placeholderStyle };
|
3028
3586
|
};
|
3029
|
-
|
3030
|
-
|
3031
|
-
|
3032
|
-
|
3033
|
-
|
3034
|
-
|
3035
|
-
|
3036
|
-
|
3037
|
-
// lib/use-breadcrumbs.ts
|
3038
|
-
init_react_import();
|
3039
|
-
import { useContext as useContext4, useMemo as useMemo5 } from "react";
|
3040
|
-
var convertPathDataToBreadcrumbs = (selectedItem, pathData, data) => {
|
3041
|
-
const id = selectedItem ? selectedItem == null ? void 0 : selectedItem.props.id : "";
|
3042
|
-
const currentPathData = pathData && id && pathData[id] ? __spreadValues({}, pathData[id]) : { label: "Page", path: [] };
|
3043
|
-
if (!id) {
|
3044
|
-
return [];
|
3045
|
-
}
|
3046
|
-
return currentPathData == null ? void 0 : currentPathData.path.reduce((acc, zoneCompound) => {
|
3047
|
-
const [area] = getZoneId(zoneCompound);
|
3048
|
-
if (area === rootDroppableId) {
|
3049
|
-
return [
|
3050
|
-
{
|
3051
|
-
label: "Page",
|
3052
|
-
selector: null
|
3053
|
-
}
|
3054
|
-
];
|
3055
|
-
}
|
3056
|
-
const parentZoneCompound = acc.length > 0 ? acc[acc.length - 1].zoneCompound : rootDroppableId;
|
3057
|
-
let parentZone = data.content;
|
3058
|
-
if (parentZoneCompound && parentZoneCompound !== rootDroppableId) {
|
3059
|
-
parentZone = data.zones[parentZoneCompound];
|
3060
|
-
}
|
3061
|
-
if (!parentZone) {
|
3062
|
-
return acc;
|
3063
|
-
}
|
3064
|
-
const itemIndex = parentZone.findIndex(
|
3065
|
-
(queryItem) => queryItem.props.id === area
|
3066
|
-
);
|
3067
|
-
const item = parentZone[itemIndex];
|
3068
|
-
if (!item) {
|
3069
|
-
return acc;
|
3070
|
-
}
|
3071
|
-
return [
|
3072
|
-
...acc,
|
3073
|
-
{
|
3074
|
-
label: item.type.toString(),
|
3075
|
-
selector: {
|
3076
|
-
index: itemIndex,
|
3077
|
-
zone: parentZoneCompound
|
3078
|
-
},
|
3079
|
-
zoneCompound
|
3080
|
-
}
|
3081
|
-
];
|
3082
|
-
}, []);
|
3083
|
-
};
|
3084
|
-
var useBreadcrumbs = (renderCount) => {
|
3085
|
-
const {
|
3086
|
-
state: { data },
|
3087
|
-
selectedItem
|
3088
|
-
} = useAppContext();
|
3089
|
-
const dzContext = useContext4(dropZoneContext);
|
3090
|
-
return useMemo5(() => {
|
3091
|
-
const breadcrumbs = convertPathDataToBreadcrumbs(
|
3092
|
-
selectedItem,
|
3093
|
-
dzContext == null ? void 0 : dzContext.pathData,
|
3094
|
-
data
|
3095
|
-
);
|
3096
|
-
if (renderCount) {
|
3097
|
-
return breadcrumbs.slice(breadcrumbs.length - renderCount);
|
3587
|
+
var createNestedDroppablePlugin = ({
|
3588
|
+
onChange
|
3589
|
+
}) => class NestedDroppablePlugin extends Plugin {
|
3590
|
+
constructor(manager, options) {
|
3591
|
+
super(manager);
|
3592
|
+
if (typeof window === "undefined") {
|
3593
|
+
return;
|
3098
3594
|
}
|
3099
|
-
|
3100
|
-
|
3595
|
+
const cleanupEffect = effects(() => {
|
3596
|
+
const handleMove = (position) => {
|
3597
|
+
if (REFRESH_ON_MOVE) {
|
3598
|
+
for (const droppable of manager.registry.droppables.value) {
|
3599
|
+
droppable.refreshShape();
|
3600
|
+
}
|
3601
|
+
}
|
3602
|
+
onChange(findDeepestCandidate(position, manager), manager);
|
3603
|
+
};
|
3604
|
+
const handleMoveThrottled = throttle(handleMove, 50);
|
3605
|
+
const handlePointerMove = (event) => {
|
3606
|
+
handleMoveThrottled({
|
3607
|
+
x: event.clientX,
|
3608
|
+
y: event.clientY
|
3609
|
+
});
|
3610
|
+
};
|
3611
|
+
document.body.addEventListener("pointermove", handlePointerMove, {
|
3612
|
+
capture: true
|
3613
|
+
// dndkit's PointerSensor prevents propagation during drag
|
3614
|
+
});
|
3615
|
+
this.destroy = () => {
|
3616
|
+
document.body.removeEventListener("pointermove", handlePointerMove, {
|
3617
|
+
capture: true
|
3618
|
+
});
|
3619
|
+
cleanupEffect();
|
3620
|
+
};
|
3621
|
+
});
|
3622
|
+
}
|
3101
3623
|
};
|
3102
3624
|
|
3103
|
-
//
|
3104
|
-
|
3105
|
-
var getClassName19 = get_class_name_factory_default("SidebarSection", styles_module_default13);
|
3106
|
-
var SidebarSection = ({
|
3107
|
-
children,
|
3108
|
-
title,
|
3109
|
-
background,
|
3110
|
-
showBreadcrumbs,
|
3111
|
-
noBorderTop,
|
3112
|
-
noPadding,
|
3113
|
-
isLoading
|
3114
|
-
}) => {
|
3115
|
-
const { setUi } = useAppContext();
|
3116
|
-
const breadcrumbs = useBreadcrumbs(1);
|
3117
|
-
return /* @__PURE__ */ jsxs13(
|
3118
|
-
"div",
|
3119
|
-
{
|
3120
|
-
className: getClassName19({ noBorderTop, noPadding }),
|
3121
|
-
style: { background },
|
3122
|
-
children: [
|
3123
|
-
/* @__PURE__ */ jsx25("div", { className: getClassName19("title"), children: /* @__PURE__ */ jsxs13("div", { className: getClassName19("breadcrumbs"), children: [
|
3124
|
-
showBreadcrumbs ? breadcrumbs.map((breadcrumb, i) => /* @__PURE__ */ jsxs13("div", { className: getClassName19("breadcrumb"), children: [
|
3125
|
-
/* @__PURE__ */ jsx25(
|
3126
|
-
"button",
|
3127
|
-
{
|
3128
|
-
type: "button",
|
3129
|
-
className: getClassName19("breadcrumbLabel"),
|
3130
|
-
onClick: () => setUi({ itemSelector: breadcrumb.selector }),
|
3131
|
-
children: breadcrumb.label
|
3132
|
-
}
|
3133
|
-
),
|
3134
|
-
/* @__PURE__ */ jsx25(ChevronRight, { size: 16 })
|
3135
|
-
] }, i)) : null,
|
3136
|
-
/* @__PURE__ */ jsx25("div", { className: getClassName19("heading"), children: /* @__PURE__ */ jsx25(Heading, { rank: "2", size: "xs", children: title }) })
|
3137
|
-
] }) }),
|
3138
|
-
/* @__PURE__ */ jsx25("div", { className: getClassName19("content"), children }),
|
3139
|
-
isLoading && /* @__PURE__ */ jsx25("div", { className: getClassName19("loadingOverlay"), children: /* @__PURE__ */ jsx25(Loader, { size: 32 }) })
|
3140
|
-
]
|
3141
|
-
}
|
3142
|
-
);
|
3143
|
-
};
|
3625
|
+
// lib/insert-component.ts
|
3626
|
+
init_react_import();
|
3144
3627
|
|
3145
3628
|
// reducer/index.ts
|
3146
3629
|
init_react_import();
|
@@ -3148,14 +3631,6 @@ init_react_import();
|
|
3148
3631
|
// reducer/data.ts
|
3149
3632
|
init_react_import();
|
3150
3633
|
|
3151
|
-
// lib/insert.ts
|
3152
|
-
init_react_import();
|
3153
|
-
var insert = (list, index, item) => {
|
3154
|
-
const result = Array.from(list);
|
3155
|
-
result.splice(index, 0, item);
|
3156
|
-
return result;
|
3157
|
-
};
|
3158
|
-
|
3159
3634
|
// lib/remove.ts
|
3160
3635
|
init_react_import();
|
3161
3636
|
var remove = (list, index) => {
|
@@ -3283,6 +3758,27 @@ function insertAction(data, action, config) {
|
|
3283
3758
|
})
|
3284
3759
|
});
|
3285
3760
|
}
|
3761
|
+
var reorderAction = (data, action) => {
|
3762
|
+
if (action.destinationZone === rootDroppableId) {
|
3763
|
+
return __spreadProps(__spreadValues({}, data), {
|
3764
|
+
content: reorder(
|
3765
|
+
data.content,
|
3766
|
+
action.sourceIndex,
|
3767
|
+
action.destinationIndex
|
3768
|
+
)
|
3769
|
+
});
|
3770
|
+
}
|
3771
|
+
const newData = setupZone(data, action.destinationZone);
|
3772
|
+
return __spreadProps(__spreadValues({}, data), {
|
3773
|
+
zones: __spreadProps(__spreadValues({}, newData.zones), {
|
3774
|
+
[action.destinationZone]: reorder(
|
3775
|
+
newData.zones[action.destinationZone],
|
3776
|
+
action.sourceIndex,
|
3777
|
+
action.destinationIndex
|
3778
|
+
)
|
3779
|
+
})
|
3780
|
+
});
|
3781
|
+
};
|
3286
3782
|
function reduceData(data, action, config) {
|
3287
3783
|
if (action.type === "insert") {
|
3288
3784
|
return insertAction(data, action, config);
|
@@ -3318,27 +3814,12 @@ function reduceData(data, action, config) {
|
|
3318
3814
|
});
|
3319
3815
|
}
|
3320
3816
|
if (action.type === "reorder") {
|
3321
|
-
|
3322
|
-
return __spreadProps(__spreadValues({}, data), {
|
3323
|
-
content: reorder(
|
3324
|
-
data.content,
|
3325
|
-
action.sourceIndex,
|
3326
|
-
action.destinationIndex
|
3327
|
-
)
|
3328
|
-
});
|
3329
|
-
}
|
3330
|
-
const newData = setupZone(data, action.destinationZone);
|
3331
|
-
return __spreadProps(__spreadValues({}, data), {
|
3332
|
-
zones: __spreadProps(__spreadValues({}, newData.zones), {
|
3333
|
-
[action.destinationZone]: reorder(
|
3334
|
-
newData.zones[action.destinationZone],
|
3335
|
-
action.sourceIndex,
|
3336
|
-
action.destinationIndex
|
3337
|
-
)
|
3338
|
-
})
|
3339
|
-
});
|
3817
|
+
return reorderAction(data, action);
|
3340
3818
|
}
|
3341
3819
|
if (action.type === "move") {
|
3820
|
+
if (action.sourceZone === action.destinationZone && action.sourceIndex === action.destinationIndex) {
|
3821
|
+
return data;
|
3822
|
+
}
|
3342
3823
|
const newData = setupZone(
|
3343
3824
|
setupZone(data, action.sourceZone),
|
3344
3825
|
action.destinationZone
|
@@ -3347,6 +3828,9 @@ function reduceData(data, action, config) {
|
|
3347
3828
|
{ zone: action.sourceZone, index: action.sourceIndex },
|
3348
3829
|
newData
|
3349
3830
|
);
|
3831
|
+
if (action.sourceZone === action.destinationZone) {
|
3832
|
+
return reorderAction(data, __spreadProps(__spreadValues({}, action), { type: "reorder" }));
|
3833
|
+
}
|
3350
3834
|
if (action.sourceZone === rootDroppableId) {
|
3351
3835
|
return __spreadProps(__spreadValues({}, newData), {
|
3352
3836
|
content: remove(newData.content, action.sourceIndex),
|
@@ -3443,6 +3927,11 @@ var reduceUi = (ui, action) => {
|
|
3443
3927
|
}
|
3444
3928
|
return __spreadValues(__spreadValues({}, ui), action.ui(ui));
|
3445
3929
|
}
|
3930
|
+
if (action.type === "duplicate") {
|
3931
|
+
return __spreadProps(__spreadValues({}, ui), {
|
3932
|
+
itemSelector: { index: action.sourceIndex + 1, zone: action.sourceZone }
|
3933
|
+
});
|
3934
|
+
}
|
3446
3935
|
return ui;
|
3447
3936
|
};
|
3448
3937
|
|
@@ -3490,7 +3979,855 @@ function createReducer({
|
|
3490
3979
|
record,
|
3491
3980
|
onAction
|
3492
3981
|
);
|
3493
|
-
}
|
3982
|
+
}
|
3983
|
+
|
3984
|
+
// lib/insert-component.ts
|
3985
|
+
var insertComponent = (componentType, zone, index, {
|
3986
|
+
config,
|
3987
|
+
dispatch,
|
3988
|
+
resolveData,
|
3989
|
+
state
|
3990
|
+
}) => {
|
3991
|
+
const id = generateId(componentType);
|
3992
|
+
const insertActionData = {
|
3993
|
+
type: "insert",
|
3994
|
+
componentType,
|
3995
|
+
destinationIndex: index,
|
3996
|
+
destinationZone: zone,
|
3997
|
+
id
|
3998
|
+
};
|
3999
|
+
const insertedData = insertAction(state.data, insertActionData, config);
|
4000
|
+
dispatch(__spreadProps(__spreadValues({}, insertActionData), {
|
4001
|
+
// Dispatch insert rather set, as user's may rely on this via onAction
|
4002
|
+
// We must always record history here so the insert is added to user history
|
4003
|
+
// If the user has defined a resolveData method, they will end up with 2 history
|
4004
|
+
// entries on insert - one for the initial insert, and one when the data resolves
|
4005
|
+
recordHistory: true
|
4006
|
+
}));
|
4007
|
+
const itemSelector = {
|
4008
|
+
index,
|
4009
|
+
zone
|
4010
|
+
};
|
4011
|
+
dispatch({ type: "setUi", ui: { itemSelector } });
|
4012
|
+
resolveData({
|
4013
|
+
data: insertedData,
|
4014
|
+
ui: __spreadProps(__spreadValues({}, state.ui), { itemSelector })
|
4015
|
+
});
|
4016
|
+
};
|
4017
|
+
|
4018
|
+
// components/DragDropContext/index.tsx
|
4019
|
+
import { useDebouncedCallback as useDebouncedCallback2 } from "use-debounce";
|
4020
|
+
import { isElement as isElement2 } from "@dnd-kit/dom/utilities";
|
4021
|
+
|
4022
|
+
// components/DragDropContext/PointerSensor.ts
|
4023
|
+
init_react_import();
|
4024
|
+
import { batch, effect } from "@dnd-kit/state";
|
4025
|
+
import { Sensor, configurator } from "@dnd-kit/abstract";
|
4026
|
+
import {
|
4027
|
+
exceedsDistance
|
4028
|
+
} from "@dnd-kit/geometry";
|
4029
|
+
import {
|
4030
|
+
getDocument,
|
4031
|
+
isElement,
|
4032
|
+
isHTMLElement,
|
4033
|
+
isPointerEvent,
|
4034
|
+
Listeners,
|
4035
|
+
getFrameTransform
|
4036
|
+
} from "@dnd-kit/dom/utilities";
|
4037
|
+
var _clearTimeout;
|
4038
|
+
var _PointerSensor = class _PointerSensor extends Sensor {
|
4039
|
+
constructor(manager, options) {
|
4040
|
+
super(manager);
|
4041
|
+
this.manager = manager;
|
4042
|
+
this.options = options;
|
4043
|
+
this.listeners = new Listeners();
|
4044
|
+
this.cleanup = /* @__PURE__ */ new Set();
|
4045
|
+
this.source = void 0;
|
4046
|
+
__privateAdd(this, _clearTimeout);
|
4047
|
+
this.handleCancel = this.handleCancel.bind(this);
|
4048
|
+
this.handlePointerUp = this.handlePointerUp.bind(this);
|
4049
|
+
this.handleKeyDown = this.handleKeyDown.bind(this);
|
4050
|
+
effect(() => {
|
4051
|
+
const unbindGlobal = this.bindGlobal(options != null ? options : {});
|
4052
|
+
return () => {
|
4053
|
+
unbindGlobal();
|
4054
|
+
};
|
4055
|
+
});
|
4056
|
+
}
|
4057
|
+
bind(source, options = this.options) {
|
4058
|
+
const unbind = effect(() => {
|
4059
|
+
var _a;
|
4060
|
+
const target = (_a = source.handle) != null ? _a : source.element;
|
4061
|
+
const listener = (event) => {
|
4062
|
+
if (isPointerEvent(event)) {
|
4063
|
+
this.handlePointerDown(event, source, options);
|
4064
|
+
}
|
4065
|
+
};
|
4066
|
+
if (target) {
|
4067
|
+
patchWindow(target.ownerDocument.defaultView);
|
4068
|
+
target.addEventListener("pointerdown", listener);
|
4069
|
+
return () => {
|
4070
|
+
target.removeEventListener("pointerdown", listener);
|
4071
|
+
};
|
4072
|
+
}
|
4073
|
+
});
|
4074
|
+
return unbind;
|
4075
|
+
}
|
4076
|
+
bindGlobal(options) {
|
4077
|
+
const documents = /* @__PURE__ */ new Set();
|
4078
|
+
for (const draggable of this.manager.registry.draggables.value) {
|
4079
|
+
if (draggable.element) {
|
4080
|
+
documents.add(getDocument(draggable.element));
|
4081
|
+
}
|
4082
|
+
}
|
4083
|
+
for (const droppable of this.manager.registry.droppables.value) {
|
4084
|
+
if (droppable.element) {
|
4085
|
+
documents.add(getDocument(droppable.element));
|
4086
|
+
}
|
4087
|
+
}
|
4088
|
+
const unbindFns = Array.from(documents).map(
|
4089
|
+
(doc) => this.listeners.bind(doc, [
|
4090
|
+
{
|
4091
|
+
type: "pointermove",
|
4092
|
+
listener: (event) => this.handlePointerMove(event, doc, options)
|
4093
|
+
},
|
4094
|
+
{
|
4095
|
+
type: "pointerup",
|
4096
|
+
listener: this.handlePointerUp,
|
4097
|
+
options: {
|
4098
|
+
capture: true
|
4099
|
+
}
|
4100
|
+
},
|
4101
|
+
{
|
4102
|
+
// Cancel activation if there is a competing Drag and Drop interaction
|
4103
|
+
type: "dragstart",
|
4104
|
+
listener: this.handleDragStart
|
4105
|
+
}
|
4106
|
+
])
|
4107
|
+
);
|
4108
|
+
return () => {
|
4109
|
+
unbindFns.forEach((unbind) => unbind());
|
4110
|
+
};
|
4111
|
+
}
|
4112
|
+
handlePointerDown(event, source, options = {}) {
|
4113
|
+
if (this.disabled || !event.isPrimary || event.button !== 0 || !isElement(event.target) || source.disabled) {
|
4114
|
+
return;
|
4115
|
+
}
|
4116
|
+
const offset = getFrameTransform(source.element);
|
4117
|
+
this.initialCoordinates = {
|
4118
|
+
x: event.clientX * offset.scaleX + offset.x,
|
4119
|
+
y: event.clientY * offset.scaleY + offset.y
|
4120
|
+
};
|
4121
|
+
this.source = source;
|
4122
|
+
const { activationConstraints } = options;
|
4123
|
+
const constraints = typeof activationConstraints === "function" ? activationConstraints(event, source) : activationConstraints;
|
4124
|
+
event.stopImmediatePropagation();
|
4125
|
+
if (!(constraints == null ? void 0 : constraints.delay) && !(constraints == null ? void 0 : constraints.distance)) {
|
4126
|
+
this.handleStart(source, event);
|
4127
|
+
} else {
|
4128
|
+
const { delay } = constraints;
|
4129
|
+
if (delay) {
|
4130
|
+
const timeout3 = setTimeout(
|
4131
|
+
() => this.handleStart(source, event),
|
4132
|
+
delay.value
|
4133
|
+
);
|
4134
|
+
__privateSet(this, _clearTimeout, () => {
|
4135
|
+
clearTimeout(timeout3);
|
4136
|
+
__privateSet(this, _clearTimeout, void 0);
|
4137
|
+
});
|
4138
|
+
}
|
4139
|
+
}
|
4140
|
+
const cleanup = () => {
|
4141
|
+
var _a;
|
4142
|
+
(_a = __privateGet(this, _clearTimeout)) == null ? void 0 : _a.call(this);
|
4143
|
+
this.initialCoordinates = void 0;
|
4144
|
+
this.source = void 0;
|
4145
|
+
};
|
4146
|
+
this.cleanup.add(cleanup);
|
4147
|
+
}
|
4148
|
+
handlePointerMove(event, doc, options) {
|
4149
|
+
if (!this.source) {
|
4150
|
+
return;
|
4151
|
+
}
|
4152
|
+
const ownerDocument = this.source.element && getDocument(this.source.element);
|
4153
|
+
if (doc !== ownerDocument) {
|
4154
|
+
return;
|
4155
|
+
}
|
4156
|
+
const coordinates = {
|
4157
|
+
x: event.clientX,
|
4158
|
+
y: event.clientY
|
4159
|
+
};
|
4160
|
+
const offset = getFrameTransform(this.source.element);
|
4161
|
+
coordinates.x = coordinates.x * offset.scaleX + offset.x;
|
4162
|
+
coordinates.y = coordinates.y * offset.scaleY + offset.y;
|
4163
|
+
if (this.manager.dragOperation.status.dragging) {
|
4164
|
+
event.preventDefault();
|
4165
|
+
event.stopPropagation();
|
4166
|
+
this.manager.actions.move({ to: coordinates });
|
4167
|
+
return;
|
4168
|
+
}
|
4169
|
+
if (!this.initialCoordinates) {
|
4170
|
+
return;
|
4171
|
+
}
|
4172
|
+
const delta = {
|
4173
|
+
x: coordinates.x - this.initialCoordinates.x,
|
4174
|
+
y: coordinates.y - this.initialCoordinates.y
|
4175
|
+
};
|
4176
|
+
const { activationConstraints } = options;
|
4177
|
+
const constraints = typeof activationConstraints === "function" ? activationConstraints(event, this.source) : activationConstraints;
|
4178
|
+
const { distance, delay } = constraints != null ? constraints : {};
|
4179
|
+
if (distance) {
|
4180
|
+
if (distance.tolerance != null && exceedsDistance(delta, distance.tolerance)) {
|
4181
|
+
return this.handleCancel();
|
4182
|
+
}
|
4183
|
+
if (exceedsDistance(delta, distance.value)) {
|
4184
|
+
return this.handleStart(this.source, event);
|
4185
|
+
}
|
4186
|
+
}
|
4187
|
+
if (delay) {
|
4188
|
+
if (exceedsDistance(delta, delay.tolerance)) {
|
4189
|
+
return this.handleCancel();
|
4190
|
+
}
|
4191
|
+
}
|
4192
|
+
}
|
4193
|
+
handlePointerUp(event) {
|
4194
|
+
event.preventDefault();
|
4195
|
+
event.stopPropagation();
|
4196
|
+
const { status } = this.manager.dragOperation;
|
4197
|
+
if (!status.idle) {
|
4198
|
+
const canceled = !status.initialized;
|
4199
|
+
this.manager.actions.stop({ canceled });
|
4200
|
+
}
|
4201
|
+
this.cleanup.forEach((cleanup) => cleanup());
|
4202
|
+
this.cleanup.clear();
|
4203
|
+
}
|
4204
|
+
handleKeyDown(event) {
|
4205
|
+
if (event.key === "Escape") {
|
4206
|
+
event.preventDefault();
|
4207
|
+
this.handleCancel();
|
4208
|
+
}
|
4209
|
+
}
|
4210
|
+
handleStart(source, event) {
|
4211
|
+
var _a;
|
4212
|
+
const { manager, initialCoordinates } = this;
|
4213
|
+
(_a = __privateGet(this, _clearTimeout)) == null ? void 0 : _a.call(this);
|
4214
|
+
if (!initialCoordinates || manager.dragOperation.status.initialized) {
|
4215
|
+
return;
|
4216
|
+
}
|
4217
|
+
if (event.defaultPrevented) {
|
4218
|
+
return;
|
4219
|
+
}
|
4220
|
+
event.preventDefault();
|
4221
|
+
batch(() => {
|
4222
|
+
manager.actions.setDragSource(source.id);
|
4223
|
+
manager.actions.start({ coordinates: initialCoordinates, event });
|
4224
|
+
});
|
4225
|
+
const ownerDocument = getDocument(event.target);
|
4226
|
+
const unbind = this.listeners.bind(ownerDocument, [
|
4227
|
+
{
|
4228
|
+
// Prevent scrolling on touch devices
|
4229
|
+
type: "touchmove",
|
4230
|
+
listener: preventDefault,
|
4231
|
+
options: {
|
4232
|
+
passive: false
|
4233
|
+
}
|
4234
|
+
},
|
4235
|
+
{
|
4236
|
+
// Prevent click events
|
4237
|
+
type: "click",
|
4238
|
+
listener: preventDefault
|
4239
|
+
},
|
4240
|
+
{
|
4241
|
+
type: "keydown",
|
4242
|
+
listener: this.handleKeyDown
|
4243
|
+
}
|
4244
|
+
]);
|
4245
|
+
ownerDocument.body.setPointerCapture(event.pointerId);
|
4246
|
+
this.cleanup.add(unbind);
|
4247
|
+
}
|
4248
|
+
handleDragStart(event) {
|
4249
|
+
const { target } = event;
|
4250
|
+
if (!isElement(target)) {
|
4251
|
+
return;
|
4252
|
+
}
|
4253
|
+
const isNativeDraggable = isHTMLElement(target) && target.draggable && target.getAttribute("draggable") === "true";
|
4254
|
+
if (isNativeDraggable) {
|
4255
|
+
this.handleCancel();
|
4256
|
+
} else {
|
4257
|
+
preventDefault(event);
|
4258
|
+
}
|
4259
|
+
}
|
4260
|
+
handleCancel() {
|
4261
|
+
const { dragOperation } = this.manager;
|
4262
|
+
if (dragOperation.status.initialized) {
|
4263
|
+
this.manager.actions.stop({ canceled: true });
|
4264
|
+
}
|
4265
|
+
this.cleanup.forEach((cleanup) => cleanup());
|
4266
|
+
this.cleanup.clear();
|
4267
|
+
}
|
4268
|
+
destroy() {
|
4269
|
+
this.listeners.clear();
|
4270
|
+
}
|
4271
|
+
};
|
4272
|
+
_clearTimeout = new WeakMap();
|
4273
|
+
_PointerSensor.configure = configurator(_PointerSensor);
|
4274
|
+
var PointerSensor = _PointerSensor;
|
4275
|
+
function preventDefault(event) {
|
4276
|
+
event.preventDefault();
|
4277
|
+
}
|
4278
|
+
function noop() {
|
4279
|
+
}
|
4280
|
+
var windows = /* @__PURE__ */ new WeakSet();
|
4281
|
+
function patchWindow(window2) {
|
4282
|
+
if (!window2 || windows.has(window2)) {
|
4283
|
+
return;
|
4284
|
+
}
|
4285
|
+
window2.addEventListener("touchmove", noop, {
|
4286
|
+
capture: false,
|
4287
|
+
passive: false
|
4288
|
+
});
|
4289
|
+
windows.add(window2);
|
4290
|
+
}
|
4291
|
+
|
4292
|
+
// components/DragDropContext/index.tsx
|
4293
|
+
import { jsx as jsx24 } from "react/jsx-runtime";
|
4294
|
+
var dragListenerContext = createContext3({
|
4295
|
+
dragListeners: {}
|
4296
|
+
});
|
4297
|
+
function useDragListener(type, fn, deps = []) {
|
4298
|
+
const { setDragListeners } = useContext4(dragListenerContext);
|
4299
|
+
useEffect13(() => {
|
4300
|
+
if (setDragListeners) {
|
4301
|
+
setDragListeners((old) => __spreadProps(__spreadValues({}, old), {
|
4302
|
+
[type]: [...old[type] || [], fn]
|
4303
|
+
}));
|
4304
|
+
}
|
4305
|
+
}, deps);
|
4306
|
+
}
|
4307
|
+
var previewContext = createContext3(null);
|
4308
|
+
var AREA_CHANGE_DEBOUNCE_MS = 100;
|
4309
|
+
var DragDropContextClient = ({ children }) => {
|
4310
|
+
const { state, config, dispatch, resolveData } = useAppContext();
|
4311
|
+
const [preview, setPreview] = useState15(null);
|
4312
|
+
const previewRef = useRef5(null);
|
4313
|
+
const { data } = state;
|
4314
|
+
const [deepest, setDeepest] = useState15(null);
|
4315
|
+
const [nextDeepest, setNextDeepest] = useState15(null);
|
4316
|
+
const deepestRef = useRef5(deepest);
|
4317
|
+
const dbDeepestRef = useRef5(deepest);
|
4318
|
+
const setDeepestDb = useDebouncedCallback2((params) => {
|
4319
|
+
setDeepest(params);
|
4320
|
+
dbDeepestRef.current = params;
|
4321
|
+
}, AREA_CHANGE_DEBOUNCE_MS);
|
4322
|
+
const setDeepestDbMaybe = useCallback9(
|
4323
|
+
(params) => {
|
4324
|
+
var _a, _b;
|
4325
|
+
if (deepestRef.current === null || ((_a = deepestRef.current) == null ? void 0 : _a.zone) === "void" || params.zone && params.area && ((_b = dbDeepestRef.current) == null ? void 0 : _b.area) === params.area) {
|
4326
|
+
setDeepest(params);
|
4327
|
+
} else {
|
4328
|
+
setDeepestDb(params);
|
4329
|
+
}
|
4330
|
+
if (!dbDeepestRef.current) {
|
4331
|
+
dbDeepestRef.current = params;
|
4332
|
+
}
|
4333
|
+
},
|
4334
|
+
[deepest]
|
4335
|
+
);
|
4336
|
+
const [plugins] = useState15(() => [
|
4337
|
+
...defaultPreset.plugins,
|
4338
|
+
createNestedDroppablePlugin({
|
4339
|
+
onChange: (params, manager) => {
|
4340
|
+
var _a, _b, _c;
|
4341
|
+
const paramsChanged = !deepestRef.current || params.area !== ((_a = deepestRef.current) == null ? void 0 : _a.area) || params.zone !== ((_b = deepestRef.current) == null ? void 0 : _b.zone);
|
4342
|
+
if (paramsChanged) {
|
4343
|
+
if (manager.dragOperation.status.dragging) {
|
4344
|
+
setDeepestDbMaybe(params);
|
4345
|
+
} else {
|
4346
|
+
setDeepest(params);
|
4347
|
+
}
|
4348
|
+
setNextDeepest(params);
|
4349
|
+
}
|
4350
|
+
if (params.area !== ((_c = deepestRef.current) == null ? void 0 : _c.area)) {
|
4351
|
+
setTimeout(() => {
|
4352
|
+
manager.collisionObserver.forceUpdate(true);
|
4353
|
+
}, 50);
|
4354
|
+
}
|
4355
|
+
deepestRef.current = params;
|
4356
|
+
}
|
4357
|
+
})
|
4358
|
+
]);
|
4359
|
+
const [sensors] = useState15(() => [
|
4360
|
+
PointerSensor.configure({
|
4361
|
+
activationConstraints(event, source) {
|
4362
|
+
var _a;
|
4363
|
+
const { pointerType, target } = event;
|
4364
|
+
if (pointerType === "mouse" && isElement2(target) && (source.handle === target || ((_a = source.handle) == null ? void 0 : _a.contains(target)))) {
|
4365
|
+
return void 0;
|
4366
|
+
}
|
4367
|
+
const delay = { value: 200, tolerance: 10 };
|
4368
|
+
if (pointerType === "touch") {
|
4369
|
+
return { delay };
|
4370
|
+
}
|
4371
|
+
return {
|
4372
|
+
delay,
|
4373
|
+
distance: { value: 5 }
|
4374
|
+
};
|
4375
|
+
}
|
4376
|
+
})
|
4377
|
+
]);
|
4378
|
+
const [draggedItem, setDraggedItem] = useState15();
|
4379
|
+
const [dragListeners, setDragListeners] = useState15({});
|
4380
|
+
const [pathData, setPathData] = useState15();
|
4381
|
+
const dragMode = useRef5(null);
|
4382
|
+
const registerPath = useCallback9(
|
4383
|
+
(selector) => {
|
4384
|
+
const item = getItem(selector, data);
|
4385
|
+
if (!item) {
|
4386
|
+
return;
|
4387
|
+
}
|
4388
|
+
const [area] = getZoneId(selector.zone);
|
4389
|
+
setPathData((latestPathData = {}) => {
|
4390
|
+
const parentPathData = latestPathData[area] || { path: [] };
|
4391
|
+
return __spreadProps(__spreadValues({}, latestPathData), {
|
4392
|
+
[item.props.id]: {
|
4393
|
+
path: [
|
4394
|
+
...parentPathData.path,
|
4395
|
+
...selector.zone ? [selector.zone] : []
|
4396
|
+
],
|
4397
|
+
label: item.type
|
4398
|
+
}
|
4399
|
+
});
|
4400
|
+
});
|
4401
|
+
},
|
4402
|
+
[data, setPathData]
|
4403
|
+
);
|
4404
|
+
const initialSelector = useRef5();
|
4405
|
+
return /* @__PURE__ */ jsx24(
|
4406
|
+
dragListenerContext.Provider,
|
4407
|
+
{
|
4408
|
+
value: {
|
4409
|
+
dragListeners,
|
4410
|
+
setDragListeners
|
4411
|
+
},
|
4412
|
+
children: /* @__PURE__ */ jsx24(previewContext.Provider, { value: preview, children: /* @__PURE__ */ jsx24(
|
4413
|
+
DragDropProvider,
|
4414
|
+
{
|
4415
|
+
plugins,
|
4416
|
+
sensors,
|
4417
|
+
onDragEnd: (event, manager) => {
|
4418
|
+
const { source, target } = event.operation;
|
4419
|
+
deepestRef.current = null;
|
4420
|
+
if (!source) {
|
4421
|
+
setDraggedItem(null);
|
4422
|
+
return;
|
4423
|
+
}
|
4424
|
+
const { zone, index } = source.data;
|
4425
|
+
const thisPreview = previewRef.current ? __spreadValues({}, previewRef.current) : null;
|
4426
|
+
previewRef.current = null;
|
4427
|
+
setTimeout(() => {
|
4428
|
+
var _a, _b;
|
4429
|
+
setDraggedItem(null);
|
4430
|
+
if (event.canceled || (target == null ? void 0 : target.type) === "void") {
|
4431
|
+
setPreview(null);
|
4432
|
+
(_a = dragListeners.dragend) == null ? void 0 : _a.forEach((fn) => {
|
4433
|
+
fn(event, manager);
|
4434
|
+
});
|
4435
|
+
return;
|
4436
|
+
}
|
4437
|
+
if (thisPreview) {
|
4438
|
+
setPreview(null);
|
4439
|
+
if (thisPreview.type === "insert") {
|
4440
|
+
insertComponent(
|
4441
|
+
thisPreview.componentType,
|
4442
|
+
thisPreview.zone,
|
4443
|
+
thisPreview.index,
|
4444
|
+
{ config, dispatch, resolveData, state }
|
4445
|
+
);
|
4446
|
+
} else if (initialSelector.current) {
|
4447
|
+
dispatch({
|
4448
|
+
type: "move",
|
4449
|
+
sourceIndex: initialSelector.current.index,
|
4450
|
+
sourceZone: initialSelector.current.zone,
|
4451
|
+
destinationIndex: thisPreview.index,
|
4452
|
+
destinationZone: thisPreview.zone,
|
4453
|
+
recordHistory: false
|
4454
|
+
});
|
4455
|
+
}
|
4456
|
+
}
|
4457
|
+
dispatch({
|
4458
|
+
type: "setUi",
|
4459
|
+
ui: {
|
4460
|
+
itemSelector: { index, zone },
|
4461
|
+
isDragging: false
|
4462
|
+
},
|
4463
|
+
recordHistory: true
|
4464
|
+
});
|
4465
|
+
(_b = dragListeners.dragend) == null ? void 0 : _b.forEach((fn) => {
|
4466
|
+
fn(event, manager);
|
4467
|
+
});
|
4468
|
+
}, 300);
|
4469
|
+
},
|
4470
|
+
onDragOver: (event, manager) => {
|
4471
|
+
var _a, _b, _c, _d;
|
4472
|
+
event.preventDefault();
|
4473
|
+
if (!draggedItem) return;
|
4474
|
+
const { source, target } = event.operation;
|
4475
|
+
if (!target || !source || target.type === "void") return;
|
4476
|
+
const [sourceId] = source.id.split(":");
|
4477
|
+
const [targetId] = target.id.split(":");
|
4478
|
+
const sourceData = source.data;
|
4479
|
+
let sourceZone = sourceData.zone;
|
4480
|
+
let sourceIndex = sourceData.index;
|
4481
|
+
let targetZone = "";
|
4482
|
+
let targetIndex = 0;
|
4483
|
+
if (target.type === "component") {
|
4484
|
+
const targetData = target.data;
|
4485
|
+
targetZone = targetData.zone;
|
4486
|
+
targetIndex = targetData.index;
|
4487
|
+
const collisionData = (_b = (_a = manager.dragOperation.data) == null ? void 0 : _a.collisionMap) == null ? void 0 : _b[targetId];
|
4488
|
+
const collisionPosition = (collisionData == null ? void 0 : collisionData.direction) === "up" || (collisionData == null ? void 0 : collisionData.direction) === "left" ? "before" : "after";
|
4489
|
+
if (targetIndex >= sourceIndex && sourceZone === targetZone) {
|
4490
|
+
targetIndex = targetIndex - 1;
|
4491
|
+
}
|
4492
|
+
if (collisionPosition === "after") {
|
4493
|
+
targetIndex = targetIndex + 1;
|
4494
|
+
}
|
4495
|
+
} else {
|
4496
|
+
targetZone = target.id.toString();
|
4497
|
+
targetIndex = 0;
|
4498
|
+
}
|
4499
|
+
if (targetId === sourceId || ((_c = pathData == null ? void 0 : pathData[target.id]) == null ? void 0 : _c.path.find((path) => {
|
4500
|
+
const [pathId] = path.split(":");
|
4501
|
+
return pathId === sourceId;
|
4502
|
+
}))) {
|
4503
|
+
return;
|
4504
|
+
}
|
4505
|
+
if (dragMode.current === "new") {
|
4506
|
+
previewRef.current = {
|
4507
|
+
componentType: sourceData.componentType,
|
4508
|
+
type: "insert",
|
4509
|
+
index: targetIndex,
|
4510
|
+
zone: targetZone,
|
4511
|
+
props: {
|
4512
|
+
id: source.id.toString()
|
4513
|
+
}
|
4514
|
+
};
|
4515
|
+
setPreview(previewRef.current);
|
4516
|
+
} else {
|
4517
|
+
if (!initialSelector.current) {
|
4518
|
+
initialSelector.current = {
|
4519
|
+
zone: sourceData.zone,
|
4520
|
+
index: sourceData.index
|
4521
|
+
};
|
4522
|
+
}
|
4523
|
+
const item = getItem(initialSelector.current, data);
|
4524
|
+
if (item) {
|
4525
|
+
previewRef.current = {
|
4526
|
+
componentType: sourceData.componentType,
|
4527
|
+
type: "move",
|
4528
|
+
index: targetIndex,
|
4529
|
+
zone: targetZone,
|
4530
|
+
props: item.props
|
4531
|
+
};
|
4532
|
+
setPreview(previewRef.current);
|
4533
|
+
}
|
4534
|
+
}
|
4535
|
+
(_d = dragListeners.dragover) == null ? void 0 : _d.forEach((fn) => {
|
4536
|
+
fn(event, manager);
|
4537
|
+
});
|
4538
|
+
},
|
4539
|
+
onDragStart: (event, manager) => {
|
4540
|
+
var _a;
|
4541
|
+
setDeepest(
|
4542
|
+
findDeepestCandidate(event.operation.position.current, manager)
|
4543
|
+
);
|
4544
|
+
dispatch({
|
4545
|
+
type: "setUi",
|
4546
|
+
ui: { itemSelector: null, isDragging: true }
|
4547
|
+
});
|
4548
|
+
(_a = dragListeners.dragstart) == null ? void 0 : _a.forEach((fn) => {
|
4549
|
+
fn(event, manager);
|
4550
|
+
});
|
4551
|
+
},
|
4552
|
+
onBeforeDragStart: (event) => {
|
4553
|
+
var _a;
|
4554
|
+
if (draggedItem) {
|
4555
|
+
console.warn("New drag started before previous drag cleaned up");
|
4556
|
+
}
|
4557
|
+
const isNewComponent = ((_a = event.operation.source) == null ? void 0 : _a.data.type) === "drawer";
|
4558
|
+
dragMode.current = isNewComponent ? "new" : "existing";
|
4559
|
+
initialSelector.current = void 0;
|
4560
|
+
setDraggedItem(event.operation.source);
|
4561
|
+
},
|
4562
|
+
children: /* @__PURE__ */ jsx24(
|
4563
|
+
DropZoneProvider,
|
4564
|
+
{
|
4565
|
+
value: {
|
4566
|
+
data,
|
4567
|
+
config,
|
4568
|
+
dispatch,
|
4569
|
+
draggedItem,
|
4570
|
+
mode: "edit",
|
4571
|
+
areaId: "root",
|
4572
|
+
depth: 0,
|
4573
|
+
registerPath,
|
4574
|
+
pathData,
|
4575
|
+
deepestZone: deepest == null ? void 0 : deepest.zone,
|
4576
|
+
deepestArea: deepest == null ? void 0 : deepest.area,
|
4577
|
+
nextDeepestZone: nextDeepest == null ? void 0 : nextDeepest.zone,
|
4578
|
+
nextDeepestArea: nextDeepest == null ? void 0 : nextDeepest.area,
|
4579
|
+
path: []
|
4580
|
+
},
|
4581
|
+
children
|
4582
|
+
}
|
4583
|
+
)
|
4584
|
+
}
|
4585
|
+
) })
|
4586
|
+
}
|
4587
|
+
);
|
4588
|
+
};
|
4589
|
+
var DragDropContext2 = ({ children }) => {
|
4590
|
+
const { status } = useAppContext();
|
4591
|
+
if (status === "LOADING") {
|
4592
|
+
return children;
|
4593
|
+
}
|
4594
|
+
return /* @__PURE__ */ jsx24(DragDropContextClient, { children });
|
4595
|
+
};
|
4596
|
+
|
4597
|
+
// components/Drawer/index.tsx
|
4598
|
+
import { jsx as jsx25, jsxs as jsxs12 } from "react/jsx-runtime";
|
4599
|
+
var getClassName18 = get_class_name_factory_default("Drawer", styles_module_default10);
|
4600
|
+
var getClassNameItem2 = get_class_name_factory_default("DrawerItem", styles_module_default10);
|
4601
|
+
var DrawerItemInner = ({
|
4602
|
+
children,
|
4603
|
+
name,
|
4604
|
+
label,
|
4605
|
+
dragRef,
|
4606
|
+
isDragDisabled
|
4607
|
+
}) => {
|
4608
|
+
const CustomInner = useMemo5(
|
4609
|
+
() => children || (({ children: children2 }) => /* @__PURE__ */ jsx25("div", { className: getClassNameItem2("default"), children: children2 })),
|
4610
|
+
[children]
|
4611
|
+
);
|
4612
|
+
return /* @__PURE__ */ jsx25(
|
4613
|
+
"div",
|
4614
|
+
{
|
4615
|
+
className: getClassNameItem2({ disabled: isDragDisabled }),
|
4616
|
+
ref: dragRef,
|
4617
|
+
onMouseDown: (e) => e.preventDefault(),
|
4618
|
+
children: /* @__PURE__ */ jsx25(CustomInner, { name, children: /* @__PURE__ */ jsx25("div", { className: getClassNameItem2("draggableWrapper"), children: /* @__PURE__ */ jsxs12("div", { className: getClassNameItem2("draggable"), children: [
|
4619
|
+
/* @__PURE__ */ jsx25("div", { className: getClassNameItem2("name"), children: label != null ? label : name }),
|
4620
|
+
/* @__PURE__ */ jsx25("div", { className: getClassNameItem2("icon"), children: /* @__PURE__ */ jsx25(DragIcon, {}) })
|
4621
|
+
] }) }) })
|
4622
|
+
}
|
4623
|
+
);
|
4624
|
+
};
|
4625
|
+
var DrawerItemDraggable = ({
|
4626
|
+
children,
|
4627
|
+
name,
|
4628
|
+
label,
|
4629
|
+
id,
|
4630
|
+
isDragDisabled
|
4631
|
+
}) => {
|
4632
|
+
const { ref } = useDraggableSafe({
|
4633
|
+
id,
|
4634
|
+
data: { type: "drawer", componentType: name },
|
4635
|
+
disabled: isDragDisabled
|
4636
|
+
});
|
4637
|
+
return /* @__PURE__ */ jsx25(
|
4638
|
+
DrawerItemInner,
|
4639
|
+
{
|
4640
|
+
name,
|
4641
|
+
label,
|
4642
|
+
dragRef: ref,
|
4643
|
+
isDragDisabled,
|
4644
|
+
children
|
4645
|
+
}
|
4646
|
+
);
|
4647
|
+
};
|
4648
|
+
var DrawerItem = ({
|
4649
|
+
name,
|
4650
|
+
children,
|
4651
|
+
id,
|
4652
|
+
label,
|
4653
|
+
index,
|
4654
|
+
isDragDisabled
|
4655
|
+
}) => {
|
4656
|
+
const resolvedId = id || name;
|
4657
|
+
const [dynamicId, setDynamicId] = useState16(generateId(resolvedId));
|
4658
|
+
if (typeof index !== "undefined") {
|
4659
|
+
console.error(
|
4660
|
+
"Warning: The `index` prop on Drawer.Item is deprecated and no longer required."
|
4661
|
+
);
|
4662
|
+
}
|
4663
|
+
useDragListener(
|
4664
|
+
"dragend",
|
4665
|
+
() => {
|
4666
|
+
setDynamicId(generateId(resolvedId));
|
4667
|
+
},
|
4668
|
+
[resolvedId]
|
4669
|
+
);
|
4670
|
+
return /* @__PURE__ */ jsx25("div", { children: /* @__PURE__ */ jsx25(
|
4671
|
+
DrawerItemDraggable,
|
4672
|
+
{
|
4673
|
+
name,
|
4674
|
+
label,
|
4675
|
+
id: dynamicId,
|
4676
|
+
isDragDisabled,
|
4677
|
+
children
|
4678
|
+
}
|
4679
|
+
) }, dynamicId);
|
4680
|
+
};
|
4681
|
+
var Drawer = ({
|
4682
|
+
children,
|
4683
|
+
droppableId,
|
4684
|
+
direction
|
4685
|
+
}) => {
|
4686
|
+
if (droppableId) {
|
4687
|
+
console.error(
|
4688
|
+
"Warning: The `droppableId` prop on Drawer is deprecated and no longer required."
|
4689
|
+
);
|
4690
|
+
}
|
4691
|
+
if (direction) {
|
4692
|
+
console.error(
|
4693
|
+
"Warning: The `direction` prop on Drawer is deprecated and no longer required to achieve multi-directional dragging."
|
4694
|
+
);
|
4695
|
+
}
|
4696
|
+
const [id] = useState16(generateId());
|
4697
|
+
const { ref } = useDroppableSafe({
|
4698
|
+
id,
|
4699
|
+
type: "void",
|
4700
|
+
collisionPriority: 0
|
4701
|
+
// Never collide with this, but we use it so NestedDroppablePlugin respects the Drawer
|
4702
|
+
});
|
4703
|
+
return /* @__PURE__ */ jsx25("div", { className: getClassName18(), ref, children });
|
4704
|
+
};
|
4705
|
+
Drawer.Item = DrawerItem;
|
4706
|
+
|
4707
|
+
// components/Puck/index.tsx
|
4708
|
+
init_react_import();
|
4709
|
+
import {
|
4710
|
+
useCallback as useCallback14,
|
4711
|
+
useEffect as useEffect21,
|
4712
|
+
useMemo as useMemo14,
|
4713
|
+
useReducer,
|
4714
|
+
useState as useState24
|
4715
|
+
} from "react";
|
4716
|
+
|
4717
|
+
// components/SidebarSection/index.tsx
|
4718
|
+
init_react_import();
|
4719
|
+
|
4720
|
+
// css-module:/home/runner/work/puck/puck/packages/core/components/SidebarSection/styles.module.css#css-module
|
4721
|
+
init_react_import();
|
4722
|
+
var styles_module_default13 = { "SidebarSection": "_SidebarSection_125qe_1", "SidebarSection-title": "_SidebarSection-title_125qe_12", "SidebarSection--noBorderTop": "_SidebarSection--noBorderTop_125qe_20", "SidebarSection-content": "_SidebarSection-content_125qe_24", "SidebarSection--noPadding": "_SidebarSection--noPadding_125qe_28", "SidebarSection-breadcrumbLabel": "_SidebarSection-breadcrumbLabel_125qe_41", "SidebarSection-breadcrumbs": "_SidebarSection-breadcrumbs_125qe_70", "SidebarSection-breadcrumb": "_SidebarSection-breadcrumb_125qe_41", "SidebarSection-heading": "_SidebarSection-heading_125qe_82", "SidebarSection-loadingOverlay": "_SidebarSection-loadingOverlay_125qe_86" };
|
4723
|
+
|
4724
|
+
// lib/use-breadcrumbs.ts
|
4725
|
+
init_react_import();
|
4726
|
+
import { useContext as useContext5, useMemo as useMemo6 } from "react";
|
4727
|
+
var convertPathDataToBreadcrumbs = (selectedItem, pathData, data) => {
|
4728
|
+
const id = selectedItem ? selectedItem == null ? void 0 : selectedItem.props.id : "";
|
4729
|
+
const currentPathData = pathData && id && pathData[id] ? __spreadValues({}, pathData[id]) : { label: "Page", path: [] };
|
4730
|
+
if (!id) {
|
4731
|
+
return [];
|
4732
|
+
}
|
4733
|
+
return currentPathData == null ? void 0 : currentPathData.path.reduce((acc, zoneCompound) => {
|
4734
|
+
const [area] = getZoneId(zoneCompound);
|
4735
|
+
if (area === rootDroppableId) {
|
4736
|
+
return [
|
4737
|
+
{
|
4738
|
+
label: "Page",
|
4739
|
+
selector: null
|
4740
|
+
}
|
4741
|
+
];
|
4742
|
+
}
|
4743
|
+
const parentZoneCompound = acc.length > 0 ? acc[acc.length - 1].zoneCompound : rootDroppableId;
|
4744
|
+
let parentZone = data.content;
|
4745
|
+
if (parentZoneCompound && parentZoneCompound !== rootDroppableId) {
|
4746
|
+
parentZone = data.zones[parentZoneCompound];
|
4747
|
+
}
|
4748
|
+
if (!parentZone) {
|
4749
|
+
return acc;
|
4750
|
+
}
|
4751
|
+
const itemIndex = parentZone.findIndex(
|
4752
|
+
(queryItem) => queryItem.props.id === area
|
4753
|
+
);
|
4754
|
+
const item = parentZone[itemIndex];
|
4755
|
+
if (!item) {
|
4756
|
+
return acc;
|
4757
|
+
}
|
4758
|
+
return [
|
4759
|
+
...acc,
|
4760
|
+
{
|
4761
|
+
label: item.type.toString(),
|
4762
|
+
selector: {
|
4763
|
+
index: itemIndex,
|
4764
|
+
zone: parentZoneCompound
|
4765
|
+
},
|
4766
|
+
zoneCompound
|
4767
|
+
}
|
4768
|
+
];
|
4769
|
+
}, []);
|
4770
|
+
};
|
4771
|
+
var useBreadcrumbs = (renderCount) => {
|
4772
|
+
const {
|
4773
|
+
state: { data },
|
4774
|
+
selectedItem
|
4775
|
+
} = useAppContext();
|
4776
|
+
const dzContext = useContext5(dropZoneContext);
|
4777
|
+
return useMemo6(() => {
|
4778
|
+
const breadcrumbs = convertPathDataToBreadcrumbs(
|
4779
|
+
selectedItem,
|
4780
|
+
dzContext == null ? void 0 : dzContext.pathData,
|
4781
|
+
data
|
4782
|
+
);
|
4783
|
+
if (renderCount) {
|
4784
|
+
return breadcrumbs.slice(breadcrumbs.length - renderCount);
|
4785
|
+
}
|
4786
|
+
return breadcrumbs;
|
4787
|
+
}, [selectedItem, dzContext == null ? void 0 : dzContext.pathData, renderCount]);
|
4788
|
+
};
|
4789
|
+
|
4790
|
+
// components/SidebarSection/index.tsx
|
4791
|
+
import { jsx as jsx26, jsxs as jsxs13 } from "react/jsx-runtime";
|
4792
|
+
var getClassName19 = get_class_name_factory_default("SidebarSection", styles_module_default13);
|
4793
|
+
var SidebarSection = ({
|
4794
|
+
children,
|
4795
|
+
title,
|
4796
|
+
background,
|
4797
|
+
showBreadcrumbs,
|
4798
|
+
noBorderTop,
|
4799
|
+
noPadding,
|
4800
|
+
isLoading
|
4801
|
+
}) => {
|
4802
|
+
const { setUi } = useAppContext();
|
4803
|
+
const breadcrumbs = useBreadcrumbs(1);
|
4804
|
+
return /* @__PURE__ */ jsxs13(
|
4805
|
+
"div",
|
4806
|
+
{
|
4807
|
+
className: getClassName19({ noBorderTop, noPadding }),
|
4808
|
+
style: { background },
|
4809
|
+
children: [
|
4810
|
+
/* @__PURE__ */ jsx26("div", { className: getClassName19("title"), children: /* @__PURE__ */ jsxs13("div", { className: getClassName19("breadcrumbs"), children: [
|
4811
|
+
showBreadcrumbs ? breadcrumbs.map((breadcrumb, i) => /* @__PURE__ */ jsxs13("div", { className: getClassName19("breadcrumb"), children: [
|
4812
|
+
/* @__PURE__ */ jsx26(
|
4813
|
+
"button",
|
4814
|
+
{
|
4815
|
+
type: "button",
|
4816
|
+
className: getClassName19("breadcrumbLabel"),
|
4817
|
+
onClick: () => setUi({ itemSelector: breadcrumb.selector }),
|
4818
|
+
children: breadcrumb.label
|
4819
|
+
}
|
4820
|
+
),
|
4821
|
+
/* @__PURE__ */ jsx26(ChevronRight, { size: 16 })
|
4822
|
+
] }, i)) : null,
|
4823
|
+
/* @__PURE__ */ jsx26("div", { className: getClassName19("heading"), children: /* @__PURE__ */ jsx26(Heading, { rank: "2", size: "xs", children: title }) })
|
4824
|
+
] }) }),
|
4825
|
+
/* @__PURE__ */ jsx26("div", { className: getClassName19("content"), children }),
|
4826
|
+
isLoading && /* @__PURE__ */ jsx26("div", { className: getClassName19("loadingOverlay"), children: /* @__PURE__ */ jsx26(Loader, { size: 32 }) })
|
4827
|
+
]
|
4828
|
+
}
|
4829
|
+
);
|
4830
|
+
};
|
3494
4831
|
|
3495
4832
|
// lib/flush-zones.ts
|
3496
4833
|
init_react_import();
|
@@ -3517,7 +4854,7 @@ init_react_import();
|
|
3517
4854
|
var styles_module_default14 = { "MenuBar": "_MenuBar_8pf8c_1", "MenuBar--menuOpen": "_MenuBar--menuOpen_8pf8c_14", "MenuBar-inner": "_MenuBar-inner_8pf8c_29", "MenuBar-history": "_MenuBar-history_8pf8c_45" };
|
3518
4855
|
|
3519
4856
|
// components/MenuBar/index.tsx
|
3520
|
-
import { Fragment as Fragment11, jsx as
|
4857
|
+
import { Fragment as Fragment11, jsx as jsx27, jsxs as jsxs14 } from "react/jsx-runtime";
|
3521
4858
|
var getClassName20 = get_class_name_factory_default("MenuBar", styles_module_default14);
|
3522
4859
|
function MenuBar({
|
3523
4860
|
appState,
|
@@ -3531,7 +4868,7 @@ function MenuBar({
|
|
3531
4868
|
history: { back, forward, historyStore }
|
3532
4869
|
} = useAppContext();
|
3533
4870
|
const { hasFuture = false, hasPast = false } = historyStore || {};
|
3534
|
-
return /* @__PURE__ */
|
4871
|
+
return /* @__PURE__ */ jsx27(
|
3535
4872
|
"div",
|
3536
4873
|
{
|
3537
4874
|
className: getClassName20({ menuOpen }),
|
@@ -3547,10 +4884,10 @@ function MenuBar({
|
|
3547
4884
|
},
|
3548
4885
|
children: /* @__PURE__ */ jsxs14("div", { className: getClassName20("inner"), children: [
|
3549
4886
|
/* @__PURE__ */ jsxs14("div", { className: getClassName20("history"), children: [
|
3550
|
-
/* @__PURE__ */
|
3551
|
-
/* @__PURE__ */
|
4887
|
+
/* @__PURE__ */ jsx27(IconButton, { title: "undo", disabled: !hasPast, onClick: back, children: /* @__PURE__ */ jsx27(Undo2, { size: 21 }) }),
|
4888
|
+
/* @__PURE__ */ jsx27(IconButton, { title: "redo", disabled: !hasFuture, onClick: forward, children: /* @__PURE__ */ jsx27(Redo2, { size: 21 }) })
|
3552
4889
|
] }),
|
3553
|
-
/* @__PURE__ */
|
4890
|
+
/* @__PURE__ */ jsx27(Fragment11, { children: renderHeaderActions && renderHeaderActions({
|
3554
4891
|
state: appState,
|
3555
4892
|
dispatch
|
3556
4893
|
}) })
|
@@ -3571,8 +4908,24 @@ init_react_import();
|
|
3571
4908
|
var styles_module_default16 = { "PuckFields": "_PuckFields_jp3lw_1", "PuckFields--isLoading": "_PuckFields--isLoading_jp3lw_6", "PuckFields-loadingOverlay": "_PuckFields-loadingOverlay_jp3lw_10", "PuckFields-loadingOverlayInner": "_PuckFields-loadingOverlayInner_jp3lw_25" };
|
3572
4909
|
|
3573
4910
|
// components/Puck/components/Fields/index.tsx
|
3574
|
-
import { useCallback as
|
3575
|
-
|
4911
|
+
import { useCallback as useCallback10, useEffect as useEffect14, useMemo as useMemo7, useState as useState17 } from "react";
|
4912
|
+
|
4913
|
+
// lib/use-parent.ts
|
4914
|
+
init_react_import();
|
4915
|
+
import { useContext as useContext6 } from "react";
|
4916
|
+
var useParent = (itemSelector) => {
|
4917
|
+
var _a;
|
4918
|
+
const { selectedItem, state } = useAppContext();
|
4919
|
+
const { pathData } = useContext6(dropZoneContext) || {};
|
4920
|
+
const item = itemSelector ? getItem(itemSelector, state.data) : selectedItem;
|
4921
|
+
const breadcrumbs = convertPathDataToBreadcrumbs(item, pathData, state.data);
|
4922
|
+
const lastItem = breadcrumbs[breadcrumbs.length - 1];
|
4923
|
+
const parent = (lastItem == null ? void 0 : lastItem.selector) ? (_a = getItem(lastItem.selector, state.data)) != null ? _a : null : null;
|
4924
|
+
return parent || null;
|
4925
|
+
};
|
4926
|
+
|
4927
|
+
// components/Puck/components/Fields/index.tsx
|
4928
|
+
import { Fragment as Fragment12, jsx as jsx28, jsxs as jsxs15 } from "react/jsx-runtime";
|
3576
4929
|
var getClassName21 = get_class_name_factory_default("PuckFields", styles_module_default16);
|
3577
4930
|
var defaultPageFields = {
|
3578
4931
|
title: { type: "text" }
|
@@ -3580,28 +4933,29 @@ var defaultPageFields = {
|
|
3580
4933
|
var DefaultFields = ({
|
3581
4934
|
children
|
3582
4935
|
}) => {
|
3583
|
-
return /* @__PURE__ */
|
4936
|
+
return /* @__PURE__ */ jsx28(Fragment12, { children });
|
3584
4937
|
};
|
3585
4938
|
var useResolvedFields = () => {
|
3586
4939
|
var _a, _b;
|
3587
4940
|
const { selectedItem, state, config } = useAppContext();
|
4941
|
+
const parent = useParent();
|
3588
4942
|
const { data } = state;
|
3589
4943
|
const rootFields = ((_a = config.root) == null ? void 0 : _a.fields) || defaultPageFields;
|
3590
4944
|
const componentConfig = selectedItem ? config.components[selectedItem.type] : null;
|
3591
|
-
const defaultFields =
|
4945
|
+
const defaultFields = useMemo7(
|
3592
4946
|
() => (selectedItem ? componentConfig == null ? void 0 : componentConfig.fields : rootFields) || {},
|
3593
4947
|
[selectedItem, rootFields, componentConfig == null ? void 0 : componentConfig.fields]
|
3594
4948
|
);
|
3595
4949
|
const rootProps = data.root.props || data.root;
|
3596
|
-
const [lastSelectedData, setLastSelectedData] =
|
3597
|
-
const [resolvedFields, setResolvedFields] =
|
3598
|
-
const [fieldsLoading, setFieldsLoading] =
|
4950
|
+
const [lastSelectedData, setLastSelectedData] = useState17({});
|
4951
|
+
const [resolvedFields, setResolvedFields] = useState17(defaultFields);
|
4952
|
+
const [fieldsLoading, setFieldsLoading] = useState17(false);
|
3599
4953
|
const defaultResolveFields = (_componentData, _params) => defaultFields;
|
3600
4954
|
const componentData = selectedItem ? selectedItem : { props: rootProps, readOnly: data.root.readOnly };
|
3601
4955
|
const hasComponentResolver = selectedItem && (componentConfig == null ? void 0 : componentConfig.resolveFields);
|
3602
4956
|
const hasRootResolver = !selectedItem && ((_b = config.root) == null ? void 0 : _b.resolveFields);
|
3603
4957
|
const hasResolver = hasComponentResolver || hasRootResolver;
|
3604
|
-
const resolveFields =
|
4958
|
+
const resolveFields = useCallback10(
|
3605
4959
|
(..._0) => __async(void 0, [..._0], function* (fields = {}) {
|
3606
4960
|
var _a2;
|
3607
4961
|
const lastData = ((_a2 = lastSelectedData.props) == null ? void 0 : _a2.id) === componentData.props.id ? lastSelectedData : null;
|
@@ -3615,7 +4969,8 @@ var useResolvedFields = () => {
|
|
3615
4969
|
fields,
|
3616
4970
|
lastFields: resolvedFields,
|
3617
4971
|
lastData,
|
3618
|
-
appState: state
|
4972
|
+
appState: state,
|
4973
|
+
parent
|
3619
4974
|
}
|
3620
4975
|
);
|
3621
4976
|
}
|
@@ -3625,7 +4980,8 @@ var useResolvedFields = () => {
|
|
3625
4980
|
fields,
|
3626
4981
|
lastFields: resolvedFields,
|
3627
4982
|
lastData,
|
3628
|
-
appState: state
|
4983
|
+
appState: state,
|
4984
|
+
parent
|
3629
4985
|
});
|
3630
4986
|
}
|
3631
4987
|
return defaultResolveFields(componentData, {
|
@@ -3637,7 +4993,7 @@ var useResolvedFields = () => {
|
|
3637
4993
|
}),
|
3638
4994
|
[data, config, componentData, selectedItem, resolvedFields, state]
|
3639
4995
|
);
|
3640
|
-
|
4996
|
+
useEffect14(() => {
|
3641
4997
|
if (hasResolver) {
|
3642
4998
|
setFieldsLoading(true);
|
3643
4999
|
resolveFields(defaultFields).then((fields) => {
|
@@ -3647,7 +5003,7 @@ var useResolvedFields = () => {
|
|
3647
5003
|
} else {
|
3648
5004
|
setResolvedFields(defaultFields);
|
3649
5005
|
}
|
3650
|
-
}, [data, defaultFields,
|
5006
|
+
}, [data, defaultFields, selectedItem, hasResolver]);
|
3651
5007
|
return [resolvedFields, fieldsLoading];
|
3652
5008
|
};
|
3653
5009
|
var Fields = () => {
|
@@ -3668,7 +5024,7 @@ var Fields = () => {
|
|
3668
5024
|
const componentResolving = selectedItem ? ((_a = componentState[selectedItem == null ? void 0 : selectedItem.props.id]) == null ? void 0 : _a.loadingCount) > 0 : ((_b = componentState["puck-root"]) == null ? void 0 : _b.loadingCount) > 0;
|
3669
5025
|
const isLoading = fieldsResolving || componentResolving;
|
3670
5026
|
const rootProps = data.root.props || data.root;
|
3671
|
-
const Wrapper =
|
5027
|
+
const Wrapper = useMemo7(() => overrides.fields || DefaultFields, [overrides]);
|
3672
5028
|
return /* @__PURE__ */ jsxs15(
|
3673
5029
|
"form",
|
3674
5030
|
{
|
@@ -3677,7 +5033,7 @@ var Fields = () => {
|
|
3677
5033
|
e.preventDefault();
|
3678
5034
|
},
|
3679
5035
|
children: [
|
3680
|
-
/* @__PURE__ */
|
5036
|
+
/* @__PURE__ */ jsx28(Wrapper, { isLoading, itemSelector, children: Object.keys(fields).map((fieldName) => {
|
3681
5037
|
const field = fields[fieldName];
|
3682
5038
|
if (!(field == null ? void 0 : field.type)) return null;
|
3683
5039
|
const onChange = (value, updatedUi) => {
|
@@ -3747,7 +5103,7 @@ var Fields = () => {
|
|
3747
5103
|
const { edit } = getPermissions({
|
3748
5104
|
item: selectedItem
|
3749
5105
|
});
|
3750
|
-
return /* @__PURE__ */
|
5106
|
+
return /* @__PURE__ */ jsx28(
|
3751
5107
|
AutoFieldPrivate,
|
3752
5108
|
{
|
3753
5109
|
field,
|
@@ -3764,7 +5120,7 @@ var Fields = () => {
|
|
3764
5120
|
const { edit } = getPermissions({
|
3765
5121
|
root: true
|
3766
5122
|
});
|
3767
|
-
return /* @__PURE__ */
|
5123
|
+
return /* @__PURE__ */ jsx28(
|
3768
5124
|
AutoFieldPrivate,
|
3769
5125
|
{
|
3770
5126
|
field,
|
@@ -3778,7 +5134,7 @@ var Fields = () => {
|
|
3778
5134
|
);
|
3779
5135
|
}
|
3780
5136
|
}) }),
|
3781
|
-
isLoading && /* @__PURE__ */
|
5137
|
+
isLoading && /* @__PURE__ */ jsx28("div", { className: getClassName21("loadingOverlay"), children: /* @__PURE__ */ jsx28("div", { className: getClassName21("loadingOverlayInner"), children: /* @__PURE__ */ jsx28(Loader, { size: 16 }) }) })
|
3782
5138
|
]
|
3783
5139
|
}
|
3784
5140
|
);
|
@@ -3789,7 +5145,7 @@ init_react_import();
|
|
3789
5145
|
|
3790
5146
|
// lib/use-component-list.tsx
|
3791
5147
|
init_react_import();
|
3792
|
-
import { useEffect as
|
5148
|
+
import { useEffect as useEffect15, useState as useState18 } from "react";
|
3793
5149
|
|
3794
5150
|
// components/ComponentList/index.tsx
|
3795
5151
|
init_react_import();
|
@@ -3799,27 +5155,17 @@ init_react_import();
|
|
3799
5155
|
var styles_module_default17 = { "ComponentList": "_ComponentList_odh9d_1", "ComponentList--isExpanded": "_ComponentList--isExpanded_odh9d_5", "ComponentList-content": "_ComponentList-content_odh9d_9", "ComponentList-title": "_ComponentList-title_odh9d_17", "ComponentList-titleIcon": "_ComponentList-titleIcon_odh9d_53" };
|
3800
5156
|
|
3801
5157
|
// components/ComponentList/index.tsx
|
3802
|
-
import { jsx as
|
5158
|
+
import { jsx as jsx29, jsxs as jsxs16 } from "react/jsx-runtime";
|
3803
5159
|
var getClassName22 = get_class_name_factory_default("ComponentList", styles_module_default17);
|
3804
5160
|
var ComponentListItem = ({
|
3805
5161
|
name,
|
3806
|
-
label
|
3807
|
-
index
|
5162
|
+
label
|
3808
5163
|
}) => {
|
3809
5164
|
const { overrides, getPermissions } = useAppContext();
|
3810
5165
|
const canInsert = getPermissions({
|
3811
5166
|
type: name
|
3812
5167
|
}).insert;
|
3813
|
-
return /* @__PURE__ */
|
3814
|
-
Drawer.Item,
|
3815
|
-
{
|
3816
|
-
label,
|
3817
|
-
name,
|
3818
|
-
index,
|
3819
|
-
isDragDisabled: !canInsert,
|
3820
|
-
children: overrides.componentItem
|
3821
|
-
}
|
3822
|
-
);
|
5168
|
+
return /* @__PURE__ */ jsx29(Drawer.Item, { label, name, isDragDisabled: !canInsert, children: overrides.componentItem });
|
3823
5169
|
};
|
3824
5170
|
var ComponentList = ({
|
3825
5171
|
children,
|
@@ -3843,19 +5189,18 @@ var ComponentList = ({
|
|
3843
5189
|
}),
|
3844
5190
|
title: expanded ? `Collapse${title ? ` ${title}` : ""}` : `Expand${title ? ` ${title}` : ""}`,
|
3845
5191
|
children: [
|
3846
|
-
/* @__PURE__ */
|
3847
|
-
/* @__PURE__ */
|
5192
|
+
/* @__PURE__ */ jsx29("div", { children: title }),
|
5193
|
+
/* @__PURE__ */ jsx29("div", { className: getClassName22("titleIcon"), children: expanded ? /* @__PURE__ */ jsx29(ChevronUp, { size: 12 }) : /* @__PURE__ */ jsx29(ChevronDown, { size: 12 }) })
|
3848
5194
|
]
|
3849
5195
|
}
|
3850
5196
|
),
|
3851
|
-
/* @__PURE__ */
|
5197
|
+
/* @__PURE__ */ jsx29("div", { className: getClassName22("content"), children: /* @__PURE__ */ jsx29(Drawer, { children: children || Object.keys(config.components).map((componentKey) => {
|
3852
5198
|
var _a;
|
3853
|
-
return /* @__PURE__ */
|
5199
|
+
return /* @__PURE__ */ jsx29(
|
3854
5200
|
ComponentListItem,
|
3855
5201
|
{
|
3856
5202
|
label: (_a = config.components[componentKey]["label"]) != null ? _a : componentKey,
|
3857
|
-
name: componentKey
|
3858
|
-
index: i
|
5203
|
+
name: componentKey
|
3859
5204
|
},
|
3860
5205
|
componentKey
|
3861
5206
|
);
|
@@ -3865,10 +5210,10 @@ var ComponentList = ({
|
|
3865
5210
|
ComponentList.Item = ComponentListItem;
|
3866
5211
|
|
3867
5212
|
// lib/use-component-list.tsx
|
3868
|
-
import { jsx as
|
5213
|
+
import { jsx as jsx30 } from "react/jsx-runtime";
|
3869
5214
|
var useComponentList = (config, ui) => {
|
3870
|
-
const [componentList, setComponentList] =
|
3871
|
-
|
5215
|
+
const [componentList, setComponentList] = useState18();
|
5216
|
+
useEffect15(() => {
|
3872
5217
|
var _a, _b, _c;
|
3873
5218
|
if (Object.keys(ui.componentList).length > 0) {
|
3874
5219
|
const matchedComponents = [];
|
@@ -3878,7 +5223,7 @@ var useComponentList = (config, ui) => {
|
|
3878
5223
|
if (category.visible === false || !category.components) {
|
3879
5224
|
return null;
|
3880
5225
|
}
|
3881
|
-
return /* @__PURE__ */
|
5226
|
+
return /* @__PURE__ */ jsx30(
|
3882
5227
|
ComponentList,
|
3883
5228
|
{
|
3884
5229
|
id: categoryKey,
|
@@ -3887,7 +5232,7 @@ var useComponentList = (config, ui) => {
|
|
3887
5232
|
var _a2;
|
3888
5233
|
matchedComponents.push(componentName);
|
3889
5234
|
const componentConf = config.components[componentName] || {};
|
3890
|
-
return /* @__PURE__ */
|
5235
|
+
return /* @__PURE__ */ jsx30(
|
3891
5236
|
ComponentList.Item,
|
3892
5237
|
{
|
3893
5238
|
label: (_a2 = componentConf["label"]) != null ? _a2 : componentName,
|
@@ -3907,7 +5252,7 @@ var useComponentList = (config, ui) => {
|
|
3907
5252
|
);
|
3908
5253
|
if (remainingComponents.length > 0 && !((_a = ui.componentList.other) == null ? void 0 : _a.components) && ((_b = ui.componentList.other) == null ? void 0 : _b.visible) !== false) {
|
3909
5254
|
_componentList.push(
|
3910
|
-
/* @__PURE__ */
|
5255
|
+
/* @__PURE__ */ jsx30(
|
3911
5256
|
ComponentList,
|
3912
5257
|
{
|
3913
5258
|
id: "other",
|
@@ -3915,7 +5260,7 @@ var useComponentList = (config, ui) => {
|
|
3915
5260
|
children: remainingComponents.map((componentName, i) => {
|
3916
5261
|
var _a2;
|
3917
5262
|
const componentConf = config.components[componentName] || {};
|
3918
|
-
return /* @__PURE__ */
|
5263
|
+
return /* @__PURE__ */ jsx30(
|
3919
5264
|
ComponentList.Item,
|
3920
5265
|
{
|
3921
5266
|
name: componentName,
|
@@ -3937,31 +5282,30 @@ var useComponentList = (config, ui) => {
|
|
3937
5282
|
};
|
3938
5283
|
|
3939
5284
|
// components/Puck/components/Components/index.tsx
|
3940
|
-
import { useMemo as
|
3941
|
-
import { jsx as
|
5285
|
+
import { useMemo as useMemo8 } from "react";
|
5286
|
+
import { jsx as jsx31 } from "react/jsx-runtime";
|
3942
5287
|
var Components = () => {
|
3943
5288
|
const { config, state, overrides } = useAppContext();
|
3944
5289
|
const componentList = useComponentList(config, state.ui);
|
3945
|
-
const Wrapper =
|
3946
|
-
return /* @__PURE__ */
|
5290
|
+
const Wrapper = useMemo8(() => overrides.components || "div", [overrides]);
|
5291
|
+
return /* @__PURE__ */ jsx31(Wrapper, { children: componentList ? componentList : /* @__PURE__ */ jsx31(ComponentList, { id: "all" }) });
|
3947
5292
|
};
|
3948
5293
|
|
3949
5294
|
// components/Puck/components/Preview/index.tsx
|
3950
5295
|
init_react_import();
|
3951
|
-
import { useCallback as
|
5296
|
+
import { useCallback as useCallback11, useEffect as useEffect17, useRef as useRef7, useMemo as useMemo9 } from "react";
|
3952
5297
|
|
3953
5298
|
// components/AutoFrame/index.tsx
|
3954
5299
|
init_react_import();
|
3955
5300
|
import {
|
3956
5301
|
createContext as createContext4,
|
3957
|
-
useContext as
|
3958
|
-
useEffect as
|
3959
|
-
|
3960
|
-
useState as useState17
|
5302
|
+
useContext as useContext7,
|
5303
|
+
useEffect as useEffect16,
|
5304
|
+
useState as useState19
|
3961
5305
|
} from "react";
|
3962
5306
|
import hash from "object-hash";
|
3963
|
-
import { createPortal as
|
3964
|
-
import { Fragment as Fragment13, jsx as
|
5307
|
+
import { createPortal as createPortal3 } from "react-dom";
|
5308
|
+
import { Fragment as Fragment13, jsx as jsx32 } from "react/jsx-runtime";
|
3965
5309
|
var styleSelector = 'style, link[rel="stylesheet"]';
|
3966
5310
|
var collectStyles = (doc) => {
|
3967
5311
|
const collected = [];
|
@@ -4004,7 +5348,7 @@ var CopyHostStyles = ({
|
|
4004
5348
|
onStylesLoaded = () => null
|
4005
5349
|
}) => {
|
4006
5350
|
const { document: doc, window: win } = useFrame();
|
4007
|
-
|
5351
|
+
useEffect16(() => {
|
4008
5352
|
if (!win || !doc) {
|
4009
5353
|
return () => {
|
4010
5354
|
};
|
@@ -4028,8 +5372,8 @@ var CopyHostStyles = ({
|
|
4028
5372
|
});
|
4029
5373
|
styleSheet = getStyleSheet(el);
|
4030
5374
|
}
|
4031
|
-
const
|
4032
|
-
if (!
|
5375
|
+
const styles2 = getStyles(styleSheet);
|
5376
|
+
if (!styles2) {
|
4033
5377
|
if (debug) {
|
4034
5378
|
console.warn(
|
4035
5379
|
`Tried to load styles for link element, but couldn't find them. Skipping...`
|
@@ -4037,7 +5381,7 @@ var CopyHostStyles = ({
|
|
4037
5381
|
}
|
4038
5382
|
return;
|
4039
5383
|
}
|
4040
|
-
mirror.innerHTML =
|
5384
|
+
mirror.innerHTML = styles2;
|
4041
5385
|
mirror.setAttribute("data-href", el.getAttribute("href"));
|
4042
5386
|
} else {
|
4043
5387
|
mirror = el.cloneNode(true);
|
@@ -4161,49 +5505,52 @@ var CopyHostStyles = ({
|
|
4161
5505
|
observer.disconnect();
|
4162
5506
|
};
|
4163
5507
|
}, []);
|
4164
|
-
return /* @__PURE__ */
|
5508
|
+
return /* @__PURE__ */ jsx32(Fragment13, { children });
|
4165
5509
|
};
|
4166
5510
|
var autoFrameContext = createContext4({});
|
4167
|
-
var useFrame = () =>
|
5511
|
+
var useFrame = () => useContext7(autoFrameContext);
|
4168
5512
|
function AutoFrame(_a) {
|
4169
5513
|
var _b = _a, {
|
4170
5514
|
children,
|
4171
5515
|
className,
|
4172
5516
|
debug,
|
4173
5517
|
id,
|
4174
|
-
onStylesLoaded
|
5518
|
+
onStylesLoaded,
|
5519
|
+
frameRef
|
4175
5520
|
} = _b, props = __objRest(_b, [
|
4176
5521
|
"children",
|
4177
5522
|
"className",
|
4178
5523
|
"debug",
|
4179
5524
|
"id",
|
4180
|
-
"onStylesLoaded"
|
5525
|
+
"onStylesLoaded",
|
5526
|
+
"frameRef"
|
4181
5527
|
]);
|
4182
|
-
const [loaded, setLoaded] =
|
4183
|
-
const [ctx, setCtx] =
|
4184
|
-
const
|
4185
|
-
|
4186
|
-
useEffect15(() => {
|
5528
|
+
const [loaded, setLoaded] = useState19(false);
|
5529
|
+
const [ctx, setCtx] = useState19({});
|
5530
|
+
const [mountTarget, setMountTarget] = useState19();
|
5531
|
+
useEffect16(() => {
|
4187
5532
|
var _a2;
|
4188
|
-
if (
|
5533
|
+
if (frameRef.current) {
|
4189
5534
|
setCtx({
|
4190
|
-
document:
|
4191
|
-
window:
|
5535
|
+
document: frameRef.current.contentDocument || void 0,
|
5536
|
+
window: frameRef.current.contentWindow || void 0
|
4192
5537
|
});
|
4193
|
-
setMountTarget(
|
5538
|
+
setMountTarget(
|
5539
|
+
(_a2 = frameRef.current.contentDocument) == null ? void 0 : _a2.getElementById("frame-root")
|
5540
|
+
);
|
4194
5541
|
}
|
4195
|
-
}, [
|
4196
|
-
return /* @__PURE__ */
|
5542
|
+
}, [frameRef, loaded]);
|
5543
|
+
return /* @__PURE__ */ jsx32(
|
4197
5544
|
"iframe",
|
4198
5545
|
__spreadProps(__spreadValues({}, props), {
|
4199
5546
|
className,
|
4200
5547
|
id,
|
4201
5548
|
srcDoc: '<!DOCTYPE html><html><head></head><body><div id="frame-root"></div></body></html>',
|
4202
|
-
ref,
|
5549
|
+
ref: frameRef,
|
4203
5550
|
onLoad: () => {
|
4204
5551
|
setLoaded(true);
|
4205
5552
|
},
|
4206
|
-
children: /* @__PURE__ */
|
5553
|
+
children: /* @__PURE__ */ jsx32(autoFrameContext.Provider, { value: ctx, children: loaded && mountTarget && /* @__PURE__ */ jsx32(CopyHostStyles, { debug, onStylesLoaded, children: createPortal3(children, mountTarget) }) })
|
4207
5554
|
})
|
4208
5555
|
);
|
4209
5556
|
}
|
@@ -4212,33 +5559,71 @@ var AutoFrame_default = AutoFrame;
|
|
4212
5559
|
|
4213
5560
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Preview/styles.module.css#css-module
|
4214
5561
|
init_react_import();
|
4215
|
-
var styles_module_default18 = { "PuckPreview": "
|
5562
|
+
var styles_module_default18 = { "PuckPreview": "_PuckPreview_z2rgu_1", "PuckPreview-frame": "_PuckPreview-frame_z2rgu_6" };
|
4216
5563
|
|
4217
5564
|
// components/Puck/components/Preview/index.tsx
|
4218
|
-
import { Fragment as Fragment14, jsx as
|
5565
|
+
import { Fragment as Fragment14, jsx as jsx33 } from "react/jsx-runtime";
|
4219
5566
|
var getClassName23 = get_class_name_factory_default("PuckPreview", styles_module_default18);
|
5567
|
+
var useBubbleIframeEvents = (ref) => {
|
5568
|
+
const { status } = useAppContext();
|
5569
|
+
useEffect17(() => {
|
5570
|
+
var _a;
|
5571
|
+
if (ref.current && status === "READY") {
|
5572
|
+
const iframe = ref.current;
|
5573
|
+
const handlePointerMove = (event) => {
|
5574
|
+
var _a2;
|
5575
|
+
const rect = iframe.getBoundingClientRect();
|
5576
|
+
const evt = new CustomEvent("pointermove", {
|
5577
|
+
bubbles: true,
|
5578
|
+
cancelable: false
|
5579
|
+
});
|
5580
|
+
const scaleFactor = rect.width / (((_a2 = iframe.contentWindow) == null ? void 0 : _a2.innerWidth) || 1);
|
5581
|
+
evt.clientX = event.clientX * scaleFactor + rect.left;
|
5582
|
+
evt.clientY = event.clientY * scaleFactor + rect.top;
|
5583
|
+
iframe.dispatchEvent(evt);
|
5584
|
+
};
|
5585
|
+
(_a = iframe.contentDocument) == null ? void 0 : _a.addEventListener(
|
5586
|
+
"pointermove",
|
5587
|
+
handlePointerMove,
|
5588
|
+
{
|
5589
|
+
capture: true
|
5590
|
+
}
|
5591
|
+
);
|
5592
|
+
return () => {
|
5593
|
+
var _a2;
|
5594
|
+
(_a2 = iframe.contentDocument) == null ? void 0 : _a2.removeEventListener(
|
5595
|
+
"pointermove",
|
5596
|
+
handlePointerMove
|
5597
|
+
);
|
5598
|
+
};
|
5599
|
+
}
|
5600
|
+
}, [status]);
|
5601
|
+
};
|
4220
5602
|
var Preview = ({ id = "puck-preview" }) => {
|
4221
5603
|
const { config, dispatch, state, setStatus, iframe, overrides } = useAppContext();
|
4222
|
-
const Page =
|
5604
|
+
const Page = useCallback11(
|
4223
5605
|
(pageProps) => {
|
4224
5606
|
var _a, _b;
|
4225
5607
|
return ((_a = config.root) == null ? void 0 : _a.render) ? (_b = config.root) == null ? void 0 : _b.render(__spreadValues({
|
4226
5608
|
id: "puck-root"
|
4227
|
-
}, pageProps)) : /* @__PURE__ */
|
5609
|
+
}, pageProps)) : /* @__PURE__ */ jsx33(Fragment14, { children: pageProps.children });
|
4228
5610
|
},
|
4229
5611
|
[config.root]
|
4230
5612
|
);
|
4231
|
-
const Frame =
|
5613
|
+
const Frame = useMemo9(() => overrides.iframe, [overrides]);
|
4232
5614
|
const rootProps = state.data.root.props || state.data.root;
|
4233
|
-
|
5615
|
+
const ref = useRef7(null);
|
5616
|
+
useBubbleIframeEvents(ref);
|
5617
|
+
return /* @__PURE__ */ jsx33(
|
4234
5618
|
"div",
|
4235
5619
|
{
|
4236
5620
|
className: getClassName23(),
|
4237
5621
|
id,
|
5622
|
+
"data-puck-preview": true,
|
4238
5623
|
onClick: () => {
|
4239
5624
|
dispatch({ type: "setUi", ui: __spreadProps(__spreadValues({}, state.ui), { itemSelector: null }) });
|
4240
5625
|
},
|
4241
|
-
children: iframe.enabled ? /* @__PURE__ */
|
5626
|
+
children: iframe.enabled ? /* @__PURE__ */ jsx33(
|
4242
5627
|
AutoFrame_default,
|
4243
5628
|
{
|
4244
5629
|
id: "preview-frame",
|
@@ -4247,27 +5632,32 @@ var Preview = ({ id = "puck-preview" }) => {
|
|
4247
5632
|
onStylesLoaded: () => {
|
4248
5633
|
setStatus("READY");
|
4249
5634
|
},
|
4250
|
-
|
4251
|
-
|
5635
|
+
frameRef: ref,
|
5636
|
+
children: /* @__PURE__ */ jsx33(autoFrameContext.Consumer, { children: ({ document: document2 }) => {
|
5637
|
+
const inner = /* @__PURE__ */ jsx33(
|
4252
5638
|
Page,
|
4253
5639
|
__spreadProps(__spreadValues({}, rootProps), {
|
4254
|
-
puck: {
|
5640
|
+
puck: {
|
5641
|
+
renderDropZone: DropZone,
|
5642
|
+
isEditing: true,
|
5643
|
+
dragRef: null
|
5644
|
+
},
|
4255
5645
|
editMode: true,
|
4256
|
-
children: /* @__PURE__ */
|
5646
|
+
children: /* @__PURE__ */ jsx33(DropZone, { zone: rootDroppableId })
|
4257
5647
|
})
|
4258
5648
|
);
|
4259
5649
|
if (Frame) {
|
4260
|
-
return /* @__PURE__ */
|
5650
|
+
return /* @__PURE__ */ jsx33(Frame, { document: document2, children: inner });
|
4261
5651
|
}
|
4262
5652
|
return inner;
|
4263
5653
|
} })
|
4264
5654
|
}
|
4265
|
-
) : /* @__PURE__ */
|
5655
|
+
) : /* @__PURE__ */ jsx33("div", { id: "preview-frame", className: getClassName23("frame"), ref, children: /* @__PURE__ */ jsx33(
|
4266
5656
|
Page,
|
4267
5657
|
__spreadProps(__spreadValues({}, rootProps), {
|
4268
|
-
puck: { renderDropZone: DropZone, isEditing: true },
|
5658
|
+
puck: { renderDropZone: DropZone, isEditing: true, dragRef: null },
|
4269
5659
|
editMode: true,
|
4270
|
-
children: /* @__PURE__ */
|
5660
|
+
children: /* @__PURE__ */ jsx33(DropZone, { zone: rootDroppableId })
|
4271
5661
|
})
|
4272
5662
|
) })
|
4273
5663
|
}
|
@@ -4317,7 +5707,7 @@ var scrollIntoView = (el) => {
|
|
4317
5707
|
};
|
4318
5708
|
|
4319
5709
|
// components/LayerTree/index.tsx
|
4320
|
-
import { useContext as
|
5710
|
+
import { useContext as useContext8 } from "react";
|
4321
5711
|
|
4322
5712
|
// lib/is-child-of-zone.ts
|
4323
5713
|
init_react_import();
|
@@ -4330,8 +5720,38 @@ var isChildOfZone = (item, maybeChild, ctx) => {
|
|
4330
5720
|
})) : false;
|
4331
5721
|
};
|
4332
5722
|
|
5723
|
+
// lib/get-frame.ts
|
5724
|
+
init_react_import();
|
5725
|
+
var getFrame = () => {
|
5726
|
+
if (typeof window === "undefined") return;
|
5727
|
+
let frameEl = document.querySelector("#preview-frame");
|
5728
|
+
if ((frameEl == null ? void 0 : frameEl.tagName) === "IFRAME") {
|
5729
|
+
return frameEl.contentDocument || document;
|
5730
|
+
}
|
5731
|
+
return (frameEl == null ? void 0 : frameEl.ownerDocument) || document;
|
5732
|
+
};
|
5733
|
+
|
5734
|
+
// lib/on-scroll-end.ts
|
5735
|
+
init_react_import();
|
5736
|
+
var onScrollEnd = (frame, cb) => {
|
5737
|
+
let scrollTimeout;
|
5738
|
+
const callback = function() {
|
5739
|
+
clearTimeout(scrollTimeout);
|
5740
|
+
scrollTimeout = setTimeout(function() {
|
5741
|
+
cb();
|
5742
|
+
frame == null ? void 0 : frame.removeEventListener("scroll", callback);
|
5743
|
+
}, 50);
|
5744
|
+
};
|
5745
|
+
frame == null ? void 0 : frame.addEventListener("scroll", callback);
|
5746
|
+
setTimeout(() => {
|
5747
|
+
if (!scrollTimeout) {
|
5748
|
+
cb();
|
5749
|
+
}
|
5750
|
+
}, 50);
|
5751
|
+
};
|
5752
|
+
|
4333
5753
|
// components/LayerTree/index.tsx
|
4334
|
-
import { Fragment as Fragment15, jsx as
|
5754
|
+
import { Fragment as Fragment15, jsx as jsx34, jsxs as jsxs17 } from "react/jsx-runtime";
|
4335
5755
|
var getClassName24 = get_class_name_factory_default("LayerTree", styles_module_default19);
|
4336
5756
|
var getClassNameLayer = get_class_name_factory_default("Layer", styles_module_default19);
|
4337
5757
|
var LayerTree = ({
|
@@ -4344,27 +5764,22 @@ var LayerTree = ({
|
|
4344
5764
|
label
|
4345
5765
|
}) => {
|
4346
5766
|
const zones = data.zones || {};
|
4347
|
-
const ctx =
|
5767
|
+
const ctx = useContext8(dropZoneContext);
|
4348
5768
|
return /* @__PURE__ */ jsxs17(Fragment15, { children: [
|
4349
5769
|
label && /* @__PURE__ */ jsxs17("div", { className: getClassName24("zoneTitle"), children: [
|
4350
|
-
/* @__PURE__ */
|
5770
|
+
/* @__PURE__ */ jsx34("div", { className: getClassName24("zoneIcon"), children: /* @__PURE__ */ jsx34(Layers, { size: "16" }) }),
|
4351
5771
|
" ",
|
4352
5772
|
label
|
4353
5773
|
] }),
|
4354
5774
|
/* @__PURE__ */ jsxs17("ul", { className: getClassName24(), children: [
|
4355
|
-
zoneContent.length === 0 && /* @__PURE__ */
|
5775
|
+
zoneContent.length === 0 && /* @__PURE__ */ jsx34("div", { className: getClassName24("helper"), children: "No items" }),
|
4356
5776
|
zoneContent.map((item, i) => {
|
4357
5777
|
var _a;
|
4358
5778
|
const isSelected = (itemSelector == null ? void 0 : itemSelector.index) === i && (itemSelector.zone === zone || itemSelector.zone === rootDroppableId && !zone);
|
4359
5779
|
const zonesForItem = findZonesForArea(data, item.props.id);
|
4360
5780
|
const containsZone = Object.keys(zonesForItem).length > 0;
|
4361
|
-
const {
|
4362
|
-
|
4363
|
-
},
|
4364
|
-
setHoveringComponent = () => {
|
4365
|
-
},
|
4366
|
-
hoveringComponent
|
4367
|
-
} = ctx || {};
|
5781
|
+
const { setHoveringComponent = () => {
|
5782
|
+
}, hoveringComponent } = ctx || {};
|
4368
5783
|
const selectedItem = itemSelector && data ? getItem(itemSelector, data) : null;
|
4369
5784
|
const isHovering = hoveringComponent === item.props.id;
|
4370
5785
|
const childIsSelected = isChildOfZone(item, selectedItem, ctx);
|
@@ -4380,7 +5795,7 @@ var LayerTree = ({
|
|
4380
5795
|
childIsSelected
|
4381
5796
|
}),
|
4382
5797
|
children: [
|
4383
|
-
/* @__PURE__ */
|
5798
|
+
/* @__PURE__ */ jsx34("div", { className: getClassNameLayer("inner"), children: /* @__PURE__ */ jsxs17(
|
4384
5799
|
"button",
|
4385
5800
|
{
|
4386
5801
|
type: "button",
|
@@ -4390,45 +5805,51 @@ var LayerTree = ({
|
|
4390
5805
|
setItemSelector(null);
|
4391
5806
|
return;
|
4392
5807
|
}
|
4393
|
-
setItemSelector({
|
4394
|
-
index: i,
|
4395
|
-
zone
|
4396
|
-
});
|
4397
5808
|
const id = zoneContent[i].props.id;
|
4398
5809
|
const frame = getFrame();
|
4399
|
-
|
4400
|
-
|
4401
|
-
`[data-rfd-drag-handle-draggable-id="draggable-${id}"]`
|
4402
|
-
)
|
5810
|
+
const el = frame == null ? void 0 : frame.querySelector(
|
5811
|
+
`[data-puck-component="${id}"]`
|
4403
5812
|
);
|
5813
|
+
if (!el) {
|
5814
|
+
console.error(
|
5815
|
+
"Scroll failed. No element was found for",
|
5816
|
+
id
|
5817
|
+
);
|
5818
|
+
return;
|
5819
|
+
}
|
5820
|
+
scrollIntoView(el);
|
5821
|
+
onScrollEnd(frame, () => {
|
5822
|
+
setItemSelector({
|
5823
|
+
index: i,
|
5824
|
+
zone
|
5825
|
+
});
|
5826
|
+
});
|
4404
5827
|
},
|
4405
5828
|
onMouseOver: (e) => {
|
4406
5829
|
e.stopPropagation();
|
4407
|
-
setHoveringArea(item.props.id);
|
4408
5830
|
setHoveringComponent(item.props.id);
|
4409
5831
|
},
|
4410
5832
|
onMouseOut: (e) => {
|
4411
5833
|
e.stopPropagation();
|
4412
|
-
setHoveringArea(null);
|
4413
5834
|
setHoveringComponent(null);
|
4414
5835
|
},
|
4415
5836
|
children: [
|
4416
|
-
containsZone && /* @__PURE__ */
|
5837
|
+
containsZone && /* @__PURE__ */ jsx34(
|
4417
5838
|
"div",
|
4418
5839
|
{
|
4419
5840
|
className: getClassNameLayer("chevron"),
|
4420
5841
|
title: isSelected ? "Collapse" : "Expand",
|
4421
|
-
children: /* @__PURE__ */
|
5842
|
+
children: /* @__PURE__ */ jsx34(ChevronDown, { size: "12" })
|
4422
5843
|
}
|
4423
5844
|
),
|
4424
5845
|
/* @__PURE__ */ jsxs17("div", { className: getClassNameLayer("title"), children: [
|
4425
|
-
/* @__PURE__ */
|
4426
|
-
/* @__PURE__ */
|
5846
|
+
/* @__PURE__ */ jsx34("div", { className: getClassNameLayer("icon"), children: item.type === "Text" || item.type === "Heading" ? /* @__PURE__ */ jsx34(Type, { size: "16" }) : /* @__PURE__ */ jsx34(LayoutGrid, { size: "16" }) }),
|
5847
|
+
/* @__PURE__ */ jsx34("div", { className: getClassNameLayer("name"), children: label2 })
|
4427
5848
|
] })
|
4428
5849
|
]
|
4429
5850
|
}
|
4430
5851
|
) }),
|
4431
|
-
containsZone && Object.keys(zonesForItem).map((zoneKey, idx) => /* @__PURE__ */
|
5852
|
+
containsZone && Object.keys(zonesForItem).map((zoneKey, idx) => /* @__PURE__ */ jsx34("div", { className: getClassNameLayer("zones"), children: /* @__PURE__ */ jsx34(
|
4432
5853
|
LayerTree,
|
4433
5854
|
{
|
4434
5855
|
config,
|
@@ -4450,13 +5871,13 @@ var LayerTree = ({
|
|
4450
5871
|
};
|
4451
5872
|
|
4452
5873
|
// components/Puck/components/Outline/index.tsx
|
4453
|
-
import { useCallback as
|
4454
|
-
import { Fragment as Fragment16, jsx as
|
5874
|
+
import { useCallback as useCallback12, useMemo as useMemo10 } from "react";
|
5875
|
+
import { Fragment as Fragment16, jsx as jsx35, jsxs as jsxs18 } from "react/jsx-runtime";
|
4455
5876
|
var Outline = () => {
|
4456
5877
|
const { dispatch, state, overrides, config } = useAppContext();
|
4457
5878
|
const { data, ui } = state;
|
4458
5879
|
const { itemSelector } = ui;
|
4459
|
-
const setItemSelector =
|
5880
|
+
const setItemSelector = useCallback12(
|
4460
5881
|
(newItemSelector) => {
|
4461
5882
|
dispatch({
|
4462
5883
|
type: "setUi",
|
@@ -4465,9 +5886,9 @@ var Outline = () => {
|
|
4465
5886
|
},
|
4466
5887
|
[]
|
4467
5888
|
);
|
4468
|
-
const Wrapper =
|
4469
|
-
return /* @__PURE__ */
|
4470
|
-
(ctx == null ? void 0 : ctx.activeZones) && (ctx == null ? void 0 : ctx.activeZones[rootDroppableId]) && /* @__PURE__ */
|
5889
|
+
const Wrapper = useMemo10(() => overrides.outline || "div", [overrides]);
|
5890
|
+
return /* @__PURE__ */ jsx35(Wrapper, { children: /* @__PURE__ */ jsx35(dropZoneContext.Consumer, { children: (ctx) => /* @__PURE__ */ jsxs18(Fragment16, { children: [
|
5891
|
+
(ctx == null ? void 0 : ctx.activeZones) && (ctx == null ? void 0 : ctx.activeZones[rootDroppableId]) && /* @__PURE__ */ jsx35(
|
4471
5892
|
LayerTree,
|
4472
5893
|
{
|
4473
5894
|
config,
|
@@ -4480,7 +5901,7 @@ var Outline = () => {
|
|
4480
5901
|
),
|
4481
5902
|
Object.entries(findZonesForArea(data, "root")).map(
|
4482
5903
|
([zoneKey, zone]) => {
|
4483
|
-
return /* @__PURE__ */
|
5904
|
+
return /* @__PURE__ */ jsx35(
|
4484
5905
|
LayerTree,
|
4485
5906
|
{
|
4486
5907
|
config,
|
@@ -4504,7 +5925,8 @@ import { useHotkeys } from "react-hotkeys-hook";
|
|
4504
5925
|
function usePuckHistory({
|
4505
5926
|
dispatch,
|
4506
5927
|
initialAppState,
|
4507
|
-
historyStore
|
5928
|
+
historyStore,
|
5929
|
+
iframeEnabled
|
4508
5930
|
}) {
|
4509
5931
|
const back = () => {
|
4510
5932
|
var _a;
|
@@ -4522,6 +5944,16 @@ function usePuckHistory({
|
|
4522
5944
|
historyStore.forward();
|
4523
5945
|
}
|
4524
5946
|
};
|
5947
|
+
const backIframe = () => {
|
5948
|
+
if (iframeEnabled) {
|
5949
|
+
back();
|
5950
|
+
}
|
5951
|
+
};
|
5952
|
+
const forwardIframe = () => {
|
5953
|
+
if (iframeEnabled) {
|
5954
|
+
forward();
|
5955
|
+
}
|
5956
|
+
};
|
4525
5957
|
const setHistories = (histories) => {
|
4526
5958
|
var _a;
|
4527
5959
|
dispatch({
|
@@ -4540,9 +5972,23 @@ function usePuckHistory({
|
|
4540
5972
|
historyStore.setHistoryIndex(index);
|
4541
5973
|
}
|
4542
5974
|
};
|
5975
|
+
const frame = getFrame();
|
5976
|
+
const resolvedFrame = typeof window !== "undefined" && frame !== document ? frame : void 0;
|
4543
5977
|
useHotkeys("meta+z", back, { preventDefault: true });
|
4544
5978
|
useHotkeys("meta+shift+z", forward, { preventDefault: true });
|
4545
5979
|
useHotkeys("meta+y", forward, { preventDefault: true });
|
5980
|
+
useHotkeys("meta+z", backIframe, {
|
5981
|
+
preventDefault: true,
|
5982
|
+
document: resolvedFrame
|
5983
|
+
});
|
5984
|
+
useHotkeys("meta+shift+z", forwardIframe, {
|
5985
|
+
preventDefault: true,
|
5986
|
+
document: resolvedFrame
|
5987
|
+
});
|
5988
|
+
useHotkeys("meta+y", forwardIframe, {
|
5989
|
+
preventDefault: true,
|
5990
|
+
document: resolvedFrame
|
5991
|
+
});
|
4546
5992
|
return {
|
4547
5993
|
back,
|
4548
5994
|
forward,
|
@@ -4554,19 +6000,19 @@ function usePuckHistory({
|
|
4554
6000
|
|
4555
6001
|
// lib/use-history-store.ts
|
4556
6002
|
init_react_import();
|
4557
|
-
import { useState as
|
4558
|
-
import { useDebouncedCallback as
|
6003
|
+
import { useState as useState20 } from "react";
|
6004
|
+
import { useDebouncedCallback as useDebouncedCallback3 } from "use-debounce";
|
4559
6005
|
var EMPTY_HISTORY_INDEX = 0;
|
4560
6006
|
function useHistoryStore(initialHistory) {
|
4561
6007
|
var _a, _b;
|
4562
|
-
const [histories, setHistories] =
|
6008
|
+
const [histories, setHistories] = useState20(
|
4563
6009
|
(_a = initialHistory == null ? void 0 : initialHistory.histories) != null ? _a : []
|
4564
6010
|
);
|
4565
6011
|
const updateHistories = (histories2) => {
|
4566
6012
|
setHistories(histories2);
|
4567
6013
|
setIndex(histories2.length - 1);
|
4568
6014
|
};
|
4569
|
-
const [index, setIndex] =
|
6015
|
+
const [index, setIndex] = useState20(
|
4570
6016
|
(_b = initialHistory == null ? void 0 : initialHistory.index) != null ? _b : EMPTY_HISTORY_INDEX
|
4571
6017
|
);
|
4572
6018
|
const hasPast = index > EMPTY_HISTORY_INDEX;
|
@@ -4574,7 +6020,7 @@ function useHistoryStore(initialHistory) {
|
|
4574
6020
|
const currentHistory = histories[index];
|
4575
6021
|
const nextHistory = hasFuture ? histories[index + 1] : null;
|
4576
6022
|
const prevHistory = hasPast ? histories[index - 1] : null;
|
4577
|
-
const record =
|
6023
|
+
const record = useDebouncedCallback3((state) => {
|
4578
6024
|
const history = {
|
4579
6025
|
state,
|
4580
6026
|
id: generateId("history")
|
@@ -4693,24 +6139,24 @@ var parse = function parse2(raw) {
|
|
4693
6139
|
!!isNaN(result) ? process.env.NODE_ENV !== "production" ? invariant(false, "Could not parse value [raw: " + raw + ", without suffix: " + value + "]") : invariant(false) : void 0;
|
4694
6140
|
return result;
|
4695
6141
|
};
|
4696
|
-
var calculateBox = function calculateBox2(borderBox,
|
6142
|
+
var calculateBox = function calculateBox2(borderBox, styles2) {
|
4697
6143
|
var margin = {
|
4698
|
-
top: parse(
|
4699
|
-
right: parse(
|
4700
|
-
bottom: parse(
|
4701
|
-
left: parse(
|
6144
|
+
top: parse(styles2.marginTop),
|
6145
|
+
right: parse(styles2.marginRight),
|
6146
|
+
bottom: parse(styles2.marginBottom),
|
6147
|
+
left: parse(styles2.marginLeft)
|
4702
6148
|
};
|
4703
6149
|
var padding = {
|
4704
|
-
top: parse(
|
4705
|
-
right: parse(
|
4706
|
-
bottom: parse(
|
4707
|
-
left: parse(
|
6150
|
+
top: parse(styles2.paddingTop),
|
6151
|
+
right: parse(styles2.paddingRight),
|
6152
|
+
bottom: parse(styles2.paddingBottom),
|
6153
|
+
left: parse(styles2.paddingLeft)
|
4708
6154
|
};
|
4709
6155
|
var border = {
|
4710
|
-
top: parse(
|
4711
|
-
right: parse(
|
4712
|
-
bottom: parse(
|
4713
|
-
left: parse(
|
6156
|
+
top: parse(styles2.borderTopWidth),
|
6157
|
+
right: parse(styles2.borderRightWidth),
|
6158
|
+
bottom: parse(styles2.borderBottomWidth),
|
6159
|
+
left: parse(styles2.borderLeftWidth)
|
4714
6160
|
};
|
4715
6161
|
return createBox({
|
4716
6162
|
borderBox,
|
@@ -4721,33 +6167,33 @@ var calculateBox = function calculateBox2(borderBox, styles) {
|
|
4721
6167
|
};
|
4722
6168
|
var getBox = function getBox2(el) {
|
4723
6169
|
var borderBox = el.getBoundingClientRect();
|
4724
|
-
var
|
4725
|
-
return calculateBox(borderBox,
|
6170
|
+
var styles2 = window.getComputedStyle(el);
|
6171
|
+
return calculateBox(borderBox, styles2);
|
4726
6172
|
};
|
4727
6173
|
|
4728
6174
|
// components/Puck/components/Canvas/index.tsx
|
4729
6175
|
import {
|
4730
|
-
useCallback as
|
4731
|
-
useEffect as
|
4732
|
-
useMemo as
|
4733
|
-
useRef as
|
4734
|
-
useState as
|
6176
|
+
useCallback as useCallback13,
|
6177
|
+
useEffect as useEffect19,
|
6178
|
+
useMemo as useMemo12,
|
6179
|
+
useRef as useRef8,
|
6180
|
+
useState as useState22
|
4735
6181
|
} from "react";
|
4736
6182
|
|
4737
6183
|
// components/ViewportControls/index.tsx
|
4738
6184
|
init_react_import();
|
4739
|
-
import { useEffect as
|
6185
|
+
import { useEffect as useEffect18, useMemo as useMemo11, useState as useState21 } from "react";
|
4740
6186
|
|
4741
6187
|
// css-module:/home/runner/work/puck/puck/packages/core/components/ViewportControls/styles.module.css#css-module
|
4742
6188
|
init_react_import();
|
4743
6189
|
var styles_module_default20 = { "ViewportControls": "_ViewportControls_g1wgg_1", "ViewportControls-divider": "_ViewportControls-divider_g1wgg_15", "ViewportControls-zoomSelect": "_ViewportControls-zoomSelect_g1wgg_21", "ViewportButton--isActive": "_ViewportButton--isActive_g1wgg_34", "ViewportButton-inner": "_ViewportButton-inner_g1wgg_34" };
|
4744
6190
|
|
4745
6191
|
// components/ViewportControls/index.tsx
|
4746
|
-
import { jsx as
|
6192
|
+
import { jsx as jsx36, jsxs as jsxs19 } from "react/jsx-runtime";
|
4747
6193
|
var icons = {
|
4748
|
-
Smartphone: /* @__PURE__ */
|
4749
|
-
Tablet: /* @__PURE__ */
|
4750
|
-
Monitor: /* @__PURE__ */
|
6194
|
+
Smartphone: /* @__PURE__ */ jsx36(Smartphone, { size: 16 }),
|
6195
|
+
Tablet: /* @__PURE__ */ jsx36(Tablet, { size: 16 }),
|
6196
|
+
Monitor: /* @__PURE__ */ jsx36(Monitor, { size: 16 })
|
4751
6197
|
};
|
4752
6198
|
var getClassName25 = get_class_name_factory_default("ViewportControls", styles_module_default20);
|
4753
6199
|
var getClassNameButton = get_class_name_factory_default("ViewportButton", styles_module_default20);
|
@@ -4759,11 +6205,11 @@ var ViewportButton = ({
|
|
4759
6205
|
onClick
|
4760
6206
|
}) => {
|
4761
6207
|
const { state } = useAppContext();
|
4762
|
-
const [isActive, setIsActive] =
|
4763
|
-
|
6208
|
+
const [isActive, setIsActive] = useState21(false);
|
6209
|
+
useEffect18(() => {
|
4764
6210
|
setIsActive(width === state.ui.viewports.current.width);
|
4765
6211
|
}, [width, state.ui.viewports.current.width]);
|
4766
|
-
return /* @__PURE__ */
|
6212
|
+
return /* @__PURE__ */ jsx36("span", { className: getClassNameButton({ isActive }), children: /* @__PURE__ */ jsx36(
|
4767
6213
|
IconButton,
|
4768
6214
|
{
|
4769
6215
|
title,
|
@@ -4772,7 +6218,7 @@ var ViewportButton = ({
|
|
4772
6218
|
e.stopPropagation();
|
4773
6219
|
onClick({ width, height });
|
4774
6220
|
},
|
4775
|
-
children: /* @__PURE__ */
|
6221
|
+
children: /* @__PURE__ */ jsx36("span", { className: getClassNameButton("inner"), children })
|
4776
6222
|
}
|
4777
6223
|
) });
|
4778
6224
|
};
|
@@ -4796,7 +6242,7 @@ var ViewportControls = ({
|
|
4796
6242
|
const defaultsContainAutoZoom = defaultZoomOptions.find(
|
4797
6243
|
(option) => option.value === autoZoom
|
4798
6244
|
);
|
4799
|
-
const zoomOptions =
|
6245
|
+
const zoomOptions = useMemo11(
|
4800
6246
|
() => [
|
4801
6247
|
...defaultZoomOptions,
|
4802
6248
|
...defaultsContainAutoZoom ? [] : [
|
@@ -4809,7 +6255,7 @@ var ViewportControls = ({
|
|
4809
6255
|
[autoZoom]
|
4810
6256
|
);
|
4811
6257
|
return /* @__PURE__ */ jsxs19("div", { className: getClassName25(), children: [
|
4812
|
-
viewports.map((viewport, i) => /* @__PURE__ */
|
6258
|
+
viewports.map((viewport, i) => /* @__PURE__ */ jsx36(
|
4813
6259
|
ViewportButton,
|
4814
6260
|
{
|
4815
6261
|
height: viewport.height,
|
@@ -4820,8 +6266,8 @@ var ViewportControls = ({
|
|
4820
6266
|
},
|
4821
6267
|
i
|
4822
6268
|
)),
|
4823
|
-
/* @__PURE__ */
|
4824
|
-
/* @__PURE__ */
|
6269
|
+
/* @__PURE__ */ jsx36("div", { className: getClassName25("divider") }),
|
6270
|
+
/* @__PURE__ */ jsx36(
|
4825
6271
|
IconButton,
|
4826
6272
|
{
|
4827
6273
|
title: "Zoom viewport out",
|
@@ -4835,10 +6281,10 @@ var ViewportControls = ({
|
|
4835
6281
|
)].value
|
4836
6282
|
);
|
4837
6283
|
},
|
4838
|
-
children: /* @__PURE__ */
|
6284
|
+
children: /* @__PURE__ */ jsx36(ZoomOut, { size: 16 })
|
4839
6285
|
}
|
4840
6286
|
),
|
4841
|
-
/* @__PURE__ */
|
6287
|
+
/* @__PURE__ */ jsx36(
|
4842
6288
|
IconButton,
|
4843
6289
|
{
|
4844
6290
|
title: "Zoom viewport in",
|
@@ -4852,11 +6298,11 @@ var ViewportControls = ({
|
|
4852
6298
|
)].value
|
4853
6299
|
);
|
4854
6300
|
},
|
4855
|
-
children: /* @__PURE__ */
|
6301
|
+
children: /* @__PURE__ */ jsx36(ZoomIn, { size: 16 })
|
4856
6302
|
}
|
4857
6303
|
),
|
4858
|
-
/* @__PURE__ */
|
4859
|
-
/* @__PURE__ */
|
6304
|
+
/* @__PURE__ */ jsx36("div", { className: getClassName25("divider") }),
|
6305
|
+
/* @__PURE__ */ jsx36(
|
4860
6306
|
"select",
|
4861
6307
|
{
|
4862
6308
|
className: getClassName25("zoomSelect"),
|
@@ -4864,7 +6310,7 @@ var ViewportControls = ({
|
|
4864
6310
|
onChange: (e) => {
|
4865
6311
|
onZoom(parseFloat(e.currentTarget.value));
|
4866
6312
|
},
|
4867
|
-
children: zoomOptions.map((option) => /* @__PURE__ */
|
6313
|
+
children: zoomOptions.map((option) => /* @__PURE__ */ jsx36(
|
4868
6314
|
"option",
|
4869
6315
|
{
|
4870
6316
|
value: option.value,
|
@@ -4879,7 +6325,7 @@ var ViewportControls = ({
|
|
4879
6325
|
|
4880
6326
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Canvas/styles.module.css#css-module
|
4881
6327
|
init_react_import();
|
4882
|
-
var styles_module_default21 = { "PuckCanvas": "
|
6328
|
+
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" };
|
4883
6329
|
|
4884
6330
|
// lib/get-zoom-config.ts
|
4885
6331
|
init_react_import();
|
@@ -4912,24 +6358,24 @@ var getZoomConfig = (uiViewport, frame, zoom) => {
|
|
4912
6358
|
};
|
4913
6359
|
|
4914
6360
|
// components/Puck/components/Canvas/index.tsx
|
4915
|
-
import { Fragment as Fragment17, jsx as
|
6361
|
+
import { Fragment as Fragment17, jsx as jsx37, jsxs as jsxs20 } from "react/jsx-runtime";
|
4916
6362
|
var getClassName26 = get_class_name_factory_default("PuckCanvas", styles_module_default21);
|
4917
6363
|
var ZOOM_ON_CHANGE = true;
|
4918
6364
|
var Canvas = () => {
|
4919
6365
|
const { status, iframe } = useAppContext();
|
4920
6366
|
const { dispatch, state, overrides, setUi, zoomConfig, setZoomConfig } = useAppContext();
|
4921
6367
|
const { ui } = state;
|
4922
|
-
const frameRef =
|
4923
|
-
const [showTransition, setShowTransition] =
|
4924
|
-
const defaultRender =
|
4925
|
-
const PuckDefault = ({ children }) => /* @__PURE__ */
|
6368
|
+
const frameRef = useRef8(null);
|
6369
|
+
const [showTransition, setShowTransition] = useState22(false);
|
6370
|
+
const defaultRender = useMemo12(() => {
|
6371
|
+
const PuckDefault = ({ children }) => /* @__PURE__ */ jsx37(Fragment17, { children });
|
4926
6372
|
return PuckDefault;
|
4927
6373
|
}, []);
|
4928
|
-
const CustomPreview =
|
6374
|
+
const CustomPreview = useMemo12(
|
4929
6375
|
() => overrides.preview || defaultRender,
|
4930
6376
|
[overrides]
|
4931
6377
|
);
|
4932
|
-
const getFrameDimensions =
|
6378
|
+
const getFrameDimensions = useCallback13(() => {
|
4933
6379
|
if (frameRef.current) {
|
4934
6380
|
const frame = frameRef.current;
|
4935
6381
|
const box = getBox(frame);
|
@@ -4937,7 +6383,7 @@ var Canvas = () => {
|
|
4937
6383
|
}
|
4938
6384
|
return { width: 0, height: 0 };
|
4939
6385
|
}, [frameRef]);
|
4940
|
-
const resetAutoZoom =
|
6386
|
+
const resetAutoZoom = useCallback13(
|
4941
6387
|
(ui2 = state.ui) => {
|
4942
6388
|
if (frameRef.current) {
|
4943
6389
|
setZoomConfig(
|
@@ -4947,11 +6393,11 @@ var Canvas = () => {
|
|
4947
6393
|
},
|
4948
6394
|
[frameRef, zoomConfig, state.ui]
|
4949
6395
|
);
|
4950
|
-
|
6396
|
+
useEffect19(() => {
|
4951
6397
|
setShowTransition(false);
|
4952
6398
|
resetAutoZoom();
|
4953
6399
|
}, [frameRef, ui.leftSideBarVisible, ui.rightSideBarVisible]);
|
4954
|
-
|
6400
|
+
useEffect19(() => {
|
4955
6401
|
const { height: frameHeight } = getFrameDimensions();
|
4956
6402
|
if (ui.viewports.current.height === "auto") {
|
4957
6403
|
setZoomConfig(__spreadProps(__spreadValues({}, zoomConfig), {
|
@@ -4959,26 +6405,24 @@ var Canvas = () => {
|
|
4959
6405
|
}));
|
4960
6406
|
}
|
4961
6407
|
}, [zoomConfig.zoom]);
|
4962
|
-
|
6408
|
+
useEffect19(() => {
|
4963
6409
|
if (ZOOM_ON_CHANGE) {
|
4964
6410
|
setShowTransition(true);
|
4965
6411
|
resetAutoZoom(ui);
|
4966
6412
|
}
|
4967
6413
|
}, [ui.viewports.current.width]);
|
4968
|
-
|
4969
|
-
const
|
6414
|
+
useEffect19(() => {
|
6415
|
+
const cb = () => {
|
4970
6416
|
setShowTransition(false);
|
4971
6417
|
resetAutoZoom();
|
4972
|
-
}
|
4973
|
-
|
4974
|
-
observer.observe(document.body);
|
4975
|
-
}
|
6418
|
+
};
|
6419
|
+
window.addEventListener("resize", cb);
|
4976
6420
|
return () => {
|
4977
|
-
|
6421
|
+
window.removeEventListener("resize", cb);
|
4978
6422
|
};
|
4979
6423
|
}, []);
|
4980
|
-
const [showLoader, setShowLoader] =
|
4981
|
-
|
6424
|
+
const [showLoader, setShowLoader] = useState22(false);
|
6425
|
+
useEffect19(() => {
|
4982
6426
|
setTimeout(() => {
|
4983
6427
|
setShowLoader(true);
|
4984
6428
|
}, 500);
|
@@ -4996,7 +6440,7 @@ var Canvas = () => {
|
|
4996
6440
|
recordHistory: true
|
4997
6441
|
}),
|
4998
6442
|
children: [
|
4999
|
-
ui.viewports.controlsVisible && iframe.enabled && /* @__PURE__ */
|
6443
|
+
ui.viewports.controlsVisible && iframe.enabled && /* @__PURE__ */ jsx37("div", { className: getClassName26("controls"), children: /* @__PURE__ */ jsx37(
|
5000
6444
|
ViewportControls,
|
5001
6445
|
{
|
5002
6446
|
autoZoom: zoomConfig.autoZoom,
|
@@ -5008,7 +6452,8 @@ var Canvas = () => {
|
|
5008
6452
|
zoom: zoomConfig.zoom
|
5009
6453
|
});
|
5010
6454
|
const newUi = __spreadProps(__spreadValues({}, ui), {
|
5011
|
-
viewports: __spreadProps(__spreadValues({}, ui.viewports), { current: uiViewport })
|
6455
|
+
viewports: __spreadProps(__spreadValues({}, ui.viewports), { current: uiViewport }),
|
6456
|
+
itemSelector: null
|
5012
6457
|
});
|
5013
6458
|
setUi(newUi);
|
5014
6459
|
if (ZOOM_ON_CHANGE) {
|
@@ -5022,7 +6467,7 @@ var Canvas = () => {
|
|
5022
6467
|
}
|
5023
6468
|
) }),
|
5024
6469
|
/* @__PURE__ */ jsxs20("div", { className: getClassName26("inner"), ref: frameRef, children: [
|
5025
|
-
/* @__PURE__ */
|
6470
|
+
/* @__PURE__ */ jsx37(
|
5026
6471
|
"div",
|
5027
6472
|
{
|
5028
6473
|
className: getClassName26("root"),
|
@@ -5034,54 +6479,28 @@ var Canvas = () => {
|
|
5034
6479
|
overflow: iframe.enabled ? void 0 : "auto"
|
5035
6480
|
},
|
5036
6481
|
suppressHydrationWarning: true,
|
5037
|
-
|
6482
|
+
id: "puck-canvas-root",
|
6483
|
+
onTransitionEnd: () => {
|
6484
|
+
window.dispatchEvent(
|
6485
|
+
new CustomEvent("viewportchange", {
|
6486
|
+
bubbles: true,
|
6487
|
+
cancelable: false
|
6488
|
+
})
|
6489
|
+
);
|
6490
|
+
},
|
6491
|
+
children: /* @__PURE__ */ jsx37(CustomPreview, { children: /* @__PURE__ */ jsx37(Preview, {}) })
|
5038
6492
|
}
|
5039
6493
|
),
|
5040
|
-
/* @__PURE__ */
|
6494
|
+
/* @__PURE__ */ jsx37("div", { className: getClassName26("loader"), children: /* @__PURE__ */ jsx37(Loader, { size: 24 }) })
|
5041
6495
|
] })
|
5042
6496
|
]
|
5043
6497
|
}
|
5044
6498
|
);
|
5045
6499
|
};
|
5046
6500
|
|
5047
|
-
// lib/insert-component.ts
|
5048
|
-
init_react_import();
|
5049
|
-
var insertComponent = (componentType, zone, index, {
|
5050
|
-
config,
|
5051
|
-
dispatch,
|
5052
|
-
resolveData,
|
5053
|
-
state
|
5054
|
-
}) => {
|
5055
|
-
const id = generateId(componentType);
|
5056
|
-
const insertActionData = {
|
5057
|
-
type: "insert",
|
5058
|
-
componentType,
|
5059
|
-
destinationIndex: index,
|
5060
|
-
destinationZone: zone,
|
5061
|
-
id
|
5062
|
-
};
|
5063
|
-
const insertedData = insertAction(state.data, insertActionData, config);
|
5064
|
-
dispatch(__spreadProps(__spreadValues({}, insertActionData), {
|
5065
|
-
// Dispatch insert rather set, as user's may rely on this via onAction
|
5066
|
-
// We must always record history here so the insert is added to user history
|
5067
|
-
// If the user has defined a resolveData method, they will end up with 2 history
|
5068
|
-
// entries on insert - one for the initial insert, and one when the data resolves
|
5069
|
-
recordHistory: true
|
5070
|
-
}));
|
5071
|
-
const itemSelector = {
|
5072
|
-
index,
|
5073
|
-
zone
|
5074
|
-
};
|
5075
|
-
dispatch({ type: "setUi", ui: { itemSelector } });
|
5076
|
-
resolveData({
|
5077
|
-
data: insertedData,
|
5078
|
-
ui: __spreadProps(__spreadValues({}, state.ui), { itemSelector })
|
5079
|
-
});
|
5080
|
-
};
|
5081
|
-
|
5082
6501
|
// lib/use-loaded-overrides.ts
|
5083
6502
|
init_react_import();
|
5084
|
-
import { useMemo as
|
6503
|
+
import { useMemo as useMemo13 } from "react";
|
5085
6504
|
|
5086
6505
|
// lib/load-overrides.ts
|
5087
6506
|
init_react_import();
|
@@ -5120,18 +6539,86 @@ var useLoadedOverrides = ({
|
|
5120
6539
|
overrides,
|
5121
6540
|
plugins
|
5122
6541
|
}) => {
|
5123
|
-
return
|
6542
|
+
return useMemo13(() => {
|
5124
6543
|
return loadOverrides({ overrides, plugins });
|
5125
6544
|
}, [plugins, overrides]);
|
5126
6545
|
};
|
5127
6546
|
|
5128
6547
|
// components/DefaultOverride/index.tsx
|
5129
6548
|
init_react_import();
|
5130
|
-
import { Fragment as Fragment18, jsx as
|
5131
|
-
var DefaultOverride = ({ children }) => /* @__PURE__ */
|
6549
|
+
import { Fragment as Fragment18, jsx as jsx38 } from "react/jsx-runtime";
|
6550
|
+
var DefaultOverride = ({ children }) => /* @__PURE__ */ jsx38(Fragment18, { children });
|
6551
|
+
|
6552
|
+
// components/Puck/index.tsx
|
6553
|
+
import { DragDropManager as DragDropManager2, Feedback } from "@dnd-kit/dom";
|
6554
|
+
|
6555
|
+
// lib/use-inject-css.ts
|
6556
|
+
init_react_import();
|
6557
|
+
import { useEffect as useEffect20, useState as useState23 } from "react";
|
6558
|
+
var styles = `
|
6559
|
+
/* Prevent user from interacting with underlying component */
|
6560
|
+
[data-puck-component] * {
|
6561
|
+
pointer-events: none;
|
6562
|
+
user-select: none;
|
6563
|
+
-webkit-user-select: none;
|
6564
|
+
}
|
6565
|
+
|
6566
|
+
[data-puck-component] {
|
6567
|
+
cursor: grab;
|
6568
|
+
pointer-events: auto !important;
|
6569
|
+
user-select: none;
|
6570
|
+
-webkit-user-select: none;
|
6571
|
+
}
|
6572
|
+
|
6573
|
+
[data-puck-disabled] {
|
6574
|
+
cursor: pointer;
|
6575
|
+
}
|
6576
|
+
|
6577
|
+
/* Placeholder */
|
6578
|
+
[data-puck-dragging]:not([data-dnd-dragging]) {
|
6579
|
+
background: var(--puck-color-azure-06) !important;
|
6580
|
+
border: none !important;
|
6581
|
+
color: #00000000 !important;
|
6582
|
+
opacity: 0.3 !important;
|
6583
|
+
outline: none !important;
|
6584
|
+
transition: none !important;
|
6585
|
+
}
|
6586
|
+
|
6587
|
+
[data-puck-dragging]:not([data-dnd-dragging]) *, [data-puck-dragging]:not([data-dnd-dragging])::after, [data-puck-dragging]:not([data-dnd-dragging])::before {
|
6588
|
+
opacity: 0 !important;
|
6589
|
+
}
|
6590
|
+
|
6591
|
+
[data-dnd-dragging] {
|
6592
|
+
pointer-events: none !important;
|
6593
|
+
outline: 2px var(--puck-color-azure-09) solid !important;
|
6594
|
+
outline-offset: -2px !important;
|
6595
|
+
}
|
6596
|
+
`;
|
6597
|
+
var useInjectStyleSheet = (initialStyles, iframeEnabled) => {
|
6598
|
+
const [el, setEl] = useState23();
|
6599
|
+
useEffect20(() => {
|
6600
|
+
setEl(document.createElement("style"));
|
6601
|
+
}, []);
|
6602
|
+
useEffect20(() => {
|
6603
|
+
var _a;
|
6604
|
+
if (!el || typeof window === "undefined") {
|
6605
|
+
return;
|
6606
|
+
}
|
6607
|
+
el.innerHTML = initialStyles;
|
6608
|
+
if (iframeEnabled) {
|
6609
|
+
const frame = getFrame();
|
6610
|
+
(_a = frame == null ? void 0 : frame.head) == null ? void 0 : _a.appendChild(el);
|
6611
|
+
}
|
6612
|
+
document.head.appendChild(el);
|
6613
|
+
}, [iframeEnabled, el]);
|
6614
|
+
return el;
|
6615
|
+
};
|
6616
|
+
var useInjectGlobalCss = (iframeEnabled) => {
|
6617
|
+
return useInjectStyleSheet(styles, iframeEnabled);
|
6618
|
+
};
|
5132
6619
|
|
5133
6620
|
// components/Puck/index.tsx
|
5134
|
-
import { Fragment as Fragment19, jsx as
|
6621
|
+
import { Fragment as Fragment19, jsx as jsx39, jsxs as jsxs21 } from "react/jsx-runtime";
|
5135
6622
|
var getClassName27 = get_class_name_factory_default("Puck", styles_module_default15);
|
5136
6623
|
var getLayoutClassName = get_class_name_factory_default("PuckLayout", styles_module_default15);
|
5137
6624
|
function Puck({
|
@@ -5154,13 +6641,14 @@ function Puck({
|
|
5154
6641
|
dnd,
|
5155
6642
|
initialHistory: _initialHistory
|
5156
6643
|
}) {
|
5157
|
-
var _a;
|
6644
|
+
var _a, _b;
|
5158
6645
|
const iframe = __spreadValues({
|
5159
6646
|
enabled: true,
|
5160
6647
|
waitForStyles: true
|
5161
6648
|
}, _iframe);
|
5162
|
-
|
5163
|
-
|
6649
|
+
useInjectGlobalCss(iframe.enabled);
|
6650
|
+
const [generatedAppState] = useState24(() => {
|
6651
|
+
var _a2, _b2, _c, _d, _e, _f, _g, _h, _i;
|
5164
6652
|
const initial = __spreadValues(__spreadValues({}, defaultAppState.ui), initialUi);
|
5165
6653
|
let clientUiState = {};
|
5166
6654
|
if (typeof window !== "undefined") {
|
@@ -5180,7 +6668,7 @@ function Puck({
|
|
5180
6668
|
clientUiState = __spreadProps(__spreadValues({}, clientUiState), {
|
5181
6669
|
viewports: __spreadProps(__spreadValues({}, initial.viewports), {
|
5182
6670
|
current: __spreadProps(__spreadValues({}, initial.viewports.current), {
|
5183
|
-
height: ((
|
6671
|
+
height: ((_b2 = (_a2 = initialUi == null ? void 0 : initialUi.viewports) == null ? void 0 : _a2.current) == null ? void 0 : _b2.height) || ((_c = viewports[closestViewport]) == null ? void 0 : _c.height) || "auto",
|
5184
6672
|
width: ((_e = (_d = initialUi == null ? void 0 : initialUi.viewports) == null ? void 0 : _d.current) == null ? void 0 : _e.width) || ((_f = viewports[closestViewport]) == null ? void 0 : _f.width)
|
5185
6673
|
})
|
5186
6674
|
})
|
@@ -5231,7 +6719,7 @@ function Puck({
|
|
5231
6719
|
histories,
|
5232
6720
|
index: initialHistoryIndex
|
5233
6721
|
});
|
5234
|
-
const [reducer] =
|
6722
|
+
const [reducer] = useState24(
|
5235
6723
|
() => createReducer({
|
5236
6724
|
config,
|
5237
6725
|
record: historyStore.record,
|
@@ -5243,28 +6731,20 @@ function Puck({
|
|
5243
6731
|
flushZones(initialAppState)
|
5244
6732
|
);
|
5245
6733
|
const { data, ui } = appState;
|
5246
|
-
const history = usePuckHistory({
|
5247
|
-
|
6734
|
+
const history = usePuckHistory({
|
6735
|
+
dispatch,
|
6736
|
+
initialAppState,
|
6737
|
+
historyStore,
|
6738
|
+
iframeEnabled: (_a = _iframe == null ? void 0 : _iframe.enabled) != null ? _a : true
|
6739
|
+
});
|
6740
|
+
const [menuOpen, setMenuOpen] = useState24(false);
|
5248
6741
|
const { itemSelector, leftSideBarVisible, rightSideBarVisible } = ui;
|
5249
|
-
const setItemSelector = useCallback11(
|
5250
|
-
(newItemSelector) => {
|
5251
|
-
if (newItemSelector === itemSelector) return;
|
5252
|
-
dispatch({
|
5253
|
-
type: "setUi",
|
5254
|
-
ui: { itemSelector: newItemSelector },
|
5255
|
-
recordHistory: true
|
5256
|
-
});
|
5257
|
-
},
|
5258
|
-
[itemSelector]
|
5259
|
-
);
|
5260
6742
|
const selectedItem = itemSelector ? getItem(itemSelector, data) : null;
|
5261
|
-
|
6743
|
+
useEffect21(() => {
|
5262
6744
|
if (onChange) onChange(data);
|
5263
6745
|
}, [data]);
|
5264
|
-
const { onDragStartOrUpdate, placeholderStyle } = usePlaceholderStyle();
|
5265
|
-
const [draggedItem, setDraggedItem] = useState21();
|
5266
6746
|
const rootProps = data.root.props || data.root;
|
5267
|
-
const toggleSidebars =
|
6747
|
+
const toggleSidebars = useCallback14(
|
5268
6748
|
(sidebar) => {
|
5269
6749
|
const widerViewport = window.matchMedia("(min-width: 638px)").matches;
|
5270
6750
|
const sideBarVisible = sidebar === "left" ? leftSideBarVisible : rightSideBarVisible;
|
@@ -5278,7 +6758,7 @@ function Puck({
|
|
5278
6758
|
},
|
5279
6759
|
[dispatch, leftSideBarVisible, rightSideBarVisible]
|
5280
6760
|
);
|
5281
|
-
|
6761
|
+
useEffect21(() => {
|
5282
6762
|
if (!window.matchMedia("(min-width: 638px)").matches) {
|
5283
6763
|
dispatch({
|
5284
6764
|
type: "setUi",
|
@@ -5301,28 +6781,28 @@ function Puck({
|
|
5301
6781
|
window.removeEventListener("resize", handleResize);
|
5302
6782
|
};
|
5303
6783
|
}, []);
|
5304
|
-
const defaultHeaderRender =
|
6784
|
+
const defaultHeaderRender = useMemo14(() => {
|
5305
6785
|
if (renderHeader) {
|
5306
6786
|
console.warn(
|
5307
6787
|
"`renderHeader` is deprecated. Please use `overrides.header` and the `usePuck` hook instead"
|
5308
6788
|
);
|
5309
6789
|
const RenderHeader = (_a2) => {
|
5310
|
-
var
|
6790
|
+
var _b2 = _a2, { actions } = _b2, props = __objRest(_b2, ["actions"]);
|
5311
6791
|
const Comp = renderHeader;
|
5312
|
-
return /* @__PURE__ */
|
6792
|
+
return /* @__PURE__ */ jsx39(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState, children: actions }));
|
5313
6793
|
};
|
5314
6794
|
return RenderHeader;
|
5315
6795
|
}
|
5316
6796
|
return DefaultOverride;
|
5317
6797
|
}, [renderHeader]);
|
5318
|
-
const defaultHeaderActionsRender =
|
6798
|
+
const defaultHeaderActionsRender = useMemo14(() => {
|
5319
6799
|
if (renderHeaderActions) {
|
5320
6800
|
console.warn(
|
5321
6801
|
"`renderHeaderActions` is deprecated. Please use `overrides.headerActions` and the `usePuck` hook instead."
|
5322
6802
|
);
|
5323
6803
|
const RenderHeader = (props) => {
|
5324
6804
|
const Comp = renderHeaderActions;
|
5325
|
-
return /* @__PURE__ */
|
6805
|
+
return /* @__PURE__ */ jsx39(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState }));
|
5326
6806
|
};
|
5327
6807
|
return RenderHeader;
|
5328
6808
|
}
|
@@ -5332,26 +6812,27 @@ function Puck({
|
|
5332
6812
|
overrides,
|
5333
6813
|
plugins
|
5334
6814
|
});
|
5335
|
-
const CustomPuck =
|
6815
|
+
const CustomPuck = useMemo14(
|
5336
6816
|
() => loadedOverrides.puck || DefaultOverride,
|
5337
6817
|
[loadedOverrides]
|
5338
6818
|
);
|
5339
|
-
const CustomHeader =
|
6819
|
+
const CustomHeader = useMemo14(
|
5340
6820
|
() => loadedOverrides.header || defaultHeaderRender,
|
5341
6821
|
[loadedOverrides]
|
5342
6822
|
);
|
5343
|
-
const CustomHeaderActions =
|
6823
|
+
const CustomHeaderActions = useMemo14(
|
5344
6824
|
() => loadedOverrides.headerActions || defaultHeaderActionsRender,
|
5345
6825
|
[loadedOverrides]
|
5346
6826
|
);
|
5347
|
-
const [mounted, setMounted] =
|
5348
|
-
|
6827
|
+
const [mounted, setMounted] = useState24(false);
|
6828
|
+
useEffect21(() => {
|
5349
6829
|
setMounted(true);
|
5350
6830
|
}, []);
|
5351
6831
|
const selectedComponentConfig = selectedItem && config.components[selectedItem.type];
|
5352
|
-
const selectedComponentLabel = selectedItem ? (
|
6832
|
+
const selectedComponentLabel = selectedItem ? (_b = selectedComponentConfig == null ? void 0 : selectedComponentConfig["label"]) != null ? _b : selectedItem.type.toString() : "";
|
6833
|
+
const [manager] = useState24(new DragDropManager2({ plugins: [Feedback] }));
|
5353
6834
|
return /* @__PURE__ */ jsxs21("div", { className: `Puck ${getClassName27()}`, children: [
|
5354
|
-
/* @__PURE__ */
|
6835
|
+
/* @__PURE__ */ jsx39(
|
5355
6836
|
AppProvider,
|
5356
6837
|
{
|
5357
6838
|
value: {
|
@@ -5373,233 +6854,133 @@ function Puck({
|
|
5373
6854
|
getPermissions: () => ({}),
|
5374
6855
|
refreshPermissions: () => null
|
5375
6856
|
},
|
5376
|
-
children: /* @__PURE__ */
|
5377
|
-
|
6857
|
+
children: /* @__PURE__ */ jsx39(DragDropContext2, { children: /* @__PURE__ */ jsx39(CustomPuck, { children: children || /* @__PURE__ */ jsx39(
|
6858
|
+
"div",
|
5378
6859
|
{
|
5379
|
-
|
5380
|
-
|
5381
|
-
|
5382
|
-
|
5383
|
-
|
5384
|
-
|
5385
|
-
|
5386
|
-
|
5387
|
-
|
5388
|
-
|
5389
|
-
|
5390
|
-
|
5391
|
-
|
5392
|
-
|
5393
|
-
|
5394
|
-
|
5395
|
-
|
5396
|
-
|
5397
|
-
|
5398
|
-
|
5399
|
-
|
5400
|
-
|
5401
|
-
|
5402
|
-
|
5403
|
-
return;
|
5404
|
-
} else {
|
5405
|
-
const { source, destination } = droppedItem;
|
5406
|
-
if (source.droppableId === destination.droppableId) {
|
5407
|
-
dispatch({
|
5408
|
-
type: "reorder",
|
5409
|
-
sourceIndex: source.index,
|
5410
|
-
destinationIndex: destination.index,
|
5411
|
-
destinationZone: destination.droppableId
|
5412
|
-
});
|
5413
|
-
} else {
|
5414
|
-
dispatch({
|
5415
|
-
type: "move",
|
5416
|
-
sourceZone: source.droppableId,
|
5417
|
-
sourceIndex: source.index,
|
5418
|
-
destinationIndex: destination.index,
|
5419
|
-
destinationZone: destination.droppableId
|
5420
|
-
});
|
5421
|
-
}
|
5422
|
-
setItemSelector({
|
5423
|
-
index: destination.index,
|
5424
|
-
zone: destination.droppableId
|
5425
|
-
});
|
5426
|
-
}
|
5427
|
-
},
|
5428
|
-
children: /* @__PURE__ */ jsx38(
|
5429
|
-
DropZoneProvider,
|
5430
|
-
{
|
5431
|
-
value: {
|
5432
|
-
data,
|
5433
|
-
itemSelector,
|
5434
|
-
setItemSelector,
|
5435
|
-
config,
|
5436
|
-
dispatch,
|
5437
|
-
draggedItem,
|
5438
|
-
placeholderStyle,
|
5439
|
-
mode: "edit",
|
5440
|
-
areaId: "root"
|
5441
|
-
},
|
5442
|
-
children: /* @__PURE__ */ jsx38(CustomPuck, { children: children || /* @__PURE__ */ jsx38(
|
5443
|
-
"div",
|
5444
|
-
{
|
5445
|
-
className: getLayoutClassName({
|
5446
|
-
leftSideBarVisible,
|
5447
|
-
menuOpen,
|
5448
|
-
mounted,
|
5449
|
-
rightSideBarVisible
|
5450
|
-
}),
|
5451
|
-
children: /* @__PURE__ */ jsxs21("div", { className: getLayoutClassName("inner"), children: [
|
5452
|
-
/* @__PURE__ */ jsx38(
|
5453
|
-
CustomHeader,
|
6860
|
+
className: getLayoutClassName({
|
6861
|
+
leftSideBarVisible,
|
6862
|
+
menuOpen,
|
6863
|
+
mounted,
|
6864
|
+
rightSideBarVisible
|
6865
|
+
}),
|
6866
|
+
children: /* @__PURE__ */ jsxs21("div", { className: getLayoutClassName("inner"), children: [
|
6867
|
+
/* @__PURE__ */ jsx39(
|
6868
|
+
CustomHeader,
|
6869
|
+
{
|
6870
|
+
actions: /* @__PURE__ */ jsx39(Fragment19, { children: /* @__PURE__ */ jsx39(CustomHeaderActions, { children: /* @__PURE__ */ jsx39(
|
6871
|
+
Button,
|
6872
|
+
{
|
6873
|
+
onClick: () => {
|
6874
|
+
onPublish && onPublish(data);
|
6875
|
+
},
|
6876
|
+
icon: /* @__PURE__ */ jsx39(Globe, { size: "14px" }),
|
6877
|
+
children: "Publish"
|
6878
|
+
}
|
6879
|
+
) }) }),
|
6880
|
+
children: /* @__PURE__ */ jsx39("header", { className: getLayoutClassName("header"), children: /* @__PURE__ */ jsxs21("div", { className: getLayoutClassName("headerInner"), children: [
|
6881
|
+
/* @__PURE__ */ jsxs21("div", { className: getLayoutClassName("headerToggle"), children: [
|
6882
|
+
/* @__PURE__ */ jsx39(
|
6883
|
+
"div",
|
5454
6884
|
{
|
5455
|
-
|
5456
|
-
|
6885
|
+
className: getLayoutClassName("leftSideBarToggle"),
|
6886
|
+
children: /* @__PURE__ */ jsx39(
|
6887
|
+
IconButton,
|
5457
6888
|
{
|
5458
6889
|
onClick: () => {
|
5459
|
-
|
6890
|
+
toggleSidebars("left");
|
5460
6891
|
},
|
5461
|
-
|
5462
|
-
children: "
|
6892
|
+
title: "Toggle left sidebar",
|
6893
|
+
children: /* @__PURE__ */ jsx39(PanelLeft, { focusable: "false" })
|
5463
6894
|
}
|
5464
|
-
)
|
5465
|
-
children: /* @__PURE__ */ jsx38("header", { className: getLayoutClassName("header"), children: /* @__PURE__ */ jsxs21("div", { className: getLayoutClassName("headerInner"), children: [
|
5466
|
-
/* @__PURE__ */ jsxs21(
|
5467
|
-
"div",
|
5468
|
-
{
|
5469
|
-
className: getLayoutClassName("headerToggle"),
|
5470
|
-
children: [
|
5471
|
-
/* @__PURE__ */ jsx38(
|
5472
|
-
"div",
|
5473
|
-
{
|
5474
|
-
className: getLayoutClassName(
|
5475
|
-
"leftSideBarToggle"
|
5476
|
-
),
|
5477
|
-
children: /* @__PURE__ */ jsx38(
|
5478
|
-
IconButton,
|
5479
|
-
{
|
5480
|
-
onClick: () => {
|
5481
|
-
toggleSidebars("left");
|
5482
|
-
},
|
5483
|
-
title: "Toggle left sidebar",
|
5484
|
-
children: /* @__PURE__ */ jsx38(PanelLeft, { focusable: "false" })
|
5485
|
-
}
|
5486
|
-
)
|
5487
|
-
}
|
5488
|
-
),
|
5489
|
-
/* @__PURE__ */ jsx38(
|
5490
|
-
"div",
|
5491
|
-
{
|
5492
|
-
className: getLayoutClassName(
|
5493
|
-
"rightSideBarToggle"
|
5494
|
-
),
|
5495
|
-
children: /* @__PURE__ */ jsx38(
|
5496
|
-
IconButton,
|
5497
|
-
{
|
5498
|
-
onClick: () => {
|
5499
|
-
toggleSidebars("right");
|
5500
|
-
},
|
5501
|
-
title: "Toggle right sidebar",
|
5502
|
-
children: /* @__PURE__ */ jsx38(PanelRight, { focusable: "false" })
|
5503
|
-
}
|
5504
|
-
)
|
5505
|
-
}
|
5506
|
-
)
|
5507
|
-
]
|
5508
|
-
}
|
5509
|
-
),
|
5510
|
-
/* @__PURE__ */ jsx38(
|
5511
|
-
"div",
|
5512
|
-
{
|
5513
|
-
className: getLayoutClassName("headerTitle"),
|
5514
|
-
children: /* @__PURE__ */ jsxs21(Heading, { rank: "2", size: "xs", children: [
|
5515
|
-
headerTitle || rootProps.title || "Page",
|
5516
|
-
headerPath && /* @__PURE__ */ jsxs21(Fragment19, { children: [
|
5517
|
-
" ",
|
5518
|
-
/* @__PURE__ */ jsx38(
|
5519
|
-
"code",
|
5520
|
-
{
|
5521
|
-
className: getLayoutClassName(
|
5522
|
-
"headerPath"
|
5523
|
-
),
|
5524
|
-
children: headerPath
|
5525
|
-
}
|
5526
|
-
)
|
5527
|
-
] })
|
5528
|
-
] })
|
5529
|
-
}
|
5530
|
-
),
|
5531
|
-
/* @__PURE__ */ jsxs21(
|
5532
|
-
"div",
|
5533
|
-
{
|
5534
|
-
className: getLayoutClassName("headerTools"),
|
5535
|
-
children: [
|
5536
|
-
/* @__PURE__ */ jsx38(
|
5537
|
-
"div",
|
5538
|
-
{
|
5539
|
-
className: getLayoutClassName("menuButton"),
|
5540
|
-
children: /* @__PURE__ */ jsx38(
|
5541
|
-
IconButton,
|
5542
|
-
{
|
5543
|
-
onClick: () => {
|
5544
|
-
return setMenuOpen(!menuOpen);
|
5545
|
-
},
|
5546
|
-
title: "Toggle menu bar",
|
5547
|
-
children: menuOpen ? /* @__PURE__ */ jsx38(ChevronUp, { focusable: "false" }) : /* @__PURE__ */ jsx38(ChevronDown, { focusable: "false" })
|
5548
|
-
}
|
5549
|
-
)
|
5550
|
-
}
|
5551
|
-
),
|
5552
|
-
/* @__PURE__ */ jsx38(
|
5553
|
-
MenuBar,
|
5554
|
-
{
|
5555
|
-
appState,
|
5556
|
-
dispatch,
|
5557
|
-
onPublish,
|
5558
|
-
menuOpen,
|
5559
|
-
renderHeaderActions: () => /* @__PURE__ */ jsx38(CustomHeaderActions, { children: /* @__PURE__ */ jsx38(
|
5560
|
-
Button,
|
5561
|
-
{
|
5562
|
-
onClick: () => {
|
5563
|
-
onPublish && onPublish(data);
|
5564
|
-
},
|
5565
|
-
icon: /* @__PURE__ */ jsx38(Globe, { size: "14px" }),
|
5566
|
-
children: "Publish"
|
5567
|
-
}
|
5568
|
-
) }),
|
5569
|
-
setMenuOpen
|
5570
|
-
}
|
5571
|
-
)
|
5572
|
-
]
|
5573
|
-
}
|
5574
|
-
)
|
5575
|
-
] }) })
|
6895
|
+
)
|
5576
6896
|
}
|
5577
6897
|
),
|
5578
|
-
/* @__PURE__ */
|
5579
|
-
|
5580
|
-
|
5581
|
-
|
5582
|
-
|
5583
|
-
|
5584
|
-
|
6898
|
+
/* @__PURE__ */ jsx39(
|
6899
|
+
"div",
|
6900
|
+
{
|
6901
|
+
className: getLayoutClassName("rightSideBarToggle"),
|
6902
|
+
children: /* @__PURE__ */ jsx39(
|
6903
|
+
IconButton,
|
6904
|
+
{
|
6905
|
+
onClick: () => {
|
6906
|
+
toggleSidebars("right");
|
6907
|
+
},
|
6908
|
+
title: "Toggle right sidebar",
|
6909
|
+
children: /* @__PURE__ */ jsx39(PanelRight, { focusable: "false" })
|
6910
|
+
}
|
6911
|
+
)
|
6912
|
+
}
|
6913
|
+
)
|
6914
|
+
] }),
|
6915
|
+
/* @__PURE__ */ jsx39("div", { className: getLayoutClassName("headerTitle"), children: /* @__PURE__ */ jsxs21(Heading, { rank: "2", size: "xs", children: [
|
6916
|
+
headerTitle || rootProps.title || "Page",
|
6917
|
+
headerPath && /* @__PURE__ */ jsxs21(Fragment19, { children: [
|
6918
|
+
" ",
|
6919
|
+
/* @__PURE__ */ jsx39(
|
6920
|
+
"code",
|
6921
|
+
{
|
6922
|
+
className: getLayoutClassName("headerPath"),
|
6923
|
+
children: headerPath
|
6924
|
+
}
|
6925
|
+
)
|
6926
|
+
] })
|
6927
|
+
] }) }),
|
6928
|
+
/* @__PURE__ */ jsxs21("div", { className: getLayoutClassName("headerTools"), children: [
|
6929
|
+
/* @__PURE__ */ jsx39("div", { className: getLayoutClassName("menuButton"), children: /* @__PURE__ */ jsx39(
|
6930
|
+
IconButton,
|
6931
|
+
{
|
6932
|
+
onClick: () => {
|
6933
|
+
return setMenuOpen(!menuOpen);
|
6934
|
+
},
|
6935
|
+
title: "Toggle menu bar",
|
6936
|
+
children: menuOpen ? /* @__PURE__ */ jsx39(ChevronUp, { focusable: "false" }) : /* @__PURE__ */ jsx39(ChevronDown, { focusable: "false" })
|
6937
|
+
}
|
6938
|
+
) }),
|
6939
|
+
/* @__PURE__ */ jsx39(
|
6940
|
+
MenuBar,
|
5585
6941
|
{
|
5586
|
-
|
5587
|
-
|
5588
|
-
|
5589
|
-
|
5590
|
-
|
6942
|
+
appState,
|
6943
|
+
dispatch,
|
6944
|
+
onPublish,
|
6945
|
+
menuOpen,
|
6946
|
+
renderHeaderActions: () => /* @__PURE__ */ jsx39(CustomHeaderActions, { children: /* @__PURE__ */ jsx39(
|
6947
|
+
Button,
|
6948
|
+
{
|
6949
|
+
onClick: () => {
|
6950
|
+
onPublish && onPublish(data);
|
6951
|
+
},
|
6952
|
+
icon: /* @__PURE__ */ jsx39(Globe, { size: "14px" }),
|
6953
|
+
children: "Publish"
|
6954
|
+
}
|
6955
|
+
) }),
|
6956
|
+
setMenuOpen
|
5591
6957
|
}
|
5592
|
-
)
|
6958
|
+
)
|
5593
6959
|
] })
|
5594
|
-
}
|
5595
|
-
|
5596
|
-
|
5597
|
-
|
6960
|
+
] }) })
|
6961
|
+
}
|
6962
|
+
),
|
6963
|
+
/* @__PURE__ */ jsxs21("div", { className: getLayoutClassName("leftSideBar"), children: [
|
6964
|
+
/* @__PURE__ */ jsx39(SidebarSection, { title: "Components", noBorderTop: true, children: /* @__PURE__ */ jsx39(Components, {}) }),
|
6965
|
+
/* @__PURE__ */ jsx39(SidebarSection, { title: "Outline", children: /* @__PURE__ */ jsx39(Outline, {}) })
|
6966
|
+
] }),
|
6967
|
+
/* @__PURE__ */ jsx39(Canvas, {}),
|
6968
|
+
/* @__PURE__ */ jsx39("div", { className: getLayoutClassName("rightSideBar"), children: /* @__PURE__ */ jsx39(
|
6969
|
+
SidebarSection,
|
6970
|
+
{
|
6971
|
+
noPadding: true,
|
6972
|
+
noBorderTop: true,
|
6973
|
+
showBreadcrumbs: true,
|
6974
|
+
title: selectedItem ? selectedComponentLabel : "Page",
|
6975
|
+
children: /* @__PURE__ */ jsx39(Fields, {})
|
6976
|
+
}
|
6977
|
+
) })
|
6978
|
+
] })
|
5598
6979
|
}
|
5599
|
-
) })
|
6980
|
+
) }) })
|
5600
6981
|
}
|
5601
6982
|
),
|
5602
|
-
/* @__PURE__ */
|
6983
|
+
/* @__PURE__ */ jsx39("div", { id: "puck-portal-root", className: getClassName27("portal") })
|
5603
6984
|
] });
|
5604
6985
|
}
|
5605
6986
|
Puck.Components = Components;
|
@@ -5609,7 +6990,7 @@ Puck.Preview = Preview;
|
|
5609
6990
|
|
5610
6991
|
// components/Render/index.tsx
|
5611
6992
|
init_react_import();
|
5612
|
-
import { jsx as
|
6993
|
+
import { jsx as jsx40 } from "react/jsx-runtime";
|
5613
6994
|
function Render({
|
5614
6995
|
config,
|
5615
6996
|
data
|
@@ -5622,21 +7003,45 @@ function Render({
|
|
5622
7003
|
const rootProps = defaultedData.root.props || defaultedData.root;
|
5623
7004
|
const title = (rootProps == null ? void 0 : rootProps.title) || "";
|
5624
7005
|
if ((_a = config.root) == null ? void 0 : _a.render) {
|
5625
|
-
return /* @__PURE__ */
|
5626
|
-
|
5627
|
-
|
5628
|
-
|
5629
|
-
|
5630
|
-
|
7006
|
+
return /* @__PURE__ */ jsx40(
|
7007
|
+
DropZoneProvider,
|
7008
|
+
{
|
7009
|
+
value: {
|
7010
|
+
data: defaultedData,
|
7011
|
+
config,
|
7012
|
+
mode: "render",
|
7013
|
+
depth: 0,
|
7014
|
+
path: []
|
5631
7015
|
},
|
5632
|
-
|
5633
|
-
|
5634
|
-
|
5635
|
-
|
5636
|
-
|
5637
|
-
|
7016
|
+
children: /* @__PURE__ */ jsx40(
|
7017
|
+
config.root.render,
|
7018
|
+
__spreadProps(__spreadValues({}, rootProps), {
|
7019
|
+
puck: {
|
7020
|
+
renderDropZone: DropZone,
|
7021
|
+
isEditing: false
|
7022
|
+
},
|
7023
|
+
title,
|
7024
|
+
editMode: false,
|
7025
|
+
id: "puck-root",
|
7026
|
+
children: /* @__PURE__ */ jsx40(DropZone, { zone: rootDroppableId })
|
7027
|
+
})
|
7028
|
+
)
|
7029
|
+
}
|
7030
|
+
);
|
5638
7031
|
}
|
5639
|
-
return /* @__PURE__ */
|
7032
|
+
return /* @__PURE__ */ jsx40(
|
7033
|
+
DropZoneProvider,
|
7034
|
+
{
|
7035
|
+
value: {
|
7036
|
+
data: defaultedData,
|
7037
|
+
config,
|
7038
|
+
mode: "render",
|
7039
|
+
depth: 0,
|
7040
|
+
path: []
|
7041
|
+
},
|
7042
|
+
children: /* @__PURE__ */ jsx40(DropZone, { zone: rootDroppableId })
|
7043
|
+
}
|
7044
|
+
);
|
5640
7045
|
}
|
5641
7046
|
|
5642
7047
|
// lib/migrate.ts
|