@measured/puck 0.21.0-canary.74d9a160 → 0.21.0-canary.7dca3a5a
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-VBJEDLUM.mjs → chunk-6SIKCDJJ.mjs} +4 -2
- package/dist/{chunk-EXX4ZSCK.mjs → chunk-FKDVYRQW.mjs} +2198 -1776
- package/dist/index.css +650 -272
- package/dist/index.d.mts +17 -5
- package/dist/index.d.ts +17 -5
- package/dist/index.js +1670 -1247
- package/dist/index.mjs +8 -2
- package/dist/no-external.css +650 -272
- package/dist/no-external.d.mts +2 -2
- package/dist/no-external.d.ts +2 -2
- package/dist/no-external.js +1670 -1247
- package/dist/no-external.mjs +8 -2
- package/dist/rsc.d.mts +2 -2
- package/dist/rsc.d.ts +2 -2
- package/dist/rsc.js +4 -2
- package/dist/rsc.mjs +1 -1
- package/dist/{walk-tree-DkTSFbz_.d.mts → walk-tree-DS1xB387.d.mts} +70 -50
- package/dist/{walk-tree-DkTSFbz_.d.ts → walk-tree-DS1xB387.d.ts} +70 -50
- package/package.json +1 -1
|
@@ -25,7 +25,7 @@ import {
|
|
|
25
25
|
walkAppState,
|
|
26
26
|
walkField,
|
|
27
27
|
walkTree
|
|
28
|
-
} from "./chunk-
|
|
28
|
+
} from "./chunk-6SIKCDJJ.mjs";
|
|
29
29
|
|
|
30
30
|
// ../../node_modules/classnames/index.js
|
|
31
31
|
var require_classnames = __commonJS({
|
|
@@ -1308,6 +1308,7 @@ var createAppStore = (initialAppStore) => create2()(
|
|
|
1308
1308
|
subscribeWithSelector2((set, get) => {
|
|
1309
1309
|
var _a, _b;
|
|
1310
1310
|
return __spreadProps(__spreadValues({
|
|
1311
|
+
instanceId: generateId(),
|
|
1311
1312
|
state: defaultAppState,
|
|
1312
1313
|
config: { components: {} },
|
|
1313
1314
|
componentState: {},
|
|
@@ -1616,7 +1617,7 @@ var getZoomConfig = (uiViewport, frame, zoom) => {
|
|
|
1616
1617
|
const viewportHeight = uiViewport.height === "auto" ? frameHeight : uiViewport.height;
|
|
1617
1618
|
let rootHeight = 0;
|
|
1618
1619
|
let autoZoom = 1;
|
|
1619
|
-
if (uiViewport.width > frameWidth || viewportHeight > frameHeight) {
|
|
1620
|
+
if (typeof uiViewport.width === "number" && (uiViewport.width > frameWidth || viewportHeight > frameHeight)) {
|
|
1620
1621
|
const widthZoom = Math.min(frameWidth / uiViewport.width, 1);
|
|
1621
1622
|
const heightZoom = Math.min(frameHeight / viewportHeight, 1);
|
|
1622
1623
|
zoom = widthZoom;
|
|
@@ -1695,7 +1696,8 @@ var IconButton = ({
|
|
|
1695
1696
|
tabIndex,
|
|
1696
1697
|
newTab,
|
|
1697
1698
|
fullWidth,
|
|
1698
|
-
title
|
|
1699
|
+
title,
|
|
1700
|
+
suppressHydrationWarning
|
|
1699
1701
|
}) => {
|
|
1700
1702
|
const [loading, setLoading] = useState(false);
|
|
1701
1703
|
const ElementType = href ? "a" : "button";
|
|
@@ -1722,6 +1724,7 @@ var IconButton = ({
|
|
|
1722
1724
|
rel: newTab ? "noreferrer" : void 0,
|
|
1723
1725
|
href,
|
|
1724
1726
|
title,
|
|
1727
|
+
suppressHydrationWarning,
|
|
1725
1728
|
children: [
|
|
1726
1729
|
/* @__PURE__ */ jsx3("span", { className: getClassName3("title"), children: title }),
|
|
1727
1730
|
children,
|
|
@@ -1983,6 +1986,15 @@ var EllipsisVertical = createLucideIcon("EllipsisVertical", [
|
|
|
1983
1986
|
["circle", { cx: "12", cy: "19", r: "1", key: "lyex9k" }]
|
|
1984
1987
|
]);
|
|
1985
1988
|
|
|
1989
|
+
// ../../node_modules/lucide-react/dist/esm/icons/expand.js
|
|
1990
|
+
init_react_import();
|
|
1991
|
+
var Expand = createLucideIcon("Expand", [
|
|
1992
|
+
["path", { d: "m21 21-6-6m6 6v-4.8m0 4.8h-4.8", key: "1c15vz" }],
|
|
1993
|
+
["path", { d: "M3 16.2V21m0 0h4.8M3 21l6-6", key: "1fsnz2" }],
|
|
1994
|
+
["path", { d: "M21 7.8V3m0 0h-4.8M21 3l-6 6", key: "hawz9i" }],
|
|
1995
|
+
["path", { d: "M3 7.8V3m0 0h4.8M3 3l6 6", key: "u9ee12" }]
|
|
1996
|
+
]);
|
|
1997
|
+
|
|
1986
1998
|
// ../../node_modules/lucide-react/dist/esm/icons/globe.js
|
|
1987
1999
|
init_react_import();
|
|
1988
2000
|
var Globe = createLucideIcon("Globe", [
|
|
@@ -1991,6 +2003,20 @@ var Globe = createLucideIcon("Globe", [
|
|
|
1991
2003
|
["path", { d: "M2 12h20", key: "9i4pu4" }]
|
|
1992
2004
|
]);
|
|
1993
2005
|
|
|
2006
|
+
// ../../node_modules/lucide-react/dist/esm/icons/hammer.js
|
|
2007
|
+
init_react_import();
|
|
2008
|
+
var Hammer = createLucideIcon("Hammer", [
|
|
2009
|
+
["path", { d: "m15 12-8.373 8.373a1 1 0 1 1-3-3L12 9", key: "eefl8a" }],
|
|
2010
|
+
["path", { d: "m18 15 4-4", key: "16gjal" }],
|
|
2011
|
+
[
|
|
2012
|
+
"path",
|
|
2013
|
+
{
|
|
2014
|
+
d: "m21.5 11.5-1.914-1.914A2 2 0 0 1 19 8.172V7l-2.26-2.26a6 6 0 0 0-4.202-1.756L9 2.96l.92.82A6.18 6.18 0 0 1 12 8.4V10l2 2h1.172a2 2 0 0 1 1.414.586L18.5 14.5",
|
|
2015
|
+
key: "b7pghm"
|
|
2016
|
+
}
|
|
2017
|
+
]
|
|
2018
|
+
]);
|
|
2019
|
+
|
|
1994
2020
|
// ../../node_modules/lucide-react/dist/esm/icons/hash.js
|
|
1995
2021
|
init_react_import();
|
|
1996
2022
|
var Hash = createLucideIcon("Hash", [
|
|
@@ -2067,6 +2093,24 @@ var Lock = createLucideIcon("Lock", [
|
|
|
2067
2093
|
["path", { d: "M7 11V7a5 5 0 0 1 10 0v4", key: "fwvmzm" }]
|
|
2068
2094
|
]);
|
|
2069
2095
|
|
|
2096
|
+
// ../../node_modules/lucide-react/dist/esm/icons/maximize-2.js
|
|
2097
|
+
init_react_import();
|
|
2098
|
+
var Maximize2 = createLucideIcon("Maximize2", [
|
|
2099
|
+
["polyline", { points: "15 3 21 3 21 9", key: "mznyad" }],
|
|
2100
|
+
["polyline", { points: "9 21 3 21 3 15", key: "1avn1i" }],
|
|
2101
|
+
["line", { x1: "21", x2: "14", y1: "3", y2: "10", key: "ota7mn" }],
|
|
2102
|
+
["line", { x1: "3", x2: "10", y1: "21", y2: "14", key: "1atl0r" }]
|
|
2103
|
+
]);
|
|
2104
|
+
|
|
2105
|
+
// ../../node_modules/lucide-react/dist/esm/icons/minimize-2.js
|
|
2106
|
+
init_react_import();
|
|
2107
|
+
var Minimize2 = createLucideIcon("Minimize2", [
|
|
2108
|
+
["polyline", { points: "4 14 10 14 10 20", key: "11kfnr" }],
|
|
2109
|
+
["polyline", { points: "20 10 14 10 14 4", key: "rlmsce" }],
|
|
2110
|
+
["line", { x1: "14", x2: "21", y1: "10", y2: "3", key: "o5lafz" }],
|
|
2111
|
+
["line", { x1: "3", x2: "10", y1: "21", y2: "14", key: "1atl0r" }]
|
|
2112
|
+
]);
|
|
2113
|
+
|
|
2070
2114
|
// ../../node_modules/lucide-react/dist/esm/icons/monitor.js
|
|
2071
2115
|
init_react_import();
|
|
2072
2116
|
var Monitor = createLucideIcon("Monitor", [
|
|
@@ -2096,6 +2140,15 @@ var Plus = createLucideIcon("Plus", [
|
|
|
2096
2140
|
["path", { d: "M12 5v14", key: "s699le" }]
|
|
2097
2141
|
]);
|
|
2098
2142
|
|
|
2143
|
+
// ../../node_modules/lucide-react/dist/esm/icons/rectangle-ellipsis.js
|
|
2144
|
+
init_react_import();
|
|
2145
|
+
var RectangleEllipsis = createLucideIcon("RectangleEllipsis", [
|
|
2146
|
+
["rect", { width: "20", height: "12", x: "2", y: "6", rx: "2", key: "9lu3g6" }],
|
|
2147
|
+
["path", { d: "M12 12h.01", key: "1mp3jc" }],
|
|
2148
|
+
["path", { d: "M17 12h.01", key: "1m0b6t" }],
|
|
2149
|
+
["path", { d: "M7 12h.01", key: "eqddd0" }]
|
|
2150
|
+
]);
|
|
2151
|
+
|
|
2099
2152
|
// ../../node_modules/lucide-react/dist/esm/icons/redo-2.js
|
|
2100
2153
|
init_react_import();
|
|
2101
2154
|
var Redo2 = createLucideIcon("Redo2", [
|
|
@@ -2138,6 +2191,14 @@ var Tablet = createLucideIcon("Tablet", [
|
|
|
2138
2191
|
["line", { x1: "12", x2: "12.01", y1: "18", y2: "18", key: "1dp563" }]
|
|
2139
2192
|
]);
|
|
2140
2193
|
|
|
2194
|
+
// ../../node_modules/lucide-react/dist/esm/icons/toy-brick.js
|
|
2195
|
+
init_react_import();
|
|
2196
|
+
var ToyBrick = createLucideIcon("ToyBrick", [
|
|
2197
|
+
["rect", { width: "18", height: "12", x: "3", y: "8", rx: "1", key: "158fvp" }],
|
|
2198
|
+
["path", { d: "M10 8V5c0-.6-.4-1-1-1H6a1 1 0 0 0-1 1v3", key: "s0042v" }],
|
|
2199
|
+
["path", { d: "M19 8V5c0-.6-.4-1-1-1h-3a1 1 0 0 0-1 1v3", key: "9wmeh2" }]
|
|
2200
|
+
]);
|
|
2201
|
+
|
|
2141
2202
|
// ../../node_modules/lucide-react/dist/esm/icons/trash.js
|
|
2142
2203
|
init_react_import();
|
|
2143
2204
|
var Trash = createLucideIcon("Trash", [
|
|
@@ -2161,6 +2222,13 @@ var Undo2 = createLucideIcon("Undo2", [
|
|
|
2161
2222
|
["path", { d: "M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11", key: "f3b9sd" }]
|
|
2162
2223
|
]);
|
|
2163
2224
|
|
|
2225
|
+
// ../../node_modules/lucide-react/dist/esm/icons/x.js
|
|
2226
|
+
init_react_import();
|
|
2227
|
+
var X = createLucideIcon("X", [
|
|
2228
|
+
["path", { d: "M18 6 6 18", key: "1bl5f8" }],
|
|
2229
|
+
["path", { d: "m6 6 12 12", key: "d8bk6v" }]
|
|
2230
|
+
]);
|
|
2231
|
+
|
|
2164
2232
|
// ../../node_modules/lucide-react/dist/esm/icons/zoom-in.js
|
|
2165
2233
|
init_react_import();
|
|
2166
2234
|
var ZoomIn = createLucideIcon("ZoomIn", [
|
|
@@ -2986,8 +3054,9 @@ var ArrayField = ({
|
|
|
2986
3054
|
var _a;
|
|
2987
3055
|
if (isDraggingAny) return;
|
|
2988
3056
|
const existingValue = value || [];
|
|
3057
|
+
const defaultProps = typeof field.defaultItemProps === "function" ? field.defaultItemProps(existingValue.length) : (_a = field.defaultItemProps) != null ? _a : {};
|
|
2989
3058
|
const newItem = defaultSlots(
|
|
2990
|
-
uniqifyItem(
|
|
3059
|
+
uniqifyItem(defaultProps),
|
|
2991
3060
|
field.arrayFields
|
|
2992
3061
|
);
|
|
2993
3062
|
const newValue = [...existingValue, newItem];
|
|
@@ -4275,14 +4344,23 @@ var DraggableComponent = ({
|
|
|
4275
4344
|
if (!el.closest("[data-puck-overlay-portal]")) {
|
|
4276
4345
|
e.stopPropagation();
|
|
4277
4346
|
}
|
|
4278
|
-
|
|
4279
|
-
|
|
4280
|
-
|
|
4281
|
-
|
|
4282
|
-
|
|
4283
|
-
|
|
4347
|
+
if (isSelected) {
|
|
4348
|
+
dispatch({
|
|
4349
|
+
type: "setUi",
|
|
4350
|
+
ui: {
|
|
4351
|
+
itemSelector: null
|
|
4352
|
+
}
|
|
4353
|
+
});
|
|
4354
|
+
} else {
|
|
4355
|
+
dispatch({
|
|
4356
|
+
type: "setUi",
|
|
4357
|
+
ui: {
|
|
4358
|
+
itemSelector: { index, zone: zoneCompound }
|
|
4359
|
+
}
|
|
4360
|
+
});
|
|
4361
|
+
}
|
|
4284
4362
|
},
|
|
4285
|
-
[index, zoneCompound, id]
|
|
4363
|
+
[index, zoneCompound, id, isSelected]
|
|
4286
4364
|
);
|
|
4287
4365
|
const appStore = useAppStoreApi();
|
|
4288
4366
|
const onSelectParent = useCallback7(() => {
|
|
@@ -4931,8 +5009,8 @@ var DragDropContextClient = ({
|
|
|
4931
5009
|
disableAutoScroll
|
|
4932
5010
|
}) => {
|
|
4933
5011
|
const dispatch = useAppStore((s) => s.dispatch);
|
|
5012
|
+
const instanceId = useAppStore((s) => s.instanceId);
|
|
4934
5013
|
const appStore = useAppStoreApi();
|
|
4935
|
-
const id = useSafeId();
|
|
4936
5014
|
const debouncedParamsRef = useRef3(null);
|
|
4937
5015
|
const tempDisableFallback = useTempDisableFallback(100);
|
|
4938
5016
|
const [zoneStore] = useState11(
|
|
@@ -4948,7 +5026,7 @@ var DragDropContextClient = ({
|
|
|
4948
5026
|
}))
|
|
4949
5027
|
);
|
|
4950
5028
|
const getChanged2 = useCallback8(
|
|
4951
|
-
(params
|
|
5029
|
+
(params) => {
|
|
4952
5030
|
const { zoneDepthIndex = {}, areaDepthIndex = {} } = zoneStore.getState() || {};
|
|
4953
5031
|
const stateHasZone = Object.keys(zoneDepthIndex).length > 0;
|
|
4954
5032
|
const stateHasArea = Object.keys(areaDepthIndex).length > 0;
|
|
@@ -4970,7 +5048,7 @@ var DragDropContextClient = ({
|
|
|
4970
5048
|
);
|
|
4971
5049
|
const setDeepestAndCollide = useCallback8(
|
|
4972
5050
|
(params, manager) => {
|
|
4973
|
-
const { zoneChanged, areaChanged } = getChanged2(params
|
|
5051
|
+
const { zoneChanged, areaChanged } = getChanged2(params);
|
|
4974
5052
|
if (!zoneChanged && !areaChanged) return;
|
|
4975
5053
|
zoneStore.setState({
|
|
4976
5054
|
zoneDepthIndex: params.zone ? { [params.zone]: true } : {},
|
|
@@ -5012,7 +5090,7 @@ var DragDropContextClient = ({
|
|
|
5012
5090
|
{
|
|
5013
5091
|
onChange: (params, manager) => {
|
|
5014
5092
|
const state = zoneStore.getState();
|
|
5015
|
-
const { zoneChanged, areaChanged } = getChanged2(params
|
|
5093
|
+
const { zoneChanged, areaChanged } = getChanged2(params);
|
|
5016
5094
|
const isDragging = manager.dragOperation.status.dragging;
|
|
5017
5095
|
if (areaChanged || zoneChanged) {
|
|
5018
5096
|
let nextZoneDepthIndex = {};
|
|
@@ -5050,7 +5128,7 @@ var DragDropContextClient = ({
|
|
|
5050
5128
|
cancelDb();
|
|
5051
5129
|
}
|
|
5052
5130
|
},
|
|
5053
|
-
|
|
5131
|
+
instanceId
|
|
5054
5132
|
)
|
|
5055
5133
|
]);
|
|
5056
5134
|
const sensors = useSensors();
|
|
@@ -5065,7 +5143,7 @@ var DragDropContextClient = ({
|
|
|
5065
5143
|
}),
|
|
5066
5144
|
[]
|
|
5067
5145
|
);
|
|
5068
|
-
return /* @__PURE__ */ jsx21(
|
|
5146
|
+
return /* @__PURE__ */ jsx21(
|
|
5069
5147
|
dragListenerContext.Provider,
|
|
5070
5148
|
{
|
|
5071
5149
|
value: {
|
|
@@ -5292,7 +5370,7 @@ var DragDropContextClient = ({
|
|
|
5292
5370
|
}
|
|
5293
5371
|
)
|
|
5294
5372
|
}
|
|
5295
|
-
)
|
|
5373
|
+
);
|
|
5296
5374
|
};
|
|
5297
5375
|
var DragDropContext = ({
|
|
5298
5376
|
children,
|
|
@@ -6475,479 +6553,759 @@ function useGetPuck() {
|
|
|
6475
6553
|
return usePuckApi.getState;
|
|
6476
6554
|
}
|
|
6477
6555
|
|
|
6478
|
-
//
|
|
6556
|
+
// plugins/blocks/index.tsx
|
|
6479
6557
|
init_react_import();
|
|
6480
|
-
import {
|
|
6481
|
-
createContext as createContext8,
|
|
6482
|
-
useCallback as useCallback21,
|
|
6483
|
-
useContext as useContext13,
|
|
6484
|
-
useEffect as useEffect29,
|
|
6485
|
-
useMemo as useMemo20,
|
|
6486
|
-
useRef as useRef12,
|
|
6487
|
-
useState as useState25
|
|
6488
|
-
} from "react";
|
|
6489
6558
|
|
|
6490
|
-
// components/
|
|
6559
|
+
// components/Puck/components/Components/index.tsx
|
|
6491
6560
|
init_react_import();
|
|
6492
6561
|
|
|
6493
|
-
//
|
|
6562
|
+
// lib/use-component-list.tsx
|
|
6494
6563
|
init_react_import();
|
|
6495
|
-
|
|
6564
|
+
import { useEffect as useEffect21, useState as useState18 } from "react";
|
|
6496
6565
|
|
|
6497
|
-
//
|
|
6566
|
+
// components/ComponentList/index.tsx
|
|
6498
6567
|
init_react_import();
|
|
6499
|
-
import { useMemo as useMemo10 } from "react";
|
|
6500
|
-
var useBreadcrumbs = (renderCount) => {
|
|
6501
|
-
const selectedId = useAppStore((s) => {
|
|
6502
|
-
var _a;
|
|
6503
|
-
return (_a = s.selectedItem) == null ? void 0 : _a.props.id;
|
|
6504
|
-
});
|
|
6505
|
-
const config = useAppStore((s) => s.config);
|
|
6506
|
-
const path = useAppStore((s) => {
|
|
6507
|
-
var _a;
|
|
6508
|
-
return (_a = s.state.indexes.nodes[selectedId]) == null ? void 0 : _a.path;
|
|
6509
|
-
});
|
|
6510
|
-
const appStore = useAppStoreApi();
|
|
6511
|
-
return useMemo10(() => {
|
|
6512
|
-
const breadcrumbs = (path == null ? void 0 : path.map((zoneCompound) => {
|
|
6513
|
-
var _a, _b, _c;
|
|
6514
|
-
const [componentId] = zoneCompound.split(":");
|
|
6515
|
-
if (componentId === "root") {
|
|
6516
|
-
return {
|
|
6517
|
-
label: "Page",
|
|
6518
|
-
selector: null
|
|
6519
|
-
};
|
|
6520
|
-
}
|
|
6521
|
-
const node = appStore.getState().state.indexes.nodes[componentId];
|
|
6522
|
-
const parentId = node.path[node.path.length - 1];
|
|
6523
|
-
const contentIds = ((_a = appStore.getState().state.indexes.zones[parentId]) == null ? void 0 : _a.contentIds) || [];
|
|
6524
|
-
const index = contentIds.indexOf(componentId);
|
|
6525
|
-
const label = node ? (_c = (_b = config.components[node.data.type]) == null ? void 0 : _b.label) != null ? _c : node.data.type : "Component";
|
|
6526
|
-
return {
|
|
6527
|
-
label,
|
|
6528
|
-
selector: node ? {
|
|
6529
|
-
index,
|
|
6530
|
-
zone: node.path[node.path.length - 1]
|
|
6531
|
-
} : null
|
|
6532
|
-
};
|
|
6533
|
-
})) || [];
|
|
6534
|
-
if (renderCount) {
|
|
6535
|
-
return breadcrumbs.slice(breadcrumbs.length - renderCount);
|
|
6536
|
-
}
|
|
6537
|
-
return breadcrumbs;
|
|
6538
|
-
}, [path, renderCount]);
|
|
6539
|
-
};
|
|
6540
6568
|
|
|
6541
|
-
// components/
|
|
6569
|
+
// css-module:/home/runner/work/puck/puck/packages/core/components/ComponentList/styles.module.css#css-module
|
|
6570
|
+
init_react_import();
|
|
6571
|
+
var styles_module_default14 = { "ComponentList": "_ComponentList_1rrlt_1", "ComponentList--isExpanded": "_ComponentList--isExpanded_1rrlt_5", "ComponentList-content": "_ComponentList-content_1rrlt_9", "ComponentList-title": "_ComponentList-title_1rrlt_17", "ComponentList-titleIcon": "_ComponentList-titleIcon_1rrlt_53" };
|
|
6572
|
+
|
|
6573
|
+
// components/ComponentList/index.tsx
|
|
6574
|
+
import { useEffect as useEffect20 } from "react";
|
|
6542
6575
|
import { jsx as jsx28, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
6543
|
-
var getClassName20 = get_class_name_factory_default("
|
|
6544
|
-
var
|
|
6576
|
+
var getClassName20 = get_class_name_factory_default("ComponentList", styles_module_default14);
|
|
6577
|
+
var ComponentListItem = ({
|
|
6578
|
+
name,
|
|
6579
|
+
label
|
|
6580
|
+
}) => {
|
|
6581
|
+
var _a;
|
|
6582
|
+
const overrides = useAppStore((s) => s.overrides);
|
|
6583
|
+
const canInsert = useAppStore(
|
|
6584
|
+
(s) => s.permissions.getPermissions({
|
|
6585
|
+
type: name
|
|
6586
|
+
}).insert
|
|
6587
|
+
);
|
|
6588
|
+
useEffect20(() => {
|
|
6589
|
+
if (overrides.componentItem) {
|
|
6590
|
+
console.warn(
|
|
6591
|
+
"The `componentItem` override has been deprecated and renamed to `drawerItem`"
|
|
6592
|
+
);
|
|
6593
|
+
}
|
|
6594
|
+
}, [overrides]);
|
|
6595
|
+
return /* @__PURE__ */ jsx28(Drawer.Item, { label, name, isDragDisabled: !canInsert, children: (_a = overrides.componentItem) != null ? _a : overrides.drawerItem });
|
|
6596
|
+
};
|
|
6597
|
+
var ComponentList = ({
|
|
6545
6598
|
children,
|
|
6546
6599
|
title,
|
|
6547
|
-
|
|
6548
|
-
showBreadcrumbs,
|
|
6549
|
-
noBorderTop,
|
|
6550
|
-
noPadding,
|
|
6551
|
-
isLoading
|
|
6600
|
+
id
|
|
6552
6601
|
}) => {
|
|
6602
|
+
const config = useAppStore((s) => s.config);
|
|
6553
6603
|
const setUi = useAppStore((s) => s.setUi);
|
|
6554
|
-
const
|
|
6555
|
-
|
|
6556
|
-
|
|
6557
|
-
|
|
6558
|
-
|
|
6559
|
-
|
|
6560
|
-
|
|
6561
|
-
|
|
6562
|
-
|
|
6563
|
-
|
|
6564
|
-
|
|
6565
|
-
|
|
6566
|
-
|
|
6567
|
-
|
|
6568
|
-
|
|
6569
|
-
|
|
6570
|
-
|
|
6571
|
-
|
|
6572
|
-
|
|
6573
|
-
|
|
6574
|
-
|
|
6575
|
-
|
|
6576
|
-
|
|
6577
|
-
|
|
6578
|
-
|
|
6579
|
-
|
|
6580
|
-
|
|
6604
|
+
const componentList = useAppStore((s) => s.state.ui.componentList);
|
|
6605
|
+
const { expanded = true } = componentList[id] || {};
|
|
6606
|
+
return /* @__PURE__ */ jsxs12("div", { className: getClassName20({ isExpanded: expanded }), children: [
|
|
6607
|
+
title && /* @__PURE__ */ jsxs12(
|
|
6608
|
+
"button",
|
|
6609
|
+
{
|
|
6610
|
+
type: "button",
|
|
6611
|
+
className: getClassName20("title"),
|
|
6612
|
+
onClick: () => setUi({
|
|
6613
|
+
componentList: __spreadProps(__spreadValues({}, componentList), {
|
|
6614
|
+
[id]: __spreadProps(__spreadValues({}, componentList[id]), {
|
|
6615
|
+
expanded: !expanded
|
|
6616
|
+
})
|
|
6617
|
+
})
|
|
6618
|
+
}),
|
|
6619
|
+
title: expanded ? `Collapse${title ? ` ${title}` : ""}` : `Expand${title ? ` ${title}` : ""}`,
|
|
6620
|
+
children: [
|
|
6621
|
+
/* @__PURE__ */ jsx28("div", { children: title }),
|
|
6622
|
+
/* @__PURE__ */ jsx28("div", { className: getClassName20("titleIcon"), children: expanded ? /* @__PURE__ */ jsx28(ChevronUp, { size: 12 }) : /* @__PURE__ */ jsx28(ChevronDown, { size: 12 }) })
|
|
6623
|
+
]
|
|
6624
|
+
}
|
|
6625
|
+
),
|
|
6626
|
+
/* @__PURE__ */ jsx28("div", { className: getClassName20("content"), children: /* @__PURE__ */ jsx28(Drawer, { children: children || Object.keys(config.components).map((componentKey) => {
|
|
6627
|
+
var _a;
|
|
6628
|
+
return /* @__PURE__ */ jsx28(
|
|
6629
|
+
ComponentListItem,
|
|
6630
|
+
{
|
|
6631
|
+
label: (_a = config.components[componentKey]["label"]) != null ? _a : componentKey,
|
|
6632
|
+
name: componentKey
|
|
6633
|
+
},
|
|
6634
|
+
componentKey
|
|
6635
|
+
);
|
|
6636
|
+
}) }) })
|
|
6637
|
+
] });
|
|
6581
6638
|
};
|
|
6639
|
+
ComponentList.Item = ComponentListItem;
|
|
6582
6640
|
|
|
6583
|
-
//
|
|
6584
|
-
|
|
6585
|
-
var
|
|
6641
|
+
// lib/use-component-list.tsx
|
|
6642
|
+
import { jsx as jsx29 } from "react/jsx-runtime";
|
|
6643
|
+
var useComponentList = () => {
|
|
6644
|
+
const [componentList, setComponentList] = useState18();
|
|
6645
|
+
const config = useAppStore((s) => s.config);
|
|
6646
|
+
const uiComponentList = useAppStore((s) => s.state.ui.componentList);
|
|
6647
|
+
useEffect21(() => {
|
|
6648
|
+
var _a, _b, _c;
|
|
6649
|
+
if (Object.keys(uiComponentList).length > 0) {
|
|
6650
|
+
const matchedComponents = [];
|
|
6651
|
+
let _componentList;
|
|
6652
|
+
_componentList = Object.entries(uiComponentList).map(
|
|
6653
|
+
([categoryKey, category]) => {
|
|
6654
|
+
if (!category.components) {
|
|
6655
|
+
return null;
|
|
6656
|
+
}
|
|
6657
|
+
category.components.forEach((componentName) => {
|
|
6658
|
+
matchedComponents.push(componentName);
|
|
6659
|
+
});
|
|
6660
|
+
if (category.visible === false) {
|
|
6661
|
+
return null;
|
|
6662
|
+
}
|
|
6663
|
+
return /* @__PURE__ */ jsx29(
|
|
6664
|
+
ComponentList,
|
|
6665
|
+
{
|
|
6666
|
+
id: categoryKey,
|
|
6667
|
+
title: category.title || categoryKey,
|
|
6668
|
+
children: category.components.map((componentName, i) => {
|
|
6669
|
+
var _a2;
|
|
6670
|
+
const componentConf = config.components[componentName] || {};
|
|
6671
|
+
return /* @__PURE__ */ jsx29(
|
|
6672
|
+
ComponentList.Item,
|
|
6673
|
+
{
|
|
6674
|
+
label: (_a2 = componentConf["label"]) != null ? _a2 : componentName,
|
|
6675
|
+
name: componentName,
|
|
6676
|
+
index: i
|
|
6677
|
+
},
|
|
6678
|
+
componentName
|
|
6679
|
+
);
|
|
6680
|
+
})
|
|
6681
|
+
},
|
|
6682
|
+
categoryKey
|
|
6683
|
+
);
|
|
6684
|
+
}
|
|
6685
|
+
);
|
|
6686
|
+
const remainingComponents = Object.keys(config.components).filter(
|
|
6687
|
+
(component) => matchedComponents.indexOf(component) === -1
|
|
6688
|
+
);
|
|
6689
|
+
if (remainingComponents.length > 0 && !((_a = uiComponentList.other) == null ? void 0 : _a.components) && ((_b = uiComponentList.other) == null ? void 0 : _b.visible) !== false) {
|
|
6690
|
+
_componentList.push(
|
|
6691
|
+
/* @__PURE__ */ jsx29(
|
|
6692
|
+
ComponentList,
|
|
6693
|
+
{
|
|
6694
|
+
id: "other",
|
|
6695
|
+
title: ((_c = uiComponentList.other) == null ? void 0 : _c.title) || "Other",
|
|
6696
|
+
children: remainingComponents.map((componentName, i) => {
|
|
6697
|
+
var _a2;
|
|
6698
|
+
const componentConf = config.components[componentName] || {};
|
|
6699
|
+
return /* @__PURE__ */ jsx29(
|
|
6700
|
+
ComponentList.Item,
|
|
6701
|
+
{
|
|
6702
|
+
name: componentName,
|
|
6703
|
+
label: (_a2 = componentConf["label"]) != null ? _a2 : componentName,
|
|
6704
|
+
index: i
|
|
6705
|
+
},
|
|
6706
|
+
componentName
|
|
6707
|
+
);
|
|
6708
|
+
})
|
|
6709
|
+
},
|
|
6710
|
+
"other"
|
|
6711
|
+
)
|
|
6712
|
+
);
|
|
6713
|
+
}
|
|
6714
|
+
setComponentList(_componentList);
|
|
6715
|
+
}
|
|
6716
|
+
}, [config.categories, config.components, uiComponentList]);
|
|
6717
|
+
return componentList;
|
|
6718
|
+
};
|
|
6586
6719
|
|
|
6587
|
-
// components/Puck/components/
|
|
6588
|
-
|
|
6720
|
+
// components/Puck/components/Components/index.tsx
|
|
6721
|
+
import { useMemo as useMemo10 } from "react";
|
|
6589
6722
|
|
|
6590
|
-
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/
|
|
6723
|
+
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Components/styles.module.css#css-module
|
|
6591
6724
|
init_react_import();
|
|
6592
|
-
var
|
|
6725
|
+
var styles_module_default15 = { "Components": "_Components_3pbdy_1" };
|
|
6593
6726
|
|
|
6594
|
-
// components/Puck/components/
|
|
6595
|
-
import {
|
|
6596
|
-
|
|
6597
|
-
|
|
6598
|
-
var getClassName21 = get_class_name_factory_default("PuckFields", styles_module_default16);
|
|
6599
|
-
var DefaultFields = ({
|
|
6600
|
-
children
|
|
6601
|
-
}) => {
|
|
6602
|
-
return /* @__PURE__ */ jsx29(Fragment8, { children });
|
|
6603
|
-
};
|
|
6604
|
-
var createOnChange = (fieldName, appStore) => (value, updatedUi) => __async(void 0, null, function* () {
|
|
6605
|
-
let currentProps;
|
|
6606
|
-
const { dispatch, state, selectedItem, resolveComponentData: resolveComponentData2 } = appStore.getState();
|
|
6607
|
-
const { data, ui } = state;
|
|
6608
|
-
const { itemSelector } = ui;
|
|
6609
|
-
const rootProps = data.root.props || data.root;
|
|
6610
|
-
if (selectedItem) {
|
|
6611
|
-
currentProps = selectedItem.props;
|
|
6612
|
-
} else {
|
|
6613
|
-
currentProps = rootProps;
|
|
6614
|
-
}
|
|
6615
|
-
const newProps = __spreadProps(__spreadValues({}, currentProps), {
|
|
6616
|
-
[fieldName]: value
|
|
6617
|
-
});
|
|
6618
|
-
if (selectedItem && itemSelector) {
|
|
6619
|
-
dispatch({
|
|
6620
|
-
type: "replace",
|
|
6621
|
-
destinationIndex: itemSelector.index,
|
|
6622
|
-
destinationZone: itemSelector.zone || rootDroppableId,
|
|
6623
|
-
data: (yield resolveComponentData2(
|
|
6624
|
-
__spreadProps(__spreadValues({}, selectedItem), { props: newProps }),
|
|
6625
|
-
"replace"
|
|
6626
|
-
)).node,
|
|
6627
|
-
ui: updatedUi
|
|
6628
|
-
});
|
|
6629
|
-
} else {
|
|
6630
|
-
if (data.root.props) {
|
|
6631
|
-
dispatch({
|
|
6632
|
-
type: "replaceRoot",
|
|
6633
|
-
root: (yield resolveComponentData2(
|
|
6634
|
-
__spreadProps(__spreadValues({}, data.root), { props: newProps }),
|
|
6635
|
-
"replace"
|
|
6636
|
-
)).node,
|
|
6637
|
-
ui: __spreadValues(__spreadValues({}, ui), updatedUi),
|
|
6638
|
-
recordHistory: true
|
|
6639
|
-
});
|
|
6640
|
-
} else {
|
|
6641
|
-
dispatch({
|
|
6642
|
-
type: "setData",
|
|
6643
|
-
data: { root: newProps }
|
|
6644
|
-
});
|
|
6645
|
-
}
|
|
6646
|
-
}
|
|
6647
|
-
});
|
|
6648
|
-
var FieldsChild = ({ fieldName }) => {
|
|
6649
|
-
const field = useAppStore((s) => s.fields.fields[fieldName]);
|
|
6650
|
-
const isReadOnly = useAppStore(
|
|
6651
|
-
(s) => ((s.selectedItem ? s.selectedItem.readOnly : s.state.data.root.readOnly) || {})[fieldName]
|
|
6652
|
-
);
|
|
6653
|
-
const value = useAppStore((s) => {
|
|
6654
|
-
const rootProps = s.state.data.root.props || s.state.data.root;
|
|
6655
|
-
return s.selectedItem ? s.selectedItem.props[fieldName] : rootProps[fieldName];
|
|
6656
|
-
});
|
|
6657
|
-
const id = useAppStore((s) => {
|
|
6658
|
-
if (!field) return null;
|
|
6659
|
-
return s.selectedItem ? `${s.selectedItem.props.id}_${field.type}_${fieldName}` : `root_${field.type}_${fieldName}`;
|
|
6660
|
-
});
|
|
6661
|
-
const permissions = useAppStore(
|
|
6662
|
-
useShallow5((s) => {
|
|
6663
|
-
const { selectedItem, permissions: permissions2 } = s;
|
|
6664
|
-
return selectedItem ? permissions2.getPermissions({ item: selectedItem }) : permissions2.getPermissions({ root: true });
|
|
6665
|
-
})
|
|
6666
|
-
);
|
|
6667
|
-
const appStore = useAppStoreApi();
|
|
6668
|
-
const onChange = useCallback12(createOnChange(fieldName, appStore), [
|
|
6669
|
-
fieldName
|
|
6670
|
-
]);
|
|
6671
|
-
const { visible = true } = field != null ? field : {};
|
|
6672
|
-
if (!field || !id || !visible) return null;
|
|
6673
|
-
if (field.type === "slot") return null;
|
|
6674
|
-
return /* @__PURE__ */ jsx29("div", { className: getClassName21("field"), children: /* @__PURE__ */ jsx29(
|
|
6675
|
-
AutoFieldPrivate,
|
|
6676
|
-
{
|
|
6677
|
-
field,
|
|
6678
|
-
name: fieldName,
|
|
6679
|
-
id,
|
|
6680
|
-
readOnly: !permissions.edit || isReadOnly,
|
|
6681
|
-
value,
|
|
6682
|
-
onChange
|
|
6683
|
-
}
|
|
6684
|
-
) }, id);
|
|
6685
|
-
};
|
|
6686
|
-
var FieldsChildMemo = memo3(FieldsChild);
|
|
6687
|
-
var FieldsInternal = ({ wrapFields = true }) => {
|
|
6727
|
+
// components/Puck/components/Components/index.tsx
|
|
6728
|
+
import { jsx as jsx30 } from "react/jsx-runtime";
|
|
6729
|
+
var getClassName21 = get_class_name_factory_default("Components", styles_module_default15);
|
|
6730
|
+
var Components = () => {
|
|
6688
6731
|
const overrides = useAppStore((s) => s.overrides);
|
|
6689
|
-
const
|
|
6690
|
-
|
|
6691
|
-
|
|
6692
|
-
|
|
6693
|
-
|
|
6694
|
-
|
|
6695
|
-
const id = useAppStore((s) => {
|
|
6696
|
-
var _a;
|
|
6697
|
-
return (_a = s.selectedItem) == null ? void 0 : _a.props.id;
|
|
6698
|
-
});
|
|
6699
|
-
const appStore = useAppStoreApi();
|
|
6700
|
-
useRegisterFieldsSlice(appStore, id);
|
|
6701
|
-
const fieldsLoading = useAppStore((s) => s.fields.loading);
|
|
6702
|
-
const fieldNames = useAppStore(
|
|
6703
|
-
useShallow5((s) => {
|
|
6704
|
-
if (s.fields.id === id) {
|
|
6705
|
-
return Object.keys(s.fields.fields);
|
|
6706
|
-
}
|
|
6707
|
-
return [];
|
|
6708
|
-
})
|
|
6709
|
-
);
|
|
6710
|
-
const isLoading = fieldsLoading || componentResolving;
|
|
6711
|
-
const Wrapper = useMemo11(() => overrides.fields || DefaultFields, [overrides]);
|
|
6712
|
-
return /* @__PURE__ */ jsxs13(
|
|
6713
|
-
"form",
|
|
6714
|
-
{
|
|
6715
|
-
className: getClassName21({ wrapFields }),
|
|
6716
|
-
onSubmit: (e) => {
|
|
6717
|
-
e.preventDefault();
|
|
6718
|
-
},
|
|
6719
|
-
children: [
|
|
6720
|
-
/* @__PURE__ */ jsx29(Wrapper, { isLoading, itemSelector, children: fieldNames.map((fieldName) => /* @__PURE__ */ jsx29(FieldsChildMemo, { fieldName }, fieldName)) }),
|
|
6721
|
-
isLoading && /* @__PURE__ */ jsx29("div", { className: getClassName21("loadingOverlay"), children: /* @__PURE__ */ jsx29("div", { className: getClassName21("loadingOverlayInner"), children: /* @__PURE__ */ jsx29(Loader, { size: 16 }) }) })
|
|
6722
|
-
]
|
|
6732
|
+
const componentList = useComponentList();
|
|
6733
|
+
const Wrapper = useMemo10(() => {
|
|
6734
|
+
if (overrides.components) {
|
|
6735
|
+
console.warn(
|
|
6736
|
+
"The `components` override has been deprecated and renamed to `drawer`"
|
|
6737
|
+
);
|
|
6723
6738
|
}
|
|
6724
|
-
|
|
6739
|
+
return overrides.components || overrides.drawer || "div";
|
|
6740
|
+
}, [overrides]);
|
|
6741
|
+
return /* @__PURE__ */ jsx30("div", { className: getClassName21(), children: /* @__PURE__ */ jsx30(Wrapper, { children: componentList ? componentList : /* @__PURE__ */ jsx30(ComponentList, { id: "all" }) }) });
|
|
6725
6742
|
};
|
|
6726
|
-
var Fields = memo3(FieldsInternal);
|
|
6727
6743
|
|
|
6728
|
-
//
|
|
6744
|
+
// plugins/blocks/index.tsx
|
|
6745
|
+
import { jsx as jsx31 } from "react/jsx-runtime";
|
|
6746
|
+
var blocksPlugin = () => ({
|
|
6747
|
+
name: "blocks",
|
|
6748
|
+
label: "Blocks",
|
|
6749
|
+
render: Components,
|
|
6750
|
+
icon: /* @__PURE__ */ jsx31(Hammer, {})
|
|
6751
|
+
});
|
|
6752
|
+
|
|
6753
|
+
// plugins/outline/index.tsx
|
|
6729
6754
|
init_react_import();
|
|
6730
6755
|
|
|
6731
|
-
//
|
|
6756
|
+
// components/Puck/components/Outline/index.tsx
|
|
6732
6757
|
init_react_import();
|
|
6733
|
-
import { useEffect as useEffect21, useState as useState18 } from "react";
|
|
6734
6758
|
|
|
6735
|
-
// components/
|
|
6759
|
+
// components/LayerTree/index.tsx
|
|
6736
6760
|
init_react_import();
|
|
6737
6761
|
|
|
6738
|
-
// css-module:/home/runner/work/puck/puck/packages/core/components/
|
|
6762
|
+
// css-module:/home/runner/work/puck/puck/packages/core/components/LayerTree/styles.module.css#css-module
|
|
6739
6763
|
init_react_import();
|
|
6740
|
-
var
|
|
6764
|
+
var styles_module_default16 = { "LayerTree": "_LayerTree_7rx04_1", "LayerTree-zoneTitle": "_LayerTree-zoneTitle_7rx04_11", "LayerTree-helper": "_LayerTree-helper_7rx04_17", "Layer": "_Layer_7rx04_1", "Layer-inner": "_Layer-inner_7rx04_29", "Layer--containsZone": "_Layer--containsZone_7rx04_35", "Layer-clickable": "_Layer-clickable_7rx04_39", "Layer--isSelected": "_Layer--isSelected_7rx04_61", "Layer-chevron": "_Layer-chevron_7rx04_77", "Layer--childIsSelected": "_Layer--childIsSelected_7rx04_78", "Layer-zones": "_Layer-zones_7rx04_82", "Layer-title": "_Layer-title_7rx04_96", "Layer-name": "_Layer-name_7rx04_105", "Layer-icon": "_Layer-icon_7rx04_111", "Layer-zoneIcon": "_Layer-zoneIcon_7rx04_116" };
|
|
6741
6765
|
|
|
6742
|
-
//
|
|
6743
|
-
|
|
6744
|
-
|
|
6745
|
-
|
|
6746
|
-
|
|
6747
|
-
|
|
6748
|
-
|
|
6749
|
-
|
|
6750
|
-
|
|
6751
|
-
const overrides = useAppStore((s) => s.overrides);
|
|
6752
|
-
const canInsert = useAppStore(
|
|
6753
|
-
(s) => s.permissions.getPermissions({
|
|
6754
|
-
type: name
|
|
6755
|
-
}).insert
|
|
6756
|
-
);
|
|
6757
|
-
useEffect20(() => {
|
|
6758
|
-
if (overrides.componentItem) {
|
|
6759
|
-
console.warn(
|
|
6760
|
-
"The `componentItem` override has been deprecated and renamed to `drawerItem`"
|
|
6761
|
-
);
|
|
6762
|
-
}
|
|
6763
|
-
}, [overrides]);
|
|
6764
|
-
return /* @__PURE__ */ jsx30(Drawer.Item, { label, name, isDragDisabled: !canInsert, children: (_a = overrides.componentItem) != null ? _a : overrides.drawerItem });
|
|
6766
|
+
// lib/scroll-into-view.ts
|
|
6767
|
+
init_react_import();
|
|
6768
|
+
var scrollIntoView = (el) => {
|
|
6769
|
+
const oldStyle = __spreadValues({}, el.style);
|
|
6770
|
+
el.style.scrollMargin = "256px";
|
|
6771
|
+
if (el) {
|
|
6772
|
+
el == null ? void 0 : el.scrollIntoView({ behavior: "smooth" });
|
|
6773
|
+
el.style.scrollMargin = oldStyle.scrollMargin || "";
|
|
6774
|
+
}
|
|
6765
6775
|
};
|
|
6766
|
-
|
|
6767
|
-
|
|
6768
|
-
|
|
6769
|
-
|
|
6770
|
-
|
|
6771
|
-
|
|
6772
|
-
|
|
6773
|
-
|
|
6774
|
-
const
|
|
6775
|
-
|
|
6776
|
-
|
|
6777
|
-
|
|
6778
|
-
|
|
6779
|
-
|
|
6780
|
-
|
|
6781
|
-
|
|
6782
|
-
|
|
6783
|
-
|
|
6784
|
-
|
|
6785
|
-
|
|
6786
|
-
|
|
6787
|
-
}),
|
|
6788
|
-
title: expanded ? `Collapse${title ? ` ${title}` : ""}` : `Expand${title ? ` ${title}` : ""}`,
|
|
6789
|
-
children: [
|
|
6790
|
-
/* @__PURE__ */ jsx30("div", { children: title }),
|
|
6791
|
-
/* @__PURE__ */ jsx30("div", { className: getClassName22("titleIcon"), children: expanded ? /* @__PURE__ */ jsx30(ChevronUp, { size: 12 }) : /* @__PURE__ */ jsx30(ChevronDown, { size: 12 }) })
|
|
6792
|
-
]
|
|
6793
|
-
}
|
|
6794
|
-
),
|
|
6795
|
-
/* @__PURE__ */ jsx30("div", { className: getClassName22("content"), children: /* @__PURE__ */ jsx30(Drawer, { children: children || Object.keys(config.components).map((componentKey) => {
|
|
6796
|
-
var _a;
|
|
6797
|
-
return /* @__PURE__ */ jsx30(
|
|
6798
|
-
ComponentListItem,
|
|
6799
|
-
{
|
|
6800
|
-
label: (_a = config.components[componentKey]["label"]) != null ? _a : componentKey,
|
|
6801
|
-
name: componentKey
|
|
6802
|
-
},
|
|
6803
|
-
componentKey
|
|
6804
|
-
);
|
|
6805
|
-
}) }) })
|
|
6806
|
-
] });
|
|
6776
|
+
|
|
6777
|
+
// components/LayerTree/index.tsx
|
|
6778
|
+
import { useCallback as useCallback12, useContext as useContext10 } from "react";
|
|
6779
|
+
|
|
6780
|
+
// lib/on-scroll-end.ts
|
|
6781
|
+
init_react_import();
|
|
6782
|
+
var onScrollEnd = (frame, cb) => {
|
|
6783
|
+
let scrollTimeout;
|
|
6784
|
+
const callback = function() {
|
|
6785
|
+
clearTimeout(scrollTimeout);
|
|
6786
|
+
scrollTimeout = setTimeout(function() {
|
|
6787
|
+
cb();
|
|
6788
|
+
frame == null ? void 0 : frame.removeEventListener("scroll", callback);
|
|
6789
|
+
}, 50);
|
|
6790
|
+
};
|
|
6791
|
+
frame == null ? void 0 : frame.addEventListener("scroll", callback);
|
|
6792
|
+
setTimeout(() => {
|
|
6793
|
+
if (!scrollTimeout) {
|
|
6794
|
+
cb();
|
|
6795
|
+
}
|
|
6796
|
+
}, 50);
|
|
6807
6797
|
};
|
|
6808
|
-
ComponentList.Item = ComponentListItem;
|
|
6809
6798
|
|
|
6810
|
-
//
|
|
6811
|
-
import {
|
|
6812
|
-
|
|
6813
|
-
|
|
6799
|
+
// components/LayerTree/index.tsx
|
|
6800
|
+
import { useShallow as useShallow5 } from "zustand/react/shallow";
|
|
6801
|
+
import { Fragment as Fragment8, jsx as jsx32, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
6802
|
+
var getClassName22 = get_class_name_factory_default("LayerTree", styles_module_default16);
|
|
6803
|
+
var getClassNameLayer = get_class_name_factory_default("Layer", styles_module_default16);
|
|
6804
|
+
var Layer = ({
|
|
6805
|
+
index,
|
|
6806
|
+
itemId,
|
|
6807
|
+
zoneCompound
|
|
6808
|
+
}) => {
|
|
6809
|
+
var _a;
|
|
6814
6810
|
const config = useAppStore((s) => s.config);
|
|
6815
|
-
const
|
|
6816
|
-
|
|
6817
|
-
|
|
6818
|
-
|
|
6819
|
-
|
|
6820
|
-
|
|
6821
|
-
|
|
6822
|
-
|
|
6823
|
-
|
|
6824
|
-
|
|
6825
|
-
|
|
6826
|
-
|
|
6827
|
-
|
|
6828
|
-
|
|
6829
|
-
|
|
6830
|
-
|
|
6831
|
-
|
|
6832
|
-
|
|
6833
|
-
|
|
6834
|
-
|
|
6835
|
-
|
|
6836
|
-
|
|
6837
|
-
|
|
6838
|
-
|
|
6839
|
-
|
|
6840
|
-
|
|
6841
|
-
|
|
6842
|
-
|
|
6843
|
-
|
|
6844
|
-
|
|
6845
|
-
|
|
6846
|
-
|
|
6847
|
-
|
|
6848
|
-
|
|
6849
|
-
|
|
6811
|
+
const itemSelector = useAppStore((s) => s.state.ui.itemSelector);
|
|
6812
|
+
const dispatch = useAppStore((s) => s.dispatch);
|
|
6813
|
+
const setItemSelector = useCallback12(
|
|
6814
|
+
(itemSelector2) => {
|
|
6815
|
+
dispatch({ type: "setUi", ui: { itemSelector: itemSelector2 } });
|
|
6816
|
+
},
|
|
6817
|
+
[dispatch]
|
|
6818
|
+
);
|
|
6819
|
+
const selecedItemId = useAppStore((s) => {
|
|
6820
|
+
var _a2;
|
|
6821
|
+
return (_a2 = s.selectedItem) == null ? void 0 : _a2.props.id;
|
|
6822
|
+
});
|
|
6823
|
+
const isSelected = selecedItemId === itemId || itemSelector && itemSelector.zone === rootDroppableId && !zoneCompound;
|
|
6824
|
+
const nodeData = useAppStore((s) => s.state.indexes.nodes[itemId]);
|
|
6825
|
+
const zonesForItem = useAppStore(
|
|
6826
|
+
useShallow5(
|
|
6827
|
+
(s) => Object.keys(s.state.indexes.zones).filter(
|
|
6828
|
+
(z) => z.split(":")[0] === itemId
|
|
6829
|
+
)
|
|
6830
|
+
)
|
|
6831
|
+
);
|
|
6832
|
+
const containsZone = zonesForItem.length > 0;
|
|
6833
|
+
const zoneStore = useContext10(ZoneStoreContext);
|
|
6834
|
+
const isHovering = useContextStore(
|
|
6835
|
+
ZoneStoreContext,
|
|
6836
|
+
(s) => s.hoveringComponent === itemId
|
|
6837
|
+
);
|
|
6838
|
+
const childIsSelected = useAppStore((s) => {
|
|
6839
|
+
var _a2, _b;
|
|
6840
|
+
const selectedData = s.state.indexes.nodes[(_a2 = s.selectedItem) == null ? void 0 : _a2.props.id];
|
|
6841
|
+
return (_b = selectedData == null ? void 0 : selectedData.path.some((candidate) => {
|
|
6842
|
+
const [candidateId] = candidate.split(":");
|
|
6843
|
+
return candidateId === itemId;
|
|
6844
|
+
})) != null ? _b : false;
|
|
6845
|
+
});
|
|
6846
|
+
const componentConfig = config.components[nodeData.data.type];
|
|
6847
|
+
const label = (_a = componentConfig == null ? void 0 : componentConfig["label"]) != null ? _a : nodeData.data.type.toString();
|
|
6848
|
+
return /* @__PURE__ */ jsxs13(
|
|
6849
|
+
"li",
|
|
6850
|
+
{
|
|
6851
|
+
className: getClassNameLayer({
|
|
6852
|
+
isSelected,
|
|
6853
|
+
isHovering,
|
|
6854
|
+
containsZone,
|
|
6855
|
+
childIsSelected
|
|
6856
|
+
}),
|
|
6857
|
+
children: [
|
|
6858
|
+
/* @__PURE__ */ jsx32("div", { className: getClassNameLayer("inner"), children: /* @__PURE__ */ jsxs13(
|
|
6859
|
+
"button",
|
|
6860
|
+
{
|
|
6861
|
+
type: "button",
|
|
6862
|
+
className: getClassNameLayer("clickable"),
|
|
6863
|
+
onClick: () => {
|
|
6864
|
+
if (isSelected) {
|
|
6865
|
+
setItemSelector(null);
|
|
6866
|
+
return;
|
|
6867
|
+
}
|
|
6868
|
+
const frame = getFrame();
|
|
6869
|
+
const el = frame == null ? void 0 : frame.querySelector(
|
|
6870
|
+
`[data-puck-component="${itemId}"]`
|
|
6871
|
+
);
|
|
6872
|
+
if (!el) {
|
|
6873
|
+
setItemSelector({
|
|
6874
|
+
index,
|
|
6875
|
+
zone: zoneCompound
|
|
6876
|
+
});
|
|
6877
|
+
return;
|
|
6878
|
+
}
|
|
6879
|
+
scrollIntoView(el);
|
|
6880
|
+
onScrollEnd(frame, () => {
|
|
6881
|
+
setItemSelector({
|
|
6882
|
+
index,
|
|
6883
|
+
zone: zoneCompound
|
|
6884
|
+
});
|
|
6885
|
+
});
|
|
6850
6886
|
},
|
|
6851
|
-
|
|
6852
|
-
|
|
6853
|
-
|
|
6854
|
-
);
|
|
6855
|
-
const remainingComponents = Object.keys(config.components).filter(
|
|
6856
|
-
(component) => matchedComponents.indexOf(component) === -1
|
|
6857
|
-
);
|
|
6858
|
-
if (remainingComponents.length > 0 && !((_a = uiComponentList.other) == null ? void 0 : _a.components) && ((_b = uiComponentList.other) == null ? void 0 : _b.visible) !== false) {
|
|
6859
|
-
_componentList.push(
|
|
6860
|
-
/* @__PURE__ */ jsx31(
|
|
6861
|
-
ComponentList,
|
|
6862
|
-
{
|
|
6863
|
-
id: "other",
|
|
6864
|
-
title: ((_c = uiComponentList.other) == null ? void 0 : _c.title) || "Other",
|
|
6865
|
-
children: remainingComponents.map((componentName, i) => {
|
|
6866
|
-
var _a2;
|
|
6867
|
-
const componentConf = config.components[componentName] || {};
|
|
6868
|
-
return /* @__PURE__ */ jsx31(
|
|
6869
|
-
ComponentList.Item,
|
|
6870
|
-
{
|
|
6871
|
-
name: componentName,
|
|
6872
|
-
label: (_a2 = componentConf["label"]) != null ? _a2 : componentName,
|
|
6873
|
-
index: i
|
|
6874
|
-
},
|
|
6875
|
-
componentName
|
|
6876
|
-
);
|
|
6877
|
-
})
|
|
6887
|
+
onMouseEnter: (e) => {
|
|
6888
|
+
e.stopPropagation();
|
|
6889
|
+
zoneStore.setState({ hoveringComponent: itemId });
|
|
6878
6890
|
},
|
|
6879
|
-
|
|
6880
|
-
|
|
6881
|
-
|
|
6882
|
-
|
|
6883
|
-
|
|
6891
|
+
onMouseLeave: (e) => {
|
|
6892
|
+
e.stopPropagation();
|
|
6893
|
+
zoneStore.setState({ hoveringComponent: null });
|
|
6894
|
+
},
|
|
6895
|
+
children: [
|
|
6896
|
+
containsZone && /* @__PURE__ */ jsx32(
|
|
6897
|
+
"div",
|
|
6898
|
+
{
|
|
6899
|
+
className: getClassNameLayer("chevron"),
|
|
6900
|
+
title: isSelected ? "Collapse" : "Expand",
|
|
6901
|
+
children: /* @__PURE__ */ jsx32(ChevronDown, { size: "12" })
|
|
6902
|
+
}
|
|
6903
|
+
),
|
|
6904
|
+
/* @__PURE__ */ jsxs13("div", { className: getClassNameLayer("title"), children: [
|
|
6905
|
+
/* @__PURE__ */ jsx32("div", { className: getClassNameLayer("icon"), children: nodeData.data.type === "Text" || nodeData.data.type === "Heading" ? /* @__PURE__ */ jsx32(Type, { size: "16" }) : /* @__PURE__ */ jsx32(LayoutGrid, { size: "16" }) }),
|
|
6906
|
+
/* @__PURE__ */ jsx32("div", { className: getClassNameLayer("name"), children: label })
|
|
6907
|
+
] })
|
|
6908
|
+
]
|
|
6909
|
+
}
|
|
6910
|
+
) }),
|
|
6911
|
+
containsZone && zonesForItem.map((subzone) => /* @__PURE__ */ jsx32("div", { className: getClassNameLayer("zones"), children: /* @__PURE__ */ jsx32(LayerTree, { zoneCompound: subzone }) }, subzone))
|
|
6912
|
+
]
|
|
6884
6913
|
}
|
|
6885
|
-
|
|
6886
|
-
|
|
6914
|
+
);
|
|
6915
|
+
};
|
|
6916
|
+
var LayerTree = ({
|
|
6917
|
+
label: _label,
|
|
6918
|
+
zoneCompound
|
|
6919
|
+
}) => {
|
|
6920
|
+
const label = useAppStore((s) => {
|
|
6921
|
+
var _a, _b, _c, _d;
|
|
6922
|
+
if (_label) return _label;
|
|
6923
|
+
if (zoneCompound === rootDroppableId) return;
|
|
6924
|
+
const [componentId, slotId] = zoneCompound.split(":");
|
|
6925
|
+
const componentType = (_a = s.state.indexes.nodes[componentId]) == null ? void 0 : _a.data.type;
|
|
6926
|
+
const configForComponent = componentType && componentType !== rootAreaId ? s.config.components[componentType] : s.config.root;
|
|
6927
|
+
return (_d = (_c = (_b = configForComponent == null ? void 0 : configForComponent.fields) == null ? void 0 : _b[slotId]) == null ? void 0 : _c.label) != null ? _d : slotId;
|
|
6928
|
+
});
|
|
6929
|
+
const contentIds = useAppStore(
|
|
6930
|
+
useShallow5(
|
|
6931
|
+
(s) => {
|
|
6932
|
+
var _a, _b;
|
|
6933
|
+
return zoneCompound ? (_b = (_a = s.state.indexes.zones[zoneCompound]) == null ? void 0 : _a.contentIds) != null ? _b : [] : [];
|
|
6934
|
+
}
|
|
6935
|
+
)
|
|
6936
|
+
);
|
|
6937
|
+
return /* @__PURE__ */ jsxs13(Fragment8, { children: [
|
|
6938
|
+
label && /* @__PURE__ */ jsxs13("div", { className: getClassName22("zoneTitle"), children: [
|
|
6939
|
+
/* @__PURE__ */ jsx32("div", { className: getClassName22("zoneIcon"), children: /* @__PURE__ */ jsx32(Layers, { size: "16" }) }),
|
|
6940
|
+
label
|
|
6941
|
+
] }),
|
|
6942
|
+
/* @__PURE__ */ jsxs13("ul", { className: getClassName22(), children: [
|
|
6943
|
+
contentIds.length === 0 && /* @__PURE__ */ jsx32("div", { className: getClassName22("helper"), children: "No items" }),
|
|
6944
|
+
contentIds.map((itemId, i) => {
|
|
6945
|
+
return /* @__PURE__ */ jsx32(
|
|
6946
|
+
Layer,
|
|
6947
|
+
{
|
|
6948
|
+
index: i,
|
|
6949
|
+
itemId,
|
|
6950
|
+
zoneCompound
|
|
6951
|
+
},
|
|
6952
|
+
itemId
|
|
6953
|
+
);
|
|
6954
|
+
})
|
|
6955
|
+
] })
|
|
6956
|
+
] });
|
|
6887
6957
|
};
|
|
6888
6958
|
|
|
6889
|
-
// components/Puck/components/
|
|
6890
|
-
import { useMemo as
|
|
6891
|
-
|
|
6892
|
-
|
|
6893
|
-
|
|
6894
|
-
|
|
6895
|
-
|
|
6896
|
-
|
|
6897
|
-
|
|
6898
|
-
"The `components` override has been deprecated and renamed to `drawer`"
|
|
6899
|
-
);
|
|
6900
|
-
}
|
|
6901
|
-
return overrides.components || overrides.drawer || "div";
|
|
6902
|
-
}, [overrides]);
|
|
6903
|
-
return /* @__PURE__ */ jsx32(Wrapper, { children: componentList ? componentList : /* @__PURE__ */ jsx32(ComponentList, { id: "all" }) });
|
|
6959
|
+
// components/Puck/components/Outline/index.tsx
|
|
6960
|
+
import { useMemo as useMemo11 } from "react";
|
|
6961
|
+
|
|
6962
|
+
// lib/data/find-zones-for-area.ts
|
|
6963
|
+
init_react_import();
|
|
6964
|
+
var findZonesForArea = (state, area) => {
|
|
6965
|
+
return Object.keys(state.indexes.zones).filter(
|
|
6966
|
+
(zone) => zone.split(":")[0] === area
|
|
6967
|
+
);
|
|
6904
6968
|
};
|
|
6905
6969
|
|
|
6906
|
-
// components/Puck/components/
|
|
6970
|
+
// components/Puck/components/Outline/index.tsx
|
|
6971
|
+
import { useShallow as useShallow6 } from "zustand/react/shallow";
|
|
6972
|
+
|
|
6973
|
+
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Outline/styles.module.css#css-module
|
|
6907
6974
|
init_react_import();
|
|
6908
|
-
|
|
6975
|
+
var styles_module_default17 = { "Outline": "_Outline_cvjlj_1" };
|
|
6909
6976
|
|
|
6910
|
-
// components/
|
|
6977
|
+
// components/Puck/components/Outline/index.tsx
|
|
6978
|
+
import { jsx as jsx33 } from "react/jsx-runtime";
|
|
6979
|
+
var getClassName23 = get_class_name_factory_default("Outline", styles_module_default17);
|
|
6980
|
+
var Outline = () => {
|
|
6981
|
+
const outlineOverride = useAppStore((s) => s.overrides.outline);
|
|
6982
|
+
const rootZones = useAppStore(
|
|
6983
|
+
useShallow6((s) => findZonesForArea(s.state, "root"))
|
|
6984
|
+
);
|
|
6985
|
+
const Wrapper = useMemo11(() => outlineOverride || "div", [outlineOverride]);
|
|
6986
|
+
return /* @__PURE__ */ jsx33("div", { className: getClassName23(), children: /* @__PURE__ */ jsx33(Wrapper, { children: rootZones.map((zoneCompound) => /* @__PURE__ */ jsx33(
|
|
6987
|
+
LayerTree,
|
|
6988
|
+
{
|
|
6989
|
+
label: rootZones.length === 1 ? "" : zoneCompound.split(":")[1],
|
|
6990
|
+
zoneCompound
|
|
6991
|
+
},
|
|
6992
|
+
zoneCompound
|
|
6993
|
+
)) }) });
|
|
6994
|
+
};
|
|
6995
|
+
|
|
6996
|
+
// plugins/outline/index.tsx
|
|
6997
|
+
import { jsx as jsx34 } from "react/jsx-runtime";
|
|
6998
|
+
var outlinePlugin = () => ({
|
|
6999
|
+
name: "outline",
|
|
7000
|
+
label: "Outline",
|
|
7001
|
+
render: Outline,
|
|
7002
|
+
icon: /* @__PURE__ */ jsx34(Layers, {})
|
|
7003
|
+
});
|
|
7004
|
+
|
|
7005
|
+
// plugins/fields/index.tsx
|
|
6911
7006
|
init_react_import();
|
|
6912
|
-
|
|
6913
|
-
|
|
6914
|
-
|
|
6915
|
-
|
|
6916
|
-
|
|
6917
|
-
|
|
6918
|
-
|
|
6919
|
-
|
|
6920
|
-
|
|
6921
|
-
|
|
6922
|
-
|
|
6923
|
-
|
|
6924
|
-
|
|
6925
|
-
|
|
6926
|
-
|
|
6927
|
-
if (hasContent) {
|
|
6928
|
-
collected.push(style);
|
|
6929
|
-
}
|
|
6930
|
-
} else {
|
|
6931
|
-
collected.push(style);
|
|
6932
|
-
}
|
|
7007
|
+
|
|
7008
|
+
// components/Breadcrumbs/index.tsx
|
|
7009
|
+
init_react_import();
|
|
7010
|
+
|
|
7011
|
+
// css-module:/home/runner/work/puck/puck/packages/core/components/Breadcrumbs/styles.module.css#css-module
|
|
7012
|
+
init_react_import();
|
|
7013
|
+
var styles_module_default18 = { "Breadcrumbs": "_Breadcrumbs_1c9yh_1", "Breadcrumbs-breadcrumbLabel": "_Breadcrumbs-breadcrumbLabel_1c9yh_7", "Breadcrumbs-breadcrumb": "_Breadcrumbs-breadcrumb_1c9yh_7" };
|
|
7014
|
+
|
|
7015
|
+
// lib/use-breadcrumbs.ts
|
|
7016
|
+
init_react_import();
|
|
7017
|
+
import { useMemo as useMemo12 } from "react";
|
|
7018
|
+
var useBreadcrumbs = (renderCount) => {
|
|
7019
|
+
const selectedId = useAppStore((s) => {
|
|
7020
|
+
var _a;
|
|
7021
|
+
return (_a = s.selectedItem) == null ? void 0 : _a.props.id;
|
|
6933
7022
|
});
|
|
6934
|
-
|
|
6935
|
-
|
|
6936
|
-
var
|
|
6937
|
-
|
|
6938
|
-
const ownerNode = ss.ownerNode;
|
|
6939
|
-
return ownerNode.href === el.href;
|
|
7023
|
+
const config = useAppStore((s) => s.config);
|
|
7024
|
+
const path = useAppStore((s) => {
|
|
7025
|
+
var _a;
|
|
7026
|
+
return (_a = s.state.indexes.nodes[selectedId]) == null ? void 0 : _a.path;
|
|
6940
7027
|
});
|
|
6941
|
-
|
|
6942
|
-
|
|
6943
|
-
|
|
6944
|
-
|
|
6945
|
-
|
|
6946
|
-
|
|
6947
|
-
|
|
6948
|
-
|
|
6949
|
-
|
|
6950
|
-
|
|
7028
|
+
const appStore = useAppStoreApi();
|
|
7029
|
+
return useMemo12(() => {
|
|
7030
|
+
const breadcrumbs = (path == null ? void 0 : path.map((zoneCompound) => {
|
|
7031
|
+
var _a, _b, _c;
|
|
7032
|
+
const [componentId] = zoneCompound.split(":");
|
|
7033
|
+
if (componentId === "root") {
|
|
7034
|
+
return {
|
|
7035
|
+
label: "Page",
|
|
7036
|
+
selector: null
|
|
7037
|
+
};
|
|
7038
|
+
}
|
|
7039
|
+
const node = appStore.getState().state.indexes.nodes[componentId];
|
|
7040
|
+
const parentId = node.path[node.path.length - 1];
|
|
7041
|
+
const contentIds = ((_a = appStore.getState().state.indexes.zones[parentId]) == null ? void 0 : _a.contentIds) || [];
|
|
7042
|
+
const index = contentIds.indexOf(componentId);
|
|
7043
|
+
const label = node ? (_c = (_b = config.components[node.data.type]) == null ? void 0 : _b.label) != null ? _c : node.data.type : "Component";
|
|
7044
|
+
return {
|
|
7045
|
+
label,
|
|
7046
|
+
selector: node ? {
|
|
7047
|
+
index,
|
|
7048
|
+
zone: node.path[node.path.length - 1]
|
|
7049
|
+
} : null
|
|
7050
|
+
};
|
|
7051
|
+
})) || [];
|
|
7052
|
+
if (renderCount) {
|
|
7053
|
+
return breadcrumbs.slice(breadcrumbs.length - renderCount);
|
|
7054
|
+
}
|
|
7055
|
+
return breadcrumbs;
|
|
7056
|
+
}, [path, renderCount]);
|
|
7057
|
+
};
|
|
7058
|
+
|
|
7059
|
+
// components/Breadcrumbs/index.tsx
|
|
7060
|
+
import { jsx as jsx35, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
7061
|
+
var getClassName24 = get_class_name_factory_default("Breadcrumbs", styles_module_default18);
|
|
7062
|
+
var Breadcrumbs = ({
|
|
7063
|
+
children,
|
|
7064
|
+
numParents = 1
|
|
7065
|
+
}) => {
|
|
7066
|
+
const setUi = useAppStore((s) => s.setUi);
|
|
7067
|
+
const breadcrumbs = useBreadcrumbs(numParents);
|
|
7068
|
+
return /* @__PURE__ */ jsxs14("div", { className: getClassName24(), children: [
|
|
7069
|
+
breadcrumbs.map((breadcrumb, i) => /* @__PURE__ */ jsxs14("div", { className: getClassName24("breadcrumb"), children: [
|
|
7070
|
+
/* @__PURE__ */ jsx35(
|
|
7071
|
+
"button",
|
|
7072
|
+
{
|
|
7073
|
+
type: "button",
|
|
7074
|
+
className: getClassName24("breadcrumbLabel"),
|
|
7075
|
+
onClick: () => setUi({ itemSelector: breadcrumb.selector }),
|
|
7076
|
+
children: breadcrumb.label
|
|
7077
|
+
}
|
|
7078
|
+
),
|
|
7079
|
+
/* @__PURE__ */ jsx35(ChevronRight, { size: 16 })
|
|
7080
|
+
] }, i)),
|
|
7081
|
+
children
|
|
7082
|
+
] });
|
|
7083
|
+
};
|
|
7084
|
+
|
|
7085
|
+
// components/Puck/components/Fields/index.tsx
|
|
7086
|
+
init_react_import();
|
|
7087
|
+
|
|
7088
|
+
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Fields/styles.module.css#css-module
|
|
7089
|
+
init_react_import();
|
|
7090
|
+
var styles_module_default19 = { "PuckFields": "_PuckFields_10bh7_1", "PuckFields--isLoading": "_PuckFields--isLoading_10bh7_6", "PuckFields-loadingOverlay": "_PuckFields-loadingOverlay_10bh7_10", "PuckFields-loadingOverlayInner": "_PuckFields-loadingOverlayInner_10bh7_25", "PuckFields-field": "_PuckFields-field_10bh7_32", "PuckFields--wrapFields": "_PuckFields--wrapFields_10bh7_36" };
|
|
7091
|
+
|
|
7092
|
+
// components/Puck/components/Fields/index.tsx
|
|
7093
|
+
import { memo as memo3, useCallback as useCallback13, useMemo as useMemo13 } from "react";
|
|
7094
|
+
import { useShallow as useShallow7 } from "zustand/react/shallow";
|
|
7095
|
+
import { Fragment as Fragment9, jsx as jsx36, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
7096
|
+
var getClassName25 = get_class_name_factory_default("PuckFields", styles_module_default19);
|
|
7097
|
+
var DefaultFields = ({
|
|
7098
|
+
children
|
|
7099
|
+
}) => {
|
|
7100
|
+
return /* @__PURE__ */ jsx36(Fragment9, { children });
|
|
7101
|
+
};
|
|
7102
|
+
var createOnChange = (fieldName, appStore) => (value, updatedUi) => __async(void 0, null, function* () {
|
|
7103
|
+
let currentProps;
|
|
7104
|
+
const { dispatch, state, selectedItem, resolveComponentData: resolveComponentData2 } = appStore.getState();
|
|
7105
|
+
const { data, ui } = state;
|
|
7106
|
+
const { itemSelector } = ui;
|
|
7107
|
+
const rootProps = data.root.props || data.root;
|
|
7108
|
+
if (selectedItem) {
|
|
7109
|
+
currentProps = selectedItem.props;
|
|
7110
|
+
} else {
|
|
7111
|
+
currentProps = rootProps;
|
|
7112
|
+
}
|
|
7113
|
+
const newProps = __spreadProps(__spreadValues({}, currentProps), {
|
|
7114
|
+
[fieldName]: value
|
|
7115
|
+
});
|
|
7116
|
+
if (selectedItem && itemSelector) {
|
|
7117
|
+
dispatch({
|
|
7118
|
+
type: "replace",
|
|
7119
|
+
destinationIndex: itemSelector.index,
|
|
7120
|
+
destinationZone: itemSelector.zone || rootDroppableId,
|
|
7121
|
+
data: (yield resolveComponentData2(
|
|
7122
|
+
__spreadProps(__spreadValues({}, selectedItem), { props: newProps }),
|
|
7123
|
+
"replace"
|
|
7124
|
+
)).node,
|
|
7125
|
+
ui: updatedUi
|
|
7126
|
+
});
|
|
7127
|
+
} else {
|
|
7128
|
+
if (data.root.props) {
|
|
7129
|
+
dispatch({
|
|
7130
|
+
type: "replaceRoot",
|
|
7131
|
+
root: (yield resolveComponentData2(
|
|
7132
|
+
__spreadProps(__spreadValues({}, data.root), { props: newProps }),
|
|
7133
|
+
"replace"
|
|
7134
|
+
)).node,
|
|
7135
|
+
ui: __spreadValues(__spreadValues({}, ui), updatedUi),
|
|
7136
|
+
recordHistory: true
|
|
7137
|
+
});
|
|
7138
|
+
} else {
|
|
7139
|
+
dispatch({
|
|
7140
|
+
type: "setData",
|
|
7141
|
+
data: { root: newProps }
|
|
7142
|
+
});
|
|
7143
|
+
}
|
|
7144
|
+
}
|
|
7145
|
+
});
|
|
7146
|
+
var FieldsChild = ({ fieldName }) => {
|
|
7147
|
+
const field = useAppStore((s) => s.fields.fields[fieldName]);
|
|
7148
|
+
const isReadOnly = useAppStore(
|
|
7149
|
+
(s) => ((s.selectedItem ? s.selectedItem.readOnly : s.state.data.root.readOnly) || {})[fieldName]
|
|
7150
|
+
);
|
|
7151
|
+
const value = useAppStore((s) => {
|
|
7152
|
+
const rootProps = s.state.data.root.props || s.state.data.root;
|
|
7153
|
+
return s.selectedItem ? s.selectedItem.props[fieldName] : rootProps[fieldName];
|
|
7154
|
+
});
|
|
7155
|
+
const id = useAppStore((s) => {
|
|
7156
|
+
if (!field) return null;
|
|
7157
|
+
return s.selectedItem ? `${s.selectedItem.props.id}_${field.type}_${fieldName}` : `root_${field.type}_${fieldName}`;
|
|
7158
|
+
});
|
|
7159
|
+
const permissions = useAppStore(
|
|
7160
|
+
useShallow7((s) => {
|
|
7161
|
+
const { selectedItem, permissions: permissions2 } = s;
|
|
7162
|
+
return selectedItem ? permissions2.getPermissions({ item: selectedItem }) : permissions2.getPermissions({ root: true });
|
|
7163
|
+
})
|
|
7164
|
+
);
|
|
7165
|
+
const appStore = useAppStoreApi();
|
|
7166
|
+
const onChange = useCallback13(createOnChange(fieldName, appStore), [
|
|
7167
|
+
fieldName
|
|
7168
|
+
]);
|
|
7169
|
+
const { visible = true } = field != null ? field : {};
|
|
7170
|
+
if (!field || !id || !visible) return null;
|
|
7171
|
+
if (field.type === "slot") return null;
|
|
7172
|
+
return /* @__PURE__ */ jsx36("div", { className: getClassName25("field"), children: /* @__PURE__ */ jsx36(
|
|
7173
|
+
AutoFieldPrivate,
|
|
7174
|
+
{
|
|
7175
|
+
field,
|
|
7176
|
+
name: fieldName,
|
|
7177
|
+
id,
|
|
7178
|
+
readOnly: !permissions.edit || isReadOnly,
|
|
7179
|
+
value,
|
|
7180
|
+
onChange
|
|
7181
|
+
}
|
|
7182
|
+
) }, id);
|
|
7183
|
+
};
|
|
7184
|
+
var FieldsChildMemo = memo3(FieldsChild);
|
|
7185
|
+
var FieldsInternal = ({ wrapFields = true }) => {
|
|
7186
|
+
const overrides = useAppStore((s) => s.overrides);
|
|
7187
|
+
const componentResolving = useAppStore((s) => {
|
|
7188
|
+
var _a, _b;
|
|
7189
|
+
const loadingCount = s.selectedItem ? (_a = s.componentState[s.selectedItem.props.id]) == null ? void 0 : _a.loadingCount : (_b = s.componentState["root"]) == null ? void 0 : _b.loadingCount;
|
|
7190
|
+
return (loadingCount != null ? loadingCount : 0) > 0;
|
|
7191
|
+
});
|
|
7192
|
+
const itemSelector = useAppStore(useShallow7((s) => s.state.ui.itemSelector));
|
|
7193
|
+
const id = useAppStore((s) => {
|
|
7194
|
+
var _a;
|
|
7195
|
+
return (_a = s.selectedItem) == null ? void 0 : _a.props.id;
|
|
7196
|
+
});
|
|
7197
|
+
const appStore = useAppStoreApi();
|
|
7198
|
+
useRegisterFieldsSlice(appStore, id);
|
|
7199
|
+
const fieldsLoading = useAppStore((s) => s.fields.loading);
|
|
7200
|
+
const fieldNames = useAppStore(
|
|
7201
|
+
useShallow7((s) => {
|
|
7202
|
+
if (s.fields.id === id) {
|
|
7203
|
+
return Object.keys(s.fields.fields);
|
|
7204
|
+
}
|
|
7205
|
+
return [];
|
|
7206
|
+
})
|
|
7207
|
+
);
|
|
7208
|
+
const isLoading = fieldsLoading || componentResolving;
|
|
7209
|
+
const Wrapper = useMemo13(() => overrides.fields || DefaultFields, [overrides]);
|
|
7210
|
+
return /* @__PURE__ */ jsxs15(
|
|
7211
|
+
"form",
|
|
7212
|
+
{
|
|
7213
|
+
className: getClassName25({ wrapFields }),
|
|
7214
|
+
onSubmit: (e) => {
|
|
7215
|
+
e.preventDefault();
|
|
7216
|
+
},
|
|
7217
|
+
children: [
|
|
7218
|
+
/* @__PURE__ */ jsx36(Wrapper, { isLoading, itemSelector, children: fieldNames.map((fieldName) => /* @__PURE__ */ jsx36(FieldsChildMemo, { fieldName }, fieldName)) }),
|
|
7219
|
+
isLoading && /* @__PURE__ */ jsx36("div", { className: getClassName25("loadingOverlay"), children: /* @__PURE__ */ jsx36("div", { className: getClassName25("loadingOverlayInner"), children: /* @__PURE__ */ jsx36(Loader, { size: 16 }) }) })
|
|
7220
|
+
]
|
|
7221
|
+
}
|
|
7222
|
+
);
|
|
7223
|
+
};
|
|
7224
|
+
var Fields = memo3(FieldsInternal);
|
|
7225
|
+
|
|
7226
|
+
// css-module:/home/runner/work/puck/puck/packages/core/plugins/fields/styles.module.css#css-module
|
|
7227
|
+
init_react_import();
|
|
7228
|
+
var styles_module_default20 = { "FieldsPlugin": "_FieldsPlugin_nd930_1", "FieldsPlugin-header": "_FieldsPlugin-header_nd930_7" };
|
|
7229
|
+
|
|
7230
|
+
// plugins/fields/index.tsx
|
|
7231
|
+
import { jsx as jsx37, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
7232
|
+
var getClassName26 = get_class_name_factory_default("FieldsPlugin", styles_module_default20);
|
|
7233
|
+
var CurrentTitle = () => {
|
|
7234
|
+
const label = useAppStore((s) => {
|
|
7235
|
+
var _a, _b;
|
|
7236
|
+
const selectedItem = s.selectedItem;
|
|
7237
|
+
return selectedItem ? (_b = (_a = s.config.components[selectedItem.type]) == null ? void 0 : _a.label) != null ? _b : selectedItem.type : "Page";
|
|
7238
|
+
});
|
|
7239
|
+
return label;
|
|
7240
|
+
};
|
|
7241
|
+
var fieldsPlugin = ({ mobileOnly = true } = {}) => ({
|
|
7242
|
+
name: "fields",
|
|
7243
|
+
label: "Fields",
|
|
7244
|
+
render: () => /* @__PURE__ */ jsxs16("div", { className: getClassName26(), children: [
|
|
7245
|
+
/* @__PURE__ */ jsx37("div", { className: getClassName26("header"), children: /* @__PURE__ */ jsx37(Breadcrumbs, { numParents: 2, children: /* @__PURE__ */ jsx37(CurrentTitle, {}) }) }),
|
|
7246
|
+
/* @__PURE__ */ jsx37(Fields, {})
|
|
7247
|
+
] }),
|
|
7248
|
+
icon: /* @__PURE__ */ jsx37(RectangleEllipsis, {}),
|
|
7249
|
+
mobileOnly
|
|
7250
|
+
});
|
|
7251
|
+
|
|
7252
|
+
// components/Puck/index.tsx
|
|
7253
|
+
init_react_import();
|
|
7254
|
+
import {
|
|
7255
|
+
createContext as createContext8,
|
|
7256
|
+
useCallback as useCallback21,
|
|
7257
|
+
useContext as useContext13,
|
|
7258
|
+
useEffect as useEffect30,
|
|
7259
|
+
useMemo as useMemo21,
|
|
7260
|
+
useRef as useRef12,
|
|
7261
|
+
useState as useState26
|
|
7262
|
+
} from "react";
|
|
7263
|
+
|
|
7264
|
+
// components/Puck/components/Preview/index.tsx
|
|
7265
|
+
init_react_import();
|
|
7266
|
+
import { useCallback as useCallback14, useEffect as useEffect23, useRef as useRef7, useMemo as useMemo14 } from "react";
|
|
7267
|
+
|
|
7268
|
+
// components/AutoFrame/index.tsx
|
|
7269
|
+
init_react_import();
|
|
7270
|
+
import {
|
|
7271
|
+
createContext as createContext6,
|
|
7272
|
+
useContext as useContext11,
|
|
7273
|
+
useEffect as useEffect22,
|
|
7274
|
+
useState as useState19
|
|
7275
|
+
} from "react";
|
|
7276
|
+
import hash from "object-hash";
|
|
7277
|
+
import { createPortal as createPortal3 } from "react-dom";
|
|
7278
|
+
import { Fragment as Fragment10, jsx as jsx38 } from "react/jsx-runtime";
|
|
7279
|
+
var styleSelector = 'style, link[rel="stylesheet"]';
|
|
7280
|
+
var collectStyles = (doc) => {
|
|
7281
|
+
const collected = [];
|
|
7282
|
+
doc.querySelectorAll(styleSelector).forEach((style) => {
|
|
7283
|
+
if (style.tagName === "STYLE") {
|
|
7284
|
+
const hasContent = !!style.innerHTML.trim();
|
|
7285
|
+
if (hasContent) {
|
|
7286
|
+
collected.push(style);
|
|
7287
|
+
}
|
|
7288
|
+
} else {
|
|
7289
|
+
collected.push(style);
|
|
7290
|
+
}
|
|
7291
|
+
});
|
|
7292
|
+
return collected;
|
|
7293
|
+
};
|
|
7294
|
+
var getStyleSheet = (el) => {
|
|
7295
|
+
return Array.from(document.styleSheets).find((ss) => {
|
|
7296
|
+
const ownerNode = ss.ownerNode;
|
|
7297
|
+
return ownerNode.href === el.href;
|
|
7298
|
+
});
|
|
7299
|
+
};
|
|
7300
|
+
var getStyles = (styleSheet) => {
|
|
7301
|
+
if (styleSheet) {
|
|
7302
|
+
try {
|
|
7303
|
+
return [...Array.from(styleSheet.cssRules)].map((rule) => rule.cssText).join("");
|
|
7304
|
+
} catch (e) {
|
|
7305
|
+
console.warn(
|
|
7306
|
+
"Access to stylesheet %s is denied. Ignoring\u2026",
|
|
7307
|
+
styleSheet.href
|
|
7308
|
+
);
|
|
6951
7309
|
}
|
|
6952
7310
|
}
|
|
6953
7311
|
return "";
|
|
@@ -7124,10 +7482,10 @@ var CopyHostStyles = ({
|
|
|
7124
7482
|
observer.disconnect();
|
|
7125
7483
|
};
|
|
7126
7484
|
}, []);
|
|
7127
|
-
return /* @__PURE__ */
|
|
7485
|
+
return /* @__PURE__ */ jsx38(Fragment10, { children });
|
|
7128
7486
|
};
|
|
7129
7487
|
var autoFrameContext = createContext6({});
|
|
7130
|
-
var useFrame = () =>
|
|
7488
|
+
var useFrame = () => useContext11(autoFrameContext);
|
|
7131
7489
|
function AutoFrame(_a) {
|
|
7132
7490
|
var _b = _a, {
|
|
7133
7491
|
children,
|
|
@@ -7171,7 +7529,7 @@ function AutoFrame(_a) {
|
|
|
7171
7529
|
}
|
|
7172
7530
|
}
|
|
7173
7531
|
}, [frameRef, loaded, stylesLoaded]);
|
|
7174
|
-
return /* @__PURE__ */
|
|
7532
|
+
return /* @__PURE__ */ jsx38(
|
|
7175
7533
|
"iframe",
|
|
7176
7534
|
__spreadProps(__spreadValues({}, props), {
|
|
7177
7535
|
className,
|
|
@@ -7181,7 +7539,7 @@ function AutoFrame(_a) {
|
|
|
7181
7539
|
onLoad: () => {
|
|
7182
7540
|
setLoaded(true);
|
|
7183
7541
|
},
|
|
7184
|
-
children: /* @__PURE__ */
|
|
7542
|
+
children: /* @__PURE__ */ jsx38(autoFrameContext.Provider, { value: ctx, children: loaded && mountTarget && /* @__PURE__ */ jsx38(
|
|
7185
7543
|
CopyHostStyles,
|
|
7186
7544
|
{
|
|
7187
7545
|
debug,
|
|
@@ -7191,1166 +7549,1023 @@ function AutoFrame(_a) {
|
|
|
7191
7549
|
) })
|
|
7192
7550
|
})
|
|
7193
7551
|
);
|
|
7194
|
-
}
|
|
7195
|
-
AutoFrame.displayName = "AutoFrame";
|
|
7196
|
-
var AutoFrame_default = AutoFrame;
|
|
7197
|
-
|
|
7198
|
-
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Preview/styles.module.css#css-module
|
|
7199
|
-
init_react_import();
|
|
7200
|
-
var
|
|
7201
|
-
|
|
7202
|
-
// components/Puck/components/Preview/index.tsx
|
|
7203
|
-
import { Fragment as
|
|
7204
|
-
var
|
|
7205
|
-
var useBubbleIframeEvents = (ref) => {
|
|
7206
|
-
const status = useAppStore((s) => s.status);
|
|
7207
|
-
useEffect23(() => {
|
|
7208
|
-
if (ref.current && status === "READY") {
|
|
7209
|
-
const iframe = ref.current;
|
|
7210
|
-
const handlePointerMove = (event) => {
|
|
7211
|
-
const evt = new BubbledPointerEvent("pointermove", __spreadProps(__spreadValues({}, event), {
|
|
7212
|
-
bubbles: true,
|
|
7213
|
-
cancelable: false,
|
|
7214
|
-
clientX: event.clientX,
|
|
7215
|
-
clientY: event.clientY,
|
|
7216
|
-
originalTarget: event.target
|
|
7217
|
-
}));
|
|
7218
|
-
iframe.dispatchEvent(evt);
|
|
7219
|
-
};
|
|
7220
|
-
const register = () => {
|
|
7221
|
-
var _a;
|
|
7222
|
-
unregister();
|
|
7223
|
-
(_a = iframe.contentDocument) == null ? void 0 : _a.addEventListener(
|
|
7224
|
-
"pointermove",
|
|
7225
|
-
handlePointerMove,
|
|
7226
|
-
{
|
|
7227
|
-
capture: true
|
|
7228
|
-
}
|
|
7229
|
-
);
|
|
7230
|
-
};
|
|
7231
|
-
const unregister = () => {
|
|
7232
|
-
var _a;
|
|
7233
|
-
(_a = iframe.contentDocument) == null ? void 0 : _a.removeEventListener(
|
|
7234
|
-
"pointermove",
|
|
7235
|
-
handlePointerMove
|
|
7236
|
-
);
|
|
7237
|
-
};
|
|
7238
|
-
register();
|
|
7239
|
-
return () => {
|
|
7240
|
-
unregister();
|
|
7241
|
-
};
|
|
7242
|
-
}
|
|
7243
|
-
}, [status]);
|
|
7244
|
-
};
|
|
7245
|
-
var Preview2 = ({ id = "puck-preview" }) => {
|
|
7246
|
-
const dispatch = useAppStore((s) => s.dispatch);
|
|
7247
|
-
const root = useAppStore((s) => s.state.data.root);
|
|
7248
|
-
const config = useAppStore((s) => s.config);
|
|
7249
|
-
const setStatus = useAppStore((s) => s.setStatus);
|
|
7250
|
-
const iframe = useAppStore((s) => s.iframe);
|
|
7251
|
-
const overrides = useAppStore((s) => s.overrides);
|
|
7252
|
-
const metadata = useAppStore((s) => s.metadata);
|
|
7253
|
-
const renderData = useAppStore(
|
|
7254
|
-
(s) => s.state.ui.previewMode === "edit" ? null : s.state.data
|
|
7255
|
-
);
|
|
7256
|
-
const Page = useCallback13(
|
|
7257
|
-
(pageProps) => {
|
|
7258
|
-
var _a, _b;
|
|
7259
|
-
const propsWithSlots = useSlots(
|
|
7260
|
-
config,
|
|
7261
|
-
{ type: "root", props: pageProps },
|
|
7262
|
-
DropZoneEditPure
|
|
7263
|
-
);
|
|
7264
|
-
return ((_a = config.root) == null ? void 0 : _a.render) ? (_b = config.root) == null ? void 0 : _b.render(__spreadValues({
|
|
7265
|
-
id: "puck-root"
|
|
7266
|
-
}, propsWithSlots)) : /* @__PURE__ */ jsx34(Fragment10, { children: propsWithSlots.children });
|
|
7267
|
-
},
|
|
7268
|
-
[config]
|
|
7269
|
-
);
|
|
7270
|
-
const Frame = useMemo13(() => overrides.iframe, [overrides]);
|
|
7271
|
-
const rootProps = root.props || root;
|
|
7272
|
-
const ref = useRef7(null);
|
|
7273
|
-
useBubbleIframeEvents(ref);
|
|
7274
|
-
const inner = !renderData ? /* @__PURE__ */ jsx34(
|
|
7275
|
-
Page,
|
|
7276
|
-
__spreadProps(__spreadValues({}, rootProps), {
|
|
7277
|
-
puck: {
|
|
7278
|
-
renderDropZone: DropZonePure,
|
|
7279
|
-
isEditing: true,
|
|
7280
|
-
dragRef: null,
|
|
7281
|
-
metadata
|
|
7282
|
-
},
|
|
7283
|
-
editMode: true,
|
|
7284
|
-
children: /* @__PURE__ */ jsx34(DropZonePure, { zone: rootDroppableId })
|
|
7285
|
-
})
|
|
7286
|
-
) : /* @__PURE__ */ jsx34(Render, { data: renderData, config, metadata });
|
|
7287
|
-
useEffect23(() => {
|
|
7288
|
-
if (!iframe.enabled) {
|
|
7289
|
-
setStatus("READY");
|
|
7290
|
-
}
|
|
7291
|
-
}, [iframe.enabled]);
|
|
7292
|
-
return /* @__PURE__ */ jsx34(
|
|
7293
|
-
"div",
|
|
7294
|
-
{
|
|
7295
|
-
className: getClassName23(),
|
|
7296
|
-
id,
|
|
7297
|
-
"data-puck-preview": true,
|
|
7298
|
-
onClick: (e) => {
|
|
7299
|
-
const el = e.target;
|
|
7300
|
-
if (!el.hasAttribute("data-puck-component") && !el.hasAttribute("data-puck-dropzone")) {
|
|
7301
|
-
dispatch({ type: "setUi", ui: { itemSelector: null } });
|
|
7302
|
-
}
|
|
7303
|
-
},
|
|
7304
|
-
children: iframe.enabled ? /* @__PURE__ */ jsx34(
|
|
7305
|
-
AutoFrame_default,
|
|
7306
|
-
{
|
|
7307
|
-
id: "preview-frame",
|
|
7308
|
-
className: getClassName23("frame"),
|
|
7309
|
-
"data-rfd-iframe": true,
|
|
7310
|
-
onReady: () => {
|
|
7311
|
-
setStatus("READY");
|
|
7312
|
-
},
|
|
7313
|
-
onNotReady: () => {
|
|
7314
|
-
setStatus("MOUNTED");
|
|
7315
|
-
},
|
|
7316
|
-
frameRef: ref,
|
|
7317
|
-
children: /* @__PURE__ */ jsx34(autoFrameContext.Consumer, { children: ({ document: document2 }) => {
|
|
7318
|
-
if (Frame) {
|
|
7319
|
-
return /* @__PURE__ */ jsx34(Frame, { document: document2, children: inner });
|
|
7320
|
-
}
|
|
7321
|
-
return inner;
|
|
7322
|
-
} })
|
|
7323
|
-
}
|
|
7324
|
-
) : /* @__PURE__ */ jsx34(
|
|
7325
|
-
"div",
|
|
7326
|
-
{
|
|
7327
|
-
id: "preview-frame",
|
|
7328
|
-
className: getClassName23("frame"),
|
|
7329
|
-
ref,
|
|
7330
|
-
"data-puck-entry": true,
|
|
7331
|
-
children: inner
|
|
7332
|
-
}
|
|
7333
|
-
)
|
|
7334
|
-
}
|
|
7335
|
-
);
|
|
7336
|
-
};
|
|
7337
|
-
|
|
7338
|
-
// components/Puck/components/Outline/index.tsx
|
|
7339
|
-
init_react_import();
|
|
7340
|
-
|
|
7341
|
-
// components/LayerTree/index.tsx
|
|
7342
|
-
init_react_import();
|
|
7343
|
-
|
|
7344
|
-
// css-module:/home/runner/work/puck/puck/packages/core/components/LayerTree/styles.module.css#css-module
|
|
7345
|
-
init_react_import();
|
|
7346
|
-
var styles_module_default19 = { "LayerTree": "_LayerTree_7rx04_1", "LayerTree-zoneTitle": "_LayerTree-zoneTitle_7rx04_11", "LayerTree-helper": "_LayerTree-helper_7rx04_17", "Layer": "_Layer_7rx04_1", "Layer-inner": "_Layer-inner_7rx04_29", "Layer--containsZone": "_Layer--containsZone_7rx04_35", "Layer-clickable": "_Layer-clickable_7rx04_39", "Layer--isSelected": "_Layer--isSelected_7rx04_61", "Layer-chevron": "_Layer-chevron_7rx04_77", "Layer--childIsSelected": "_Layer--childIsSelected_7rx04_78", "Layer-zones": "_Layer-zones_7rx04_82", "Layer-title": "_Layer-title_7rx04_96", "Layer-name": "_Layer-name_7rx04_105", "Layer-icon": "_Layer-icon_7rx04_111", "Layer-zoneIcon": "_Layer-zoneIcon_7rx04_116" };
|
|
7347
|
-
|
|
7348
|
-
// lib/scroll-into-view.ts
|
|
7349
|
-
init_react_import();
|
|
7350
|
-
var scrollIntoView = (el) => {
|
|
7351
|
-
const oldStyle = __spreadValues({}, el.style);
|
|
7352
|
-
el.style.scrollMargin = "256px";
|
|
7353
|
-
if (el) {
|
|
7354
|
-
el == null ? void 0 : el.scrollIntoView({ behavior: "smooth" });
|
|
7355
|
-
el.style.scrollMargin = oldStyle.scrollMargin || "";
|
|
7356
|
-
}
|
|
7357
|
-
};
|
|
7358
|
-
|
|
7359
|
-
// components/LayerTree/index.tsx
|
|
7360
|
-
import { useCallback as useCallback14, useContext as useContext11 } from "react";
|
|
7361
|
-
|
|
7362
|
-
// lib/on-scroll-end.ts
|
|
7363
|
-
init_react_import();
|
|
7364
|
-
var onScrollEnd = (frame, cb) => {
|
|
7365
|
-
let scrollTimeout;
|
|
7366
|
-
const callback = function() {
|
|
7367
|
-
clearTimeout(scrollTimeout);
|
|
7368
|
-
scrollTimeout = setTimeout(function() {
|
|
7369
|
-
cb();
|
|
7370
|
-
frame == null ? void 0 : frame.removeEventListener("scroll", callback);
|
|
7371
|
-
}, 50);
|
|
7372
|
-
};
|
|
7373
|
-
frame == null ? void 0 : frame.addEventListener("scroll", callback);
|
|
7374
|
-
setTimeout(() => {
|
|
7375
|
-
if (!scrollTimeout) {
|
|
7376
|
-
cb();
|
|
7377
|
-
}
|
|
7378
|
-
}, 50);
|
|
7379
|
-
};
|
|
7380
|
-
|
|
7381
|
-
// components/LayerTree/index.tsx
|
|
7382
|
-
import { useShallow as useShallow6 } from "zustand/react/shallow";
|
|
7383
|
-
import { Fragment as Fragment11, jsx as jsx35, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
7384
|
-
var getClassName24 = get_class_name_factory_default("LayerTree", styles_module_default19);
|
|
7385
|
-
var getClassNameLayer = get_class_name_factory_default("Layer", styles_module_default19);
|
|
7386
|
-
var Layer = ({
|
|
7387
|
-
index,
|
|
7388
|
-
itemId,
|
|
7389
|
-
zoneCompound
|
|
7390
|
-
}) => {
|
|
7391
|
-
var _a;
|
|
7392
|
-
const config = useAppStore((s) => s.config);
|
|
7393
|
-
const itemSelector = useAppStore((s) => s.state.ui.itemSelector);
|
|
7394
|
-
const dispatch = useAppStore((s) => s.dispatch);
|
|
7395
|
-
const setItemSelector = useCallback14(
|
|
7396
|
-
(itemSelector2) => {
|
|
7397
|
-
dispatch({ type: "setUi", ui: { itemSelector: itemSelector2 } });
|
|
7398
|
-
},
|
|
7399
|
-
[dispatch]
|
|
7400
|
-
);
|
|
7401
|
-
const selecedItemId = useAppStore((s) => {
|
|
7402
|
-
var _a2;
|
|
7403
|
-
return (_a2 = s.selectedItem) == null ? void 0 : _a2.props.id;
|
|
7404
|
-
});
|
|
7405
|
-
const isSelected = selecedItemId === itemId || itemSelector && itemSelector.zone === rootDroppableId && !zoneCompound;
|
|
7406
|
-
const nodeData = useAppStore((s) => s.state.indexes.nodes[itemId]);
|
|
7407
|
-
const zonesForItem = useAppStore(
|
|
7408
|
-
useShallow6(
|
|
7409
|
-
(s) => Object.keys(s.state.indexes.zones).filter(
|
|
7410
|
-
(z) => z.split(":")[0] === itemId
|
|
7411
|
-
)
|
|
7412
|
-
)
|
|
7413
|
-
);
|
|
7414
|
-
const containsZone = zonesForItem.length > 0;
|
|
7415
|
-
const zoneStore = useContext11(ZoneStoreContext);
|
|
7416
|
-
const isHovering = useContextStore(
|
|
7417
|
-
ZoneStoreContext,
|
|
7418
|
-
(s) => s.hoveringComponent === itemId
|
|
7419
|
-
);
|
|
7420
|
-
const childIsSelected = useAppStore((s) => {
|
|
7421
|
-
var _a2, _b;
|
|
7422
|
-
const selectedData = s.state.indexes.nodes[(_a2 = s.selectedItem) == null ? void 0 : _a2.props.id];
|
|
7423
|
-
return (_b = selectedData == null ? void 0 : selectedData.path.some((candidate) => {
|
|
7424
|
-
const [candidateId] = candidate.split(":");
|
|
7425
|
-
return candidateId === itemId;
|
|
7426
|
-
})) != null ? _b : false;
|
|
7427
|
-
});
|
|
7428
|
-
const componentConfig = config.components[nodeData.data.type];
|
|
7429
|
-
const label = (_a = componentConfig == null ? void 0 : componentConfig["label"]) != null ? _a : nodeData.data.type.toString();
|
|
7430
|
-
return /* @__PURE__ */ jsxs15(
|
|
7431
|
-
"li",
|
|
7432
|
-
{
|
|
7433
|
-
className: getClassNameLayer({
|
|
7434
|
-
isSelected,
|
|
7435
|
-
isHovering,
|
|
7436
|
-
containsZone,
|
|
7437
|
-
childIsSelected
|
|
7438
|
-
}),
|
|
7439
|
-
children: [
|
|
7440
|
-
/* @__PURE__ */ jsx35("div", { className: getClassNameLayer("inner"), children: /* @__PURE__ */ jsxs15(
|
|
7441
|
-
"button",
|
|
7442
|
-
{
|
|
7443
|
-
type: "button",
|
|
7444
|
-
className: getClassNameLayer("clickable"),
|
|
7445
|
-
onClick: () => {
|
|
7446
|
-
if (isSelected) {
|
|
7447
|
-
setItemSelector(null);
|
|
7448
|
-
return;
|
|
7449
|
-
}
|
|
7450
|
-
const frame = getFrame();
|
|
7451
|
-
const el = frame == null ? void 0 : frame.querySelector(
|
|
7452
|
-
`[data-puck-component="${itemId}"]`
|
|
7453
|
-
);
|
|
7454
|
-
if (!el) {
|
|
7455
|
-
setItemSelector({
|
|
7456
|
-
index,
|
|
7457
|
-
zone: zoneCompound
|
|
7458
|
-
});
|
|
7459
|
-
return;
|
|
7460
|
-
}
|
|
7461
|
-
scrollIntoView(el);
|
|
7462
|
-
onScrollEnd(frame, () => {
|
|
7463
|
-
setItemSelector({
|
|
7464
|
-
index,
|
|
7465
|
-
zone: zoneCompound
|
|
7466
|
-
});
|
|
7467
|
-
});
|
|
7468
|
-
},
|
|
7469
|
-
onMouseEnter: (e) => {
|
|
7470
|
-
e.stopPropagation();
|
|
7471
|
-
zoneStore.setState({ hoveringComponent: itemId });
|
|
7472
|
-
},
|
|
7473
|
-
onMouseLeave: (e) => {
|
|
7474
|
-
e.stopPropagation();
|
|
7475
|
-
zoneStore.setState({ hoveringComponent: null });
|
|
7476
|
-
},
|
|
7477
|
-
children: [
|
|
7478
|
-
containsZone && /* @__PURE__ */ jsx35(
|
|
7479
|
-
"div",
|
|
7480
|
-
{
|
|
7481
|
-
className: getClassNameLayer("chevron"),
|
|
7482
|
-
title: isSelected ? "Collapse" : "Expand",
|
|
7483
|
-
children: /* @__PURE__ */ jsx35(ChevronDown, { size: "12" })
|
|
7484
|
-
}
|
|
7485
|
-
),
|
|
7486
|
-
/* @__PURE__ */ jsxs15("div", { className: getClassNameLayer("title"), children: [
|
|
7487
|
-
/* @__PURE__ */ jsx35("div", { className: getClassNameLayer("icon"), children: nodeData.data.type === "Text" || nodeData.data.type === "Heading" ? /* @__PURE__ */ jsx35(Type, { size: "16" }) : /* @__PURE__ */ jsx35(LayoutGrid, { size: "16" }) }),
|
|
7488
|
-
/* @__PURE__ */ jsx35("div", { className: getClassNameLayer("name"), children: label })
|
|
7489
|
-
] })
|
|
7490
|
-
]
|
|
7491
|
-
}
|
|
7492
|
-
) }),
|
|
7493
|
-
containsZone && zonesForItem.map((subzone) => /* @__PURE__ */ jsx35("div", { className: getClassNameLayer("zones"), children: /* @__PURE__ */ jsx35(LayerTree, { zoneCompound: subzone }) }, subzone))
|
|
7494
|
-
]
|
|
7495
|
-
}
|
|
7496
|
-
);
|
|
7497
|
-
};
|
|
7498
|
-
var LayerTree = ({
|
|
7499
|
-
label: _label,
|
|
7500
|
-
zoneCompound
|
|
7501
|
-
}) => {
|
|
7502
|
-
const label = useAppStore((s) => {
|
|
7503
|
-
var _a, _b, _c, _d;
|
|
7504
|
-
if (_label) return _label;
|
|
7505
|
-
if (zoneCompound === rootDroppableId) return;
|
|
7506
|
-
const [componentId, slotId] = zoneCompound.split(":");
|
|
7507
|
-
const componentType = (_a = s.state.indexes.nodes[componentId]) == null ? void 0 : _a.data.type;
|
|
7508
|
-
const configForComponent = componentType && componentType !== rootAreaId ? s.config.components[componentType] : s.config.root;
|
|
7509
|
-
return (_d = (_c = (_b = configForComponent == null ? void 0 : configForComponent.fields) == null ? void 0 : _b[slotId]) == null ? void 0 : _c.label) != null ? _d : slotId;
|
|
7510
|
-
});
|
|
7511
|
-
const contentIds = useAppStore(
|
|
7512
|
-
useShallow6(
|
|
7513
|
-
(s) => {
|
|
7514
|
-
var _a, _b;
|
|
7515
|
-
return zoneCompound ? (_b = (_a = s.state.indexes.zones[zoneCompound]) == null ? void 0 : _a.contentIds) != null ? _b : [] : [];
|
|
7516
|
-
}
|
|
7517
|
-
)
|
|
7518
|
-
);
|
|
7519
|
-
return /* @__PURE__ */ jsxs15(Fragment11, { children: [
|
|
7520
|
-
label && /* @__PURE__ */ jsxs15("div", { className: getClassName24("zoneTitle"), children: [
|
|
7521
|
-
/* @__PURE__ */ jsx35("div", { className: getClassName24("zoneIcon"), children: /* @__PURE__ */ jsx35(Layers, { size: "16" }) }),
|
|
7522
|
-
label
|
|
7523
|
-
] }),
|
|
7524
|
-
/* @__PURE__ */ jsxs15("ul", { className: getClassName24(), children: [
|
|
7525
|
-
contentIds.length === 0 && /* @__PURE__ */ jsx35("div", { className: getClassName24("helper"), children: "No items" }),
|
|
7526
|
-
contentIds.map((itemId, i) => {
|
|
7527
|
-
return /* @__PURE__ */ jsx35(
|
|
7528
|
-
Layer,
|
|
7552
|
+
}
|
|
7553
|
+
AutoFrame.displayName = "AutoFrame";
|
|
7554
|
+
var AutoFrame_default = AutoFrame;
|
|
7555
|
+
|
|
7556
|
+
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Preview/styles.module.css#css-module
|
|
7557
|
+
init_react_import();
|
|
7558
|
+
var styles_module_default21 = { "PuckPreview": "_PuckPreview_z2rgu_1", "PuckPreview-frame": "_PuckPreview-frame_z2rgu_6" };
|
|
7559
|
+
|
|
7560
|
+
// components/Puck/components/Preview/index.tsx
|
|
7561
|
+
import { Fragment as Fragment11, jsx as jsx39 } from "react/jsx-runtime";
|
|
7562
|
+
var getClassName27 = get_class_name_factory_default("PuckPreview", styles_module_default21);
|
|
7563
|
+
var useBubbleIframeEvents = (ref) => {
|
|
7564
|
+
const status = useAppStore((s) => s.status);
|
|
7565
|
+
useEffect23(() => {
|
|
7566
|
+
if (ref.current && status === "READY") {
|
|
7567
|
+
const iframe = ref.current;
|
|
7568
|
+
const handlePointerMove = (event) => {
|
|
7569
|
+
const evt = new BubbledPointerEvent("pointermove", __spreadProps(__spreadValues({}, event), {
|
|
7570
|
+
bubbles: true,
|
|
7571
|
+
cancelable: false,
|
|
7572
|
+
clientX: event.clientX,
|
|
7573
|
+
clientY: event.clientY,
|
|
7574
|
+
originalTarget: event.target
|
|
7575
|
+
}));
|
|
7576
|
+
iframe.dispatchEvent(evt);
|
|
7577
|
+
};
|
|
7578
|
+
const register = () => {
|
|
7579
|
+
var _a;
|
|
7580
|
+
unregister();
|
|
7581
|
+
(_a = iframe.contentDocument) == null ? void 0 : _a.addEventListener(
|
|
7582
|
+
"pointermove",
|
|
7583
|
+
handlePointerMove,
|
|
7529
7584
|
{
|
|
7530
|
-
|
|
7531
|
-
|
|
7532
|
-
zoneCompound
|
|
7533
|
-
},
|
|
7534
|
-
itemId
|
|
7585
|
+
capture: true
|
|
7586
|
+
}
|
|
7535
7587
|
);
|
|
7536
|
-
}
|
|
7537
|
-
|
|
7538
|
-
|
|
7588
|
+
};
|
|
7589
|
+
const unregister = () => {
|
|
7590
|
+
var _a;
|
|
7591
|
+
(_a = iframe.contentDocument) == null ? void 0 : _a.removeEventListener(
|
|
7592
|
+
"pointermove",
|
|
7593
|
+
handlePointerMove
|
|
7594
|
+
);
|
|
7595
|
+
};
|
|
7596
|
+
register();
|
|
7597
|
+
return () => {
|
|
7598
|
+
unregister();
|
|
7599
|
+
};
|
|
7600
|
+
}
|
|
7601
|
+
}, [status]);
|
|
7539
7602
|
};
|
|
7540
|
-
|
|
7541
|
-
|
|
7542
|
-
|
|
7543
|
-
|
|
7544
|
-
|
|
7545
|
-
|
|
7546
|
-
|
|
7547
|
-
|
|
7548
|
-
|
|
7603
|
+
var Preview2 = ({ id = "puck-preview" }) => {
|
|
7604
|
+
const dispatch = useAppStore((s) => s.dispatch);
|
|
7605
|
+
const root = useAppStore((s) => s.state.data.root);
|
|
7606
|
+
const config = useAppStore((s) => s.config);
|
|
7607
|
+
const setStatus = useAppStore((s) => s.setStatus);
|
|
7608
|
+
const iframe = useAppStore((s) => s.iframe);
|
|
7609
|
+
const overrides = useAppStore((s) => s.overrides);
|
|
7610
|
+
const metadata = useAppStore((s) => s.metadata);
|
|
7611
|
+
const renderData = useAppStore(
|
|
7612
|
+
(s) => s.state.ui.previewMode === "edit" ? null : s.state.data
|
|
7549
7613
|
);
|
|
7550
|
-
|
|
7551
|
-
|
|
7552
|
-
|
|
7553
|
-
|
|
7554
|
-
|
|
7555
|
-
|
|
7556
|
-
|
|
7557
|
-
|
|
7558
|
-
|
|
7614
|
+
const Page = useCallback14(
|
|
7615
|
+
(pageProps) => {
|
|
7616
|
+
var _a, _b;
|
|
7617
|
+
const propsWithSlots = useSlots(
|
|
7618
|
+
config,
|
|
7619
|
+
{ type: "root", props: pageProps },
|
|
7620
|
+
DropZoneEditPure
|
|
7621
|
+
);
|
|
7622
|
+
return ((_a = config.root) == null ? void 0 : _a.render) ? (_b = config.root) == null ? void 0 : _b.render(__spreadValues({
|
|
7623
|
+
id: "puck-root"
|
|
7624
|
+
}, propsWithSlots)) : /* @__PURE__ */ jsx39(Fragment11, { children: propsWithSlots.children });
|
|
7625
|
+
},
|
|
7626
|
+
[config]
|
|
7559
7627
|
);
|
|
7560
|
-
const
|
|
7561
|
-
|
|
7562
|
-
|
|
7628
|
+
const Frame = useMemo14(() => overrides.iframe, [overrides]);
|
|
7629
|
+
const rootProps = root.props || root;
|
|
7630
|
+
const ref = useRef7(null);
|
|
7631
|
+
useBubbleIframeEvents(ref);
|
|
7632
|
+
const inner = !renderData ? /* @__PURE__ */ jsx39(
|
|
7633
|
+
Page,
|
|
7634
|
+
__spreadProps(__spreadValues({}, rootProps), {
|
|
7635
|
+
puck: {
|
|
7636
|
+
renderDropZone: DropZonePure,
|
|
7637
|
+
isEditing: true,
|
|
7638
|
+
dragRef: null,
|
|
7639
|
+
metadata
|
|
7640
|
+
},
|
|
7641
|
+
editMode: true,
|
|
7642
|
+
children: /* @__PURE__ */ jsx39(DropZonePure, { zone: rootDroppableId })
|
|
7643
|
+
})
|
|
7644
|
+
) : /* @__PURE__ */ jsx39(Render, { data: renderData, config, metadata });
|
|
7645
|
+
useEffect23(() => {
|
|
7646
|
+
if (!iframe.enabled) {
|
|
7647
|
+
setStatus("READY");
|
|
7648
|
+
}
|
|
7649
|
+
}, [iframe.enabled]);
|
|
7650
|
+
return /* @__PURE__ */ jsx39(
|
|
7651
|
+
"div",
|
|
7563
7652
|
{
|
|
7564
|
-
|
|
7565
|
-
|
|
7566
|
-
|
|
7567
|
-
|
|
7568
|
-
|
|
7653
|
+
className: getClassName27(),
|
|
7654
|
+
id,
|
|
7655
|
+
"data-puck-preview": true,
|
|
7656
|
+
onClick: (e) => {
|
|
7657
|
+
const el = e.target;
|
|
7658
|
+
if (!el.hasAttribute("data-puck-component") && !el.hasAttribute("data-puck-dropzone")) {
|
|
7659
|
+
dispatch({ type: "setUi", ui: { itemSelector: null } });
|
|
7660
|
+
}
|
|
7661
|
+
},
|
|
7662
|
+
children: iframe.enabled ? /* @__PURE__ */ jsx39(
|
|
7663
|
+
AutoFrame_default,
|
|
7664
|
+
{
|
|
7665
|
+
id: "preview-frame",
|
|
7666
|
+
className: getClassName27("frame"),
|
|
7667
|
+
"data-rfd-iframe": true,
|
|
7668
|
+
onReady: () => {
|
|
7669
|
+
setStatus("READY");
|
|
7670
|
+
},
|
|
7671
|
+
onNotReady: () => {
|
|
7672
|
+
setStatus("MOUNTED");
|
|
7673
|
+
},
|
|
7674
|
+
frameRef: ref,
|
|
7675
|
+
children: /* @__PURE__ */ jsx39(autoFrameContext.Consumer, { children: ({ document: document2 }) => {
|
|
7676
|
+
if (Frame) {
|
|
7677
|
+
return /* @__PURE__ */ jsx39(Frame, { document: document2, children: inner });
|
|
7678
|
+
}
|
|
7679
|
+
return inner;
|
|
7680
|
+
} })
|
|
7681
|
+
}
|
|
7682
|
+
) : /* @__PURE__ */ jsx39(
|
|
7683
|
+
"div",
|
|
7684
|
+
{
|
|
7685
|
+
id: "preview-frame",
|
|
7686
|
+
className: getClassName27("frame"),
|
|
7687
|
+
ref,
|
|
7688
|
+
"data-puck-entry": true,
|
|
7689
|
+
children: inner
|
|
7690
|
+
}
|
|
7691
|
+
)
|
|
7692
|
+
}
|
|
7693
|
+
);
|
|
7569
7694
|
};
|
|
7570
7695
|
|
|
7571
|
-
//
|
|
7572
|
-
init_react_import();
|
|
7573
|
-
import {
|
|
7574
|
-
useCallback as useCallback15,
|
|
7575
|
-
useEffect as useEffect25,
|
|
7576
|
-
useMemo as useMemo17,
|
|
7577
|
-
useRef as useRef9,
|
|
7578
|
-
useState as useState21
|
|
7579
|
-
} from "react";
|
|
7580
|
-
|
|
7581
|
-
// components/ViewportControls/index.tsx
|
|
7696
|
+
// lib/use-loaded-overrides.ts
|
|
7582
7697
|
init_react_import();
|
|
7583
|
-
import {
|
|
7698
|
+
import { useMemo as useMemo15 } from "react";
|
|
7584
7699
|
|
|
7585
|
-
//
|
|
7700
|
+
// lib/load-overrides.ts
|
|
7586
7701
|
init_react_import();
|
|
7587
|
-
var
|
|
7588
|
-
|
|
7589
|
-
|
|
7590
|
-
import { jsx as jsx37, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
7591
|
-
var icons = {
|
|
7592
|
-
Smartphone: /* @__PURE__ */ jsx37(Smartphone, { size: 16 }),
|
|
7593
|
-
Tablet: /* @__PURE__ */ jsx37(Tablet, { size: 16 }),
|
|
7594
|
-
Monitor: /* @__PURE__ */ jsx37(Monitor, { size: 16 })
|
|
7595
|
-
};
|
|
7596
|
-
var getClassName25 = get_class_name_factory_default("ViewportControls", styles_module_default20);
|
|
7597
|
-
var getClassNameButton = get_class_name_factory_default("ViewportButton", styles_module_default20);
|
|
7598
|
-
var ViewportButton = ({
|
|
7599
|
-
children,
|
|
7600
|
-
height = "auto",
|
|
7601
|
-
title,
|
|
7602
|
-
width,
|
|
7603
|
-
onClick
|
|
7604
|
-
}) => {
|
|
7605
|
-
const viewports = useAppStore((s) => s.state.ui.viewports);
|
|
7606
|
-
const [isActive, setIsActive] = useState20(false);
|
|
7607
|
-
useEffect24(() => {
|
|
7608
|
-
setIsActive(width === viewports.current.width);
|
|
7609
|
-
}, [width, viewports.current.width]);
|
|
7610
|
-
return /* @__PURE__ */ jsx37("span", { className: getClassNameButton({ isActive }), children: /* @__PURE__ */ jsx37(
|
|
7611
|
-
IconButton,
|
|
7612
|
-
{
|
|
7613
|
-
type: "button",
|
|
7614
|
-
title,
|
|
7615
|
-
disabled: isActive,
|
|
7616
|
-
onClick: (e) => {
|
|
7617
|
-
e.stopPropagation();
|
|
7618
|
-
onClick({ width, height });
|
|
7619
|
-
},
|
|
7620
|
-
children: /* @__PURE__ */ jsx37("span", { className: getClassNameButton("inner"), children })
|
|
7621
|
-
}
|
|
7622
|
-
) });
|
|
7623
|
-
};
|
|
7624
|
-
var defaultZoomOptions = [
|
|
7625
|
-
{ label: "25%", value: 0.25 },
|
|
7626
|
-
{ label: "50%", value: 0.5 },
|
|
7627
|
-
{ label: "75%", value: 0.75 },
|
|
7628
|
-
{ label: "100%", value: 1 },
|
|
7629
|
-
{ label: "125%", value: 1.25 },
|
|
7630
|
-
{ label: "150%", value: 1.5 },
|
|
7631
|
-
{ label: "200%", value: 2 }
|
|
7632
|
-
];
|
|
7633
|
-
var ViewportControls = ({
|
|
7634
|
-
autoZoom,
|
|
7635
|
-
zoom,
|
|
7636
|
-
onViewportChange,
|
|
7637
|
-
onZoom
|
|
7702
|
+
var loadOverrides = ({
|
|
7703
|
+
overrides,
|
|
7704
|
+
plugins
|
|
7638
7705
|
}) => {
|
|
7639
|
-
|
|
7640
|
-
|
|
7641
|
-
|
|
7642
|
-
(
|
|
7643
|
-
|
|
7644
|
-
|
|
7645
|
-
|
|
7646
|
-
|
|
7647
|
-
|
|
7648
|
-
{
|
|
7649
|
-
|
|
7650
|
-
|
|
7651
|
-
|
|
7652
|
-
|
|
7653
|
-
|
|
7654
|
-
|
|
7655
|
-
|
|
7656
|
-
|
|
7657
|
-
viewports.map((viewport, i) => /* @__PURE__ */ jsx37(
|
|
7658
|
-
ViewportButton,
|
|
7659
|
-
{
|
|
7660
|
-
height: viewport.height,
|
|
7661
|
-
width: viewport.width,
|
|
7662
|
-
title: viewport.label ? `Switch to ${viewport.label} viewport` : "Switch viewport",
|
|
7663
|
-
onClick: onViewportChange,
|
|
7664
|
-
children: typeof viewport.icon === "string" ? icons[viewport.icon] || viewport.icon : viewport.icon || icons.Smartphone
|
|
7665
|
-
},
|
|
7666
|
-
i
|
|
7667
|
-
)),
|
|
7668
|
-
/* @__PURE__ */ jsx37("div", { className: getClassName25("divider") }),
|
|
7669
|
-
/* @__PURE__ */ jsx37(
|
|
7670
|
-
IconButton,
|
|
7671
|
-
{
|
|
7672
|
-
type: "button",
|
|
7673
|
-
title: "Zoom viewport out",
|
|
7674
|
-
disabled: zoom <= ((_a = zoomOptions[0]) == null ? void 0 : _a.value),
|
|
7675
|
-
onClick: (e) => {
|
|
7676
|
-
e.stopPropagation();
|
|
7677
|
-
onZoom(
|
|
7678
|
-
zoomOptions[Math.max(
|
|
7679
|
-
zoomOptions.findIndex((option) => option.value === zoom) - 1,
|
|
7680
|
-
0
|
|
7681
|
-
)].value
|
|
7682
|
-
);
|
|
7683
|
-
},
|
|
7684
|
-
children: /* @__PURE__ */ jsx37(ZoomOut, { size: 16 })
|
|
7685
|
-
}
|
|
7686
|
-
),
|
|
7687
|
-
/* @__PURE__ */ jsx37(
|
|
7688
|
-
IconButton,
|
|
7689
|
-
{
|
|
7690
|
-
type: "button",
|
|
7691
|
-
title: "Zoom viewport in",
|
|
7692
|
-
disabled: zoom >= ((_b = zoomOptions[zoomOptions.length - 1]) == null ? void 0 : _b.value),
|
|
7693
|
-
onClick: (e) => {
|
|
7694
|
-
e.stopPropagation();
|
|
7695
|
-
onZoom(
|
|
7696
|
-
zoomOptions[Math.min(
|
|
7697
|
-
zoomOptions.findIndex((option) => option.value === zoom) + 1,
|
|
7698
|
-
zoomOptions.length - 1
|
|
7699
|
-
)].value
|
|
7700
|
-
);
|
|
7701
|
-
},
|
|
7702
|
-
children: /* @__PURE__ */ jsx37(ZoomIn, { size: 16 })
|
|
7703
|
-
}
|
|
7704
|
-
),
|
|
7705
|
-
/* @__PURE__ */ jsx37("div", { className: getClassName25("divider") }),
|
|
7706
|
-
/* @__PURE__ */ jsx37(
|
|
7707
|
-
"select",
|
|
7708
|
-
{
|
|
7709
|
-
className: getClassName25("zoomSelect"),
|
|
7710
|
-
value: zoom.toString(),
|
|
7711
|
-
onClick: (e) => {
|
|
7712
|
-
e.stopPropagation();
|
|
7713
|
-
},
|
|
7714
|
-
onChange: (e) => {
|
|
7715
|
-
onZoom(parseFloat(e.currentTarget.value));
|
|
7716
|
-
},
|
|
7717
|
-
children: zoomOptions.map((option) => /* @__PURE__ */ jsx37(
|
|
7718
|
-
"option",
|
|
7719
|
-
{
|
|
7720
|
-
value: option.value,
|
|
7721
|
-
label: option.label
|
|
7722
|
-
},
|
|
7723
|
-
option.label
|
|
7724
|
-
))
|
|
7706
|
+
const collected = __spreadValues({}, overrides);
|
|
7707
|
+
plugins == null ? void 0 : plugins.forEach((plugin) => {
|
|
7708
|
+
if (!plugin.overrides) return;
|
|
7709
|
+
Object.keys(plugin.overrides).forEach((_overridesType) => {
|
|
7710
|
+
var _a;
|
|
7711
|
+
const overridesType = _overridesType;
|
|
7712
|
+
if (!((_a = plugin.overrides) == null ? void 0 : _a[overridesType])) return;
|
|
7713
|
+
if (overridesType === "fieldTypes") {
|
|
7714
|
+
const fieldTypes = plugin.overrides.fieldTypes;
|
|
7715
|
+
Object.keys(fieldTypes).forEach((fieldType) => {
|
|
7716
|
+
collected.fieldTypes = collected.fieldTypes || {};
|
|
7717
|
+
const childNode2 = collected.fieldTypes[fieldType];
|
|
7718
|
+
const Comp2 = (props) => fieldTypes[fieldType](__spreadProps(__spreadValues({}, props), {
|
|
7719
|
+
children: childNode2 ? childNode2(props) : props.children
|
|
7720
|
+
}));
|
|
7721
|
+
collected.fieldTypes[fieldType] = Comp2;
|
|
7722
|
+
});
|
|
7723
|
+
return;
|
|
7725
7724
|
}
|
|
7726
|
-
|
|
7727
|
-
|
|
7725
|
+
const childNode = collected[overridesType];
|
|
7726
|
+
const Comp = (props) => plugin.overrides[overridesType](__spreadProps(__spreadValues({}, props), {
|
|
7727
|
+
children: childNode ? childNode(props) : props.children
|
|
7728
|
+
}));
|
|
7729
|
+
collected[overridesType] = Comp;
|
|
7730
|
+
});
|
|
7731
|
+
});
|
|
7732
|
+
return collected;
|
|
7728
7733
|
};
|
|
7729
7734
|
|
|
7730
|
-
//
|
|
7731
|
-
|
|
7732
|
-
|
|
7735
|
+
// lib/use-loaded-overrides.ts
|
|
7736
|
+
var useLoadedOverrides = ({
|
|
7737
|
+
overrides,
|
|
7738
|
+
plugins
|
|
7739
|
+
}) => {
|
|
7740
|
+
return useMemo15(() => {
|
|
7741
|
+
return loadOverrides({ overrides, plugins });
|
|
7742
|
+
}, [plugins, overrides]);
|
|
7743
|
+
};
|
|
7733
7744
|
|
|
7734
|
-
// components/Puck/
|
|
7735
|
-
|
|
7745
|
+
// components/Puck/index.tsx
|
|
7746
|
+
var import_fast_deep_equal = __toESM(require_fast_deep_equal());
|
|
7736
7747
|
|
|
7737
|
-
//
|
|
7748
|
+
// components/Puck/components/Layout/index.tsx
|
|
7738
7749
|
init_react_import();
|
|
7739
|
-
import {
|
|
7740
|
-
createContext as createContext7,
|
|
7741
|
-
useContext as useContext12,
|
|
7742
|
-
useRef as useRef8,
|
|
7743
|
-
useMemo as useMemo16
|
|
7744
|
-
} from "react";
|
|
7745
|
-
import { jsx as jsx38 } from "react/jsx-runtime";
|
|
7746
|
-
var FrameContext = createContext7(null);
|
|
7747
|
-
var FrameProvider = ({
|
|
7748
|
-
children
|
|
7749
|
-
}) => {
|
|
7750
|
-
const frameRef = useRef8(null);
|
|
7751
|
-
const value = useMemo16(
|
|
7752
|
-
() => ({
|
|
7753
|
-
frameRef
|
|
7754
|
-
}),
|
|
7755
|
-
[]
|
|
7756
|
-
);
|
|
7757
|
-
return /* @__PURE__ */ jsx38(FrameContext.Provider, { value, children });
|
|
7758
|
-
};
|
|
7759
|
-
var useCanvasFrame = () => {
|
|
7760
|
-
const context = useContext12(FrameContext);
|
|
7761
|
-
if (context === null) {
|
|
7762
|
-
throw new Error("useCanvasFrame must be used within a FrameProvider");
|
|
7763
|
-
}
|
|
7764
|
-
return context;
|
|
7765
|
-
};
|
|
7750
|
+
import { useEffect as useEffect29, useMemo as useMemo20, useState as useState25 } from "react";
|
|
7766
7751
|
|
|
7767
|
-
// components/Puck/components/
|
|
7768
|
-
|
|
7769
|
-
var
|
|
7770
|
-
|
|
7771
|
-
|
|
7772
|
-
|
|
7773
|
-
|
|
7774
|
-
|
|
7775
|
-
|
|
7776
|
-
|
|
7777
|
-
|
|
7778
|
-
|
|
7779
|
-
zoomConfig,
|
|
7780
|
-
setZoomConfig,
|
|
7781
|
-
status,
|
|
7782
|
-
iframe
|
|
7783
|
-
} = useAppStore(
|
|
7784
|
-
useShallow8((s) => ({
|
|
7785
|
-
dispatch: s.dispatch,
|
|
7786
|
-
overrides: s.overrides,
|
|
7787
|
-
setUi: s.setUi,
|
|
7788
|
-
zoomConfig: s.zoomConfig,
|
|
7789
|
-
setZoomConfig: s.setZoomConfig,
|
|
7790
|
-
status: s.status,
|
|
7791
|
-
iframe: s.iframe
|
|
7792
|
-
}))
|
|
7793
|
-
);
|
|
7794
|
-
const {
|
|
7795
|
-
leftSideBarVisible,
|
|
7796
|
-
rightSideBarVisible,
|
|
7797
|
-
leftSideBarWidth,
|
|
7798
|
-
rightSideBarWidth,
|
|
7799
|
-
viewports
|
|
7800
|
-
} = useAppStore(
|
|
7801
|
-
useShallow8((s) => ({
|
|
7802
|
-
leftSideBarVisible: s.state.ui.leftSideBarVisible,
|
|
7803
|
-
rightSideBarVisible: s.state.ui.rightSideBarVisible,
|
|
7804
|
-
leftSideBarWidth: s.state.ui.leftSideBarWidth,
|
|
7805
|
-
rightSideBarWidth: s.state.ui.rightSideBarWidth,
|
|
7806
|
-
viewports: s.state.ui.viewports
|
|
7807
|
-
}))
|
|
7808
|
-
);
|
|
7809
|
-
const [showTransition, setShowTransition] = useState21(false);
|
|
7810
|
-
const isResizingRef = useRef9(false);
|
|
7811
|
-
const defaultRender = useMemo17(() => {
|
|
7812
|
-
const PuckDefault = ({ children }) => /* @__PURE__ */ jsx39(Fragment12, { children });
|
|
7813
|
-
return PuckDefault;
|
|
7752
|
+
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Layout/styles.module.css#css-module
|
|
7753
|
+
init_react_import();
|
|
7754
|
+
var styles_module_default22 = { "Puck": "_Puck_hv23j_19", "Puck-portal": "_Puck-portal_hv23j_31", "PuckLayout": "_PuckLayout_hv23j_36", "PuckLayout-inner": "_PuckLayout-inner_hv23j_40", "PuckLayout--mounted": "_PuckLayout--mounted_hv23j_73", "PuckLayout--mobilePanelHeightToggle": "_PuckLayout--mobilePanelHeightToggle_hv23j_77", "PuckLayout--leftSideBarVisible": "_PuckLayout--leftSideBarVisible_hv23j_77", "PuckLayout--isExpanded": "_PuckLayout--isExpanded_hv23j_83", "PuckLayout--mobilePanelHeightMinContent": "_PuckLayout--mobilePanelHeightMinContent_hv23j_101", "PuckLayout--rightSideBarVisible": "_PuckLayout--rightSideBarVisible_hv23j_128", "PuckLayout-mounted": "_PuckLayout-mounted_hv23j_147", "PuckLayout-nav": "_PuckLayout-nav_hv23j_188", "PuckLayout-header": "_PuckLayout-header_hv23j_204", "PuckPluginTab": "_PuckPluginTab_hv23j_218", "PuckPluginTab--visible": "_PuckPluginTab--visible_hv23j_224", "PuckPluginTab-body": "_PuckPluginTab-body_hv23j_229" };
|
|
7755
|
+
|
|
7756
|
+
// lib/use-inject-css.ts
|
|
7757
|
+
init_react_import();
|
|
7758
|
+
import { useEffect as useEffect24, useState as useState20 } from "react";
|
|
7759
|
+
var styles = ``;
|
|
7760
|
+
var useInjectStyleSheet = (initialStyles, iframeEnabled) => {
|
|
7761
|
+
const [el, setEl] = useState20();
|
|
7762
|
+
useEffect24(() => {
|
|
7763
|
+
setEl(document.createElement("style"));
|
|
7814
7764
|
}, []);
|
|
7815
|
-
|
|
7816
|
-
|
|
7817
|
-
|
|
7818
|
-
|
|
7819
|
-
const getFrameDimensions = useCallback15(() => {
|
|
7820
|
-
if (frameRef.current) {
|
|
7821
|
-
const frame = frameRef.current;
|
|
7822
|
-
const box = getBox(frame);
|
|
7823
|
-
return { width: box.contentBox.width, height: box.contentBox.height };
|
|
7824
|
-
}
|
|
7825
|
-
return { width: 0, height: 0 };
|
|
7826
|
-
}, [frameRef]);
|
|
7827
|
-
useEffect25(() => {
|
|
7828
|
-
resetAutoZoom();
|
|
7829
|
-
}, [
|
|
7830
|
-
frameRef,
|
|
7831
|
-
leftSideBarVisible,
|
|
7832
|
-
rightSideBarVisible,
|
|
7833
|
-
leftSideBarWidth,
|
|
7834
|
-
rightSideBarWidth,
|
|
7835
|
-
viewports
|
|
7836
|
-
]);
|
|
7837
|
-
useEffect25(() => {
|
|
7838
|
-
const { height: frameHeight } = getFrameDimensions();
|
|
7839
|
-
if (viewports.current.height === "auto") {
|
|
7840
|
-
setZoomConfig(__spreadProps(__spreadValues({}, zoomConfig), {
|
|
7841
|
-
rootHeight: frameHeight / zoomConfig.zoom
|
|
7842
|
-
}));
|
|
7765
|
+
useEffect24(() => {
|
|
7766
|
+
var _a;
|
|
7767
|
+
if (!el || typeof window === "undefined") {
|
|
7768
|
+
return;
|
|
7843
7769
|
}
|
|
7844
|
-
|
|
7845
|
-
|
|
7846
|
-
|
|
7847
|
-
|
|
7770
|
+
el.innerHTML = initialStyles;
|
|
7771
|
+
if (iframeEnabled) {
|
|
7772
|
+
const frame = getFrame();
|
|
7773
|
+
(_a = frame == null ? void 0 : frame.head) == null ? void 0 : _a.appendChild(el);
|
|
7848
7774
|
}
|
|
7849
|
-
|
|
7850
|
-
|
|
7851
|
-
|
|
7852
|
-
|
|
7853
|
-
|
|
7854
|
-
|
|
7855
|
-
|
|
7775
|
+
document.head.appendChild(el);
|
|
7776
|
+
}, [iframeEnabled, el]);
|
|
7777
|
+
return el;
|
|
7778
|
+
};
|
|
7779
|
+
var useInjectGlobalCss = (iframeEnabled) => {
|
|
7780
|
+
return useInjectStyleSheet(styles, iframeEnabled);
|
|
7781
|
+
};
|
|
7782
|
+
|
|
7783
|
+
// components/DefaultOverride/index.tsx
|
|
7784
|
+
init_react_import();
|
|
7785
|
+
import { Fragment as Fragment12, jsx as jsx40 } from "react/jsx-runtime";
|
|
7786
|
+
var DefaultOverride = ({ children }) => /* @__PURE__ */ jsx40(Fragment12, { children });
|
|
7787
|
+
|
|
7788
|
+
// lib/use-preview-mode-hotkeys.ts
|
|
7789
|
+
init_react_import();
|
|
7790
|
+
import { useCallback as useCallback15 } from "react";
|
|
7791
|
+
var usePreviewModeHotkeys = () => {
|
|
7792
|
+
const appStore = useAppStoreApi();
|
|
7793
|
+
const toggleInteractive = useCallback15(() => {
|
|
7794
|
+
const dispatch = appStore.getState().dispatch;
|
|
7795
|
+
dispatch({
|
|
7796
|
+
type: "setUi",
|
|
7797
|
+
ui: (ui) => ({
|
|
7798
|
+
previewMode: ui.previewMode === "edit" ? "interactive" : "edit"
|
|
7799
|
+
})
|
|
7856
7800
|
});
|
|
7857
|
-
|
|
7858
|
-
|
|
7859
|
-
|
|
7860
|
-
|
|
7861
|
-
|
|
7862
|
-
|
|
7863
|
-
|
|
7864
|
-
|
|
7865
|
-
|
|
7866
|
-
|
|
7867
|
-
|
|
7868
|
-
|
|
7801
|
+
}, [appStore]);
|
|
7802
|
+
useHotkey({ meta: true, i: true }, toggleInteractive);
|
|
7803
|
+
useHotkey({ ctrl: true, i: true }, toggleInteractive);
|
|
7804
|
+
};
|
|
7805
|
+
|
|
7806
|
+
// components/Puck/components/Header/index.tsx
|
|
7807
|
+
init_react_import();
|
|
7808
|
+
import { memo as memo4, useCallback as useCallback16, useMemo as useMemo16, useState as useState21 } from "react";
|
|
7809
|
+
|
|
7810
|
+
// components/MenuBar/index.tsx
|
|
7811
|
+
init_react_import();
|
|
7812
|
+
|
|
7813
|
+
// css-module:/home/runner/work/puck/puck/packages/core/components/MenuBar/styles.module.css#css-module
|
|
7814
|
+
init_react_import();
|
|
7815
|
+
var styles_module_default23 = { "MenuBar": "_MenuBar_8pf8c_1", "MenuBar--menuOpen": "_MenuBar--menuOpen_8pf8c_14", "MenuBar-inner": "_MenuBar-inner_8pf8c_29", "MenuBar-history": "_MenuBar-history_8pf8c_45" };
|
|
7816
|
+
|
|
7817
|
+
// components/MenuBar/index.tsx
|
|
7818
|
+
import { Fragment as Fragment13, jsx as jsx41, jsxs as jsxs17 } from "react/jsx-runtime";
|
|
7819
|
+
var getClassName28 = get_class_name_factory_default("MenuBar", styles_module_default23);
|
|
7820
|
+
function MenuBar({
|
|
7821
|
+
menuOpen = false,
|
|
7822
|
+
renderHeaderActions,
|
|
7823
|
+
setMenuOpen
|
|
7824
|
+
}) {
|
|
7825
|
+
const back = useAppStore((s) => s.history.back);
|
|
7826
|
+
const forward = useAppStore((s) => s.history.forward);
|
|
7827
|
+
const hasFuture = useAppStore((s) => s.history.hasFuture());
|
|
7828
|
+
const hasPast = useAppStore((s) => s.history.hasPast());
|
|
7829
|
+
return /* @__PURE__ */ jsx41(
|
|
7869
7830
|
"div",
|
|
7870
7831
|
{
|
|
7871
|
-
className:
|
|
7872
|
-
|
|
7873
|
-
|
|
7874
|
-
|
|
7875
|
-
|
|
7876
|
-
|
|
7877
|
-
|
|
7878
|
-
|
|
7879
|
-
|
|
7880
|
-
ui: { itemSelector: null },
|
|
7881
|
-
recordHistory: true
|
|
7882
|
-
});
|
|
7832
|
+
className: getClassName28({ menuOpen }),
|
|
7833
|
+
onClick: (event) => {
|
|
7834
|
+
var _a;
|
|
7835
|
+
const element = event.target;
|
|
7836
|
+
if (window.matchMedia("(min-width: 638px)").matches) {
|
|
7837
|
+
return;
|
|
7838
|
+
}
|
|
7839
|
+
if (element.tagName === "A" && ((_a = element.getAttribute("href")) == null ? void 0 : _a.startsWith("#"))) {
|
|
7840
|
+
setMenuOpen(false);
|
|
7883
7841
|
}
|
|
7884
7842
|
},
|
|
7885
|
-
children: [
|
|
7886
|
-
|
|
7887
|
-
|
|
7888
|
-
|
|
7889
|
-
autoZoom: zoomConfig.autoZoom,
|
|
7890
|
-
zoom: zoomConfig.zoom,
|
|
7891
|
-
onViewportChange: (viewport) => {
|
|
7892
|
-
setShowTransition(true);
|
|
7893
|
-
isResizingRef.current = true;
|
|
7894
|
-
const uiViewport = __spreadProps(__spreadValues({}, viewport), {
|
|
7895
|
-
height: viewport.height || "auto",
|
|
7896
|
-
zoom: zoomConfig.zoom
|
|
7897
|
-
});
|
|
7898
|
-
const newUi = {
|
|
7899
|
-
viewports: __spreadProps(__spreadValues({}, viewports), { current: uiViewport })
|
|
7900
|
-
};
|
|
7901
|
-
setUi(newUi);
|
|
7902
|
-
if (ZOOM_ON_CHANGE) {
|
|
7903
|
-
resetAutoZoom({
|
|
7904
|
-
viewports: __spreadProps(__spreadValues({}, viewports), { current: uiViewport })
|
|
7905
|
-
});
|
|
7906
|
-
}
|
|
7907
|
-
},
|
|
7908
|
-
onZoom: (zoom) => {
|
|
7909
|
-
setShowTransition(true);
|
|
7910
|
-
isResizingRef.current = true;
|
|
7911
|
-
setZoomConfig(__spreadProps(__spreadValues({}, zoomConfig), { zoom }));
|
|
7912
|
-
}
|
|
7913
|
-
}
|
|
7914
|
-
) }),
|
|
7915
|
-
/* @__PURE__ */ jsxs17("div", { className: getClassName26("inner"), ref: frameRef, children: [
|
|
7916
|
-
/* @__PURE__ */ jsx39(
|
|
7917
|
-
"div",
|
|
7843
|
+
children: /* @__PURE__ */ jsxs17("div", { className: getClassName28("inner"), children: [
|
|
7844
|
+
/* @__PURE__ */ jsxs17("div", { className: getClassName28("history"), children: [
|
|
7845
|
+
/* @__PURE__ */ jsx41(
|
|
7846
|
+
IconButton,
|
|
7918
7847
|
{
|
|
7919
|
-
|
|
7920
|
-
|
|
7921
|
-
|
|
7922
|
-
|
|
7923
|
-
|
|
7924
|
-
transition: showTransition ? `width ${TRANSITION_DURATION}ms ease-out, height ${TRANSITION_DURATION}ms ease-out, transform ${TRANSITION_DURATION}ms ease-out` : "",
|
|
7925
|
-
overflow: iframe.enabled ? void 0 : "auto"
|
|
7926
|
-
},
|
|
7927
|
-
suppressHydrationWarning: true,
|
|
7928
|
-
id: "puck-canvas-root",
|
|
7929
|
-
onTransitionEnd: () => {
|
|
7930
|
-
setShowTransition(false);
|
|
7931
|
-
isResizingRef.current = false;
|
|
7932
|
-
},
|
|
7933
|
-
children: /* @__PURE__ */ jsx39(CustomPreview, { children: /* @__PURE__ */ jsx39(Preview2, {}) })
|
|
7848
|
+
type: "button",
|
|
7849
|
+
title: "undo",
|
|
7850
|
+
disabled: !hasPast,
|
|
7851
|
+
onClick: back,
|
|
7852
|
+
children: /* @__PURE__ */ jsx41(Undo2, { size: 21 })
|
|
7934
7853
|
}
|
|
7935
7854
|
),
|
|
7936
|
-
/* @__PURE__ */
|
|
7937
|
-
|
|
7938
|
-
|
|
7855
|
+
/* @__PURE__ */ jsx41(
|
|
7856
|
+
IconButton,
|
|
7857
|
+
{
|
|
7858
|
+
type: "button",
|
|
7859
|
+
title: "redo",
|
|
7860
|
+
disabled: !hasFuture,
|
|
7861
|
+
onClick: forward,
|
|
7862
|
+
children: /* @__PURE__ */ jsx41(Redo2, { size: 21 })
|
|
7863
|
+
}
|
|
7864
|
+
)
|
|
7865
|
+
] }),
|
|
7866
|
+
/* @__PURE__ */ jsx41(Fragment13, { children: renderHeaderActions && renderHeaderActions() })
|
|
7867
|
+
] })
|
|
7939
7868
|
}
|
|
7940
7869
|
);
|
|
7941
|
-
}
|
|
7870
|
+
}
|
|
7942
7871
|
|
|
7943
|
-
//
|
|
7872
|
+
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Header/styles.module.css#css-module
|
|
7944
7873
|
init_react_import();
|
|
7945
|
-
|
|
7874
|
+
var styles_module_default24 = { "PuckHeader": "_PuckHeader_1bhmt_1", "PuckHeader-inner": "_PuckHeader-inner_1bhmt_16", "PuckHeader-toggle": "_PuckHeader-toggle_1bhmt_32", "PuckHeader--rightSideBarVisible": "_PuckHeader--rightSideBarVisible_1bhmt_39", "PuckHeader-rightSideBarToggle": "_PuckHeader-rightSideBarToggle_1bhmt_39", "PuckHeader--leftSideBarVisible": "_PuckHeader--leftSideBarVisible_1bhmt_40", "PuckHeader-leftSideBarToggle": "_PuckHeader-leftSideBarToggle_1bhmt_40", "PuckHeader-title": "_PuckHeader-title_1bhmt_56", "PuckHeader-path": "_PuckHeader-path_1bhmt_60", "PuckHeader-tools": "_PuckHeader-tools_1bhmt_67", "PuckHeader-menuButton": "_PuckHeader-menuButton_1bhmt_73", "PuckHeader--menuOpen": "_PuckHeader--menuOpen_1bhmt_78" };
|
|
7946
7875
|
|
|
7947
|
-
//
|
|
7948
|
-
|
|
7949
|
-
var
|
|
7950
|
-
|
|
7951
|
-
|
|
7952
|
-
|
|
7953
|
-
|
|
7954
|
-
|
|
7955
|
-
|
|
7956
|
-
|
|
7957
|
-
|
|
7958
|
-
|
|
7959
|
-
|
|
7960
|
-
|
|
7961
|
-
|
|
7962
|
-
|
|
7963
|
-
|
|
7964
|
-
|
|
7965
|
-
|
|
7966
|
-
|
|
7967
|
-
|
|
7968
|
-
|
|
7969
|
-
|
|
7970
|
-
return;
|
|
7971
|
-
}
|
|
7972
|
-
|
|
7973
|
-
|
|
7974
|
-
|
|
7975
|
-
|
|
7976
|
-
|
|
7977
|
-
|
|
7876
|
+
// components/Puck/components/Header/index.tsx
|
|
7877
|
+
import { Fragment as Fragment14, jsx as jsx42, jsxs as jsxs18 } from "react/jsx-runtime";
|
|
7878
|
+
var getClassName29 = get_class_name_factory_default("PuckHeader", styles_module_default24);
|
|
7879
|
+
var HeaderInner = () => {
|
|
7880
|
+
const {
|
|
7881
|
+
onPublish,
|
|
7882
|
+
renderHeader,
|
|
7883
|
+
renderHeaderActions,
|
|
7884
|
+
headerTitle,
|
|
7885
|
+
headerPath,
|
|
7886
|
+
iframe: _iframe
|
|
7887
|
+
} = usePropsContext();
|
|
7888
|
+
const dispatch = useAppStore((s) => s.dispatch);
|
|
7889
|
+
const appStore = useAppStoreApi();
|
|
7890
|
+
const defaultHeaderRender = useMemo16(() => {
|
|
7891
|
+
if (renderHeader) {
|
|
7892
|
+
console.warn(
|
|
7893
|
+
"`renderHeader` is deprecated. Please use `overrides.header` and the `usePuck` hook instead"
|
|
7894
|
+
);
|
|
7895
|
+
const RenderHeader = (_a) => {
|
|
7896
|
+
var _b = _a, { actions } = _b, props = __objRest(_b, ["actions"]);
|
|
7897
|
+
const Comp = renderHeader;
|
|
7898
|
+
const appState = useAppStore((s) => s.state);
|
|
7899
|
+
return /* @__PURE__ */ jsx42(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState, children: actions }));
|
|
7900
|
+
};
|
|
7901
|
+
return RenderHeader;
|
|
7902
|
+
}
|
|
7903
|
+
return DefaultOverride;
|
|
7904
|
+
}, [renderHeader]);
|
|
7905
|
+
const defaultHeaderActionsRender = useMemo16(() => {
|
|
7906
|
+
if (renderHeaderActions) {
|
|
7907
|
+
console.warn(
|
|
7908
|
+
"`renderHeaderActions` is deprecated. Please use `overrides.headerActions` and the `usePuck` hook instead."
|
|
7909
|
+
);
|
|
7910
|
+
const RenderHeader = (props) => {
|
|
7911
|
+
const Comp = renderHeaderActions;
|
|
7912
|
+
const appState = useAppStore((s) => s.state);
|
|
7913
|
+
return /* @__PURE__ */ jsx42(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState }));
|
|
7914
|
+
};
|
|
7915
|
+
return RenderHeader;
|
|
7916
|
+
}
|
|
7917
|
+
return DefaultOverride;
|
|
7918
|
+
}, [renderHeaderActions]);
|
|
7919
|
+
const CustomHeader = useAppStore(
|
|
7920
|
+
(s) => s.overrides.header || defaultHeaderRender
|
|
7921
|
+
);
|
|
7922
|
+
const CustomHeaderActions = useAppStore(
|
|
7923
|
+
(s) => s.overrides.headerActions || defaultHeaderActionsRender
|
|
7924
|
+
);
|
|
7925
|
+
const [menuOpen, setMenuOpen] = useState21(false);
|
|
7926
|
+
const rootTitle = useAppStore((s) => {
|
|
7927
|
+
var _a, _b;
|
|
7928
|
+
const rootData = (_a = s.state.indexes.nodes["root"]) == null ? void 0 : _a.data;
|
|
7929
|
+
return (_b = rootData.props.title) != null ? _b : "";
|
|
7978
7930
|
});
|
|
7979
|
-
|
|
7980
|
-
|
|
7981
|
-
|
|
7982
|
-
|
|
7983
|
-
|
|
7984
|
-
|
|
7985
|
-
|
|
7986
|
-
|
|
7987
|
-
|
|
7988
|
-
|
|
7989
|
-
|
|
7931
|
+
const leftSideBarVisible = useAppStore((s) => s.state.ui.leftSideBarVisible);
|
|
7932
|
+
const rightSideBarVisible = useAppStore(
|
|
7933
|
+
(s) => s.state.ui.rightSideBarVisible
|
|
7934
|
+
);
|
|
7935
|
+
const toggleSidebars = useCallback16(
|
|
7936
|
+
(sidebar) => {
|
|
7937
|
+
const widerViewport = window.matchMedia("(min-width: 638px)").matches;
|
|
7938
|
+
const sideBarVisible = sidebar === "left" ? leftSideBarVisible : rightSideBarVisible;
|
|
7939
|
+
const oppositeSideBar = sidebar === "left" ? "rightSideBarVisible" : "leftSideBarVisible";
|
|
7940
|
+
dispatch({
|
|
7941
|
+
type: "setUi",
|
|
7942
|
+
ui: __spreadValues({
|
|
7943
|
+
[`${sidebar}SideBarVisible`]: !sideBarVisible
|
|
7944
|
+
}, !widerViewport ? { [oppositeSideBar]: false } : {})
|
|
7945
|
+
});
|
|
7946
|
+
},
|
|
7947
|
+
[dispatch, leftSideBarVisible, rightSideBarVisible]
|
|
7948
|
+
);
|
|
7949
|
+
return /* @__PURE__ */ jsx42(
|
|
7950
|
+
CustomHeader,
|
|
7951
|
+
{
|
|
7952
|
+
actions: /* @__PURE__ */ jsx42(Fragment14, { children: /* @__PURE__ */ jsx42(CustomHeaderActions, { children: /* @__PURE__ */ jsx42(
|
|
7953
|
+
Button,
|
|
7954
|
+
{
|
|
7955
|
+
onClick: () => {
|
|
7956
|
+
const data = appStore.getState().state.data;
|
|
7957
|
+
onPublish && onPublish(data);
|
|
7958
|
+
},
|
|
7959
|
+
icon: /* @__PURE__ */ jsx42(Globe, { size: "14px" }),
|
|
7960
|
+
children: "Publish"
|
|
7961
|
+
}
|
|
7962
|
+
) }) }),
|
|
7963
|
+
children: /* @__PURE__ */ jsx42(
|
|
7964
|
+
"header",
|
|
7965
|
+
{
|
|
7966
|
+
className: getClassName29({ leftSideBarVisible, rightSideBarVisible }),
|
|
7967
|
+
children: /* @__PURE__ */ jsxs18("div", { className: getClassName29("inner"), children: [
|
|
7968
|
+
/* @__PURE__ */ jsxs18("div", { className: getClassName29("toggle"), children: [
|
|
7969
|
+
/* @__PURE__ */ jsx42("div", { className: getClassName29("leftSideBarToggle"), children: /* @__PURE__ */ jsx42(
|
|
7970
|
+
IconButton,
|
|
7971
|
+
{
|
|
7972
|
+
type: "button",
|
|
7973
|
+
onClick: () => {
|
|
7974
|
+
toggleSidebars("left");
|
|
7975
|
+
},
|
|
7976
|
+
title: "Toggle left sidebar",
|
|
7977
|
+
children: /* @__PURE__ */ jsx42(PanelLeft, { focusable: "false" })
|
|
7978
|
+
}
|
|
7979
|
+
) }),
|
|
7980
|
+
/* @__PURE__ */ jsx42("div", { className: getClassName29("rightSideBarToggle"), children: /* @__PURE__ */ jsx42(
|
|
7981
|
+
IconButton,
|
|
7982
|
+
{
|
|
7983
|
+
type: "button",
|
|
7984
|
+
onClick: () => {
|
|
7985
|
+
toggleSidebars("right");
|
|
7986
|
+
},
|
|
7987
|
+
title: "Toggle right sidebar",
|
|
7988
|
+
children: /* @__PURE__ */ jsx42(PanelRight, { focusable: "false" })
|
|
7989
|
+
}
|
|
7990
|
+
) })
|
|
7991
|
+
] }),
|
|
7992
|
+
/* @__PURE__ */ jsx42("div", { className: getClassName29("title"), children: /* @__PURE__ */ jsxs18(Heading, { rank: "2", size: "xs", children: [
|
|
7993
|
+
headerTitle || rootTitle || "Page",
|
|
7994
|
+
headerPath && /* @__PURE__ */ jsxs18(Fragment14, { children: [
|
|
7995
|
+
" ",
|
|
7996
|
+
/* @__PURE__ */ jsx42("code", { className: getClassName29("path"), children: headerPath })
|
|
7997
|
+
] })
|
|
7998
|
+
] }) }),
|
|
7999
|
+
/* @__PURE__ */ jsxs18("div", { className: getClassName29("tools"), children: [
|
|
8000
|
+
/* @__PURE__ */ jsx42("div", { className: getClassName29("menuButton"), children: /* @__PURE__ */ jsx42(
|
|
8001
|
+
IconButton,
|
|
8002
|
+
{
|
|
8003
|
+
type: "button",
|
|
8004
|
+
onClick: () => {
|
|
8005
|
+
return setMenuOpen(!menuOpen);
|
|
8006
|
+
},
|
|
8007
|
+
title: "Toggle menu bar",
|
|
8008
|
+
children: menuOpen ? /* @__PURE__ */ jsx42(ChevronUp, { focusable: "false" }) : /* @__PURE__ */ jsx42(ChevronDown, { focusable: "false" })
|
|
8009
|
+
}
|
|
8010
|
+
) }),
|
|
8011
|
+
/* @__PURE__ */ jsx42(
|
|
8012
|
+
MenuBar,
|
|
8013
|
+
{
|
|
8014
|
+
dispatch,
|
|
8015
|
+
onPublish,
|
|
8016
|
+
menuOpen,
|
|
8017
|
+
renderHeaderActions: () => /* @__PURE__ */ jsx42(CustomHeaderActions, { children: /* @__PURE__ */ jsx42(
|
|
8018
|
+
Button,
|
|
8019
|
+
{
|
|
8020
|
+
onClick: () => {
|
|
8021
|
+
const data = appStore.getState().state.data;
|
|
8022
|
+
onPublish && onPublish(data);
|
|
8023
|
+
},
|
|
8024
|
+
icon: /* @__PURE__ */ jsx42(Globe, { size: "14px" }),
|
|
8025
|
+
children: "Publish"
|
|
8026
|
+
}
|
|
8027
|
+
) }),
|
|
8028
|
+
setMenuOpen
|
|
8029
|
+
}
|
|
8030
|
+
)
|
|
8031
|
+
] })
|
|
8032
|
+
] })
|
|
8033
|
+
}
|
|
8034
|
+
)
|
|
8035
|
+
}
|
|
8036
|
+
);
|
|
7990
8037
|
};
|
|
8038
|
+
var Header = memo4(HeaderInner);
|
|
7991
8039
|
|
|
7992
|
-
// components/
|
|
8040
|
+
// components/SidebarSection/index.tsx
|
|
7993
8041
|
init_react_import();
|
|
7994
|
-
import { Fragment as Fragment13, jsx as jsx40 } from "react/jsx-runtime";
|
|
7995
|
-
var DefaultOverride = ({ children }) => /* @__PURE__ */ jsx40(Fragment13, { children });
|
|
7996
8042
|
|
|
7997
|
-
//
|
|
8043
|
+
// css-module:/home/runner/work/puck/puck/packages/core/components/SidebarSection/styles.module.css#css-module
|
|
7998
8044
|
init_react_import();
|
|
7999
|
-
|
|
8000
|
-
|
|
8001
|
-
|
|
8002
|
-
|
|
8003
|
-
|
|
8004
|
-
|
|
8005
|
-
|
|
8006
|
-
|
|
8007
|
-
|
|
8008
|
-
|
|
8009
|
-
|
|
8010
|
-
|
|
8011
|
-
|
|
8012
|
-
|
|
8013
|
-
|
|
8014
|
-
|
|
8045
|
+
var styles_module_default25 = { "SidebarSection": "_SidebarSection_8boj8_1", "SidebarSection-title": "_SidebarSection-title_8boj8_12", "SidebarSection--noBorderTop": "_SidebarSection--noBorderTop_8boj8_20", "SidebarSection-content": "_SidebarSection-content_8boj8_24", "SidebarSection--noPadding": "_SidebarSection--noPadding_8boj8_28", "SidebarSection-breadcrumbLabel": "_SidebarSection-breadcrumbLabel_8boj8_41", "SidebarSection-breadcrumbs": "_SidebarSection-breadcrumbs_8boj8_70", "SidebarSection-breadcrumb": "_SidebarSection-breadcrumb_8boj8_41", "SidebarSection-heading": "_SidebarSection-heading_8boj8_82", "SidebarSection-loadingOverlay": "_SidebarSection-loadingOverlay_8boj8_86" };
|
|
8046
|
+
|
|
8047
|
+
// components/SidebarSection/index.tsx
|
|
8048
|
+
import { jsx as jsx43, jsxs as jsxs19 } from "react/jsx-runtime";
|
|
8049
|
+
var getClassName30 = get_class_name_factory_default("SidebarSection", styles_module_default25);
|
|
8050
|
+
var SidebarSection = ({
|
|
8051
|
+
children,
|
|
8052
|
+
title,
|
|
8053
|
+
background,
|
|
8054
|
+
showBreadcrumbs,
|
|
8055
|
+
noBorderTop,
|
|
8056
|
+
noPadding,
|
|
8057
|
+
isLoading
|
|
8058
|
+
}) => {
|
|
8059
|
+
return /* @__PURE__ */ jsxs19(
|
|
8060
|
+
"div",
|
|
8061
|
+
{
|
|
8062
|
+
className: getClassName30({ noBorderTop, noPadding }),
|
|
8063
|
+
style: { background },
|
|
8064
|
+
children: [
|
|
8065
|
+
/* @__PURE__ */ jsx43("div", { className: getClassName30("title"), children: /* @__PURE__ */ jsxs19("div", { className: getClassName30("breadcrumbs"), children: [
|
|
8066
|
+
showBreadcrumbs && /* @__PURE__ */ jsx43(Breadcrumbs, {}),
|
|
8067
|
+
/* @__PURE__ */ jsx43("div", { className: getClassName30("heading"), children: /* @__PURE__ */ jsx43(Heading, { rank: "2", size: "xs", children: title }) })
|
|
8068
|
+
] }) }),
|
|
8069
|
+
/* @__PURE__ */ jsx43("div", { className: getClassName30("content"), children }),
|
|
8070
|
+
isLoading && /* @__PURE__ */ jsx43("div", { className: getClassName30("loadingOverlay"), children: /* @__PURE__ */ jsx43(Loader, { size: 32 }) })
|
|
8071
|
+
]
|
|
8015
8072
|
}
|
|
8016
|
-
|
|
8017
|
-
}, [iframeEnabled, el]);
|
|
8018
|
-
return el;
|
|
8019
|
-
};
|
|
8020
|
-
var useInjectGlobalCss = (iframeEnabled) => {
|
|
8021
|
-
return useInjectStyleSheet(styles, iframeEnabled);
|
|
8073
|
+
);
|
|
8022
8074
|
};
|
|
8023
8075
|
|
|
8024
|
-
//
|
|
8076
|
+
// components/Puck/components/Canvas/index.tsx
|
|
8077
|
+
init_react_import();
|
|
8078
|
+
import {
|
|
8079
|
+
useCallback as useCallback17,
|
|
8080
|
+
useEffect as useEffect26,
|
|
8081
|
+
useMemo as useMemo19,
|
|
8082
|
+
useRef as useRef9,
|
|
8083
|
+
useState as useState23
|
|
8084
|
+
} from "react";
|
|
8085
|
+
|
|
8086
|
+
// components/ViewportControls/index.tsx
|
|
8025
8087
|
init_react_import();
|
|
8026
|
-
import {
|
|
8027
|
-
var usePreviewModeHotkeys = () => {
|
|
8028
|
-
const appStore = useAppStoreApi();
|
|
8029
|
-
const toggleInteractive = useCallback16(() => {
|
|
8030
|
-
const dispatch = appStore.getState().dispatch;
|
|
8031
|
-
dispatch({
|
|
8032
|
-
type: "setUi",
|
|
8033
|
-
ui: (ui) => ({
|
|
8034
|
-
previewMode: ui.previewMode === "edit" ? "interactive" : "edit"
|
|
8035
|
-
})
|
|
8036
|
-
});
|
|
8037
|
-
}, [appStore]);
|
|
8038
|
-
useHotkey({ meta: true, i: true }, toggleInteractive);
|
|
8039
|
-
useHotkey({ ctrl: true, i: true }, toggleInteractive);
|
|
8040
|
-
};
|
|
8088
|
+
import { useEffect as useEffect25, useMemo as useMemo17, useState as useState22 } from "react";
|
|
8041
8089
|
|
|
8042
|
-
//
|
|
8090
|
+
// css-module:/home/runner/work/puck/puck/packages/core/components/ViewportControls/styles.module.css#css-module
|
|
8043
8091
|
init_react_import();
|
|
8044
|
-
|
|
8045
|
-
|
|
8046
|
-
|
|
8047
|
-
|
|
8048
|
-
|
|
8049
|
-
|
|
8050
|
-
|
|
8092
|
+
var styles_module_default26 = { "ViewportControls": "_ViewportControls_e3unb_1", "ViewportControls--fullScreen": "_ViewportControls--fullScreen_e3unb_5", "ViewportControls-toggleButton": "_ViewportControls-toggleButton_e3unb_14", "ViewportControls--isExpanded": "_ViewportControls--isExpanded_e3unb_38", "ViewportControls-actions": "_ViewportControls-actions_e3unb_42", "ViewportControls-actionsInner": "_ViewportControls-actionsInner_e3unb_46", "ViewportControls-divider": "_ViewportControls-divider_e3unb_75", "ViewportControls-zoomSelect": "_ViewportControls-zoomSelect_e3unb_81", "ViewportControls-zoom": "_ViewportControls-zoom_e3unb_81", "ViewportButton-inner": "_ViewportButton-inner_e3unb_111", "ViewportButton--isActive": "_ViewportButton--isActive_e3unb_119" };
|
|
8093
|
+
|
|
8094
|
+
// components/ViewportControls/index.tsx
|
|
8095
|
+
import { jsx as jsx44, jsxs as jsxs20 } from "react/jsx-runtime";
|
|
8096
|
+
var icons = {
|
|
8097
|
+
Smartphone: /* @__PURE__ */ jsx44(Smartphone, { size: 16 }),
|
|
8098
|
+
Tablet: /* @__PURE__ */ jsx44(Tablet, { size: 16 }),
|
|
8099
|
+
Monitor: /* @__PURE__ */ jsx44(Monitor, { size: 16 }),
|
|
8100
|
+
FullWidth: /* @__PURE__ */ jsx44(Expand, { size: 16 })
|
|
8101
|
+
};
|
|
8102
|
+
var getClassName31 = get_class_name_factory_default("ViewportControls", styles_module_default26);
|
|
8103
|
+
var getClassNameButton = get_class_name_factory_default("ViewportButton", styles_module_default26);
|
|
8104
|
+
var ActionButton = ({
|
|
8105
|
+
children,
|
|
8106
|
+
title,
|
|
8107
|
+
onClick,
|
|
8108
|
+
isActive,
|
|
8109
|
+
disabled
|
|
8110
|
+
}) => {
|
|
8111
|
+
return /* @__PURE__ */ jsx44("span", { className: getClassNameButton({ isActive }), suppressHydrationWarning: true, children: /* @__PURE__ */ jsx44(
|
|
8112
|
+
IconButton,
|
|
8113
|
+
{
|
|
8114
|
+
type: "button",
|
|
8115
|
+
title,
|
|
8116
|
+
disabled: disabled || isActive,
|
|
8117
|
+
onClick,
|
|
8118
|
+
suppressHydrationWarning: true,
|
|
8119
|
+
children: /* @__PURE__ */ jsx44("span", { className: getClassNameButton("inner"), children })
|
|
8051
8120
|
}
|
|
8052
|
-
|
|
8053
|
-
}
|
|
8054
|
-
return true;
|
|
8121
|
+
) });
|
|
8055
8122
|
};
|
|
8056
|
-
var
|
|
8057
|
-
|
|
8058
|
-
|
|
8059
|
-
|
|
8060
|
-
|
|
8061
|
-
|
|
8062
|
-
|
|
8063
|
-
|
|
8064
|
-
|
|
8065
|
-
|
|
8066
|
-
|
|
8067
|
-
|
|
8068
|
-
|
|
8069
|
-
|
|
8070
|
-
|
|
8123
|
+
var defaultZoomOptions = [
|
|
8124
|
+
{ label: "25%", value: 0.25 },
|
|
8125
|
+
{ label: "50%", value: 0.5 },
|
|
8126
|
+
{ label: "75%", value: 0.75 },
|
|
8127
|
+
{ label: "100%", value: 1 },
|
|
8128
|
+
{ label: "125%", value: 1.25 },
|
|
8129
|
+
{ label: "150%", value: 1.5 },
|
|
8130
|
+
{ label: "200%", value: 2 }
|
|
8131
|
+
];
|
|
8132
|
+
var ViewportControls = ({
|
|
8133
|
+
autoZoom,
|
|
8134
|
+
zoom,
|
|
8135
|
+
onViewportChange,
|
|
8136
|
+
onZoom,
|
|
8137
|
+
fullScreen
|
|
8138
|
+
}) => {
|
|
8139
|
+
var _a, _b;
|
|
8140
|
+
const viewports = useAppStore((s) => s.viewports);
|
|
8141
|
+
const uiViewports = useAppStore((s) => s.state.ui.viewports);
|
|
8142
|
+
const defaultsContainAutoZoom = defaultZoomOptions.find(
|
|
8143
|
+
(option) => option.value === autoZoom
|
|
8071
8144
|
);
|
|
8072
|
-
|
|
8073
|
-
|
|
8074
|
-
|
|
8075
|
-
|
|
8076
|
-
|
|
8077
|
-
|
|
8078
|
-
|
|
8079
|
-
|
|
8080
|
-
|
|
8081
|
-
|
|
8082
|
-
|
|
8083
|
-
|
|
8084
|
-
|
|
8085
|
-
|
|
8086
|
-
|
|
8087
|
-
|
|
8088
|
-
|
|
8089
|
-
|
|
8090
|
-
|
|
8091
|
-
|
|
8092
|
-
|
|
8093
|
-
|
|
8094
|
-
})
|
|
8095
|
-
|
|
8096
|
-
|
|
8097
|
-
|
|
8145
|
+
const zoomOptions = useMemo17(
|
|
8146
|
+
() => [
|
|
8147
|
+
...defaultZoomOptions,
|
|
8148
|
+
...defaultsContainAutoZoom ? [] : [
|
|
8149
|
+
{
|
|
8150
|
+
value: autoZoom,
|
|
8151
|
+
label: `${(autoZoom * 100).toFixed(0)}% (Auto)`
|
|
8152
|
+
}
|
|
8153
|
+
]
|
|
8154
|
+
].filter((a) => a.value <= autoZoom).sort((a, b) => a.value > b.value ? 1 : -1),
|
|
8155
|
+
[autoZoom]
|
|
8156
|
+
);
|
|
8157
|
+
const [activeViewport, setActiveViewport] = useState22(
|
|
8158
|
+
uiViewports.current.width
|
|
8159
|
+
);
|
|
8160
|
+
useEffect25(() => {
|
|
8161
|
+
setActiveViewport(uiViewports.current.width);
|
|
8162
|
+
}, [uiViewports.current]);
|
|
8163
|
+
const [isExpanded, setIsExpanded] = useState22(false);
|
|
8164
|
+
return /* @__PURE__ */ jsxs20(
|
|
8165
|
+
"div",
|
|
8166
|
+
{
|
|
8167
|
+
className: getClassName31({ isExpanded, fullScreen }),
|
|
8168
|
+
suppressHydrationWarning: true,
|
|
8169
|
+
children: [
|
|
8170
|
+
/* @__PURE__ */ jsx44("div", { className: getClassName31("actions"), children: /* @__PURE__ */ jsxs20("div", { className: getClassName31("actionsInner"), children: [
|
|
8171
|
+
viewports.map((viewport, i) => /* @__PURE__ */ jsx44(
|
|
8172
|
+
ActionButton,
|
|
8173
|
+
{
|
|
8174
|
+
title: viewport.label ? `Switch to ${viewport.label} viewport` : "Switch viewport",
|
|
8175
|
+
onClick: () => {
|
|
8176
|
+
setActiveViewport(viewport.width);
|
|
8177
|
+
onViewportChange(viewport);
|
|
8178
|
+
},
|
|
8179
|
+
isActive: activeViewport === viewport.width,
|
|
8180
|
+
children: typeof viewport.icon === "string" ? icons[viewport.icon] || viewport.icon : viewport.icon || icons.Smartphone
|
|
8181
|
+
},
|
|
8182
|
+
i
|
|
8183
|
+
)),
|
|
8184
|
+
/* @__PURE__ */ jsx44("div", { className: getClassName31("divider") }),
|
|
8185
|
+
/* @__PURE__ */ jsx44(
|
|
8186
|
+
ActionButton,
|
|
8187
|
+
{
|
|
8188
|
+
title: "Zoom viewport out",
|
|
8189
|
+
disabled: zoom <= ((_a = zoomOptions[0]) == null ? void 0 : _a.value),
|
|
8190
|
+
onClick: (e) => {
|
|
8191
|
+
e.stopPropagation();
|
|
8192
|
+
onZoom(
|
|
8193
|
+
zoomOptions[Math.max(
|
|
8194
|
+
zoomOptions.findIndex((option) => option.value === zoom) - 1,
|
|
8195
|
+
0
|
|
8196
|
+
)].value
|
|
8197
|
+
);
|
|
8198
|
+
},
|
|
8199
|
+
children: /* @__PURE__ */ jsx44(ZoomOut, { size: 16 })
|
|
8200
|
+
}
|
|
8201
|
+
),
|
|
8202
|
+
/* @__PURE__ */ jsx44(
|
|
8203
|
+
ActionButton,
|
|
8204
|
+
{
|
|
8205
|
+
title: "Zoom viewport in",
|
|
8206
|
+
disabled: zoom >= ((_b = zoomOptions[zoomOptions.length - 1]) == null ? void 0 : _b.value),
|
|
8207
|
+
onClick: (e) => {
|
|
8208
|
+
e.stopPropagation();
|
|
8209
|
+
onZoom(
|
|
8210
|
+
zoomOptions[Math.min(
|
|
8211
|
+
zoomOptions.findIndex((option) => option.value === zoom) + 1,
|
|
8212
|
+
zoomOptions.length - 1
|
|
8213
|
+
)].value
|
|
8214
|
+
);
|
|
8215
|
+
},
|
|
8216
|
+
children: /* @__PURE__ */ jsx44(ZoomIn, { size: 16 })
|
|
8217
|
+
}
|
|
8218
|
+
),
|
|
8219
|
+
/* @__PURE__ */ jsxs20("div", { className: getClassName31("zoom"), children: [
|
|
8220
|
+
/* @__PURE__ */ jsx44("div", { className: getClassName31("divider") }),
|
|
8221
|
+
/* @__PURE__ */ jsx44(
|
|
8222
|
+
"select",
|
|
8223
|
+
{
|
|
8224
|
+
className: getClassName31("zoomSelect"),
|
|
8225
|
+
value: zoom.toString(),
|
|
8226
|
+
onClick: (e) => {
|
|
8227
|
+
e.stopPropagation();
|
|
8228
|
+
},
|
|
8229
|
+
onChange: (e) => {
|
|
8230
|
+
onZoom(parseFloat(e.currentTarget.value));
|
|
8231
|
+
},
|
|
8232
|
+
children: zoomOptions.map((option) => /* @__PURE__ */ jsx44(
|
|
8233
|
+
"option",
|
|
8234
|
+
{
|
|
8235
|
+
value: option.value,
|
|
8236
|
+
label: option.label
|
|
8237
|
+
},
|
|
8238
|
+
option.label
|
|
8239
|
+
))
|
|
8240
|
+
}
|
|
8241
|
+
)
|
|
8242
|
+
] })
|
|
8243
|
+
] }) }),
|
|
8244
|
+
/* @__PURE__ */ jsx44(
|
|
8245
|
+
"button",
|
|
8246
|
+
{
|
|
8247
|
+
className: getClassName31("toggleButton"),
|
|
8248
|
+
title: "Toggle viewport menu",
|
|
8249
|
+
onClick: () => setIsExpanded((s) => !s),
|
|
8250
|
+
children: isExpanded ? /* @__PURE__ */ jsx44(X, { size: 16 }) : /* @__PURE__ */ jsx44(Monitor, { size: 16 })
|
|
8251
|
+
}
|
|
8252
|
+
)
|
|
8253
|
+
]
|
|
8254
|
+
}
|
|
8098
8255
|
);
|
|
8099
|
-
useHotkey({ delete: true }, deleteSelectedComponent);
|
|
8100
|
-
useHotkey({ backspace: true }, deleteSelectedComponent);
|
|
8101
8256
|
};
|
|
8102
8257
|
|
|
8103
|
-
// components/Puck/
|
|
8104
|
-
var import_fast_deep_equal = __toESM(require_fast_deep_equal());
|
|
8105
|
-
|
|
8106
|
-
// components/Puck/components/Header/index.tsx
|
|
8258
|
+
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Canvas/styles.module.css#css-module
|
|
8107
8259
|
init_react_import();
|
|
8108
|
-
|
|
8260
|
+
var styles_module_default27 = { "PuckCanvas": "_PuckCanvas_t6s9b_1", "PuckCanvas-controls": "_PuckCanvas-controls_t6s9b_17", "PuckCanvas--fullScreen": "_PuckCanvas--fullScreen_t6s9b_22", "PuckCanvas-inner": "_PuckCanvas-inner_t6s9b_33", "PuckCanvas-root": "_PuckCanvas-root_t6s9b_42", "PuckCanvas--ready": "_PuckCanvas--ready_t6s9b_67", "PuckCanvas-loader": "_PuckCanvas-loader_t6s9b_72", "PuckCanvas--showLoader": "_PuckCanvas--showLoader_t6s9b_82" };
|
|
8109
8261
|
|
|
8110
|
-
// components/
|
|
8111
|
-
|
|
8262
|
+
// components/Puck/components/Canvas/index.tsx
|
|
8263
|
+
import { useShallow as useShallow8 } from "zustand/react/shallow";
|
|
8112
8264
|
|
|
8113
|
-
//
|
|
8265
|
+
// lib/frame-context.tsx
|
|
8114
8266
|
init_react_import();
|
|
8115
|
-
|
|
8267
|
+
import {
|
|
8268
|
+
createContext as createContext7,
|
|
8269
|
+
useContext as useContext12,
|
|
8270
|
+
useRef as useRef8,
|
|
8271
|
+
useMemo as useMemo18
|
|
8272
|
+
} from "react";
|
|
8273
|
+
import { jsx as jsx45 } from "react/jsx-runtime";
|
|
8274
|
+
var FrameContext = createContext7(null);
|
|
8275
|
+
var FrameProvider = ({
|
|
8276
|
+
children
|
|
8277
|
+
}) => {
|
|
8278
|
+
const frameRef = useRef8(null);
|
|
8279
|
+
const value = useMemo18(
|
|
8280
|
+
() => ({
|
|
8281
|
+
frameRef
|
|
8282
|
+
}),
|
|
8283
|
+
[]
|
|
8284
|
+
);
|
|
8285
|
+
return /* @__PURE__ */ jsx45(FrameContext.Provider, { value, children });
|
|
8286
|
+
};
|
|
8287
|
+
var useCanvasFrame = () => {
|
|
8288
|
+
const context = useContext12(FrameContext);
|
|
8289
|
+
if (context === null) {
|
|
8290
|
+
throw new Error("useCanvasFrame must be used within a FrameProvider");
|
|
8291
|
+
}
|
|
8292
|
+
return context;
|
|
8293
|
+
};
|
|
8116
8294
|
|
|
8117
|
-
// components/
|
|
8118
|
-
import { Fragment as
|
|
8119
|
-
var
|
|
8120
|
-
|
|
8121
|
-
|
|
8122
|
-
|
|
8123
|
-
|
|
8124
|
-
|
|
8125
|
-
const
|
|
8126
|
-
const
|
|
8127
|
-
|
|
8128
|
-
|
|
8129
|
-
|
|
8295
|
+
// components/Puck/components/Canvas/index.tsx
|
|
8296
|
+
import { Fragment as Fragment15, jsx as jsx46, jsxs as jsxs21 } from "react/jsx-runtime";
|
|
8297
|
+
var getClassName32 = get_class_name_factory_default("PuckCanvas", styles_module_default27);
|
|
8298
|
+
var ZOOM_ON_CHANGE = true;
|
|
8299
|
+
var TRANSITION_DURATION = 150;
|
|
8300
|
+
var Canvas = () => {
|
|
8301
|
+
const { frameRef } = useCanvasFrame();
|
|
8302
|
+
const resetAutoZoom = useResetAutoZoom(frameRef);
|
|
8303
|
+
const { _experimentalFullScreenCanvas } = usePropsContext();
|
|
8304
|
+
const {
|
|
8305
|
+
dispatch,
|
|
8306
|
+
overrides,
|
|
8307
|
+
setUi,
|
|
8308
|
+
zoomConfig,
|
|
8309
|
+
setZoomConfig,
|
|
8310
|
+
status,
|
|
8311
|
+
iframe
|
|
8312
|
+
} = useAppStore(
|
|
8313
|
+
useShallow8((s) => ({
|
|
8314
|
+
dispatch: s.dispatch,
|
|
8315
|
+
overrides: s.overrides,
|
|
8316
|
+
setUi: s.setUi,
|
|
8317
|
+
zoomConfig: s.zoomConfig,
|
|
8318
|
+
setZoomConfig: s.setZoomConfig,
|
|
8319
|
+
status: s.status,
|
|
8320
|
+
iframe: s.iframe
|
|
8321
|
+
}))
|
|
8322
|
+
);
|
|
8323
|
+
const {
|
|
8324
|
+
leftSideBarVisible,
|
|
8325
|
+
rightSideBarVisible,
|
|
8326
|
+
leftSideBarWidth,
|
|
8327
|
+
rightSideBarWidth,
|
|
8328
|
+
viewports
|
|
8329
|
+
} = useAppStore(
|
|
8330
|
+
useShallow8((s) => ({
|
|
8331
|
+
leftSideBarVisible: s.state.ui.leftSideBarVisible,
|
|
8332
|
+
rightSideBarVisible: s.state.ui.rightSideBarVisible,
|
|
8333
|
+
leftSideBarWidth: s.state.ui.leftSideBarWidth,
|
|
8334
|
+
rightSideBarWidth: s.state.ui.rightSideBarWidth,
|
|
8335
|
+
viewports: s.state.ui.viewports
|
|
8336
|
+
}))
|
|
8337
|
+
);
|
|
8338
|
+
const [showTransition, setShowTransition] = useState23(false);
|
|
8339
|
+
const isResizingRef = useRef9(false);
|
|
8340
|
+
const defaultRender = useMemo19(() => {
|
|
8341
|
+
const PuckDefault = ({ children }) => /* @__PURE__ */ jsx46(Fragment15, { children });
|
|
8342
|
+
return PuckDefault;
|
|
8343
|
+
}, []);
|
|
8344
|
+
const CustomPreview = useMemo19(
|
|
8345
|
+
() => overrides.preview || defaultRender,
|
|
8346
|
+
[overrides]
|
|
8347
|
+
);
|
|
8348
|
+
const getFrameDimensions = useCallback17(() => {
|
|
8349
|
+
if (frameRef.current) {
|
|
8350
|
+
const frame = frameRef.current;
|
|
8351
|
+
const box = getBox(frame);
|
|
8352
|
+
return { width: box.contentBox.width, height: box.contentBox.height };
|
|
8353
|
+
}
|
|
8354
|
+
return { width: 0, height: 0 };
|
|
8355
|
+
}, [frameRef]);
|
|
8356
|
+
useEffect26(() => {
|
|
8357
|
+
resetAutoZoom();
|
|
8358
|
+
}, [
|
|
8359
|
+
frameRef,
|
|
8360
|
+
leftSideBarVisible,
|
|
8361
|
+
rightSideBarVisible,
|
|
8362
|
+
leftSideBarWidth,
|
|
8363
|
+
rightSideBarWidth,
|
|
8364
|
+
viewports
|
|
8365
|
+
]);
|
|
8366
|
+
useEffect26(() => {
|
|
8367
|
+
const { height: frameHeight } = getFrameDimensions();
|
|
8368
|
+
if (viewports.current.height === "auto") {
|
|
8369
|
+
setZoomConfig(__spreadProps(__spreadValues({}, zoomConfig), {
|
|
8370
|
+
rootHeight: frameHeight / zoomConfig.zoom
|
|
8371
|
+
}));
|
|
8372
|
+
}
|
|
8373
|
+
}, [zoomConfig.zoom, getFrameDimensions, setZoomConfig]);
|
|
8374
|
+
useEffect26(() => {
|
|
8375
|
+
if (ZOOM_ON_CHANGE) {
|
|
8376
|
+
resetAutoZoom();
|
|
8377
|
+
}
|
|
8378
|
+
}, [viewports.current.width, viewports]);
|
|
8379
|
+
useEffect26(() => {
|
|
8380
|
+
if (!frameRef.current) return;
|
|
8381
|
+
const resizeObserver = new ResizeObserver(() => {
|
|
8382
|
+
if (!isResizingRef.current) {
|
|
8383
|
+
resetAutoZoom();
|
|
8384
|
+
}
|
|
8385
|
+
});
|
|
8386
|
+
resizeObserver.observe(frameRef.current);
|
|
8387
|
+
return () => {
|
|
8388
|
+
resizeObserver.disconnect();
|
|
8389
|
+
};
|
|
8390
|
+
}, [frameRef.current]);
|
|
8391
|
+
const [showLoader, setShowLoader] = useState23(false);
|
|
8392
|
+
useEffect26(() => {
|
|
8393
|
+
setTimeout(() => {
|
|
8394
|
+
setShowLoader(true);
|
|
8395
|
+
}, 500);
|
|
8396
|
+
}, []);
|
|
8397
|
+
return /* @__PURE__ */ jsxs21(
|
|
8130
8398
|
"div",
|
|
8131
8399
|
{
|
|
8132
|
-
className:
|
|
8133
|
-
|
|
8134
|
-
|
|
8135
|
-
|
|
8136
|
-
|
|
8137
|
-
|
|
8138
|
-
|
|
8139
|
-
if (
|
|
8140
|
-
|
|
8400
|
+
className: getClassName32({
|
|
8401
|
+
ready: status === "READY" || !iframe.enabled || !iframe.waitForStyles,
|
|
8402
|
+
showLoader,
|
|
8403
|
+
fullScreen: _experimentalFullScreenCanvas
|
|
8404
|
+
}),
|
|
8405
|
+
onClick: (e) => {
|
|
8406
|
+
const el = e.target;
|
|
8407
|
+
if (!el.hasAttribute("data-puck-component") && !el.hasAttribute("data-puck-dropzone")) {
|
|
8408
|
+
dispatch({
|
|
8409
|
+
type: "setUi",
|
|
8410
|
+
ui: { itemSelector: null },
|
|
8411
|
+
recordHistory: true
|
|
8412
|
+
});
|
|
8141
8413
|
}
|
|
8142
8414
|
},
|
|
8143
|
-
children:
|
|
8144
|
-
/* @__PURE__ */
|
|
8145
|
-
|
|
8146
|
-
|
|
8147
|
-
|
|
8148
|
-
|
|
8149
|
-
|
|
8150
|
-
|
|
8151
|
-
|
|
8152
|
-
|
|
8415
|
+
children: [
|
|
8416
|
+
viewports.controlsVisible && iframe.enabled && /* @__PURE__ */ jsx46("div", { className: getClassName32("controls"), children: /* @__PURE__ */ jsx46(
|
|
8417
|
+
ViewportControls,
|
|
8418
|
+
{
|
|
8419
|
+
fullScreen: _experimentalFullScreenCanvas,
|
|
8420
|
+
autoZoom: zoomConfig.autoZoom,
|
|
8421
|
+
zoom: zoomConfig.zoom,
|
|
8422
|
+
onViewportChange: (viewport) => {
|
|
8423
|
+
setShowTransition(true);
|
|
8424
|
+
isResizingRef.current = true;
|
|
8425
|
+
const uiViewport = __spreadProps(__spreadValues({}, viewport), {
|
|
8426
|
+
height: viewport.height || "auto",
|
|
8427
|
+
zoom: zoomConfig.zoom
|
|
8428
|
+
});
|
|
8429
|
+
const newUi = {
|
|
8430
|
+
viewports: __spreadProps(__spreadValues({}, viewports), { current: uiViewport })
|
|
8431
|
+
};
|
|
8432
|
+
setUi(newUi);
|
|
8433
|
+
if (ZOOM_ON_CHANGE) {
|
|
8434
|
+
resetAutoZoom({
|
|
8435
|
+
viewports: __spreadProps(__spreadValues({}, viewports), { current: uiViewport })
|
|
8436
|
+
});
|
|
8437
|
+
}
|
|
8438
|
+
},
|
|
8439
|
+
onZoom: (zoom) => {
|
|
8440
|
+
setShowTransition(true);
|
|
8441
|
+
isResizingRef.current = true;
|
|
8442
|
+
setZoomConfig(__spreadProps(__spreadValues({}, zoomConfig), { zoom }));
|
|
8153
8443
|
}
|
|
8154
|
-
|
|
8155
|
-
|
|
8156
|
-
|
|
8444
|
+
}
|
|
8445
|
+
) }),
|
|
8446
|
+
/* @__PURE__ */ jsxs21("div", { className: getClassName32("inner"), ref: frameRef, children: [
|
|
8447
|
+
/* @__PURE__ */ jsx46(
|
|
8448
|
+
"div",
|
|
8157
8449
|
{
|
|
8158
|
-
|
|
8159
|
-
|
|
8160
|
-
|
|
8161
|
-
|
|
8162
|
-
|
|
8450
|
+
className: getClassName32("root"),
|
|
8451
|
+
style: {
|
|
8452
|
+
width: iframe.enabled ? viewports.current.width : "100%",
|
|
8453
|
+
height: zoomConfig.rootHeight,
|
|
8454
|
+
transform: iframe.enabled ? `scale(${zoomConfig.zoom})` : void 0,
|
|
8455
|
+
transition: showTransition ? `width ${TRANSITION_DURATION}ms ease-out, height ${TRANSITION_DURATION}ms ease-out, transform ${TRANSITION_DURATION}ms ease-out` : "",
|
|
8456
|
+
overflow: iframe.enabled ? void 0 : "auto"
|
|
8457
|
+
},
|
|
8458
|
+
suppressHydrationWarning: true,
|
|
8459
|
+
id: "puck-canvas-root",
|
|
8460
|
+
onTransitionEnd: () => {
|
|
8461
|
+
setShowTransition(false);
|
|
8462
|
+
isResizingRef.current = false;
|
|
8463
|
+
},
|
|
8464
|
+
children: /* @__PURE__ */ jsx46(CustomPreview, { children: /* @__PURE__ */ jsx46(Preview2, {}) })
|
|
8163
8465
|
}
|
|
8164
|
-
)
|
|
8165
|
-
|
|
8166
|
-
|
|
8167
|
-
]
|
|
8466
|
+
),
|
|
8467
|
+
/* @__PURE__ */ jsx46("div", { className: getClassName32("loader"), children: /* @__PURE__ */ jsx46(Loader, { size: 24 }) })
|
|
8468
|
+
] })
|
|
8469
|
+
]
|
|
8168
8470
|
}
|
|
8169
8471
|
);
|
|
8170
|
-
}
|
|
8472
|
+
};
|
|
8171
8473
|
|
|
8172
|
-
//
|
|
8474
|
+
// lib/use-sidebar-resize.ts
|
|
8173
8475
|
init_react_import();
|
|
8174
|
-
|
|
8175
|
-
|
|
8176
|
-
|
|
8177
|
-
|
|
8178
|
-
|
|
8179
|
-
|
|
8180
|
-
const {
|
|
8181
|
-
onPublish,
|
|
8182
|
-
renderHeader,
|
|
8183
|
-
renderHeaderActions,
|
|
8184
|
-
headerTitle,
|
|
8185
|
-
headerPath,
|
|
8186
|
-
iframe: _iframe
|
|
8187
|
-
} = usePropsContext();
|
|
8188
|
-
const dispatch = useAppStore((s) => s.dispatch);
|
|
8189
|
-
const appStore = useAppStoreApi();
|
|
8190
|
-
const defaultHeaderRender = useMemo19(() => {
|
|
8191
|
-
if (renderHeader) {
|
|
8192
|
-
console.warn(
|
|
8193
|
-
"`renderHeader` is deprecated. Please use `overrides.header` and the `usePuck` hook instead"
|
|
8194
|
-
);
|
|
8195
|
-
const RenderHeader = (_a) => {
|
|
8196
|
-
var _b = _a, { actions } = _b, props = __objRest(_b, ["actions"]);
|
|
8197
|
-
const Comp = renderHeader;
|
|
8198
|
-
const appState = useAppStore((s) => s.state);
|
|
8199
|
-
return /* @__PURE__ */ jsx42(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState, children: actions }));
|
|
8200
|
-
};
|
|
8201
|
-
return RenderHeader;
|
|
8202
|
-
}
|
|
8203
|
-
return DefaultOverride;
|
|
8204
|
-
}, [renderHeader]);
|
|
8205
|
-
const defaultHeaderActionsRender = useMemo19(() => {
|
|
8206
|
-
if (renderHeaderActions) {
|
|
8207
|
-
console.warn(
|
|
8208
|
-
"`renderHeaderActions` is deprecated. Please use `overrides.headerActions` and the `usePuck` hook instead."
|
|
8209
|
-
);
|
|
8210
|
-
const RenderHeader = (props) => {
|
|
8211
|
-
const Comp = renderHeaderActions;
|
|
8212
|
-
const appState = useAppStore((s) => s.state);
|
|
8213
|
-
return /* @__PURE__ */ jsx42(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState }));
|
|
8214
|
-
};
|
|
8215
|
-
return RenderHeader;
|
|
8216
|
-
}
|
|
8217
|
-
return DefaultOverride;
|
|
8218
|
-
}, [renderHeaderActions]);
|
|
8219
|
-
const CustomHeader = useAppStore(
|
|
8220
|
-
(s) => s.overrides.header || defaultHeaderRender
|
|
8221
|
-
);
|
|
8222
|
-
const CustomHeaderActions = useAppStore(
|
|
8223
|
-
(s) => s.overrides.headerActions || defaultHeaderActionsRender
|
|
8224
|
-
);
|
|
8225
|
-
const [menuOpen, setMenuOpen] = useState23(false);
|
|
8226
|
-
const rootTitle = useAppStore((s) => {
|
|
8227
|
-
var _a, _b;
|
|
8228
|
-
const rootData = (_a = s.state.indexes.nodes["root"]) == null ? void 0 : _a.data;
|
|
8229
|
-
return (_b = rootData.props.title) != null ? _b : "";
|
|
8230
|
-
});
|
|
8231
|
-
const leftSideBarVisible = useAppStore((s) => s.state.ui.leftSideBarVisible);
|
|
8232
|
-
const rightSideBarVisible = useAppStore(
|
|
8233
|
-
(s) => s.state.ui.rightSideBarVisible
|
|
8234
|
-
);
|
|
8235
|
-
const toggleSidebars = useCallback18(
|
|
8236
|
-
(sidebar) => {
|
|
8237
|
-
const widerViewport = window.matchMedia("(min-width: 638px)").matches;
|
|
8238
|
-
const sideBarVisible = sidebar === "left" ? leftSideBarVisible : rightSideBarVisible;
|
|
8239
|
-
const oppositeSideBar = sidebar === "left" ? "rightSideBarVisible" : "leftSideBarVisible";
|
|
8240
|
-
dispatch({
|
|
8241
|
-
type: "setUi",
|
|
8242
|
-
ui: __spreadValues({
|
|
8243
|
-
[`${sidebar}SideBarVisible`]: !sideBarVisible
|
|
8244
|
-
}, !widerViewport ? { [oppositeSideBar]: false } : {})
|
|
8245
|
-
});
|
|
8246
|
-
},
|
|
8247
|
-
[dispatch, leftSideBarVisible, rightSideBarVisible]
|
|
8476
|
+
import { useCallback as useCallback18, useEffect as useEffect27, useRef as useRef10, useState as useState24 } from "react";
|
|
8477
|
+
function useSidebarResize(position, dispatch) {
|
|
8478
|
+
const [width, setWidth] = useState24(null);
|
|
8479
|
+
const sidebarRef = useRef10(null);
|
|
8480
|
+
const storeWidth = useAppStore(
|
|
8481
|
+
(s) => position === "left" ? s.state.ui.leftSideBarWidth : s.state.ui.rightSideBarWidth
|
|
8248
8482
|
);
|
|
8249
|
-
|
|
8250
|
-
|
|
8251
|
-
|
|
8252
|
-
|
|
8253
|
-
|
|
8254
|
-
|
|
8255
|
-
|
|
8256
|
-
|
|
8257
|
-
|
|
8258
|
-
|
|
8259
|
-
|
|
8260
|
-
|
|
8261
|
-
|
|
8262
|
-
|
|
8263
|
-
|
|
8264
|
-
|
|
8265
|
-
{
|
|
8266
|
-
className: getClassName28({ leftSideBarVisible, rightSideBarVisible }),
|
|
8267
|
-
children: /* @__PURE__ */ jsxs19("div", { className: getClassName28("inner"), children: [
|
|
8268
|
-
/* @__PURE__ */ jsxs19("div", { className: getClassName28("toggle"), children: [
|
|
8269
|
-
/* @__PURE__ */ jsx42("div", { className: getClassName28("leftSideBarToggle"), children: /* @__PURE__ */ jsx42(
|
|
8270
|
-
IconButton,
|
|
8271
|
-
{
|
|
8272
|
-
type: "button",
|
|
8273
|
-
onClick: () => {
|
|
8274
|
-
toggleSidebars("left");
|
|
8275
|
-
},
|
|
8276
|
-
title: "Toggle left sidebar",
|
|
8277
|
-
children: /* @__PURE__ */ jsx42(PanelLeft, { focusable: "false" })
|
|
8278
|
-
}
|
|
8279
|
-
) }),
|
|
8280
|
-
/* @__PURE__ */ jsx42("div", { className: getClassName28("rightSideBarToggle"), children: /* @__PURE__ */ jsx42(
|
|
8281
|
-
IconButton,
|
|
8282
|
-
{
|
|
8283
|
-
type: "button",
|
|
8284
|
-
onClick: () => {
|
|
8285
|
-
toggleSidebars("right");
|
|
8286
|
-
},
|
|
8287
|
-
title: "Toggle right sidebar",
|
|
8288
|
-
children: /* @__PURE__ */ jsx42(PanelRight, { focusable: "false" })
|
|
8289
|
-
}
|
|
8290
|
-
) })
|
|
8291
|
-
] }),
|
|
8292
|
-
/* @__PURE__ */ jsx42("div", { className: getClassName28("title"), children: /* @__PURE__ */ jsxs19(Heading, { rank: "2", size: "xs", children: [
|
|
8293
|
-
headerTitle || rootTitle || "Page",
|
|
8294
|
-
headerPath && /* @__PURE__ */ jsxs19(Fragment15, { children: [
|
|
8295
|
-
" ",
|
|
8296
|
-
/* @__PURE__ */ jsx42("code", { className: getClassName28("path"), children: headerPath })
|
|
8297
|
-
] })
|
|
8298
|
-
] }) }),
|
|
8299
|
-
/* @__PURE__ */ jsxs19("div", { className: getClassName28("tools"), children: [
|
|
8300
|
-
/* @__PURE__ */ jsx42("div", { className: getClassName28("menuButton"), children: /* @__PURE__ */ jsx42(
|
|
8301
|
-
IconButton,
|
|
8302
|
-
{
|
|
8303
|
-
type: "button",
|
|
8304
|
-
onClick: () => {
|
|
8305
|
-
return setMenuOpen(!menuOpen);
|
|
8306
|
-
},
|
|
8307
|
-
title: "Toggle menu bar",
|
|
8308
|
-
children: menuOpen ? /* @__PURE__ */ jsx42(ChevronUp, { focusable: "false" }) : /* @__PURE__ */ jsx42(ChevronDown, { focusable: "false" })
|
|
8309
|
-
}
|
|
8310
|
-
) }),
|
|
8311
|
-
/* @__PURE__ */ jsx42(
|
|
8312
|
-
MenuBar,
|
|
8313
|
-
{
|
|
8314
|
-
dispatch,
|
|
8315
|
-
onPublish,
|
|
8316
|
-
menuOpen,
|
|
8317
|
-
renderHeaderActions: () => /* @__PURE__ */ jsx42(CustomHeaderActions, { children: /* @__PURE__ */ jsx42(
|
|
8318
|
-
Button,
|
|
8319
|
-
{
|
|
8320
|
-
onClick: () => {
|
|
8321
|
-
const data = appStore.getState().state.data;
|
|
8322
|
-
onPublish && onPublish(data);
|
|
8323
|
-
},
|
|
8324
|
-
icon: /* @__PURE__ */ jsx42(Globe, { size: "14px" }),
|
|
8325
|
-
children: "Publish"
|
|
8326
|
-
}
|
|
8327
|
-
) }),
|
|
8328
|
-
setMenuOpen
|
|
8329
|
-
}
|
|
8330
|
-
)
|
|
8331
|
-
] })
|
|
8332
|
-
] })
|
|
8483
|
+
useEffect27(() => {
|
|
8484
|
+
if (typeof window !== "undefined" && !storeWidth) {
|
|
8485
|
+
try {
|
|
8486
|
+
const savedWidths = localStorage.getItem("puck-sidebar-widths");
|
|
8487
|
+
if (savedWidths) {
|
|
8488
|
+
const widths = JSON.parse(savedWidths);
|
|
8489
|
+
const savedWidth = widths[position];
|
|
8490
|
+
const key = position === "left" ? "leftSideBarWidth" : "rightSideBarWidth";
|
|
8491
|
+
if (savedWidth) {
|
|
8492
|
+
dispatch({
|
|
8493
|
+
type: "setUi",
|
|
8494
|
+
ui: {
|
|
8495
|
+
[key]: savedWidth
|
|
8496
|
+
}
|
|
8497
|
+
});
|
|
8498
|
+
}
|
|
8333
8499
|
}
|
|
8334
|
-
)
|
|
8500
|
+
} catch (error) {
|
|
8501
|
+
console.error(
|
|
8502
|
+
`Failed to load ${position} sidebar width from localStorage`,
|
|
8503
|
+
error
|
|
8504
|
+
);
|
|
8505
|
+
}
|
|
8506
|
+
}
|
|
8507
|
+
}, [dispatch, position, storeWidth]);
|
|
8508
|
+
useEffect27(() => {
|
|
8509
|
+
if (storeWidth !== void 0) {
|
|
8510
|
+
setWidth(storeWidth);
|
|
8335
8511
|
}
|
|
8512
|
+
}, [storeWidth]);
|
|
8513
|
+
const handleResizeEnd = useCallback18(
|
|
8514
|
+
(width2) => {
|
|
8515
|
+
dispatch({
|
|
8516
|
+
type: "setUi",
|
|
8517
|
+
ui: {
|
|
8518
|
+
[position === "left" ? "leftSideBarWidth" : "rightSideBarWidth"]: width2
|
|
8519
|
+
}
|
|
8520
|
+
});
|
|
8521
|
+
let widths = {};
|
|
8522
|
+
try {
|
|
8523
|
+
const savedWidths = localStorage.getItem("puck-sidebar-widths");
|
|
8524
|
+
widths = savedWidths ? JSON.parse(savedWidths) : {};
|
|
8525
|
+
} catch (error) {
|
|
8526
|
+
console.error(
|
|
8527
|
+
`Failed to save ${position} sidebar width to localStorage`,
|
|
8528
|
+
error
|
|
8529
|
+
);
|
|
8530
|
+
} finally {
|
|
8531
|
+
localStorage.setItem(
|
|
8532
|
+
"puck-sidebar-widths",
|
|
8533
|
+
JSON.stringify(__spreadProps(__spreadValues({}, widths), {
|
|
8534
|
+
[position]: width2
|
|
8535
|
+
}))
|
|
8536
|
+
);
|
|
8537
|
+
}
|
|
8538
|
+
window.dispatchEvent(
|
|
8539
|
+
new CustomEvent("viewportchange", {
|
|
8540
|
+
bubbles: true,
|
|
8541
|
+
cancelable: false
|
|
8542
|
+
})
|
|
8543
|
+
);
|
|
8544
|
+
},
|
|
8545
|
+
[dispatch, position]
|
|
8336
8546
|
);
|
|
8337
|
-
|
|
8338
|
-
|
|
8547
|
+
return {
|
|
8548
|
+
width,
|
|
8549
|
+
setWidth,
|
|
8550
|
+
sidebarRef,
|
|
8551
|
+
handleResizeEnd
|
|
8552
|
+
};
|
|
8553
|
+
}
|
|
8339
8554
|
|
|
8340
8555
|
// components/Puck/components/Sidebar/index.tsx
|
|
8341
8556
|
init_react_import();
|
|
8342
8557
|
|
|
8343
8558
|
// components/Puck/components/ResizeHandle/index.tsx
|
|
8344
8559
|
init_react_import();
|
|
8345
|
-
import { useCallback as useCallback19, useRef as
|
|
8560
|
+
import { useCallback as useCallback19, useRef as useRef11 } from "react";
|
|
8346
8561
|
|
|
8347
8562
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/ResizeHandle/styles.module.css#css-module
|
|
8348
8563
|
init_react_import();
|
|
8349
|
-
var
|
|
8564
|
+
var styles_module_default28 = { "ResizeHandle": "_ResizeHandle_144bf_2", "ResizeHandle--left": "_ResizeHandle--left_144bf_16", "ResizeHandle--right": "_ResizeHandle--right_144bf_20" };
|
|
8350
8565
|
|
|
8351
8566
|
// components/Puck/components/ResizeHandle/index.tsx
|
|
8352
|
-
import { jsx as
|
|
8353
|
-
var
|
|
8567
|
+
import { jsx as jsx47 } from "react/jsx-runtime";
|
|
8568
|
+
var getClassName33 = get_class_name_factory_default("ResizeHandle", styles_module_default28);
|
|
8354
8569
|
var ResizeHandle = ({
|
|
8355
8570
|
position,
|
|
8356
8571
|
sidebarRef,
|
|
@@ -8359,10 +8574,10 @@ var ResizeHandle = ({
|
|
|
8359
8574
|
}) => {
|
|
8360
8575
|
const { frameRef } = useCanvasFrame();
|
|
8361
8576
|
const resetAutoZoom = useResetAutoZoom(frameRef);
|
|
8362
|
-
const handleRef =
|
|
8363
|
-
const isDragging =
|
|
8364
|
-
const startX =
|
|
8365
|
-
const startWidth =
|
|
8577
|
+
const handleRef = useRef11(null);
|
|
8578
|
+
const isDragging = useRef11(false);
|
|
8579
|
+
const startX = useRef11(0);
|
|
8580
|
+
const startWidth = useRef11(0);
|
|
8366
8581
|
const handleMouseMove = useCallback19(
|
|
8367
8582
|
(e) => {
|
|
8368
8583
|
if (!isDragging.current) return;
|
|
@@ -8408,11 +8623,11 @@ var ResizeHandle = ({
|
|
|
8408
8623
|
},
|
|
8409
8624
|
[position, handleMouseMove, handleMouseUp]
|
|
8410
8625
|
);
|
|
8411
|
-
return /* @__PURE__ */
|
|
8626
|
+
return /* @__PURE__ */ jsx47(
|
|
8412
8627
|
"div",
|
|
8413
8628
|
{
|
|
8414
8629
|
ref: handleRef,
|
|
8415
|
-
className:
|
|
8630
|
+
className: getClassName33({ [position]: true }),
|
|
8416
8631
|
onMouseDown: handleMouseDown
|
|
8417
8632
|
}
|
|
8418
8633
|
);
|
|
@@ -8420,11 +8635,11 @@ var ResizeHandle = ({
|
|
|
8420
8635
|
|
|
8421
8636
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Sidebar/styles.module.css#css-module
|
|
8422
8637
|
init_react_import();
|
|
8423
|
-
var
|
|
8638
|
+
var styles_module_default29 = { "Sidebar": "_Sidebar_o396p_1", "Sidebar--isVisible": "_Sidebar--isVisible_o396p_9", "Sidebar--left": "_Sidebar--left_o396p_13", "Sidebar--right": "_Sidebar--right_o396p_25", "Sidebar-resizeHandle": "_Sidebar-resizeHandle_o396p_37" };
|
|
8424
8639
|
|
|
8425
8640
|
// components/Puck/components/Sidebar/index.tsx
|
|
8426
|
-
import { Fragment as Fragment16, jsx as
|
|
8427
|
-
var
|
|
8641
|
+
import { Fragment as Fragment16, jsx as jsx48, jsxs as jsxs22 } from "react/jsx-runtime";
|
|
8642
|
+
var getClassName34 = get_class_name_factory_default("Sidebar", styles_module_default29);
|
|
8428
8643
|
var Sidebar = ({
|
|
8429
8644
|
position,
|
|
8430
8645
|
sidebarRef,
|
|
@@ -8433,10 +8648,16 @@ var Sidebar = ({
|
|
|
8433
8648
|
onResizeEnd,
|
|
8434
8649
|
children
|
|
8435
8650
|
}) => {
|
|
8436
|
-
|
|
8437
|
-
|
|
8438
|
-
|
|
8439
|
-
|
|
8651
|
+
return /* @__PURE__ */ jsxs22(Fragment16, { children: [
|
|
8652
|
+
/* @__PURE__ */ jsx48(
|
|
8653
|
+
"div",
|
|
8654
|
+
{
|
|
8655
|
+
ref: sidebarRef,
|
|
8656
|
+
className: getClassName34({ [position]: true, isVisible }),
|
|
8657
|
+
children
|
|
8658
|
+
}
|
|
8659
|
+
),
|
|
8660
|
+
/* @__PURE__ */ jsx48("div", { className: `${getClassName34("resizeHandle")}`, children: /* @__PURE__ */ jsx48(
|
|
8440
8661
|
ResizeHandle,
|
|
8441
8662
|
{
|
|
8442
8663
|
position,
|
|
@@ -8448,103 +8669,364 @@ var Sidebar = ({
|
|
|
8448
8669
|
] });
|
|
8449
8670
|
};
|
|
8450
8671
|
|
|
8451
|
-
// lib/use-
|
|
8672
|
+
// lib/use-delete-hotkeys.ts
|
|
8452
8673
|
init_react_import();
|
|
8453
|
-
import { useCallback as useCallback20
|
|
8454
|
-
|
|
8455
|
-
|
|
8456
|
-
|
|
8457
|
-
|
|
8458
|
-
(
|
|
8674
|
+
import { useCallback as useCallback20 } from "react";
|
|
8675
|
+
var isElementVisible = (element) => {
|
|
8676
|
+
let current = element;
|
|
8677
|
+
while (current && current !== document.body) {
|
|
8678
|
+
const style = window.getComputedStyle(current);
|
|
8679
|
+
if (style.display === "none" || style.visibility === "hidden" || style.opacity === "0" || current.getAttribute("aria-hidden") === "true" || current.hasAttribute("hidden")) {
|
|
8680
|
+
return false;
|
|
8681
|
+
}
|
|
8682
|
+
current = current.parentElement;
|
|
8683
|
+
}
|
|
8684
|
+
return true;
|
|
8685
|
+
};
|
|
8686
|
+
var shouldBlockDeleteHotkey = (e) => {
|
|
8687
|
+
var _a;
|
|
8688
|
+
if (e == null ? void 0 : e.defaultPrevented) return true;
|
|
8689
|
+
const origin = ((_a = e == null ? void 0 : e.composedPath) == null ? void 0 : _a.call(e)[0]) || (e == null ? void 0 : e.target) || document.activeElement;
|
|
8690
|
+
if (origin instanceof HTMLElement) {
|
|
8691
|
+
const tag = origin.tagName.toLowerCase();
|
|
8692
|
+
if (tag === "input" || tag === "textarea" || tag === "select") return true;
|
|
8693
|
+
if (origin.isContentEditable) return true;
|
|
8694
|
+
const role = origin.getAttribute("role");
|
|
8695
|
+
if (role === "textbox" || role === "combobox" || role === "searchbox" || role === "listbox" || role === "grid") {
|
|
8696
|
+
return true;
|
|
8697
|
+
}
|
|
8698
|
+
}
|
|
8699
|
+
const modal = document.querySelector(
|
|
8700
|
+
'dialog[open], [aria-modal="true"], [role="dialog"], [role="alertdialog"]'
|
|
8459
8701
|
);
|
|
8460
|
-
|
|
8461
|
-
|
|
8462
|
-
|
|
8463
|
-
|
|
8464
|
-
|
|
8465
|
-
|
|
8466
|
-
|
|
8467
|
-
|
|
8468
|
-
|
|
8469
|
-
|
|
8470
|
-
|
|
8471
|
-
|
|
8472
|
-
|
|
8473
|
-
|
|
8474
|
-
|
|
8475
|
-
|
|
8702
|
+
if (modal && isElementVisible(modal)) {
|
|
8703
|
+
return true;
|
|
8704
|
+
}
|
|
8705
|
+
return false;
|
|
8706
|
+
};
|
|
8707
|
+
var useDeleteHotkeys = () => {
|
|
8708
|
+
const appStore = useAppStoreApi();
|
|
8709
|
+
const deleteSelectedComponent = useCallback20(
|
|
8710
|
+
(e) => {
|
|
8711
|
+
var _a;
|
|
8712
|
+
if (shouldBlockDeleteHotkey(e)) {
|
|
8713
|
+
return false;
|
|
8714
|
+
}
|
|
8715
|
+
const { state, dispatch, permissions, selectedItem } = appStore.getState();
|
|
8716
|
+
const sel = (_a = state.ui) == null ? void 0 : _a.itemSelector;
|
|
8717
|
+
if (!(sel == null ? void 0 : sel.zone) || !selectedItem) return true;
|
|
8718
|
+
if (!permissions.getPermissions({ item: selectedItem }).delete)
|
|
8719
|
+
return true;
|
|
8720
|
+
dispatch({
|
|
8721
|
+
type: "remove",
|
|
8722
|
+
index: sel.index,
|
|
8723
|
+
zone: sel.zone
|
|
8724
|
+
});
|
|
8725
|
+
return true;
|
|
8726
|
+
},
|
|
8727
|
+
[appStore]
|
|
8728
|
+
);
|
|
8729
|
+
useHotkey({ delete: true }, deleteSelectedComponent);
|
|
8730
|
+
useHotkey({ backspace: true }, deleteSelectedComponent);
|
|
8731
|
+
};
|
|
8732
|
+
|
|
8733
|
+
// components/Puck/components/Nav/index.tsx
|
|
8734
|
+
init_react_import();
|
|
8735
|
+
|
|
8736
|
+
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Nav/styles.module.css#css-module
|
|
8737
|
+
init_react_import();
|
|
8738
|
+
var styles_module_default30 = { "Nav": "_Nav_3nnxc_1", "Nav-list": "_Nav-list_3nnxc_5", "Nav-mobileActions": "_Nav-mobileActions_3nnxc_23", "NavItem-link": "_NavItem-link_3nnxc_38", "NavItem": "_NavItem_3nnxc_38", "NavItem-linkIcon": "_NavItem-linkIcon_3nnxc_88", "NavItem--active": "_NavItem--active_3nnxc_93", "NavItem--mobileOnly": "_NavItem--mobileOnly_3nnxc_120" };
|
|
8739
|
+
|
|
8740
|
+
// components/Puck/components/Nav/index.tsx
|
|
8741
|
+
import { jsx as jsx49, jsxs as jsxs23 } from "react/jsx-runtime";
|
|
8742
|
+
var getClassName35 = get_class_name_factory_default("Nav", styles_module_default30);
|
|
8743
|
+
var getClassNameItem3 = get_class_name_factory_default("NavItem", styles_module_default30);
|
|
8744
|
+
var MenuItem = ({
|
|
8745
|
+
label,
|
|
8746
|
+
icon,
|
|
8747
|
+
onClick,
|
|
8748
|
+
isActive,
|
|
8749
|
+
mobileOnly
|
|
8750
|
+
}) => {
|
|
8751
|
+
return /* @__PURE__ */ jsx49("li", { className: getClassNameItem3({ active: isActive, mobileOnly }), children: onClick && /* @__PURE__ */ jsxs23("div", { className: getClassNameItem3("link"), onClick, children: [
|
|
8752
|
+
icon && /* @__PURE__ */ jsx49("span", { className: getClassNameItem3("linkIcon"), children: icon }),
|
|
8753
|
+
/* @__PURE__ */ jsx49("span", { className: getClassNameItem3("linkLabel"), children: label })
|
|
8754
|
+
] }) });
|
|
8755
|
+
};
|
|
8756
|
+
var Nav = ({
|
|
8757
|
+
items,
|
|
8758
|
+
mobileActions
|
|
8759
|
+
}) => {
|
|
8760
|
+
return /* @__PURE__ */ jsxs23("nav", { className: getClassName35(), children: [
|
|
8761
|
+
/* @__PURE__ */ jsx49("ul", { className: getClassName35("list"), children: Object.entries(items).map(([key, item]) => /* @__PURE__ */ jsx49(MenuItem, __spreadValues({}, item), key)) }),
|
|
8762
|
+
mobileActions && /* @__PURE__ */ jsx49("div", { className: getClassName35("mobileActions"), children: mobileActions })
|
|
8763
|
+
] });
|
|
8764
|
+
};
|
|
8765
|
+
|
|
8766
|
+
// components/Puck/components/Layout/index.tsx
|
|
8767
|
+
import { jsx as jsx50, jsxs as jsxs24 } from "react/jsx-runtime";
|
|
8768
|
+
var getClassName36 = get_class_name_factory_default("Puck", styles_module_default22);
|
|
8769
|
+
var getLayoutClassName = get_class_name_factory_default("PuckLayout", styles_module_default22);
|
|
8770
|
+
var getPluginTabClassName = get_class_name_factory_default("PuckPluginTab", styles_module_default22);
|
|
8771
|
+
var FieldSideBar = () => {
|
|
8772
|
+
const title = useAppStore(
|
|
8773
|
+
(s) => {
|
|
8774
|
+
var _a, _b;
|
|
8775
|
+
return s.selectedItem ? (_b = (_a = s.config.components[s.selectedItem.type]) == null ? void 0 : _a["label"]) != null ? _b : s.selectedItem.type.toString() : "Page";
|
|
8776
|
+
}
|
|
8777
|
+
);
|
|
8778
|
+
return /* @__PURE__ */ jsx50(SidebarSection, { noPadding: true, noBorderTop: true, showBreadcrumbs: true, title, children: /* @__PURE__ */ jsx50(Fields, {}) });
|
|
8779
|
+
};
|
|
8780
|
+
var PluginTab = ({
|
|
8781
|
+
children,
|
|
8782
|
+
visible,
|
|
8783
|
+
mobileOnly
|
|
8784
|
+
}) => {
|
|
8785
|
+
return /* @__PURE__ */ jsx50("div", { className: getPluginTabClassName({ visible, mobileOnly }), children: /* @__PURE__ */ jsx50("div", { className: getPluginTabClassName("body"), children }) });
|
|
8786
|
+
};
|
|
8787
|
+
var Layout = ({ children }) => {
|
|
8788
|
+
const {
|
|
8789
|
+
iframe: _iframe,
|
|
8790
|
+
dnd,
|
|
8791
|
+
initialHistory: _initialHistory,
|
|
8792
|
+
plugins,
|
|
8793
|
+
height = "100dvh"
|
|
8794
|
+
} = usePropsContext();
|
|
8795
|
+
const iframe = useMemo20(
|
|
8796
|
+
() => __spreadValues({
|
|
8797
|
+
enabled: true,
|
|
8798
|
+
waitForStyles: true
|
|
8799
|
+
}, _iframe),
|
|
8800
|
+
[_iframe]
|
|
8801
|
+
);
|
|
8802
|
+
useInjectGlobalCss(iframe.enabled);
|
|
8803
|
+
const dispatch = useAppStore((s) => s.dispatch);
|
|
8804
|
+
const leftSideBarVisible = useAppStore((s) => s.state.ui.leftSideBarVisible);
|
|
8805
|
+
const rightSideBarVisible = useAppStore(
|
|
8806
|
+
(s) => s.state.ui.rightSideBarVisible
|
|
8807
|
+
);
|
|
8808
|
+
const instanceId = useAppStore((s) => s.instanceId);
|
|
8809
|
+
const {
|
|
8810
|
+
width: leftWidth,
|
|
8811
|
+
setWidth: setLeftWidth,
|
|
8812
|
+
sidebarRef: leftSidebarRef,
|
|
8813
|
+
handleResizeEnd: handleLeftSidebarResizeEnd
|
|
8814
|
+
} = useSidebarResize("left", dispatch);
|
|
8815
|
+
const {
|
|
8816
|
+
width: rightWidth,
|
|
8817
|
+
setWidth: setRightWidth,
|
|
8818
|
+
sidebarRef: rightSidebarRef,
|
|
8819
|
+
handleResizeEnd: handleRightSidebarResizeEnd
|
|
8820
|
+
} = useSidebarResize("right", dispatch);
|
|
8821
|
+
useEffect29(() => {
|
|
8822
|
+
if (!window.matchMedia("(min-width: 638px)").matches) {
|
|
8823
|
+
dispatch({
|
|
8824
|
+
type: "setUi",
|
|
8825
|
+
ui: {
|
|
8826
|
+
leftSideBarVisible: false,
|
|
8827
|
+
rightSideBarVisible: false
|
|
8828
|
+
}
|
|
8829
|
+
});
|
|
8830
|
+
}
|
|
8831
|
+
const handleResize = () => {
|
|
8832
|
+
if (!window.matchMedia("(min-width: 638px)").matches) {
|
|
8833
|
+
dispatch({
|
|
8834
|
+
type: "setUi",
|
|
8835
|
+
ui: (ui) => __spreadValues(__spreadValues({}, ui), ui.rightSideBarVisible ? { leftSideBarVisible: false } : {})
|
|
8836
|
+
});
|
|
8837
|
+
}
|
|
8838
|
+
};
|
|
8839
|
+
window.addEventListener("resize", handleResize);
|
|
8840
|
+
return () => {
|
|
8841
|
+
window.removeEventListener("resize", handleResize);
|
|
8842
|
+
};
|
|
8843
|
+
}, []);
|
|
8844
|
+
const overrides = useAppStore((s) => s.overrides);
|
|
8845
|
+
const CustomPuck = useMemo20(
|
|
8846
|
+
() => overrides.puck || DefaultOverride,
|
|
8847
|
+
[overrides]
|
|
8848
|
+
);
|
|
8849
|
+
const [mounted, setMounted] = useState25(false);
|
|
8850
|
+
useEffect29(() => {
|
|
8851
|
+
setMounted(true);
|
|
8852
|
+
}, []);
|
|
8853
|
+
const ready = useAppStore((s) => s.status === "READY");
|
|
8854
|
+
useMonitorHotkeys();
|
|
8855
|
+
useEffect29(() => {
|
|
8856
|
+
if (ready && iframe.enabled) {
|
|
8857
|
+
const frameDoc = getFrame();
|
|
8858
|
+
if (frameDoc) {
|
|
8859
|
+
return monitorHotkeys(frameDoc);
|
|
8860
|
+
}
|
|
8861
|
+
}
|
|
8862
|
+
}, [ready, iframe.enabled]);
|
|
8863
|
+
usePreviewModeHotkeys();
|
|
8864
|
+
useDeleteHotkeys();
|
|
8865
|
+
const layoutOptions = {};
|
|
8866
|
+
if (leftWidth) {
|
|
8867
|
+
layoutOptions["--puck-user-left-side-bar-width"] = `${leftWidth}px`;
|
|
8868
|
+
}
|
|
8869
|
+
if (rightWidth) {
|
|
8870
|
+
layoutOptions["--puck-user-right-side-bar-width"] = `${rightWidth}px`;
|
|
8871
|
+
}
|
|
8872
|
+
const setUi = useAppStore((s) => s.setUi);
|
|
8873
|
+
const currentPlugin = useAppStore((s) => {
|
|
8874
|
+
var _a;
|
|
8875
|
+
return (_a = s.state.ui.plugin) == null ? void 0 : _a.current;
|
|
8876
|
+
});
|
|
8877
|
+
const appStoreApi = useAppStoreApi();
|
|
8878
|
+
const [mobilePanelHeightMode, setMobilePanelHeightMode] = useState25("toggle");
|
|
8879
|
+
const pluginItems = useMemo20(() => {
|
|
8880
|
+
const details = {};
|
|
8881
|
+
const defaultPlugins = [blocksPlugin(), outlinePlugin()];
|
|
8882
|
+
const combinedPlugins = [
|
|
8883
|
+
...defaultPlugins,
|
|
8884
|
+
...plugins != null ? plugins : []
|
|
8885
|
+
];
|
|
8886
|
+
if (!(plugins == null ? void 0 : plugins.some((p) => p.name === "fields"))) {
|
|
8887
|
+
combinedPlugins.push(fieldsPlugin());
|
|
8888
|
+
}
|
|
8889
|
+
combinedPlugins == null ? void 0 : combinedPlugins.forEach((plugin) => {
|
|
8890
|
+
var _a, _b;
|
|
8891
|
+
if (plugin.name && plugin.render) {
|
|
8892
|
+
if (details[plugin.name]) {
|
|
8893
|
+
delete details[plugin.name];
|
|
8476
8894
|
}
|
|
8477
|
-
|
|
8478
|
-
|
|
8479
|
-
|
|
8480
|
-
|
|
8481
|
-
|
|
8895
|
+
details[plugin.name] = {
|
|
8896
|
+
label: (_a = plugin.label) != null ? _a : plugin.name,
|
|
8897
|
+
icon: (_b = plugin.icon) != null ? _b : /* @__PURE__ */ jsx50(ToyBrick, {}),
|
|
8898
|
+
onClick: () => {
|
|
8899
|
+
var _a2;
|
|
8900
|
+
setMobilePanelHeightMode((_a2 = plugin.mobilePanelHeight) != null ? _a2 : "toggle");
|
|
8901
|
+
if (plugin.name === currentPlugin) {
|
|
8902
|
+
if (leftSideBarVisible) {
|
|
8903
|
+
setUi({ leftSideBarVisible: false });
|
|
8904
|
+
} else {
|
|
8905
|
+
setUi({ leftSideBarVisible: true });
|
|
8906
|
+
}
|
|
8907
|
+
} else {
|
|
8908
|
+
if (plugin.name) {
|
|
8909
|
+
setUi({
|
|
8910
|
+
plugin: { current: plugin.name },
|
|
8911
|
+
leftSideBarVisible: true
|
|
8912
|
+
});
|
|
8913
|
+
}
|
|
8914
|
+
}
|
|
8915
|
+
},
|
|
8916
|
+
isActive: leftSideBarVisible && currentPlugin === plugin.name,
|
|
8917
|
+
render: plugin.render,
|
|
8918
|
+
mobileOnly: plugin.mobileOnly
|
|
8919
|
+
};
|
|
8482
8920
|
}
|
|
8921
|
+
});
|
|
8922
|
+
return details;
|
|
8923
|
+
}, [plugins, currentPlugin, appStoreApi, leftSideBarVisible]);
|
|
8924
|
+
useEffect29(() => {
|
|
8925
|
+
if (!currentPlugin) {
|
|
8926
|
+
const names = Object.keys(pluginItems);
|
|
8927
|
+
setUi({ plugin: { current: names[0] } });
|
|
8483
8928
|
}
|
|
8484
|
-
}, [
|
|
8485
|
-
|
|
8486
|
-
|
|
8487
|
-
|
|
8929
|
+
}, [pluginItems, currentPlugin]);
|
|
8930
|
+
const hasDesktopFieldsPlugin = pluginItems["fields"] && pluginItems["fields"].mobileOnly === false;
|
|
8931
|
+
const mobilePanelExpanded = useAppStore(
|
|
8932
|
+
(s) => {
|
|
8933
|
+
var _a;
|
|
8934
|
+
return (_a = s.state.ui.mobilePanelExpanded) != null ? _a : false;
|
|
8488
8935
|
}
|
|
8489
|
-
}, [storeWidth]);
|
|
8490
|
-
const handleResizeEnd = useCallback20(
|
|
8491
|
-
(width2) => {
|
|
8492
|
-
dispatch({
|
|
8493
|
-
type: "setUi",
|
|
8494
|
-
ui: {
|
|
8495
|
-
[position === "left" ? "leftSideBarWidth" : "rightSideBarWidth"]: width2
|
|
8496
|
-
}
|
|
8497
|
-
});
|
|
8498
|
-
let widths = {};
|
|
8499
|
-
try {
|
|
8500
|
-
const savedWidths = localStorage.getItem("puck-sidebar-widths");
|
|
8501
|
-
widths = savedWidths ? JSON.parse(savedWidths) : {};
|
|
8502
|
-
} catch (error) {
|
|
8503
|
-
console.error(
|
|
8504
|
-
`Failed to save ${position} sidebar width to localStorage`,
|
|
8505
|
-
error
|
|
8506
|
-
);
|
|
8507
|
-
} finally {
|
|
8508
|
-
localStorage.setItem(
|
|
8509
|
-
"puck-sidebar-widths",
|
|
8510
|
-
JSON.stringify(__spreadProps(__spreadValues({}, widths), {
|
|
8511
|
-
[position]: width2
|
|
8512
|
-
}))
|
|
8513
|
-
);
|
|
8514
|
-
}
|
|
8515
|
-
window.dispatchEvent(
|
|
8516
|
-
new CustomEvent("viewportchange", {
|
|
8517
|
-
bubbles: true,
|
|
8518
|
-
cancelable: false
|
|
8519
|
-
})
|
|
8520
|
-
);
|
|
8521
|
-
},
|
|
8522
|
-
[dispatch, position]
|
|
8523
8936
|
);
|
|
8524
|
-
return
|
|
8525
|
-
|
|
8526
|
-
|
|
8527
|
-
|
|
8528
|
-
|
|
8529
|
-
|
|
8530
|
-
|
|
8531
|
-
|
|
8532
|
-
|
|
8533
|
-
|
|
8534
|
-
|
|
8535
|
-
|
|
8536
|
-
|
|
8537
|
-
|
|
8538
|
-
|
|
8539
|
-
|
|
8540
|
-
|
|
8937
|
+
return /* @__PURE__ */ jsxs24(
|
|
8938
|
+
"div",
|
|
8939
|
+
{
|
|
8940
|
+
className: `Puck ${getClassName36()}`,
|
|
8941
|
+
style: { height },
|
|
8942
|
+
id: instanceId,
|
|
8943
|
+
children: [
|
|
8944
|
+
/* @__PURE__ */ jsx50(DragDropContext, { disableAutoScroll: dnd == null ? void 0 : dnd.disableAutoScroll, children: /* @__PURE__ */ jsx50(CustomPuck, { children: children || /* @__PURE__ */ jsx50(FrameProvider, { children: /* @__PURE__ */ jsx50(
|
|
8945
|
+
"div",
|
|
8946
|
+
{
|
|
8947
|
+
className: getLayoutClassName({
|
|
8948
|
+
leftSideBarVisible,
|
|
8949
|
+
mounted,
|
|
8950
|
+
rightSideBarVisible: !hasDesktopFieldsPlugin && rightSideBarVisible,
|
|
8951
|
+
isExpanded: mobilePanelExpanded,
|
|
8952
|
+
mobilePanelHeightToggle: mobilePanelHeightMode === "toggle",
|
|
8953
|
+
mobilePanelHeightMinContent: mobilePanelHeightMode === "min-content"
|
|
8954
|
+
}),
|
|
8955
|
+
children: /* @__PURE__ */ jsxs24(
|
|
8956
|
+
"div",
|
|
8957
|
+
{
|
|
8958
|
+
className: getLayoutClassName("inner"),
|
|
8959
|
+
style: layoutOptions,
|
|
8960
|
+
children: [
|
|
8961
|
+
/* @__PURE__ */ jsx50("div", { className: getLayoutClassName("header"), children: /* @__PURE__ */ jsx50(Header, {}) }),
|
|
8962
|
+
/* @__PURE__ */ jsx50("div", { className: getLayoutClassName("nav"), children: /* @__PURE__ */ jsx50(
|
|
8963
|
+
Nav,
|
|
8964
|
+
{
|
|
8965
|
+
items: pluginItems,
|
|
8966
|
+
mobileActions: leftSideBarVisible && mobilePanelHeightMode === "toggle" && /* @__PURE__ */ jsx50(
|
|
8967
|
+
IconButton,
|
|
8968
|
+
{
|
|
8969
|
+
type: "button",
|
|
8970
|
+
title: "maximize",
|
|
8971
|
+
onClick: () => {
|
|
8972
|
+
setUi({
|
|
8973
|
+
mobilePanelExpanded: !mobilePanelExpanded
|
|
8974
|
+
});
|
|
8975
|
+
},
|
|
8976
|
+
children: mobilePanelExpanded ? /* @__PURE__ */ jsx50(Minimize2, { size: 21 }) : /* @__PURE__ */ jsx50(Maximize2, { size: 21 })
|
|
8977
|
+
}
|
|
8978
|
+
)
|
|
8979
|
+
}
|
|
8980
|
+
) }),
|
|
8981
|
+
/* @__PURE__ */ jsx50(
|
|
8982
|
+
Sidebar,
|
|
8983
|
+
{
|
|
8984
|
+
position: "left",
|
|
8985
|
+
sidebarRef: leftSidebarRef,
|
|
8986
|
+
isVisible: leftSideBarVisible,
|
|
8987
|
+
onResize: setLeftWidth,
|
|
8988
|
+
onResizeEnd: handleLeftSidebarResizeEnd,
|
|
8989
|
+
children: Object.entries(pluginItems).map(
|
|
8990
|
+
([id, { mobileOnly, render: Render2, label }]) => /* @__PURE__ */ jsx50(
|
|
8991
|
+
PluginTab,
|
|
8992
|
+
{
|
|
8993
|
+
visible: currentPlugin === id,
|
|
8994
|
+
mobileOnly,
|
|
8995
|
+
children: /* @__PURE__ */ jsx50(Render2, {})
|
|
8996
|
+
},
|
|
8997
|
+
id
|
|
8998
|
+
)
|
|
8999
|
+
)
|
|
9000
|
+
}
|
|
9001
|
+
),
|
|
9002
|
+
/* @__PURE__ */ jsx50(Canvas, {}),
|
|
9003
|
+
!hasDesktopFieldsPlugin && /* @__PURE__ */ jsx50(
|
|
9004
|
+
Sidebar,
|
|
9005
|
+
{
|
|
9006
|
+
position: "right",
|
|
9007
|
+
sidebarRef: rightSidebarRef,
|
|
9008
|
+
isVisible: rightSideBarVisible,
|
|
9009
|
+
onResize: setRightWidth,
|
|
9010
|
+
onResizeEnd: handleRightSidebarResizeEnd,
|
|
9011
|
+
children: /* @__PURE__ */ jsx50(FieldSideBar, {})
|
|
9012
|
+
}
|
|
9013
|
+
)
|
|
9014
|
+
]
|
|
9015
|
+
}
|
|
9016
|
+
)
|
|
9017
|
+
}
|
|
9018
|
+
) }) }) }),
|
|
9019
|
+
/* @__PURE__ */ jsx50("div", { id: "puck-portal-root", className: getClassName36("portal") })
|
|
9020
|
+
]
|
|
8541
9021
|
}
|
|
8542
9022
|
);
|
|
8543
|
-
return /* @__PURE__ */ jsx45(SidebarSection, { noPadding: true, noBorderTop: true, showBreadcrumbs: true, title, children: /* @__PURE__ */ jsx45(Fields, {}) });
|
|
8544
9023
|
};
|
|
9024
|
+
|
|
9025
|
+
// components/Puck/index.tsx
|
|
9026
|
+
import { jsx as jsx51 } from "react/jsx-runtime";
|
|
8545
9027
|
var propsContext = createContext8({});
|
|
8546
9028
|
function PropsProvider(props) {
|
|
8547
|
-
return /* @__PURE__ */
|
|
9029
|
+
return /* @__PURE__ */ jsx51(propsContext.Provider, { value: props, children: props.children });
|
|
8548
9030
|
}
|
|
8549
9031
|
var usePropsContext = () => useContext13(propsContext);
|
|
8550
9032
|
function PuckProvider({ children }) {
|
|
@@ -8563,15 +9045,15 @@ function PuckProvider({ children }) {
|
|
|
8563
9045
|
onAction,
|
|
8564
9046
|
fieldTransforms
|
|
8565
9047
|
} = usePropsContext();
|
|
8566
|
-
const iframe =
|
|
9048
|
+
const iframe = useMemo21(
|
|
8567
9049
|
() => __spreadValues({
|
|
8568
9050
|
enabled: true,
|
|
8569
9051
|
waitForStyles: true
|
|
8570
9052
|
}, _iframe),
|
|
8571
9053
|
[_iframe]
|
|
8572
9054
|
);
|
|
8573
|
-
const [generatedAppState] =
|
|
8574
|
-
var _a, _b, _c, _d, _e, _f, _g
|
|
9055
|
+
const [generatedAppState] = useState26(() => {
|
|
9056
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
8575
9057
|
const initial = __spreadValues(__spreadValues({}, defaultAppState.ui), initialUi);
|
|
8576
9058
|
let clientUiState = {};
|
|
8577
9059
|
if (typeof window !== "undefined") {
|
|
@@ -8582,29 +9064,39 @@ function PuckProvider({ children }) {
|
|
|
8582
9064
|
});
|
|
8583
9065
|
}
|
|
8584
9066
|
const viewportWidth = window.innerWidth;
|
|
8585
|
-
const
|
|
9067
|
+
const fullWidthViewport = Object.values(viewports).find(
|
|
9068
|
+
(v) => v.width === "100%"
|
|
9069
|
+
);
|
|
9070
|
+
const containsFullWidthViewport = !!fullWidthViewport;
|
|
9071
|
+
const viewportDifferences = Object.entries(viewports).filter(([_, value]) => value.width !== "100%").map(([key, value]) => ({
|
|
8586
9072
|
key,
|
|
8587
|
-
diff: Math.abs(
|
|
9073
|
+
diff: Math.abs(
|
|
9074
|
+
viewportWidth - (typeof value.width === "string" ? viewportWidth : value.width)
|
|
9075
|
+
),
|
|
9076
|
+
value
|
|
8588
9077
|
})).sort((a, b) => a.diff > b.diff ? 1 : -1);
|
|
8589
|
-
|
|
9078
|
+
let closestViewport = viewportDifferences[0].value;
|
|
9079
|
+
if (closestViewport.width < viewportWidth && containsFullWidthViewport) {
|
|
9080
|
+
closestViewport = fullWidthViewport;
|
|
9081
|
+
}
|
|
8590
9082
|
if (iframe.enabled) {
|
|
8591
9083
|
clientUiState = __spreadProps(__spreadValues({}, clientUiState), {
|
|
8592
9084
|
viewports: __spreadProps(__spreadValues({}, initial.viewports), {
|
|
8593
9085
|
current: __spreadProps(__spreadValues({}, initial.viewports.current), {
|
|
8594
|
-
height: ((_b = (_a = initialUi == null ? void 0 : initialUi.viewports) == null ? void 0 : _a.current) == null ? void 0 : _b.height) || (
|
|
8595
|
-
width: ((
|
|
9086
|
+
height: ((_b = (_a = initialUi == null ? void 0 : initialUi.viewports) == null ? void 0 : _a.current) == null ? void 0 : _b.height) || (closestViewport == null ? void 0 : closestViewport.height) || "auto",
|
|
9087
|
+
width: ((_d = (_c = initialUi == null ? void 0 : initialUi.viewports) == null ? void 0 : _c.current) == null ? void 0 : _d.width) || (closestViewport == null ? void 0 : closestViewport.width)
|
|
8596
9088
|
})
|
|
8597
9089
|
})
|
|
8598
9090
|
});
|
|
8599
9091
|
}
|
|
8600
9092
|
}
|
|
8601
|
-
if (Object.keys((initialData == null ? void 0 : initialData.root) || {}).length > 0 && !((
|
|
9093
|
+
if (Object.keys((initialData == null ? void 0 : initialData.root) || {}).length > 0 && !((_e = initialData == null ? void 0 : initialData.root) == null ? void 0 : _e.props)) {
|
|
8602
9094
|
console.warn(
|
|
8603
9095
|
"Warning: Defining props on `root` is deprecated. Please use `root.props`, or republish this page to migrate automatically."
|
|
8604
9096
|
);
|
|
8605
9097
|
}
|
|
8606
|
-
const rootProps = ((
|
|
8607
|
-
const defaultedRootProps = __spreadValues(__spreadValues({}, (
|
|
9098
|
+
const rootProps = ((_f = initialData == null ? void 0 : initialData.root) == null ? void 0 : _f.props) || (initialData == null ? void 0 : initialData.root) || {};
|
|
9099
|
+
const defaultedRootProps = __spreadValues(__spreadValues({}, (_g = config.root) == null ? void 0 : _g.defaultProps), rootProps);
|
|
8608
9100
|
const root = populateIds(
|
|
8609
9101
|
toComponent(__spreadProps(__spreadValues({}, initialData == null ? void 0 : initialData.root), { props: defaultedRootProps })),
|
|
8610
9102
|
config
|
|
@@ -8634,7 +9126,7 @@ function PuckProvider({ children }) {
|
|
|
8634
9126
|
return walkAppState(newAppState, config);
|
|
8635
9127
|
});
|
|
8636
9128
|
const { appendData = true } = _initialHistory || {};
|
|
8637
|
-
const [blendedHistories] =
|
|
9129
|
+
const [blendedHistories] = useState26(
|
|
8638
9130
|
[
|
|
8639
9131
|
...(_initialHistory == null ? void 0 : _initialHistory.histories) || [],
|
|
8640
9132
|
...appendData ? [{ state: generatedAppState }] : []
|
|
@@ -8654,7 +9146,7 @@ function PuckProvider({ children }) {
|
|
|
8654
9146
|
overrides,
|
|
8655
9147
|
plugins
|
|
8656
9148
|
});
|
|
8657
|
-
const loadedFieldTransforms =
|
|
9149
|
+
const loadedFieldTransforms = useMemo21(() => {
|
|
8658
9150
|
const _plugins = plugins || [];
|
|
8659
9151
|
const pluginFieldTransforms = _plugins.reduce(
|
|
8660
9152
|
(acc, plugin) => __spreadValues(__spreadValues({}, acc), plugin.fieldTransforms),
|
|
@@ -8662,9 +9154,11 @@ function PuckProvider({ children }) {
|
|
|
8662
9154
|
);
|
|
8663
9155
|
return __spreadValues(__spreadValues({}, pluginFieldTransforms), fieldTransforms);
|
|
8664
9156
|
}, [fieldTransforms, plugins]);
|
|
9157
|
+
const instanceId = useSafeId();
|
|
8665
9158
|
const generateAppStore = useCallback21(
|
|
8666
9159
|
(state) => {
|
|
8667
9160
|
return {
|
|
9161
|
+
instanceId,
|
|
8668
9162
|
state,
|
|
8669
9163
|
config,
|
|
8670
9164
|
plugins: plugins || [],
|
|
@@ -8677,6 +9171,7 @@ function PuckProvider({ children }) {
|
|
|
8677
9171
|
};
|
|
8678
9172
|
},
|
|
8679
9173
|
[
|
|
9174
|
+
instanceId,
|
|
8680
9175
|
initialAppState,
|
|
8681
9176
|
config,
|
|
8682
9177
|
plugins,
|
|
@@ -8688,15 +9183,15 @@ function PuckProvider({ children }) {
|
|
|
8688
9183
|
loadedFieldTransforms
|
|
8689
9184
|
]
|
|
8690
9185
|
);
|
|
8691
|
-
const [appStore] =
|
|
9186
|
+
const [appStore] = useState26(
|
|
8692
9187
|
() => createAppStore(generateAppStore(initialAppState))
|
|
8693
9188
|
);
|
|
8694
|
-
|
|
9189
|
+
useEffect30(() => {
|
|
8695
9190
|
if (process.env.NODE_ENV !== "production") {
|
|
8696
9191
|
window.__PUCK_INTERNAL_DO_NOT_USE = { appStore };
|
|
8697
9192
|
}
|
|
8698
9193
|
}, [appStore]);
|
|
8699
|
-
|
|
9194
|
+
useEffect30(() => {
|
|
8700
9195
|
const state = appStore.getState().state;
|
|
8701
9196
|
appStore.setState(__spreadValues({}, generateAppStore(state)));
|
|
8702
9197
|
}, [config, plugins, loadedOverrides, viewports, iframe, onAction, metadata]);
|
|
@@ -8706,8 +9201,8 @@ function PuckProvider({ children }) {
|
|
|
8706
9201
|
initialAppState
|
|
8707
9202
|
});
|
|
8708
9203
|
const previousData = useRef12(null);
|
|
8709
|
-
|
|
8710
|
-
appStore.subscribe(
|
|
9204
|
+
useEffect30(() => {
|
|
9205
|
+
return appStore.subscribe(
|
|
8711
9206
|
(s) => s.state.data,
|
|
8712
9207
|
(data) => {
|
|
8713
9208
|
if (onChange) {
|
|
@@ -8717,149 +9212,17 @@ function PuckProvider({ children }) {
|
|
|
8717
9212
|
}
|
|
8718
9213
|
}
|
|
8719
9214
|
);
|
|
8720
|
-
}, []);
|
|
9215
|
+
}, [onChange]);
|
|
8721
9216
|
useRegisterPermissionsSlice(appStore, permissions);
|
|
8722
9217
|
const uPuckStore = useRegisterUsePuckStore(appStore);
|
|
8723
|
-
|
|
9218
|
+
useEffect30(() => {
|
|
8724
9219
|
const { resolveAndCommitData } = appStore.getState();
|
|
8725
9220
|
resolveAndCommitData();
|
|
8726
9221
|
}, []);
|
|
8727
|
-
return /* @__PURE__ */
|
|
8728
|
-
}
|
|
8729
|
-
function PuckLayout({ children }) {
|
|
8730
|
-
const {
|
|
8731
|
-
iframe: _iframe,
|
|
8732
|
-
dnd,
|
|
8733
|
-
initialHistory: _initialHistory
|
|
8734
|
-
} = usePropsContext();
|
|
8735
|
-
const iframe = useMemo20(
|
|
8736
|
-
() => __spreadValues({
|
|
8737
|
-
enabled: true,
|
|
8738
|
-
waitForStyles: true
|
|
8739
|
-
}, _iframe),
|
|
8740
|
-
[_iframe]
|
|
8741
|
-
);
|
|
8742
|
-
useInjectGlobalCss(iframe.enabled);
|
|
8743
|
-
const dispatch = useAppStore((s) => s.dispatch);
|
|
8744
|
-
const leftSideBarVisible = useAppStore((s) => s.state.ui.leftSideBarVisible);
|
|
8745
|
-
const rightSideBarVisible = useAppStore(
|
|
8746
|
-
(s) => s.state.ui.rightSideBarVisible
|
|
8747
|
-
);
|
|
8748
|
-
const {
|
|
8749
|
-
width: leftWidth,
|
|
8750
|
-
setWidth: setLeftWidth,
|
|
8751
|
-
sidebarRef: leftSidebarRef,
|
|
8752
|
-
handleResizeEnd: handleLeftSidebarResizeEnd
|
|
8753
|
-
} = useSidebarResize("left", dispatch);
|
|
8754
|
-
const {
|
|
8755
|
-
width: rightWidth,
|
|
8756
|
-
setWidth: setRightWidth,
|
|
8757
|
-
sidebarRef: rightSidebarRef,
|
|
8758
|
-
handleResizeEnd: handleRightSidebarResizeEnd
|
|
8759
|
-
} = useSidebarResize("right", dispatch);
|
|
8760
|
-
useEffect29(() => {
|
|
8761
|
-
if (!window.matchMedia("(min-width: 638px)").matches) {
|
|
8762
|
-
dispatch({
|
|
8763
|
-
type: "setUi",
|
|
8764
|
-
ui: {
|
|
8765
|
-
leftSideBarVisible: false,
|
|
8766
|
-
rightSideBarVisible: false
|
|
8767
|
-
}
|
|
8768
|
-
});
|
|
8769
|
-
}
|
|
8770
|
-
const handleResize = () => {
|
|
8771
|
-
if (!window.matchMedia("(min-width: 638px)").matches) {
|
|
8772
|
-
dispatch({
|
|
8773
|
-
type: "setUi",
|
|
8774
|
-
ui: (ui) => __spreadValues(__spreadValues({}, ui), ui.rightSideBarVisible ? { leftSideBarVisible: false } : {})
|
|
8775
|
-
});
|
|
8776
|
-
}
|
|
8777
|
-
};
|
|
8778
|
-
window.addEventListener("resize", handleResize);
|
|
8779
|
-
return () => {
|
|
8780
|
-
window.removeEventListener("resize", handleResize);
|
|
8781
|
-
};
|
|
8782
|
-
}, []);
|
|
8783
|
-
const overrides = useAppStore((s) => s.overrides);
|
|
8784
|
-
const CustomPuck = useMemo20(
|
|
8785
|
-
() => overrides.puck || DefaultOverride,
|
|
8786
|
-
[overrides]
|
|
8787
|
-
);
|
|
8788
|
-
const [mounted, setMounted] = useState25(false);
|
|
8789
|
-
useEffect29(() => {
|
|
8790
|
-
setMounted(true);
|
|
8791
|
-
}, []);
|
|
8792
|
-
const ready = useAppStore((s) => s.status === "READY");
|
|
8793
|
-
useMonitorHotkeys();
|
|
8794
|
-
useDeleteHotkeys();
|
|
8795
|
-
useEffect29(() => {
|
|
8796
|
-
if (ready && iframe.enabled) {
|
|
8797
|
-
const frameDoc = getFrame();
|
|
8798
|
-
if (frameDoc) {
|
|
8799
|
-
return monitorHotkeys(frameDoc);
|
|
8800
|
-
}
|
|
8801
|
-
}
|
|
8802
|
-
}, [ready, iframe.enabled]);
|
|
8803
|
-
usePreviewModeHotkeys();
|
|
8804
|
-
const layoutOptions = {};
|
|
8805
|
-
if (leftWidth) {
|
|
8806
|
-
layoutOptions["--puck-user-left-side-bar-width"] = `${leftWidth}px`;
|
|
8807
|
-
}
|
|
8808
|
-
if (rightWidth) {
|
|
8809
|
-
layoutOptions["--puck-user-right-side-bar-width"] = `${rightWidth}px`;
|
|
8810
|
-
}
|
|
8811
|
-
return /* @__PURE__ */ jsxs21("div", { className: `Puck ${getClassName31()}`, children: [
|
|
8812
|
-
/* @__PURE__ */ jsx45(DragDropContext, { disableAutoScroll: dnd == null ? void 0 : dnd.disableAutoScroll, children: /* @__PURE__ */ jsx45(CustomPuck, { children: children || /* @__PURE__ */ jsx45(FrameProvider, { children: /* @__PURE__ */ jsx45(
|
|
8813
|
-
"div",
|
|
8814
|
-
{
|
|
8815
|
-
className: getLayoutClassName({
|
|
8816
|
-
leftSideBarVisible,
|
|
8817
|
-
mounted,
|
|
8818
|
-
rightSideBarVisible
|
|
8819
|
-
}),
|
|
8820
|
-
children: /* @__PURE__ */ jsxs21(
|
|
8821
|
-
"div",
|
|
8822
|
-
{
|
|
8823
|
-
className: getLayoutClassName("inner"),
|
|
8824
|
-
style: layoutOptions,
|
|
8825
|
-
children: [
|
|
8826
|
-
/* @__PURE__ */ jsx45(Header, {}),
|
|
8827
|
-
/* @__PURE__ */ jsxs21(
|
|
8828
|
-
Sidebar,
|
|
8829
|
-
{
|
|
8830
|
-
position: "left",
|
|
8831
|
-
sidebarRef: leftSidebarRef,
|
|
8832
|
-
isVisible: leftSideBarVisible,
|
|
8833
|
-
onResize: setLeftWidth,
|
|
8834
|
-
onResizeEnd: handleLeftSidebarResizeEnd,
|
|
8835
|
-
children: [
|
|
8836
|
-
/* @__PURE__ */ jsx45(SidebarSection, { title: "Components", noBorderTop: true, children: /* @__PURE__ */ jsx45(Components, {}) }),
|
|
8837
|
-
/* @__PURE__ */ jsx45(SidebarSection, { title: "Outline", children: /* @__PURE__ */ jsx45(Outline, {}) })
|
|
8838
|
-
]
|
|
8839
|
-
}
|
|
8840
|
-
),
|
|
8841
|
-
/* @__PURE__ */ jsx45(Canvas, {}),
|
|
8842
|
-
/* @__PURE__ */ jsx45(
|
|
8843
|
-
Sidebar,
|
|
8844
|
-
{
|
|
8845
|
-
position: "right",
|
|
8846
|
-
sidebarRef: rightSidebarRef,
|
|
8847
|
-
isVisible: rightSideBarVisible,
|
|
8848
|
-
onResize: setRightWidth,
|
|
8849
|
-
onResizeEnd: handleRightSidebarResizeEnd,
|
|
8850
|
-
children: /* @__PURE__ */ jsx45(FieldSideBar, {})
|
|
8851
|
-
}
|
|
8852
|
-
)
|
|
8853
|
-
]
|
|
8854
|
-
}
|
|
8855
|
-
)
|
|
8856
|
-
}
|
|
8857
|
-
) }) }) }),
|
|
8858
|
-
/* @__PURE__ */ jsx45("div", { id: "puck-portal-root", className: getClassName31("portal") })
|
|
8859
|
-
] });
|
|
9222
|
+
return /* @__PURE__ */ jsx51(appStoreContext.Provider, { value: appStore, children: /* @__PURE__ */ jsx51(UsePuckStoreContext.Provider, { value: uPuckStore, children }) });
|
|
8860
9223
|
}
|
|
8861
9224
|
function Puck(props) {
|
|
8862
|
-
return /* @__PURE__ */
|
|
9225
|
+
return /* @__PURE__ */ jsx51(PropsProvider, __spreadProps(__spreadValues({}, props), { children: /* @__PURE__ */ jsx51(PuckProvider, __spreadProps(__spreadValues({}, props), { children: /* @__PURE__ */ jsx51(Layout, { children: props.children }) })) }));
|
|
8863
9226
|
}
|
|
8864
9227
|
Puck.Components = Components;
|
|
8865
9228
|
Puck.Fields = Fields;
|
|
@@ -8921,6 +9284,9 @@ export {
|
|
|
8921
9284
|
createUsePuck,
|
|
8922
9285
|
usePuck,
|
|
8923
9286
|
useGetPuck,
|
|
9287
|
+
blocksPlugin,
|
|
9288
|
+
outlinePlugin,
|
|
9289
|
+
fieldsPlugin,
|
|
8924
9290
|
Puck
|
|
8925
9291
|
};
|
|
8926
9292
|
/*! Bundled license information:
|
|
@@ -9020,6 +9386,14 @@ lucide-react/dist/esm/icons/ellipsis-vertical.js:
|
|
|
9020
9386
|
* See the LICENSE file in the root directory of this source tree.
|
|
9021
9387
|
*)
|
|
9022
9388
|
|
|
9389
|
+
lucide-react/dist/esm/icons/expand.js:
|
|
9390
|
+
(**
|
|
9391
|
+
* @license lucide-react v0.468.0 - ISC
|
|
9392
|
+
*
|
|
9393
|
+
* This source code is licensed under the ISC license.
|
|
9394
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
9395
|
+
*)
|
|
9396
|
+
|
|
9023
9397
|
lucide-react/dist/esm/icons/globe.js:
|
|
9024
9398
|
(**
|
|
9025
9399
|
* @license lucide-react v0.468.0 - ISC
|
|
@@ -9028,6 +9402,14 @@ lucide-react/dist/esm/icons/globe.js:
|
|
|
9028
9402
|
* See the LICENSE file in the root directory of this source tree.
|
|
9029
9403
|
*)
|
|
9030
9404
|
|
|
9405
|
+
lucide-react/dist/esm/icons/hammer.js:
|
|
9406
|
+
(**
|
|
9407
|
+
* @license lucide-react v0.468.0 - ISC
|
|
9408
|
+
*
|
|
9409
|
+
* This source code is licensed under the ISC license.
|
|
9410
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
9411
|
+
*)
|
|
9412
|
+
|
|
9031
9413
|
lucide-react/dist/esm/icons/hash.js:
|
|
9032
9414
|
(**
|
|
9033
9415
|
* @license lucide-react v0.468.0 - ISC
|
|
@@ -9084,6 +9466,22 @@ lucide-react/dist/esm/icons/lock.js:
|
|
|
9084
9466
|
* See the LICENSE file in the root directory of this source tree.
|
|
9085
9467
|
*)
|
|
9086
9468
|
|
|
9469
|
+
lucide-react/dist/esm/icons/maximize-2.js:
|
|
9470
|
+
(**
|
|
9471
|
+
* @license lucide-react v0.468.0 - ISC
|
|
9472
|
+
*
|
|
9473
|
+
* This source code is licensed under the ISC license.
|
|
9474
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
9475
|
+
*)
|
|
9476
|
+
|
|
9477
|
+
lucide-react/dist/esm/icons/minimize-2.js:
|
|
9478
|
+
(**
|
|
9479
|
+
* @license lucide-react v0.468.0 - ISC
|
|
9480
|
+
*
|
|
9481
|
+
* This source code is licensed under the ISC license.
|
|
9482
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
9483
|
+
*)
|
|
9484
|
+
|
|
9087
9485
|
lucide-react/dist/esm/icons/monitor.js:
|
|
9088
9486
|
(**
|
|
9089
9487
|
* @license lucide-react v0.468.0 - ISC
|
|
@@ -9116,6 +9514,14 @@ lucide-react/dist/esm/icons/plus.js:
|
|
|
9116
9514
|
* See the LICENSE file in the root directory of this source tree.
|
|
9117
9515
|
*)
|
|
9118
9516
|
|
|
9517
|
+
lucide-react/dist/esm/icons/rectangle-ellipsis.js:
|
|
9518
|
+
(**
|
|
9519
|
+
* @license lucide-react v0.468.0 - ISC
|
|
9520
|
+
*
|
|
9521
|
+
* This source code is licensed under the ISC license.
|
|
9522
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
9523
|
+
*)
|
|
9524
|
+
|
|
9119
9525
|
lucide-react/dist/esm/icons/redo-2.js:
|
|
9120
9526
|
(**
|
|
9121
9527
|
* @license lucide-react v0.468.0 - ISC
|
|
@@ -9156,6 +9562,14 @@ lucide-react/dist/esm/icons/tablet.js:
|
|
|
9156
9562
|
* See the LICENSE file in the root directory of this source tree.
|
|
9157
9563
|
*)
|
|
9158
9564
|
|
|
9565
|
+
lucide-react/dist/esm/icons/toy-brick.js:
|
|
9566
|
+
(**
|
|
9567
|
+
* @license lucide-react v0.468.0 - ISC
|
|
9568
|
+
*
|
|
9569
|
+
* This source code is licensed under the ISC license.
|
|
9570
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
9571
|
+
*)
|
|
9572
|
+
|
|
9159
9573
|
lucide-react/dist/esm/icons/trash.js:
|
|
9160
9574
|
(**
|
|
9161
9575
|
* @license lucide-react v0.468.0 - ISC
|
|
@@ -9180,6 +9594,14 @@ lucide-react/dist/esm/icons/undo-2.js:
|
|
|
9180
9594
|
* See the LICENSE file in the root directory of this source tree.
|
|
9181
9595
|
*)
|
|
9182
9596
|
|
|
9597
|
+
lucide-react/dist/esm/icons/x.js:
|
|
9598
|
+
(**
|
|
9599
|
+
* @license lucide-react v0.468.0 - ISC
|
|
9600
|
+
*
|
|
9601
|
+
* This source code is licensed under the ISC license.
|
|
9602
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
9603
|
+
*)
|
|
9604
|
+
|
|
9183
9605
|
lucide-react/dist/esm/icons/zoom-in.js:
|
|
9184
9606
|
(**
|
|
9185
9607
|
* @license lucide-react v0.468.0 - ISC
|