@measured/puck 0.20.0-canary.755737e8 → 0.20.0-canary.93d525c5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +24 -20
- package/dist/{chunk-IM42S4YL.mjs → chunk-H6KSTNLT.mjs} +49 -7
- package/dist/index.css +256 -364
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1199 -1254
- package/dist/index.mjs +924 -1021
- package/dist/rsc.d.mts +2 -2
- package/dist/rsc.d.ts +2 -2
- package/dist/rsc.js +49 -7
- package/dist/rsc.mjs +1 -1
- package/dist/{walk-tree-6PP75PCU.d.mts → walk-tree-BOSl1o0G.d.mts} +20 -32
- package/dist/{walk-tree-6PP75PCU.d.ts → walk-tree-BOSl1o0G.d.ts} +20 -32
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -25,7 +25,7 @@ import {
|
|
|
25
25
|
walkAppState,
|
|
26
26
|
walkField,
|
|
27
27
|
walkTree
|
|
28
|
-
} from "./chunk-
|
|
28
|
+
} from "./chunk-H6KSTNLT.mjs";
|
|
29
29
|
|
|
30
30
|
// ../../node_modules/classnames/index.js
|
|
31
31
|
var require_classnames = __commonJS({
|
|
@@ -375,20 +375,6 @@ var Globe = createLucideIcon("Globe", [
|
|
|
375
375
|
["path", { d: "M2 12h20", key: "9i4pu4" }]
|
|
376
376
|
]);
|
|
377
377
|
|
|
378
|
-
// ../../node_modules/lucide-react/dist/esm/icons/hammer.js
|
|
379
|
-
init_react_import();
|
|
380
|
-
var Hammer = createLucideIcon("Hammer", [
|
|
381
|
-
["path", { d: "m15 12-8.373 8.373a1 1 0 1 1-3-3L12 9", key: "eefl8a" }],
|
|
382
|
-
["path", { d: "m18 15 4-4", key: "16gjal" }],
|
|
383
|
-
[
|
|
384
|
-
"path",
|
|
385
|
-
{
|
|
386
|
-
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",
|
|
387
|
-
key: "b7pghm"
|
|
388
|
-
}
|
|
389
|
-
]
|
|
390
|
-
]);
|
|
391
|
-
|
|
392
378
|
// ../../node_modules/lucide-react/dist/esm/icons/hash.js
|
|
393
379
|
init_react_import();
|
|
394
380
|
var Hash = createLucideIcon("Hash", [
|
|
@@ -536,14 +522,6 @@ var Tablet = createLucideIcon("Tablet", [
|
|
|
536
522
|
["line", { x1: "12", x2: "12.01", y1: "18", y2: "18", key: "1dp563" }]
|
|
537
523
|
]);
|
|
538
524
|
|
|
539
|
-
// ../../node_modules/lucide-react/dist/esm/icons/toy-brick.js
|
|
540
|
-
init_react_import();
|
|
541
|
-
var ToyBrick = createLucideIcon("ToyBrick", [
|
|
542
|
-
["rect", { width: "18", height: "12", x: "3", y: "8", rx: "1", key: "158fvp" }],
|
|
543
|
-
["path", { d: "M10 8V5c0-.6-.4-1-1-1H6a1 1 0 0 0-1 1v3", key: "s0042v" }],
|
|
544
|
-
["path", { d: "M19 8V5c0-.6-.4-1-1-1h-3a1 1 0 0 0-1 1v3", key: "9wmeh2" }]
|
|
545
|
-
]);
|
|
546
|
-
|
|
547
525
|
// ../../node_modules/lucide-react/dist/esm/icons/trash.js
|
|
548
526
|
init_react_import();
|
|
549
527
|
var Trash = createLucideIcon("Trash", [
|
|
@@ -1316,11 +1294,18 @@ var monitorHotkeys = (doc) => {
|
|
|
1316
1294
|
}
|
|
1317
1295
|
}
|
|
1318
1296
|
};
|
|
1297
|
+
const onVisibilityChanged = (e) => {
|
|
1298
|
+
if (document.visibilityState === "hidden") {
|
|
1299
|
+
useHotkeyStore.getState().reset();
|
|
1300
|
+
}
|
|
1301
|
+
};
|
|
1319
1302
|
doc.addEventListener("keydown", onKeyDown);
|
|
1320
1303
|
doc.addEventListener("keyup", onKeyUp);
|
|
1304
|
+
doc.addEventListener("visibilitychange", onVisibilityChanged);
|
|
1321
1305
|
return () => {
|
|
1322
1306
|
doc.removeEventListener("keydown", onKeyDown);
|
|
1323
1307
|
doc.removeEventListener("keyup", onKeyUp);
|
|
1308
|
+
doc.removeEventListener("visibilitychange", onVisibilityChanged);
|
|
1324
1309
|
};
|
|
1325
1310
|
};
|
|
1326
1311
|
var useMonitorHotkeys = () => {
|
|
@@ -1415,7 +1400,7 @@ var createHistorySlice = (set, get) => {
|
|
|
1415
1400
|
const { dispatch, history } = get();
|
|
1416
1401
|
dispatch({
|
|
1417
1402
|
type: "set",
|
|
1418
|
-
state: ((_a =
|
|
1403
|
+
state: ((_a = histories[histories.length - 1]) == null ? void 0 : _a.state) || history.initialAppState
|
|
1419
1404
|
});
|
|
1420
1405
|
set({ history: __spreadProps(__spreadValues({}, history), { histories, index: histories.length - 1 }) });
|
|
1421
1406
|
},
|
|
@@ -3109,6 +3094,7 @@ var ExternalInput = ({
|
|
|
3109
3094
|
hasFilterFields && /* @__PURE__ */ jsx12("div", { className: getClassNameModal("searchActionIcon"), children: /* @__PURE__ */ jsx12(
|
|
3110
3095
|
IconButton,
|
|
3111
3096
|
{
|
|
3097
|
+
type: "button",
|
|
3112
3098
|
title: "Toggle filters",
|
|
3113
3099
|
onClick: (e) => {
|
|
3114
3100
|
e.preventDefault();
|
|
@@ -3456,9 +3442,8 @@ var ObjectField = ({
|
|
|
3456
3442
|
readOnly,
|
|
3457
3443
|
children: /* @__PURE__ */ jsx17("div", { className: getClassName14(), children: /* @__PURE__ */ jsx17("fieldset", { className: getClassName14("fieldset"), children: Object.keys(field.objectFields).map((subName) => {
|
|
3458
3444
|
const subField = field.objectFields[subName];
|
|
3459
|
-
const subPath = `${
|
|
3460
|
-
const
|
|
3461
|
-
const subReadOnly = readOnly ? readOnly : readOnlyFields[localSubPath];
|
|
3445
|
+
const subPath = `${localName}.${subName}`;
|
|
3446
|
+
const subReadOnly = readOnly ? readOnly : readOnlyFields[subPath];
|
|
3462
3447
|
const label2 = subField.label || subName;
|
|
3463
3448
|
return /* @__PURE__ */ jsx17(
|
|
3464
3449
|
NestedFieldProvider,
|
|
@@ -3557,7 +3542,7 @@ var FieldLabelInternal = ({
|
|
|
3557
3542
|
);
|
|
3558
3543
|
};
|
|
3559
3544
|
function AutoFieldInternal(props) {
|
|
3560
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
3545
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
3561
3546
|
const dispatch = useAppStore((s) => s.dispatch);
|
|
3562
3547
|
const overrides = useAppStore((s) => s.overrides);
|
|
3563
3548
|
const readOnly = useAppStore((s) => {
|
|
@@ -3629,21 +3614,23 @@ function AutoFieldInternal(props) {
|
|
|
3629
3614
|
if (field.type === "slot") {
|
|
3630
3615
|
return null;
|
|
3631
3616
|
}
|
|
3617
|
+
let children = null;
|
|
3618
|
+
let FieldComponent;
|
|
3632
3619
|
if (field.type === "custom") {
|
|
3633
3620
|
if (!field.render) {
|
|
3634
3621
|
return null;
|
|
3635
3622
|
}
|
|
3636
|
-
|
|
3637
|
-
|
|
3623
|
+
FieldComponent = field.render;
|
|
3624
|
+
} else {
|
|
3625
|
+
children = defaultFields[field.type](mergedProps);
|
|
3626
|
+
FieldComponent = render[field.type];
|
|
3638
3627
|
}
|
|
3639
|
-
const children = defaultFields[field.type](mergedProps);
|
|
3640
|
-
const Render2 = render[field.type];
|
|
3641
3628
|
return /* @__PURE__ */ jsx18(
|
|
3642
3629
|
NestedFieldContext.Provider,
|
|
3643
3630
|
{
|
|
3644
3631
|
value: {
|
|
3645
3632
|
readOnlyFields: nestedFieldContext.readOnlyFields || readOnly || {},
|
|
3646
|
-
localName: nestedFieldContext.localName
|
|
3633
|
+
localName: (_i = nestedFieldContext.localName) != null ? _i : mergedProps.name
|
|
3647
3634
|
},
|
|
3648
3635
|
children: /* @__PURE__ */ jsx18(
|
|
3649
3636
|
"div",
|
|
@@ -3654,7 +3641,7 @@ function AutoFieldInternal(props) {
|
|
|
3654
3641
|
onClick: (e) => {
|
|
3655
3642
|
e.stopPropagation();
|
|
3656
3643
|
},
|
|
3657
|
-
children: /* @__PURE__ */ jsx18(
|
|
3644
|
+
children: /* @__PURE__ */ jsx18(FieldComponent, __spreadProps(__spreadValues({}, mergedProps), { children }))
|
|
3658
3645
|
}
|
|
3659
3646
|
)
|
|
3660
3647
|
}
|
|
@@ -5027,7 +5014,7 @@ var DropZoneRender = forwardRef3(
|
|
|
5027
5014
|
const ctx = useContext7(dropZoneContext);
|
|
5028
5015
|
const { areaId = "root" } = ctx || {};
|
|
5029
5016
|
const { config, data, metadata } = useContext7(renderContext);
|
|
5030
|
-
let zoneCompound =
|
|
5017
|
+
let zoneCompound = `${areaId}:${zone}`;
|
|
5031
5018
|
let content = (data == null ? void 0 : data.content) || [];
|
|
5032
5019
|
useEffect16(() => {
|
|
5033
5020
|
if (!content) {
|
|
@@ -5044,8 +5031,7 @@ var DropZoneRender = forwardRef3(
|
|
|
5044
5031
|
if (!data || !config) {
|
|
5045
5032
|
return null;
|
|
5046
5033
|
}
|
|
5047
|
-
if (
|
|
5048
|
-
zoneCompound = `${areaId}:${zone}`;
|
|
5034
|
+
if (zoneCompound !== rootDroppableId) {
|
|
5049
5035
|
content = setupZone(data, zoneCompound).zones[zoneCompound];
|
|
5050
5036
|
}
|
|
5051
5037
|
return /* @__PURE__ */ jsx23("div", { className, style, ref, children: content.map((item) => {
|
|
@@ -5300,6 +5286,7 @@ var findDeepestCandidate = (position, manager) => {
|
|
|
5300
5286
|
});
|
|
5301
5287
|
filteredCandidates.reverse();
|
|
5302
5288
|
const primaryCandidate = filteredCandidates[0];
|
|
5289
|
+
if (!primaryCandidate) return { zone: null, area: null };
|
|
5303
5290
|
const primaryCandidateData = primaryCandidate.data;
|
|
5304
5291
|
const primaryCandidateIsComponent = "containsActiveZone" in primaryCandidateData;
|
|
5305
5292
|
const zone = getZoneId(primaryCandidate);
|
|
@@ -5946,28 +5933,125 @@ import {
|
|
|
5946
5933
|
createContext as createContext7,
|
|
5947
5934
|
useCallback as useCallback18,
|
|
5948
5935
|
useContext as useContext12,
|
|
5949
|
-
useEffect as
|
|
5950
|
-
useMemo as
|
|
5936
|
+
useEffect as useEffect25,
|
|
5937
|
+
useMemo as useMemo21,
|
|
5951
5938
|
useRef as useRef8,
|
|
5952
|
-
useState as
|
|
5939
|
+
useState as useState23
|
|
5953
5940
|
} from "react";
|
|
5954
5941
|
|
|
5942
|
+
// components/SidebarSection/index.tsx
|
|
5943
|
+
init_react_import();
|
|
5944
|
+
|
|
5945
|
+
// css-module:/home/runner/work/puck/puck/packages/core/components/SidebarSection/styles.module.css#css-module
|
|
5946
|
+
init_react_import();
|
|
5947
|
+
var styles_module_default13 = { "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" };
|
|
5948
|
+
|
|
5949
|
+
// lib/use-breadcrumbs.ts
|
|
5950
|
+
init_react_import();
|
|
5951
|
+
import { useMemo as useMemo12 } from "react";
|
|
5952
|
+
var useBreadcrumbs = (renderCount) => {
|
|
5953
|
+
const selectedId = useAppStore((s) => {
|
|
5954
|
+
var _a;
|
|
5955
|
+
return (_a = s.selectedItem) == null ? void 0 : _a.props.id;
|
|
5956
|
+
});
|
|
5957
|
+
const config = useAppStore((s) => s.config);
|
|
5958
|
+
const path = useAppStore((s) => {
|
|
5959
|
+
var _a;
|
|
5960
|
+
return (_a = s.state.indexes.nodes[selectedId]) == null ? void 0 : _a.path;
|
|
5961
|
+
});
|
|
5962
|
+
const appStore = useAppStoreApi();
|
|
5963
|
+
return useMemo12(() => {
|
|
5964
|
+
const breadcrumbs = (path == null ? void 0 : path.map((zoneCompound) => {
|
|
5965
|
+
var _a, _b, _c;
|
|
5966
|
+
const [componentId] = zoneCompound.split(":");
|
|
5967
|
+
if (componentId === "root") {
|
|
5968
|
+
return {
|
|
5969
|
+
label: "Page",
|
|
5970
|
+
selector: null
|
|
5971
|
+
};
|
|
5972
|
+
}
|
|
5973
|
+
const node = appStore.getState().state.indexes.nodes[componentId];
|
|
5974
|
+
const parentId = node.path[node.path.length - 1];
|
|
5975
|
+
const contentIds = ((_a = appStore.getState().state.indexes.zones[parentId]) == null ? void 0 : _a.contentIds) || [];
|
|
5976
|
+
const index = contentIds.indexOf(componentId);
|
|
5977
|
+
const label = node ? (_c = (_b = config.components[node.data.type]) == null ? void 0 : _b.label) != null ? _c : node.data.type : "Component";
|
|
5978
|
+
return {
|
|
5979
|
+
label,
|
|
5980
|
+
selector: node ? {
|
|
5981
|
+
index,
|
|
5982
|
+
zone: node.path[node.path.length - 1]
|
|
5983
|
+
} : null
|
|
5984
|
+
};
|
|
5985
|
+
})) || [];
|
|
5986
|
+
if (renderCount) {
|
|
5987
|
+
return breadcrumbs.slice(breadcrumbs.length - renderCount);
|
|
5988
|
+
}
|
|
5989
|
+
return breadcrumbs;
|
|
5990
|
+
}, [path, renderCount]);
|
|
5991
|
+
};
|
|
5992
|
+
|
|
5993
|
+
// components/SidebarSection/index.tsx
|
|
5994
|
+
import { jsx as jsx26, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
5995
|
+
var getClassName19 = get_class_name_factory_default("SidebarSection", styles_module_default13);
|
|
5996
|
+
var SidebarSection = ({
|
|
5997
|
+
children,
|
|
5998
|
+
title,
|
|
5999
|
+
background,
|
|
6000
|
+
showBreadcrumbs,
|
|
6001
|
+
noBorderTop,
|
|
6002
|
+
noPadding,
|
|
6003
|
+
isLoading
|
|
6004
|
+
}) => {
|
|
6005
|
+
const setUi = useAppStore((s) => s.setUi);
|
|
6006
|
+
const breadcrumbs = useBreadcrumbs(1);
|
|
6007
|
+
return /* @__PURE__ */ jsxs12(
|
|
6008
|
+
"div",
|
|
6009
|
+
{
|
|
6010
|
+
className: getClassName19({ noBorderTop, noPadding }),
|
|
6011
|
+
style: { background },
|
|
6012
|
+
children: [
|
|
6013
|
+
/* @__PURE__ */ jsx26("div", { className: getClassName19("title"), children: /* @__PURE__ */ jsxs12("div", { className: getClassName19("breadcrumbs"), children: [
|
|
6014
|
+
showBreadcrumbs ? breadcrumbs.map((breadcrumb, i) => /* @__PURE__ */ jsxs12("div", { className: getClassName19("breadcrumb"), children: [
|
|
6015
|
+
/* @__PURE__ */ jsx26(
|
|
6016
|
+
"button",
|
|
6017
|
+
{
|
|
6018
|
+
type: "button",
|
|
6019
|
+
className: getClassName19("breadcrumbLabel"),
|
|
6020
|
+
onClick: () => setUi({ itemSelector: breadcrumb.selector }),
|
|
6021
|
+
children: breadcrumb.label
|
|
6022
|
+
}
|
|
6023
|
+
),
|
|
6024
|
+
/* @__PURE__ */ jsx26(ChevronRight, { size: 16 })
|
|
6025
|
+
] }, i)) : null,
|
|
6026
|
+
/* @__PURE__ */ jsx26("div", { className: getClassName19("heading"), children: /* @__PURE__ */ jsx26(Heading, { rank: "2", size: "xs", children: title }) })
|
|
6027
|
+
] }) }),
|
|
6028
|
+
/* @__PURE__ */ jsx26("div", { className: getClassName19("content"), children }),
|
|
6029
|
+
isLoading && /* @__PURE__ */ jsx26("div", { className: getClassName19("loadingOverlay"), children: /* @__PURE__ */ jsx26(Loader, { size: 32 }) })
|
|
6030
|
+
]
|
|
6031
|
+
}
|
|
6032
|
+
);
|
|
6033
|
+
};
|
|
6034
|
+
|
|
6035
|
+
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/styles.module.css#css-module
|
|
6036
|
+
init_react_import();
|
|
6037
|
+
var styles_module_default14 = { "Puck": "_Puck_dnlfp_19", "Puck-portal": "_Puck-portal_dnlfp_31", "PuckLayout-inner": "_PuckLayout-inner_dnlfp_38", "PuckLayout--mounted": "_PuckLayout--mounted_dnlfp_50", "PuckLayout--leftSideBarVisible": "_PuckLayout--leftSideBarVisible_dnlfp_54", "PuckLayout--rightSideBarVisible": "_PuckLayout--rightSideBarVisible_dnlfp_60", "PuckLayout-mounted": "_PuckLayout-mounted_dnlfp_74", "PuckLayout": "_PuckLayout_dnlfp_38", "PuckLayout-leftSideBar": "_PuckLayout-leftSideBar_dnlfp_115", "PuckLayout-rightSideBar": "_PuckLayout-rightSideBar_dnlfp_124" };
|
|
6038
|
+
|
|
5955
6039
|
// components/Puck/components/Fields/index.tsx
|
|
5956
6040
|
init_react_import();
|
|
5957
6041
|
|
|
5958
6042
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Fields/styles.module.css#css-module
|
|
5959
6043
|
init_react_import();
|
|
5960
|
-
var
|
|
6044
|
+
var styles_module_default15 = { "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" };
|
|
5961
6045
|
|
|
5962
6046
|
// components/Puck/components/Fields/index.tsx
|
|
5963
|
-
import { memo as memo2, useCallback as useCallback12, useMemo as
|
|
6047
|
+
import { memo as memo2, useCallback as useCallback12, useMemo as useMemo13 } from "react";
|
|
5964
6048
|
import { useShallow as useShallow5 } from "zustand/react/shallow";
|
|
5965
|
-
import { Fragment as Fragment7, jsx as
|
|
5966
|
-
var
|
|
6049
|
+
import { Fragment as Fragment7, jsx as jsx27, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
6050
|
+
var getClassName20 = get_class_name_factory_default("PuckFields", styles_module_default15);
|
|
5967
6051
|
var DefaultFields = ({
|
|
5968
6052
|
children
|
|
5969
6053
|
}) => {
|
|
5970
|
-
return /* @__PURE__ */
|
|
6054
|
+
return /* @__PURE__ */ jsx27(Fragment7, { children });
|
|
5971
6055
|
};
|
|
5972
6056
|
var createOnChange = (fieldName, appStore) => (value, updatedUi) => __async(void 0, null, function* () {
|
|
5973
6057
|
let currentProps;
|
|
@@ -6039,7 +6123,7 @@ var FieldsChild = ({ fieldName }) => {
|
|
|
6039
6123
|
const { visible = true } = field != null ? field : {};
|
|
6040
6124
|
if (!field || !id || !visible) return null;
|
|
6041
6125
|
if (field.type === "slot") return null;
|
|
6042
|
-
return /* @__PURE__ */
|
|
6126
|
+
return /* @__PURE__ */ jsx27("div", { className: getClassName20("field"), children: /* @__PURE__ */ jsx27(
|
|
6043
6127
|
AutoFieldPrivate,
|
|
6044
6128
|
{
|
|
6045
6129
|
field,
|
|
@@ -6076,17 +6160,17 @@ var FieldsInternal = ({ wrapFields = true }) => {
|
|
|
6076
6160
|
})
|
|
6077
6161
|
);
|
|
6078
6162
|
const isLoading = fieldsLoading || componentResolving;
|
|
6079
|
-
const Wrapper =
|
|
6080
|
-
return /* @__PURE__ */
|
|
6163
|
+
const Wrapper = useMemo13(() => overrides.fields || DefaultFields, [overrides]);
|
|
6164
|
+
return /* @__PURE__ */ jsxs13(
|
|
6081
6165
|
"form",
|
|
6082
6166
|
{
|
|
6083
|
-
className:
|
|
6167
|
+
className: getClassName20({ wrapFields }),
|
|
6084
6168
|
onSubmit: (e) => {
|
|
6085
6169
|
e.preventDefault();
|
|
6086
6170
|
},
|
|
6087
6171
|
children: [
|
|
6088
|
-
/* @__PURE__ */
|
|
6089
|
-
isLoading && /* @__PURE__ */
|
|
6172
|
+
/* @__PURE__ */ jsx27(Wrapper, { isLoading, itemSelector, children: fieldNames.map((fieldName) => /* @__PURE__ */ jsx27(FieldsChildMemo, { fieldName }, fieldName)) }),
|
|
6173
|
+
isLoading && /* @__PURE__ */ jsx27("div", { className: getClassName20("loadingOverlay"), children: /* @__PURE__ */ jsx27("div", { className: getClassName20("loadingOverlayInner"), children: /* @__PURE__ */ jsx27(Loader, { size: 16 }) }) })
|
|
6090
6174
|
]
|
|
6091
6175
|
}
|
|
6092
6176
|
);
|
|
@@ -6105,11 +6189,11 @@ init_react_import();
|
|
|
6105
6189
|
|
|
6106
6190
|
// css-module:/home/runner/work/puck/puck/packages/core/components/ComponentList/styles.module.css#css-module
|
|
6107
6191
|
init_react_import();
|
|
6108
|
-
var
|
|
6192
|
+
var styles_module_default16 = { "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" };
|
|
6109
6193
|
|
|
6110
6194
|
// components/ComponentList/index.tsx
|
|
6111
|
-
import { jsx as
|
|
6112
|
-
var
|
|
6195
|
+
import { jsx as jsx28, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
6196
|
+
var getClassName21 = get_class_name_factory_default("ComponentList", styles_module_default16);
|
|
6113
6197
|
var ComponentListItem = ({
|
|
6114
6198
|
name,
|
|
6115
6199
|
label
|
|
@@ -6120,7 +6204,7 @@ var ComponentListItem = ({
|
|
|
6120
6204
|
type: name
|
|
6121
6205
|
}).insert
|
|
6122
6206
|
);
|
|
6123
|
-
return /* @__PURE__ */
|
|
6207
|
+
return /* @__PURE__ */ jsx28(Drawer.Item, { label, name, isDragDisabled: !canInsert, children: overrides.componentItem });
|
|
6124
6208
|
};
|
|
6125
6209
|
var ComponentList = ({
|
|
6126
6210
|
children,
|
|
@@ -6131,12 +6215,12 @@ var ComponentList = ({
|
|
|
6131
6215
|
const setUi = useAppStore((s) => s.setUi);
|
|
6132
6216
|
const componentList = useAppStore((s) => s.state.ui.componentList);
|
|
6133
6217
|
const { expanded = true } = componentList[id] || {};
|
|
6134
|
-
return /* @__PURE__ */
|
|
6135
|
-
title && /* @__PURE__ */
|
|
6218
|
+
return /* @__PURE__ */ jsxs14("div", { className: getClassName21({ isExpanded: expanded }), children: [
|
|
6219
|
+
title && /* @__PURE__ */ jsxs14(
|
|
6136
6220
|
"button",
|
|
6137
6221
|
{
|
|
6138
6222
|
type: "button",
|
|
6139
|
-
className:
|
|
6223
|
+
className: getClassName21("title"),
|
|
6140
6224
|
onClick: () => setUi({
|
|
6141
6225
|
componentList: __spreadProps(__spreadValues({}, componentList), {
|
|
6142
6226
|
[id]: __spreadProps(__spreadValues({}, componentList[id]), {
|
|
@@ -6146,14 +6230,14 @@ var ComponentList = ({
|
|
|
6146
6230
|
}),
|
|
6147
6231
|
title: expanded ? `Collapse${title ? ` ${title}` : ""}` : `Expand${title ? ` ${title}` : ""}`,
|
|
6148
6232
|
children: [
|
|
6149
|
-
/* @__PURE__ */
|
|
6150
|
-
/* @__PURE__ */
|
|
6233
|
+
/* @__PURE__ */ jsx28("div", { children: title }),
|
|
6234
|
+
/* @__PURE__ */ jsx28("div", { className: getClassName21("titleIcon"), children: expanded ? /* @__PURE__ */ jsx28(ChevronUp, { size: 12 }) : /* @__PURE__ */ jsx28(ChevronDown, { size: 12 }) })
|
|
6151
6235
|
]
|
|
6152
6236
|
}
|
|
6153
6237
|
),
|
|
6154
|
-
/* @__PURE__ */
|
|
6238
|
+
/* @__PURE__ */ jsx28("div", { className: getClassName21("content"), children: /* @__PURE__ */ jsx28(Drawer, { children: children || Object.keys(config.components).map((componentKey) => {
|
|
6155
6239
|
var _a;
|
|
6156
|
-
return /* @__PURE__ */
|
|
6240
|
+
return /* @__PURE__ */ jsx28(
|
|
6157
6241
|
ComponentListItem,
|
|
6158
6242
|
{
|
|
6159
6243
|
label: (_a = config.components[componentKey]["label"]) != null ? _a : componentKey,
|
|
@@ -6167,7 +6251,7 @@ var ComponentList = ({
|
|
|
6167
6251
|
ComponentList.Item = ComponentListItem;
|
|
6168
6252
|
|
|
6169
6253
|
// lib/use-component-list.tsx
|
|
6170
|
-
import { jsx as
|
|
6254
|
+
import { jsx as jsx29 } from "react/jsx-runtime";
|
|
6171
6255
|
var useComponentList = () => {
|
|
6172
6256
|
const [componentList, setComponentList] = useState16();
|
|
6173
6257
|
const config = useAppStore((s) => s.config);
|
|
@@ -6182,7 +6266,7 @@ var useComponentList = () => {
|
|
|
6182
6266
|
if (category.visible === false || !category.components) {
|
|
6183
6267
|
return null;
|
|
6184
6268
|
}
|
|
6185
|
-
return /* @__PURE__ */
|
|
6269
|
+
return /* @__PURE__ */ jsx29(
|
|
6186
6270
|
ComponentList,
|
|
6187
6271
|
{
|
|
6188
6272
|
id: categoryKey,
|
|
@@ -6191,7 +6275,7 @@ var useComponentList = () => {
|
|
|
6191
6275
|
var _a2;
|
|
6192
6276
|
matchedComponents.push(componentName);
|
|
6193
6277
|
const componentConf = config.components[componentName] || {};
|
|
6194
|
-
return /* @__PURE__ */
|
|
6278
|
+
return /* @__PURE__ */ jsx29(
|
|
6195
6279
|
ComponentList.Item,
|
|
6196
6280
|
{
|
|
6197
6281
|
label: (_a2 = componentConf["label"]) != null ? _a2 : componentName,
|
|
@@ -6211,7 +6295,7 @@ var useComponentList = () => {
|
|
|
6211
6295
|
);
|
|
6212
6296
|
if (remainingComponents.length > 0 && !((_a = uiComponentList.other) == null ? void 0 : _a.components) && ((_b = uiComponentList.other) == null ? void 0 : _b.visible) !== false) {
|
|
6213
6297
|
_componentList.push(
|
|
6214
|
-
/* @__PURE__ */
|
|
6298
|
+
/* @__PURE__ */ jsx29(
|
|
6215
6299
|
ComponentList,
|
|
6216
6300
|
{
|
|
6217
6301
|
id: "other",
|
|
@@ -6219,7 +6303,7 @@ var useComponentList = () => {
|
|
|
6219
6303
|
children: remainingComponents.map((componentName, i) => {
|
|
6220
6304
|
var _a2;
|
|
6221
6305
|
const componentConf = config.components[componentName] || {};
|
|
6222
|
-
return /* @__PURE__ */
|
|
6306
|
+
return /* @__PURE__ */ jsx29(
|
|
6223
6307
|
ComponentList.Item,
|
|
6224
6308
|
{
|
|
6225
6309
|
name: componentName,
|
|
@@ -6241,18 +6325,18 @@ var useComponentList = () => {
|
|
|
6241
6325
|
};
|
|
6242
6326
|
|
|
6243
6327
|
// components/Puck/components/Components/index.tsx
|
|
6244
|
-
import { useMemo as
|
|
6245
|
-
import { jsx as
|
|
6328
|
+
import { useMemo as useMemo14 } from "react";
|
|
6329
|
+
import { jsx as jsx30 } from "react/jsx-runtime";
|
|
6246
6330
|
var Components = () => {
|
|
6247
6331
|
const overrides = useAppStore((s) => s.overrides);
|
|
6248
6332
|
const componentList = useComponentList();
|
|
6249
|
-
const Wrapper =
|
|
6250
|
-
return /* @__PURE__ */
|
|
6333
|
+
const Wrapper = useMemo14(() => overrides.components || "div", [overrides]);
|
|
6334
|
+
return /* @__PURE__ */ jsx30(Wrapper, { children: componentList ? componentList : /* @__PURE__ */ jsx30(ComponentList, { id: "all" }) });
|
|
6251
6335
|
};
|
|
6252
6336
|
|
|
6253
6337
|
// components/Puck/components/Preview/index.tsx
|
|
6254
6338
|
init_react_import();
|
|
6255
|
-
import { useCallback as useCallback13, useEffect as useEffect20, useRef as useRef6, useMemo as
|
|
6339
|
+
import { useCallback as useCallback13, useEffect as useEffect20, useRef as useRef6, useMemo as useMemo15 } from "react";
|
|
6256
6340
|
|
|
6257
6341
|
// components/AutoFrame/index.tsx
|
|
6258
6342
|
init_react_import();
|
|
@@ -6264,12 +6348,19 @@ import {
|
|
|
6264
6348
|
} from "react";
|
|
6265
6349
|
import hash from "object-hash";
|
|
6266
6350
|
import { createPortal as createPortal3 } from "react-dom";
|
|
6267
|
-
import { Fragment as Fragment8, jsx as
|
|
6351
|
+
import { Fragment as Fragment8, jsx as jsx31 } from "react/jsx-runtime";
|
|
6268
6352
|
var styleSelector = 'style, link[rel="stylesheet"]';
|
|
6269
6353
|
var collectStyles = (doc) => {
|
|
6270
6354
|
const collected = [];
|
|
6271
6355
|
doc.querySelectorAll(styleSelector).forEach((style) => {
|
|
6272
|
-
|
|
6356
|
+
if (style.tagName === "STYLE") {
|
|
6357
|
+
const hasContent = !!style.innerHTML.trim();
|
|
6358
|
+
if (hasContent) {
|
|
6359
|
+
collected.push(style);
|
|
6360
|
+
}
|
|
6361
|
+
} else {
|
|
6362
|
+
collected.push(style);
|
|
6363
|
+
}
|
|
6273
6364
|
});
|
|
6274
6365
|
return collected;
|
|
6275
6366
|
};
|
|
@@ -6282,7 +6373,7 @@ var getStyleSheet = (el) => {
|
|
|
6282
6373
|
var getStyles = (styleSheet) => {
|
|
6283
6374
|
if (styleSheet) {
|
|
6284
6375
|
try {
|
|
6285
|
-
return [...styleSheet.cssRules].map((rule) => rule.cssText).join("");
|
|
6376
|
+
return [...Array.from(styleSheet.cssRules)].map((rule) => rule.cssText).join("");
|
|
6286
6377
|
} catch (e) {
|
|
6287
6378
|
console.warn(
|
|
6288
6379
|
"Access to stylesheet %s is denied. Ignoring\u2026",
|
|
@@ -6464,7 +6555,7 @@ var CopyHostStyles = ({
|
|
|
6464
6555
|
observer.disconnect();
|
|
6465
6556
|
};
|
|
6466
6557
|
}, []);
|
|
6467
|
-
return /* @__PURE__ */
|
|
6558
|
+
return /* @__PURE__ */ jsx31(Fragment8, { children });
|
|
6468
6559
|
};
|
|
6469
6560
|
var autoFrameContext = createContext5({});
|
|
6470
6561
|
var useFrame = () => useContext9(autoFrameContext);
|
|
@@ -6511,7 +6602,7 @@ function AutoFrame(_a) {
|
|
|
6511
6602
|
}
|
|
6512
6603
|
}
|
|
6513
6604
|
}, [frameRef, loaded, stylesLoaded]);
|
|
6514
|
-
return /* @__PURE__ */
|
|
6605
|
+
return /* @__PURE__ */ jsx31(
|
|
6515
6606
|
"iframe",
|
|
6516
6607
|
__spreadProps(__spreadValues({}, props), {
|
|
6517
6608
|
className,
|
|
@@ -6521,7 +6612,7 @@ function AutoFrame(_a) {
|
|
|
6521
6612
|
onLoad: () => {
|
|
6522
6613
|
setLoaded(true);
|
|
6523
6614
|
},
|
|
6524
|
-
children: /* @__PURE__ */
|
|
6615
|
+
children: /* @__PURE__ */ jsx31(autoFrameContext.Provider, { value: ctx, children: loaded && mountTarget && /* @__PURE__ */ jsx31(
|
|
6525
6616
|
CopyHostStyles,
|
|
6526
6617
|
{
|
|
6527
6618
|
debug,
|
|
@@ -6537,11 +6628,11 @@ var AutoFrame_default = AutoFrame;
|
|
|
6537
6628
|
|
|
6538
6629
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Preview/styles.module.css#css-module
|
|
6539
6630
|
init_react_import();
|
|
6540
|
-
var
|
|
6631
|
+
var styles_module_default17 = { "PuckPreview": "_PuckPreview_z2rgu_1", "PuckPreview-frame": "_PuckPreview-frame_z2rgu_6" };
|
|
6541
6632
|
|
|
6542
6633
|
// components/Puck/components/Preview/index.tsx
|
|
6543
|
-
import { Fragment as Fragment9, jsx as
|
|
6544
|
-
var
|
|
6634
|
+
import { Fragment as Fragment9, jsx as jsx32 } from "react/jsx-runtime";
|
|
6635
|
+
var getClassName22 = get_class_name_factory_default("PuckPreview", styles_module_default17);
|
|
6545
6636
|
var useBubbleIframeEvents = (ref) => {
|
|
6546
6637
|
const status = useAppStore((s) => s.status);
|
|
6547
6638
|
useEffect20(() => {
|
|
@@ -6603,15 +6694,15 @@ var Preview2 = ({ id = "puck-preview" }) => {
|
|
|
6603
6694
|
);
|
|
6604
6695
|
return ((_a = config.root) == null ? void 0 : _a.render) ? (_b = config.root) == null ? void 0 : _b.render(__spreadValues({
|
|
6605
6696
|
id: "puck-root"
|
|
6606
|
-
}, propsWithSlots)) : /* @__PURE__ */
|
|
6697
|
+
}, propsWithSlots)) : /* @__PURE__ */ jsx32(Fragment9, { children: propsWithSlots.children });
|
|
6607
6698
|
},
|
|
6608
6699
|
[config]
|
|
6609
6700
|
);
|
|
6610
|
-
const Frame =
|
|
6701
|
+
const Frame = useMemo15(() => overrides.iframe, [overrides]);
|
|
6611
6702
|
const rootProps = root.props || root;
|
|
6612
6703
|
const ref = useRef6(null);
|
|
6613
6704
|
useBubbleIframeEvents(ref);
|
|
6614
|
-
const inner = !renderData ? /* @__PURE__ */
|
|
6705
|
+
const inner = !renderData ? /* @__PURE__ */ jsx32(
|
|
6615
6706
|
Page,
|
|
6616
6707
|
__spreadProps(__spreadValues({}, rootProps), {
|
|
6617
6708
|
puck: {
|
|
@@ -6621,28 +6712,28 @@ var Preview2 = ({ id = "puck-preview" }) => {
|
|
|
6621
6712
|
metadata
|
|
6622
6713
|
},
|
|
6623
6714
|
editMode: true,
|
|
6624
|
-
children: /* @__PURE__ */
|
|
6715
|
+
children: /* @__PURE__ */ jsx32(DropZonePure, { zone: rootDroppableId })
|
|
6625
6716
|
})
|
|
6626
|
-
) : /* @__PURE__ */
|
|
6717
|
+
) : /* @__PURE__ */ jsx32(Render, { data: renderData, config });
|
|
6627
6718
|
useEffect20(() => {
|
|
6628
6719
|
if (!iframe.enabled) {
|
|
6629
6720
|
setStatus("READY");
|
|
6630
6721
|
}
|
|
6631
6722
|
}, [iframe.enabled]);
|
|
6632
|
-
return /* @__PURE__ */
|
|
6723
|
+
return /* @__PURE__ */ jsx32(
|
|
6633
6724
|
"div",
|
|
6634
6725
|
{
|
|
6635
|
-
className:
|
|
6726
|
+
className: getClassName22(),
|
|
6636
6727
|
id,
|
|
6637
6728
|
"data-puck-preview": true,
|
|
6638
6729
|
onClick: () => {
|
|
6639
6730
|
dispatch({ type: "setUi", ui: { itemSelector: null } });
|
|
6640
6731
|
},
|
|
6641
|
-
children: iframe.enabled ? /* @__PURE__ */
|
|
6732
|
+
children: iframe.enabled ? /* @__PURE__ */ jsx32(
|
|
6642
6733
|
AutoFrame_default,
|
|
6643
6734
|
{
|
|
6644
6735
|
id: "preview-frame",
|
|
6645
|
-
className:
|
|
6736
|
+
className: getClassName22("frame"),
|
|
6646
6737
|
"data-rfd-iframe": true,
|
|
6647
6738
|
onReady: () => {
|
|
6648
6739
|
setStatus("READY");
|
|
@@ -6651,18 +6742,18 @@ var Preview2 = ({ id = "puck-preview" }) => {
|
|
|
6651
6742
|
setStatus("MOUNTED");
|
|
6652
6743
|
},
|
|
6653
6744
|
frameRef: ref,
|
|
6654
|
-
children: /* @__PURE__ */
|
|
6745
|
+
children: /* @__PURE__ */ jsx32(autoFrameContext.Consumer, { children: ({ document: document2 }) => {
|
|
6655
6746
|
if (Frame) {
|
|
6656
|
-
return /* @__PURE__ */
|
|
6747
|
+
return /* @__PURE__ */ jsx32(Frame, { document: document2, children: inner });
|
|
6657
6748
|
}
|
|
6658
6749
|
return inner;
|
|
6659
6750
|
} })
|
|
6660
6751
|
}
|
|
6661
|
-
) : /* @__PURE__ */
|
|
6752
|
+
) : /* @__PURE__ */ jsx32(
|
|
6662
6753
|
"div",
|
|
6663
6754
|
{
|
|
6664
6755
|
id: "preview-frame",
|
|
6665
|
-
className:
|
|
6756
|
+
className: getClassName22("frame"),
|
|
6666
6757
|
ref,
|
|
6667
6758
|
"data-puck-entry": true,
|
|
6668
6759
|
children: inner
|
|
@@ -6680,7 +6771,7 @@ init_react_import();
|
|
|
6680
6771
|
|
|
6681
6772
|
// css-module:/home/runner/work/puck/puck/packages/core/components/LayerTree/styles.module.css#css-module
|
|
6682
6773
|
init_react_import();
|
|
6683
|
-
var
|
|
6774
|
+
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" };
|
|
6684
6775
|
|
|
6685
6776
|
// lib/scroll-into-view.ts
|
|
6686
6777
|
init_react_import();
|
|
@@ -6717,16 +6808,15 @@ var onScrollEnd = (frame, cb) => {
|
|
|
6717
6808
|
|
|
6718
6809
|
// components/LayerTree/index.tsx
|
|
6719
6810
|
import { useShallow as useShallow6 } from "zustand/react/shallow";
|
|
6720
|
-
import { Fragment as Fragment10, jsx as
|
|
6721
|
-
var
|
|
6722
|
-
var getClassNameLayer = get_class_name_factory_default("Layer",
|
|
6811
|
+
import { Fragment as Fragment10, jsx as jsx33, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
6812
|
+
var getClassName23 = get_class_name_factory_default("LayerTree", styles_module_default18);
|
|
6813
|
+
var getClassNameLayer = get_class_name_factory_default("Layer", styles_module_default18);
|
|
6723
6814
|
var Layer = ({
|
|
6724
6815
|
index,
|
|
6725
6816
|
itemId,
|
|
6726
6817
|
zoneCompound
|
|
6727
6818
|
}) => {
|
|
6728
6819
|
var _a;
|
|
6729
|
-
const ctx = useContext10(dropZoneContext);
|
|
6730
6820
|
const config = useAppStore((s) => s.config);
|
|
6731
6821
|
const itemSelector = useAppStore((s) => s.state.ui.itemSelector);
|
|
6732
6822
|
const dispatch = useAppStore((s) => s.dispatch);
|
|
@@ -6765,7 +6855,7 @@ var Layer = ({
|
|
|
6765
6855
|
});
|
|
6766
6856
|
const componentConfig = config.components[nodeData.data.type];
|
|
6767
6857
|
const label = (_a = componentConfig == null ? void 0 : componentConfig["label"]) != null ? _a : nodeData.data.type.toString();
|
|
6768
|
-
return /* @__PURE__ */
|
|
6858
|
+
return /* @__PURE__ */ jsxs15(
|
|
6769
6859
|
"li",
|
|
6770
6860
|
{
|
|
6771
6861
|
className: getClassNameLayer({
|
|
@@ -6775,7 +6865,7 @@ var Layer = ({
|
|
|
6775
6865
|
childIsSelected
|
|
6776
6866
|
}),
|
|
6777
6867
|
children: [
|
|
6778
|
-
/* @__PURE__ */
|
|
6868
|
+
/* @__PURE__ */ jsx33("div", { className: getClassNameLayer("inner"), children: /* @__PURE__ */ jsxs15(
|
|
6779
6869
|
"button",
|
|
6780
6870
|
{
|
|
6781
6871
|
type: "button",
|
|
@@ -6813,22 +6903,22 @@ var Layer = ({
|
|
|
6813
6903
|
zoneStore.setState({ hoveringComponent: null });
|
|
6814
6904
|
},
|
|
6815
6905
|
children: [
|
|
6816
|
-
containsZone && /* @__PURE__ */
|
|
6906
|
+
containsZone && /* @__PURE__ */ jsx33(
|
|
6817
6907
|
"div",
|
|
6818
6908
|
{
|
|
6819
6909
|
className: getClassNameLayer("chevron"),
|
|
6820
6910
|
title: isSelected ? "Collapse" : "Expand",
|
|
6821
|
-
children: /* @__PURE__ */
|
|
6911
|
+
children: /* @__PURE__ */ jsx33(ChevronDown, { size: "12" })
|
|
6822
6912
|
}
|
|
6823
6913
|
),
|
|
6824
|
-
/* @__PURE__ */
|
|
6825
|
-
/* @__PURE__ */
|
|
6826
|
-
/* @__PURE__ */
|
|
6914
|
+
/* @__PURE__ */ jsxs15("div", { className: getClassNameLayer("title"), children: [
|
|
6915
|
+
/* @__PURE__ */ jsx33("div", { className: getClassNameLayer("icon"), children: nodeData.data.type === "Text" || nodeData.data.type === "Heading" ? /* @__PURE__ */ jsx33(Type, { size: "16" }) : /* @__PURE__ */ jsx33(LayoutGrid, { size: "16" }) }),
|
|
6916
|
+
/* @__PURE__ */ jsx33("div", { className: getClassNameLayer("name"), children: label })
|
|
6827
6917
|
] })
|
|
6828
6918
|
]
|
|
6829
6919
|
}
|
|
6830
6920
|
) }),
|
|
6831
|
-
containsZone && zonesForItem.map((subzone) => /* @__PURE__ */
|
|
6921
|
+
containsZone && zonesForItem.map((subzone) => /* @__PURE__ */ jsx33("div", { className: getClassNameLayer("zones"), children: /* @__PURE__ */ jsx33(LayerTree, { zoneCompound: subzone }) }, subzone))
|
|
6832
6922
|
]
|
|
6833
6923
|
}
|
|
6834
6924
|
);
|
|
@@ -6837,7 +6927,15 @@ var LayerTree = ({
|
|
|
6837
6927
|
label: _label,
|
|
6838
6928
|
zoneCompound
|
|
6839
6929
|
}) => {
|
|
6840
|
-
const label =
|
|
6930
|
+
const label = useAppStore((s) => {
|
|
6931
|
+
var _a, _b, _c, _d;
|
|
6932
|
+
if (_label) return _label;
|
|
6933
|
+
if (zoneCompound === rootDroppableId) return;
|
|
6934
|
+
const [componentId, slotId] = zoneCompound.split(":");
|
|
6935
|
+
const componentType = (_a = s.state.indexes.nodes[componentId]) == null ? void 0 : _a.data.type;
|
|
6936
|
+
const configForComponent = componentType && componentType !== rootAreaId ? s.config.components[componentType] : s.config.root;
|
|
6937
|
+
return (_d = (_c = (_b = configForComponent == null ? void 0 : configForComponent.fields) == null ? void 0 : _b[slotId]) == null ? void 0 : _c.label) != null ? _d : slotId;
|
|
6938
|
+
});
|
|
6841
6939
|
const contentIds = useAppStore(
|
|
6842
6940
|
useShallow6(
|
|
6843
6941
|
(s) => {
|
|
@@ -6846,15 +6944,15 @@ var LayerTree = ({
|
|
|
6846
6944
|
}
|
|
6847
6945
|
)
|
|
6848
6946
|
);
|
|
6849
|
-
return /* @__PURE__ */
|
|
6850
|
-
label && /* @__PURE__ */
|
|
6851
|
-
/* @__PURE__ */
|
|
6947
|
+
return /* @__PURE__ */ jsxs15(Fragment10, { children: [
|
|
6948
|
+
label && /* @__PURE__ */ jsxs15("div", { className: getClassName23("zoneTitle"), children: [
|
|
6949
|
+
/* @__PURE__ */ jsx33("div", { className: getClassName23("zoneIcon"), children: /* @__PURE__ */ jsx33(Layers, { size: "16" }) }),
|
|
6852
6950
|
label
|
|
6853
6951
|
] }),
|
|
6854
|
-
/* @__PURE__ */
|
|
6855
|
-
contentIds.length === 0 && /* @__PURE__ */
|
|
6952
|
+
/* @__PURE__ */ jsxs15("ul", { className: getClassName23(), children: [
|
|
6953
|
+
contentIds.length === 0 && /* @__PURE__ */ jsx33("div", { className: getClassName23("helper"), children: "No items" }),
|
|
6856
6954
|
contentIds.map((itemId, i) => {
|
|
6857
|
-
return /* @__PURE__ */
|
|
6955
|
+
return /* @__PURE__ */ jsx33(
|
|
6858
6956
|
Layer,
|
|
6859
6957
|
{
|
|
6860
6958
|
index: i,
|
|
@@ -6869,7 +6967,7 @@ var LayerTree = ({
|
|
|
6869
6967
|
};
|
|
6870
6968
|
|
|
6871
6969
|
// components/Puck/components/Outline/index.tsx
|
|
6872
|
-
import { useMemo as
|
|
6970
|
+
import { useMemo as useMemo16 } from "react";
|
|
6873
6971
|
|
|
6874
6972
|
// lib/data/find-zones-for-area.ts
|
|
6875
6973
|
init_react_import();
|
|
@@ -6881,14 +6979,14 @@ var findZonesForArea = (state, area) => {
|
|
|
6881
6979
|
|
|
6882
6980
|
// components/Puck/components/Outline/index.tsx
|
|
6883
6981
|
import { useShallow as useShallow7 } from "zustand/react/shallow";
|
|
6884
|
-
import { jsx as
|
|
6982
|
+
import { jsx as jsx34 } from "react/jsx-runtime";
|
|
6885
6983
|
var Outline = () => {
|
|
6886
6984
|
const outlineOverride = useAppStore((s) => s.overrides.outline);
|
|
6887
6985
|
const rootZones = useAppStore(
|
|
6888
6986
|
useShallow7((s) => findZonesForArea(s.state, "root"))
|
|
6889
6987
|
);
|
|
6890
|
-
const Wrapper =
|
|
6891
|
-
return /* @__PURE__ */
|
|
6988
|
+
const Wrapper = useMemo16(() => outlineOverride || "div", [outlineOverride]);
|
|
6989
|
+
return /* @__PURE__ */ jsx34(Wrapper, { children: rootZones.map((zoneCompound) => /* @__PURE__ */ jsx34(
|
|
6892
6990
|
LayerTree,
|
|
6893
6991
|
{
|
|
6894
6992
|
label: rootZones.length === 1 ? "" : zoneCompound.split(":")[1],
|
|
@@ -6898,572 +6996,64 @@ var Outline = () => {
|
|
|
6898
6996
|
)) });
|
|
6899
6997
|
};
|
|
6900
6998
|
|
|
6901
|
-
//
|
|
6999
|
+
// components/Puck/components/Canvas/index.tsx
|
|
6902
7000
|
init_react_import();
|
|
6903
|
-
import { useMemo as useMemo16 } from "react";
|
|
6904
7001
|
|
|
6905
|
-
//
|
|
7002
|
+
// ../../node_modules/css-box-model/dist/css-box-model.esm.js
|
|
6906
7003
|
init_react_import();
|
|
6907
|
-
var loadOverrides = ({
|
|
6908
|
-
overrides,
|
|
6909
|
-
plugins
|
|
6910
|
-
}) => {
|
|
6911
|
-
const collected = __spreadValues({}, overrides);
|
|
6912
|
-
plugins == null ? void 0 : plugins.forEach((plugin) => {
|
|
6913
|
-
if (!plugin.overrides) return;
|
|
6914
|
-
Object.keys(plugin.overrides).forEach((_overridesType) => {
|
|
6915
|
-
const overridesType = _overridesType;
|
|
6916
|
-
if (overridesType === "fieldTypes") {
|
|
6917
|
-
const fieldTypes = plugin.overrides.fieldTypes;
|
|
6918
|
-
Object.keys(fieldTypes).forEach((fieldType) => {
|
|
6919
|
-
collected.fieldTypes = collected.fieldTypes || {};
|
|
6920
|
-
const childNode2 = collected.fieldTypes[fieldType];
|
|
6921
|
-
const Comp2 = (props) => fieldTypes[fieldType](__spreadProps(__spreadValues({}, props), {
|
|
6922
|
-
children: childNode2 ? childNode2(props) : props.children
|
|
6923
|
-
}));
|
|
6924
|
-
collected.fieldTypes[fieldType] = Comp2;
|
|
6925
|
-
});
|
|
6926
|
-
return;
|
|
6927
|
-
}
|
|
6928
|
-
const childNode = collected[overridesType];
|
|
6929
|
-
const Comp = (props) => plugin.overrides[overridesType](__spreadProps(__spreadValues({}, props), {
|
|
6930
|
-
children: childNode ? childNode(props) : props.children
|
|
6931
|
-
}));
|
|
6932
|
-
collected[overridesType] = Comp;
|
|
6933
|
-
});
|
|
6934
|
-
});
|
|
6935
|
-
return collected;
|
|
6936
|
-
};
|
|
6937
|
-
|
|
6938
|
-
// lib/use-loaded-overrides.ts
|
|
6939
|
-
var useLoadedOverrides = ({
|
|
6940
|
-
overrides,
|
|
6941
|
-
plugins
|
|
6942
|
-
}) => {
|
|
6943
|
-
return useMemo16(() => {
|
|
6944
|
-
return loadOverrides({ overrides, plugins });
|
|
6945
|
-
}, [plugins, overrides]);
|
|
6946
|
-
};
|
|
6947
7004
|
|
|
6948
|
-
//
|
|
7005
|
+
// ../../node_modules/tiny-invariant/dist/esm/tiny-invariant.js
|
|
6949
7006
|
init_react_import();
|
|
6950
|
-
|
|
6951
|
-
|
|
6952
|
-
|
|
6953
|
-
|
|
6954
|
-
|
|
6955
|
-
|
|
6956
|
-
|
|
6957
|
-
|
|
6958
|
-
|
|
6959
|
-
|
|
6960
|
-
|
|
6961
|
-
|
|
6962
|
-
|
|
6963
|
-
|
|
6964
|
-
|
|
6965
|
-
|
|
6966
|
-
|
|
6967
|
-
|
|
6968
|
-
|
|
6969
|
-
|
|
6970
|
-
|
|
6971
|
-
|
|
6972
|
-
|
|
6973
|
-
|
|
6974
|
-
|
|
6975
|
-
|
|
6976
|
-
|
|
6977
|
-
|
|
6978
|
-
|
|
7007
|
+
var isProduction = process.env.NODE_ENV === "production";
|
|
7008
|
+
var prefix = "Invariant failed";
|
|
7009
|
+
function invariant(condition, message) {
|
|
7010
|
+
if (condition) {
|
|
7011
|
+
return;
|
|
7012
|
+
}
|
|
7013
|
+
if (isProduction) {
|
|
7014
|
+
throw new Error(prefix);
|
|
7015
|
+
}
|
|
7016
|
+
var provided = typeof message === "function" ? message() : message;
|
|
7017
|
+
var value = provided ? "".concat(prefix, ": ").concat(provided) : prefix;
|
|
7018
|
+
throw new Error(value);
|
|
7019
|
+
}
|
|
7020
|
+
|
|
7021
|
+
// ../../node_modules/css-box-model/dist/css-box-model.esm.js
|
|
7022
|
+
var getRect = function getRect2(_ref) {
|
|
7023
|
+
var top = _ref.top, right = _ref.right, bottom = _ref.bottom, left = _ref.left;
|
|
7024
|
+
var width = right - left;
|
|
7025
|
+
var height = bottom - top;
|
|
7026
|
+
var rect = {
|
|
7027
|
+
top,
|
|
7028
|
+
right,
|
|
7029
|
+
bottom,
|
|
7030
|
+
left,
|
|
7031
|
+
width,
|
|
7032
|
+
height,
|
|
7033
|
+
x: left,
|
|
7034
|
+
y: top,
|
|
7035
|
+
center: {
|
|
7036
|
+
x: (right + left) / 2,
|
|
7037
|
+
y: (bottom + top) / 2
|
|
6979
7038
|
}
|
|
6980
7039
|
};
|
|
6981
|
-
|
|
6982
|
-
return __spreadProps(__spreadValues({}, storeData), { get });
|
|
7040
|
+
return rect;
|
|
6983
7041
|
};
|
|
6984
|
-
var
|
|
6985
|
-
null
|
|
6986
|
-
);
|
|
6987
|
-
var convertToPickedStore = (store) => {
|
|
7042
|
+
var expand = function expand2(target, expandBy) {
|
|
6988
7043
|
return {
|
|
6989
|
-
|
|
6990
|
-
|
|
6991
|
-
|
|
6992
|
-
|
|
6993
|
-
history: store.history,
|
|
6994
|
-
selectedItem: store.selectedItem
|
|
7044
|
+
top: target.top - expandBy.top,
|
|
7045
|
+
left: target.left - expandBy.left,
|
|
7046
|
+
bottom: target.bottom + expandBy.bottom,
|
|
7047
|
+
right: target.right + expandBy.right
|
|
6995
7048
|
};
|
|
6996
7049
|
};
|
|
6997
|
-
var
|
|
6998
|
-
|
|
6999
|
-
|
|
7000
|
-
|
|
7001
|
-
|
|
7002
|
-
|
|
7003
|
-
|
|
7004
|
-
return appStore.subscribe(
|
|
7005
|
-
(store) => convertToPickedStore(store),
|
|
7006
|
-
(pickedStore) => {
|
|
7007
|
-
usePuckStore.setState(generateUsePuck(pickedStore));
|
|
7008
|
-
}
|
|
7009
|
-
);
|
|
7010
|
-
}, []);
|
|
7011
|
-
return usePuckStore;
|
|
7012
|
-
};
|
|
7013
|
-
function createUsePuck() {
|
|
7014
|
-
return function usePuck2(selector) {
|
|
7015
|
-
const usePuckApi = useContext11(UsePuckStoreContext);
|
|
7016
|
-
if (!usePuckApi) {
|
|
7017
|
-
throw new Error("usePuck must be used inside <Puck>.");
|
|
7018
|
-
}
|
|
7019
|
-
const result = useStore3(
|
|
7020
|
-
usePuckApi,
|
|
7021
|
-
selector != null ? selector : (s) => s
|
|
7022
|
-
);
|
|
7023
|
-
return result;
|
|
7024
|
-
};
|
|
7025
|
-
}
|
|
7026
|
-
function usePuck() {
|
|
7027
|
-
useEffect21(() => {
|
|
7028
|
-
console.warn(
|
|
7029
|
-
"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."
|
|
7030
|
-
);
|
|
7031
|
-
}, []);
|
|
7032
|
-
return createUsePuck()((s) => s);
|
|
7033
|
-
}
|
|
7034
|
-
function useGetPuck() {
|
|
7035
|
-
const usePuckApi = useContext11(UsePuckStoreContext);
|
|
7036
|
-
if (!usePuckApi) {
|
|
7037
|
-
throw new Error("usePuckGet must be used inside <Puck>.");
|
|
7038
|
-
}
|
|
7039
|
-
return usePuckApi.getState;
|
|
7040
|
-
}
|
|
7041
|
-
|
|
7042
|
-
// components/Puck/index.tsx
|
|
7043
|
-
import fdeq from "fast-deep-equal";
|
|
7044
|
-
|
|
7045
|
-
// components/Puck/components/Layout/index.tsx
|
|
7046
|
-
init_react_import();
|
|
7047
|
-
import { useEffect as useEffect25, useMemo as useMemo21, useState as useState23 } from "react";
|
|
7048
|
-
|
|
7049
|
-
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Layout/styles.module.css#css-module
|
|
7050
|
-
init_react_import();
|
|
7051
|
-
var styles_module_default17 = { "Puck": "_Puck_n6ob8_19", "Puck-portal": "_Puck-portal_n6ob8_31", "PuckLayout-inner": "_PuckLayout-inner_n6ob8_36", "PuckLayout--mounted": "_PuckLayout--mounted_n6ob8_48", "PuckLayout--leftSideBarVisible": "_PuckLayout--leftSideBarVisible_n6ob8_53", "PuckLayout--rightSideBarVisible": "_PuckLayout--rightSideBarVisible_n6ob8_61", "PuckLayout-mounted": "_PuckLayout-mounted_n6ob8_77", "PuckLayout": "_PuckLayout_n6ob8_36", "PuckLayout-leftSideBar": "_PuckLayout-leftSideBar_n6ob8_118", "PuckLayout-rightSideBar": "_PuckLayout-rightSideBar_n6ob8_128", "PuckLayout-nav": "_PuckLayout-nav_n6ob8_137" };
|
|
7052
|
-
|
|
7053
|
-
// lib/use-inject-css.ts
|
|
7054
|
-
init_react_import();
|
|
7055
|
-
import { useEffect as useEffect22, useState as useState19 } from "react";
|
|
7056
|
-
var styles = ``;
|
|
7057
|
-
var useInjectStyleSheet = (initialStyles, iframeEnabled) => {
|
|
7058
|
-
const [el, setEl] = useState19();
|
|
7059
|
-
useEffect22(() => {
|
|
7060
|
-
setEl(document.createElement("style"));
|
|
7061
|
-
}, []);
|
|
7062
|
-
useEffect22(() => {
|
|
7063
|
-
var _a;
|
|
7064
|
-
if (!el || typeof window === "undefined") {
|
|
7065
|
-
return;
|
|
7066
|
-
}
|
|
7067
|
-
el.innerHTML = initialStyles;
|
|
7068
|
-
if (iframeEnabled) {
|
|
7069
|
-
const frame = getFrame();
|
|
7070
|
-
(_a = frame == null ? void 0 : frame.head) == null ? void 0 : _a.appendChild(el);
|
|
7071
|
-
}
|
|
7072
|
-
document.head.appendChild(el);
|
|
7073
|
-
}, [iframeEnabled, el]);
|
|
7074
|
-
return el;
|
|
7075
|
-
};
|
|
7076
|
-
var useInjectGlobalCss = (iframeEnabled) => {
|
|
7077
|
-
return useInjectStyleSheet(styles, iframeEnabled);
|
|
7078
|
-
};
|
|
7079
|
-
|
|
7080
|
-
// components/DefaultOverride/index.tsx
|
|
7081
|
-
init_react_import();
|
|
7082
|
-
import { Fragment as Fragment11, jsx as jsx34 } from "react/jsx-runtime";
|
|
7083
|
-
var DefaultOverride = ({ children }) => /* @__PURE__ */ jsx34(Fragment11, { children });
|
|
7084
|
-
|
|
7085
|
-
// lib/use-preview-mode-hotkeys.ts
|
|
7086
|
-
init_react_import();
|
|
7087
|
-
import { useCallback as useCallback15 } from "react";
|
|
7088
|
-
var usePreviewModeHotkeys = () => {
|
|
7089
|
-
const appStore = useAppStoreApi();
|
|
7090
|
-
const toggleInteractive = useCallback15(() => {
|
|
7091
|
-
const dispatch = appStore.getState().dispatch;
|
|
7092
|
-
dispatch({
|
|
7093
|
-
type: "setUi",
|
|
7094
|
-
ui: (ui) => ({
|
|
7095
|
-
previewMode: ui.previewMode === "edit" ? "interactive" : "edit"
|
|
7096
|
-
})
|
|
7097
|
-
});
|
|
7098
|
-
}, [appStore]);
|
|
7099
|
-
useHotkey({ meta: true, i: true }, toggleInteractive);
|
|
7100
|
-
useHotkey({ ctrl: true, i: true }, toggleInteractive);
|
|
7101
|
-
};
|
|
7102
|
-
|
|
7103
|
-
// components/Puck/components/Header/index.tsx
|
|
7104
|
-
init_react_import();
|
|
7105
|
-
import { memo as memo3, useCallback as useCallback16, useMemo as useMemo17, useState as useState20 } from "react";
|
|
7106
|
-
|
|
7107
|
-
// components/MenuBar/index.tsx
|
|
7108
|
-
init_react_import();
|
|
7109
|
-
|
|
7110
|
-
// css-module:/home/runner/work/puck/puck/packages/core/components/MenuBar/styles.module.css#css-module
|
|
7111
|
-
init_react_import();
|
|
7112
|
-
var styles_module_default18 = { "MenuBar": "_MenuBar_8pf8c_1", "MenuBar--menuOpen": "_MenuBar--menuOpen_8pf8c_14", "MenuBar-inner": "_MenuBar-inner_8pf8c_29", "MenuBar-history": "_MenuBar-history_8pf8c_45" };
|
|
7113
|
-
|
|
7114
|
-
// components/MenuBar/index.tsx
|
|
7115
|
-
import { Fragment as Fragment12, jsx as jsx35, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
7116
|
-
var getClassName23 = get_class_name_factory_default("MenuBar", styles_module_default18);
|
|
7117
|
-
function MenuBar({
|
|
7118
|
-
menuOpen = false,
|
|
7119
|
-
renderHeaderActions,
|
|
7120
|
-
setMenuOpen
|
|
7121
|
-
}) {
|
|
7122
|
-
const back = useAppStore((s) => s.history.back);
|
|
7123
|
-
const forward = useAppStore((s) => s.history.forward);
|
|
7124
|
-
const hasFuture = useAppStore((s) => s.history.hasFuture());
|
|
7125
|
-
const hasPast = useAppStore((s) => s.history.hasPast());
|
|
7126
|
-
return /* @__PURE__ */ jsx35(
|
|
7127
|
-
"div",
|
|
7128
|
-
{
|
|
7129
|
-
className: getClassName23({ menuOpen }),
|
|
7130
|
-
onClick: (event) => {
|
|
7131
|
-
var _a;
|
|
7132
|
-
const element = event.target;
|
|
7133
|
-
if (window.matchMedia("(min-width: 638px)").matches) {
|
|
7134
|
-
return;
|
|
7135
|
-
}
|
|
7136
|
-
if (element.tagName === "A" && ((_a = element.getAttribute("href")) == null ? void 0 : _a.startsWith("#"))) {
|
|
7137
|
-
setMenuOpen(false);
|
|
7138
|
-
}
|
|
7139
|
-
},
|
|
7140
|
-
children: /* @__PURE__ */ jsxs15("div", { className: getClassName23("inner"), children: [
|
|
7141
|
-
/* @__PURE__ */ jsxs15("div", { className: getClassName23("history"), children: [
|
|
7142
|
-
/* @__PURE__ */ jsx35(IconButton, { title: "undo", disabled: !hasPast, onClick: back, children: /* @__PURE__ */ jsx35(Undo2, { size: 21 }) }),
|
|
7143
|
-
/* @__PURE__ */ jsx35(IconButton, { title: "redo", disabled: !hasFuture, onClick: forward, children: /* @__PURE__ */ jsx35(Redo2, { size: 21 }) })
|
|
7144
|
-
] }),
|
|
7145
|
-
/* @__PURE__ */ jsx35(Fragment12, { children: renderHeaderActions && renderHeaderActions() })
|
|
7146
|
-
] })
|
|
7147
|
-
}
|
|
7148
|
-
);
|
|
7149
|
-
}
|
|
7150
|
-
|
|
7151
|
-
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Header/styles.module.css#css-module
|
|
7152
|
-
init_react_import();
|
|
7153
|
-
var styles_module_default19 = { "PuckHeader": "_PuckHeader_dlc6d_1", "PuckHeader-inner": "_PuckHeader-inner_dlc6d_16", "PuckHeader-toggle": "_PuckHeader-toggle_dlc6d_33", "PuckHeader--rightSideBarVisible": "_PuckHeader--rightSideBarVisible_dlc6d_40", "PuckHeader-rightSideBarToggle": "_PuckHeader-rightSideBarToggle_dlc6d_40", "PuckHeader--leftSideBarVisible": "_PuckHeader--leftSideBarVisible_dlc6d_41", "PuckHeader-leftSideBarToggle": "_PuckHeader-leftSideBarToggle_dlc6d_41", "PuckHeader-title": "_PuckHeader-title_dlc6d_45", "PuckHeader-path": "_PuckHeader-path_dlc6d_49", "PuckHeader-tools": "_PuckHeader-tools_dlc6d_56", "PuckHeader-menuButton": "_PuckHeader-menuButton_dlc6d_62", "PuckHeader--menuOpen": "_PuckHeader--menuOpen_dlc6d_67" };
|
|
7154
|
-
|
|
7155
|
-
// components/Puck/components/Header/index.tsx
|
|
7156
|
-
import { Fragment as Fragment13, jsx as jsx36, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
7157
|
-
var getClassName24 = get_class_name_factory_default("PuckHeader", styles_module_default19);
|
|
7158
|
-
var HeaderInner = () => {
|
|
7159
|
-
const {
|
|
7160
|
-
onPublish,
|
|
7161
|
-
renderHeader,
|
|
7162
|
-
renderHeaderActions,
|
|
7163
|
-
headerTitle,
|
|
7164
|
-
headerPath,
|
|
7165
|
-
iframe: _iframe
|
|
7166
|
-
} = usePropsContext();
|
|
7167
|
-
const dispatch = useAppStore((s) => s.dispatch);
|
|
7168
|
-
const appStore = useAppStoreApi();
|
|
7169
|
-
const defaultHeaderRender = useMemo17(() => {
|
|
7170
|
-
if (renderHeader) {
|
|
7171
|
-
console.warn(
|
|
7172
|
-
"`renderHeader` is deprecated. Please use `overrides.header` and the `usePuck` hook instead"
|
|
7173
|
-
);
|
|
7174
|
-
const RenderHeader = (_a) => {
|
|
7175
|
-
var _b = _a, { actions } = _b, props = __objRest(_b, ["actions"]);
|
|
7176
|
-
const Comp = renderHeader;
|
|
7177
|
-
const appState = useAppStore((s) => s.state);
|
|
7178
|
-
return /* @__PURE__ */ jsx36(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState, children: actions }));
|
|
7179
|
-
};
|
|
7180
|
-
return RenderHeader;
|
|
7181
|
-
}
|
|
7182
|
-
return DefaultOverride;
|
|
7183
|
-
}, [renderHeader]);
|
|
7184
|
-
const defaultHeaderActionsRender = useMemo17(() => {
|
|
7185
|
-
if (renderHeaderActions) {
|
|
7186
|
-
console.warn(
|
|
7187
|
-
"`renderHeaderActions` is deprecated. Please use `overrides.headerActions` and the `usePuck` hook instead."
|
|
7188
|
-
);
|
|
7189
|
-
const RenderHeader = (props) => {
|
|
7190
|
-
const Comp = renderHeaderActions;
|
|
7191
|
-
const appState = useAppStore((s) => s.state);
|
|
7192
|
-
return /* @__PURE__ */ jsx36(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState }));
|
|
7193
|
-
};
|
|
7194
|
-
return RenderHeader;
|
|
7195
|
-
}
|
|
7196
|
-
return DefaultOverride;
|
|
7197
|
-
}, [renderHeader]);
|
|
7198
|
-
const CustomHeader = useAppStore(
|
|
7199
|
-
(s) => s.overrides.header || defaultHeaderRender
|
|
7200
|
-
);
|
|
7201
|
-
const CustomHeaderActions = useAppStore(
|
|
7202
|
-
(s) => s.overrides.headerActions || defaultHeaderActionsRender
|
|
7203
|
-
);
|
|
7204
|
-
const [menuOpen, setMenuOpen] = useState20(false);
|
|
7205
|
-
const rootTitle = useAppStore((s) => {
|
|
7206
|
-
var _a, _b;
|
|
7207
|
-
const rootData = (_a = s.state.indexes.nodes["root"]) == null ? void 0 : _a.data;
|
|
7208
|
-
return (_b = rootData.props.title) != null ? _b : "";
|
|
7209
|
-
});
|
|
7210
|
-
const leftSideBarVisible = useAppStore((s) => s.state.ui.leftSideBarVisible);
|
|
7211
|
-
const rightSideBarVisible = useAppStore(
|
|
7212
|
-
(s) => s.state.ui.rightSideBarVisible
|
|
7213
|
-
);
|
|
7214
|
-
const toggleSidebars = useCallback16(
|
|
7215
|
-
(sidebar) => {
|
|
7216
|
-
const widerViewport = window.matchMedia("(min-width: 638px)").matches;
|
|
7217
|
-
const sideBarVisible = sidebar === "left" ? leftSideBarVisible : rightSideBarVisible;
|
|
7218
|
-
const oppositeSideBar = sidebar === "left" ? "rightSideBarVisible" : "leftSideBarVisible";
|
|
7219
|
-
dispatch({
|
|
7220
|
-
type: "setUi",
|
|
7221
|
-
ui: __spreadValues({
|
|
7222
|
-
[`${sidebar}SideBarVisible`]: !sideBarVisible
|
|
7223
|
-
}, !widerViewport ? { [oppositeSideBar]: false } : {})
|
|
7224
|
-
});
|
|
7225
|
-
},
|
|
7226
|
-
[dispatch, leftSideBarVisible, rightSideBarVisible]
|
|
7227
|
-
);
|
|
7228
|
-
return /* @__PURE__ */ jsx36(
|
|
7229
|
-
CustomHeader,
|
|
7230
|
-
{
|
|
7231
|
-
actions: /* @__PURE__ */ jsx36(Fragment13, { children: /* @__PURE__ */ jsx36(CustomHeaderActions, { children: /* @__PURE__ */ jsx36(
|
|
7232
|
-
Button,
|
|
7233
|
-
{
|
|
7234
|
-
onClick: () => {
|
|
7235
|
-
const data = appStore.getState().state.data;
|
|
7236
|
-
onPublish && onPublish(data);
|
|
7237
|
-
},
|
|
7238
|
-
icon: /* @__PURE__ */ jsx36(Globe, { size: "14px" }),
|
|
7239
|
-
children: "Publish"
|
|
7240
|
-
}
|
|
7241
|
-
) }) }),
|
|
7242
|
-
children: /* @__PURE__ */ jsx36(
|
|
7243
|
-
"header",
|
|
7244
|
-
{
|
|
7245
|
-
className: getClassName24({ leftSideBarVisible, rightSideBarVisible }),
|
|
7246
|
-
children: /* @__PURE__ */ jsxs16("div", { className: getClassName24("inner"), children: [
|
|
7247
|
-
/* @__PURE__ */ jsxs16("div", { className: getClassName24("toggle"), children: [
|
|
7248
|
-
/* @__PURE__ */ jsx36("div", { className: getClassName24("leftSideBarToggle"), children: /* @__PURE__ */ jsx36(
|
|
7249
|
-
IconButton,
|
|
7250
|
-
{
|
|
7251
|
-
onClick: () => {
|
|
7252
|
-
toggleSidebars("left");
|
|
7253
|
-
},
|
|
7254
|
-
title: "Toggle left sidebar",
|
|
7255
|
-
children: /* @__PURE__ */ jsx36(PanelLeft, { focusable: "false" })
|
|
7256
|
-
}
|
|
7257
|
-
) }),
|
|
7258
|
-
/* @__PURE__ */ jsx36("div", { className: getClassName24("rightSideBarToggle"), children: /* @__PURE__ */ jsx36(
|
|
7259
|
-
IconButton,
|
|
7260
|
-
{
|
|
7261
|
-
onClick: () => {
|
|
7262
|
-
toggleSidebars("right");
|
|
7263
|
-
},
|
|
7264
|
-
title: "Toggle right sidebar",
|
|
7265
|
-
children: /* @__PURE__ */ jsx36(PanelRight, { focusable: "false" })
|
|
7266
|
-
}
|
|
7267
|
-
) })
|
|
7268
|
-
] }),
|
|
7269
|
-
/* @__PURE__ */ jsx36("div", { className: getClassName24("title"), children: /* @__PURE__ */ jsxs16(Heading, { rank: "2", size: "xs", children: [
|
|
7270
|
-
headerTitle || rootTitle || "Page",
|
|
7271
|
-
headerPath && /* @__PURE__ */ jsxs16(Fragment13, { children: [
|
|
7272
|
-
" ",
|
|
7273
|
-
/* @__PURE__ */ jsx36("code", { className: getClassName24("path"), children: headerPath })
|
|
7274
|
-
] })
|
|
7275
|
-
] }) }),
|
|
7276
|
-
/* @__PURE__ */ jsxs16("div", { className: getClassName24("tools"), children: [
|
|
7277
|
-
/* @__PURE__ */ jsx36("div", { className: getClassName24("menuButton"), children: /* @__PURE__ */ jsx36(
|
|
7278
|
-
IconButton,
|
|
7279
|
-
{
|
|
7280
|
-
onClick: () => {
|
|
7281
|
-
return setMenuOpen(!menuOpen);
|
|
7282
|
-
},
|
|
7283
|
-
title: "Toggle menu bar",
|
|
7284
|
-
children: menuOpen ? /* @__PURE__ */ jsx36(ChevronUp, { focusable: "false" }) : /* @__PURE__ */ jsx36(ChevronDown, { focusable: "false" })
|
|
7285
|
-
}
|
|
7286
|
-
) }),
|
|
7287
|
-
/* @__PURE__ */ jsx36(
|
|
7288
|
-
MenuBar,
|
|
7289
|
-
{
|
|
7290
|
-
dispatch,
|
|
7291
|
-
onPublish,
|
|
7292
|
-
menuOpen,
|
|
7293
|
-
renderHeaderActions: () => /* @__PURE__ */ jsx36(CustomHeaderActions, { children: /* @__PURE__ */ jsx36(
|
|
7294
|
-
Button,
|
|
7295
|
-
{
|
|
7296
|
-
onClick: () => {
|
|
7297
|
-
const data = appStore.getState().state.data;
|
|
7298
|
-
onPublish && onPublish(data);
|
|
7299
|
-
},
|
|
7300
|
-
icon: /* @__PURE__ */ jsx36(Globe, { size: "14px" }),
|
|
7301
|
-
children: "Publish"
|
|
7302
|
-
}
|
|
7303
|
-
) }),
|
|
7304
|
-
setMenuOpen
|
|
7305
|
-
}
|
|
7306
|
-
)
|
|
7307
|
-
] })
|
|
7308
|
-
] })
|
|
7309
|
-
}
|
|
7310
|
-
)
|
|
7311
|
-
}
|
|
7312
|
-
);
|
|
7313
|
-
};
|
|
7314
|
-
var Header = memo3(HeaderInner);
|
|
7315
|
-
|
|
7316
|
-
// components/SidebarSection/index.tsx
|
|
7317
|
-
init_react_import();
|
|
7318
|
-
|
|
7319
|
-
// css-module:/home/runner/work/puck/puck/packages/core/components/SidebarSection/styles.module.css#css-module
|
|
7320
|
-
init_react_import();
|
|
7321
|
-
var styles_module_default20 = { "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" };
|
|
7322
|
-
|
|
7323
|
-
// lib/use-breadcrumbs.ts
|
|
7324
|
-
init_react_import();
|
|
7325
|
-
import { useMemo as useMemo18 } from "react";
|
|
7326
|
-
var useBreadcrumbs = (renderCount) => {
|
|
7327
|
-
const selectedId = useAppStore((s) => {
|
|
7328
|
-
var _a;
|
|
7329
|
-
return (_a = s.selectedItem) == null ? void 0 : _a.props.id;
|
|
7330
|
-
});
|
|
7331
|
-
const config = useAppStore((s) => s.config);
|
|
7332
|
-
const path = useAppStore((s) => {
|
|
7333
|
-
var _a;
|
|
7334
|
-
return (_a = s.state.indexes.nodes[selectedId]) == null ? void 0 : _a.path;
|
|
7335
|
-
});
|
|
7336
|
-
const appStore = useAppStoreApi();
|
|
7337
|
-
return useMemo18(() => {
|
|
7338
|
-
const breadcrumbs = (path == null ? void 0 : path.map((zoneCompound) => {
|
|
7339
|
-
var _a, _b, _c;
|
|
7340
|
-
const [componentId] = zoneCompound.split(":");
|
|
7341
|
-
if (componentId === "root") {
|
|
7342
|
-
return {
|
|
7343
|
-
label: "Page",
|
|
7344
|
-
selector: null
|
|
7345
|
-
};
|
|
7346
|
-
}
|
|
7347
|
-
const node = appStore.getState().state.indexes.nodes[componentId];
|
|
7348
|
-
const parentId = node.path[node.path.length - 1];
|
|
7349
|
-
const contentIds = ((_a = appStore.getState().state.indexes.zones[parentId]) == null ? void 0 : _a.contentIds) || [];
|
|
7350
|
-
const index = contentIds.indexOf(componentId);
|
|
7351
|
-
const label = node ? (_c = (_b = config.components[node.data.type]) == null ? void 0 : _b.label) != null ? _c : node.data.type : "Component";
|
|
7352
|
-
return {
|
|
7353
|
-
label,
|
|
7354
|
-
selector: node ? {
|
|
7355
|
-
index,
|
|
7356
|
-
zone: node.path[node.path.length - 1]
|
|
7357
|
-
} : null
|
|
7358
|
-
};
|
|
7359
|
-
})) || [];
|
|
7360
|
-
if (renderCount) {
|
|
7361
|
-
return breadcrumbs.slice(breadcrumbs.length - renderCount);
|
|
7362
|
-
}
|
|
7363
|
-
return breadcrumbs;
|
|
7364
|
-
}, [path, renderCount]);
|
|
7365
|
-
};
|
|
7366
|
-
|
|
7367
|
-
// components/SidebarSection/index.tsx
|
|
7368
|
-
import { jsx as jsx37, jsxs as jsxs17 } from "react/jsx-runtime";
|
|
7369
|
-
var getClassName25 = get_class_name_factory_default("SidebarSection", styles_module_default20);
|
|
7370
|
-
var SidebarSection = ({
|
|
7371
|
-
children,
|
|
7372
|
-
title,
|
|
7373
|
-
background,
|
|
7374
|
-
showBreadcrumbs,
|
|
7375
|
-
noBorderTop,
|
|
7376
|
-
noPadding,
|
|
7377
|
-
isLoading
|
|
7378
|
-
}) => {
|
|
7379
|
-
const setUi = useAppStore((s) => s.setUi);
|
|
7380
|
-
const breadcrumbs = useBreadcrumbs(1);
|
|
7381
|
-
return /* @__PURE__ */ jsxs17(
|
|
7382
|
-
"div",
|
|
7383
|
-
{
|
|
7384
|
-
className: getClassName25({ noBorderTop, noPadding }),
|
|
7385
|
-
style: { background },
|
|
7386
|
-
children: [
|
|
7387
|
-
/* @__PURE__ */ jsx37("div", { className: getClassName25("title"), children: /* @__PURE__ */ jsxs17("div", { className: getClassName25("breadcrumbs"), children: [
|
|
7388
|
-
showBreadcrumbs ? breadcrumbs.map((breadcrumb, i) => /* @__PURE__ */ jsxs17("div", { className: getClassName25("breadcrumb"), children: [
|
|
7389
|
-
/* @__PURE__ */ jsx37(
|
|
7390
|
-
"button",
|
|
7391
|
-
{
|
|
7392
|
-
type: "button",
|
|
7393
|
-
className: getClassName25("breadcrumbLabel"),
|
|
7394
|
-
onClick: () => setUi({ itemSelector: breadcrumb.selector }),
|
|
7395
|
-
children: breadcrumb.label
|
|
7396
|
-
}
|
|
7397
|
-
),
|
|
7398
|
-
/* @__PURE__ */ jsx37(ChevronRight, { size: 16 })
|
|
7399
|
-
] }, i)) : null,
|
|
7400
|
-
/* @__PURE__ */ jsx37("div", { className: getClassName25("heading"), children: /* @__PURE__ */ jsx37(Heading, { rank: "2", size: "xs", children: title }) })
|
|
7401
|
-
] }) }),
|
|
7402
|
-
/* @__PURE__ */ jsx37("div", { className: getClassName25("content"), children }),
|
|
7403
|
-
isLoading && /* @__PURE__ */ jsx37("div", { className: getClassName25("loadingOverlay"), children: /* @__PURE__ */ jsx37(Loader, { size: 32 }) })
|
|
7404
|
-
]
|
|
7405
|
-
}
|
|
7406
|
-
);
|
|
7407
|
-
};
|
|
7408
|
-
|
|
7409
|
-
// components/Puck/components/Canvas/index.tsx
|
|
7410
|
-
init_react_import();
|
|
7411
|
-
|
|
7412
|
-
// ../../node_modules/css-box-model/dist/css-box-model.esm.js
|
|
7413
|
-
init_react_import();
|
|
7414
|
-
|
|
7415
|
-
// ../../node_modules/tiny-invariant/dist/esm/tiny-invariant.js
|
|
7416
|
-
init_react_import();
|
|
7417
|
-
var isProduction = process.env.NODE_ENV === "production";
|
|
7418
|
-
var prefix = "Invariant failed";
|
|
7419
|
-
function invariant(condition, message) {
|
|
7420
|
-
if (condition) {
|
|
7421
|
-
return;
|
|
7422
|
-
}
|
|
7423
|
-
if (isProduction) {
|
|
7424
|
-
throw new Error(prefix);
|
|
7425
|
-
}
|
|
7426
|
-
var provided = typeof message === "function" ? message() : message;
|
|
7427
|
-
var value = provided ? "".concat(prefix, ": ").concat(provided) : prefix;
|
|
7428
|
-
throw new Error(value);
|
|
7429
|
-
}
|
|
7430
|
-
|
|
7431
|
-
// ../../node_modules/css-box-model/dist/css-box-model.esm.js
|
|
7432
|
-
var getRect = function getRect2(_ref) {
|
|
7433
|
-
var top = _ref.top, right = _ref.right, bottom = _ref.bottom, left = _ref.left;
|
|
7434
|
-
var width = right - left;
|
|
7435
|
-
var height = bottom - top;
|
|
7436
|
-
var rect = {
|
|
7437
|
-
top,
|
|
7438
|
-
right,
|
|
7439
|
-
bottom,
|
|
7440
|
-
left,
|
|
7441
|
-
width,
|
|
7442
|
-
height,
|
|
7443
|
-
x: left,
|
|
7444
|
-
y: top,
|
|
7445
|
-
center: {
|
|
7446
|
-
x: (right + left) / 2,
|
|
7447
|
-
y: (bottom + top) / 2
|
|
7448
|
-
}
|
|
7449
|
-
};
|
|
7450
|
-
return rect;
|
|
7451
|
-
};
|
|
7452
|
-
var expand = function expand2(target, expandBy) {
|
|
7453
|
-
return {
|
|
7454
|
-
top: target.top - expandBy.top,
|
|
7455
|
-
left: target.left - expandBy.left,
|
|
7456
|
-
bottom: target.bottom + expandBy.bottom,
|
|
7457
|
-
right: target.right + expandBy.right
|
|
7458
|
-
};
|
|
7459
|
-
};
|
|
7460
|
-
var shrink = function shrink2(target, shrinkBy) {
|
|
7461
|
-
return {
|
|
7462
|
-
top: target.top + shrinkBy.top,
|
|
7463
|
-
left: target.left + shrinkBy.left,
|
|
7464
|
-
bottom: target.bottom - shrinkBy.bottom,
|
|
7465
|
-
right: target.right - shrinkBy.right
|
|
7466
|
-
};
|
|
7050
|
+
var shrink = function shrink2(target, shrinkBy) {
|
|
7051
|
+
return {
|
|
7052
|
+
top: target.top + shrinkBy.top,
|
|
7053
|
+
left: target.left + shrinkBy.left,
|
|
7054
|
+
bottom: target.bottom - shrinkBy.bottom,
|
|
7055
|
+
right: target.right - shrinkBy.right
|
|
7056
|
+
};
|
|
7467
7057
|
};
|
|
7468
7058
|
var noSpacing = {
|
|
7469
7059
|
top: 0,
|
|
@@ -7530,30 +7120,30 @@ var getBox = function getBox2(el) {
|
|
|
7530
7120
|
|
|
7531
7121
|
// components/Puck/components/Canvas/index.tsx
|
|
7532
7122
|
import {
|
|
7533
|
-
useCallback as
|
|
7534
|
-
useEffect as
|
|
7535
|
-
useMemo as
|
|
7123
|
+
useCallback as useCallback15,
|
|
7124
|
+
useEffect as useEffect22,
|
|
7125
|
+
useMemo as useMemo18,
|
|
7536
7126
|
useRef as useRef7,
|
|
7537
|
-
useState as
|
|
7127
|
+
useState as useState19
|
|
7538
7128
|
} from "react";
|
|
7539
7129
|
|
|
7540
7130
|
// components/ViewportControls/index.tsx
|
|
7541
7131
|
init_react_import();
|
|
7542
|
-
import { useEffect as
|
|
7132
|
+
import { useEffect as useEffect21, useMemo as useMemo17, useState as useState18 } from "react";
|
|
7543
7133
|
|
|
7544
7134
|
// css-module:/home/runner/work/puck/puck/packages/core/components/ViewportControls/styles.module.css#css-module
|
|
7545
7135
|
init_react_import();
|
|
7546
|
-
var
|
|
7136
|
+
var styles_module_default19 = { "ViewportControls": "_ViewportControls_gejzr_1", "ViewportControls-divider": "_ViewportControls-divider_gejzr_15", "ViewportControls-zoomSelect": "_ViewportControls-zoomSelect_gejzr_21", "ViewportButton--isActive": "_ViewportButton--isActive_gejzr_38", "ViewportButton-inner": "_ViewportButton-inner_gejzr_38" };
|
|
7547
7137
|
|
|
7548
7138
|
// components/ViewportControls/index.tsx
|
|
7549
|
-
import { jsx as
|
|
7139
|
+
import { jsx as jsx35, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
7550
7140
|
var icons = {
|
|
7551
|
-
Smartphone: /* @__PURE__ */
|
|
7552
|
-
Tablet: /* @__PURE__ */
|
|
7553
|
-
Monitor: /* @__PURE__ */
|
|
7141
|
+
Smartphone: /* @__PURE__ */ jsx35(Smartphone, { size: 16 }),
|
|
7142
|
+
Tablet: /* @__PURE__ */ jsx35(Tablet, { size: 16 }),
|
|
7143
|
+
Monitor: /* @__PURE__ */ jsx35(Monitor, { size: 16 })
|
|
7554
7144
|
};
|
|
7555
|
-
var
|
|
7556
|
-
var getClassNameButton = get_class_name_factory_default("ViewportButton",
|
|
7145
|
+
var getClassName24 = get_class_name_factory_default("ViewportControls", styles_module_default19);
|
|
7146
|
+
var getClassNameButton = get_class_name_factory_default("ViewportButton", styles_module_default19);
|
|
7557
7147
|
var ViewportButton = ({
|
|
7558
7148
|
children,
|
|
7559
7149
|
height = "auto",
|
|
@@ -7562,20 +7152,21 @@ var ViewportButton = ({
|
|
|
7562
7152
|
onClick
|
|
7563
7153
|
}) => {
|
|
7564
7154
|
const viewports = useAppStore((s) => s.state.ui.viewports);
|
|
7565
|
-
const [isActive, setIsActive] =
|
|
7566
|
-
|
|
7155
|
+
const [isActive, setIsActive] = useState18(false);
|
|
7156
|
+
useEffect21(() => {
|
|
7567
7157
|
setIsActive(width === viewports.current.width);
|
|
7568
7158
|
}, [width, viewports.current.width]);
|
|
7569
|
-
return /* @__PURE__ */
|
|
7159
|
+
return /* @__PURE__ */ jsx35("span", { className: getClassNameButton({ isActive }), children: /* @__PURE__ */ jsx35(
|
|
7570
7160
|
IconButton,
|
|
7571
7161
|
{
|
|
7162
|
+
type: "button",
|
|
7572
7163
|
title,
|
|
7573
7164
|
disabled: isActive,
|
|
7574
7165
|
onClick: (e) => {
|
|
7575
7166
|
e.stopPropagation();
|
|
7576
7167
|
onClick({ width, height });
|
|
7577
7168
|
},
|
|
7578
|
-
children: /* @__PURE__ */
|
|
7169
|
+
children: /* @__PURE__ */ jsx35("span", { className: getClassNameButton("inner"), children })
|
|
7579
7170
|
}
|
|
7580
7171
|
) });
|
|
7581
7172
|
};
|
|
@@ -7599,7 +7190,7 @@ var ViewportControls = ({
|
|
|
7599
7190
|
const defaultsContainAutoZoom = defaultZoomOptions.find(
|
|
7600
7191
|
(option) => option.value === autoZoom
|
|
7601
7192
|
);
|
|
7602
|
-
const zoomOptions =
|
|
7193
|
+
const zoomOptions = useMemo17(
|
|
7603
7194
|
() => [
|
|
7604
7195
|
...defaultZoomOptions,
|
|
7605
7196
|
...defaultsContainAutoZoom ? [] : [
|
|
@@ -7611,8 +7202,8 @@ var ViewportControls = ({
|
|
|
7611
7202
|
].filter((a) => a.value <= autoZoom).sort((a, b) => a.value > b.value ? 1 : -1),
|
|
7612
7203
|
[autoZoom]
|
|
7613
7204
|
);
|
|
7614
|
-
return /* @__PURE__ */
|
|
7615
|
-
viewports.map((viewport, i) => /* @__PURE__ */
|
|
7205
|
+
return /* @__PURE__ */ jsxs16("div", { className: getClassName24(), children: [
|
|
7206
|
+
viewports.map((viewport, i) => /* @__PURE__ */ jsx35(
|
|
7616
7207
|
ViewportButton,
|
|
7617
7208
|
{
|
|
7618
7209
|
height: viewport.height,
|
|
@@ -7623,10 +7214,11 @@ var ViewportControls = ({
|
|
|
7623
7214
|
},
|
|
7624
7215
|
i
|
|
7625
7216
|
)),
|
|
7626
|
-
/* @__PURE__ */
|
|
7627
|
-
/* @__PURE__ */
|
|
7217
|
+
/* @__PURE__ */ jsx35("div", { className: getClassName24("divider") }),
|
|
7218
|
+
/* @__PURE__ */ jsx35(
|
|
7628
7219
|
IconButton,
|
|
7629
7220
|
{
|
|
7221
|
+
type: "button",
|
|
7630
7222
|
title: "Zoom viewport out",
|
|
7631
7223
|
disabled: zoom <= ((_a = zoomOptions[0]) == null ? void 0 : _a.value),
|
|
7632
7224
|
onClick: (e) => {
|
|
@@ -7638,12 +7230,13 @@ var ViewportControls = ({
|
|
|
7638
7230
|
)].value
|
|
7639
7231
|
);
|
|
7640
7232
|
},
|
|
7641
|
-
children: /* @__PURE__ */
|
|
7233
|
+
children: /* @__PURE__ */ jsx35(ZoomOut, { size: 16 })
|
|
7642
7234
|
}
|
|
7643
7235
|
),
|
|
7644
|
-
/* @__PURE__ */
|
|
7236
|
+
/* @__PURE__ */ jsx35(
|
|
7645
7237
|
IconButton,
|
|
7646
7238
|
{
|
|
7239
|
+
type: "button",
|
|
7647
7240
|
title: "Zoom viewport in",
|
|
7648
7241
|
disabled: zoom >= ((_b = zoomOptions[zoomOptions.length - 1]) == null ? void 0 : _b.value),
|
|
7649
7242
|
onClick: (e) => {
|
|
@@ -7655,19 +7248,19 @@ var ViewportControls = ({
|
|
|
7655
7248
|
)].value
|
|
7656
7249
|
);
|
|
7657
7250
|
},
|
|
7658
|
-
children: /* @__PURE__ */
|
|
7251
|
+
children: /* @__PURE__ */ jsx35(ZoomIn, { size: 16 })
|
|
7659
7252
|
}
|
|
7660
7253
|
),
|
|
7661
|
-
/* @__PURE__ */
|
|
7662
|
-
/* @__PURE__ */
|
|
7254
|
+
/* @__PURE__ */ jsx35("div", { className: getClassName24("divider") }),
|
|
7255
|
+
/* @__PURE__ */ jsx35(
|
|
7663
7256
|
"select",
|
|
7664
7257
|
{
|
|
7665
|
-
className:
|
|
7258
|
+
className: getClassName24("zoomSelect"),
|
|
7666
7259
|
value: zoom.toString(),
|
|
7667
7260
|
onChange: (e) => {
|
|
7668
7261
|
onZoom(parseFloat(e.currentTarget.value));
|
|
7669
7262
|
},
|
|
7670
|
-
children: zoomOptions.map((option) => /* @__PURE__ */
|
|
7263
|
+
children: zoomOptions.map((option) => /* @__PURE__ */ jsx35(
|
|
7671
7264
|
"option",
|
|
7672
7265
|
{
|
|
7673
7266
|
value: option.value,
|
|
@@ -7682,7 +7275,7 @@ var ViewportControls = ({
|
|
|
7682
7275
|
|
|
7683
7276
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Canvas/styles.module.css#css-module
|
|
7684
7277
|
init_react_import();
|
|
7685
|
-
var
|
|
7278
|
+
var styles_module_default20 = { "PuckCanvas": "_PuckCanvas_18jay_1", "PuckCanvas-controls": "_PuckCanvas-controls_18jay_16", "PuckCanvas-inner": "_PuckCanvas-inner_18jay_21", "PuckCanvas-root": "_PuckCanvas-root_18jay_30", "PuckCanvas--ready": "_PuckCanvas--ready_18jay_55", "PuckCanvas-loader": "_PuckCanvas-loader_18jay_60", "PuckCanvas--showLoader": "_PuckCanvas--showLoader_18jay_70" };
|
|
7686
7279
|
|
|
7687
7280
|
// lib/get-zoom-config.ts
|
|
7688
7281
|
init_react_import();
|
|
@@ -7716,8 +7309,8 @@ var getZoomConfig = (uiViewport, frame, zoom) => {
|
|
|
7716
7309
|
|
|
7717
7310
|
// components/Puck/components/Canvas/index.tsx
|
|
7718
7311
|
import { useShallow as useShallow8 } from "zustand/react/shallow";
|
|
7719
|
-
import { Fragment as
|
|
7720
|
-
var
|
|
7312
|
+
import { Fragment as Fragment11, jsx as jsx36, jsxs as jsxs17 } from "react/jsx-runtime";
|
|
7313
|
+
var getClassName25 = get_class_name_factory_default("PuckCanvas", styles_module_default20);
|
|
7721
7314
|
var ZOOM_ON_CHANGE = true;
|
|
7722
7315
|
var Canvas = () => {
|
|
7723
7316
|
const {
|
|
@@ -7747,344 +7340,585 @@ var Canvas = () => {
|
|
|
7747
7340
|
}))
|
|
7748
7341
|
);
|
|
7749
7342
|
const frameRef = useRef7(null);
|
|
7750
|
-
const [showTransition, setShowTransition] =
|
|
7751
|
-
const defaultRender =
|
|
7752
|
-
const PuckDefault = ({ children }) => /* @__PURE__ */
|
|
7343
|
+
const [showTransition, setShowTransition] = useState19(false);
|
|
7344
|
+
const defaultRender = useMemo18(() => {
|
|
7345
|
+
const PuckDefault = ({ children }) => /* @__PURE__ */ jsx36(Fragment11, { children });
|
|
7753
7346
|
return PuckDefault;
|
|
7754
7347
|
}, []);
|
|
7755
|
-
const CustomPreview =
|
|
7348
|
+
const CustomPreview = useMemo18(
|
|
7756
7349
|
() => overrides.preview || defaultRender,
|
|
7757
7350
|
[overrides]
|
|
7758
7351
|
);
|
|
7759
|
-
const getFrameDimensions =
|
|
7352
|
+
const getFrameDimensions = useCallback15(() => {
|
|
7760
7353
|
if (frameRef.current) {
|
|
7761
7354
|
const frame = frameRef.current;
|
|
7762
7355
|
const box = getBox(frame);
|
|
7763
7356
|
return { width: box.contentBox.width, height: box.contentBox.height };
|
|
7764
7357
|
}
|
|
7765
|
-
return { width: 0, height: 0 };
|
|
7766
|
-
}, [frameRef]);
|
|
7767
|
-
const resetAutoZoom =
|
|
7768
|
-
(newViewports = viewports) => {
|
|
7769
|
-
if (frameRef.current) {
|
|
7770
|
-
setZoomConfig(
|
|
7771
|
-
getZoomConfig(
|
|
7772
|
-
newViewports == null ? void 0 : newViewports.current,
|
|
7773
|
-
frameRef.current,
|
|
7774
|
-
zoomConfig.zoom
|
|
7775
|
-
)
|
|
7776
|
-
);
|
|
7777
|
-
}
|
|
7778
|
-
},
|
|
7779
|
-
[frameRef, zoomConfig, viewports]
|
|
7358
|
+
return { width: 0, height: 0 };
|
|
7359
|
+
}, [frameRef]);
|
|
7360
|
+
const resetAutoZoom = useCallback15(
|
|
7361
|
+
(newViewports = viewports) => {
|
|
7362
|
+
if (frameRef.current) {
|
|
7363
|
+
setZoomConfig(
|
|
7364
|
+
getZoomConfig(
|
|
7365
|
+
newViewports == null ? void 0 : newViewports.current,
|
|
7366
|
+
frameRef.current,
|
|
7367
|
+
zoomConfig.zoom
|
|
7368
|
+
)
|
|
7369
|
+
);
|
|
7370
|
+
}
|
|
7371
|
+
},
|
|
7372
|
+
[frameRef, zoomConfig, viewports]
|
|
7373
|
+
);
|
|
7374
|
+
useEffect22(() => {
|
|
7375
|
+
setShowTransition(false);
|
|
7376
|
+
resetAutoZoom(viewports);
|
|
7377
|
+
}, [frameRef, leftSideBarVisible, rightSideBarVisible]);
|
|
7378
|
+
useEffect22(() => {
|
|
7379
|
+
const { height: frameHeight } = getFrameDimensions();
|
|
7380
|
+
if (viewports.current.height === "auto") {
|
|
7381
|
+
setZoomConfig(__spreadProps(__spreadValues({}, zoomConfig), {
|
|
7382
|
+
rootHeight: frameHeight / zoomConfig.zoom
|
|
7383
|
+
}));
|
|
7384
|
+
}
|
|
7385
|
+
}, [zoomConfig.zoom]);
|
|
7386
|
+
useEffect22(() => {
|
|
7387
|
+
if (ZOOM_ON_CHANGE) {
|
|
7388
|
+
setShowTransition(true);
|
|
7389
|
+
resetAutoZoom(viewports);
|
|
7390
|
+
}
|
|
7391
|
+
}, [viewports.current.width]);
|
|
7392
|
+
useEffect22(() => {
|
|
7393
|
+
const cb = () => {
|
|
7394
|
+
setShowTransition(false);
|
|
7395
|
+
resetAutoZoom();
|
|
7396
|
+
};
|
|
7397
|
+
window.addEventListener("resize", cb);
|
|
7398
|
+
return () => {
|
|
7399
|
+
window.removeEventListener("resize", cb);
|
|
7400
|
+
};
|
|
7401
|
+
}, []);
|
|
7402
|
+
const [showLoader, setShowLoader] = useState19(false);
|
|
7403
|
+
useEffect22(() => {
|
|
7404
|
+
setTimeout(() => {
|
|
7405
|
+
setShowLoader(true);
|
|
7406
|
+
}, 500);
|
|
7407
|
+
}, []);
|
|
7408
|
+
return /* @__PURE__ */ jsxs17(
|
|
7409
|
+
"div",
|
|
7410
|
+
{
|
|
7411
|
+
className: getClassName25({
|
|
7412
|
+
ready: status === "READY" || !iframe.enabled || !iframe.waitForStyles,
|
|
7413
|
+
showLoader
|
|
7414
|
+
}),
|
|
7415
|
+
onClick: () => dispatch({
|
|
7416
|
+
type: "setUi",
|
|
7417
|
+
ui: { itemSelector: null },
|
|
7418
|
+
recordHistory: true
|
|
7419
|
+
}),
|
|
7420
|
+
children: [
|
|
7421
|
+
viewports.controlsVisible && iframe.enabled && /* @__PURE__ */ jsx36("div", { className: getClassName25("controls"), children: /* @__PURE__ */ jsx36(
|
|
7422
|
+
ViewportControls,
|
|
7423
|
+
{
|
|
7424
|
+
autoZoom: zoomConfig.autoZoom,
|
|
7425
|
+
zoom: zoomConfig.zoom,
|
|
7426
|
+
onViewportChange: (viewport) => {
|
|
7427
|
+
setShowTransition(true);
|
|
7428
|
+
const uiViewport = __spreadProps(__spreadValues({}, viewport), {
|
|
7429
|
+
height: viewport.height || "auto",
|
|
7430
|
+
zoom: zoomConfig.zoom
|
|
7431
|
+
});
|
|
7432
|
+
const newUi = {
|
|
7433
|
+
viewports: __spreadProps(__spreadValues({}, viewports), { current: uiViewport }),
|
|
7434
|
+
itemSelector: null
|
|
7435
|
+
};
|
|
7436
|
+
setUi(newUi);
|
|
7437
|
+
if (ZOOM_ON_CHANGE) {
|
|
7438
|
+
resetAutoZoom(__spreadProps(__spreadValues({}, viewports), { current: uiViewport }));
|
|
7439
|
+
}
|
|
7440
|
+
},
|
|
7441
|
+
onZoom: (zoom) => {
|
|
7442
|
+
setShowTransition(true);
|
|
7443
|
+
setZoomConfig(__spreadProps(__spreadValues({}, zoomConfig), { zoom }));
|
|
7444
|
+
}
|
|
7445
|
+
}
|
|
7446
|
+
) }),
|
|
7447
|
+
/* @__PURE__ */ jsxs17("div", { className: getClassName25("inner"), ref: frameRef, children: [
|
|
7448
|
+
/* @__PURE__ */ jsx36(
|
|
7449
|
+
"div",
|
|
7450
|
+
{
|
|
7451
|
+
className: getClassName25("root"),
|
|
7452
|
+
style: {
|
|
7453
|
+
width: iframe.enabled ? viewports.current.width : "100%",
|
|
7454
|
+
height: zoomConfig.rootHeight,
|
|
7455
|
+
transform: iframe.enabled ? `scale(${zoomConfig.zoom})` : void 0,
|
|
7456
|
+
transition: showTransition ? "width 150ms ease-out, height 150ms ease-out, transform 150ms ease-out" : "",
|
|
7457
|
+
overflow: iframe.enabled ? void 0 : "auto"
|
|
7458
|
+
},
|
|
7459
|
+
suppressHydrationWarning: true,
|
|
7460
|
+
id: "puck-canvas-root",
|
|
7461
|
+
onTransitionEnd: () => {
|
|
7462
|
+
window.dispatchEvent(
|
|
7463
|
+
new CustomEvent("viewportchange", {
|
|
7464
|
+
bubbles: true,
|
|
7465
|
+
cancelable: false
|
|
7466
|
+
})
|
|
7467
|
+
);
|
|
7468
|
+
},
|
|
7469
|
+
children: /* @__PURE__ */ jsx36(CustomPreview, { children: /* @__PURE__ */ jsx36(Preview2, {}) })
|
|
7470
|
+
}
|
|
7471
|
+
),
|
|
7472
|
+
/* @__PURE__ */ jsx36("div", { className: getClassName25("loader"), children: /* @__PURE__ */ jsx36(Loader, { size: 24 }) })
|
|
7473
|
+
] })
|
|
7474
|
+
]
|
|
7475
|
+
}
|
|
7476
|
+
);
|
|
7477
|
+
};
|
|
7478
|
+
|
|
7479
|
+
// lib/use-loaded-overrides.ts
|
|
7480
|
+
init_react_import();
|
|
7481
|
+
import { useMemo as useMemo19 } from "react";
|
|
7482
|
+
|
|
7483
|
+
// lib/load-overrides.ts
|
|
7484
|
+
init_react_import();
|
|
7485
|
+
var loadOverrides = ({
|
|
7486
|
+
overrides,
|
|
7487
|
+
plugins
|
|
7488
|
+
}) => {
|
|
7489
|
+
const collected = __spreadValues({}, overrides);
|
|
7490
|
+
plugins == null ? void 0 : plugins.forEach((plugin) => {
|
|
7491
|
+
Object.keys(plugin.overrides).forEach((_overridesType) => {
|
|
7492
|
+
const overridesType = _overridesType;
|
|
7493
|
+
if (overridesType === "fieldTypes") {
|
|
7494
|
+
const fieldTypes = plugin.overrides.fieldTypes;
|
|
7495
|
+
Object.keys(fieldTypes).forEach((fieldType) => {
|
|
7496
|
+
collected.fieldTypes = collected.fieldTypes || {};
|
|
7497
|
+
const childNode2 = collected.fieldTypes[fieldType];
|
|
7498
|
+
const Comp2 = (props) => fieldTypes[fieldType](__spreadProps(__spreadValues({}, props), {
|
|
7499
|
+
children: childNode2 ? childNode2(props) : props.children
|
|
7500
|
+
}));
|
|
7501
|
+
collected.fieldTypes[fieldType] = Comp2;
|
|
7502
|
+
});
|
|
7503
|
+
return;
|
|
7504
|
+
}
|
|
7505
|
+
const childNode = collected[overridesType];
|
|
7506
|
+
const Comp = (props) => plugin.overrides[overridesType](__spreadProps(__spreadValues({}, props), {
|
|
7507
|
+
children: childNode ? childNode(props) : props.children
|
|
7508
|
+
}));
|
|
7509
|
+
collected[overridesType] = Comp;
|
|
7510
|
+
});
|
|
7511
|
+
});
|
|
7512
|
+
return collected;
|
|
7513
|
+
};
|
|
7514
|
+
|
|
7515
|
+
// lib/use-loaded-overrides.ts
|
|
7516
|
+
var useLoadedOverrides = ({
|
|
7517
|
+
overrides,
|
|
7518
|
+
plugins
|
|
7519
|
+
}) => {
|
|
7520
|
+
return useMemo19(() => {
|
|
7521
|
+
return loadOverrides({ overrides, plugins });
|
|
7522
|
+
}, [plugins, overrides]);
|
|
7523
|
+
};
|
|
7524
|
+
|
|
7525
|
+
// components/DefaultOverride/index.tsx
|
|
7526
|
+
init_react_import();
|
|
7527
|
+
import { Fragment as Fragment12, jsx as jsx37 } from "react/jsx-runtime";
|
|
7528
|
+
var DefaultOverride = ({ children }) => /* @__PURE__ */ jsx37(Fragment12, { children });
|
|
7529
|
+
|
|
7530
|
+
// lib/use-inject-css.ts
|
|
7531
|
+
init_react_import();
|
|
7532
|
+
import { useEffect as useEffect23, useState as useState20 } from "react";
|
|
7533
|
+
var styles = ``;
|
|
7534
|
+
var useInjectStyleSheet = (initialStyles, iframeEnabled) => {
|
|
7535
|
+
const [el, setEl] = useState20();
|
|
7536
|
+
useEffect23(() => {
|
|
7537
|
+
setEl(document.createElement("style"));
|
|
7538
|
+
}, []);
|
|
7539
|
+
useEffect23(() => {
|
|
7540
|
+
var _a;
|
|
7541
|
+
if (!el || typeof window === "undefined") {
|
|
7542
|
+
return;
|
|
7543
|
+
}
|
|
7544
|
+
el.innerHTML = initialStyles;
|
|
7545
|
+
if (iframeEnabled) {
|
|
7546
|
+
const frame = getFrame();
|
|
7547
|
+
(_a = frame == null ? void 0 : frame.head) == null ? void 0 : _a.appendChild(el);
|
|
7548
|
+
}
|
|
7549
|
+
document.head.appendChild(el);
|
|
7550
|
+
}, [iframeEnabled, el]);
|
|
7551
|
+
return el;
|
|
7552
|
+
};
|
|
7553
|
+
var useInjectGlobalCss = (iframeEnabled) => {
|
|
7554
|
+
return useInjectStyleSheet(styles, iframeEnabled);
|
|
7555
|
+
};
|
|
7556
|
+
|
|
7557
|
+
// lib/use-preview-mode-hotkeys.ts
|
|
7558
|
+
init_react_import();
|
|
7559
|
+
import { useCallback as useCallback16 } from "react";
|
|
7560
|
+
var usePreviewModeHotkeys = () => {
|
|
7561
|
+
const appStore = useAppStoreApi();
|
|
7562
|
+
const toggleInteractive = useCallback16(() => {
|
|
7563
|
+
const dispatch = appStore.getState().dispatch;
|
|
7564
|
+
dispatch({
|
|
7565
|
+
type: "setUi",
|
|
7566
|
+
ui: (ui) => ({
|
|
7567
|
+
previewMode: ui.previewMode === "edit" ? "interactive" : "edit"
|
|
7568
|
+
})
|
|
7569
|
+
});
|
|
7570
|
+
}, [appStore]);
|
|
7571
|
+
useHotkey({ meta: true, i: true }, toggleInteractive);
|
|
7572
|
+
useHotkey({ ctrl: true, i: true }, toggleInteractive);
|
|
7573
|
+
};
|
|
7574
|
+
|
|
7575
|
+
// lib/use-puck.ts
|
|
7576
|
+
init_react_import();
|
|
7577
|
+
import { createContext as createContext6, useContext as useContext11, useEffect as useEffect24, useState as useState21 } from "react";
|
|
7578
|
+
import { createStore as createStore4, useStore as useStore3 } from "zustand";
|
|
7579
|
+
var generateUsePuck = (store) => {
|
|
7580
|
+
const history = {
|
|
7581
|
+
back: store.history.back,
|
|
7582
|
+
forward: store.history.forward,
|
|
7583
|
+
setHistories: store.history.setHistories,
|
|
7584
|
+
setHistoryIndex: store.history.setHistoryIndex,
|
|
7585
|
+
hasPast: store.history.hasPast(),
|
|
7586
|
+
hasFuture: store.history.hasFuture(),
|
|
7587
|
+
histories: store.history.histories,
|
|
7588
|
+
index: store.history.index
|
|
7589
|
+
};
|
|
7590
|
+
const storeData = {
|
|
7591
|
+
appState: makeStatePublic(store.state),
|
|
7592
|
+
config: store.config,
|
|
7593
|
+
dispatch: store.dispatch,
|
|
7594
|
+
getPermissions: store.permissions.getPermissions,
|
|
7595
|
+
refreshPermissions: store.permissions.refreshPermissions,
|
|
7596
|
+
history,
|
|
7597
|
+
selectedItem: store.selectedItem || null,
|
|
7598
|
+
getItemBySelector: (selector) => getItem(selector, store.state),
|
|
7599
|
+
getItemById: (id) => store.state.indexes.nodes[id].data,
|
|
7600
|
+
getSelectorForId: (id) => {
|
|
7601
|
+
const node = store.state.indexes.nodes[id];
|
|
7602
|
+
if (!node) return;
|
|
7603
|
+
const zoneCompound = `${node.parentId}:${node.zone}`;
|
|
7604
|
+
const index = store.state.indexes.zones[zoneCompound].contentIds.indexOf(id);
|
|
7605
|
+
return { zone: zoneCompound, index };
|
|
7606
|
+
}
|
|
7607
|
+
};
|
|
7608
|
+
const get = () => storeData;
|
|
7609
|
+
return __spreadProps(__spreadValues({}, storeData), { get });
|
|
7610
|
+
};
|
|
7611
|
+
var UsePuckStoreContext = createContext6(
|
|
7612
|
+
null
|
|
7613
|
+
);
|
|
7614
|
+
var convertToPickedStore = (store) => {
|
|
7615
|
+
return {
|
|
7616
|
+
state: store.state,
|
|
7617
|
+
config: store.config,
|
|
7618
|
+
dispatch: store.dispatch,
|
|
7619
|
+
permissions: store.permissions,
|
|
7620
|
+
history: store.history,
|
|
7621
|
+
selectedItem: store.selectedItem
|
|
7622
|
+
};
|
|
7623
|
+
};
|
|
7624
|
+
var useRegisterUsePuckStore = (appStore) => {
|
|
7625
|
+
const [usePuckStore] = useState21(
|
|
7626
|
+
() => createStore4(
|
|
7627
|
+
() => generateUsePuck(convertToPickedStore(appStore.getState()))
|
|
7628
|
+
)
|
|
7780
7629
|
);
|
|
7781
7630
|
useEffect24(() => {
|
|
7782
|
-
|
|
7783
|
-
|
|
7784
|
-
|
|
7785
|
-
|
|
7786
|
-
|
|
7787
|
-
|
|
7788
|
-
setZoomConfig(__spreadProps(__spreadValues({}, zoomConfig), {
|
|
7789
|
-
rootHeight: frameHeight / zoomConfig.zoom
|
|
7790
|
-
}));
|
|
7791
|
-
}
|
|
7792
|
-
}, [zoomConfig.zoom]);
|
|
7793
|
-
useEffect24(() => {
|
|
7794
|
-
if (ZOOM_ON_CHANGE) {
|
|
7795
|
-
setShowTransition(true);
|
|
7796
|
-
resetAutoZoom(viewports);
|
|
7797
|
-
}
|
|
7798
|
-
}, [viewports.current.width]);
|
|
7799
|
-
useEffect24(() => {
|
|
7800
|
-
const cb = () => {
|
|
7801
|
-
setShowTransition(false);
|
|
7802
|
-
resetAutoZoom();
|
|
7803
|
-
};
|
|
7804
|
-
window.addEventListener("resize", cb);
|
|
7805
|
-
return () => {
|
|
7806
|
-
window.removeEventListener("resize", cb);
|
|
7807
|
-
};
|
|
7631
|
+
return appStore.subscribe(
|
|
7632
|
+
(store) => convertToPickedStore(store),
|
|
7633
|
+
(pickedStore) => {
|
|
7634
|
+
usePuckStore.setState(generateUsePuck(pickedStore));
|
|
7635
|
+
}
|
|
7636
|
+
);
|
|
7808
7637
|
}, []);
|
|
7809
|
-
|
|
7638
|
+
return usePuckStore;
|
|
7639
|
+
};
|
|
7640
|
+
function createUsePuck() {
|
|
7641
|
+
return function usePuck2(selector) {
|
|
7642
|
+
const usePuckApi = useContext11(UsePuckStoreContext);
|
|
7643
|
+
if (!usePuckApi) {
|
|
7644
|
+
throw new Error("usePuck must be used inside <Puck>.");
|
|
7645
|
+
}
|
|
7646
|
+
const result = useStore3(
|
|
7647
|
+
usePuckApi,
|
|
7648
|
+
selector != null ? selector : (s) => s
|
|
7649
|
+
);
|
|
7650
|
+
return result;
|
|
7651
|
+
};
|
|
7652
|
+
}
|
|
7653
|
+
function usePuck() {
|
|
7810
7654
|
useEffect24(() => {
|
|
7811
|
-
|
|
7812
|
-
|
|
7813
|
-
|
|
7655
|
+
console.warn(
|
|
7656
|
+
"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."
|
|
7657
|
+
);
|
|
7814
7658
|
}, []);
|
|
7815
|
-
return
|
|
7659
|
+
return createUsePuck()((s) => s);
|
|
7660
|
+
}
|
|
7661
|
+
function useGetPuck() {
|
|
7662
|
+
const usePuckApi = useContext11(UsePuckStoreContext);
|
|
7663
|
+
if (!usePuckApi) {
|
|
7664
|
+
throw new Error("usePuckGet must be used inside <Puck>.");
|
|
7665
|
+
}
|
|
7666
|
+
return usePuckApi.getState;
|
|
7667
|
+
}
|
|
7668
|
+
|
|
7669
|
+
// components/Puck/index.tsx
|
|
7670
|
+
import fdeq from "fast-deep-equal";
|
|
7671
|
+
|
|
7672
|
+
// components/Puck/components/Header/index.tsx
|
|
7673
|
+
init_react_import();
|
|
7674
|
+
import { memo as memo3, useCallback as useCallback17, useMemo as useMemo20, useState as useState22 } from "react";
|
|
7675
|
+
|
|
7676
|
+
// components/MenuBar/index.tsx
|
|
7677
|
+
init_react_import();
|
|
7678
|
+
|
|
7679
|
+
// css-module:/home/runner/work/puck/puck/packages/core/components/MenuBar/styles.module.css#css-module
|
|
7680
|
+
init_react_import();
|
|
7681
|
+
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" };
|
|
7682
|
+
|
|
7683
|
+
// components/MenuBar/index.tsx
|
|
7684
|
+
import { Fragment as Fragment13, jsx as jsx38, jsxs as jsxs18 } from "react/jsx-runtime";
|
|
7685
|
+
var getClassName26 = get_class_name_factory_default("MenuBar", styles_module_default21);
|
|
7686
|
+
function MenuBar({
|
|
7687
|
+
menuOpen = false,
|
|
7688
|
+
renderHeaderActions,
|
|
7689
|
+
setMenuOpen
|
|
7690
|
+
}) {
|
|
7691
|
+
const back = useAppStore((s) => s.history.back);
|
|
7692
|
+
const forward = useAppStore((s) => s.history.forward);
|
|
7693
|
+
const hasFuture = useAppStore((s) => s.history.hasFuture());
|
|
7694
|
+
const hasPast = useAppStore((s) => s.history.hasPast());
|
|
7695
|
+
return /* @__PURE__ */ jsx38(
|
|
7816
7696
|
"div",
|
|
7817
7697
|
{
|
|
7818
|
-
className:
|
|
7819
|
-
|
|
7820
|
-
|
|
7821
|
-
|
|
7822
|
-
|
|
7823
|
-
|
|
7824
|
-
|
|
7825
|
-
|
|
7826
|
-
|
|
7827
|
-
|
|
7828
|
-
|
|
7829
|
-
|
|
7830
|
-
|
|
7831
|
-
|
|
7832
|
-
|
|
7833
|
-
onViewportChange: (viewport) => {
|
|
7834
|
-
setShowTransition(true);
|
|
7835
|
-
const uiViewport = __spreadProps(__spreadValues({}, viewport), {
|
|
7836
|
-
height: viewport.height || "auto",
|
|
7837
|
-
zoom: zoomConfig.zoom
|
|
7838
|
-
});
|
|
7839
|
-
const newUi = {
|
|
7840
|
-
viewports: __spreadProps(__spreadValues({}, viewports), { current: uiViewport }),
|
|
7841
|
-
itemSelector: null
|
|
7842
|
-
};
|
|
7843
|
-
setUi(newUi);
|
|
7844
|
-
if (ZOOM_ON_CHANGE) {
|
|
7845
|
-
resetAutoZoom(__spreadProps(__spreadValues({}, viewports), { current: uiViewport }));
|
|
7846
|
-
}
|
|
7847
|
-
},
|
|
7848
|
-
onZoom: (zoom) => {
|
|
7849
|
-
setShowTransition(true);
|
|
7850
|
-
setZoomConfig(__spreadProps(__spreadValues({}, zoomConfig), { zoom }));
|
|
7851
|
-
}
|
|
7852
|
-
}
|
|
7853
|
-
) }),
|
|
7854
|
-
/* @__PURE__ */ jsxs19("div", { className: getClassName27("inner"), ref: frameRef, children: [
|
|
7855
|
-
/* @__PURE__ */ jsx39(
|
|
7856
|
-
"div",
|
|
7698
|
+
className: getClassName26({ menuOpen }),
|
|
7699
|
+
onClick: (event) => {
|
|
7700
|
+
var _a;
|
|
7701
|
+
const element = event.target;
|
|
7702
|
+
if (window.matchMedia("(min-width: 638px)").matches) {
|
|
7703
|
+
return;
|
|
7704
|
+
}
|
|
7705
|
+
if (element.tagName === "A" && ((_a = element.getAttribute("href")) == null ? void 0 : _a.startsWith("#"))) {
|
|
7706
|
+
setMenuOpen(false);
|
|
7707
|
+
}
|
|
7708
|
+
},
|
|
7709
|
+
children: /* @__PURE__ */ jsxs18("div", { className: getClassName26("inner"), children: [
|
|
7710
|
+
/* @__PURE__ */ jsxs18("div", { className: getClassName26("history"), children: [
|
|
7711
|
+
/* @__PURE__ */ jsx38(
|
|
7712
|
+
IconButton,
|
|
7857
7713
|
{
|
|
7858
|
-
|
|
7859
|
-
|
|
7860
|
-
|
|
7861
|
-
|
|
7862
|
-
|
|
7863
|
-
transition: showTransition ? "width 150ms ease-out, height 150ms ease-out, transform 150ms ease-out" : "",
|
|
7864
|
-
overflow: iframe.enabled ? void 0 : "auto"
|
|
7865
|
-
},
|
|
7866
|
-
suppressHydrationWarning: true,
|
|
7867
|
-
id: "puck-canvas-root",
|
|
7868
|
-
onTransitionEnd: () => {
|
|
7869
|
-
window.dispatchEvent(
|
|
7870
|
-
new CustomEvent("viewportchange", {
|
|
7871
|
-
bubbles: true,
|
|
7872
|
-
cancelable: false
|
|
7873
|
-
})
|
|
7874
|
-
);
|
|
7875
|
-
},
|
|
7876
|
-
children: /* @__PURE__ */ jsx39(CustomPreview, { children: /* @__PURE__ */ jsx39(Preview2, {}) })
|
|
7714
|
+
type: "button",
|
|
7715
|
+
title: "undo",
|
|
7716
|
+
disabled: !hasPast,
|
|
7717
|
+
onClick: back,
|
|
7718
|
+
children: /* @__PURE__ */ jsx38(Undo2, { size: 21 })
|
|
7877
7719
|
}
|
|
7878
7720
|
),
|
|
7879
|
-
/* @__PURE__ */
|
|
7880
|
-
|
|
7881
|
-
|
|
7721
|
+
/* @__PURE__ */ jsx38(
|
|
7722
|
+
IconButton,
|
|
7723
|
+
{
|
|
7724
|
+
type: "button",
|
|
7725
|
+
title: "redo",
|
|
7726
|
+
disabled: !hasFuture,
|
|
7727
|
+
onClick: forward,
|
|
7728
|
+
children: /* @__PURE__ */ jsx38(Redo2, { size: 21 })
|
|
7729
|
+
}
|
|
7730
|
+
)
|
|
7731
|
+
] }),
|
|
7732
|
+
/* @__PURE__ */ jsx38(Fragment13, { children: renderHeaderActions && renderHeaderActions() })
|
|
7733
|
+
] })
|
|
7882
7734
|
}
|
|
7883
7735
|
);
|
|
7884
|
-
}
|
|
7885
|
-
|
|
7886
|
-
// components/Puck/components/Nav/index.tsx
|
|
7887
|
-
init_react_import();
|
|
7736
|
+
}
|
|
7888
7737
|
|
|
7889
|
-
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/
|
|
7738
|
+
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Header/styles.module.css#css-module
|
|
7890
7739
|
init_react_import();
|
|
7891
|
-
var
|
|
7892
|
-
|
|
7893
|
-
// components/Puck/components/Nav/index.tsx
|
|
7894
|
-
import { jsx as jsx40, jsxs as jsxs20 } from "react/jsx-runtime";
|
|
7895
|
-
var getClassName28 = get_class_name_factory_default("Nav", styles_module_default23);
|
|
7896
|
-
var getClassNameSection = get_class_name_factory_default("NavSection", styles_module_default23);
|
|
7897
|
-
var getClassNameItem3 = get_class_name_factory_default("NavItem", styles_module_default23);
|
|
7898
|
-
var MenuItem = ({
|
|
7899
|
-
label,
|
|
7900
|
-
icon,
|
|
7901
|
-
items,
|
|
7902
|
-
onClick,
|
|
7903
|
-
isActive
|
|
7904
|
-
}) => {
|
|
7905
|
-
const showChildren = isActive;
|
|
7906
|
-
return /* @__PURE__ */ jsxs20("li", { className: getClassNameItem3({ active: isActive }), children: [
|
|
7907
|
-
onClick && /* @__PURE__ */ jsxs20("div", { className: getClassNameItem3("link"), onClick, children: [
|
|
7908
|
-
icon && /* @__PURE__ */ jsx40("span", { className: getClassNameItem3("linkIcon"), children: icon }),
|
|
7909
|
-
/* @__PURE__ */ jsx40("span", { className: getClassNameItem3("linkLabel"), children: label })
|
|
7910
|
-
] }),
|
|
7911
|
-
items && showChildren && /* @__PURE__ */ jsx40("ul", { className: getClassNameItem3("list"), children: Object.entries(items).map(([key, item]) => /* @__PURE__ */ jsx40(MenuItem, __spreadValues({}, item), key)) })
|
|
7912
|
-
] });
|
|
7913
|
-
};
|
|
7914
|
-
var NavSection = ({ title, items }) => {
|
|
7915
|
-
return /* @__PURE__ */ jsxs20("li", { className: getClassNameSection(), children: [
|
|
7916
|
-
title && /* @__PURE__ */ jsx40("div", { className: getClassNameSection("title"), children: title }),
|
|
7917
|
-
/* @__PURE__ */ jsx40("ul", { className: getClassNameSection("list"), children: Object.entries(items).map(([key, item]) => /* @__PURE__ */ jsx40(MenuItem, __spreadValues({}, item), key)) })
|
|
7918
|
-
] });
|
|
7919
|
-
};
|
|
7920
|
-
var Nav = ({
|
|
7921
|
-
navigation,
|
|
7922
|
-
slim
|
|
7923
|
-
}) => {
|
|
7924
|
-
return /* @__PURE__ */ jsx40("nav", { className: getClassName28({ slim }), children: /* @__PURE__ */ jsx40("ul", { className: getClassName28("list"), children: Object.entries(navigation).map(([key, section]) => {
|
|
7925
|
-
return /* @__PURE__ */ jsx40(NavSection, { title: section.title, items: section.items }, key);
|
|
7926
|
-
}) }) });
|
|
7927
|
-
};
|
|
7740
|
+
var styles_module_default22 = { "PuckHeader": "_PuckHeader_15xnq_1", "PuckHeader-inner": "_PuckHeader-inner_15xnq_10", "PuckHeader-toggle": "_PuckHeader-toggle_15xnq_20", "PuckHeader--rightSideBarVisible": "_PuckHeader--rightSideBarVisible_15xnq_27", "PuckHeader-rightSideBarToggle": "_PuckHeader-rightSideBarToggle_15xnq_27", "PuckHeader--leftSideBarVisible": "_PuckHeader--leftSideBarVisible_15xnq_28", "PuckHeader-leftSideBarToggle": "_PuckHeader-leftSideBarToggle_15xnq_28", "PuckHeader-title": "_PuckHeader-title_15xnq_32", "PuckHeader-path": "_PuckHeader-path_15xnq_36", "PuckHeader-tools": "_PuckHeader-tools_15xnq_43", "PuckHeader-menuButton": "_PuckHeader-menuButton_15xnq_49", "PuckHeader--menuOpen": "_PuckHeader--menuOpen_15xnq_54" };
|
|
7928
7741
|
|
|
7929
|
-
// components/Puck/components/
|
|
7930
|
-
import { jsx as
|
|
7931
|
-
var
|
|
7932
|
-
var
|
|
7933
|
-
|
|
7934
|
-
|
|
7935
|
-
|
|
7936
|
-
|
|
7937
|
-
|
|
7742
|
+
// components/Puck/components/Header/index.tsx
|
|
7743
|
+
import { Fragment as Fragment14, jsx as jsx39, jsxs as jsxs19 } from "react/jsx-runtime";
|
|
7744
|
+
var getClassName27 = get_class_name_factory_default("PuckHeader", styles_module_default22);
|
|
7745
|
+
var HeaderInner = () => {
|
|
7746
|
+
const {
|
|
7747
|
+
onPublish,
|
|
7748
|
+
renderHeader,
|
|
7749
|
+
renderHeaderActions,
|
|
7750
|
+
headerTitle,
|
|
7751
|
+
headerPath,
|
|
7752
|
+
iframe: _iframe
|
|
7753
|
+
} = usePropsContext();
|
|
7754
|
+
const dispatch = useAppStore((s) => s.dispatch);
|
|
7755
|
+
const appStore = useAppStoreApi();
|
|
7756
|
+
const defaultHeaderRender = useMemo20(() => {
|
|
7757
|
+
if (renderHeader) {
|
|
7758
|
+
console.warn(
|
|
7759
|
+
"`renderHeader` is deprecated. Please use `overrides.header` and the `usePuck` hook instead"
|
|
7760
|
+
);
|
|
7761
|
+
const RenderHeader = (_a) => {
|
|
7762
|
+
var _b = _a, { actions } = _b, props = __objRest(_b, ["actions"]);
|
|
7763
|
+
const Comp = renderHeader;
|
|
7764
|
+
const appState = useAppStore((s) => s.state);
|
|
7765
|
+
return /* @__PURE__ */ jsx39(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState, children: actions }));
|
|
7766
|
+
};
|
|
7767
|
+
return RenderHeader;
|
|
7768
|
+
}
|
|
7769
|
+
return DefaultOverride;
|
|
7770
|
+
}, [renderHeader]);
|
|
7771
|
+
const defaultHeaderActionsRender = useMemo20(() => {
|
|
7772
|
+
if (renderHeaderActions) {
|
|
7773
|
+
console.warn(
|
|
7774
|
+
"`renderHeaderActions` is deprecated. Please use `overrides.headerActions` and the `usePuck` hook instead."
|
|
7775
|
+
);
|
|
7776
|
+
const RenderHeader = (props) => {
|
|
7777
|
+
const Comp = renderHeaderActions;
|
|
7778
|
+
const appState = useAppStore((s) => s.state);
|
|
7779
|
+
return /* @__PURE__ */ jsx39(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState }));
|
|
7780
|
+
};
|
|
7781
|
+
return RenderHeader;
|
|
7938
7782
|
}
|
|
7783
|
+
return DefaultOverride;
|
|
7784
|
+
}, [renderHeader]);
|
|
7785
|
+
const CustomHeader = useAppStore(
|
|
7786
|
+
(s) => s.overrides.header || defaultHeaderRender
|
|
7939
7787
|
);
|
|
7940
|
-
|
|
7941
|
-
|
|
7942
|
-
var Layout = ({ children }) => {
|
|
7943
|
-
const {
|
|
7944
|
-
iframe: _iframe,
|
|
7945
|
-
dnd,
|
|
7946
|
-
initialHistory: _initialHistory,
|
|
7947
|
-
plugins
|
|
7948
|
-
} = usePropsContext();
|
|
7949
|
-
const iframe = useMemo21(
|
|
7950
|
-
() => __spreadValues({
|
|
7951
|
-
enabled: true,
|
|
7952
|
-
waitForStyles: true
|
|
7953
|
-
}, _iframe),
|
|
7954
|
-
[_iframe]
|
|
7788
|
+
const CustomHeaderActions = useAppStore(
|
|
7789
|
+
(s) => s.overrides.headerActions || defaultHeaderActionsRender
|
|
7955
7790
|
);
|
|
7956
|
-
|
|
7791
|
+
const [menuOpen, setMenuOpen] = useState22(false);
|
|
7792
|
+
const rootTitle = useAppStore((s) => {
|
|
7793
|
+
var _a, _b;
|
|
7794
|
+
const rootData = (_a = s.state.indexes.nodes["root"]) == null ? void 0 : _a.data;
|
|
7795
|
+
return (_b = rootData.props.title) != null ? _b : "";
|
|
7796
|
+
});
|
|
7957
7797
|
const leftSideBarVisible = useAppStore((s) => s.state.ui.leftSideBarVisible);
|
|
7958
7798
|
const rightSideBarVisible = useAppStore(
|
|
7959
7799
|
(s) => s.state.ui.rightSideBarVisible
|
|
7960
7800
|
);
|
|
7961
|
-
const
|
|
7962
|
-
|
|
7963
|
-
|
|
7801
|
+
const toggleSidebars = useCallback17(
|
|
7802
|
+
(sidebar) => {
|
|
7803
|
+
const widerViewport = window.matchMedia("(min-width: 638px)").matches;
|
|
7804
|
+
const sideBarVisible = sidebar === "left" ? leftSideBarVisible : rightSideBarVisible;
|
|
7805
|
+
const oppositeSideBar = sidebar === "left" ? "rightSideBarVisible" : "leftSideBarVisible";
|
|
7964
7806
|
dispatch({
|
|
7965
7807
|
type: "setUi",
|
|
7966
|
-
ui: {
|
|
7967
|
-
|
|
7968
|
-
|
|
7969
|
-
}
|
|
7808
|
+
ui: __spreadValues({
|
|
7809
|
+
[`${sidebar}SideBarVisible`]: !sideBarVisible
|
|
7810
|
+
}, !widerViewport ? { [oppositeSideBar]: false } : {})
|
|
7970
7811
|
});
|
|
7971
|
-
}
|
|
7972
|
-
|
|
7973
|
-
if (!window.matchMedia("(min-width: 638px)").matches) {
|
|
7974
|
-
dispatch({
|
|
7975
|
-
type: "setUi",
|
|
7976
|
-
ui: (ui) => __spreadValues(__spreadValues({}, ui), ui.rightSideBarVisible ? { leftSideBarVisible: false } : {})
|
|
7977
|
-
});
|
|
7978
|
-
}
|
|
7979
|
-
};
|
|
7980
|
-
window.addEventListener("resize", handleResize);
|
|
7981
|
-
return () => {
|
|
7982
|
-
window.removeEventListener("resize", handleResize);
|
|
7983
|
-
};
|
|
7984
|
-
}, []);
|
|
7985
|
-
const overrides = useAppStore((s) => s.overrides);
|
|
7986
|
-
const CustomPuck = useMemo21(
|
|
7987
|
-
() => overrides.puck || DefaultOverride,
|
|
7988
|
-
[overrides]
|
|
7812
|
+
},
|
|
7813
|
+
[dispatch, leftSideBarVisible, rightSideBarVisible]
|
|
7989
7814
|
);
|
|
7990
|
-
|
|
7991
|
-
|
|
7992
|
-
|
|
7993
|
-
|
|
7994
|
-
|
|
7995
|
-
|
|
7996
|
-
useEffect25(() => {
|
|
7997
|
-
if (ready && iframe.enabled) {
|
|
7998
|
-
const frameDoc = getFrame();
|
|
7999
|
-
if (frameDoc) {
|
|
8000
|
-
return monitorHotkeys(frameDoc);
|
|
8001
|
-
}
|
|
8002
|
-
}
|
|
8003
|
-
}, [ready, iframe.enabled]);
|
|
8004
|
-
usePreviewModeHotkeys();
|
|
8005
|
-
const [view, setView] = useState23("blocks");
|
|
8006
|
-
const pluginItems = useMemo21(() => {
|
|
8007
|
-
const details = {};
|
|
8008
|
-
plugins == null ? void 0 : plugins.forEach((plugin) => {
|
|
8009
|
-
var _a, _b;
|
|
8010
|
-
if (plugin.name && plugin.render) {
|
|
8011
|
-
details[plugin.name] = {
|
|
8012
|
-
label: (_a = plugin.label) != null ? _a : plugin.name,
|
|
8013
|
-
icon: (_b = plugin.icon) != null ? _b : /* @__PURE__ */ jsx41(ToyBrick, {}),
|
|
7815
|
+
return /* @__PURE__ */ jsx39(
|
|
7816
|
+
CustomHeader,
|
|
7817
|
+
{
|
|
7818
|
+
actions: /* @__PURE__ */ jsx39(Fragment14, { children: /* @__PURE__ */ jsx39(CustomHeaderActions, { children: /* @__PURE__ */ jsx39(
|
|
7819
|
+
Button,
|
|
7820
|
+
{
|
|
8014
7821
|
onClick: () => {
|
|
8015
|
-
|
|
7822
|
+
const data = appStore.getState().state.data;
|
|
7823
|
+
onPublish && onPublish(data);
|
|
8016
7824
|
},
|
|
8017
|
-
|
|
8018
|
-
|
|
8019
|
-
}
|
|
8020
|
-
}
|
|
8021
|
-
|
|
8022
|
-
|
|
8023
|
-
|
|
8024
|
-
|
|
8025
|
-
|
|
8026
|
-
|
|
8027
|
-
|
|
8028
|
-
|
|
8029
|
-
|
|
8030
|
-
|
|
8031
|
-
|
|
8032
|
-
|
|
8033
|
-
|
|
8034
|
-
|
|
8035
|
-
|
|
8036
|
-
|
|
8037
|
-
|
|
8038
|
-
|
|
8039
|
-
|
|
8040
|
-
|
|
8041
|
-
|
|
8042
|
-
|
|
8043
|
-
|
|
8044
|
-
|
|
8045
|
-
|
|
8046
|
-
|
|
8047
|
-
|
|
8048
|
-
|
|
8049
|
-
|
|
8050
|
-
|
|
8051
|
-
|
|
8052
|
-
|
|
8053
|
-
|
|
8054
|
-
|
|
8055
|
-
|
|
8056
|
-
|
|
8057
|
-
|
|
8058
|
-
|
|
8059
|
-
|
|
8060
|
-
|
|
8061
|
-
|
|
8062
|
-
|
|
7825
|
+
icon: /* @__PURE__ */ jsx39(Globe, { size: "14px" }),
|
|
7826
|
+
children: "Publish"
|
|
7827
|
+
}
|
|
7828
|
+
) }) }),
|
|
7829
|
+
children: /* @__PURE__ */ jsx39(
|
|
7830
|
+
"header",
|
|
7831
|
+
{
|
|
7832
|
+
className: getClassName27({ leftSideBarVisible, rightSideBarVisible }),
|
|
7833
|
+
children: /* @__PURE__ */ jsxs19("div", { className: getClassName27("inner"), children: [
|
|
7834
|
+
/* @__PURE__ */ jsxs19("div", { className: getClassName27("toggle"), children: [
|
|
7835
|
+
/* @__PURE__ */ jsx39("div", { className: getClassName27("leftSideBarToggle"), children: /* @__PURE__ */ jsx39(
|
|
7836
|
+
IconButton,
|
|
7837
|
+
{
|
|
7838
|
+
type: "button",
|
|
7839
|
+
onClick: () => {
|
|
7840
|
+
toggleSidebars("left");
|
|
7841
|
+
},
|
|
7842
|
+
title: "Toggle left sidebar",
|
|
7843
|
+
children: /* @__PURE__ */ jsx39(PanelLeft, { focusable: "false" })
|
|
7844
|
+
}
|
|
7845
|
+
) }),
|
|
7846
|
+
/* @__PURE__ */ jsx39("div", { className: getClassName27("rightSideBarToggle"), children: /* @__PURE__ */ jsx39(
|
|
7847
|
+
IconButton,
|
|
7848
|
+
{
|
|
7849
|
+
type: "button",
|
|
7850
|
+
onClick: () => {
|
|
7851
|
+
toggleSidebars("right");
|
|
7852
|
+
},
|
|
7853
|
+
title: "Toggle right sidebar",
|
|
7854
|
+
children: /* @__PURE__ */ jsx39(PanelRight, { focusable: "false" })
|
|
7855
|
+
}
|
|
7856
|
+
) })
|
|
7857
|
+
] }),
|
|
7858
|
+
/* @__PURE__ */ jsx39("div", { className: getClassName27("title"), children: /* @__PURE__ */ jsxs19(Heading, { rank: "2", size: "xs", children: [
|
|
7859
|
+
headerTitle || rootTitle || "Page",
|
|
7860
|
+
headerPath && /* @__PURE__ */ jsxs19(Fragment14, { children: [
|
|
7861
|
+
" ",
|
|
7862
|
+
/* @__PURE__ */ jsx39("code", { className: getClassName27("path"), children: headerPath })
|
|
7863
|
+
] })
|
|
7864
|
+
] }) }),
|
|
7865
|
+
/* @__PURE__ */ jsxs19("div", { className: getClassName27("tools"), children: [
|
|
7866
|
+
/* @__PURE__ */ jsx39("div", { className: getClassName27("menuButton"), children: /* @__PURE__ */ jsx39(
|
|
7867
|
+
IconButton,
|
|
7868
|
+
{
|
|
7869
|
+
type: "button",
|
|
7870
|
+
onClick: () => {
|
|
7871
|
+
return setMenuOpen(!menuOpen);
|
|
7872
|
+
},
|
|
7873
|
+
title: "Toggle menu bar",
|
|
7874
|
+
children: menuOpen ? /* @__PURE__ */ jsx39(ChevronUp, { focusable: "false" }) : /* @__PURE__ */ jsx39(ChevronDown, { focusable: "false" })
|
|
7875
|
+
}
|
|
7876
|
+
) }),
|
|
7877
|
+
/* @__PURE__ */ jsx39(
|
|
7878
|
+
MenuBar,
|
|
7879
|
+
{
|
|
7880
|
+
dispatch,
|
|
7881
|
+
onPublish,
|
|
7882
|
+
menuOpen,
|
|
7883
|
+
renderHeaderActions: () => /* @__PURE__ */ jsx39(CustomHeaderActions, { children: /* @__PURE__ */ jsx39(
|
|
7884
|
+
Button,
|
|
7885
|
+
{
|
|
8063
7886
|
onClick: () => {
|
|
8064
|
-
|
|
7887
|
+
const data = appStore.getState().state.data;
|
|
7888
|
+
onPublish && onPublish(data);
|
|
8065
7889
|
},
|
|
8066
|
-
|
|
7890
|
+
icon: /* @__PURE__ */ jsx39(Globe, { size: "14px" }),
|
|
7891
|
+
children: "Publish"
|
|
8067
7892
|
}
|
|
8068
|
-
},
|
|
7893
|
+
) }),
|
|
7894
|
+
setMenuOpen
|
|
8069
7895
|
}
|
|
8070
|
-
|
|
8071
|
-
}
|
|
8072
|
-
|
|
8073
|
-
|
|
8074
|
-
|
|
8075
|
-
|
|
8076
|
-
|
|
8077
|
-
}
|
|
8078
|
-
) }) }),
|
|
8079
|
-
/* @__PURE__ */ jsx41("div", { id: "puck-portal-root", className: getClassName29("portal") })
|
|
8080
|
-
] });
|
|
7896
|
+
)
|
|
7897
|
+
] })
|
|
7898
|
+
] })
|
|
7899
|
+
}
|
|
7900
|
+
)
|
|
7901
|
+
}
|
|
7902
|
+
);
|
|
8081
7903
|
};
|
|
7904
|
+
var Header = memo3(HeaderInner);
|
|
8082
7905
|
|
|
8083
7906
|
// components/Puck/index.tsx
|
|
8084
|
-
import { jsx as
|
|
7907
|
+
import { jsx as jsx40, jsxs as jsxs20 } from "react/jsx-runtime";
|
|
7908
|
+
var getClassName28 = get_class_name_factory_default("Puck", styles_module_default14);
|
|
7909
|
+
var getLayoutClassName = get_class_name_factory_default("PuckLayout", styles_module_default14);
|
|
7910
|
+
var FieldSideBar = () => {
|
|
7911
|
+
const title = useAppStore(
|
|
7912
|
+
(s) => {
|
|
7913
|
+
var _a, _b;
|
|
7914
|
+
return s.selectedItem ? (_b = (_a = s.config.components[s.selectedItem.type]) == null ? void 0 : _a["label"]) != null ? _b : s.selectedItem.type.toString() : "Page";
|
|
7915
|
+
}
|
|
7916
|
+
);
|
|
7917
|
+
return /* @__PURE__ */ jsx40(SidebarSection, { noPadding: true, noBorderTop: true, showBreadcrumbs: true, title, children: /* @__PURE__ */ jsx40(Fields, {}) });
|
|
7918
|
+
};
|
|
8085
7919
|
var propsContext = createContext7({});
|
|
8086
7920
|
function PropsProvider(props) {
|
|
8087
|
-
return /* @__PURE__ */
|
|
7921
|
+
return /* @__PURE__ */ jsx40(propsContext.Provider, { value: props, children: props.children });
|
|
8088
7922
|
}
|
|
8089
7923
|
var usePropsContext = () => useContext12(propsContext);
|
|
8090
7924
|
function PuckProvider({ children }) {
|
|
@@ -8102,14 +7936,14 @@ function PuckProvider({ children }) {
|
|
|
8102
7936
|
metadata,
|
|
8103
7937
|
onAction
|
|
8104
7938
|
} = usePropsContext();
|
|
8105
|
-
const iframe =
|
|
7939
|
+
const iframe = useMemo21(
|
|
8106
7940
|
() => __spreadValues({
|
|
8107
7941
|
enabled: true,
|
|
8108
7942
|
waitForStyles: true
|
|
8109
7943
|
}, _iframe),
|
|
8110
7944
|
[_iframe]
|
|
8111
7945
|
);
|
|
8112
|
-
const [generatedAppState] =
|
|
7946
|
+
const [generatedAppState] = useState23(() => {
|
|
8113
7947
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
8114
7948
|
const initial = __spreadValues(__spreadValues({}, defaultAppState.ui), initialUi);
|
|
8115
7949
|
let clientUiState = {};
|
|
@@ -8169,7 +8003,7 @@ function PuckProvider({ children }) {
|
|
|
8169
8003
|
return walkAppState(newAppState, config);
|
|
8170
8004
|
});
|
|
8171
8005
|
const { appendData = true } = _initialHistory || {};
|
|
8172
|
-
const [blendedHistories] =
|
|
8006
|
+
const [blendedHistories] = useState23(
|
|
8173
8007
|
[
|
|
8174
8008
|
...(_initialHistory == null ? void 0 : _initialHistory.histories) || [],
|
|
8175
8009
|
...appendData ? [{ state: generatedAppState }] : []
|
|
@@ -8213,15 +8047,15 @@ function PuckProvider({ children }) {
|
|
|
8213
8047
|
metadata
|
|
8214
8048
|
]
|
|
8215
8049
|
);
|
|
8216
|
-
const [appStore] =
|
|
8050
|
+
const [appStore] = useState23(
|
|
8217
8051
|
() => createAppStore(generateAppStore(initialAppState))
|
|
8218
8052
|
);
|
|
8219
|
-
|
|
8053
|
+
useEffect25(() => {
|
|
8220
8054
|
if (process.env.NODE_ENV !== "production") {
|
|
8221
8055
|
window.__PUCK_INTERNAL_DO_NOT_USE = { appStore };
|
|
8222
8056
|
}
|
|
8223
8057
|
}, [appStore]);
|
|
8224
|
-
|
|
8058
|
+
useEffect25(() => {
|
|
8225
8059
|
const state = appStore.getState().state;
|
|
8226
8060
|
appStore.setState(__spreadValues({}, generateAppStore(state)));
|
|
8227
8061
|
}, [config, plugins, loadedOverrides, viewports, iframe, onAction, metadata]);
|
|
@@ -8231,7 +8065,7 @@ function PuckProvider({ children }) {
|
|
|
8231
8065
|
initialAppState
|
|
8232
8066
|
});
|
|
8233
8067
|
const previousData = useRef8(null);
|
|
8234
|
-
|
|
8068
|
+
useEffect25(() => {
|
|
8235
8069
|
appStore.subscribe(
|
|
8236
8070
|
(s) => s.state.data,
|
|
8237
8071
|
(data) => {
|
|
@@ -8245,14 +8079,99 @@ function PuckProvider({ children }) {
|
|
|
8245
8079
|
}, []);
|
|
8246
8080
|
useRegisterPermissionsSlice(appStore, permissions);
|
|
8247
8081
|
const uPuckStore = useRegisterUsePuckStore(appStore);
|
|
8248
|
-
|
|
8082
|
+
useEffect25(() => {
|
|
8249
8083
|
const { resolveAndCommitData } = appStore.getState();
|
|
8250
8084
|
resolveAndCommitData();
|
|
8251
8085
|
}, []);
|
|
8252
|
-
return /* @__PURE__ */
|
|
8086
|
+
return /* @__PURE__ */ jsx40(appStoreContext.Provider, { value: appStore, children: /* @__PURE__ */ jsx40(UsePuckStoreContext.Provider, { value: uPuckStore, children }) });
|
|
8087
|
+
}
|
|
8088
|
+
function PuckLayout({ children }) {
|
|
8089
|
+
const {
|
|
8090
|
+
iframe: _iframe,
|
|
8091
|
+
dnd,
|
|
8092
|
+
initialHistory: _initialHistory
|
|
8093
|
+
} = usePropsContext();
|
|
8094
|
+
const iframe = useMemo21(
|
|
8095
|
+
() => __spreadValues({
|
|
8096
|
+
enabled: true,
|
|
8097
|
+
waitForStyles: true
|
|
8098
|
+
}, _iframe),
|
|
8099
|
+
[_iframe]
|
|
8100
|
+
);
|
|
8101
|
+
useInjectGlobalCss(iframe.enabled);
|
|
8102
|
+
const leftSideBarVisible = useAppStore((s) => s.state.ui.leftSideBarVisible);
|
|
8103
|
+
const rightSideBarVisible = useAppStore(
|
|
8104
|
+
(s) => s.state.ui.rightSideBarVisible
|
|
8105
|
+
);
|
|
8106
|
+
const dispatch = useAppStore((s) => s.dispatch);
|
|
8107
|
+
useEffect25(() => {
|
|
8108
|
+
if (!window.matchMedia("(min-width: 638px)").matches) {
|
|
8109
|
+
dispatch({
|
|
8110
|
+
type: "setUi",
|
|
8111
|
+
ui: {
|
|
8112
|
+
leftSideBarVisible: false,
|
|
8113
|
+
rightSideBarVisible: false
|
|
8114
|
+
}
|
|
8115
|
+
});
|
|
8116
|
+
}
|
|
8117
|
+
const handleResize = () => {
|
|
8118
|
+
if (!window.matchMedia("(min-width: 638px)").matches) {
|
|
8119
|
+
dispatch({
|
|
8120
|
+
type: "setUi",
|
|
8121
|
+
ui: (ui) => __spreadValues(__spreadValues({}, ui), ui.rightSideBarVisible ? { leftSideBarVisible: false } : {})
|
|
8122
|
+
});
|
|
8123
|
+
}
|
|
8124
|
+
};
|
|
8125
|
+
window.addEventListener("resize", handleResize);
|
|
8126
|
+
return () => {
|
|
8127
|
+
window.removeEventListener("resize", handleResize);
|
|
8128
|
+
};
|
|
8129
|
+
}, []);
|
|
8130
|
+
const overrides = useAppStore((s) => s.overrides);
|
|
8131
|
+
const CustomPuck = useMemo21(
|
|
8132
|
+
() => overrides.puck || DefaultOverride,
|
|
8133
|
+
[overrides]
|
|
8134
|
+
);
|
|
8135
|
+
const [mounted, setMounted] = useState23(false);
|
|
8136
|
+
useEffect25(() => {
|
|
8137
|
+
setMounted(true);
|
|
8138
|
+
}, []);
|
|
8139
|
+
const ready = useAppStore((s) => s.status === "READY");
|
|
8140
|
+
useMonitorHotkeys();
|
|
8141
|
+
useEffect25(() => {
|
|
8142
|
+
if (ready && iframe.enabled) {
|
|
8143
|
+
const frameDoc = getFrame();
|
|
8144
|
+
if (frameDoc) {
|
|
8145
|
+
return monitorHotkeys(frameDoc);
|
|
8146
|
+
}
|
|
8147
|
+
}
|
|
8148
|
+
}, [ready, iframe.enabled]);
|
|
8149
|
+
usePreviewModeHotkeys();
|
|
8150
|
+
return /* @__PURE__ */ jsxs20("div", { className: `Puck ${getClassName28()}`, children: [
|
|
8151
|
+
/* @__PURE__ */ jsx40(DragDropContext, { disableAutoScroll: dnd == null ? void 0 : dnd.disableAutoScroll, children: /* @__PURE__ */ jsx40(CustomPuck, { children: children || /* @__PURE__ */ jsx40(
|
|
8152
|
+
"div",
|
|
8153
|
+
{
|
|
8154
|
+
className: getLayoutClassName({
|
|
8155
|
+
leftSideBarVisible,
|
|
8156
|
+
mounted,
|
|
8157
|
+
rightSideBarVisible
|
|
8158
|
+
}),
|
|
8159
|
+
children: /* @__PURE__ */ jsxs20("div", { className: getLayoutClassName("inner"), children: [
|
|
8160
|
+
/* @__PURE__ */ jsx40(Header, {}),
|
|
8161
|
+
/* @__PURE__ */ jsxs20("div", { className: getLayoutClassName("leftSideBar"), children: [
|
|
8162
|
+
/* @__PURE__ */ jsx40(SidebarSection, { title: "Components", noBorderTop: true, children: /* @__PURE__ */ jsx40(Components, {}) }),
|
|
8163
|
+
/* @__PURE__ */ jsx40(SidebarSection, { title: "Outline", children: /* @__PURE__ */ jsx40(Outline, {}) })
|
|
8164
|
+
] }),
|
|
8165
|
+
/* @__PURE__ */ jsx40(Canvas, {}),
|
|
8166
|
+
/* @__PURE__ */ jsx40("div", { className: getLayoutClassName("rightSideBar"), children: /* @__PURE__ */ jsx40(FieldSideBar, {}) })
|
|
8167
|
+
] })
|
|
8168
|
+
}
|
|
8169
|
+
) }) }),
|
|
8170
|
+
/* @__PURE__ */ jsx40("div", { id: "puck-portal-root", className: getClassName28("portal") })
|
|
8171
|
+
] });
|
|
8253
8172
|
}
|
|
8254
8173
|
function Puck(props) {
|
|
8255
|
-
return /* @__PURE__ */
|
|
8174
|
+
return /* @__PURE__ */ jsx40(PropsProvider, __spreadProps(__spreadValues({}, props), { children: /* @__PURE__ */ jsx40(PuckProvider, __spreadProps(__spreadValues({}, props), { children: /* @__PURE__ */ jsx40(PuckLayout, __spreadValues({}, props)) })) }));
|
|
8256
8175
|
}
|
|
8257
8176
|
Puck.Components = Components;
|
|
8258
8177
|
Puck.Fields = Fields;
|
|
@@ -8386,14 +8305,6 @@ lucide-react/dist/esm/icons/globe.js:
|
|
|
8386
8305
|
* See the LICENSE file in the root directory of this source tree.
|
|
8387
8306
|
*)
|
|
8388
8307
|
|
|
8389
|
-
lucide-react/dist/esm/icons/hammer.js:
|
|
8390
|
-
(**
|
|
8391
|
-
* @license lucide-react v0.468.0 - ISC
|
|
8392
|
-
*
|
|
8393
|
-
* This source code is licensed under the ISC license.
|
|
8394
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
8395
|
-
*)
|
|
8396
|
-
|
|
8397
8308
|
lucide-react/dist/esm/icons/hash.js:
|
|
8398
8309
|
(**
|
|
8399
8310
|
* @license lucide-react v0.468.0 - ISC
|
|
@@ -8522,14 +8433,6 @@ lucide-react/dist/esm/icons/tablet.js:
|
|
|
8522
8433
|
* See the LICENSE file in the root directory of this source tree.
|
|
8523
8434
|
*)
|
|
8524
8435
|
|
|
8525
|
-
lucide-react/dist/esm/icons/toy-brick.js:
|
|
8526
|
-
(**
|
|
8527
|
-
* @license lucide-react v0.468.0 - ISC
|
|
8528
|
-
*
|
|
8529
|
-
* This source code is licensed under the ISC license.
|
|
8530
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
8531
|
-
*)
|
|
8532
|
-
|
|
8533
8436
|
lucide-react/dist/esm/icons/trash.js:
|
|
8534
8437
|
(**
|
|
8535
8438
|
* @license lucide-react v0.468.0 - ISC
|