@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
package/dist/no-external.js
CHANGED
|
@@ -204,8 +204,11 @@ __export(no_external_exports, {
|
|
|
204
204
|
Label: () => Label,
|
|
205
205
|
Puck: () => Puck,
|
|
206
206
|
Render: () => Render,
|
|
207
|
+
blocksPlugin: () => blocksPlugin,
|
|
207
208
|
createUsePuck: () => createUsePuck,
|
|
209
|
+
fieldsPlugin: () => fieldsPlugin,
|
|
208
210
|
migrate: () => migrate,
|
|
211
|
+
outlinePlugin: () => outlinePlugin,
|
|
209
212
|
overrideKeys: () => overrideKeys,
|
|
210
213
|
registerOverlayPortal: () => registerOverlayPortal,
|
|
211
214
|
renderContext: () => renderContext,
|
|
@@ -495,6 +498,15 @@ var EllipsisVertical = createLucideIcon("EllipsisVertical", [
|
|
|
495
498
|
["circle", { cx: "12", cy: "19", r: "1", key: "lyex9k" }]
|
|
496
499
|
]);
|
|
497
500
|
|
|
501
|
+
// ../../node_modules/lucide-react/dist/esm/icons/expand.js
|
|
502
|
+
init_react_import();
|
|
503
|
+
var Expand = createLucideIcon("Expand", [
|
|
504
|
+
["path", { d: "m21 21-6-6m6 6v-4.8m0 4.8h-4.8", key: "1c15vz" }],
|
|
505
|
+
["path", { d: "M3 16.2V21m0 0h4.8M3 21l6-6", key: "1fsnz2" }],
|
|
506
|
+
["path", { d: "M21 7.8V3m0 0h-4.8M21 3l-6 6", key: "hawz9i" }],
|
|
507
|
+
["path", { d: "M3 7.8V3m0 0h4.8M3 3l6 6", key: "u9ee12" }]
|
|
508
|
+
]);
|
|
509
|
+
|
|
498
510
|
// ../../node_modules/lucide-react/dist/esm/icons/globe.js
|
|
499
511
|
init_react_import();
|
|
500
512
|
var Globe = createLucideIcon("Globe", [
|
|
@@ -503,6 +515,20 @@ var Globe = createLucideIcon("Globe", [
|
|
|
503
515
|
["path", { d: "M2 12h20", key: "9i4pu4" }]
|
|
504
516
|
]);
|
|
505
517
|
|
|
518
|
+
// ../../node_modules/lucide-react/dist/esm/icons/hammer.js
|
|
519
|
+
init_react_import();
|
|
520
|
+
var Hammer = createLucideIcon("Hammer", [
|
|
521
|
+
["path", { d: "m15 12-8.373 8.373a1 1 0 1 1-3-3L12 9", key: "eefl8a" }],
|
|
522
|
+
["path", { d: "m18 15 4-4", key: "16gjal" }],
|
|
523
|
+
[
|
|
524
|
+
"path",
|
|
525
|
+
{
|
|
526
|
+
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",
|
|
527
|
+
key: "b7pghm"
|
|
528
|
+
}
|
|
529
|
+
]
|
|
530
|
+
]);
|
|
531
|
+
|
|
506
532
|
// ../../node_modules/lucide-react/dist/esm/icons/hash.js
|
|
507
533
|
init_react_import();
|
|
508
534
|
var Hash = createLucideIcon("Hash", [
|
|
@@ -579,6 +605,24 @@ var Lock = createLucideIcon("Lock", [
|
|
|
579
605
|
["path", { d: "M7 11V7a5 5 0 0 1 10 0v4", key: "fwvmzm" }]
|
|
580
606
|
]);
|
|
581
607
|
|
|
608
|
+
// ../../node_modules/lucide-react/dist/esm/icons/maximize-2.js
|
|
609
|
+
init_react_import();
|
|
610
|
+
var Maximize2 = createLucideIcon("Maximize2", [
|
|
611
|
+
["polyline", { points: "15 3 21 3 21 9", key: "mznyad" }],
|
|
612
|
+
["polyline", { points: "9 21 3 21 3 15", key: "1avn1i" }],
|
|
613
|
+
["line", { x1: "21", x2: "14", y1: "3", y2: "10", key: "ota7mn" }],
|
|
614
|
+
["line", { x1: "3", x2: "10", y1: "21", y2: "14", key: "1atl0r" }]
|
|
615
|
+
]);
|
|
616
|
+
|
|
617
|
+
// ../../node_modules/lucide-react/dist/esm/icons/minimize-2.js
|
|
618
|
+
init_react_import();
|
|
619
|
+
var Minimize2 = createLucideIcon("Minimize2", [
|
|
620
|
+
["polyline", { points: "4 14 10 14 10 20", key: "11kfnr" }],
|
|
621
|
+
["polyline", { points: "20 10 14 10 14 4", key: "rlmsce" }],
|
|
622
|
+
["line", { x1: "14", x2: "21", y1: "10", y2: "3", key: "o5lafz" }],
|
|
623
|
+
["line", { x1: "3", x2: "10", y1: "21", y2: "14", key: "1atl0r" }]
|
|
624
|
+
]);
|
|
625
|
+
|
|
582
626
|
// ../../node_modules/lucide-react/dist/esm/icons/monitor.js
|
|
583
627
|
init_react_import();
|
|
584
628
|
var Monitor = createLucideIcon("Monitor", [
|
|
@@ -608,6 +652,15 @@ var Plus = createLucideIcon("Plus", [
|
|
|
608
652
|
["path", { d: "M12 5v14", key: "s699le" }]
|
|
609
653
|
]);
|
|
610
654
|
|
|
655
|
+
// ../../node_modules/lucide-react/dist/esm/icons/rectangle-ellipsis.js
|
|
656
|
+
init_react_import();
|
|
657
|
+
var RectangleEllipsis = createLucideIcon("RectangleEllipsis", [
|
|
658
|
+
["rect", { width: "20", height: "12", x: "2", y: "6", rx: "2", key: "9lu3g6" }],
|
|
659
|
+
["path", { d: "M12 12h.01", key: "1mp3jc" }],
|
|
660
|
+
["path", { d: "M17 12h.01", key: "1m0b6t" }],
|
|
661
|
+
["path", { d: "M7 12h.01", key: "eqddd0" }]
|
|
662
|
+
]);
|
|
663
|
+
|
|
611
664
|
// ../../node_modules/lucide-react/dist/esm/icons/redo-2.js
|
|
612
665
|
init_react_import();
|
|
613
666
|
var Redo2 = createLucideIcon("Redo2", [
|
|
@@ -650,6 +703,14 @@ var Tablet = createLucideIcon("Tablet", [
|
|
|
650
703
|
["line", { x1: "12", x2: "12.01", y1: "18", y2: "18", key: "1dp563" }]
|
|
651
704
|
]);
|
|
652
705
|
|
|
706
|
+
// ../../node_modules/lucide-react/dist/esm/icons/toy-brick.js
|
|
707
|
+
init_react_import();
|
|
708
|
+
var ToyBrick = createLucideIcon("ToyBrick", [
|
|
709
|
+
["rect", { width: "18", height: "12", x: "3", y: "8", rx: "1", key: "158fvp" }],
|
|
710
|
+
["path", { d: "M10 8V5c0-.6-.4-1-1-1H6a1 1 0 0 0-1 1v3", key: "s0042v" }],
|
|
711
|
+
["path", { d: "M19 8V5c0-.6-.4-1-1-1h-3a1 1 0 0 0-1 1v3", key: "9wmeh2" }]
|
|
712
|
+
]);
|
|
713
|
+
|
|
653
714
|
// ../../node_modules/lucide-react/dist/esm/icons/trash.js
|
|
654
715
|
init_react_import();
|
|
655
716
|
var Trash = createLucideIcon("Trash", [
|
|
@@ -673,6 +734,13 @@ var Undo2 = createLucideIcon("Undo2", [
|
|
|
673
734
|
["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" }]
|
|
674
735
|
]);
|
|
675
736
|
|
|
737
|
+
// ../../node_modules/lucide-react/dist/esm/icons/x.js
|
|
738
|
+
init_react_import();
|
|
739
|
+
var X = createLucideIcon("X", [
|
|
740
|
+
["path", { d: "M18 6 6 18", key: "1bl5f8" }],
|
|
741
|
+
["path", { d: "m6 6 12 12", key: "d8bk6v" }]
|
|
742
|
+
]);
|
|
743
|
+
|
|
676
744
|
// ../../node_modules/lucide-react/dist/esm/icons/zoom-in.js
|
|
677
745
|
init_react_import();
|
|
678
746
|
var ZoomIn = createLucideIcon("ZoomIn", [
|
|
@@ -1648,7 +1716,8 @@ init_react_import();
|
|
|
1648
1716
|
var defaultViewports = [
|
|
1649
1717
|
{ width: 360, height: "auto", icon: "Smartphone", label: "Small" },
|
|
1650
1718
|
{ width: 768, height: "auto", icon: "Tablet", label: "Medium" },
|
|
1651
|
-
{ width: 1280, height: "auto", icon: "Monitor", label: "Large" }
|
|
1719
|
+
{ width: 1280, height: "auto", icon: "Monitor", label: "Large" },
|
|
1720
|
+
{ width: "100%", height: "auto", icon: "FullWidth", label: "Full-width" }
|
|
1652
1721
|
];
|
|
1653
1722
|
|
|
1654
1723
|
// store/index.ts
|
|
@@ -2290,7 +2359,8 @@ var defaultAppState = {
|
|
|
2290
2359
|
options: [],
|
|
2291
2360
|
controlsVisible: true
|
|
2292
2361
|
},
|
|
2293
|
-
field: { focus: null }
|
|
2362
|
+
field: { focus: null },
|
|
2363
|
+
plugin: { current: null }
|
|
2294
2364
|
},
|
|
2295
2365
|
indexes: {
|
|
2296
2366
|
nodes: {},
|
|
@@ -2306,6 +2376,7 @@ var createAppStore = (initialAppStore) => (0, import_zustand2.create)()(
|
|
|
2306
2376
|
(0, import_middleware2.subscribeWithSelector)((set, get) => {
|
|
2307
2377
|
var _a, _b;
|
|
2308
2378
|
return __spreadProps(__spreadValues({
|
|
2379
|
+
instanceId: generateId(),
|
|
2309
2380
|
state: defaultAppState,
|
|
2310
2381
|
config: { components: {} },
|
|
2311
2382
|
componentState: {},
|
|
@@ -2614,7 +2685,7 @@ var getZoomConfig = (uiViewport, frame, zoom) => {
|
|
|
2614
2685
|
const viewportHeight = uiViewport.height === "auto" ? frameHeight : uiViewport.height;
|
|
2615
2686
|
let rootHeight = 0;
|
|
2616
2687
|
let autoZoom = 1;
|
|
2617
|
-
if (uiViewport.width > frameWidth || viewportHeight > frameHeight) {
|
|
2688
|
+
if (typeof uiViewport.width === "number" && (uiViewport.width > frameWidth || viewportHeight > frameHeight)) {
|
|
2618
2689
|
const widthZoom = Math.min(frameWidth / uiViewport.width, 1);
|
|
2619
2690
|
const heightZoom = Math.min(frameHeight / viewportHeight, 1);
|
|
2620
2691
|
zoom = widthZoom;
|
|
@@ -2693,7 +2764,8 @@ var IconButton = ({
|
|
|
2693
2764
|
tabIndex,
|
|
2694
2765
|
newTab,
|
|
2695
2766
|
fullWidth,
|
|
2696
|
-
title
|
|
2767
|
+
title,
|
|
2768
|
+
suppressHydrationWarning
|
|
2697
2769
|
}) => {
|
|
2698
2770
|
const [loading, setLoading] = (0, import_react9.useState)(false);
|
|
2699
2771
|
const ElementType = href ? "a" : "button";
|
|
@@ -2720,6 +2792,7 @@ var IconButton = ({
|
|
|
2720
2792
|
rel: newTab ? "noreferrer" : void 0,
|
|
2721
2793
|
href,
|
|
2722
2794
|
title,
|
|
2795
|
+
suppressHydrationWarning,
|
|
2723
2796
|
children: [
|
|
2724
2797
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: getClassName3("title"), children: title }),
|
|
2725
2798
|
children,
|
|
@@ -3535,8 +3608,9 @@ var ArrayField = ({
|
|
|
3535
3608
|
var _a;
|
|
3536
3609
|
if (isDraggingAny) return;
|
|
3537
3610
|
const existingValue = value || [];
|
|
3611
|
+
const defaultProps = typeof field.defaultItemProps === "function" ? field.defaultItemProps(existingValue.length) : (_a = field.defaultItemProps) != null ? _a : {};
|
|
3538
3612
|
const newItem = defaultSlots(
|
|
3539
|
-
uniqifyItem(
|
|
3613
|
+
uniqifyItem(defaultProps),
|
|
3540
3614
|
field.arrayFields
|
|
3541
3615
|
);
|
|
3542
3616
|
const newValue = [...existingValue, newItem];
|
|
@@ -4901,14 +4975,23 @@ var DraggableComponent = ({
|
|
|
4901
4975
|
if (!el.closest("[data-puck-overlay-portal]")) {
|
|
4902
4976
|
e.stopPropagation();
|
|
4903
4977
|
}
|
|
4904
|
-
|
|
4905
|
-
|
|
4906
|
-
|
|
4907
|
-
|
|
4908
|
-
|
|
4909
|
-
|
|
4978
|
+
if (isSelected) {
|
|
4979
|
+
dispatch({
|
|
4980
|
+
type: "setUi",
|
|
4981
|
+
ui: {
|
|
4982
|
+
itemSelector: null
|
|
4983
|
+
}
|
|
4984
|
+
});
|
|
4985
|
+
} else {
|
|
4986
|
+
dispatch({
|
|
4987
|
+
type: "setUi",
|
|
4988
|
+
ui: {
|
|
4989
|
+
itemSelector: { index, zone: zoneCompound }
|
|
4990
|
+
}
|
|
4991
|
+
});
|
|
4992
|
+
}
|
|
4910
4993
|
},
|
|
4911
|
-
[index, zoneCompound, id]
|
|
4994
|
+
[index, zoneCompound, id, isSelected]
|
|
4912
4995
|
);
|
|
4913
4996
|
const appStore = useAppStoreApi();
|
|
4914
4997
|
const onSelectParent = (0, import_react24.useCallback)(() => {
|
|
@@ -6602,8 +6685,8 @@ var DragDropContextClient = ({
|
|
|
6602
6685
|
disableAutoScroll
|
|
6603
6686
|
}) => {
|
|
6604
6687
|
const dispatch = useAppStore((s) => s.dispatch);
|
|
6688
|
+
const instanceId = useAppStore((s) => s.instanceId);
|
|
6605
6689
|
const appStore = useAppStoreApi();
|
|
6606
|
-
const id = useSafeId();
|
|
6607
6690
|
const debouncedParamsRef = (0, import_react37.useRef)(null);
|
|
6608
6691
|
const tempDisableFallback = useTempDisableFallback(100);
|
|
6609
6692
|
const [zoneStore] = (0, import_react37.useState)(
|
|
@@ -6619,7 +6702,7 @@ var DragDropContextClient = ({
|
|
|
6619
6702
|
}))
|
|
6620
6703
|
);
|
|
6621
6704
|
const getChanged2 = (0, import_react37.useCallback)(
|
|
6622
|
-
(params
|
|
6705
|
+
(params) => {
|
|
6623
6706
|
const { zoneDepthIndex = {}, areaDepthIndex = {} } = zoneStore.getState() || {};
|
|
6624
6707
|
const stateHasZone = Object.keys(zoneDepthIndex).length > 0;
|
|
6625
6708
|
const stateHasArea = Object.keys(areaDepthIndex).length > 0;
|
|
@@ -6641,7 +6724,7 @@ var DragDropContextClient = ({
|
|
|
6641
6724
|
);
|
|
6642
6725
|
const setDeepestAndCollide = (0, import_react37.useCallback)(
|
|
6643
6726
|
(params, manager) => {
|
|
6644
|
-
const { zoneChanged, areaChanged } = getChanged2(params
|
|
6727
|
+
const { zoneChanged, areaChanged } = getChanged2(params);
|
|
6645
6728
|
if (!zoneChanged && !areaChanged) return;
|
|
6646
6729
|
zoneStore.setState({
|
|
6647
6730
|
zoneDepthIndex: params.zone ? { [params.zone]: true } : {},
|
|
@@ -6683,7 +6766,7 @@ var DragDropContextClient = ({
|
|
|
6683
6766
|
{
|
|
6684
6767
|
onChange: (params, manager) => {
|
|
6685
6768
|
const state = zoneStore.getState();
|
|
6686
|
-
const { zoneChanged, areaChanged } = getChanged2(params
|
|
6769
|
+
const { zoneChanged, areaChanged } = getChanged2(params);
|
|
6687
6770
|
const isDragging = manager.dragOperation.status.dragging;
|
|
6688
6771
|
if (areaChanged || zoneChanged) {
|
|
6689
6772
|
let nextZoneDepthIndex = {};
|
|
@@ -6721,7 +6804,7 @@ var DragDropContextClient = ({
|
|
|
6721
6804
|
cancelDb();
|
|
6722
6805
|
}
|
|
6723
6806
|
},
|
|
6724
|
-
|
|
6807
|
+
instanceId
|
|
6725
6808
|
)
|
|
6726
6809
|
]);
|
|
6727
6810
|
const sensors = useSensors();
|
|
@@ -6736,7 +6819,7 @@ var DragDropContextClient = ({
|
|
|
6736
6819
|
}),
|
|
6737
6820
|
[]
|
|
6738
6821
|
);
|
|
6739
|
-
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
6822
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
6740
6823
|
dragListenerContext.Provider,
|
|
6741
6824
|
{
|
|
6742
6825
|
value: {
|
|
@@ -6963,7 +7046,7 @@ var DragDropContextClient = ({
|
|
|
6963
7046
|
}
|
|
6964
7047
|
)
|
|
6965
7048
|
}
|
|
6966
|
-
)
|
|
7049
|
+
);
|
|
6967
7050
|
};
|
|
6968
7051
|
var DragDropContext = ({
|
|
6969
7052
|
children,
|
|
@@ -7105,121 +7188,24 @@ Drawer.Item = DrawerItem;
|
|
|
7105
7188
|
|
|
7106
7189
|
// components/Puck/index.tsx
|
|
7107
7190
|
init_react_import();
|
|
7108
|
-
var
|
|
7109
|
-
|
|
7110
|
-
// components/SidebarSection/index.tsx
|
|
7111
|
-
init_react_import();
|
|
7112
|
-
|
|
7113
|
-
// css-module:/home/runner/work/puck/puck/packages/core/components/SidebarSection/styles.module.css#css-module
|
|
7114
|
-
init_react_import();
|
|
7115
|
-
var styles_module_default14 = { "SidebarSection": "_SidebarSection_8boj8_1", "SidebarSection-title": "_SidebarSection-title_8boj8_12", "SidebarSection--noBorderTop": "_SidebarSection--noBorderTop_8boj8_20", "SidebarSection-content": "_SidebarSection-content_8boj8_24", "SidebarSection--noPadding": "_SidebarSection--noPadding_8boj8_28", "SidebarSection-breadcrumbLabel": "_SidebarSection-breadcrumbLabel_8boj8_41", "SidebarSection-breadcrumbs": "_SidebarSection-breadcrumbs_8boj8_70", "SidebarSection-breadcrumb": "_SidebarSection-breadcrumb_8boj8_41", "SidebarSection-heading": "_SidebarSection-heading_8boj8_82", "SidebarSection-loadingOverlay": "_SidebarSection-loadingOverlay_8boj8_86" };
|
|
7116
|
-
|
|
7117
|
-
// lib/use-breadcrumbs.ts
|
|
7118
|
-
init_react_import();
|
|
7119
|
-
var import_react40 = require("react");
|
|
7120
|
-
var useBreadcrumbs = (renderCount) => {
|
|
7121
|
-
const selectedId = useAppStore((s) => {
|
|
7122
|
-
var _a;
|
|
7123
|
-
return (_a = s.selectedItem) == null ? void 0 : _a.props.id;
|
|
7124
|
-
});
|
|
7125
|
-
const config = useAppStore((s) => s.config);
|
|
7126
|
-
const path = useAppStore((s) => {
|
|
7127
|
-
var _a;
|
|
7128
|
-
return (_a = s.state.indexes.nodes[selectedId]) == null ? void 0 : _a.path;
|
|
7129
|
-
});
|
|
7130
|
-
const appStore = useAppStoreApi();
|
|
7131
|
-
return (0, import_react40.useMemo)(() => {
|
|
7132
|
-
const breadcrumbs = (path == null ? void 0 : path.map((zoneCompound) => {
|
|
7133
|
-
var _a, _b, _c;
|
|
7134
|
-
const [componentId] = zoneCompound.split(":");
|
|
7135
|
-
if (componentId === "root") {
|
|
7136
|
-
return {
|
|
7137
|
-
label: "Page",
|
|
7138
|
-
selector: null
|
|
7139
|
-
};
|
|
7140
|
-
}
|
|
7141
|
-
const node = appStore.getState().state.indexes.nodes[componentId];
|
|
7142
|
-
const parentId = node.path[node.path.length - 1];
|
|
7143
|
-
const contentIds = ((_a = appStore.getState().state.indexes.zones[parentId]) == null ? void 0 : _a.contentIds) || [];
|
|
7144
|
-
const index = contentIds.indexOf(componentId);
|
|
7145
|
-
const label = node ? (_c = (_b = config.components[node.data.type]) == null ? void 0 : _b.label) != null ? _c : node.data.type : "Component";
|
|
7146
|
-
return {
|
|
7147
|
-
label,
|
|
7148
|
-
selector: node ? {
|
|
7149
|
-
index,
|
|
7150
|
-
zone: node.path[node.path.length - 1]
|
|
7151
|
-
} : null
|
|
7152
|
-
};
|
|
7153
|
-
})) || [];
|
|
7154
|
-
if (renderCount) {
|
|
7155
|
-
return breadcrumbs.slice(breadcrumbs.length - renderCount);
|
|
7156
|
-
}
|
|
7157
|
-
return breadcrumbs;
|
|
7158
|
-
}, [path, renderCount]);
|
|
7159
|
-
};
|
|
7160
|
-
|
|
7161
|
-
// components/SidebarSection/index.tsx
|
|
7162
|
-
var import_jsx_runtime29 = require("react/jsx-runtime");
|
|
7163
|
-
var getClassName20 = get_class_name_factory_default("SidebarSection", styles_module_default14);
|
|
7164
|
-
var SidebarSection = ({
|
|
7165
|
-
children,
|
|
7166
|
-
title,
|
|
7167
|
-
background,
|
|
7168
|
-
showBreadcrumbs,
|
|
7169
|
-
noBorderTop,
|
|
7170
|
-
noPadding,
|
|
7171
|
-
isLoading
|
|
7172
|
-
}) => {
|
|
7173
|
-
const setUi = useAppStore((s) => s.setUi);
|
|
7174
|
-
const breadcrumbs = useBreadcrumbs(1);
|
|
7175
|
-
return /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(
|
|
7176
|
-
"div",
|
|
7177
|
-
{
|
|
7178
|
-
className: getClassName20({ noBorderTop, noPadding }),
|
|
7179
|
-
style: { background },
|
|
7180
|
-
children: [
|
|
7181
|
-
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: getClassName20("title"), children: /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: getClassName20("breadcrumbs"), children: [
|
|
7182
|
-
showBreadcrumbs ? breadcrumbs.map((breadcrumb, i) => /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: getClassName20("breadcrumb"), children: [
|
|
7183
|
-
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
7184
|
-
"button",
|
|
7185
|
-
{
|
|
7186
|
-
type: "button",
|
|
7187
|
-
className: getClassName20("breadcrumbLabel"),
|
|
7188
|
-
onClick: () => setUi({ itemSelector: breadcrumb.selector }),
|
|
7189
|
-
children: breadcrumb.label
|
|
7190
|
-
}
|
|
7191
|
-
),
|
|
7192
|
-
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(ChevronRight, { size: 16 })
|
|
7193
|
-
] }, i)) : null,
|
|
7194
|
-
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: getClassName20("heading"), children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(Heading, { rank: "2", size: "xs", children: title }) })
|
|
7195
|
-
] }) }),
|
|
7196
|
-
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: getClassName20("content"), children }),
|
|
7197
|
-
isLoading && /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: getClassName20("loadingOverlay"), children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(Loader, { size: 32 }) })
|
|
7198
|
-
]
|
|
7199
|
-
}
|
|
7200
|
-
);
|
|
7201
|
-
};
|
|
7202
|
-
|
|
7203
|
-
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/styles.module.css#css-module
|
|
7204
|
-
init_react_import();
|
|
7205
|
-
var styles_module_default15 = { "Puck": "_Puck_1yxlw_19", "Puck-portal": "_Puck-portal_1yxlw_31", "PuckLayout-inner": "_PuckLayout-inner_1yxlw_38", "PuckLayout--mounted": "_PuckLayout--mounted_1yxlw_59", "PuckLayout--leftSideBarVisible": "_PuckLayout--leftSideBarVisible_1yxlw_63", "PuckLayout--rightSideBarVisible": "_PuckLayout--rightSideBarVisible_1yxlw_69", "PuckLayout-mounted": "_PuckLayout-mounted_1yxlw_83", "PuckLayout": "_PuckLayout_1yxlw_38" };
|
|
7191
|
+
var import_react61 = require("react");
|
|
7206
7192
|
|
|
7207
7193
|
// components/Puck/components/Fields/index.tsx
|
|
7208
7194
|
init_react_import();
|
|
7209
7195
|
|
|
7210
7196
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Fields/styles.module.css#css-module
|
|
7211
7197
|
init_react_import();
|
|
7212
|
-
var
|
|
7198
|
+
var styles_module_default14 = { "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" };
|
|
7213
7199
|
|
|
7214
7200
|
// components/Puck/components/Fields/index.tsx
|
|
7215
|
-
var
|
|
7201
|
+
var import_react40 = require("react");
|
|
7216
7202
|
var import_shallow5 = require("zustand/react/shallow");
|
|
7217
|
-
var
|
|
7218
|
-
var
|
|
7203
|
+
var import_jsx_runtime29 = require("react/jsx-runtime");
|
|
7204
|
+
var getClassName20 = get_class_name_factory_default("PuckFields", styles_module_default14);
|
|
7219
7205
|
var DefaultFields = ({
|
|
7220
7206
|
children
|
|
7221
7207
|
}) => {
|
|
7222
|
-
return /* @__PURE__ */ (0,
|
|
7208
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_jsx_runtime29.Fragment, { children });
|
|
7223
7209
|
};
|
|
7224
7210
|
var createOnChange = (fieldName, appStore) => (value, updatedUi) => __async(void 0, null, function* () {
|
|
7225
7211
|
let currentProps;
|
|
@@ -7285,13 +7271,13 @@ var FieldsChild = ({ fieldName }) => {
|
|
|
7285
7271
|
})
|
|
7286
7272
|
);
|
|
7287
7273
|
const appStore = useAppStoreApi();
|
|
7288
|
-
const onChange = (0,
|
|
7274
|
+
const onChange = (0, import_react40.useCallback)(createOnChange(fieldName, appStore), [
|
|
7289
7275
|
fieldName
|
|
7290
7276
|
]);
|
|
7291
7277
|
const { visible = true } = field != null ? field : {};
|
|
7292
7278
|
if (!field || !id || !visible) return null;
|
|
7293
7279
|
if (field.type === "slot") return null;
|
|
7294
|
-
return /* @__PURE__ */ (0,
|
|
7280
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: getClassName20("field"), children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
7295
7281
|
AutoFieldPrivate,
|
|
7296
7282
|
{
|
|
7297
7283
|
field,
|
|
@@ -7303,7 +7289,7 @@ var FieldsChild = ({ fieldName }) => {
|
|
|
7303
7289
|
}
|
|
7304
7290
|
) }, id);
|
|
7305
7291
|
};
|
|
7306
|
-
var FieldsChildMemo = (0,
|
|
7292
|
+
var FieldsChildMemo = (0, import_react40.memo)(FieldsChild);
|
|
7307
7293
|
var FieldsInternal = ({ wrapFields = true }) => {
|
|
7308
7294
|
const overrides = useAppStore((s) => s.overrides);
|
|
7309
7295
|
const componentResolving = useAppStore((s) => {
|
|
@@ -7328,41 +7314,41 @@ var FieldsInternal = ({ wrapFields = true }) => {
|
|
|
7328
7314
|
})
|
|
7329
7315
|
);
|
|
7330
7316
|
const isLoading = fieldsLoading || componentResolving;
|
|
7331
|
-
const Wrapper = (0,
|
|
7332
|
-
return /* @__PURE__ */ (0,
|
|
7317
|
+
const Wrapper = (0, import_react40.useMemo)(() => overrides.fields || DefaultFields, [overrides]);
|
|
7318
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(
|
|
7333
7319
|
"form",
|
|
7334
7320
|
{
|
|
7335
|
-
className:
|
|
7321
|
+
className: getClassName20({ wrapFields }),
|
|
7336
7322
|
onSubmit: (e) => {
|
|
7337
7323
|
e.preventDefault();
|
|
7338
7324
|
},
|
|
7339
7325
|
children: [
|
|
7340
|
-
/* @__PURE__ */ (0,
|
|
7341
|
-
isLoading && /* @__PURE__ */ (0,
|
|
7326
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(Wrapper, { isLoading, itemSelector, children: fieldNames.map((fieldName) => /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(FieldsChildMemo, { fieldName }, fieldName)) }),
|
|
7327
|
+
isLoading && /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: getClassName20("loadingOverlay"), children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: getClassName20("loadingOverlayInner"), children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(Loader, { size: 16 }) }) })
|
|
7342
7328
|
]
|
|
7343
7329
|
}
|
|
7344
7330
|
);
|
|
7345
7331
|
};
|
|
7346
|
-
var Fields = (0,
|
|
7332
|
+
var Fields = (0, import_react40.memo)(FieldsInternal);
|
|
7347
7333
|
|
|
7348
7334
|
// components/Puck/components/Components/index.tsx
|
|
7349
7335
|
init_react_import();
|
|
7350
7336
|
|
|
7351
7337
|
// lib/use-component-list.tsx
|
|
7352
7338
|
init_react_import();
|
|
7353
|
-
var
|
|
7339
|
+
var import_react42 = require("react");
|
|
7354
7340
|
|
|
7355
7341
|
// components/ComponentList/index.tsx
|
|
7356
7342
|
init_react_import();
|
|
7357
7343
|
|
|
7358
7344
|
// css-module:/home/runner/work/puck/puck/packages/core/components/ComponentList/styles.module.css#css-module
|
|
7359
7345
|
init_react_import();
|
|
7360
|
-
var
|
|
7346
|
+
var styles_module_default15 = { "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" };
|
|
7361
7347
|
|
|
7362
7348
|
// components/ComponentList/index.tsx
|
|
7363
|
-
var
|
|
7364
|
-
var
|
|
7365
|
-
var
|
|
7349
|
+
var import_react41 = require("react");
|
|
7350
|
+
var import_jsx_runtime30 = require("react/jsx-runtime");
|
|
7351
|
+
var getClassName21 = get_class_name_factory_default("ComponentList", styles_module_default15);
|
|
7366
7352
|
var ComponentListItem = ({
|
|
7367
7353
|
name,
|
|
7368
7354
|
label
|
|
@@ -7374,14 +7360,14 @@ var ComponentListItem = ({
|
|
|
7374
7360
|
type: name
|
|
7375
7361
|
}).insert
|
|
7376
7362
|
);
|
|
7377
|
-
(0,
|
|
7363
|
+
(0, import_react41.useEffect)(() => {
|
|
7378
7364
|
if (overrides.componentItem) {
|
|
7379
7365
|
console.warn(
|
|
7380
7366
|
"The `componentItem` override has been deprecated and renamed to `drawerItem`"
|
|
7381
7367
|
);
|
|
7382
7368
|
}
|
|
7383
7369
|
}, [overrides]);
|
|
7384
|
-
return /* @__PURE__ */ (0,
|
|
7370
|
+
return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Drawer.Item, { label, name, isDragDisabled: !canInsert, children: (_a = overrides.componentItem) != null ? _a : overrides.drawerItem });
|
|
7385
7371
|
};
|
|
7386
7372
|
var ComponentList = ({
|
|
7387
7373
|
children,
|
|
@@ -7392,12 +7378,12 @@ var ComponentList = ({
|
|
|
7392
7378
|
const setUi = useAppStore((s) => s.setUi);
|
|
7393
7379
|
const componentList = useAppStore((s) => s.state.ui.componentList);
|
|
7394
7380
|
const { expanded = true } = componentList[id] || {};
|
|
7395
|
-
return /* @__PURE__ */ (0,
|
|
7396
|
-
title && /* @__PURE__ */ (0,
|
|
7381
|
+
return /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("div", { className: getClassName21({ isExpanded: expanded }), children: [
|
|
7382
|
+
title && /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(
|
|
7397
7383
|
"button",
|
|
7398
7384
|
{
|
|
7399
7385
|
type: "button",
|
|
7400
|
-
className:
|
|
7386
|
+
className: getClassName21("title"),
|
|
7401
7387
|
onClick: () => setUi({
|
|
7402
7388
|
componentList: __spreadProps(__spreadValues({}, componentList), {
|
|
7403
7389
|
[id]: __spreadProps(__spreadValues({}, componentList[id]), {
|
|
@@ -7407,14 +7393,14 @@ var ComponentList = ({
|
|
|
7407
7393
|
}),
|
|
7408
7394
|
title: expanded ? `Collapse${title ? ` ${title}` : ""}` : `Expand${title ? ` ${title}` : ""}`,
|
|
7409
7395
|
children: [
|
|
7410
|
-
/* @__PURE__ */ (0,
|
|
7411
|
-
/* @__PURE__ */ (0,
|
|
7396
|
+
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)("div", { children: title }),
|
|
7397
|
+
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)("div", { className: getClassName21("titleIcon"), children: expanded ? /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(ChevronUp, { size: 12 }) : /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(ChevronDown, { size: 12 }) })
|
|
7412
7398
|
]
|
|
7413
7399
|
}
|
|
7414
7400
|
),
|
|
7415
|
-
/* @__PURE__ */ (0,
|
|
7401
|
+
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)("div", { className: getClassName21("content"), children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Drawer, { children: children || Object.keys(config.components).map((componentKey) => {
|
|
7416
7402
|
var _a;
|
|
7417
|
-
return /* @__PURE__ */ (0,
|
|
7403
|
+
return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
|
7418
7404
|
ComponentListItem,
|
|
7419
7405
|
{
|
|
7420
7406
|
label: (_a = config.components[componentKey]["label"]) != null ? _a : componentKey,
|
|
@@ -7428,12 +7414,12 @@ var ComponentList = ({
|
|
|
7428
7414
|
ComponentList.Item = ComponentListItem;
|
|
7429
7415
|
|
|
7430
7416
|
// lib/use-component-list.tsx
|
|
7431
|
-
var
|
|
7417
|
+
var import_jsx_runtime31 = require("react/jsx-runtime");
|
|
7432
7418
|
var useComponentList = () => {
|
|
7433
|
-
const [componentList, setComponentList] = (0,
|
|
7419
|
+
const [componentList, setComponentList] = (0, import_react42.useState)();
|
|
7434
7420
|
const config = useAppStore((s) => s.config);
|
|
7435
7421
|
const uiComponentList = useAppStore((s) => s.state.ui.componentList);
|
|
7436
|
-
(0,
|
|
7422
|
+
(0, import_react42.useEffect)(() => {
|
|
7437
7423
|
var _a, _b, _c;
|
|
7438
7424
|
if (Object.keys(uiComponentList).length > 0) {
|
|
7439
7425
|
const matchedComponents = [];
|
|
@@ -7449,7 +7435,7 @@ var useComponentList = () => {
|
|
|
7449
7435
|
if (category.visible === false) {
|
|
7450
7436
|
return null;
|
|
7451
7437
|
}
|
|
7452
|
-
return /* @__PURE__ */ (0,
|
|
7438
|
+
return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
7453
7439
|
ComponentList,
|
|
7454
7440
|
{
|
|
7455
7441
|
id: categoryKey,
|
|
@@ -7457,7 +7443,7 @@ var useComponentList = () => {
|
|
|
7457
7443
|
children: category.components.map((componentName, i) => {
|
|
7458
7444
|
var _a2;
|
|
7459
7445
|
const componentConf = config.components[componentName] || {};
|
|
7460
|
-
return /* @__PURE__ */ (0,
|
|
7446
|
+
return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
7461
7447
|
ComponentList.Item,
|
|
7462
7448
|
{
|
|
7463
7449
|
label: (_a2 = componentConf["label"]) != null ? _a2 : componentName,
|
|
@@ -7477,7 +7463,7 @@ var useComponentList = () => {
|
|
|
7477
7463
|
);
|
|
7478
7464
|
if (remainingComponents.length > 0 && !((_a = uiComponentList.other) == null ? void 0 : _a.components) && ((_b = uiComponentList.other) == null ? void 0 : _b.visible) !== false) {
|
|
7479
7465
|
_componentList.push(
|
|
7480
|
-
/* @__PURE__ */ (0,
|
|
7466
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
7481
7467
|
ComponentList,
|
|
7482
7468
|
{
|
|
7483
7469
|
id: "other",
|
|
@@ -7485,7 +7471,7 @@ var useComponentList = () => {
|
|
|
7485
7471
|
children: remainingComponents.map((componentName, i) => {
|
|
7486
7472
|
var _a2;
|
|
7487
7473
|
const componentConf = config.components[componentName] || {};
|
|
7488
|
-
return /* @__PURE__ */ (0,
|
|
7474
|
+
return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
7489
7475
|
ComponentList.Item,
|
|
7490
7476
|
{
|
|
7491
7477
|
name: componentName,
|
|
@@ -7507,12 +7493,19 @@ var useComponentList = () => {
|
|
|
7507
7493
|
};
|
|
7508
7494
|
|
|
7509
7495
|
// components/Puck/components/Components/index.tsx
|
|
7510
|
-
var
|
|
7511
|
-
|
|
7496
|
+
var import_react43 = require("react");
|
|
7497
|
+
|
|
7498
|
+
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Components/styles.module.css#css-module
|
|
7499
|
+
init_react_import();
|
|
7500
|
+
var styles_module_default16 = { "Components": "_Components_3pbdy_1" };
|
|
7501
|
+
|
|
7502
|
+
// components/Puck/components/Components/index.tsx
|
|
7503
|
+
var import_jsx_runtime32 = require("react/jsx-runtime");
|
|
7504
|
+
var getClassName22 = get_class_name_factory_default("Components", styles_module_default16);
|
|
7512
7505
|
var Components = () => {
|
|
7513
7506
|
const overrides = useAppStore((s) => s.overrides);
|
|
7514
7507
|
const componentList = useComponentList();
|
|
7515
|
-
const Wrapper = (0,
|
|
7508
|
+
const Wrapper = (0, import_react43.useMemo)(() => {
|
|
7516
7509
|
if (overrides.components) {
|
|
7517
7510
|
console.warn(
|
|
7518
7511
|
"The `components` override has been deprecated and renamed to `drawer`"
|
|
@@ -7520,19 +7513,19 @@ var Components = () => {
|
|
|
7520
7513
|
}
|
|
7521
7514
|
return overrides.components || overrides.drawer || "div";
|
|
7522
7515
|
}, [overrides]);
|
|
7523
|
-
return /* @__PURE__ */ (0,
|
|
7516
|
+
return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("div", { className: getClassName22(), children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Wrapper, { children: componentList ? componentList : /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(ComponentList, { id: "all" }) }) });
|
|
7524
7517
|
};
|
|
7525
7518
|
|
|
7526
7519
|
// components/Puck/components/Preview/index.tsx
|
|
7527
7520
|
init_react_import();
|
|
7528
|
-
var
|
|
7521
|
+
var import_react45 = require("react");
|
|
7529
7522
|
|
|
7530
7523
|
// components/AutoFrame/index.tsx
|
|
7531
7524
|
init_react_import();
|
|
7532
|
-
var
|
|
7525
|
+
var import_react44 = require("react");
|
|
7533
7526
|
var import_object_hash = __toESM(require("object-hash"));
|
|
7534
7527
|
var import_react_dom3 = require("react-dom");
|
|
7535
|
-
var
|
|
7528
|
+
var import_jsx_runtime33 = require("react/jsx-runtime");
|
|
7536
7529
|
var styleSelector = 'style, link[rel="stylesheet"]';
|
|
7537
7530
|
var collectStyles = (doc) => {
|
|
7538
7531
|
const collected = [];
|
|
@@ -7582,7 +7575,7 @@ var CopyHostStyles = ({
|
|
|
7582
7575
|
onStylesLoaded = () => null
|
|
7583
7576
|
}) => {
|
|
7584
7577
|
const { document: doc, window: win } = useFrame();
|
|
7585
|
-
(0,
|
|
7578
|
+
(0, import_react44.useEffect)(() => {
|
|
7586
7579
|
if (!win || !doc) {
|
|
7587
7580
|
return () => {
|
|
7588
7581
|
};
|
|
@@ -7739,10 +7732,10 @@ var CopyHostStyles = ({
|
|
|
7739
7732
|
observer.disconnect();
|
|
7740
7733
|
};
|
|
7741
7734
|
}, []);
|
|
7742
|
-
return /* @__PURE__ */ (0,
|
|
7735
|
+
return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_jsx_runtime33.Fragment, { children });
|
|
7743
7736
|
};
|
|
7744
|
-
var autoFrameContext = (0,
|
|
7745
|
-
var useFrame = () => (0,
|
|
7737
|
+
var autoFrameContext = (0, import_react44.createContext)({});
|
|
7738
|
+
var useFrame = () => (0, import_react44.useContext)(autoFrameContext);
|
|
7746
7739
|
function AutoFrame(_a) {
|
|
7747
7740
|
var _b = _a, {
|
|
7748
7741
|
children,
|
|
@@ -7763,11 +7756,11 @@ function AutoFrame(_a) {
|
|
|
7763
7756
|
"onNotReady",
|
|
7764
7757
|
"frameRef"
|
|
7765
7758
|
]);
|
|
7766
|
-
const [loaded, setLoaded] = (0,
|
|
7767
|
-
const [ctx, setCtx] = (0,
|
|
7768
|
-
const [mountTarget, setMountTarget] = (0,
|
|
7769
|
-
const [stylesLoaded, setStylesLoaded] = (0,
|
|
7770
|
-
(0,
|
|
7759
|
+
const [loaded, setLoaded] = (0, import_react44.useState)(false);
|
|
7760
|
+
const [ctx, setCtx] = (0, import_react44.useState)({});
|
|
7761
|
+
const [mountTarget, setMountTarget] = (0, import_react44.useState)();
|
|
7762
|
+
const [stylesLoaded, setStylesLoaded] = (0, import_react44.useState)(false);
|
|
7763
|
+
(0, import_react44.useEffect)(() => {
|
|
7771
7764
|
var _a2;
|
|
7772
7765
|
if (frameRef.current) {
|
|
7773
7766
|
const doc = frameRef.current.contentDocument;
|
|
@@ -7786,7 +7779,7 @@ function AutoFrame(_a) {
|
|
|
7786
7779
|
}
|
|
7787
7780
|
}
|
|
7788
7781
|
}, [frameRef, loaded, stylesLoaded]);
|
|
7789
|
-
return /* @__PURE__ */ (0,
|
|
7782
|
+
return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
7790
7783
|
"iframe",
|
|
7791
7784
|
__spreadProps(__spreadValues({}, props), {
|
|
7792
7785
|
className,
|
|
@@ -7796,7 +7789,7 @@ function AutoFrame(_a) {
|
|
|
7796
7789
|
onLoad: () => {
|
|
7797
7790
|
setLoaded(true);
|
|
7798
7791
|
},
|
|
7799
|
-
children: /* @__PURE__ */ (0,
|
|
7792
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(autoFrameContext.Provider, { value: ctx, children: loaded && mountTarget && /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
7800
7793
|
CopyHostStyles,
|
|
7801
7794
|
{
|
|
7802
7795
|
debug,
|
|
@@ -7812,14 +7805,14 @@ var AutoFrame_default = AutoFrame;
|
|
|
7812
7805
|
|
|
7813
7806
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Preview/styles.module.css#css-module
|
|
7814
7807
|
init_react_import();
|
|
7815
|
-
var
|
|
7808
|
+
var styles_module_default17 = { "PuckPreview": "_PuckPreview_z2rgu_1", "PuckPreview-frame": "_PuckPreview-frame_z2rgu_6" };
|
|
7816
7809
|
|
|
7817
7810
|
// components/Puck/components/Preview/index.tsx
|
|
7818
|
-
var
|
|
7819
|
-
var getClassName23 = get_class_name_factory_default("PuckPreview",
|
|
7811
|
+
var import_jsx_runtime34 = require("react/jsx-runtime");
|
|
7812
|
+
var getClassName23 = get_class_name_factory_default("PuckPreview", styles_module_default17);
|
|
7820
7813
|
var useBubbleIframeEvents = (ref) => {
|
|
7821
7814
|
const status = useAppStore((s) => s.status);
|
|
7822
|
-
(0,
|
|
7815
|
+
(0, import_react45.useEffect)(() => {
|
|
7823
7816
|
if (ref.current && status === "READY") {
|
|
7824
7817
|
const iframe = ref.current;
|
|
7825
7818
|
const handlePointerMove = (event) => {
|
|
@@ -7868,7 +7861,7 @@ var Preview2 = ({ id = "puck-preview" }) => {
|
|
|
7868
7861
|
const renderData = useAppStore(
|
|
7869
7862
|
(s) => s.state.ui.previewMode === "edit" ? null : s.state.data
|
|
7870
7863
|
);
|
|
7871
|
-
const Page = (0,
|
|
7864
|
+
const Page = (0, import_react45.useCallback)(
|
|
7872
7865
|
(pageProps) => {
|
|
7873
7866
|
var _a, _b;
|
|
7874
7867
|
const propsWithSlots = useSlots(
|
|
@@ -7878,15 +7871,15 @@ var Preview2 = ({ id = "puck-preview" }) => {
|
|
|
7878
7871
|
);
|
|
7879
7872
|
return ((_a = config.root) == null ? void 0 : _a.render) ? (_b = config.root) == null ? void 0 : _b.render(__spreadValues({
|
|
7880
7873
|
id: "puck-root"
|
|
7881
|
-
}, propsWithSlots)) : /* @__PURE__ */ (0,
|
|
7874
|
+
}, propsWithSlots)) : /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_jsx_runtime34.Fragment, { children: propsWithSlots.children });
|
|
7882
7875
|
},
|
|
7883
7876
|
[config]
|
|
7884
7877
|
);
|
|
7885
|
-
const Frame = (0,
|
|
7878
|
+
const Frame = (0, import_react45.useMemo)(() => overrides.iframe, [overrides]);
|
|
7886
7879
|
const rootProps = root.props || root;
|
|
7887
|
-
const ref = (0,
|
|
7880
|
+
const ref = (0, import_react45.useRef)(null);
|
|
7888
7881
|
useBubbleIframeEvents(ref);
|
|
7889
|
-
const inner = !renderData ? /* @__PURE__ */ (0,
|
|
7882
|
+
const inner = !renderData ? /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
|
7890
7883
|
Page,
|
|
7891
7884
|
__spreadProps(__spreadValues({}, rootProps), {
|
|
7892
7885
|
puck: {
|
|
@@ -7896,15 +7889,15 @@ var Preview2 = ({ id = "puck-preview" }) => {
|
|
|
7896
7889
|
metadata
|
|
7897
7890
|
},
|
|
7898
7891
|
editMode: true,
|
|
7899
|
-
children: /* @__PURE__ */ (0,
|
|
7892
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(DropZonePure, { zone: rootDroppableId })
|
|
7900
7893
|
})
|
|
7901
|
-
) : /* @__PURE__ */ (0,
|
|
7902
|
-
(0,
|
|
7894
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Render, { data: renderData, config, metadata });
|
|
7895
|
+
(0, import_react45.useEffect)(() => {
|
|
7903
7896
|
if (!iframe.enabled) {
|
|
7904
7897
|
setStatus("READY");
|
|
7905
7898
|
}
|
|
7906
7899
|
}, [iframe.enabled]);
|
|
7907
|
-
return /* @__PURE__ */ (0,
|
|
7900
|
+
return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
|
7908
7901
|
"div",
|
|
7909
7902
|
{
|
|
7910
7903
|
className: getClassName23(),
|
|
@@ -7916,7 +7909,7 @@ var Preview2 = ({ id = "puck-preview" }) => {
|
|
|
7916
7909
|
dispatch({ type: "setUi", ui: { itemSelector: null } });
|
|
7917
7910
|
}
|
|
7918
7911
|
},
|
|
7919
|
-
children: iframe.enabled ? /* @__PURE__ */ (0,
|
|
7912
|
+
children: iframe.enabled ? /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
|
7920
7913
|
AutoFrame_default,
|
|
7921
7914
|
{
|
|
7922
7915
|
id: "preview-frame",
|
|
@@ -7929,14 +7922,14 @@ var Preview2 = ({ id = "puck-preview" }) => {
|
|
|
7929
7922
|
setStatus("MOUNTED");
|
|
7930
7923
|
},
|
|
7931
7924
|
frameRef: ref,
|
|
7932
|
-
children: /* @__PURE__ */ (0,
|
|
7925
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(autoFrameContext.Consumer, { children: ({ document: document2 }) => {
|
|
7933
7926
|
if (Frame) {
|
|
7934
|
-
return /* @__PURE__ */ (0,
|
|
7927
|
+
return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Frame, { document: document2, children: inner });
|
|
7935
7928
|
}
|
|
7936
7929
|
return inner;
|
|
7937
7930
|
} })
|
|
7938
7931
|
}
|
|
7939
|
-
) : /* @__PURE__ */ (0,
|
|
7932
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
|
7940
7933
|
"div",
|
|
7941
7934
|
{
|
|
7942
7935
|
id: "preview-frame",
|
|
@@ -7958,7 +7951,7 @@ init_react_import();
|
|
|
7958
7951
|
|
|
7959
7952
|
// css-module:/home/runner/work/puck/puck/packages/core/components/LayerTree/styles.module.css#css-module
|
|
7960
7953
|
init_react_import();
|
|
7961
|
-
var
|
|
7954
|
+
var styles_module_default18 = { "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" };
|
|
7962
7955
|
|
|
7963
7956
|
// lib/scroll-into-view.ts
|
|
7964
7957
|
init_react_import();
|
|
@@ -7972,7 +7965,7 @@ var scrollIntoView = (el) => {
|
|
|
7972
7965
|
};
|
|
7973
7966
|
|
|
7974
7967
|
// components/LayerTree/index.tsx
|
|
7975
|
-
var
|
|
7968
|
+
var import_react46 = require("react");
|
|
7976
7969
|
|
|
7977
7970
|
// lib/on-scroll-end.ts
|
|
7978
7971
|
init_react_import();
|
|
@@ -7995,9 +7988,9 @@ var onScrollEnd = (frame, cb) => {
|
|
|
7995
7988
|
|
|
7996
7989
|
// components/LayerTree/index.tsx
|
|
7997
7990
|
var import_shallow6 = require("zustand/react/shallow");
|
|
7998
|
-
var
|
|
7999
|
-
var getClassName24 = get_class_name_factory_default("LayerTree",
|
|
8000
|
-
var getClassNameLayer = get_class_name_factory_default("Layer",
|
|
7991
|
+
var import_jsx_runtime35 = require("react/jsx-runtime");
|
|
7992
|
+
var getClassName24 = get_class_name_factory_default("LayerTree", styles_module_default18);
|
|
7993
|
+
var getClassNameLayer = get_class_name_factory_default("Layer", styles_module_default18);
|
|
8001
7994
|
var Layer = ({
|
|
8002
7995
|
index,
|
|
8003
7996
|
itemId,
|
|
@@ -8007,7 +8000,7 @@ var Layer = ({
|
|
|
8007
8000
|
const config = useAppStore((s) => s.config);
|
|
8008
8001
|
const itemSelector = useAppStore((s) => s.state.ui.itemSelector);
|
|
8009
8002
|
const dispatch = useAppStore((s) => s.dispatch);
|
|
8010
|
-
const setItemSelector = (0,
|
|
8003
|
+
const setItemSelector = (0, import_react46.useCallback)(
|
|
8011
8004
|
(itemSelector2) => {
|
|
8012
8005
|
dispatch({ type: "setUi", ui: { itemSelector: itemSelector2 } });
|
|
8013
8006
|
},
|
|
@@ -8027,7 +8020,7 @@ var Layer = ({
|
|
|
8027
8020
|
)
|
|
8028
8021
|
);
|
|
8029
8022
|
const containsZone = zonesForItem.length > 0;
|
|
8030
|
-
const zoneStore = (0,
|
|
8023
|
+
const zoneStore = (0, import_react46.useContext)(ZoneStoreContext);
|
|
8031
8024
|
const isHovering = useContextStore(
|
|
8032
8025
|
ZoneStoreContext,
|
|
8033
8026
|
(s) => s.hoveringComponent === itemId
|
|
@@ -8042,7 +8035,7 @@ var Layer = ({
|
|
|
8042
8035
|
});
|
|
8043
8036
|
const componentConfig = config.components[nodeData.data.type];
|
|
8044
8037
|
const label = (_a = componentConfig == null ? void 0 : componentConfig["label"]) != null ? _a : nodeData.data.type.toString();
|
|
8045
|
-
return /* @__PURE__ */ (0,
|
|
8038
|
+
return /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(
|
|
8046
8039
|
"li",
|
|
8047
8040
|
{
|
|
8048
8041
|
className: getClassNameLayer({
|
|
@@ -8052,7 +8045,7 @@ var Layer = ({
|
|
|
8052
8045
|
childIsSelected
|
|
8053
8046
|
}),
|
|
8054
8047
|
children: [
|
|
8055
|
-
/* @__PURE__ */ (0,
|
|
8048
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: getClassNameLayer("inner"), children: /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(
|
|
8056
8049
|
"button",
|
|
8057
8050
|
{
|
|
8058
8051
|
type: "button",
|
|
@@ -8090,22 +8083,22 @@ var Layer = ({
|
|
|
8090
8083
|
zoneStore.setState({ hoveringComponent: null });
|
|
8091
8084
|
},
|
|
8092
8085
|
children: [
|
|
8093
|
-
containsZone && /* @__PURE__ */ (0,
|
|
8086
|
+
containsZone && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
|
8094
8087
|
"div",
|
|
8095
8088
|
{
|
|
8096
8089
|
className: getClassNameLayer("chevron"),
|
|
8097
8090
|
title: isSelected ? "Collapse" : "Expand",
|
|
8098
|
-
children: /* @__PURE__ */ (0,
|
|
8091
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(ChevronDown, { size: "12" })
|
|
8099
8092
|
}
|
|
8100
8093
|
),
|
|
8101
|
-
/* @__PURE__ */ (0,
|
|
8102
|
-
/* @__PURE__ */ (0,
|
|
8103
|
-
/* @__PURE__ */ (0,
|
|
8094
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { className: getClassNameLayer("title"), children: [
|
|
8095
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: getClassNameLayer("icon"), children: nodeData.data.type === "Text" || nodeData.data.type === "Heading" ? /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Type, { size: "16" }) : /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(LayoutGrid, { size: "16" }) }),
|
|
8096
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: getClassNameLayer("name"), children: label })
|
|
8104
8097
|
] })
|
|
8105
8098
|
]
|
|
8106
8099
|
}
|
|
8107
8100
|
) }),
|
|
8108
|
-
containsZone && zonesForItem.map((subzone) => /* @__PURE__ */ (0,
|
|
8101
|
+
containsZone && zonesForItem.map((subzone) => /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: getClassNameLayer("zones"), children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(LayerTree, { zoneCompound: subzone }) }, subzone))
|
|
8109
8102
|
]
|
|
8110
8103
|
}
|
|
8111
8104
|
);
|
|
@@ -8131,15 +8124,15 @@ var LayerTree = ({
|
|
|
8131
8124
|
}
|
|
8132
8125
|
)
|
|
8133
8126
|
);
|
|
8134
|
-
return /* @__PURE__ */ (0,
|
|
8135
|
-
label && /* @__PURE__ */ (0,
|
|
8136
|
-
/* @__PURE__ */ (0,
|
|
8127
|
+
return /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(import_jsx_runtime35.Fragment, { children: [
|
|
8128
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { className: getClassName24("zoneTitle"), children: [
|
|
8129
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: getClassName24("zoneIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Layers, { size: "16" }) }),
|
|
8137
8130
|
label
|
|
8138
8131
|
] }),
|
|
8139
|
-
/* @__PURE__ */ (0,
|
|
8140
|
-
contentIds.length === 0 && /* @__PURE__ */ (0,
|
|
8132
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("ul", { className: getClassName24(), children: [
|
|
8133
|
+
contentIds.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: getClassName24("helper"), children: "No items" }),
|
|
8141
8134
|
contentIds.map((itemId, i) => {
|
|
8142
|
-
return /* @__PURE__ */ (0,
|
|
8135
|
+
return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
|
8143
8136
|
Layer,
|
|
8144
8137
|
{
|
|
8145
8138
|
index: i,
|
|
@@ -8154,7 +8147,7 @@ var LayerTree = ({
|
|
|
8154
8147
|
};
|
|
8155
8148
|
|
|
8156
8149
|
// components/Puck/components/Outline/index.tsx
|
|
8157
|
-
var
|
|
8150
|
+
var import_react47 = require("react");
|
|
8158
8151
|
|
|
8159
8152
|
// lib/data/find-zones-for-area.ts
|
|
8160
8153
|
init_react_import();
|
|
@@ -8166,867 +8159,1050 @@ var findZonesForArea = (state, area) => {
|
|
|
8166
8159
|
|
|
8167
8160
|
// components/Puck/components/Outline/index.tsx
|
|
8168
8161
|
var import_shallow7 = require("zustand/react/shallow");
|
|
8169
|
-
|
|
8162
|
+
|
|
8163
|
+
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Outline/styles.module.css#css-module
|
|
8164
|
+
init_react_import();
|
|
8165
|
+
var styles_module_default19 = { "Outline": "_Outline_cvjlj_1" };
|
|
8166
|
+
|
|
8167
|
+
// components/Puck/components/Outline/index.tsx
|
|
8168
|
+
var import_jsx_runtime36 = require("react/jsx-runtime");
|
|
8169
|
+
var getClassName25 = get_class_name_factory_default("Outline", styles_module_default19);
|
|
8170
8170
|
var Outline = () => {
|
|
8171
8171
|
const outlineOverride = useAppStore((s) => s.overrides.outline);
|
|
8172
8172
|
const rootZones = useAppStore(
|
|
8173
8173
|
(0, import_shallow7.useShallow)((s) => findZonesForArea(s.state, "root"))
|
|
8174
8174
|
);
|
|
8175
|
-
const Wrapper = (0,
|
|
8176
|
-
return /* @__PURE__ */ (0,
|
|
8175
|
+
const Wrapper = (0, import_react47.useMemo)(() => outlineOverride || "div", [outlineOverride]);
|
|
8176
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: getClassName25(), children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Wrapper, { children: rootZones.map((zoneCompound) => /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
8177
8177
|
LayerTree,
|
|
8178
8178
|
{
|
|
8179
8179
|
label: rootZones.length === 1 ? "" : zoneCompound.split(":")[1],
|
|
8180
8180
|
zoneCompound
|
|
8181
8181
|
},
|
|
8182
8182
|
zoneCompound
|
|
8183
|
-
)) });
|
|
8183
|
+
)) }) });
|
|
8184
8184
|
};
|
|
8185
8185
|
|
|
8186
|
-
//
|
|
8187
|
-
init_react_import();
|
|
8188
|
-
var import_react51 = require("react");
|
|
8189
|
-
|
|
8190
|
-
// components/ViewportControls/index.tsx
|
|
8186
|
+
// lib/use-loaded-overrides.ts
|
|
8191
8187
|
init_react_import();
|
|
8192
|
-
var
|
|
8188
|
+
var import_react48 = require("react");
|
|
8193
8189
|
|
|
8194
|
-
//
|
|
8190
|
+
// lib/load-overrides.ts
|
|
8195
8191
|
init_react_import();
|
|
8196
|
-
var
|
|
8197
|
-
|
|
8198
|
-
|
|
8199
|
-
var import_jsx_runtime38 = require("react/jsx-runtime");
|
|
8200
|
-
var icons = {
|
|
8201
|
-
Smartphone: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(Smartphone, { size: 16 }),
|
|
8202
|
-
Tablet: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(Tablet, { size: 16 }),
|
|
8203
|
-
Monitor: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(Monitor, { size: 16 })
|
|
8204
|
-
};
|
|
8205
|
-
var getClassName25 = get_class_name_factory_default("ViewportControls", styles_module_default20);
|
|
8206
|
-
var getClassNameButton = get_class_name_factory_default("ViewportButton", styles_module_default20);
|
|
8207
|
-
var ViewportButton = ({
|
|
8208
|
-
children,
|
|
8209
|
-
height = "auto",
|
|
8210
|
-
title,
|
|
8211
|
-
width,
|
|
8212
|
-
onClick
|
|
8192
|
+
var loadOverrides = ({
|
|
8193
|
+
overrides,
|
|
8194
|
+
plugins
|
|
8213
8195
|
}) => {
|
|
8214
|
-
const
|
|
8215
|
-
|
|
8216
|
-
|
|
8217
|
-
|
|
8218
|
-
|
|
8219
|
-
|
|
8220
|
-
|
|
8221
|
-
|
|
8222
|
-
|
|
8223
|
-
|
|
8224
|
-
|
|
8225
|
-
|
|
8226
|
-
|
|
8227
|
-
|
|
8228
|
-
|
|
8229
|
-
|
|
8230
|
-
|
|
8231
|
-
|
|
8196
|
+
const collected = __spreadValues({}, overrides);
|
|
8197
|
+
plugins == null ? void 0 : plugins.forEach((plugin) => {
|
|
8198
|
+
if (!plugin.overrides) return;
|
|
8199
|
+
Object.keys(plugin.overrides).forEach((_overridesType) => {
|
|
8200
|
+
var _a;
|
|
8201
|
+
const overridesType = _overridesType;
|
|
8202
|
+
if (!((_a = plugin.overrides) == null ? void 0 : _a[overridesType])) return;
|
|
8203
|
+
if (overridesType === "fieldTypes") {
|
|
8204
|
+
const fieldTypes = plugin.overrides.fieldTypes;
|
|
8205
|
+
Object.keys(fieldTypes).forEach((fieldType) => {
|
|
8206
|
+
collected.fieldTypes = collected.fieldTypes || {};
|
|
8207
|
+
const childNode2 = collected.fieldTypes[fieldType];
|
|
8208
|
+
const Comp2 = (props) => fieldTypes[fieldType](__spreadProps(__spreadValues({}, props), {
|
|
8209
|
+
children: childNode2 ? childNode2(props) : props.children
|
|
8210
|
+
}));
|
|
8211
|
+
collected.fieldTypes[fieldType] = Comp2;
|
|
8212
|
+
});
|
|
8213
|
+
return;
|
|
8214
|
+
}
|
|
8215
|
+
const childNode = collected[overridesType];
|
|
8216
|
+
const Comp = (props) => plugin.overrides[overridesType](__spreadProps(__spreadValues({}, props), {
|
|
8217
|
+
children: childNode ? childNode(props) : props.children
|
|
8218
|
+
}));
|
|
8219
|
+
collected[overridesType] = Comp;
|
|
8220
|
+
});
|
|
8221
|
+
});
|
|
8222
|
+
return collected;
|
|
8232
8223
|
};
|
|
8233
|
-
|
|
8234
|
-
|
|
8235
|
-
|
|
8236
|
-
|
|
8237
|
-
|
|
8238
|
-
{ label: "125%", value: 1.25 },
|
|
8239
|
-
{ label: "150%", value: 1.5 },
|
|
8240
|
-
{ label: "200%", value: 2 }
|
|
8241
|
-
];
|
|
8242
|
-
var ViewportControls = ({
|
|
8243
|
-
autoZoom,
|
|
8244
|
-
zoom,
|
|
8245
|
-
onViewportChange,
|
|
8246
|
-
onZoom
|
|
8224
|
+
|
|
8225
|
+
// lib/use-loaded-overrides.ts
|
|
8226
|
+
var useLoadedOverrides = ({
|
|
8227
|
+
overrides,
|
|
8228
|
+
plugins
|
|
8247
8229
|
}) => {
|
|
8248
|
-
|
|
8249
|
-
|
|
8250
|
-
|
|
8251
|
-
|
|
8252
|
-
|
|
8253
|
-
|
|
8254
|
-
|
|
8255
|
-
|
|
8256
|
-
|
|
8257
|
-
|
|
8258
|
-
|
|
8259
|
-
|
|
8260
|
-
|
|
8261
|
-
|
|
8262
|
-
|
|
8263
|
-
|
|
8230
|
+
return (0, import_react48.useMemo)(() => {
|
|
8231
|
+
return loadOverrides({ overrides, plugins });
|
|
8232
|
+
}, [plugins, overrides]);
|
|
8233
|
+
};
|
|
8234
|
+
|
|
8235
|
+
// lib/use-puck.ts
|
|
8236
|
+
init_react_import();
|
|
8237
|
+
var import_react49 = require("react");
|
|
8238
|
+
var import_zustand6 = require("zustand");
|
|
8239
|
+
var generateUsePuck = (store) => {
|
|
8240
|
+
const history = {
|
|
8241
|
+
back: store.history.back,
|
|
8242
|
+
forward: store.history.forward,
|
|
8243
|
+
setHistories: store.history.setHistories,
|
|
8244
|
+
setHistoryIndex: store.history.setHistoryIndex,
|
|
8245
|
+
hasPast: store.history.hasPast(),
|
|
8246
|
+
hasFuture: store.history.hasFuture(),
|
|
8247
|
+
histories: store.history.histories,
|
|
8248
|
+
index: store.history.index
|
|
8249
|
+
};
|
|
8250
|
+
const storeData = {
|
|
8251
|
+
appState: makeStatePublic(store.state),
|
|
8252
|
+
config: store.config,
|
|
8253
|
+
dispatch: store.dispatch,
|
|
8254
|
+
getPermissions: store.permissions.getPermissions,
|
|
8255
|
+
refreshPermissions: store.permissions.refreshPermissions,
|
|
8256
|
+
history,
|
|
8257
|
+
selectedItem: store.selectedItem || null,
|
|
8258
|
+
getItemBySelector: (selector) => getItem(selector, store.state),
|
|
8259
|
+
getItemById: (id) => store.state.indexes.nodes[id].data,
|
|
8260
|
+
getSelectorForId: (id) => getSelectorForId(store.state, id)
|
|
8261
|
+
};
|
|
8262
|
+
return storeData;
|
|
8263
|
+
};
|
|
8264
|
+
var UsePuckStoreContext = (0, import_react49.createContext)(
|
|
8265
|
+
null
|
|
8266
|
+
);
|
|
8267
|
+
var convertToPickedStore = (store) => {
|
|
8268
|
+
return {
|
|
8269
|
+
state: store.state,
|
|
8270
|
+
config: store.config,
|
|
8271
|
+
dispatch: store.dispatch,
|
|
8272
|
+
permissions: store.permissions,
|
|
8273
|
+
history: store.history,
|
|
8274
|
+
selectedItem: store.selectedItem
|
|
8275
|
+
};
|
|
8276
|
+
};
|
|
8277
|
+
var useRegisterUsePuckStore = (appStore) => {
|
|
8278
|
+
const [usePuckStore] = (0, import_react49.useState)(
|
|
8279
|
+
() => (0, import_zustand6.createStore)(
|
|
8280
|
+
() => generateUsePuck(convertToPickedStore(appStore.getState()))
|
|
8281
|
+
)
|
|
8264
8282
|
);
|
|
8265
|
-
|
|
8266
|
-
|
|
8267
|
-
|
|
8268
|
-
{
|
|
8269
|
-
|
|
8270
|
-
width: viewport.width,
|
|
8271
|
-
title: viewport.label ? `Switch to ${viewport.label} viewport` : "Switch viewport",
|
|
8272
|
-
onClick: onViewportChange,
|
|
8273
|
-
children: typeof viewport.icon === "string" ? icons[viewport.icon] || viewport.icon : viewport.icon || icons.Smartphone
|
|
8274
|
-
},
|
|
8275
|
-
i
|
|
8276
|
-
)),
|
|
8277
|
-
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)("div", { className: getClassName25("divider") }),
|
|
8278
|
-
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
|
|
8279
|
-
IconButton,
|
|
8280
|
-
{
|
|
8281
|
-
type: "button",
|
|
8282
|
-
title: "Zoom viewport out",
|
|
8283
|
-
disabled: zoom <= ((_a = zoomOptions[0]) == null ? void 0 : _a.value),
|
|
8284
|
-
onClick: (e) => {
|
|
8285
|
-
e.stopPropagation();
|
|
8286
|
-
onZoom(
|
|
8287
|
-
zoomOptions[Math.max(
|
|
8288
|
-
zoomOptions.findIndex((option) => option.value === zoom) - 1,
|
|
8289
|
-
0
|
|
8290
|
-
)].value
|
|
8291
|
-
);
|
|
8292
|
-
},
|
|
8293
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(ZoomOut, { size: 16 })
|
|
8294
|
-
}
|
|
8295
|
-
),
|
|
8296
|
-
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
|
|
8297
|
-
IconButton,
|
|
8298
|
-
{
|
|
8299
|
-
type: "button",
|
|
8300
|
-
title: "Zoom viewport in",
|
|
8301
|
-
disabled: zoom >= ((_b = zoomOptions[zoomOptions.length - 1]) == null ? void 0 : _b.value),
|
|
8302
|
-
onClick: (e) => {
|
|
8303
|
-
e.stopPropagation();
|
|
8304
|
-
onZoom(
|
|
8305
|
-
zoomOptions[Math.min(
|
|
8306
|
-
zoomOptions.findIndex((option) => option.value === zoom) + 1,
|
|
8307
|
-
zoomOptions.length - 1
|
|
8308
|
-
)].value
|
|
8309
|
-
);
|
|
8310
|
-
},
|
|
8311
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(ZoomIn, { size: 16 })
|
|
8312
|
-
}
|
|
8313
|
-
),
|
|
8314
|
-
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)("div", { className: getClassName25("divider") }),
|
|
8315
|
-
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
|
|
8316
|
-
"select",
|
|
8317
|
-
{
|
|
8318
|
-
className: getClassName25("zoomSelect"),
|
|
8319
|
-
value: zoom.toString(),
|
|
8320
|
-
onClick: (e) => {
|
|
8321
|
-
e.stopPropagation();
|
|
8322
|
-
},
|
|
8323
|
-
onChange: (e) => {
|
|
8324
|
-
onZoom(parseFloat(e.currentTarget.value));
|
|
8325
|
-
},
|
|
8326
|
-
children: zoomOptions.map((option) => /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
|
|
8327
|
-
"option",
|
|
8328
|
-
{
|
|
8329
|
-
value: option.value,
|
|
8330
|
-
label: option.label
|
|
8331
|
-
},
|
|
8332
|
-
option.label
|
|
8333
|
-
))
|
|
8283
|
+
(0, import_react49.useEffect)(() => {
|
|
8284
|
+
return appStore.subscribe(
|
|
8285
|
+
(store) => convertToPickedStore(store),
|
|
8286
|
+
(pickedStore) => {
|
|
8287
|
+
usePuckStore.setState(generateUsePuck(pickedStore));
|
|
8334
8288
|
}
|
|
8335
|
-
)
|
|
8336
|
-
]
|
|
8289
|
+
);
|
|
8290
|
+
}, []);
|
|
8291
|
+
return usePuckStore;
|
|
8337
8292
|
};
|
|
8293
|
+
function createUsePuck() {
|
|
8294
|
+
return function usePuck2(selector) {
|
|
8295
|
+
const usePuckApi = (0, import_react49.useContext)(UsePuckStoreContext);
|
|
8296
|
+
if (!usePuckApi) {
|
|
8297
|
+
throw new Error("usePuck must be used inside <Puck>.");
|
|
8298
|
+
}
|
|
8299
|
+
const result = (0, import_zustand6.useStore)(
|
|
8300
|
+
usePuckApi,
|
|
8301
|
+
selector != null ? selector : (s) => s
|
|
8302
|
+
);
|
|
8303
|
+
return result;
|
|
8304
|
+
};
|
|
8305
|
+
}
|
|
8306
|
+
function usePuck() {
|
|
8307
|
+
(0, import_react49.useEffect)(() => {
|
|
8308
|
+
console.warn(
|
|
8309
|
+
"You're using the `usePuck` method without a selector, which may cause unnecessary re-renders. Replace with `createUsePuck` and provide a selector for improved performance."
|
|
8310
|
+
);
|
|
8311
|
+
}, []);
|
|
8312
|
+
return createUsePuck()((s) => s);
|
|
8313
|
+
}
|
|
8314
|
+
function useGetPuck() {
|
|
8315
|
+
const usePuckApi = (0, import_react49.useContext)(UsePuckStoreContext);
|
|
8316
|
+
if (!usePuckApi) {
|
|
8317
|
+
throw new Error("usePuckGet must be used inside <Puck>.");
|
|
8318
|
+
}
|
|
8319
|
+
return usePuckApi.getState;
|
|
8320
|
+
}
|
|
8338
8321
|
|
|
8339
|
-
//
|
|
8322
|
+
// components/Puck/index.tsx
|
|
8323
|
+
var import_fast_deep_equal = __toESM(require_fast_deep_equal());
|
|
8324
|
+
|
|
8325
|
+
// lib/data/to-component.ts
|
|
8340
8326
|
init_react_import();
|
|
8341
|
-
var
|
|
8327
|
+
var toComponent = (item) => {
|
|
8328
|
+
return "type" in item ? item : __spreadProps(__spreadValues({}, item), {
|
|
8329
|
+
props: __spreadProps(__spreadValues({}, item.props), { id: "root" }),
|
|
8330
|
+
type: "root"
|
|
8331
|
+
});
|
|
8332
|
+
};
|
|
8342
8333
|
|
|
8343
|
-
// components/Puck/components/
|
|
8344
|
-
|
|
8334
|
+
// components/Puck/components/Layout/index.tsx
|
|
8335
|
+
init_react_import();
|
|
8336
|
+
var import_react60 = require("react");
|
|
8345
8337
|
|
|
8346
|
-
//
|
|
8338
|
+
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Layout/styles.module.css#css-module
|
|
8339
|
+
init_react_import();
|
|
8340
|
+
var styles_module_default20 = { "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" };
|
|
8341
|
+
|
|
8342
|
+
// lib/use-inject-css.ts
|
|
8347
8343
|
init_react_import();
|
|
8348
8344
|
var import_react50 = require("react");
|
|
8349
|
-
var
|
|
8350
|
-
var
|
|
8351
|
-
|
|
8352
|
-
|
|
8353
|
-
|
|
8354
|
-
|
|
8355
|
-
|
|
8356
|
-
|
|
8357
|
-
|
|
8358
|
-
|
|
8359
|
-
|
|
8360
|
-
|
|
8361
|
-
|
|
8345
|
+
var styles = ``;
|
|
8346
|
+
var useInjectStyleSheet = (initialStyles, iframeEnabled) => {
|
|
8347
|
+
const [el, setEl] = (0, import_react50.useState)();
|
|
8348
|
+
(0, import_react50.useEffect)(() => {
|
|
8349
|
+
setEl(document.createElement("style"));
|
|
8350
|
+
}, []);
|
|
8351
|
+
(0, import_react50.useEffect)(() => {
|
|
8352
|
+
var _a;
|
|
8353
|
+
if (!el || typeof window === "undefined") {
|
|
8354
|
+
return;
|
|
8355
|
+
}
|
|
8356
|
+
el.innerHTML = initialStyles;
|
|
8357
|
+
if (iframeEnabled) {
|
|
8358
|
+
const frame = getFrame();
|
|
8359
|
+
(_a = frame == null ? void 0 : frame.head) == null ? void 0 : _a.appendChild(el);
|
|
8360
|
+
}
|
|
8361
|
+
document.head.appendChild(el);
|
|
8362
|
+
}, [iframeEnabled, el]);
|
|
8363
|
+
return el;
|
|
8362
8364
|
};
|
|
8363
|
-
var
|
|
8364
|
-
|
|
8365
|
-
if (context === null) {
|
|
8366
|
-
throw new Error("useCanvasFrame must be used within a FrameProvider");
|
|
8367
|
-
}
|
|
8368
|
-
return context;
|
|
8365
|
+
var useInjectGlobalCss = (iframeEnabled) => {
|
|
8366
|
+
return useInjectStyleSheet(styles, iframeEnabled);
|
|
8369
8367
|
};
|
|
8370
8368
|
|
|
8371
|
-
// components/
|
|
8372
|
-
|
|
8373
|
-
var
|
|
8374
|
-
var
|
|
8375
|
-
|
|
8376
|
-
|
|
8377
|
-
|
|
8378
|
-
|
|
8369
|
+
// components/DefaultOverride/index.tsx
|
|
8370
|
+
init_react_import();
|
|
8371
|
+
var import_jsx_runtime37 = require("react/jsx-runtime");
|
|
8372
|
+
var DefaultOverride = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(import_jsx_runtime37.Fragment, { children });
|
|
8373
|
+
|
|
8374
|
+
// lib/use-preview-mode-hotkeys.ts
|
|
8375
|
+
init_react_import();
|
|
8376
|
+
var import_react51 = require("react");
|
|
8377
|
+
var usePreviewModeHotkeys = () => {
|
|
8378
|
+
const appStore = useAppStoreApi();
|
|
8379
|
+
const toggleInteractive = (0, import_react51.useCallback)(() => {
|
|
8380
|
+
const dispatch = appStore.getState().dispatch;
|
|
8381
|
+
dispatch({
|
|
8382
|
+
type: "setUi",
|
|
8383
|
+
ui: (ui) => ({
|
|
8384
|
+
previewMode: ui.previewMode === "edit" ? "interactive" : "edit"
|
|
8385
|
+
})
|
|
8386
|
+
});
|
|
8387
|
+
}, [appStore]);
|
|
8388
|
+
useHotkey({ meta: true, i: true }, toggleInteractive);
|
|
8389
|
+
useHotkey({ ctrl: true, i: true }, toggleInteractive);
|
|
8390
|
+
};
|
|
8391
|
+
|
|
8392
|
+
// components/Puck/components/Header/index.tsx
|
|
8393
|
+
init_react_import();
|
|
8394
|
+
var import_react52 = require("react");
|
|
8395
|
+
|
|
8396
|
+
// components/MenuBar/index.tsx
|
|
8397
|
+
init_react_import();
|
|
8398
|
+
|
|
8399
|
+
// css-module:/home/runner/work/puck/puck/packages/core/components/MenuBar/styles.module.css#css-module
|
|
8400
|
+
init_react_import();
|
|
8401
|
+
var styles_module_default21 = { "MenuBar": "_MenuBar_8pf8c_1", "MenuBar--menuOpen": "_MenuBar--menuOpen_8pf8c_14", "MenuBar-inner": "_MenuBar-inner_8pf8c_29", "MenuBar-history": "_MenuBar-history_8pf8c_45" };
|
|
8402
|
+
|
|
8403
|
+
// components/MenuBar/index.tsx
|
|
8404
|
+
var import_jsx_runtime38 = require("react/jsx-runtime");
|
|
8405
|
+
var getClassName26 = get_class_name_factory_default("MenuBar", styles_module_default21);
|
|
8406
|
+
function MenuBar({
|
|
8407
|
+
menuOpen = false,
|
|
8408
|
+
renderHeaderActions,
|
|
8409
|
+
setMenuOpen
|
|
8410
|
+
}) {
|
|
8411
|
+
const back = useAppStore((s) => s.history.back);
|
|
8412
|
+
const forward = useAppStore((s) => s.history.forward);
|
|
8413
|
+
const hasFuture = useAppStore((s) => s.history.hasFuture());
|
|
8414
|
+
const hasPast = useAppStore((s) => s.history.hasPast());
|
|
8415
|
+
return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
|
|
8416
|
+
"div",
|
|
8417
|
+
{
|
|
8418
|
+
className: getClassName26({ menuOpen }),
|
|
8419
|
+
onClick: (event) => {
|
|
8420
|
+
var _a;
|
|
8421
|
+
const element = event.target;
|
|
8422
|
+
if (window.matchMedia("(min-width: 638px)").matches) {
|
|
8423
|
+
return;
|
|
8424
|
+
}
|
|
8425
|
+
if (element.tagName === "A" && ((_a = element.getAttribute("href")) == null ? void 0 : _a.startsWith("#"))) {
|
|
8426
|
+
setMenuOpen(false);
|
|
8427
|
+
}
|
|
8428
|
+
},
|
|
8429
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("div", { className: getClassName26("inner"), children: [
|
|
8430
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("div", { className: getClassName26("history"), children: [
|
|
8431
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
|
|
8432
|
+
IconButton,
|
|
8433
|
+
{
|
|
8434
|
+
type: "button",
|
|
8435
|
+
title: "undo",
|
|
8436
|
+
disabled: !hasPast,
|
|
8437
|
+
onClick: back,
|
|
8438
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(Undo2, { size: 21 })
|
|
8439
|
+
}
|
|
8440
|
+
),
|
|
8441
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
|
|
8442
|
+
IconButton,
|
|
8443
|
+
{
|
|
8444
|
+
type: "button",
|
|
8445
|
+
title: "redo",
|
|
8446
|
+
disabled: !hasFuture,
|
|
8447
|
+
onClick: forward,
|
|
8448
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(Redo2, { size: 21 })
|
|
8449
|
+
}
|
|
8450
|
+
)
|
|
8451
|
+
] }),
|
|
8452
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)(import_jsx_runtime38.Fragment, { children: renderHeaderActions && renderHeaderActions() })
|
|
8453
|
+
] })
|
|
8454
|
+
}
|
|
8455
|
+
);
|
|
8456
|
+
}
|
|
8457
|
+
|
|
8458
|
+
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Header/styles.module.css#css-module
|
|
8459
|
+
init_react_import();
|
|
8460
|
+
var styles_module_default22 = { "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" };
|
|
8461
|
+
|
|
8462
|
+
// components/Puck/components/Header/index.tsx
|
|
8463
|
+
var import_jsx_runtime39 = require("react/jsx-runtime");
|
|
8464
|
+
var getClassName27 = get_class_name_factory_default("PuckHeader", styles_module_default22);
|
|
8465
|
+
var HeaderInner = () => {
|
|
8379
8466
|
const {
|
|
8380
|
-
|
|
8381
|
-
|
|
8382
|
-
|
|
8383
|
-
|
|
8384
|
-
|
|
8385
|
-
|
|
8386
|
-
|
|
8387
|
-
|
|
8388
|
-
|
|
8389
|
-
|
|
8390
|
-
|
|
8391
|
-
|
|
8392
|
-
|
|
8393
|
-
|
|
8394
|
-
|
|
8395
|
-
|
|
8396
|
-
|
|
8467
|
+
onPublish,
|
|
8468
|
+
renderHeader,
|
|
8469
|
+
renderHeaderActions,
|
|
8470
|
+
headerTitle,
|
|
8471
|
+
headerPath,
|
|
8472
|
+
iframe: _iframe
|
|
8473
|
+
} = usePropsContext();
|
|
8474
|
+
const dispatch = useAppStore((s) => s.dispatch);
|
|
8475
|
+
const appStore = useAppStoreApi();
|
|
8476
|
+
const defaultHeaderRender = (0, import_react52.useMemo)(() => {
|
|
8477
|
+
if (renderHeader) {
|
|
8478
|
+
console.warn(
|
|
8479
|
+
"`renderHeader` is deprecated. Please use `overrides.header` and the `usePuck` hook instead"
|
|
8480
|
+
);
|
|
8481
|
+
const RenderHeader = (_a) => {
|
|
8482
|
+
var _b = _a, { actions } = _b, props = __objRest(_b, ["actions"]);
|
|
8483
|
+
const Comp = renderHeader;
|
|
8484
|
+
const appState = useAppStore((s) => s.state);
|
|
8485
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState, children: actions }));
|
|
8486
|
+
};
|
|
8487
|
+
return RenderHeader;
|
|
8488
|
+
}
|
|
8489
|
+
return DefaultOverride;
|
|
8490
|
+
}, [renderHeader]);
|
|
8491
|
+
const defaultHeaderActionsRender = (0, import_react52.useMemo)(() => {
|
|
8492
|
+
if (renderHeaderActions) {
|
|
8493
|
+
console.warn(
|
|
8494
|
+
"`renderHeaderActions` is deprecated. Please use `overrides.headerActions` and the `usePuck` hook instead."
|
|
8495
|
+
);
|
|
8496
|
+
const RenderHeader = (props) => {
|
|
8497
|
+
const Comp = renderHeaderActions;
|
|
8498
|
+
const appState = useAppStore((s) => s.state);
|
|
8499
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState }));
|
|
8500
|
+
};
|
|
8501
|
+
return RenderHeader;
|
|
8502
|
+
}
|
|
8503
|
+
return DefaultOverride;
|
|
8504
|
+
}, [renderHeaderActions]);
|
|
8505
|
+
const CustomHeader = useAppStore(
|
|
8506
|
+
(s) => s.overrides.header || defaultHeaderRender
|
|
8397
8507
|
);
|
|
8398
|
-
const
|
|
8399
|
-
|
|
8400
|
-
rightSideBarVisible,
|
|
8401
|
-
leftSideBarWidth,
|
|
8402
|
-
rightSideBarWidth,
|
|
8403
|
-
viewports
|
|
8404
|
-
} = useAppStore(
|
|
8405
|
-
(0, import_shallow8.useShallow)((s) => ({
|
|
8406
|
-
leftSideBarVisible: s.state.ui.leftSideBarVisible,
|
|
8407
|
-
rightSideBarVisible: s.state.ui.rightSideBarVisible,
|
|
8408
|
-
leftSideBarWidth: s.state.ui.leftSideBarWidth,
|
|
8409
|
-
rightSideBarWidth: s.state.ui.rightSideBarWidth,
|
|
8410
|
-
viewports: s.state.ui.viewports
|
|
8411
|
-
}))
|
|
8508
|
+
const CustomHeaderActions = useAppStore(
|
|
8509
|
+
(s) => s.overrides.headerActions || defaultHeaderActionsRender
|
|
8412
8510
|
);
|
|
8413
|
-
const [
|
|
8414
|
-
const
|
|
8415
|
-
|
|
8416
|
-
const
|
|
8417
|
-
return
|
|
8418
|
-
}
|
|
8419
|
-
const
|
|
8420
|
-
|
|
8421
|
-
|
|
8511
|
+
const [menuOpen, setMenuOpen] = (0, import_react52.useState)(false);
|
|
8512
|
+
const rootTitle = useAppStore((s) => {
|
|
8513
|
+
var _a, _b;
|
|
8514
|
+
const rootData = (_a = s.state.indexes.nodes["root"]) == null ? void 0 : _a.data;
|
|
8515
|
+
return (_b = rootData.props.title) != null ? _b : "";
|
|
8516
|
+
});
|
|
8517
|
+
const leftSideBarVisible = useAppStore((s) => s.state.ui.leftSideBarVisible);
|
|
8518
|
+
const rightSideBarVisible = useAppStore(
|
|
8519
|
+
(s) => s.state.ui.rightSideBarVisible
|
|
8422
8520
|
);
|
|
8423
|
-
const
|
|
8424
|
-
|
|
8425
|
-
const
|
|
8426
|
-
const
|
|
8427
|
-
|
|
8428
|
-
|
|
8429
|
-
|
|
8430
|
-
|
|
8431
|
-
|
|
8432
|
-
|
|
8433
|
-
|
|
8434
|
-
|
|
8435
|
-
leftSideBarVisible,
|
|
8436
|
-
|
|
8437
|
-
|
|
8438
|
-
|
|
8439
|
-
viewports
|
|
8440
|
-
]);
|
|
8441
|
-
(0, import_react51.useEffect)(() => {
|
|
8442
|
-
const { height: frameHeight } = getFrameDimensions();
|
|
8443
|
-
if (viewports.current.height === "auto") {
|
|
8444
|
-
setZoomConfig(__spreadProps(__spreadValues({}, zoomConfig), {
|
|
8445
|
-
rootHeight: frameHeight / zoomConfig.zoom
|
|
8446
|
-
}));
|
|
8447
|
-
}
|
|
8448
|
-
}, [zoomConfig.zoom, getFrameDimensions, setZoomConfig]);
|
|
8449
|
-
(0, import_react51.useEffect)(() => {
|
|
8450
|
-
if (ZOOM_ON_CHANGE) {
|
|
8451
|
-
resetAutoZoom();
|
|
8452
|
-
}
|
|
8453
|
-
}, [viewports.current.width, viewports]);
|
|
8454
|
-
(0, import_react51.useEffect)(() => {
|
|
8455
|
-
if (!frameRef.current) return;
|
|
8456
|
-
const resizeObserver = new ResizeObserver(() => {
|
|
8457
|
-
if (!isResizingRef.current) {
|
|
8458
|
-
resetAutoZoom();
|
|
8459
|
-
}
|
|
8460
|
-
});
|
|
8461
|
-
resizeObserver.observe(frameRef.current);
|
|
8462
|
-
return () => {
|
|
8463
|
-
resizeObserver.disconnect();
|
|
8464
|
-
};
|
|
8465
|
-
}, [frameRef.current]);
|
|
8466
|
-
const [showLoader, setShowLoader] = (0, import_react51.useState)(false);
|
|
8467
|
-
(0, import_react51.useEffect)(() => {
|
|
8468
|
-
setTimeout(() => {
|
|
8469
|
-
setShowLoader(true);
|
|
8470
|
-
}, 500);
|
|
8471
|
-
}, []);
|
|
8472
|
-
return /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)(
|
|
8473
|
-
"div",
|
|
8521
|
+
const toggleSidebars = (0, import_react52.useCallback)(
|
|
8522
|
+
(sidebar) => {
|
|
8523
|
+
const widerViewport = window.matchMedia("(min-width: 638px)").matches;
|
|
8524
|
+
const sideBarVisible = sidebar === "left" ? leftSideBarVisible : rightSideBarVisible;
|
|
8525
|
+
const oppositeSideBar = sidebar === "left" ? "rightSideBarVisible" : "leftSideBarVisible";
|
|
8526
|
+
dispatch({
|
|
8527
|
+
type: "setUi",
|
|
8528
|
+
ui: __spreadValues({
|
|
8529
|
+
[`${sidebar}SideBarVisible`]: !sideBarVisible
|
|
8530
|
+
}, !widerViewport ? { [oppositeSideBar]: false } : {})
|
|
8531
|
+
});
|
|
8532
|
+
},
|
|
8533
|
+
[dispatch, leftSideBarVisible, rightSideBarVisible]
|
|
8534
|
+
);
|
|
8535
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
8536
|
+
CustomHeader,
|
|
8474
8537
|
{
|
|
8475
|
-
|
|
8476
|
-
|
|
8477
|
-
|
|
8478
|
-
|
|
8479
|
-
|
|
8480
|
-
|
|
8481
|
-
|
|
8482
|
-
|
|
8483
|
-
|
|
8484
|
-
ui: { itemSelector: null },
|
|
8485
|
-
recordHistory: true
|
|
8486
|
-
});
|
|
8538
|
+
actions: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(import_jsx_runtime39.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(CustomHeaderActions, { children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
8539
|
+
Button,
|
|
8540
|
+
{
|
|
8541
|
+
onClick: () => {
|
|
8542
|
+
const data = appStore.getState().state.data;
|
|
8543
|
+
onPublish && onPublish(data);
|
|
8544
|
+
},
|
|
8545
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Globe, { size: "14px" }),
|
|
8546
|
+
children: "Publish"
|
|
8487
8547
|
}
|
|
8488
|
-
},
|
|
8489
|
-
children:
|
|
8490
|
-
|
|
8491
|
-
|
|
8492
|
-
{
|
|
8493
|
-
|
|
8494
|
-
|
|
8495
|
-
|
|
8496
|
-
|
|
8497
|
-
|
|
8498
|
-
|
|
8499
|
-
|
|
8500
|
-
|
|
8501
|
-
|
|
8502
|
-
|
|
8503
|
-
|
|
8504
|
-
|
|
8505
|
-
|
|
8506
|
-
|
|
8507
|
-
|
|
8508
|
-
|
|
8509
|
-
|
|
8510
|
-
|
|
8511
|
-
|
|
8512
|
-
|
|
8513
|
-
|
|
8514
|
-
|
|
8515
|
-
|
|
8516
|
-
|
|
8517
|
-
|
|
8518
|
-
|
|
8519
|
-
|
|
8520
|
-
|
|
8521
|
-
|
|
8522
|
-
|
|
8523
|
-
|
|
8524
|
-
|
|
8525
|
-
|
|
8526
|
-
|
|
8527
|
-
|
|
8528
|
-
|
|
8529
|
-
|
|
8530
|
-
|
|
8531
|
-
|
|
8532
|
-
|
|
8533
|
-
|
|
8534
|
-
|
|
8535
|
-
|
|
8536
|
-
},
|
|
8537
|
-
|
|
8538
|
-
|
|
8539
|
-
|
|
8540
|
-
|
|
8541
|
-
|
|
8542
|
-
|
|
8548
|
+
) }) }),
|
|
8549
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
8550
|
+
"header",
|
|
8551
|
+
{
|
|
8552
|
+
className: getClassName27({ leftSideBarVisible, rightSideBarVisible }),
|
|
8553
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: getClassName27("inner"), children: [
|
|
8554
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: getClassName27("toggle"), children: [
|
|
8555
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { className: getClassName27("leftSideBarToggle"), children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
8556
|
+
IconButton,
|
|
8557
|
+
{
|
|
8558
|
+
type: "button",
|
|
8559
|
+
onClick: () => {
|
|
8560
|
+
toggleSidebars("left");
|
|
8561
|
+
},
|
|
8562
|
+
title: "Toggle left sidebar",
|
|
8563
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(PanelLeft, { focusable: "false" })
|
|
8564
|
+
}
|
|
8565
|
+
) }),
|
|
8566
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { className: getClassName27("rightSideBarToggle"), children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
8567
|
+
IconButton,
|
|
8568
|
+
{
|
|
8569
|
+
type: "button",
|
|
8570
|
+
onClick: () => {
|
|
8571
|
+
toggleSidebars("right");
|
|
8572
|
+
},
|
|
8573
|
+
title: "Toggle right sidebar",
|
|
8574
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(PanelRight, { focusable: "false" })
|
|
8575
|
+
}
|
|
8576
|
+
) })
|
|
8577
|
+
] }),
|
|
8578
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { className: getClassName27("title"), children: /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(Heading, { rank: "2", size: "xs", children: [
|
|
8579
|
+
headerTitle || rootTitle || "Page",
|
|
8580
|
+
headerPath && /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(import_jsx_runtime39.Fragment, { children: [
|
|
8581
|
+
" ",
|
|
8582
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)("code", { className: getClassName27("path"), children: headerPath })
|
|
8583
|
+
] })
|
|
8584
|
+
] }) }),
|
|
8585
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: getClassName27("tools"), children: [
|
|
8586
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { className: getClassName27("menuButton"), children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
8587
|
+
IconButton,
|
|
8588
|
+
{
|
|
8589
|
+
type: "button",
|
|
8590
|
+
onClick: () => {
|
|
8591
|
+
return setMenuOpen(!menuOpen);
|
|
8592
|
+
},
|
|
8593
|
+
title: "Toggle menu bar",
|
|
8594
|
+
children: menuOpen ? /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(ChevronUp, { focusable: "false" }) : /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(ChevronDown, { focusable: "false" })
|
|
8595
|
+
}
|
|
8596
|
+
) }),
|
|
8597
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
8598
|
+
MenuBar,
|
|
8599
|
+
{
|
|
8600
|
+
dispatch,
|
|
8601
|
+
onPublish,
|
|
8602
|
+
menuOpen,
|
|
8603
|
+
renderHeaderActions: () => /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(CustomHeaderActions, { children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
8604
|
+
Button,
|
|
8605
|
+
{
|
|
8606
|
+
onClick: () => {
|
|
8607
|
+
const data = appStore.getState().state.data;
|
|
8608
|
+
onPublish && onPublish(data);
|
|
8609
|
+
},
|
|
8610
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Globe, { size: "14px" }),
|
|
8611
|
+
children: "Publish"
|
|
8612
|
+
}
|
|
8613
|
+
) }),
|
|
8614
|
+
setMenuOpen
|
|
8615
|
+
}
|
|
8616
|
+
)
|
|
8617
|
+
] })
|
|
8618
|
+
] })
|
|
8619
|
+
}
|
|
8620
|
+
)
|
|
8543
8621
|
}
|
|
8544
8622
|
);
|
|
8545
8623
|
};
|
|
8624
|
+
var Header = (0, import_react52.memo)(HeaderInner);
|
|
8546
8625
|
|
|
8547
|
-
//
|
|
8626
|
+
// components/SidebarSection/index.tsx
|
|
8548
8627
|
init_react_import();
|
|
8549
|
-
var import_react52 = require("react");
|
|
8550
8628
|
|
|
8551
|
-
//
|
|
8629
|
+
// css-module:/home/runner/work/puck/puck/packages/core/components/SidebarSection/styles.module.css#css-module
|
|
8552
8630
|
init_react_import();
|
|
8553
|
-
var
|
|
8554
|
-
overrides,
|
|
8555
|
-
plugins
|
|
8556
|
-
}) => {
|
|
8557
|
-
const collected = __spreadValues({}, overrides);
|
|
8558
|
-
plugins == null ? void 0 : plugins.forEach((plugin) => {
|
|
8559
|
-
if (!plugin.overrides) return;
|
|
8560
|
-
Object.keys(plugin.overrides).forEach((_overridesType) => {
|
|
8561
|
-
var _a;
|
|
8562
|
-
const overridesType = _overridesType;
|
|
8563
|
-
if (!((_a = plugin.overrides) == null ? void 0 : _a[overridesType])) return;
|
|
8564
|
-
if (overridesType === "fieldTypes") {
|
|
8565
|
-
const fieldTypes = plugin.overrides.fieldTypes;
|
|
8566
|
-
Object.keys(fieldTypes).forEach((fieldType) => {
|
|
8567
|
-
collected.fieldTypes = collected.fieldTypes || {};
|
|
8568
|
-
const childNode2 = collected.fieldTypes[fieldType];
|
|
8569
|
-
const Comp2 = (props) => fieldTypes[fieldType](__spreadProps(__spreadValues({}, props), {
|
|
8570
|
-
children: childNode2 ? childNode2(props) : props.children
|
|
8571
|
-
}));
|
|
8572
|
-
collected.fieldTypes[fieldType] = Comp2;
|
|
8573
|
-
});
|
|
8574
|
-
return;
|
|
8575
|
-
}
|
|
8576
|
-
const childNode = collected[overridesType];
|
|
8577
|
-
const Comp = (props) => plugin.overrides[overridesType](__spreadProps(__spreadValues({}, props), {
|
|
8578
|
-
children: childNode ? childNode(props) : props.children
|
|
8579
|
-
}));
|
|
8580
|
-
collected[overridesType] = Comp;
|
|
8581
|
-
});
|
|
8582
|
-
});
|
|
8583
|
-
return collected;
|
|
8584
|
-
};
|
|
8631
|
+
var styles_module_default23 = { "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" };
|
|
8585
8632
|
|
|
8586
|
-
//
|
|
8587
|
-
|
|
8588
|
-
overrides,
|
|
8589
|
-
plugins
|
|
8590
|
-
}) => {
|
|
8591
|
-
return (0, import_react52.useMemo)(() => {
|
|
8592
|
-
return loadOverrides({ overrides, plugins });
|
|
8593
|
-
}, [plugins, overrides]);
|
|
8594
|
-
};
|
|
8633
|
+
// components/Breadcrumbs/index.tsx
|
|
8634
|
+
init_react_import();
|
|
8595
8635
|
|
|
8596
|
-
// components/
|
|
8636
|
+
// css-module:/home/runner/work/puck/puck/packages/core/components/Breadcrumbs/styles.module.css#css-module
|
|
8597
8637
|
init_react_import();
|
|
8598
|
-
var
|
|
8599
|
-
var DefaultOverride = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(import_jsx_runtime41.Fragment, { children });
|
|
8638
|
+
var styles_module_default24 = { "Breadcrumbs": "_Breadcrumbs_1c9yh_1", "Breadcrumbs-breadcrumbLabel": "_Breadcrumbs-breadcrumbLabel_1c9yh_7", "Breadcrumbs-breadcrumb": "_Breadcrumbs-breadcrumb_1c9yh_7" };
|
|
8600
8639
|
|
|
8601
|
-
// lib/use-
|
|
8640
|
+
// lib/use-breadcrumbs.ts
|
|
8602
8641
|
init_react_import();
|
|
8603
8642
|
var import_react53 = require("react");
|
|
8604
|
-
var
|
|
8605
|
-
|
|
8606
|
-
const [el, setEl] = (0, import_react53.useState)();
|
|
8607
|
-
(0, import_react53.useEffect)(() => {
|
|
8608
|
-
setEl(document.createElement("style"));
|
|
8609
|
-
}, []);
|
|
8610
|
-
(0, import_react53.useEffect)(() => {
|
|
8643
|
+
var useBreadcrumbs = (renderCount) => {
|
|
8644
|
+
const selectedId = useAppStore((s) => {
|
|
8611
8645
|
var _a;
|
|
8612
|
-
|
|
8613
|
-
|
|
8614
|
-
|
|
8615
|
-
|
|
8616
|
-
|
|
8617
|
-
|
|
8618
|
-
|
|
8646
|
+
return (_a = s.selectedItem) == null ? void 0 : _a.props.id;
|
|
8647
|
+
});
|
|
8648
|
+
const config = useAppStore((s) => s.config);
|
|
8649
|
+
const path = useAppStore((s) => {
|
|
8650
|
+
var _a;
|
|
8651
|
+
return (_a = s.state.indexes.nodes[selectedId]) == null ? void 0 : _a.path;
|
|
8652
|
+
});
|
|
8653
|
+
const appStore = useAppStoreApi();
|
|
8654
|
+
return (0, import_react53.useMemo)(() => {
|
|
8655
|
+
const breadcrumbs = (path == null ? void 0 : path.map((zoneCompound) => {
|
|
8656
|
+
var _a, _b, _c;
|
|
8657
|
+
const [componentId] = zoneCompound.split(":");
|
|
8658
|
+
if (componentId === "root") {
|
|
8659
|
+
return {
|
|
8660
|
+
label: "Page",
|
|
8661
|
+
selector: null
|
|
8662
|
+
};
|
|
8663
|
+
}
|
|
8664
|
+
const node = appStore.getState().state.indexes.nodes[componentId];
|
|
8665
|
+
const parentId = node.path[node.path.length - 1];
|
|
8666
|
+
const contentIds = ((_a = appStore.getState().state.indexes.zones[parentId]) == null ? void 0 : _a.contentIds) || [];
|
|
8667
|
+
const index = contentIds.indexOf(componentId);
|
|
8668
|
+
const label = node ? (_c = (_b = config.components[node.data.type]) == null ? void 0 : _b.label) != null ? _c : node.data.type : "Component";
|
|
8669
|
+
return {
|
|
8670
|
+
label,
|
|
8671
|
+
selector: node ? {
|
|
8672
|
+
index,
|
|
8673
|
+
zone: node.path[node.path.length - 1]
|
|
8674
|
+
} : null
|
|
8675
|
+
};
|
|
8676
|
+
})) || [];
|
|
8677
|
+
if (renderCount) {
|
|
8678
|
+
return breadcrumbs.slice(breadcrumbs.length - renderCount);
|
|
8619
8679
|
}
|
|
8620
|
-
|
|
8621
|
-
}, [
|
|
8622
|
-
return el;
|
|
8680
|
+
return breadcrumbs;
|
|
8681
|
+
}, [path, renderCount]);
|
|
8623
8682
|
};
|
|
8624
|
-
|
|
8625
|
-
|
|
8683
|
+
|
|
8684
|
+
// components/Breadcrumbs/index.tsx
|
|
8685
|
+
var import_jsx_runtime40 = require("react/jsx-runtime");
|
|
8686
|
+
var getClassName28 = get_class_name_factory_default("Breadcrumbs", styles_module_default24);
|
|
8687
|
+
var Breadcrumbs = ({
|
|
8688
|
+
children,
|
|
8689
|
+
numParents = 1
|
|
8690
|
+
}) => {
|
|
8691
|
+
const setUi = useAppStore((s) => s.setUi);
|
|
8692
|
+
const breadcrumbs = useBreadcrumbs(numParents);
|
|
8693
|
+
return /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)("div", { className: getClassName28(), children: [
|
|
8694
|
+
breadcrumbs.map((breadcrumb, i) => /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)("div", { className: getClassName28("breadcrumb"), children: [
|
|
8695
|
+
/* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
|
|
8696
|
+
"button",
|
|
8697
|
+
{
|
|
8698
|
+
type: "button",
|
|
8699
|
+
className: getClassName28("breadcrumbLabel"),
|
|
8700
|
+
onClick: () => setUi({ itemSelector: breadcrumb.selector }),
|
|
8701
|
+
children: breadcrumb.label
|
|
8702
|
+
}
|
|
8703
|
+
),
|
|
8704
|
+
/* @__PURE__ */ (0, import_jsx_runtime40.jsx)(ChevronRight, { size: 16 })
|
|
8705
|
+
] }, i)),
|
|
8706
|
+
children
|
|
8707
|
+
] });
|
|
8626
8708
|
};
|
|
8627
8709
|
|
|
8628
|
-
//
|
|
8710
|
+
// components/SidebarSection/index.tsx
|
|
8711
|
+
var import_jsx_runtime41 = require("react/jsx-runtime");
|
|
8712
|
+
var getClassName29 = get_class_name_factory_default("SidebarSection", styles_module_default23);
|
|
8713
|
+
var SidebarSection = ({
|
|
8714
|
+
children,
|
|
8715
|
+
title,
|
|
8716
|
+
background,
|
|
8717
|
+
showBreadcrumbs,
|
|
8718
|
+
noBorderTop,
|
|
8719
|
+
noPadding,
|
|
8720
|
+
isLoading
|
|
8721
|
+
}) => {
|
|
8722
|
+
return /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(
|
|
8723
|
+
"div",
|
|
8724
|
+
{
|
|
8725
|
+
className: getClassName29({ noBorderTop, noPadding }),
|
|
8726
|
+
style: { background },
|
|
8727
|
+
children: [
|
|
8728
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { className: getClassName29("title"), children: /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: getClassName29("breadcrumbs"), children: [
|
|
8729
|
+
showBreadcrumbs && /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Breadcrumbs, {}),
|
|
8730
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { className: getClassName29("heading"), children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Heading, { rank: "2", size: "xs", children: title }) })
|
|
8731
|
+
] }) }),
|
|
8732
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { className: getClassName29("content"), children }),
|
|
8733
|
+
isLoading && /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { className: getClassName29("loadingOverlay"), children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Loader, { size: 32 }) })
|
|
8734
|
+
]
|
|
8735
|
+
}
|
|
8736
|
+
);
|
|
8737
|
+
};
|
|
8738
|
+
|
|
8739
|
+
// components/Puck/components/Canvas/index.tsx
|
|
8740
|
+
init_react_import();
|
|
8741
|
+
var import_react56 = require("react");
|
|
8742
|
+
|
|
8743
|
+
// components/ViewportControls/index.tsx
|
|
8629
8744
|
init_react_import();
|
|
8630
8745
|
var import_react54 = require("react");
|
|
8631
|
-
|
|
8632
|
-
|
|
8633
|
-
|
|
8634
|
-
|
|
8635
|
-
|
|
8636
|
-
|
|
8637
|
-
|
|
8638
|
-
|
|
8639
|
-
|
|
8640
|
-
|
|
8641
|
-
|
|
8642
|
-
|
|
8643
|
-
|
|
8746
|
+
|
|
8747
|
+
// css-module:/home/runner/work/puck/puck/packages/core/components/ViewportControls/styles.module.css#css-module
|
|
8748
|
+
init_react_import();
|
|
8749
|
+
var styles_module_default25 = { "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" };
|
|
8750
|
+
|
|
8751
|
+
// components/ViewportControls/index.tsx
|
|
8752
|
+
var import_jsx_runtime42 = require("react/jsx-runtime");
|
|
8753
|
+
var icons = {
|
|
8754
|
+
Smartphone: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(Smartphone, { size: 16 }),
|
|
8755
|
+
Tablet: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(Tablet, { size: 16 }),
|
|
8756
|
+
Monitor: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(Monitor, { size: 16 }),
|
|
8757
|
+
FullWidth: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(Expand, { size: 16 })
|
|
8758
|
+
};
|
|
8759
|
+
var getClassName30 = get_class_name_factory_default("ViewportControls", styles_module_default25);
|
|
8760
|
+
var getClassNameButton = get_class_name_factory_default("ViewportButton", styles_module_default25);
|
|
8761
|
+
var ActionButton = ({
|
|
8762
|
+
children,
|
|
8763
|
+
title,
|
|
8764
|
+
onClick,
|
|
8765
|
+
isActive,
|
|
8766
|
+
disabled
|
|
8767
|
+
}) => {
|
|
8768
|
+
return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("span", { className: getClassNameButton({ isActive }), suppressHydrationWarning: true, children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
|
|
8769
|
+
IconButton,
|
|
8770
|
+
{
|
|
8771
|
+
type: "button",
|
|
8772
|
+
title,
|
|
8773
|
+
disabled: disabled || isActive,
|
|
8774
|
+
onClick,
|
|
8775
|
+
suppressHydrationWarning: true,
|
|
8776
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("span", { className: getClassNameButton("inner"), children })
|
|
8777
|
+
}
|
|
8778
|
+
) });
|
|
8779
|
+
};
|
|
8780
|
+
var defaultZoomOptions = [
|
|
8781
|
+
{ label: "25%", value: 0.25 },
|
|
8782
|
+
{ label: "50%", value: 0.5 },
|
|
8783
|
+
{ label: "75%", value: 0.75 },
|
|
8784
|
+
{ label: "100%", value: 1 },
|
|
8785
|
+
{ label: "125%", value: 1.25 },
|
|
8786
|
+
{ label: "150%", value: 1.5 },
|
|
8787
|
+
{ label: "200%", value: 2 }
|
|
8788
|
+
];
|
|
8789
|
+
var ViewportControls = ({
|
|
8790
|
+
autoZoom,
|
|
8791
|
+
zoom,
|
|
8792
|
+
onViewportChange,
|
|
8793
|
+
onZoom,
|
|
8794
|
+
fullScreen
|
|
8795
|
+
}) => {
|
|
8796
|
+
var _a, _b;
|
|
8797
|
+
const viewports = useAppStore((s) => s.viewports);
|
|
8798
|
+
const uiViewports = useAppStore((s) => s.state.ui.viewports);
|
|
8799
|
+
const defaultsContainAutoZoom = defaultZoomOptions.find(
|
|
8800
|
+
(option) => option.value === autoZoom
|
|
8801
|
+
);
|
|
8802
|
+
const zoomOptions = (0, import_react54.useMemo)(
|
|
8803
|
+
() => [
|
|
8804
|
+
...defaultZoomOptions,
|
|
8805
|
+
...defaultsContainAutoZoom ? [] : [
|
|
8806
|
+
{
|
|
8807
|
+
value: autoZoom,
|
|
8808
|
+
label: `${(autoZoom * 100).toFixed(0)}% (Auto)`
|
|
8809
|
+
}
|
|
8810
|
+
]
|
|
8811
|
+
].filter((a) => a.value <= autoZoom).sort((a, b) => a.value > b.value ? 1 : -1),
|
|
8812
|
+
[autoZoom]
|
|
8813
|
+
);
|
|
8814
|
+
const [activeViewport, setActiveViewport] = (0, import_react54.useState)(
|
|
8815
|
+
uiViewports.current.width
|
|
8816
|
+
);
|
|
8817
|
+
(0, import_react54.useEffect)(() => {
|
|
8818
|
+
setActiveViewport(uiViewports.current.width);
|
|
8819
|
+
}, [uiViewports.current]);
|
|
8820
|
+
const [isExpanded, setIsExpanded] = (0, import_react54.useState)(false);
|
|
8821
|
+
return /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)(
|
|
8822
|
+
"div",
|
|
8823
|
+
{
|
|
8824
|
+
className: getClassName30({ isExpanded, fullScreen }),
|
|
8825
|
+
suppressHydrationWarning: true,
|
|
8826
|
+
children: [
|
|
8827
|
+
/* @__PURE__ */ (0, import_jsx_runtime42.jsx)("div", { className: getClassName30("actions"), children: /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("div", { className: getClassName30("actionsInner"), children: [
|
|
8828
|
+
viewports.map((viewport, i) => /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
|
|
8829
|
+
ActionButton,
|
|
8830
|
+
{
|
|
8831
|
+
title: viewport.label ? `Switch to ${viewport.label} viewport` : "Switch viewport",
|
|
8832
|
+
onClick: () => {
|
|
8833
|
+
setActiveViewport(viewport.width);
|
|
8834
|
+
onViewportChange(viewport);
|
|
8835
|
+
},
|
|
8836
|
+
isActive: activeViewport === viewport.width,
|
|
8837
|
+
children: typeof viewport.icon === "string" ? icons[viewport.icon] || viewport.icon : viewport.icon || icons.Smartphone
|
|
8838
|
+
},
|
|
8839
|
+
i
|
|
8840
|
+
)),
|
|
8841
|
+
/* @__PURE__ */ (0, import_jsx_runtime42.jsx)("div", { className: getClassName30("divider") }),
|
|
8842
|
+
/* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
|
|
8843
|
+
ActionButton,
|
|
8844
|
+
{
|
|
8845
|
+
title: "Zoom viewport out",
|
|
8846
|
+
disabled: zoom <= ((_a = zoomOptions[0]) == null ? void 0 : _a.value),
|
|
8847
|
+
onClick: (e) => {
|
|
8848
|
+
e.stopPropagation();
|
|
8849
|
+
onZoom(
|
|
8850
|
+
zoomOptions[Math.max(
|
|
8851
|
+
zoomOptions.findIndex((option) => option.value === zoom) - 1,
|
|
8852
|
+
0
|
|
8853
|
+
)].value
|
|
8854
|
+
);
|
|
8855
|
+
},
|
|
8856
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(ZoomOut, { size: 16 })
|
|
8857
|
+
}
|
|
8858
|
+
),
|
|
8859
|
+
/* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
|
|
8860
|
+
ActionButton,
|
|
8861
|
+
{
|
|
8862
|
+
title: "Zoom viewport in",
|
|
8863
|
+
disabled: zoom >= ((_b = zoomOptions[zoomOptions.length - 1]) == null ? void 0 : _b.value),
|
|
8864
|
+
onClick: (e) => {
|
|
8865
|
+
e.stopPropagation();
|
|
8866
|
+
onZoom(
|
|
8867
|
+
zoomOptions[Math.min(
|
|
8868
|
+
zoomOptions.findIndex((option) => option.value === zoom) + 1,
|
|
8869
|
+
zoomOptions.length - 1
|
|
8870
|
+
)].value
|
|
8871
|
+
);
|
|
8872
|
+
},
|
|
8873
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(ZoomIn, { size: 16 })
|
|
8874
|
+
}
|
|
8875
|
+
),
|
|
8876
|
+
/* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("div", { className: getClassName30("zoom"), children: [
|
|
8877
|
+
/* @__PURE__ */ (0, import_jsx_runtime42.jsx)("div", { className: getClassName30("divider") }),
|
|
8878
|
+
/* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
|
|
8879
|
+
"select",
|
|
8880
|
+
{
|
|
8881
|
+
className: getClassName30("zoomSelect"),
|
|
8882
|
+
value: zoom.toString(),
|
|
8883
|
+
onClick: (e) => {
|
|
8884
|
+
e.stopPropagation();
|
|
8885
|
+
},
|
|
8886
|
+
onChange: (e) => {
|
|
8887
|
+
onZoom(parseFloat(e.currentTarget.value));
|
|
8888
|
+
},
|
|
8889
|
+
children: zoomOptions.map((option) => /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
|
|
8890
|
+
"option",
|
|
8891
|
+
{
|
|
8892
|
+
value: option.value,
|
|
8893
|
+
label: option.label
|
|
8894
|
+
},
|
|
8895
|
+
option.label
|
|
8896
|
+
))
|
|
8897
|
+
}
|
|
8898
|
+
)
|
|
8899
|
+
] })
|
|
8900
|
+
] }) }),
|
|
8901
|
+
/* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
|
|
8902
|
+
"button",
|
|
8903
|
+
{
|
|
8904
|
+
className: getClassName30("toggleButton"),
|
|
8905
|
+
title: "Toggle viewport menu",
|
|
8906
|
+
onClick: () => setIsExpanded((s) => !s),
|
|
8907
|
+
children: isExpanded ? /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(X, { size: 16 }) : /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(Monitor, { size: 16 })
|
|
8908
|
+
}
|
|
8909
|
+
)
|
|
8910
|
+
]
|
|
8911
|
+
}
|
|
8912
|
+
);
|
|
8644
8913
|
};
|
|
8645
8914
|
|
|
8646
|
-
//
|
|
8915
|
+
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Canvas/styles.module.css#css-module
|
|
8916
|
+
init_react_import();
|
|
8917
|
+
var styles_module_default26 = { "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" };
|
|
8918
|
+
|
|
8919
|
+
// components/Puck/components/Canvas/index.tsx
|
|
8920
|
+
var import_shallow8 = require("zustand/react/shallow");
|
|
8921
|
+
|
|
8922
|
+
// lib/frame-context.tsx
|
|
8647
8923
|
init_react_import();
|
|
8648
8924
|
var import_react55 = require("react");
|
|
8649
|
-
var
|
|
8650
|
-
|
|
8651
|
-
|
|
8652
|
-
|
|
8653
|
-
|
|
8654
|
-
|
|
8655
|
-
|
|
8656
|
-
|
|
8657
|
-
|
|
8658
|
-
|
|
8659
|
-
|
|
8660
|
-
var shouldBlockDeleteHotkey = (e) => {
|
|
8661
|
-
var _a;
|
|
8662
|
-
if (e == null ? void 0 : e.defaultPrevented) return true;
|
|
8663
|
-
const origin = ((_a = e == null ? void 0 : e.composedPath) == null ? void 0 : _a.call(e)[0]) || (e == null ? void 0 : e.target) || document.activeElement;
|
|
8664
|
-
if (origin instanceof HTMLElement) {
|
|
8665
|
-
const tag = origin.tagName.toLowerCase();
|
|
8666
|
-
if (tag === "input" || tag === "textarea" || tag === "select") return true;
|
|
8667
|
-
if (origin.isContentEditable) return true;
|
|
8668
|
-
const role = origin.getAttribute("role");
|
|
8669
|
-
if (role === "textbox" || role === "combobox" || role === "searchbox" || role === "listbox" || role === "grid") {
|
|
8670
|
-
return true;
|
|
8671
|
-
}
|
|
8672
|
-
}
|
|
8673
|
-
const modal = document.querySelector(
|
|
8674
|
-
'dialog[open], [aria-modal="true"], [role="dialog"], [role="alertdialog"]'
|
|
8925
|
+
var import_jsx_runtime43 = require("react/jsx-runtime");
|
|
8926
|
+
var FrameContext = (0, import_react55.createContext)(null);
|
|
8927
|
+
var FrameProvider = ({
|
|
8928
|
+
children
|
|
8929
|
+
}) => {
|
|
8930
|
+
const frameRef = (0, import_react55.useRef)(null);
|
|
8931
|
+
const value = (0, import_react55.useMemo)(
|
|
8932
|
+
() => ({
|
|
8933
|
+
frameRef
|
|
8934
|
+
}),
|
|
8935
|
+
[]
|
|
8675
8936
|
);
|
|
8676
|
-
|
|
8677
|
-
return true;
|
|
8678
|
-
}
|
|
8679
|
-
return false;
|
|
8937
|
+
return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(FrameContext.Provider, { value, children });
|
|
8680
8938
|
};
|
|
8681
|
-
var
|
|
8682
|
-
const
|
|
8683
|
-
|
|
8684
|
-
(
|
|
8685
|
-
|
|
8686
|
-
|
|
8687
|
-
return false;
|
|
8688
|
-
}
|
|
8689
|
-
const { state, dispatch, permissions, selectedItem } = appStore.getState();
|
|
8690
|
-
const sel = (_a = state.ui) == null ? void 0 : _a.itemSelector;
|
|
8691
|
-
if (!(sel == null ? void 0 : sel.zone) || !selectedItem) return true;
|
|
8692
|
-
if (!permissions.getPermissions({ item: selectedItem }).delete)
|
|
8693
|
-
return true;
|
|
8694
|
-
dispatch({
|
|
8695
|
-
type: "remove",
|
|
8696
|
-
index: sel.index,
|
|
8697
|
-
zone: sel.zone
|
|
8698
|
-
});
|
|
8699
|
-
return true;
|
|
8700
|
-
},
|
|
8701
|
-
[appStore]
|
|
8702
|
-
);
|
|
8703
|
-
useHotkey({ delete: true }, deleteSelectedComponent);
|
|
8704
|
-
useHotkey({ backspace: true }, deleteSelectedComponent);
|
|
8939
|
+
var useCanvasFrame = () => {
|
|
8940
|
+
const context = (0, import_react55.useContext)(FrameContext);
|
|
8941
|
+
if (context === null) {
|
|
8942
|
+
throw new Error("useCanvasFrame must be used within a FrameProvider");
|
|
8943
|
+
}
|
|
8944
|
+
return context;
|
|
8705
8945
|
};
|
|
8706
8946
|
|
|
8707
|
-
//
|
|
8708
|
-
|
|
8709
|
-
var
|
|
8710
|
-
var
|
|
8711
|
-
var
|
|
8712
|
-
|
|
8713
|
-
|
|
8714
|
-
|
|
8715
|
-
|
|
8716
|
-
|
|
8717
|
-
|
|
8718
|
-
|
|
8719
|
-
|
|
8720
|
-
|
|
8721
|
-
|
|
8722
|
-
|
|
8723
|
-
|
|
8724
|
-
|
|
8725
|
-
|
|
8726
|
-
|
|
8727
|
-
|
|
8728
|
-
|
|
8729
|
-
|
|
8730
|
-
|
|
8731
|
-
|
|
8732
|
-
|
|
8733
|
-
|
|
8734
|
-
return storeData;
|
|
8735
|
-
};
|
|
8736
|
-
var UsePuckStoreContext = (0, import_react56.createContext)(
|
|
8737
|
-
null
|
|
8738
|
-
);
|
|
8739
|
-
var convertToPickedStore = (store) => {
|
|
8740
|
-
return {
|
|
8741
|
-
state: store.state,
|
|
8742
|
-
config: store.config,
|
|
8743
|
-
dispatch: store.dispatch,
|
|
8744
|
-
permissions: store.permissions,
|
|
8745
|
-
history: store.history,
|
|
8746
|
-
selectedItem: store.selectedItem
|
|
8747
|
-
};
|
|
8748
|
-
};
|
|
8749
|
-
var useRegisterUsePuckStore = (appStore) => {
|
|
8750
|
-
const [usePuckStore] = (0, import_react56.useState)(
|
|
8751
|
-
() => (0, import_zustand6.createStore)(
|
|
8752
|
-
() => generateUsePuck(convertToPickedStore(appStore.getState()))
|
|
8753
|
-
)
|
|
8947
|
+
// components/Puck/components/Canvas/index.tsx
|
|
8948
|
+
var import_jsx_runtime44 = require("react/jsx-runtime");
|
|
8949
|
+
var getClassName31 = get_class_name_factory_default("PuckCanvas", styles_module_default26);
|
|
8950
|
+
var ZOOM_ON_CHANGE = true;
|
|
8951
|
+
var TRANSITION_DURATION = 150;
|
|
8952
|
+
var Canvas = () => {
|
|
8953
|
+
const { frameRef } = useCanvasFrame();
|
|
8954
|
+
const resetAutoZoom = useResetAutoZoom(frameRef);
|
|
8955
|
+
const { _experimentalFullScreenCanvas } = usePropsContext();
|
|
8956
|
+
const {
|
|
8957
|
+
dispatch,
|
|
8958
|
+
overrides,
|
|
8959
|
+
setUi,
|
|
8960
|
+
zoomConfig,
|
|
8961
|
+
setZoomConfig,
|
|
8962
|
+
status,
|
|
8963
|
+
iframe
|
|
8964
|
+
} = useAppStore(
|
|
8965
|
+
(0, import_shallow8.useShallow)((s) => ({
|
|
8966
|
+
dispatch: s.dispatch,
|
|
8967
|
+
overrides: s.overrides,
|
|
8968
|
+
setUi: s.setUi,
|
|
8969
|
+
zoomConfig: s.zoomConfig,
|
|
8970
|
+
setZoomConfig: s.setZoomConfig,
|
|
8971
|
+
status: s.status,
|
|
8972
|
+
iframe: s.iframe
|
|
8973
|
+
}))
|
|
8754
8974
|
);
|
|
8755
|
-
|
|
8756
|
-
|
|
8757
|
-
|
|
8758
|
-
|
|
8759
|
-
|
|
8760
|
-
|
|
8761
|
-
|
|
8975
|
+
const {
|
|
8976
|
+
leftSideBarVisible,
|
|
8977
|
+
rightSideBarVisible,
|
|
8978
|
+
leftSideBarWidth,
|
|
8979
|
+
rightSideBarWidth,
|
|
8980
|
+
viewports
|
|
8981
|
+
} = useAppStore(
|
|
8982
|
+
(0, import_shallow8.useShallow)((s) => ({
|
|
8983
|
+
leftSideBarVisible: s.state.ui.leftSideBarVisible,
|
|
8984
|
+
rightSideBarVisible: s.state.ui.rightSideBarVisible,
|
|
8985
|
+
leftSideBarWidth: s.state.ui.leftSideBarWidth,
|
|
8986
|
+
rightSideBarWidth: s.state.ui.rightSideBarWidth,
|
|
8987
|
+
viewports: s.state.ui.viewports
|
|
8988
|
+
}))
|
|
8989
|
+
);
|
|
8990
|
+
const [showTransition, setShowTransition] = (0, import_react56.useState)(false);
|
|
8991
|
+
const isResizingRef = (0, import_react56.useRef)(false);
|
|
8992
|
+
const defaultRender = (0, import_react56.useMemo)(() => {
|
|
8993
|
+
const PuckDefault = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(import_jsx_runtime44.Fragment, { children });
|
|
8994
|
+
return PuckDefault;
|
|
8762
8995
|
}, []);
|
|
8763
|
-
|
|
8764
|
-
|
|
8765
|
-
|
|
8766
|
-
|
|
8767
|
-
|
|
8768
|
-
if (
|
|
8769
|
-
|
|
8996
|
+
const CustomPreview = (0, import_react56.useMemo)(
|
|
8997
|
+
() => overrides.preview || defaultRender,
|
|
8998
|
+
[overrides]
|
|
8999
|
+
);
|
|
9000
|
+
const getFrameDimensions = (0, import_react56.useCallback)(() => {
|
|
9001
|
+
if (frameRef.current) {
|
|
9002
|
+
const frame = frameRef.current;
|
|
9003
|
+
const box = getBox(frame);
|
|
9004
|
+
return { width: box.contentBox.width, height: box.contentBox.height };
|
|
8770
9005
|
}
|
|
8771
|
-
|
|
8772
|
-
|
|
8773
|
-
selector != null ? selector : (s) => s
|
|
8774
|
-
);
|
|
8775
|
-
return result;
|
|
8776
|
-
};
|
|
8777
|
-
}
|
|
8778
|
-
function usePuck() {
|
|
9006
|
+
return { width: 0, height: 0 };
|
|
9007
|
+
}, [frameRef]);
|
|
8779
9008
|
(0, import_react56.useEffect)(() => {
|
|
8780
|
-
|
|
8781
|
-
|
|
8782
|
-
|
|
8783
|
-
|
|
8784
|
-
|
|
8785
|
-
|
|
8786
|
-
|
|
8787
|
-
|
|
8788
|
-
|
|
8789
|
-
|
|
8790
|
-
|
|
8791
|
-
|
|
8792
|
-
}
|
|
8793
|
-
|
|
8794
|
-
|
|
8795
|
-
|
|
8796
|
-
|
|
8797
|
-
|
|
8798
|
-
|
|
8799
|
-
|
|
8800
|
-
|
|
8801
|
-
|
|
8802
|
-
|
|
8803
|
-
|
|
8804
|
-
|
|
8805
|
-
|
|
8806
|
-
|
|
8807
|
-
|
|
8808
|
-
|
|
8809
|
-
|
|
8810
|
-
|
|
8811
|
-
|
|
8812
|
-
|
|
8813
|
-
|
|
8814
|
-
|
|
8815
|
-
|
|
8816
|
-
|
|
8817
|
-
|
|
8818
|
-
|
|
8819
|
-
|
|
8820
|
-
return /* @__PURE__ */ (0,
|
|
9009
|
+
resetAutoZoom();
|
|
9010
|
+
}, [
|
|
9011
|
+
frameRef,
|
|
9012
|
+
leftSideBarVisible,
|
|
9013
|
+
rightSideBarVisible,
|
|
9014
|
+
leftSideBarWidth,
|
|
9015
|
+
rightSideBarWidth,
|
|
9016
|
+
viewports
|
|
9017
|
+
]);
|
|
9018
|
+
(0, import_react56.useEffect)(() => {
|
|
9019
|
+
const { height: frameHeight } = getFrameDimensions();
|
|
9020
|
+
if (viewports.current.height === "auto") {
|
|
9021
|
+
setZoomConfig(__spreadProps(__spreadValues({}, zoomConfig), {
|
|
9022
|
+
rootHeight: frameHeight / zoomConfig.zoom
|
|
9023
|
+
}));
|
|
9024
|
+
}
|
|
9025
|
+
}, [zoomConfig.zoom, getFrameDimensions, setZoomConfig]);
|
|
9026
|
+
(0, import_react56.useEffect)(() => {
|
|
9027
|
+
if (ZOOM_ON_CHANGE) {
|
|
9028
|
+
resetAutoZoom();
|
|
9029
|
+
}
|
|
9030
|
+
}, [viewports.current.width, viewports]);
|
|
9031
|
+
(0, import_react56.useEffect)(() => {
|
|
9032
|
+
if (!frameRef.current) return;
|
|
9033
|
+
const resizeObserver = new ResizeObserver(() => {
|
|
9034
|
+
if (!isResizingRef.current) {
|
|
9035
|
+
resetAutoZoom();
|
|
9036
|
+
}
|
|
9037
|
+
});
|
|
9038
|
+
resizeObserver.observe(frameRef.current);
|
|
9039
|
+
return () => {
|
|
9040
|
+
resizeObserver.disconnect();
|
|
9041
|
+
};
|
|
9042
|
+
}, [frameRef.current]);
|
|
9043
|
+
const [showLoader, setShowLoader] = (0, import_react56.useState)(false);
|
|
9044
|
+
(0, import_react56.useEffect)(() => {
|
|
9045
|
+
setTimeout(() => {
|
|
9046
|
+
setShowLoader(true);
|
|
9047
|
+
}, 500);
|
|
9048
|
+
}, []);
|
|
9049
|
+
return /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)(
|
|
8821
9050
|
"div",
|
|
8822
9051
|
{
|
|
8823
|
-
className:
|
|
8824
|
-
|
|
8825
|
-
|
|
8826
|
-
|
|
8827
|
-
|
|
8828
|
-
|
|
8829
|
-
|
|
8830
|
-
if (
|
|
8831
|
-
|
|
9052
|
+
className: getClassName31({
|
|
9053
|
+
ready: status === "READY" || !iframe.enabled || !iframe.waitForStyles,
|
|
9054
|
+
showLoader,
|
|
9055
|
+
fullScreen: _experimentalFullScreenCanvas
|
|
9056
|
+
}),
|
|
9057
|
+
onClick: (e) => {
|
|
9058
|
+
const el = e.target;
|
|
9059
|
+
if (!el.hasAttribute("data-puck-component") && !el.hasAttribute("data-puck-dropzone")) {
|
|
9060
|
+
dispatch({
|
|
9061
|
+
type: "setUi",
|
|
9062
|
+
ui: { itemSelector: null },
|
|
9063
|
+
recordHistory: true
|
|
9064
|
+
});
|
|
8832
9065
|
}
|
|
8833
9066
|
},
|
|
8834
|
-
children:
|
|
8835
|
-
/* @__PURE__ */ (0,
|
|
8836
|
-
|
|
8837
|
-
|
|
8838
|
-
|
|
8839
|
-
|
|
8840
|
-
|
|
8841
|
-
|
|
8842
|
-
|
|
8843
|
-
|
|
9067
|
+
children: [
|
|
9068
|
+
viewports.controlsVisible && iframe.enabled && /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("div", { className: getClassName31("controls"), children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
|
|
9069
|
+
ViewportControls,
|
|
9070
|
+
{
|
|
9071
|
+
fullScreen: _experimentalFullScreenCanvas,
|
|
9072
|
+
autoZoom: zoomConfig.autoZoom,
|
|
9073
|
+
zoom: zoomConfig.zoom,
|
|
9074
|
+
onViewportChange: (viewport) => {
|
|
9075
|
+
setShowTransition(true);
|
|
9076
|
+
isResizingRef.current = true;
|
|
9077
|
+
const uiViewport = __spreadProps(__spreadValues({}, viewport), {
|
|
9078
|
+
height: viewport.height || "auto",
|
|
9079
|
+
zoom: zoomConfig.zoom
|
|
9080
|
+
});
|
|
9081
|
+
const newUi = {
|
|
9082
|
+
viewports: __spreadProps(__spreadValues({}, viewports), { current: uiViewport })
|
|
9083
|
+
};
|
|
9084
|
+
setUi(newUi);
|
|
9085
|
+
if (ZOOM_ON_CHANGE) {
|
|
9086
|
+
resetAutoZoom({
|
|
9087
|
+
viewports: __spreadProps(__spreadValues({}, viewports), { current: uiViewport })
|
|
9088
|
+
});
|
|
9089
|
+
}
|
|
9090
|
+
},
|
|
9091
|
+
onZoom: (zoom) => {
|
|
9092
|
+
setShowTransition(true);
|
|
9093
|
+
isResizingRef.current = true;
|
|
9094
|
+
setZoomConfig(__spreadProps(__spreadValues({}, zoomConfig), { zoom }));
|
|
8844
9095
|
}
|
|
8845
|
-
|
|
8846
|
-
|
|
8847
|
-
|
|
9096
|
+
}
|
|
9097
|
+
) }),
|
|
9098
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsxs)("div", { className: getClassName31("inner"), ref: frameRef, children: [
|
|
9099
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
|
|
9100
|
+
"div",
|
|
8848
9101
|
{
|
|
8849
|
-
|
|
8850
|
-
|
|
8851
|
-
|
|
8852
|
-
|
|
8853
|
-
|
|
9102
|
+
className: getClassName31("root"),
|
|
9103
|
+
style: {
|
|
9104
|
+
width: iframe.enabled ? viewports.current.width : "100%",
|
|
9105
|
+
height: zoomConfig.rootHeight,
|
|
9106
|
+
transform: iframe.enabled ? `scale(${zoomConfig.zoom})` : void 0,
|
|
9107
|
+
transition: showTransition ? `width ${TRANSITION_DURATION}ms ease-out, height ${TRANSITION_DURATION}ms ease-out, transform ${TRANSITION_DURATION}ms ease-out` : "",
|
|
9108
|
+
overflow: iframe.enabled ? void 0 : "auto"
|
|
9109
|
+
},
|
|
9110
|
+
suppressHydrationWarning: true,
|
|
9111
|
+
id: "puck-canvas-root",
|
|
9112
|
+
onTransitionEnd: () => {
|
|
9113
|
+
setShowTransition(false);
|
|
9114
|
+
isResizingRef.current = false;
|
|
9115
|
+
},
|
|
9116
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(CustomPreview, { children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(Preview2, {}) })
|
|
8854
9117
|
}
|
|
8855
|
-
)
|
|
8856
|
-
|
|
8857
|
-
|
|
8858
|
-
]
|
|
9118
|
+
),
|
|
9119
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)("div", { className: getClassName31("loader"), children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(Loader, { size: 24 }) })
|
|
9120
|
+
] })
|
|
9121
|
+
]
|
|
8859
9122
|
}
|
|
8860
9123
|
);
|
|
8861
|
-
}
|
|
9124
|
+
};
|
|
8862
9125
|
|
|
8863
|
-
//
|
|
9126
|
+
// lib/use-sidebar-resize.ts
|
|
8864
9127
|
init_react_import();
|
|
8865
|
-
var
|
|
8866
|
-
|
|
8867
|
-
|
|
8868
|
-
|
|
8869
|
-
|
|
8870
|
-
|
|
8871
|
-
|
|
8872
|
-
|
|
8873
|
-
|
|
8874
|
-
|
|
8875
|
-
|
|
8876
|
-
|
|
8877
|
-
|
|
8878
|
-
|
|
8879
|
-
|
|
8880
|
-
|
|
8881
|
-
|
|
8882
|
-
|
|
8883
|
-
|
|
8884
|
-
|
|
8885
|
-
|
|
8886
|
-
|
|
8887
|
-
|
|
8888
|
-
|
|
8889
|
-
|
|
8890
|
-
|
|
8891
|
-
|
|
8892
|
-
|
|
9128
|
+
var import_react57 = require("react");
|
|
9129
|
+
function useSidebarResize(position, dispatch) {
|
|
9130
|
+
const [width, setWidth] = (0, import_react57.useState)(null);
|
|
9131
|
+
const sidebarRef = (0, import_react57.useRef)(null);
|
|
9132
|
+
const storeWidth = useAppStore(
|
|
9133
|
+
(s) => position === "left" ? s.state.ui.leftSideBarWidth : s.state.ui.rightSideBarWidth
|
|
9134
|
+
);
|
|
9135
|
+
(0, import_react57.useEffect)(() => {
|
|
9136
|
+
if (typeof window !== "undefined" && !storeWidth) {
|
|
9137
|
+
try {
|
|
9138
|
+
const savedWidths = localStorage.getItem("puck-sidebar-widths");
|
|
9139
|
+
if (savedWidths) {
|
|
9140
|
+
const widths = JSON.parse(savedWidths);
|
|
9141
|
+
const savedWidth = widths[position];
|
|
9142
|
+
const key = position === "left" ? "leftSideBarWidth" : "rightSideBarWidth";
|
|
9143
|
+
if (savedWidth) {
|
|
9144
|
+
dispatch({
|
|
9145
|
+
type: "setUi",
|
|
9146
|
+
ui: {
|
|
9147
|
+
[key]: savedWidth
|
|
9148
|
+
}
|
|
9149
|
+
});
|
|
9150
|
+
}
|
|
9151
|
+
}
|
|
9152
|
+
} catch (error) {
|
|
9153
|
+
console.error(
|
|
9154
|
+
`Failed to load ${position} sidebar width from localStorage`,
|
|
9155
|
+
error
|
|
9156
|
+
);
|
|
9157
|
+
}
|
|
8893
9158
|
}
|
|
8894
|
-
|
|
8895
|
-
|
|
8896
|
-
|
|
8897
|
-
|
|
8898
|
-
console.warn(
|
|
8899
|
-
"`renderHeaderActions` is deprecated. Please use `overrides.headerActions` and the `usePuck` hook instead."
|
|
8900
|
-
);
|
|
8901
|
-
const RenderHeader = (props) => {
|
|
8902
|
-
const Comp = renderHeaderActions;
|
|
8903
|
-
const appState = useAppStore((s) => s.state);
|
|
8904
|
-
return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState }));
|
|
8905
|
-
};
|
|
8906
|
-
return RenderHeader;
|
|
9159
|
+
}, [dispatch, position, storeWidth]);
|
|
9160
|
+
(0, import_react57.useEffect)(() => {
|
|
9161
|
+
if (storeWidth !== void 0) {
|
|
9162
|
+
setWidth(storeWidth);
|
|
8907
9163
|
}
|
|
8908
|
-
|
|
8909
|
-
|
|
8910
|
-
|
|
8911
|
-
(s) => s.overrides.header || defaultHeaderRender
|
|
8912
|
-
);
|
|
8913
|
-
const CustomHeaderActions = useAppStore(
|
|
8914
|
-
(s) => s.overrides.headerActions || defaultHeaderActionsRender
|
|
8915
|
-
);
|
|
8916
|
-
const [menuOpen, setMenuOpen] = (0, import_react57.useState)(false);
|
|
8917
|
-
const rootTitle = useAppStore((s) => {
|
|
8918
|
-
var _a, _b;
|
|
8919
|
-
const rootData = (_a = s.state.indexes.nodes["root"]) == null ? void 0 : _a.data;
|
|
8920
|
-
return (_b = rootData.props.title) != null ? _b : "";
|
|
8921
|
-
});
|
|
8922
|
-
const leftSideBarVisible = useAppStore((s) => s.state.ui.leftSideBarVisible);
|
|
8923
|
-
const rightSideBarVisible = useAppStore(
|
|
8924
|
-
(s) => s.state.ui.rightSideBarVisible
|
|
8925
|
-
);
|
|
8926
|
-
const toggleSidebars = (0, import_react57.useCallback)(
|
|
8927
|
-
(sidebar) => {
|
|
8928
|
-
const widerViewport = window.matchMedia("(min-width: 638px)").matches;
|
|
8929
|
-
const sideBarVisible = sidebar === "left" ? leftSideBarVisible : rightSideBarVisible;
|
|
8930
|
-
const oppositeSideBar = sidebar === "left" ? "rightSideBarVisible" : "leftSideBarVisible";
|
|
9164
|
+
}, [storeWidth]);
|
|
9165
|
+
const handleResizeEnd = (0, import_react57.useCallback)(
|
|
9166
|
+
(width2) => {
|
|
8931
9167
|
dispatch({
|
|
8932
9168
|
type: "setUi",
|
|
8933
|
-
ui:
|
|
8934
|
-
[
|
|
8935
|
-
}, !widerViewport ? { [oppositeSideBar]: false } : {})
|
|
8936
|
-
});
|
|
8937
|
-
},
|
|
8938
|
-
[dispatch, leftSideBarVisible, rightSideBarVisible]
|
|
8939
|
-
);
|
|
8940
|
-
return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
|
|
8941
|
-
CustomHeader,
|
|
8942
|
-
{
|
|
8943
|
-
actions: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(import_jsx_runtime43.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(CustomHeaderActions, { children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
|
|
8944
|
-
Button,
|
|
8945
|
-
{
|
|
8946
|
-
onClick: () => {
|
|
8947
|
-
const data = appStore.getState().state.data;
|
|
8948
|
-
onPublish && onPublish(data);
|
|
8949
|
-
},
|
|
8950
|
-
icon: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Globe, { size: "14px" }),
|
|
8951
|
-
children: "Publish"
|
|
8952
|
-
}
|
|
8953
|
-
) }) }),
|
|
8954
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
|
|
8955
|
-
"header",
|
|
8956
|
-
{
|
|
8957
|
-
className: getClassName28({ leftSideBarVisible, rightSideBarVisible }),
|
|
8958
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("div", { className: getClassName28("inner"), children: [
|
|
8959
|
-
/* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("div", { className: getClassName28("toggle"), children: [
|
|
8960
|
-
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)("div", { className: getClassName28("leftSideBarToggle"), children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
|
|
8961
|
-
IconButton,
|
|
8962
|
-
{
|
|
8963
|
-
type: "button",
|
|
8964
|
-
onClick: () => {
|
|
8965
|
-
toggleSidebars("left");
|
|
8966
|
-
},
|
|
8967
|
-
title: "Toggle left sidebar",
|
|
8968
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(PanelLeft, { focusable: "false" })
|
|
8969
|
-
}
|
|
8970
|
-
) }),
|
|
8971
|
-
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)("div", { className: getClassName28("rightSideBarToggle"), children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
|
|
8972
|
-
IconButton,
|
|
8973
|
-
{
|
|
8974
|
-
type: "button",
|
|
8975
|
-
onClick: () => {
|
|
8976
|
-
toggleSidebars("right");
|
|
8977
|
-
},
|
|
8978
|
-
title: "Toggle right sidebar",
|
|
8979
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(PanelRight, { focusable: "false" })
|
|
8980
|
-
}
|
|
8981
|
-
) })
|
|
8982
|
-
] }),
|
|
8983
|
-
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)("div", { className: getClassName28("title"), children: /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(Heading, { rank: "2", size: "xs", children: [
|
|
8984
|
-
headerTitle || rootTitle || "Page",
|
|
8985
|
-
headerPath && /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(import_jsx_runtime43.Fragment, { children: [
|
|
8986
|
-
" ",
|
|
8987
|
-
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)("code", { className: getClassName28("path"), children: headerPath })
|
|
8988
|
-
] })
|
|
8989
|
-
] }) }),
|
|
8990
|
-
/* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("div", { className: getClassName28("tools"), children: [
|
|
8991
|
-
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)("div", { className: getClassName28("menuButton"), children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
|
|
8992
|
-
IconButton,
|
|
8993
|
-
{
|
|
8994
|
-
type: "button",
|
|
8995
|
-
onClick: () => {
|
|
8996
|
-
return setMenuOpen(!menuOpen);
|
|
8997
|
-
},
|
|
8998
|
-
title: "Toggle menu bar",
|
|
8999
|
-
children: menuOpen ? /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(ChevronUp, { focusable: "false" }) : /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(ChevronDown, { focusable: "false" })
|
|
9000
|
-
}
|
|
9001
|
-
) }),
|
|
9002
|
-
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
|
|
9003
|
-
MenuBar,
|
|
9004
|
-
{
|
|
9005
|
-
dispatch,
|
|
9006
|
-
onPublish,
|
|
9007
|
-
menuOpen,
|
|
9008
|
-
renderHeaderActions: () => /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(CustomHeaderActions, { children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
|
|
9009
|
-
Button,
|
|
9010
|
-
{
|
|
9011
|
-
onClick: () => {
|
|
9012
|
-
const data = appStore.getState().state.data;
|
|
9013
|
-
onPublish && onPublish(data);
|
|
9014
|
-
},
|
|
9015
|
-
icon: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Globe, { size: "14px" }),
|
|
9016
|
-
children: "Publish"
|
|
9017
|
-
}
|
|
9018
|
-
) }),
|
|
9019
|
-
setMenuOpen
|
|
9020
|
-
}
|
|
9021
|
-
)
|
|
9022
|
-
] })
|
|
9023
|
-
] })
|
|
9169
|
+
ui: {
|
|
9170
|
+
[position === "left" ? "leftSideBarWidth" : "rightSideBarWidth"]: width2
|
|
9024
9171
|
}
|
|
9025
|
-
)
|
|
9026
|
-
|
|
9172
|
+
});
|
|
9173
|
+
let widths = {};
|
|
9174
|
+
try {
|
|
9175
|
+
const savedWidths = localStorage.getItem("puck-sidebar-widths");
|
|
9176
|
+
widths = savedWidths ? JSON.parse(savedWidths) : {};
|
|
9177
|
+
} catch (error) {
|
|
9178
|
+
console.error(
|
|
9179
|
+
`Failed to save ${position} sidebar width to localStorage`,
|
|
9180
|
+
error
|
|
9181
|
+
);
|
|
9182
|
+
} finally {
|
|
9183
|
+
localStorage.setItem(
|
|
9184
|
+
"puck-sidebar-widths",
|
|
9185
|
+
JSON.stringify(__spreadProps(__spreadValues({}, widths), {
|
|
9186
|
+
[position]: width2
|
|
9187
|
+
}))
|
|
9188
|
+
);
|
|
9189
|
+
}
|
|
9190
|
+
window.dispatchEvent(
|
|
9191
|
+
new CustomEvent("viewportchange", {
|
|
9192
|
+
bubbles: true,
|
|
9193
|
+
cancelable: false
|
|
9194
|
+
})
|
|
9195
|
+
);
|
|
9196
|
+
},
|
|
9197
|
+
[dispatch, position]
|
|
9027
9198
|
);
|
|
9028
|
-
|
|
9029
|
-
|
|
9199
|
+
return {
|
|
9200
|
+
width,
|
|
9201
|
+
setWidth,
|
|
9202
|
+
sidebarRef,
|
|
9203
|
+
handleResizeEnd
|
|
9204
|
+
};
|
|
9205
|
+
}
|
|
9030
9206
|
|
|
9031
9207
|
// components/Puck/components/Sidebar/index.tsx
|
|
9032
9208
|
init_react_import();
|
|
@@ -9037,11 +9213,11 @@ var import_react58 = require("react");
|
|
|
9037
9213
|
|
|
9038
9214
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/ResizeHandle/styles.module.css#css-module
|
|
9039
9215
|
init_react_import();
|
|
9040
|
-
var
|
|
9216
|
+
var styles_module_default27 = { "ResizeHandle": "_ResizeHandle_144bf_2", "ResizeHandle--left": "_ResizeHandle--left_144bf_16", "ResizeHandle--right": "_ResizeHandle--right_144bf_20" };
|
|
9041
9217
|
|
|
9042
9218
|
// components/Puck/components/ResizeHandle/index.tsx
|
|
9043
|
-
var
|
|
9044
|
-
var
|
|
9219
|
+
var import_jsx_runtime45 = require("react/jsx-runtime");
|
|
9220
|
+
var getClassName32 = get_class_name_factory_default("ResizeHandle", styles_module_default27);
|
|
9045
9221
|
var ResizeHandle = ({
|
|
9046
9222
|
position,
|
|
9047
9223
|
sidebarRef,
|
|
@@ -9099,11 +9275,11 @@ var ResizeHandle = ({
|
|
|
9099
9275
|
},
|
|
9100
9276
|
[position, handleMouseMove, handleMouseUp]
|
|
9101
9277
|
);
|
|
9102
|
-
return /* @__PURE__ */ (0,
|
|
9278
|
+
return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
|
|
9103
9279
|
"div",
|
|
9104
9280
|
{
|
|
9105
9281
|
ref: handleRef,
|
|
9106
|
-
className:
|
|
9282
|
+
className: getClassName32({ [position]: true }),
|
|
9107
9283
|
onMouseDown: handleMouseDown
|
|
9108
9284
|
}
|
|
9109
9285
|
);
|
|
@@ -9111,11 +9287,11 @@ var ResizeHandle = ({
|
|
|
9111
9287
|
|
|
9112
9288
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Sidebar/styles.module.css#css-module
|
|
9113
9289
|
init_react_import();
|
|
9114
|
-
var
|
|
9290
|
+
var styles_module_default28 = { "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" };
|
|
9115
9291
|
|
|
9116
9292
|
// components/Puck/components/Sidebar/index.tsx
|
|
9117
|
-
var
|
|
9118
|
-
var
|
|
9293
|
+
var import_jsx_runtime46 = require("react/jsx-runtime");
|
|
9294
|
+
var getClassName33 = get_class_name_factory_default("Sidebar", styles_module_default28);
|
|
9119
9295
|
var Sidebar = ({
|
|
9120
9296
|
position,
|
|
9121
9297
|
sidebarRef,
|
|
@@ -9124,10 +9300,16 @@ var Sidebar = ({
|
|
|
9124
9300
|
onResizeEnd,
|
|
9125
9301
|
children
|
|
9126
9302
|
}) => {
|
|
9127
|
-
|
|
9128
|
-
|
|
9129
|
-
|
|
9130
|
-
|
|
9303
|
+
return /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)(import_jsx_runtime46.Fragment, { children: [
|
|
9304
|
+
/* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
|
|
9305
|
+
"div",
|
|
9306
|
+
{
|
|
9307
|
+
ref: sidebarRef,
|
|
9308
|
+
className: getClassName33({ [position]: true, isVisible }),
|
|
9309
|
+
children
|
|
9310
|
+
}
|
|
9311
|
+
),
|
|
9312
|
+
/* @__PURE__ */ (0, import_jsx_runtime46.jsx)("div", { className: `${getClassName33("resizeHandle")}`, children: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
|
|
9131
9313
|
ResizeHandle,
|
|
9132
9314
|
{
|
|
9133
9315
|
position,
|
|
@@ -9139,114 +9321,415 @@ var Sidebar = ({
|
|
|
9139
9321
|
] });
|
|
9140
9322
|
};
|
|
9141
9323
|
|
|
9142
|
-
// lib/use-
|
|
9324
|
+
// lib/use-delete-hotkeys.ts
|
|
9143
9325
|
init_react_import();
|
|
9144
9326
|
var import_react59 = require("react");
|
|
9145
|
-
|
|
9146
|
-
|
|
9147
|
-
|
|
9148
|
-
|
|
9149
|
-
(
|
|
9327
|
+
var isElementVisible = (element) => {
|
|
9328
|
+
let current = element;
|
|
9329
|
+
while (current && current !== document.body) {
|
|
9330
|
+
const style = window.getComputedStyle(current);
|
|
9331
|
+
if (style.display === "none" || style.visibility === "hidden" || style.opacity === "0" || current.getAttribute("aria-hidden") === "true" || current.hasAttribute("hidden")) {
|
|
9332
|
+
return false;
|
|
9333
|
+
}
|
|
9334
|
+
current = current.parentElement;
|
|
9335
|
+
}
|
|
9336
|
+
return true;
|
|
9337
|
+
};
|
|
9338
|
+
var shouldBlockDeleteHotkey = (e) => {
|
|
9339
|
+
var _a;
|
|
9340
|
+
if (e == null ? void 0 : e.defaultPrevented) return true;
|
|
9341
|
+
const origin = ((_a = e == null ? void 0 : e.composedPath) == null ? void 0 : _a.call(e)[0]) || (e == null ? void 0 : e.target) || document.activeElement;
|
|
9342
|
+
if (origin instanceof HTMLElement) {
|
|
9343
|
+
const tag = origin.tagName.toLowerCase();
|
|
9344
|
+
if (tag === "input" || tag === "textarea" || tag === "select") return true;
|
|
9345
|
+
if (origin.isContentEditable) return true;
|
|
9346
|
+
const role = origin.getAttribute("role");
|
|
9347
|
+
if (role === "textbox" || role === "combobox" || role === "searchbox" || role === "listbox" || role === "grid") {
|
|
9348
|
+
return true;
|
|
9349
|
+
}
|
|
9350
|
+
}
|
|
9351
|
+
const modal = document.querySelector(
|
|
9352
|
+
'dialog[open], [aria-modal="true"], [role="dialog"], [role="alertdialog"]'
|
|
9150
9353
|
);
|
|
9151
|
-
(
|
|
9152
|
-
|
|
9153
|
-
|
|
9154
|
-
|
|
9155
|
-
|
|
9156
|
-
|
|
9157
|
-
|
|
9158
|
-
|
|
9159
|
-
|
|
9160
|
-
|
|
9161
|
-
|
|
9162
|
-
|
|
9163
|
-
|
|
9164
|
-
|
|
9165
|
-
|
|
9166
|
-
|
|
9354
|
+
if (modal && isElementVisible(modal)) {
|
|
9355
|
+
return true;
|
|
9356
|
+
}
|
|
9357
|
+
return false;
|
|
9358
|
+
};
|
|
9359
|
+
var useDeleteHotkeys = () => {
|
|
9360
|
+
const appStore = useAppStoreApi();
|
|
9361
|
+
const deleteSelectedComponent = (0, import_react59.useCallback)(
|
|
9362
|
+
(e) => {
|
|
9363
|
+
var _a;
|
|
9364
|
+
if (shouldBlockDeleteHotkey(e)) {
|
|
9365
|
+
return false;
|
|
9366
|
+
}
|
|
9367
|
+
const { state, dispatch, permissions, selectedItem } = appStore.getState();
|
|
9368
|
+
const sel = (_a = state.ui) == null ? void 0 : _a.itemSelector;
|
|
9369
|
+
if (!(sel == null ? void 0 : sel.zone) || !selectedItem) return true;
|
|
9370
|
+
if (!permissions.getPermissions({ item: selectedItem }).delete)
|
|
9371
|
+
return true;
|
|
9372
|
+
dispatch({
|
|
9373
|
+
type: "remove",
|
|
9374
|
+
index: sel.index,
|
|
9375
|
+
zone: sel.zone
|
|
9376
|
+
});
|
|
9377
|
+
return true;
|
|
9378
|
+
},
|
|
9379
|
+
[appStore]
|
|
9380
|
+
);
|
|
9381
|
+
useHotkey({ delete: true }, deleteSelectedComponent);
|
|
9382
|
+
useHotkey({ backspace: true }, deleteSelectedComponent);
|
|
9383
|
+
};
|
|
9384
|
+
|
|
9385
|
+
// components/Puck/components/Nav/index.tsx
|
|
9386
|
+
init_react_import();
|
|
9387
|
+
|
|
9388
|
+
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Nav/styles.module.css#css-module
|
|
9389
|
+
init_react_import();
|
|
9390
|
+
var styles_module_default29 = { "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" };
|
|
9391
|
+
|
|
9392
|
+
// components/Puck/components/Nav/index.tsx
|
|
9393
|
+
var import_jsx_runtime47 = require("react/jsx-runtime");
|
|
9394
|
+
var getClassName34 = get_class_name_factory_default("Nav", styles_module_default29);
|
|
9395
|
+
var getClassNameItem3 = get_class_name_factory_default("NavItem", styles_module_default29);
|
|
9396
|
+
var MenuItem = ({
|
|
9397
|
+
label,
|
|
9398
|
+
icon,
|
|
9399
|
+
onClick,
|
|
9400
|
+
isActive,
|
|
9401
|
+
mobileOnly
|
|
9402
|
+
}) => {
|
|
9403
|
+
return /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("li", { className: getClassNameItem3({ active: isActive, mobileOnly }), children: onClick && /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("div", { className: getClassNameItem3("link"), onClick, children: [
|
|
9404
|
+
icon && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("span", { className: getClassNameItem3("linkIcon"), children: icon }),
|
|
9405
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("span", { className: getClassNameItem3("linkLabel"), children: label })
|
|
9406
|
+
] }) });
|
|
9407
|
+
};
|
|
9408
|
+
var Nav = ({
|
|
9409
|
+
items,
|
|
9410
|
+
mobileActions
|
|
9411
|
+
}) => {
|
|
9412
|
+
return /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("nav", { className: getClassName34(), children: [
|
|
9413
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("ul", { className: getClassName34("list"), children: Object.entries(items).map(([key, item]) => /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(MenuItem, __spreadValues({}, item), key)) }),
|
|
9414
|
+
mobileActions && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("div", { className: getClassName34("mobileActions"), children: mobileActions })
|
|
9415
|
+
] });
|
|
9416
|
+
};
|
|
9417
|
+
|
|
9418
|
+
// plugins/blocks/index.tsx
|
|
9419
|
+
init_react_import();
|
|
9420
|
+
var import_jsx_runtime48 = require("react/jsx-runtime");
|
|
9421
|
+
var blocksPlugin = () => ({
|
|
9422
|
+
name: "blocks",
|
|
9423
|
+
label: "Blocks",
|
|
9424
|
+
render: Components,
|
|
9425
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(Hammer, {})
|
|
9426
|
+
});
|
|
9427
|
+
|
|
9428
|
+
// plugins/outline/index.tsx
|
|
9429
|
+
init_react_import();
|
|
9430
|
+
var import_jsx_runtime49 = require("react/jsx-runtime");
|
|
9431
|
+
var outlinePlugin = () => ({
|
|
9432
|
+
name: "outline",
|
|
9433
|
+
label: "Outline",
|
|
9434
|
+
render: Outline,
|
|
9435
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(Layers, {})
|
|
9436
|
+
});
|
|
9437
|
+
|
|
9438
|
+
// plugins/fields/index.tsx
|
|
9439
|
+
init_react_import();
|
|
9440
|
+
|
|
9441
|
+
// css-module:/home/runner/work/puck/puck/packages/core/plugins/fields/styles.module.css#css-module
|
|
9442
|
+
init_react_import();
|
|
9443
|
+
var styles_module_default30 = { "FieldsPlugin": "_FieldsPlugin_nd930_1", "FieldsPlugin-header": "_FieldsPlugin-header_nd930_7" };
|
|
9444
|
+
|
|
9445
|
+
// plugins/fields/index.tsx
|
|
9446
|
+
var import_jsx_runtime50 = require("react/jsx-runtime");
|
|
9447
|
+
var getClassName35 = get_class_name_factory_default("FieldsPlugin", styles_module_default30);
|
|
9448
|
+
var CurrentTitle = () => {
|
|
9449
|
+
const label = useAppStore((s) => {
|
|
9450
|
+
var _a, _b;
|
|
9451
|
+
const selectedItem = s.selectedItem;
|
|
9452
|
+
return selectedItem ? (_b = (_a = s.config.components[selectedItem.type]) == null ? void 0 : _a.label) != null ? _b : selectedItem.type : "Page";
|
|
9453
|
+
});
|
|
9454
|
+
return label;
|
|
9455
|
+
};
|
|
9456
|
+
var fieldsPlugin = ({ mobileOnly = true } = {}) => ({
|
|
9457
|
+
name: "fields",
|
|
9458
|
+
label: "Fields",
|
|
9459
|
+
render: () => /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("div", { className: getClassName35(), children: [
|
|
9460
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)("div", { className: getClassName35("header"), children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Breadcrumbs, { numParents: 2, children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(CurrentTitle, {}) }) }),
|
|
9461
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Fields, {})
|
|
9462
|
+
] }),
|
|
9463
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(RectangleEllipsis, {}),
|
|
9464
|
+
mobileOnly
|
|
9465
|
+
});
|
|
9466
|
+
|
|
9467
|
+
// components/Puck/components/Layout/index.tsx
|
|
9468
|
+
var import_jsx_runtime51 = require("react/jsx-runtime");
|
|
9469
|
+
var getClassName36 = get_class_name_factory_default("Puck", styles_module_default20);
|
|
9470
|
+
var getLayoutClassName = get_class_name_factory_default("PuckLayout", styles_module_default20);
|
|
9471
|
+
var getPluginTabClassName = get_class_name_factory_default("PuckPluginTab", styles_module_default20);
|
|
9472
|
+
var FieldSideBar = () => {
|
|
9473
|
+
const title = useAppStore(
|
|
9474
|
+
(s) => {
|
|
9475
|
+
var _a, _b;
|
|
9476
|
+
return s.selectedItem ? (_b = (_a = s.config.components[s.selectedItem.type]) == null ? void 0 : _a["label"]) != null ? _b : s.selectedItem.type.toString() : "Page";
|
|
9477
|
+
}
|
|
9478
|
+
);
|
|
9479
|
+
return /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(SidebarSection, { noPadding: true, noBorderTop: true, showBreadcrumbs: true, title, children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Fields, {}) });
|
|
9480
|
+
};
|
|
9481
|
+
var PluginTab = ({
|
|
9482
|
+
children,
|
|
9483
|
+
visible,
|
|
9484
|
+
mobileOnly
|
|
9485
|
+
}) => {
|
|
9486
|
+
return /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("div", { className: getPluginTabClassName({ visible, mobileOnly }), children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("div", { className: getPluginTabClassName("body"), children }) });
|
|
9487
|
+
};
|
|
9488
|
+
var Layout = ({ children }) => {
|
|
9489
|
+
const {
|
|
9490
|
+
iframe: _iframe,
|
|
9491
|
+
dnd,
|
|
9492
|
+
initialHistory: _initialHistory,
|
|
9493
|
+
plugins,
|
|
9494
|
+
height = "100dvh"
|
|
9495
|
+
} = usePropsContext();
|
|
9496
|
+
const iframe = (0, import_react60.useMemo)(
|
|
9497
|
+
() => __spreadValues({
|
|
9498
|
+
enabled: true,
|
|
9499
|
+
waitForStyles: true
|
|
9500
|
+
}, _iframe),
|
|
9501
|
+
[_iframe]
|
|
9502
|
+
);
|
|
9503
|
+
useInjectGlobalCss(iframe.enabled);
|
|
9504
|
+
const dispatch = useAppStore((s) => s.dispatch);
|
|
9505
|
+
const leftSideBarVisible = useAppStore((s) => s.state.ui.leftSideBarVisible);
|
|
9506
|
+
const rightSideBarVisible = useAppStore(
|
|
9507
|
+
(s) => s.state.ui.rightSideBarVisible
|
|
9508
|
+
);
|
|
9509
|
+
const instanceId = useAppStore((s) => s.instanceId);
|
|
9510
|
+
const {
|
|
9511
|
+
width: leftWidth,
|
|
9512
|
+
setWidth: setLeftWidth,
|
|
9513
|
+
sidebarRef: leftSidebarRef,
|
|
9514
|
+
handleResizeEnd: handleLeftSidebarResizeEnd
|
|
9515
|
+
} = useSidebarResize("left", dispatch);
|
|
9516
|
+
const {
|
|
9517
|
+
width: rightWidth,
|
|
9518
|
+
setWidth: setRightWidth,
|
|
9519
|
+
sidebarRef: rightSidebarRef,
|
|
9520
|
+
handleResizeEnd: handleRightSidebarResizeEnd
|
|
9521
|
+
} = useSidebarResize("right", dispatch);
|
|
9522
|
+
(0, import_react60.useEffect)(() => {
|
|
9523
|
+
if (!window.matchMedia("(min-width: 638px)").matches) {
|
|
9524
|
+
dispatch({
|
|
9525
|
+
type: "setUi",
|
|
9526
|
+
ui: {
|
|
9527
|
+
leftSideBarVisible: false,
|
|
9528
|
+
rightSideBarVisible: false
|
|
9167
9529
|
}
|
|
9168
|
-
}
|
|
9169
|
-
|
|
9170
|
-
|
|
9171
|
-
|
|
9172
|
-
|
|
9530
|
+
});
|
|
9531
|
+
}
|
|
9532
|
+
const handleResize = () => {
|
|
9533
|
+
if (!window.matchMedia("(min-width: 638px)").matches) {
|
|
9534
|
+
dispatch({
|
|
9535
|
+
type: "setUi",
|
|
9536
|
+
ui: (ui) => __spreadValues(__spreadValues({}, ui), ui.rightSideBarVisible ? { leftSideBarVisible: false } : {})
|
|
9537
|
+
});
|
|
9538
|
+
}
|
|
9539
|
+
};
|
|
9540
|
+
window.addEventListener("resize", handleResize);
|
|
9541
|
+
return () => {
|
|
9542
|
+
window.removeEventListener("resize", handleResize);
|
|
9543
|
+
};
|
|
9544
|
+
}, []);
|
|
9545
|
+
const overrides = useAppStore((s) => s.overrides);
|
|
9546
|
+
const CustomPuck = (0, import_react60.useMemo)(
|
|
9547
|
+
() => overrides.puck || DefaultOverride,
|
|
9548
|
+
[overrides]
|
|
9549
|
+
);
|
|
9550
|
+
const [mounted, setMounted] = (0, import_react60.useState)(false);
|
|
9551
|
+
(0, import_react60.useEffect)(() => {
|
|
9552
|
+
setMounted(true);
|
|
9553
|
+
}, []);
|
|
9554
|
+
const ready = useAppStore((s) => s.status === "READY");
|
|
9555
|
+
useMonitorHotkeys();
|
|
9556
|
+
(0, import_react60.useEffect)(() => {
|
|
9557
|
+
if (ready && iframe.enabled) {
|
|
9558
|
+
const frameDoc = getFrame();
|
|
9559
|
+
if (frameDoc) {
|
|
9560
|
+
return monitorHotkeys(frameDoc);
|
|
9561
|
+
}
|
|
9562
|
+
}
|
|
9563
|
+
}, [ready, iframe.enabled]);
|
|
9564
|
+
usePreviewModeHotkeys();
|
|
9565
|
+
useDeleteHotkeys();
|
|
9566
|
+
const layoutOptions = {};
|
|
9567
|
+
if (leftWidth) {
|
|
9568
|
+
layoutOptions["--puck-user-left-side-bar-width"] = `${leftWidth}px`;
|
|
9569
|
+
}
|
|
9570
|
+
if (rightWidth) {
|
|
9571
|
+
layoutOptions["--puck-user-right-side-bar-width"] = `${rightWidth}px`;
|
|
9572
|
+
}
|
|
9573
|
+
const setUi = useAppStore((s) => s.setUi);
|
|
9574
|
+
const currentPlugin = useAppStore((s) => {
|
|
9575
|
+
var _a;
|
|
9576
|
+
return (_a = s.state.ui.plugin) == null ? void 0 : _a.current;
|
|
9577
|
+
});
|
|
9578
|
+
const appStoreApi = useAppStoreApi();
|
|
9579
|
+
const [mobilePanelHeightMode, setMobilePanelHeightMode] = (0, import_react60.useState)("toggle");
|
|
9580
|
+
const pluginItems = (0, import_react60.useMemo)(() => {
|
|
9581
|
+
const details = {};
|
|
9582
|
+
const defaultPlugins = [blocksPlugin(), outlinePlugin()];
|
|
9583
|
+
const combinedPlugins = [
|
|
9584
|
+
...defaultPlugins,
|
|
9585
|
+
...plugins != null ? plugins : []
|
|
9586
|
+
];
|
|
9587
|
+
if (!(plugins == null ? void 0 : plugins.some((p) => p.name === "fields"))) {
|
|
9588
|
+
combinedPlugins.push(fieldsPlugin());
|
|
9589
|
+
}
|
|
9590
|
+
combinedPlugins == null ? void 0 : combinedPlugins.forEach((plugin) => {
|
|
9591
|
+
var _a, _b;
|
|
9592
|
+
if (plugin.name && plugin.render) {
|
|
9593
|
+
if (details[plugin.name]) {
|
|
9594
|
+
delete details[plugin.name];
|
|
9595
|
+
}
|
|
9596
|
+
details[plugin.name] = {
|
|
9597
|
+
label: (_a = plugin.label) != null ? _a : plugin.name,
|
|
9598
|
+
icon: (_b = plugin.icon) != null ? _b : /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(ToyBrick, {}),
|
|
9599
|
+
onClick: () => {
|
|
9600
|
+
var _a2;
|
|
9601
|
+
setMobilePanelHeightMode((_a2 = plugin.mobilePanelHeight) != null ? _a2 : "toggle");
|
|
9602
|
+
if (plugin.name === currentPlugin) {
|
|
9603
|
+
if (leftSideBarVisible) {
|
|
9604
|
+
setUi({ leftSideBarVisible: false });
|
|
9605
|
+
} else {
|
|
9606
|
+
setUi({ leftSideBarVisible: true });
|
|
9607
|
+
}
|
|
9608
|
+
} else {
|
|
9609
|
+
if (plugin.name) {
|
|
9610
|
+
setUi({
|
|
9611
|
+
plugin: { current: plugin.name },
|
|
9612
|
+
leftSideBarVisible: true
|
|
9613
|
+
});
|
|
9614
|
+
}
|
|
9615
|
+
}
|
|
9616
|
+
},
|
|
9617
|
+
isActive: leftSideBarVisible && currentPlugin === plugin.name,
|
|
9618
|
+
render: plugin.render,
|
|
9619
|
+
mobileOnly: plugin.mobileOnly
|
|
9620
|
+
};
|
|
9173
9621
|
}
|
|
9622
|
+
});
|
|
9623
|
+
return details;
|
|
9624
|
+
}, [plugins, currentPlugin, appStoreApi, leftSideBarVisible]);
|
|
9625
|
+
(0, import_react60.useEffect)(() => {
|
|
9626
|
+
if (!currentPlugin) {
|
|
9627
|
+
const names = Object.keys(pluginItems);
|
|
9628
|
+
setUi({ plugin: { current: names[0] } });
|
|
9174
9629
|
}
|
|
9175
|
-
}, [
|
|
9176
|
-
|
|
9177
|
-
|
|
9178
|
-
|
|
9630
|
+
}, [pluginItems, currentPlugin]);
|
|
9631
|
+
const hasDesktopFieldsPlugin = pluginItems["fields"] && pluginItems["fields"].mobileOnly === false;
|
|
9632
|
+
const mobilePanelExpanded = useAppStore(
|
|
9633
|
+
(s) => {
|
|
9634
|
+
var _a;
|
|
9635
|
+
return (_a = s.state.ui.mobilePanelExpanded) != null ? _a : false;
|
|
9179
9636
|
}
|
|
9180
|
-
}, [storeWidth]);
|
|
9181
|
-
const handleResizeEnd = (0, import_react59.useCallback)(
|
|
9182
|
-
(width2) => {
|
|
9183
|
-
dispatch({
|
|
9184
|
-
type: "setUi",
|
|
9185
|
-
ui: {
|
|
9186
|
-
[position === "left" ? "leftSideBarWidth" : "rightSideBarWidth"]: width2
|
|
9187
|
-
}
|
|
9188
|
-
});
|
|
9189
|
-
let widths = {};
|
|
9190
|
-
try {
|
|
9191
|
-
const savedWidths = localStorage.getItem("puck-sidebar-widths");
|
|
9192
|
-
widths = savedWidths ? JSON.parse(savedWidths) : {};
|
|
9193
|
-
} catch (error) {
|
|
9194
|
-
console.error(
|
|
9195
|
-
`Failed to save ${position} sidebar width to localStorage`,
|
|
9196
|
-
error
|
|
9197
|
-
);
|
|
9198
|
-
} finally {
|
|
9199
|
-
localStorage.setItem(
|
|
9200
|
-
"puck-sidebar-widths",
|
|
9201
|
-
JSON.stringify(__spreadProps(__spreadValues({}, widths), {
|
|
9202
|
-
[position]: width2
|
|
9203
|
-
}))
|
|
9204
|
-
);
|
|
9205
|
-
}
|
|
9206
|
-
window.dispatchEvent(
|
|
9207
|
-
new CustomEvent("viewportchange", {
|
|
9208
|
-
bubbles: true,
|
|
9209
|
-
cancelable: false
|
|
9210
|
-
})
|
|
9211
|
-
);
|
|
9212
|
-
},
|
|
9213
|
-
[dispatch, position]
|
|
9214
9637
|
);
|
|
9215
|
-
return
|
|
9216
|
-
|
|
9217
|
-
|
|
9218
|
-
|
|
9219
|
-
|
|
9220
|
-
|
|
9221
|
-
|
|
9222
|
-
|
|
9223
|
-
|
|
9224
|
-
|
|
9225
|
-
|
|
9226
|
-
|
|
9227
|
-
|
|
9228
|
-
|
|
9229
|
-
|
|
9230
|
-
|
|
9231
|
-
|
|
9232
|
-
|
|
9233
|
-
|
|
9234
|
-
|
|
9235
|
-
|
|
9236
|
-
|
|
9237
|
-
|
|
9238
|
-
|
|
9239
|
-
|
|
9240
|
-
|
|
9638
|
+
return /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(
|
|
9639
|
+
"div",
|
|
9640
|
+
{
|
|
9641
|
+
className: `Puck ${getClassName36()}`,
|
|
9642
|
+
style: { height },
|
|
9643
|
+
id: instanceId,
|
|
9644
|
+
children: [
|
|
9645
|
+
/* @__PURE__ */ (0, import_jsx_runtime51.jsx)(DragDropContext, { disableAutoScroll: dnd == null ? void 0 : dnd.disableAutoScroll, children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(CustomPuck, { children: children || /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(FrameProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
|
|
9646
|
+
"div",
|
|
9647
|
+
{
|
|
9648
|
+
className: getLayoutClassName({
|
|
9649
|
+
leftSideBarVisible,
|
|
9650
|
+
mounted,
|
|
9651
|
+
rightSideBarVisible: !hasDesktopFieldsPlugin && rightSideBarVisible,
|
|
9652
|
+
isExpanded: mobilePanelExpanded,
|
|
9653
|
+
mobilePanelHeightToggle: mobilePanelHeightMode === "toggle",
|
|
9654
|
+
mobilePanelHeightMinContent: mobilePanelHeightMode === "min-content"
|
|
9655
|
+
}),
|
|
9656
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(
|
|
9657
|
+
"div",
|
|
9658
|
+
{
|
|
9659
|
+
className: getLayoutClassName("inner"),
|
|
9660
|
+
style: layoutOptions,
|
|
9661
|
+
children: [
|
|
9662
|
+
/* @__PURE__ */ (0, import_jsx_runtime51.jsx)("div", { className: getLayoutClassName("header"), children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Header, {}) }),
|
|
9663
|
+
/* @__PURE__ */ (0, import_jsx_runtime51.jsx)("div", { className: getLayoutClassName("nav"), children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
|
|
9664
|
+
Nav,
|
|
9665
|
+
{
|
|
9666
|
+
items: pluginItems,
|
|
9667
|
+
mobileActions: leftSideBarVisible && mobilePanelHeightMode === "toggle" && /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
|
|
9668
|
+
IconButton,
|
|
9669
|
+
{
|
|
9670
|
+
type: "button",
|
|
9671
|
+
title: "maximize",
|
|
9672
|
+
onClick: () => {
|
|
9673
|
+
setUi({
|
|
9674
|
+
mobilePanelExpanded: !mobilePanelExpanded
|
|
9675
|
+
});
|
|
9676
|
+
},
|
|
9677
|
+
children: mobilePanelExpanded ? /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Minimize2, { size: 21 }) : /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Maximize2, { size: 21 })
|
|
9678
|
+
}
|
|
9679
|
+
)
|
|
9680
|
+
}
|
|
9681
|
+
) }),
|
|
9682
|
+
/* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
|
|
9683
|
+
Sidebar,
|
|
9684
|
+
{
|
|
9685
|
+
position: "left",
|
|
9686
|
+
sidebarRef: leftSidebarRef,
|
|
9687
|
+
isVisible: leftSideBarVisible,
|
|
9688
|
+
onResize: setLeftWidth,
|
|
9689
|
+
onResizeEnd: handleLeftSidebarResizeEnd,
|
|
9690
|
+
children: Object.entries(pluginItems).map(
|
|
9691
|
+
([id, { mobileOnly, render: Render2, label }]) => /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
|
|
9692
|
+
PluginTab,
|
|
9693
|
+
{
|
|
9694
|
+
visible: currentPlugin === id,
|
|
9695
|
+
mobileOnly,
|
|
9696
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Render2, {})
|
|
9697
|
+
},
|
|
9698
|
+
id
|
|
9699
|
+
)
|
|
9700
|
+
)
|
|
9701
|
+
}
|
|
9702
|
+
),
|
|
9703
|
+
/* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Canvas, {}),
|
|
9704
|
+
!hasDesktopFieldsPlugin && /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
|
|
9705
|
+
Sidebar,
|
|
9706
|
+
{
|
|
9707
|
+
position: "right",
|
|
9708
|
+
sidebarRef: rightSidebarRef,
|
|
9709
|
+
isVisible: rightSideBarVisible,
|
|
9710
|
+
onResize: setRightWidth,
|
|
9711
|
+
onResizeEnd: handleRightSidebarResizeEnd,
|
|
9712
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(FieldSideBar, {})
|
|
9713
|
+
}
|
|
9714
|
+
)
|
|
9715
|
+
]
|
|
9716
|
+
}
|
|
9717
|
+
)
|
|
9718
|
+
}
|
|
9719
|
+
) }) }) }),
|
|
9720
|
+
/* @__PURE__ */ (0, import_jsx_runtime51.jsx)("div", { id: "puck-portal-root", className: getClassName36("portal") })
|
|
9721
|
+
]
|
|
9241
9722
|
}
|
|
9242
9723
|
);
|
|
9243
|
-
return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(SidebarSection, { noPadding: true, noBorderTop: true, showBreadcrumbs: true, title, children: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(Fields, {}) });
|
|
9244
9724
|
};
|
|
9245
|
-
|
|
9725
|
+
|
|
9726
|
+
// components/Puck/index.tsx
|
|
9727
|
+
var import_jsx_runtime52 = require("react/jsx-runtime");
|
|
9728
|
+
var propsContext = (0, import_react61.createContext)({});
|
|
9246
9729
|
function PropsProvider(props) {
|
|
9247
|
-
return /* @__PURE__ */ (0,
|
|
9730
|
+
return /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(propsContext.Provider, { value: props, children: props.children });
|
|
9248
9731
|
}
|
|
9249
|
-
var usePropsContext = () => (0,
|
|
9732
|
+
var usePropsContext = () => (0, import_react61.useContext)(propsContext);
|
|
9250
9733
|
function PuckProvider({ children }) {
|
|
9251
9734
|
const {
|
|
9252
9735
|
config,
|
|
@@ -9263,15 +9746,15 @@ function PuckProvider({ children }) {
|
|
|
9263
9746
|
onAction,
|
|
9264
9747
|
fieldTransforms
|
|
9265
9748
|
} = usePropsContext();
|
|
9266
|
-
const iframe = (0,
|
|
9749
|
+
const iframe = (0, import_react61.useMemo)(
|
|
9267
9750
|
() => __spreadValues({
|
|
9268
9751
|
enabled: true,
|
|
9269
9752
|
waitForStyles: true
|
|
9270
9753
|
}, _iframe),
|
|
9271
9754
|
[_iframe]
|
|
9272
9755
|
);
|
|
9273
|
-
const [generatedAppState] = (0,
|
|
9274
|
-
var _a, _b, _c, _d, _e, _f, _g
|
|
9756
|
+
const [generatedAppState] = (0, import_react61.useState)(() => {
|
|
9757
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
9275
9758
|
const initial = __spreadValues(__spreadValues({}, defaultAppState.ui), initialUi);
|
|
9276
9759
|
let clientUiState = {};
|
|
9277
9760
|
if (typeof window !== "undefined") {
|
|
@@ -9282,29 +9765,39 @@ function PuckProvider({ children }) {
|
|
|
9282
9765
|
});
|
|
9283
9766
|
}
|
|
9284
9767
|
const viewportWidth = window.innerWidth;
|
|
9285
|
-
const
|
|
9768
|
+
const fullWidthViewport = Object.values(viewports).find(
|
|
9769
|
+
(v) => v.width === "100%"
|
|
9770
|
+
);
|
|
9771
|
+
const containsFullWidthViewport = !!fullWidthViewport;
|
|
9772
|
+
const viewportDifferences = Object.entries(viewports).filter(([_, value]) => value.width !== "100%").map(([key, value]) => ({
|
|
9286
9773
|
key,
|
|
9287
|
-
diff: Math.abs(
|
|
9774
|
+
diff: Math.abs(
|
|
9775
|
+
viewportWidth - (typeof value.width === "string" ? viewportWidth : value.width)
|
|
9776
|
+
),
|
|
9777
|
+
value
|
|
9288
9778
|
})).sort((a, b) => a.diff > b.diff ? 1 : -1);
|
|
9289
|
-
|
|
9779
|
+
let closestViewport = viewportDifferences[0].value;
|
|
9780
|
+
if (closestViewport.width < viewportWidth && containsFullWidthViewport) {
|
|
9781
|
+
closestViewport = fullWidthViewport;
|
|
9782
|
+
}
|
|
9290
9783
|
if (iframe.enabled) {
|
|
9291
9784
|
clientUiState = __spreadProps(__spreadValues({}, clientUiState), {
|
|
9292
9785
|
viewports: __spreadProps(__spreadValues({}, initial.viewports), {
|
|
9293
9786
|
current: __spreadProps(__spreadValues({}, initial.viewports.current), {
|
|
9294
|
-
height: ((_b = (_a = initialUi == null ? void 0 : initialUi.viewports) == null ? void 0 : _a.current) == null ? void 0 : _b.height) || (
|
|
9295
|
-
width: ((
|
|
9787
|
+
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",
|
|
9788
|
+
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)
|
|
9296
9789
|
})
|
|
9297
9790
|
})
|
|
9298
9791
|
});
|
|
9299
9792
|
}
|
|
9300
9793
|
}
|
|
9301
|
-
if (Object.keys((initialData == null ? void 0 : initialData.root) || {}).length > 0 && !((
|
|
9794
|
+
if (Object.keys((initialData == null ? void 0 : initialData.root) || {}).length > 0 && !((_e = initialData == null ? void 0 : initialData.root) == null ? void 0 : _e.props)) {
|
|
9302
9795
|
console.warn(
|
|
9303
9796
|
"Warning: Defining props on `root` is deprecated. Please use `root.props`, or republish this page to migrate automatically."
|
|
9304
9797
|
);
|
|
9305
9798
|
}
|
|
9306
|
-
const rootProps = ((
|
|
9307
|
-
const defaultedRootProps = __spreadValues(__spreadValues({}, (
|
|
9799
|
+
const rootProps = ((_f = initialData == null ? void 0 : initialData.root) == null ? void 0 : _f.props) || (initialData == null ? void 0 : initialData.root) || {};
|
|
9800
|
+
const defaultedRootProps = __spreadValues(__spreadValues({}, (_g = config.root) == null ? void 0 : _g.defaultProps), rootProps);
|
|
9308
9801
|
const root = populateIds(
|
|
9309
9802
|
toComponent(__spreadProps(__spreadValues({}, initialData == null ? void 0 : initialData.root), { props: defaultedRootProps })),
|
|
9310
9803
|
config
|
|
@@ -9334,7 +9827,7 @@ function PuckProvider({ children }) {
|
|
|
9334
9827
|
return walkAppState(newAppState, config);
|
|
9335
9828
|
});
|
|
9336
9829
|
const { appendData = true } = _initialHistory || {};
|
|
9337
|
-
const [blendedHistories] = (0,
|
|
9830
|
+
const [blendedHistories] = (0, import_react61.useState)(
|
|
9338
9831
|
[
|
|
9339
9832
|
...(_initialHistory == null ? void 0 : _initialHistory.histories) || [],
|
|
9340
9833
|
...appendData ? [{ state: generatedAppState }] : []
|
|
@@ -9354,7 +9847,7 @@ function PuckProvider({ children }) {
|
|
|
9354
9847
|
overrides,
|
|
9355
9848
|
plugins
|
|
9356
9849
|
});
|
|
9357
|
-
const loadedFieldTransforms = (0,
|
|
9850
|
+
const loadedFieldTransforms = (0, import_react61.useMemo)(() => {
|
|
9358
9851
|
const _plugins = plugins || [];
|
|
9359
9852
|
const pluginFieldTransforms = _plugins.reduce(
|
|
9360
9853
|
(acc, plugin) => __spreadValues(__spreadValues({}, acc), plugin.fieldTransforms),
|
|
@@ -9362,9 +9855,11 @@ function PuckProvider({ children }) {
|
|
|
9362
9855
|
);
|
|
9363
9856
|
return __spreadValues(__spreadValues({}, pluginFieldTransforms), fieldTransforms);
|
|
9364
9857
|
}, [fieldTransforms, plugins]);
|
|
9365
|
-
const
|
|
9858
|
+
const instanceId = useSafeId();
|
|
9859
|
+
const generateAppStore = (0, import_react61.useCallback)(
|
|
9366
9860
|
(state) => {
|
|
9367
9861
|
return {
|
|
9862
|
+
instanceId,
|
|
9368
9863
|
state,
|
|
9369
9864
|
config,
|
|
9370
9865
|
plugins: plugins || [],
|
|
@@ -9377,6 +9872,7 @@ function PuckProvider({ children }) {
|
|
|
9377
9872
|
};
|
|
9378
9873
|
},
|
|
9379
9874
|
[
|
|
9875
|
+
instanceId,
|
|
9380
9876
|
initialAppState,
|
|
9381
9877
|
config,
|
|
9382
9878
|
plugins,
|
|
@@ -9388,15 +9884,15 @@ function PuckProvider({ children }) {
|
|
|
9388
9884
|
loadedFieldTransforms
|
|
9389
9885
|
]
|
|
9390
9886
|
);
|
|
9391
|
-
const [appStore] = (0,
|
|
9887
|
+
const [appStore] = (0, import_react61.useState)(
|
|
9392
9888
|
() => createAppStore(generateAppStore(initialAppState))
|
|
9393
9889
|
);
|
|
9394
|
-
(0,
|
|
9890
|
+
(0, import_react61.useEffect)(() => {
|
|
9395
9891
|
if (process.env.NODE_ENV !== "production") {
|
|
9396
9892
|
window.__PUCK_INTERNAL_DO_NOT_USE = { appStore };
|
|
9397
9893
|
}
|
|
9398
9894
|
}, [appStore]);
|
|
9399
|
-
(0,
|
|
9895
|
+
(0, import_react61.useEffect)(() => {
|
|
9400
9896
|
const state = appStore.getState().state;
|
|
9401
9897
|
appStore.setState(__spreadValues({}, generateAppStore(state)));
|
|
9402
9898
|
}, [config, plugins, loadedOverrides, viewports, iframe, onAction, metadata]);
|
|
@@ -9405,9 +9901,9 @@ function PuckProvider({ children }) {
|
|
|
9405
9901
|
index: initialHistoryIndex,
|
|
9406
9902
|
initialAppState
|
|
9407
9903
|
});
|
|
9408
|
-
const previousData = (0,
|
|
9409
|
-
(0,
|
|
9410
|
-
appStore.subscribe(
|
|
9904
|
+
const previousData = (0, import_react61.useRef)(null);
|
|
9905
|
+
(0, import_react61.useEffect)(() => {
|
|
9906
|
+
return appStore.subscribe(
|
|
9411
9907
|
(s) => s.state.data,
|
|
9412
9908
|
(data) => {
|
|
9413
9909
|
if (onChange) {
|
|
@@ -9417,149 +9913,17 @@ function PuckProvider({ children }) {
|
|
|
9417
9913
|
}
|
|
9418
9914
|
}
|
|
9419
9915
|
);
|
|
9420
|
-
}, []);
|
|
9916
|
+
}, [onChange]);
|
|
9421
9917
|
useRegisterPermissionsSlice(appStore, permissions);
|
|
9422
9918
|
const uPuckStore = useRegisterUsePuckStore(appStore);
|
|
9423
|
-
(0,
|
|
9919
|
+
(0, import_react61.useEffect)(() => {
|
|
9424
9920
|
const { resolveAndCommitData } = appStore.getState();
|
|
9425
9921
|
resolveAndCommitData();
|
|
9426
9922
|
}, []);
|
|
9427
|
-
return /* @__PURE__ */ (0,
|
|
9428
|
-
}
|
|
9429
|
-
function PuckLayout({ children }) {
|
|
9430
|
-
const {
|
|
9431
|
-
iframe: _iframe,
|
|
9432
|
-
dnd,
|
|
9433
|
-
initialHistory: _initialHistory
|
|
9434
|
-
} = usePropsContext();
|
|
9435
|
-
const iframe = (0, import_react60.useMemo)(
|
|
9436
|
-
() => __spreadValues({
|
|
9437
|
-
enabled: true,
|
|
9438
|
-
waitForStyles: true
|
|
9439
|
-
}, _iframe),
|
|
9440
|
-
[_iframe]
|
|
9441
|
-
);
|
|
9442
|
-
useInjectGlobalCss(iframe.enabled);
|
|
9443
|
-
const dispatch = useAppStore((s) => s.dispatch);
|
|
9444
|
-
const leftSideBarVisible = useAppStore((s) => s.state.ui.leftSideBarVisible);
|
|
9445
|
-
const rightSideBarVisible = useAppStore(
|
|
9446
|
-
(s) => s.state.ui.rightSideBarVisible
|
|
9447
|
-
);
|
|
9448
|
-
const {
|
|
9449
|
-
width: leftWidth,
|
|
9450
|
-
setWidth: setLeftWidth,
|
|
9451
|
-
sidebarRef: leftSidebarRef,
|
|
9452
|
-
handleResizeEnd: handleLeftSidebarResizeEnd
|
|
9453
|
-
} = useSidebarResize("left", dispatch);
|
|
9454
|
-
const {
|
|
9455
|
-
width: rightWidth,
|
|
9456
|
-
setWidth: setRightWidth,
|
|
9457
|
-
sidebarRef: rightSidebarRef,
|
|
9458
|
-
handleResizeEnd: handleRightSidebarResizeEnd
|
|
9459
|
-
} = useSidebarResize("right", dispatch);
|
|
9460
|
-
(0, import_react60.useEffect)(() => {
|
|
9461
|
-
if (!window.matchMedia("(min-width: 638px)").matches) {
|
|
9462
|
-
dispatch({
|
|
9463
|
-
type: "setUi",
|
|
9464
|
-
ui: {
|
|
9465
|
-
leftSideBarVisible: false,
|
|
9466
|
-
rightSideBarVisible: false
|
|
9467
|
-
}
|
|
9468
|
-
});
|
|
9469
|
-
}
|
|
9470
|
-
const handleResize = () => {
|
|
9471
|
-
if (!window.matchMedia("(min-width: 638px)").matches) {
|
|
9472
|
-
dispatch({
|
|
9473
|
-
type: "setUi",
|
|
9474
|
-
ui: (ui) => __spreadValues(__spreadValues({}, ui), ui.rightSideBarVisible ? { leftSideBarVisible: false } : {})
|
|
9475
|
-
});
|
|
9476
|
-
}
|
|
9477
|
-
};
|
|
9478
|
-
window.addEventListener("resize", handleResize);
|
|
9479
|
-
return () => {
|
|
9480
|
-
window.removeEventListener("resize", handleResize);
|
|
9481
|
-
};
|
|
9482
|
-
}, []);
|
|
9483
|
-
const overrides = useAppStore((s) => s.overrides);
|
|
9484
|
-
const CustomPuck = (0, import_react60.useMemo)(
|
|
9485
|
-
() => overrides.puck || DefaultOverride,
|
|
9486
|
-
[overrides]
|
|
9487
|
-
);
|
|
9488
|
-
const [mounted, setMounted] = (0, import_react60.useState)(false);
|
|
9489
|
-
(0, import_react60.useEffect)(() => {
|
|
9490
|
-
setMounted(true);
|
|
9491
|
-
}, []);
|
|
9492
|
-
const ready = useAppStore((s) => s.status === "READY");
|
|
9493
|
-
useMonitorHotkeys();
|
|
9494
|
-
useDeleteHotkeys();
|
|
9495
|
-
(0, import_react60.useEffect)(() => {
|
|
9496
|
-
if (ready && iframe.enabled) {
|
|
9497
|
-
const frameDoc = getFrame();
|
|
9498
|
-
if (frameDoc) {
|
|
9499
|
-
return monitorHotkeys(frameDoc);
|
|
9500
|
-
}
|
|
9501
|
-
}
|
|
9502
|
-
}, [ready, iframe.enabled]);
|
|
9503
|
-
usePreviewModeHotkeys();
|
|
9504
|
-
const layoutOptions = {};
|
|
9505
|
-
if (leftWidth) {
|
|
9506
|
-
layoutOptions["--puck-user-left-side-bar-width"] = `${leftWidth}px`;
|
|
9507
|
-
}
|
|
9508
|
-
if (rightWidth) {
|
|
9509
|
-
layoutOptions["--puck-user-right-side-bar-width"] = `${rightWidth}px`;
|
|
9510
|
-
}
|
|
9511
|
-
return /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)("div", { className: `Puck ${getClassName31()}`, children: [
|
|
9512
|
-
/* @__PURE__ */ (0, import_jsx_runtime46.jsx)(DragDropContext, { disableAutoScroll: dnd == null ? void 0 : dnd.disableAutoScroll, children: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(CustomPuck, { children: children || /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(FrameProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
|
|
9513
|
-
"div",
|
|
9514
|
-
{
|
|
9515
|
-
className: getLayoutClassName({
|
|
9516
|
-
leftSideBarVisible,
|
|
9517
|
-
mounted,
|
|
9518
|
-
rightSideBarVisible
|
|
9519
|
-
}),
|
|
9520
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)(
|
|
9521
|
-
"div",
|
|
9522
|
-
{
|
|
9523
|
-
className: getLayoutClassName("inner"),
|
|
9524
|
-
style: layoutOptions,
|
|
9525
|
-
children: [
|
|
9526
|
-
/* @__PURE__ */ (0, import_jsx_runtime46.jsx)(Header, {}),
|
|
9527
|
-
/* @__PURE__ */ (0, import_jsx_runtime46.jsxs)(
|
|
9528
|
-
Sidebar,
|
|
9529
|
-
{
|
|
9530
|
-
position: "left",
|
|
9531
|
-
sidebarRef: leftSidebarRef,
|
|
9532
|
-
isVisible: leftSideBarVisible,
|
|
9533
|
-
onResize: setLeftWidth,
|
|
9534
|
-
onResizeEnd: handleLeftSidebarResizeEnd,
|
|
9535
|
-
children: [
|
|
9536
|
-
/* @__PURE__ */ (0, import_jsx_runtime46.jsx)(SidebarSection, { title: "Components", noBorderTop: true, children: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(Components, {}) }),
|
|
9537
|
-
/* @__PURE__ */ (0, import_jsx_runtime46.jsx)(SidebarSection, { title: "Outline", children: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(Outline, {}) })
|
|
9538
|
-
]
|
|
9539
|
-
}
|
|
9540
|
-
),
|
|
9541
|
-
/* @__PURE__ */ (0, import_jsx_runtime46.jsx)(Canvas, {}),
|
|
9542
|
-
/* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
|
|
9543
|
-
Sidebar,
|
|
9544
|
-
{
|
|
9545
|
-
position: "right",
|
|
9546
|
-
sidebarRef: rightSidebarRef,
|
|
9547
|
-
isVisible: rightSideBarVisible,
|
|
9548
|
-
onResize: setRightWidth,
|
|
9549
|
-
onResizeEnd: handleRightSidebarResizeEnd,
|
|
9550
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(FieldSideBar, {})
|
|
9551
|
-
}
|
|
9552
|
-
)
|
|
9553
|
-
]
|
|
9554
|
-
}
|
|
9555
|
-
)
|
|
9556
|
-
}
|
|
9557
|
-
) }) }) }),
|
|
9558
|
-
/* @__PURE__ */ (0, import_jsx_runtime46.jsx)("div", { id: "puck-portal-root", className: getClassName31("portal") })
|
|
9559
|
-
] });
|
|
9923
|
+
return /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(appStoreContext.Provider, { value: appStore, children: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(UsePuckStoreContext.Provider, { value: uPuckStore, children }) });
|
|
9560
9924
|
}
|
|
9561
9925
|
function Puck(props) {
|
|
9562
|
-
return /* @__PURE__ */ (0,
|
|
9926
|
+
return /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(PropsProvider, __spreadProps(__spreadValues({}, props), { children: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(PuckProvider, __spreadProps(__spreadValues({}, props), { children: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(Layout, { children: props.children }) })) }));
|
|
9563
9927
|
}
|
|
9564
9928
|
Puck.Components = Components;
|
|
9565
9929
|
Puck.Fields = Fields;
|
|
@@ -9792,8 +10156,11 @@ function resolveAllData(_0, _1) {
|
|
|
9792
10156
|
Label,
|
|
9793
10157
|
Puck,
|
|
9794
10158
|
Render,
|
|
10159
|
+
blocksPlugin,
|
|
9795
10160
|
createUsePuck,
|
|
10161
|
+
fieldsPlugin,
|
|
9796
10162
|
migrate,
|
|
10163
|
+
outlinePlugin,
|
|
9797
10164
|
overrideKeys,
|
|
9798
10165
|
registerOverlayPortal,
|
|
9799
10166
|
renderContext,
|
|
@@ -9901,6 +10268,14 @@ lucide-react/dist/esm/icons/ellipsis-vertical.js:
|
|
|
9901
10268
|
* See the LICENSE file in the root directory of this source tree.
|
|
9902
10269
|
*)
|
|
9903
10270
|
|
|
10271
|
+
lucide-react/dist/esm/icons/expand.js:
|
|
10272
|
+
(**
|
|
10273
|
+
* @license lucide-react v0.468.0 - ISC
|
|
10274
|
+
*
|
|
10275
|
+
* This source code is licensed under the ISC license.
|
|
10276
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
10277
|
+
*)
|
|
10278
|
+
|
|
9904
10279
|
lucide-react/dist/esm/icons/globe.js:
|
|
9905
10280
|
(**
|
|
9906
10281
|
* @license lucide-react v0.468.0 - ISC
|
|
@@ -9909,6 +10284,14 @@ lucide-react/dist/esm/icons/globe.js:
|
|
|
9909
10284
|
* See the LICENSE file in the root directory of this source tree.
|
|
9910
10285
|
*)
|
|
9911
10286
|
|
|
10287
|
+
lucide-react/dist/esm/icons/hammer.js:
|
|
10288
|
+
(**
|
|
10289
|
+
* @license lucide-react v0.468.0 - ISC
|
|
10290
|
+
*
|
|
10291
|
+
* This source code is licensed under the ISC license.
|
|
10292
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
10293
|
+
*)
|
|
10294
|
+
|
|
9912
10295
|
lucide-react/dist/esm/icons/hash.js:
|
|
9913
10296
|
(**
|
|
9914
10297
|
* @license lucide-react v0.468.0 - ISC
|
|
@@ -9965,6 +10348,22 @@ lucide-react/dist/esm/icons/lock.js:
|
|
|
9965
10348
|
* See the LICENSE file in the root directory of this source tree.
|
|
9966
10349
|
*)
|
|
9967
10350
|
|
|
10351
|
+
lucide-react/dist/esm/icons/maximize-2.js:
|
|
10352
|
+
(**
|
|
10353
|
+
* @license lucide-react v0.468.0 - ISC
|
|
10354
|
+
*
|
|
10355
|
+
* This source code is licensed under the ISC license.
|
|
10356
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
10357
|
+
*)
|
|
10358
|
+
|
|
10359
|
+
lucide-react/dist/esm/icons/minimize-2.js:
|
|
10360
|
+
(**
|
|
10361
|
+
* @license lucide-react v0.468.0 - ISC
|
|
10362
|
+
*
|
|
10363
|
+
* This source code is licensed under the ISC license.
|
|
10364
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
10365
|
+
*)
|
|
10366
|
+
|
|
9968
10367
|
lucide-react/dist/esm/icons/monitor.js:
|
|
9969
10368
|
(**
|
|
9970
10369
|
* @license lucide-react v0.468.0 - ISC
|
|
@@ -9997,6 +10396,14 @@ lucide-react/dist/esm/icons/plus.js:
|
|
|
9997
10396
|
* See the LICENSE file in the root directory of this source tree.
|
|
9998
10397
|
*)
|
|
9999
10398
|
|
|
10399
|
+
lucide-react/dist/esm/icons/rectangle-ellipsis.js:
|
|
10400
|
+
(**
|
|
10401
|
+
* @license lucide-react v0.468.0 - ISC
|
|
10402
|
+
*
|
|
10403
|
+
* This source code is licensed under the ISC license.
|
|
10404
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
10405
|
+
*)
|
|
10406
|
+
|
|
10000
10407
|
lucide-react/dist/esm/icons/redo-2.js:
|
|
10001
10408
|
(**
|
|
10002
10409
|
* @license lucide-react v0.468.0 - ISC
|
|
@@ -10037,6 +10444,14 @@ lucide-react/dist/esm/icons/tablet.js:
|
|
|
10037
10444
|
* See the LICENSE file in the root directory of this source tree.
|
|
10038
10445
|
*)
|
|
10039
10446
|
|
|
10447
|
+
lucide-react/dist/esm/icons/toy-brick.js:
|
|
10448
|
+
(**
|
|
10449
|
+
* @license lucide-react v0.468.0 - ISC
|
|
10450
|
+
*
|
|
10451
|
+
* This source code is licensed under the ISC license.
|
|
10452
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
10453
|
+
*)
|
|
10454
|
+
|
|
10040
10455
|
lucide-react/dist/esm/icons/trash.js:
|
|
10041
10456
|
(**
|
|
10042
10457
|
* @license lucide-react v0.468.0 - ISC
|
|
@@ -10061,6 +10476,14 @@ lucide-react/dist/esm/icons/undo-2.js:
|
|
|
10061
10476
|
* See the LICENSE file in the root directory of this source tree.
|
|
10062
10477
|
*)
|
|
10063
10478
|
|
|
10479
|
+
lucide-react/dist/esm/icons/x.js:
|
|
10480
|
+
(**
|
|
10481
|
+
* @license lucide-react v0.468.0 - ISC
|
|
10482
|
+
*
|
|
10483
|
+
* This source code is licensed under the ISC license.
|
|
10484
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
10485
|
+
*)
|
|
10486
|
+
|
|
10064
10487
|
lucide-react/dist/esm/icons/zoom-in.js:
|
|
10065
10488
|
(**
|
|
10066
10489
|
* @license lucide-react v0.468.0 - ISC
|