@measured/puck 0.19.1 → 0.20.0-canary.755737e8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.css +364 -256
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1232 -1088
- package/dist/index.mjs +1217 -1073
- package/dist/rsc.d.mts +2 -2
- package/dist/rsc.d.ts +2 -2
- package/dist/{walk-tree-DrJNb8b-.d.mts → walk-tree-6PP75PCU.d.mts} +6 -2
- package/dist/{walk-tree-DrJNb8b-.d.ts → walk-tree-6PP75PCU.d.ts} +6 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
@@ -458,6 +458,20 @@ var Globe = createLucideIcon("Globe", [
|
|
458
458
|
["path", { d: "M2 12h20", key: "9i4pu4" }]
|
459
459
|
]);
|
460
460
|
|
461
|
+
// ../../node_modules/lucide-react/dist/esm/icons/hammer.js
|
462
|
+
init_react_import();
|
463
|
+
var Hammer = createLucideIcon("Hammer", [
|
464
|
+
["path", { d: "m15 12-8.373 8.373a1 1 0 1 1-3-3L12 9", key: "eefl8a" }],
|
465
|
+
["path", { d: "m18 15 4-4", key: "16gjal" }],
|
466
|
+
[
|
467
|
+
"path",
|
468
|
+
{
|
469
|
+
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",
|
470
|
+
key: "b7pghm"
|
471
|
+
}
|
472
|
+
]
|
473
|
+
]);
|
474
|
+
|
461
475
|
// ../../node_modules/lucide-react/dist/esm/icons/hash.js
|
462
476
|
init_react_import();
|
463
477
|
var Hash = createLucideIcon("Hash", [
|
@@ -605,6 +619,14 @@ var Tablet = createLucideIcon("Tablet", [
|
|
605
619
|
["line", { x1: "12", x2: "12.01", y1: "18", y2: "18", key: "1dp563" }]
|
606
620
|
]);
|
607
621
|
|
622
|
+
// ../../node_modules/lucide-react/dist/esm/icons/toy-brick.js
|
623
|
+
init_react_import();
|
624
|
+
var ToyBrick = createLucideIcon("ToyBrick", [
|
625
|
+
["rect", { width: "18", height: "12", x: "3", y: "8", rx: "1", key: "158fvp" }],
|
626
|
+
["path", { d: "M10 8V5c0-.6-.4-1-1-1H6a1 1 0 0 0-1 1v3", key: "s0042v" }],
|
627
|
+
["path", { d: "M19 8V5c0-.6-.4-1-1-1h-3a1 1 0 0 0-1 1v3", key: "9wmeh2" }]
|
628
|
+
]);
|
629
|
+
|
608
630
|
// ../../node_modules/lucide-react/dist/esm/icons/trash.js
|
609
631
|
init_react_import();
|
610
632
|
var Trash = createLucideIcon("Trash", [
|
@@ -6769,121 +6791,24 @@ Drawer.Item = DrawerItem;
|
|
6769
6791
|
|
6770
6792
|
// components/Puck/index.tsx
|
6771
6793
|
init_react_import();
|
6772
|
-
var
|
6773
|
-
|
6774
|
-
// components/SidebarSection/index.tsx
|
6775
|
-
init_react_import();
|
6776
|
-
|
6777
|
-
// css-module:/home/runner/work/puck/puck/packages/core/components/SidebarSection/styles.module.css#css-module
|
6778
|
-
init_react_import();
|
6779
|
-
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" };
|
6780
|
-
|
6781
|
-
// lib/use-breadcrumbs.ts
|
6782
|
-
init_react_import();
|
6783
|
-
var import_react41 = require("react");
|
6784
|
-
var useBreadcrumbs = (renderCount) => {
|
6785
|
-
const selectedId = useAppStore((s) => {
|
6786
|
-
var _a;
|
6787
|
-
return (_a = s.selectedItem) == null ? void 0 : _a.props.id;
|
6788
|
-
});
|
6789
|
-
const config = useAppStore((s) => s.config);
|
6790
|
-
const path = useAppStore((s) => {
|
6791
|
-
var _a;
|
6792
|
-
return (_a = s.state.indexes.nodes[selectedId]) == null ? void 0 : _a.path;
|
6793
|
-
});
|
6794
|
-
const appStore = useAppStoreApi();
|
6795
|
-
return (0, import_react41.useMemo)(() => {
|
6796
|
-
const breadcrumbs = (path == null ? void 0 : path.map((zoneCompound) => {
|
6797
|
-
var _a, _b, _c;
|
6798
|
-
const [componentId] = zoneCompound.split(":");
|
6799
|
-
if (componentId === "root") {
|
6800
|
-
return {
|
6801
|
-
label: "Page",
|
6802
|
-
selector: null
|
6803
|
-
};
|
6804
|
-
}
|
6805
|
-
const node = appStore.getState().state.indexes.nodes[componentId];
|
6806
|
-
const parentId = node.path[node.path.length - 1];
|
6807
|
-
const contentIds = ((_a = appStore.getState().state.indexes.zones[parentId]) == null ? void 0 : _a.contentIds) || [];
|
6808
|
-
const index = contentIds.indexOf(componentId);
|
6809
|
-
const label = node ? (_c = (_b = config.components[node.data.type]) == null ? void 0 : _b.label) != null ? _c : node.data.type : "Component";
|
6810
|
-
return {
|
6811
|
-
label,
|
6812
|
-
selector: node ? {
|
6813
|
-
index,
|
6814
|
-
zone: node.path[node.path.length - 1]
|
6815
|
-
} : null
|
6816
|
-
};
|
6817
|
-
})) || [];
|
6818
|
-
if (renderCount) {
|
6819
|
-
return breadcrumbs.slice(breadcrumbs.length - renderCount);
|
6820
|
-
}
|
6821
|
-
return breadcrumbs;
|
6822
|
-
}, [path, renderCount]);
|
6823
|
-
};
|
6824
|
-
|
6825
|
-
// components/SidebarSection/index.tsx
|
6826
|
-
var import_jsx_runtime28 = require("react/jsx-runtime");
|
6827
|
-
var getClassName19 = get_class_name_factory_default("SidebarSection", styles_module_default13);
|
6828
|
-
var SidebarSection = ({
|
6829
|
-
children,
|
6830
|
-
title,
|
6831
|
-
background,
|
6832
|
-
showBreadcrumbs,
|
6833
|
-
noBorderTop,
|
6834
|
-
noPadding,
|
6835
|
-
isLoading
|
6836
|
-
}) => {
|
6837
|
-
const setUi = useAppStore((s) => s.setUi);
|
6838
|
-
const breadcrumbs = useBreadcrumbs(1);
|
6839
|
-
return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(
|
6840
|
-
"div",
|
6841
|
-
{
|
6842
|
-
className: getClassName19({ noBorderTop, noPadding }),
|
6843
|
-
style: { background },
|
6844
|
-
children: [
|
6845
|
-
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: getClassName19("title"), children: /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: getClassName19("breadcrumbs"), children: [
|
6846
|
-
showBreadcrumbs ? breadcrumbs.map((breadcrumb, i) => /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: getClassName19("breadcrumb"), children: [
|
6847
|
-
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
6848
|
-
"button",
|
6849
|
-
{
|
6850
|
-
type: "button",
|
6851
|
-
className: getClassName19("breadcrumbLabel"),
|
6852
|
-
onClick: () => setUi({ itemSelector: breadcrumb.selector }),
|
6853
|
-
children: breadcrumb.label
|
6854
|
-
}
|
6855
|
-
),
|
6856
|
-
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)(ChevronRight, { size: 16 })
|
6857
|
-
] }, i)) : null,
|
6858
|
-
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: getClassName19("heading"), children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(Heading, { rank: "2", size: "xs", children: title }) })
|
6859
|
-
] }) }),
|
6860
|
-
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: getClassName19("content"), children }),
|
6861
|
-
isLoading && /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: getClassName19("loadingOverlay"), children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(Loader, { size: 32 }) })
|
6862
|
-
]
|
6863
|
-
}
|
6864
|
-
);
|
6865
|
-
};
|
6866
|
-
|
6867
|
-
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/styles.module.css#css-module
|
6868
|
-
init_react_import();
|
6869
|
-
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" };
|
6794
|
+
var import_react57 = require("react");
|
6870
6795
|
|
6871
6796
|
// components/Puck/components/Fields/index.tsx
|
6872
6797
|
init_react_import();
|
6873
6798
|
|
6874
6799
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Fields/styles.module.css#css-module
|
6875
6800
|
init_react_import();
|
6876
|
-
var
|
6801
|
+
var styles_module_default13 = { "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" };
|
6877
6802
|
|
6878
6803
|
// components/Puck/components/Fields/index.tsx
|
6879
|
-
var
|
6804
|
+
var import_react41 = require("react");
|
6880
6805
|
var import_shallow5 = require("zustand/react/shallow");
|
6881
|
-
var
|
6882
|
-
var
|
6806
|
+
var import_jsx_runtime28 = require("react/jsx-runtime");
|
6807
|
+
var getClassName19 = get_class_name_factory_default("PuckFields", styles_module_default13);
|
6883
6808
|
var DefaultFields = ({
|
6884
6809
|
children
|
6885
6810
|
}) => {
|
6886
|
-
return /* @__PURE__ */ (0,
|
6811
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(import_jsx_runtime28.Fragment, { children });
|
6887
6812
|
};
|
6888
6813
|
var createOnChange = (fieldName, appStore) => (value, updatedUi) => __async(void 0, null, function* () {
|
6889
6814
|
let currentProps;
|
@@ -6949,13 +6874,13 @@ var FieldsChild = ({ fieldName }) => {
|
|
6949
6874
|
})
|
6950
6875
|
);
|
6951
6876
|
const appStore = useAppStoreApi();
|
6952
|
-
const onChange = (0,
|
6877
|
+
const onChange = (0, import_react41.useCallback)(createOnChange(fieldName, appStore), [
|
6953
6878
|
fieldName
|
6954
6879
|
]);
|
6955
6880
|
const { visible = true } = field != null ? field : {};
|
6956
6881
|
if (!field || !id || !visible) return null;
|
6957
6882
|
if (field.type === "slot") return null;
|
6958
|
-
return /* @__PURE__ */ (0,
|
6883
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: getClassName19("field"), children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
6959
6884
|
AutoFieldPrivate,
|
6960
6885
|
{
|
6961
6886
|
field,
|
@@ -6967,7 +6892,7 @@ var FieldsChild = ({ fieldName }) => {
|
|
6967
6892
|
}
|
6968
6893
|
) }, id);
|
6969
6894
|
};
|
6970
|
-
var FieldsChildMemo = (0,
|
6895
|
+
var FieldsChildMemo = (0, import_react41.memo)(FieldsChild);
|
6971
6896
|
var FieldsInternal = ({ wrapFields = true }) => {
|
6972
6897
|
const overrides = useAppStore((s) => s.overrides);
|
6973
6898
|
const componentResolving = useAppStore((s) => {
|
@@ -6992,40 +6917,40 @@ var FieldsInternal = ({ wrapFields = true }) => {
|
|
6992
6917
|
})
|
6993
6918
|
);
|
6994
6919
|
const isLoading = fieldsLoading || componentResolving;
|
6995
|
-
const Wrapper = (0,
|
6996
|
-
return /* @__PURE__ */ (0,
|
6920
|
+
const Wrapper = (0, import_react41.useMemo)(() => overrides.fields || DefaultFields, [overrides]);
|
6921
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(
|
6997
6922
|
"form",
|
6998
6923
|
{
|
6999
|
-
className:
|
6924
|
+
className: getClassName19({ wrapFields }),
|
7000
6925
|
onSubmit: (e) => {
|
7001
6926
|
e.preventDefault();
|
7002
6927
|
},
|
7003
6928
|
children: [
|
7004
|
-
/* @__PURE__ */ (0,
|
7005
|
-
isLoading && /* @__PURE__ */ (0,
|
6929
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)(Wrapper, { isLoading, itemSelector, children: fieldNames.map((fieldName) => /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(FieldsChildMemo, { fieldName }, fieldName)) }),
|
6930
|
+
isLoading && /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: getClassName19("loadingOverlay"), children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: getClassName19("loadingOverlayInner"), children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(Loader, { size: 16 }) }) })
|
7006
6931
|
]
|
7007
6932
|
}
|
7008
6933
|
);
|
7009
6934
|
};
|
7010
|
-
var Fields = (0,
|
6935
|
+
var Fields = (0, import_react41.memo)(FieldsInternal);
|
7011
6936
|
|
7012
6937
|
// components/Puck/components/Components/index.tsx
|
7013
6938
|
init_react_import();
|
7014
6939
|
|
7015
6940
|
// lib/use-component-list.tsx
|
7016
6941
|
init_react_import();
|
7017
|
-
var
|
6942
|
+
var import_react42 = require("react");
|
7018
6943
|
|
7019
6944
|
// components/ComponentList/index.tsx
|
7020
6945
|
init_react_import();
|
7021
6946
|
|
7022
6947
|
// css-module:/home/runner/work/puck/puck/packages/core/components/ComponentList/styles.module.css#css-module
|
7023
6948
|
init_react_import();
|
7024
|
-
var
|
6949
|
+
var styles_module_default14 = { "ComponentList": "_ComponentList_1rrlt_1", "ComponentList--isExpanded": "_ComponentList--isExpanded_1rrlt_5", "ComponentList-content": "_ComponentList-content_1rrlt_9", "ComponentList-title": "_ComponentList-title_1rrlt_17", "ComponentList-titleIcon": "_ComponentList-titleIcon_1rrlt_53" };
|
7025
6950
|
|
7026
6951
|
// components/ComponentList/index.tsx
|
7027
|
-
var
|
7028
|
-
var
|
6952
|
+
var import_jsx_runtime29 = require("react/jsx-runtime");
|
6953
|
+
var getClassName20 = get_class_name_factory_default("ComponentList", styles_module_default14);
|
7029
6954
|
var ComponentListItem = ({
|
7030
6955
|
name,
|
7031
6956
|
label
|
@@ -7036,7 +6961,7 @@ var ComponentListItem = ({
|
|
7036
6961
|
type: name
|
7037
6962
|
}).insert
|
7038
6963
|
);
|
7039
|
-
return /* @__PURE__ */ (0,
|
6964
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(Drawer.Item, { label, name, isDragDisabled: !canInsert, children: overrides.componentItem });
|
7040
6965
|
};
|
7041
6966
|
var ComponentList = ({
|
7042
6967
|
children,
|
@@ -7047,12 +6972,12 @@ var ComponentList = ({
|
|
7047
6972
|
const setUi = useAppStore((s) => s.setUi);
|
7048
6973
|
const componentList = useAppStore((s) => s.state.ui.componentList);
|
7049
6974
|
const { expanded = true } = componentList[id] || {};
|
7050
|
-
return /* @__PURE__ */ (0,
|
7051
|
-
title && /* @__PURE__ */ (0,
|
6975
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: getClassName20({ isExpanded: expanded }), children: [
|
6976
|
+
title && /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(
|
7052
6977
|
"button",
|
7053
6978
|
{
|
7054
6979
|
type: "button",
|
7055
|
-
className:
|
6980
|
+
className: getClassName20("title"),
|
7056
6981
|
onClick: () => setUi({
|
7057
6982
|
componentList: __spreadProps(__spreadValues({}, componentList), {
|
7058
6983
|
[id]: __spreadProps(__spreadValues({}, componentList[id]), {
|
@@ -7062,14 +6987,14 @@ var ComponentList = ({
|
|
7062
6987
|
}),
|
7063
6988
|
title: expanded ? `Collapse${title ? ` ${title}` : ""}` : `Expand${title ? ` ${title}` : ""}`,
|
7064
6989
|
children: [
|
7065
|
-
/* @__PURE__ */ (0,
|
7066
|
-
/* @__PURE__ */ (0,
|
6990
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { children: title }),
|
6991
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: getClassName20("titleIcon"), children: expanded ? /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(ChevronUp, { size: 12 }) : /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(ChevronDown, { size: 12 }) })
|
7067
6992
|
]
|
7068
6993
|
}
|
7069
6994
|
),
|
7070
|
-
/* @__PURE__ */ (0,
|
6995
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: getClassName20("content"), children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(Drawer, { children: children || Object.keys(config.components).map((componentKey) => {
|
7071
6996
|
var _a;
|
7072
|
-
return /* @__PURE__ */ (0,
|
6997
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
7073
6998
|
ComponentListItem,
|
7074
6999
|
{
|
7075
7000
|
label: (_a = config.components[componentKey]["label"]) != null ? _a : componentKey,
|
@@ -7083,12 +7008,12 @@ var ComponentList = ({
|
|
7083
7008
|
ComponentList.Item = ComponentListItem;
|
7084
7009
|
|
7085
7010
|
// lib/use-component-list.tsx
|
7086
|
-
var
|
7011
|
+
var import_jsx_runtime30 = require("react/jsx-runtime");
|
7087
7012
|
var useComponentList = () => {
|
7088
|
-
const [componentList, setComponentList] = (0,
|
7013
|
+
const [componentList, setComponentList] = (0, import_react42.useState)();
|
7089
7014
|
const config = useAppStore((s) => s.config);
|
7090
7015
|
const uiComponentList = useAppStore((s) => s.state.ui.componentList);
|
7091
|
-
(0,
|
7016
|
+
(0, import_react42.useEffect)(() => {
|
7092
7017
|
var _a, _b, _c;
|
7093
7018
|
if (Object.keys(uiComponentList).length > 0) {
|
7094
7019
|
const matchedComponents = [];
|
@@ -7098,7 +7023,7 @@ var useComponentList = () => {
|
|
7098
7023
|
if (category.visible === false || !category.components) {
|
7099
7024
|
return null;
|
7100
7025
|
}
|
7101
|
-
return /* @__PURE__ */ (0,
|
7026
|
+
return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
7102
7027
|
ComponentList,
|
7103
7028
|
{
|
7104
7029
|
id: categoryKey,
|
@@ -7107,7 +7032,7 @@ var useComponentList = () => {
|
|
7107
7032
|
var _a2;
|
7108
7033
|
matchedComponents.push(componentName);
|
7109
7034
|
const componentConf = config.components[componentName] || {};
|
7110
|
-
return /* @__PURE__ */ (0,
|
7035
|
+
return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
7111
7036
|
ComponentList.Item,
|
7112
7037
|
{
|
7113
7038
|
label: (_a2 = componentConf["label"]) != null ? _a2 : componentName,
|
@@ -7127,7 +7052,7 @@ var useComponentList = () => {
|
|
7127
7052
|
);
|
7128
7053
|
if (remainingComponents.length > 0 && !((_a = uiComponentList.other) == null ? void 0 : _a.components) && ((_b = uiComponentList.other) == null ? void 0 : _b.visible) !== false) {
|
7129
7054
|
_componentList.push(
|
7130
|
-
/* @__PURE__ */ (0,
|
7055
|
+
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
7131
7056
|
ComponentList,
|
7132
7057
|
{
|
7133
7058
|
id: "other",
|
@@ -7135,7 +7060,7 @@ var useComponentList = () => {
|
|
7135
7060
|
children: remainingComponents.map((componentName, i) => {
|
7136
7061
|
var _a2;
|
7137
7062
|
const componentConf = config.components[componentName] || {};
|
7138
|
-
return /* @__PURE__ */ (0,
|
7063
|
+
return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
7139
7064
|
ComponentList.Item,
|
7140
7065
|
{
|
7141
7066
|
name: componentName,
|
@@ -7157,25 +7082,25 @@ var useComponentList = () => {
|
|
7157
7082
|
};
|
7158
7083
|
|
7159
7084
|
// components/Puck/components/Components/index.tsx
|
7160
|
-
var
|
7161
|
-
var
|
7085
|
+
var import_react43 = require("react");
|
7086
|
+
var import_jsx_runtime31 = require("react/jsx-runtime");
|
7162
7087
|
var Components = () => {
|
7163
7088
|
const overrides = useAppStore((s) => s.overrides);
|
7164
7089
|
const componentList = useComponentList();
|
7165
|
-
const Wrapper = (0,
|
7166
|
-
return /* @__PURE__ */ (0,
|
7090
|
+
const Wrapper = (0, import_react43.useMemo)(() => overrides.components || "div", [overrides]);
|
7091
|
+
return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(Wrapper, { children: componentList ? componentList : /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(ComponentList, { id: "all" }) });
|
7167
7092
|
};
|
7168
7093
|
|
7169
7094
|
// components/Puck/components/Preview/index.tsx
|
7170
7095
|
init_react_import();
|
7171
|
-
var
|
7096
|
+
var import_react45 = require("react");
|
7172
7097
|
|
7173
7098
|
// components/AutoFrame/index.tsx
|
7174
7099
|
init_react_import();
|
7175
|
-
var
|
7100
|
+
var import_react44 = require("react");
|
7176
7101
|
var import_object_hash = __toESM(require("object-hash"));
|
7177
7102
|
var import_react_dom3 = require("react-dom");
|
7178
|
-
var
|
7103
|
+
var import_jsx_runtime32 = require("react/jsx-runtime");
|
7179
7104
|
var styleSelector = 'style, link[rel="stylesheet"]';
|
7180
7105
|
var collectStyles = (doc) => {
|
7181
7106
|
const collected = [];
|
@@ -7218,7 +7143,7 @@ var CopyHostStyles = ({
|
|
7218
7143
|
onStylesLoaded = () => null
|
7219
7144
|
}) => {
|
7220
7145
|
const { document: doc, window: win } = useFrame();
|
7221
|
-
(0,
|
7146
|
+
(0, import_react44.useEffect)(() => {
|
7222
7147
|
if (!win || !doc) {
|
7223
7148
|
return () => {
|
7224
7149
|
};
|
@@ -7375,10 +7300,10 @@ var CopyHostStyles = ({
|
|
7375
7300
|
observer.disconnect();
|
7376
7301
|
};
|
7377
7302
|
}, []);
|
7378
|
-
return /* @__PURE__ */ (0,
|
7303
|
+
return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_jsx_runtime32.Fragment, { children });
|
7379
7304
|
};
|
7380
|
-
var autoFrameContext = (0,
|
7381
|
-
var useFrame = () => (0,
|
7305
|
+
var autoFrameContext = (0, import_react44.createContext)({});
|
7306
|
+
var useFrame = () => (0, import_react44.useContext)(autoFrameContext);
|
7382
7307
|
function AutoFrame(_a) {
|
7383
7308
|
var _b = _a, {
|
7384
7309
|
children,
|
@@ -7399,11 +7324,11 @@ function AutoFrame(_a) {
|
|
7399
7324
|
"onNotReady",
|
7400
7325
|
"frameRef"
|
7401
7326
|
]);
|
7402
|
-
const [loaded, setLoaded] = (0,
|
7403
|
-
const [ctx, setCtx] = (0,
|
7404
|
-
const [mountTarget, setMountTarget] = (0,
|
7405
|
-
const [stylesLoaded, setStylesLoaded] = (0,
|
7406
|
-
(0,
|
7327
|
+
const [loaded, setLoaded] = (0, import_react44.useState)(false);
|
7328
|
+
const [ctx, setCtx] = (0, import_react44.useState)({});
|
7329
|
+
const [mountTarget, setMountTarget] = (0, import_react44.useState)();
|
7330
|
+
const [stylesLoaded, setStylesLoaded] = (0, import_react44.useState)(false);
|
7331
|
+
(0, import_react44.useEffect)(() => {
|
7407
7332
|
var _a2;
|
7408
7333
|
if (frameRef.current) {
|
7409
7334
|
const doc = frameRef.current.contentDocument;
|
@@ -7422,7 +7347,7 @@ function AutoFrame(_a) {
|
|
7422
7347
|
}
|
7423
7348
|
}
|
7424
7349
|
}, [frameRef, loaded, stylesLoaded]);
|
7425
|
-
return /* @__PURE__ */ (0,
|
7350
|
+
return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
7426
7351
|
"iframe",
|
7427
7352
|
__spreadProps(__spreadValues({}, props), {
|
7428
7353
|
className,
|
@@ -7432,7 +7357,7 @@ function AutoFrame(_a) {
|
|
7432
7357
|
onLoad: () => {
|
7433
7358
|
setLoaded(true);
|
7434
7359
|
},
|
7435
|
-
children: /* @__PURE__ */ (0,
|
7360
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(autoFrameContext.Provider, { value: ctx, children: loaded && mountTarget && /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
7436
7361
|
CopyHostStyles,
|
7437
7362
|
{
|
7438
7363
|
debug,
|
@@ -7448,14 +7373,14 @@ var AutoFrame_default = AutoFrame;
|
|
7448
7373
|
|
7449
7374
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Preview/styles.module.css#css-module
|
7450
7375
|
init_react_import();
|
7451
|
-
var
|
7376
|
+
var styles_module_default15 = { "PuckPreview": "_PuckPreview_z2rgu_1", "PuckPreview-frame": "_PuckPreview-frame_z2rgu_6" };
|
7452
7377
|
|
7453
7378
|
// components/Puck/components/Preview/index.tsx
|
7454
|
-
var
|
7455
|
-
var
|
7379
|
+
var import_jsx_runtime33 = require("react/jsx-runtime");
|
7380
|
+
var getClassName21 = get_class_name_factory_default("PuckPreview", styles_module_default15);
|
7456
7381
|
var useBubbleIframeEvents = (ref) => {
|
7457
7382
|
const status = useAppStore((s) => s.status);
|
7458
|
-
(0,
|
7383
|
+
(0, import_react45.useEffect)(() => {
|
7459
7384
|
if (ref.current && status === "READY") {
|
7460
7385
|
const iframe = ref.current;
|
7461
7386
|
const handlePointerMove = (event) => {
|
@@ -7504,7 +7429,7 @@ var Preview2 = ({ id = "puck-preview" }) => {
|
|
7504
7429
|
const renderData = useAppStore(
|
7505
7430
|
(s) => s.state.ui.previewMode === "edit" ? null : s.state.data
|
7506
7431
|
);
|
7507
|
-
const Page = (0,
|
7432
|
+
const Page = (0, import_react45.useCallback)(
|
7508
7433
|
(pageProps) => {
|
7509
7434
|
var _a, _b;
|
7510
7435
|
const propsWithSlots = useSlots(
|
@@ -7514,15 +7439,15 @@ var Preview2 = ({ id = "puck-preview" }) => {
|
|
7514
7439
|
);
|
7515
7440
|
return ((_a = config.root) == null ? void 0 : _a.render) ? (_b = config.root) == null ? void 0 : _b.render(__spreadValues({
|
7516
7441
|
id: "puck-root"
|
7517
|
-
}, propsWithSlots)) : /* @__PURE__ */ (0,
|
7442
|
+
}, propsWithSlots)) : /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_jsx_runtime33.Fragment, { children: propsWithSlots.children });
|
7518
7443
|
},
|
7519
7444
|
[config]
|
7520
7445
|
);
|
7521
|
-
const Frame = (0,
|
7446
|
+
const Frame = (0, import_react45.useMemo)(() => overrides.iframe, [overrides]);
|
7522
7447
|
const rootProps = root.props || root;
|
7523
|
-
const ref = (0,
|
7448
|
+
const ref = (0, import_react45.useRef)(null);
|
7524
7449
|
useBubbleIframeEvents(ref);
|
7525
|
-
const inner = !renderData ? /* @__PURE__ */ (0,
|
7450
|
+
const inner = !renderData ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
7526
7451
|
Page,
|
7527
7452
|
__spreadProps(__spreadValues({}, rootProps), {
|
7528
7453
|
puck: {
|
@@ -7532,28 +7457,28 @@ var Preview2 = ({ id = "puck-preview" }) => {
|
|
7532
7457
|
metadata
|
7533
7458
|
},
|
7534
7459
|
editMode: true,
|
7535
|
-
children: /* @__PURE__ */ (0,
|
7460
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(DropZonePure, { zone: rootDroppableId })
|
7536
7461
|
})
|
7537
|
-
) : /* @__PURE__ */ (0,
|
7538
|
-
(0,
|
7462
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Render2, { data: renderData, config });
|
7463
|
+
(0, import_react45.useEffect)(() => {
|
7539
7464
|
if (!iframe.enabled) {
|
7540
7465
|
setStatus("READY");
|
7541
7466
|
}
|
7542
7467
|
}, [iframe.enabled]);
|
7543
|
-
return /* @__PURE__ */ (0,
|
7468
|
+
return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
7544
7469
|
"div",
|
7545
7470
|
{
|
7546
|
-
className:
|
7471
|
+
className: getClassName21(),
|
7547
7472
|
id,
|
7548
7473
|
"data-puck-preview": true,
|
7549
7474
|
onClick: () => {
|
7550
7475
|
dispatch({ type: "setUi", ui: { itemSelector: null } });
|
7551
7476
|
},
|
7552
|
-
children: iframe.enabled ? /* @__PURE__ */ (0,
|
7477
|
+
children: iframe.enabled ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
7553
7478
|
AutoFrame_default,
|
7554
7479
|
{
|
7555
7480
|
id: "preview-frame",
|
7556
|
-
className:
|
7481
|
+
className: getClassName21("frame"),
|
7557
7482
|
"data-rfd-iframe": true,
|
7558
7483
|
onReady: () => {
|
7559
7484
|
setStatus("READY");
|
@@ -7562,18 +7487,18 @@ var Preview2 = ({ id = "puck-preview" }) => {
|
|
7562
7487
|
setStatus("MOUNTED");
|
7563
7488
|
},
|
7564
7489
|
frameRef: ref,
|
7565
|
-
children: /* @__PURE__ */ (0,
|
7490
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(autoFrameContext.Consumer, { children: ({ document: document2 }) => {
|
7566
7491
|
if (Frame) {
|
7567
|
-
return /* @__PURE__ */ (0,
|
7492
|
+
return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Frame, { document: document2, children: inner });
|
7568
7493
|
}
|
7569
7494
|
return inner;
|
7570
7495
|
} })
|
7571
7496
|
}
|
7572
|
-
) : /* @__PURE__ */ (0,
|
7497
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
7573
7498
|
"div",
|
7574
7499
|
{
|
7575
7500
|
id: "preview-frame",
|
7576
|
-
className:
|
7501
|
+
className: getClassName21("frame"),
|
7577
7502
|
ref,
|
7578
7503
|
"data-puck-entry": true,
|
7579
7504
|
children: inner
|
@@ -7591,7 +7516,7 @@ init_react_import();
|
|
7591
7516
|
|
7592
7517
|
// css-module:/home/runner/work/puck/puck/packages/core/components/LayerTree/styles.module.css#css-module
|
7593
7518
|
init_react_import();
|
7594
|
-
var
|
7519
|
+
var styles_module_default16 = { "LayerTree": "_LayerTree_7rx04_1", "LayerTree-zoneTitle": "_LayerTree-zoneTitle_7rx04_11", "LayerTree-helper": "_LayerTree-helper_7rx04_17", "Layer": "_Layer_7rx04_1", "Layer-inner": "_Layer-inner_7rx04_29", "Layer--containsZone": "_Layer--containsZone_7rx04_35", "Layer-clickable": "_Layer-clickable_7rx04_39", "Layer--isSelected": "_Layer--isSelected_7rx04_61", "Layer-chevron": "_Layer-chevron_7rx04_77", "Layer--childIsSelected": "_Layer--childIsSelected_7rx04_78", "Layer-zones": "_Layer-zones_7rx04_82", "Layer-title": "_Layer-title_7rx04_96", "Layer-name": "_Layer-name_7rx04_105", "Layer-icon": "_Layer-icon_7rx04_111", "Layer-zoneIcon": "_Layer-zoneIcon_7rx04_116" };
|
7595
7520
|
|
7596
7521
|
// lib/scroll-into-view.ts
|
7597
7522
|
init_react_import();
|
@@ -7605,7 +7530,7 @@ var scrollIntoView = (el) => {
|
|
7605
7530
|
};
|
7606
7531
|
|
7607
7532
|
// components/LayerTree/index.tsx
|
7608
|
-
var
|
7533
|
+
var import_react46 = require("react");
|
7609
7534
|
|
7610
7535
|
// lib/on-scroll-end.ts
|
7611
7536
|
init_react_import();
|
@@ -7628,20 +7553,20 @@ var onScrollEnd = (frame, cb) => {
|
|
7628
7553
|
|
7629
7554
|
// components/LayerTree/index.tsx
|
7630
7555
|
var import_shallow6 = require("zustand/react/shallow");
|
7631
|
-
var
|
7632
|
-
var
|
7633
|
-
var getClassNameLayer = get_class_name_factory_default("Layer",
|
7556
|
+
var import_jsx_runtime34 = require("react/jsx-runtime");
|
7557
|
+
var getClassName22 = get_class_name_factory_default("LayerTree", styles_module_default16);
|
7558
|
+
var getClassNameLayer = get_class_name_factory_default("Layer", styles_module_default16);
|
7634
7559
|
var Layer = ({
|
7635
7560
|
index,
|
7636
7561
|
itemId,
|
7637
7562
|
zoneCompound
|
7638
7563
|
}) => {
|
7639
7564
|
var _a;
|
7640
|
-
const ctx = (0,
|
7565
|
+
const ctx = (0, import_react46.useContext)(dropZoneContext);
|
7641
7566
|
const config = useAppStore((s) => s.config);
|
7642
7567
|
const itemSelector = useAppStore((s) => s.state.ui.itemSelector);
|
7643
7568
|
const dispatch = useAppStore((s) => s.dispatch);
|
7644
|
-
const setItemSelector = (0,
|
7569
|
+
const setItemSelector = (0, import_react46.useCallback)(
|
7645
7570
|
(itemSelector2) => {
|
7646
7571
|
dispatch({ type: "setUi", ui: { itemSelector: itemSelector2 } });
|
7647
7572
|
},
|
@@ -7661,7 +7586,7 @@ var Layer = ({
|
|
7661
7586
|
)
|
7662
7587
|
);
|
7663
7588
|
const containsZone = zonesForItem.length > 0;
|
7664
|
-
const zoneStore = (0,
|
7589
|
+
const zoneStore = (0, import_react46.useContext)(ZoneStoreContext);
|
7665
7590
|
const isHovering = useContextStore(
|
7666
7591
|
ZoneStoreContext,
|
7667
7592
|
(s) => s.hoveringComponent === itemId
|
@@ -7676,7 +7601,7 @@ var Layer = ({
|
|
7676
7601
|
});
|
7677
7602
|
const componentConfig = config.components[nodeData.data.type];
|
7678
7603
|
const label = (_a = componentConfig == null ? void 0 : componentConfig["label"]) != null ? _a : nodeData.data.type.toString();
|
7679
|
-
return /* @__PURE__ */ (0,
|
7604
|
+
return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(
|
7680
7605
|
"li",
|
7681
7606
|
{
|
7682
7607
|
className: getClassNameLayer({
|
@@ -7686,7 +7611,7 @@ var Layer = ({
|
|
7686
7611
|
childIsSelected
|
7687
7612
|
}),
|
7688
7613
|
children: [
|
7689
|
-
/* @__PURE__ */ (0,
|
7614
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: getClassNameLayer("inner"), children: /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(
|
7690
7615
|
"button",
|
7691
7616
|
{
|
7692
7617
|
type: "button",
|
@@ -7724,22 +7649,22 @@ var Layer = ({
|
|
7724
7649
|
zoneStore.setState({ hoveringComponent: null });
|
7725
7650
|
},
|
7726
7651
|
children: [
|
7727
|
-
containsZone && /* @__PURE__ */ (0,
|
7652
|
+
containsZone && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
7728
7653
|
"div",
|
7729
7654
|
{
|
7730
7655
|
className: getClassNameLayer("chevron"),
|
7731
7656
|
title: isSelected ? "Collapse" : "Expand",
|
7732
|
-
children: /* @__PURE__ */ (0,
|
7657
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(ChevronDown, { size: "12" })
|
7733
7658
|
}
|
7734
7659
|
),
|
7735
|
-
/* @__PURE__ */ (0,
|
7736
|
-
/* @__PURE__ */ (0,
|
7737
|
-
/* @__PURE__ */ (0,
|
7660
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("div", { className: getClassNameLayer("title"), children: [
|
7661
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: getClassNameLayer("icon"), children: nodeData.data.type === "Text" || nodeData.data.type === "Heading" ? /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Type, { size: "16" }) : /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(LayoutGrid, { size: "16" }) }),
|
7662
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: getClassNameLayer("name"), children: label })
|
7738
7663
|
] })
|
7739
7664
|
]
|
7740
7665
|
}
|
7741
7666
|
) }),
|
7742
|
-
containsZone && zonesForItem.map((subzone) => /* @__PURE__ */ (0,
|
7667
|
+
containsZone && zonesForItem.map((subzone) => /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: getClassNameLayer("zones"), children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(LayerTree, { zoneCompound: subzone }) }, subzone))
|
7743
7668
|
]
|
7744
7669
|
}
|
7745
7670
|
);
|
@@ -7757,15 +7682,15 @@ var LayerTree = ({
|
|
7757
7682
|
}
|
7758
7683
|
)
|
7759
7684
|
);
|
7760
|
-
return /* @__PURE__ */ (0,
|
7761
|
-
label && /* @__PURE__ */ (0,
|
7762
|
-
/* @__PURE__ */ (0,
|
7685
|
+
return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(import_jsx_runtime34.Fragment, { children: [
|
7686
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("div", { className: getClassName22("zoneTitle"), children: [
|
7687
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: getClassName22("zoneIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Layers, { size: "16" }) }),
|
7763
7688
|
label
|
7764
7689
|
] }),
|
7765
|
-
/* @__PURE__ */ (0,
|
7766
|
-
contentIds.length === 0 && /* @__PURE__ */ (0,
|
7690
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("ul", { className: getClassName22(), children: [
|
7691
|
+
contentIds.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: getClassName22("helper"), children: "No items" }),
|
7767
7692
|
contentIds.map((itemId, i) => {
|
7768
|
-
return /* @__PURE__ */ (0,
|
7693
|
+
return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
7769
7694
|
Layer,
|
7770
7695
|
{
|
7771
7696
|
index: i,
|
@@ -7780,7 +7705,7 @@ var LayerTree = ({
|
|
7780
7705
|
};
|
7781
7706
|
|
7782
7707
|
// components/Puck/components/Outline/index.tsx
|
7783
|
-
var
|
7708
|
+
var import_react47 = require("react");
|
7784
7709
|
|
7785
7710
|
// lib/data/find-zones-for-area.ts
|
7786
7711
|
init_react_import();
|
@@ -7792,14 +7717,14 @@ var findZonesForArea = (state, area) => {
|
|
7792
7717
|
|
7793
7718
|
// components/Puck/components/Outline/index.tsx
|
7794
7719
|
var import_shallow7 = require("zustand/react/shallow");
|
7795
|
-
var
|
7720
|
+
var import_jsx_runtime35 = require("react/jsx-runtime");
|
7796
7721
|
var Outline = () => {
|
7797
7722
|
const outlineOverride = useAppStore((s) => s.overrides.outline);
|
7798
7723
|
const rootZones = useAppStore(
|
7799
7724
|
(0, import_shallow7.useShallow)((s) => findZonesForArea(s.state, "root"))
|
7800
7725
|
);
|
7801
|
-
const Wrapper = (0,
|
7802
|
-
return /* @__PURE__ */ (0,
|
7726
|
+
const Wrapper = (0, import_react47.useMemo)(() => outlineOverride || "div", [outlineOverride]);
|
7727
|
+
return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Wrapper, { children: rootZones.map((zoneCompound) => /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
7803
7728
|
LayerTree,
|
7804
7729
|
{
|
7805
7730
|
label: rootZones.length === 1 ? "" : zoneCompound.split(":")[1],
|
@@ -7809,901 +7734,1189 @@ var Outline = () => {
|
|
7809
7734
|
)) });
|
7810
7735
|
};
|
7811
7736
|
|
7812
|
-
//
|
7737
|
+
// lib/use-loaded-overrides.ts
|
7813
7738
|
init_react_import();
|
7739
|
+
var import_react48 = require("react");
|
7814
7740
|
|
7815
|
-
//
|
7741
|
+
// lib/load-overrides.ts
|
7816
7742
|
init_react_import();
|
7743
|
+
var loadOverrides = ({
|
7744
|
+
overrides,
|
7745
|
+
plugins
|
7746
|
+
}) => {
|
7747
|
+
const collected = __spreadValues({}, overrides);
|
7748
|
+
plugins == null ? void 0 : plugins.forEach((plugin) => {
|
7749
|
+
if (!plugin.overrides) return;
|
7750
|
+
Object.keys(plugin.overrides).forEach((_overridesType) => {
|
7751
|
+
const overridesType = _overridesType;
|
7752
|
+
if (overridesType === "fieldTypes") {
|
7753
|
+
const fieldTypes = plugin.overrides.fieldTypes;
|
7754
|
+
Object.keys(fieldTypes).forEach((fieldType) => {
|
7755
|
+
collected.fieldTypes = collected.fieldTypes || {};
|
7756
|
+
const childNode2 = collected.fieldTypes[fieldType];
|
7757
|
+
const Comp2 = (props) => fieldTypes[fieldType](__spreadProps(__spreadValues({}, props), {
|
7758
|
+
children: childNode2 ? childNode2(props) : props.children
|
7759
|
+
}));
|
7760
|
+
collected.fieldTypes[fieldType] = Comp2;
|
7761
|
+
});
|
7762
|
+
return;
|
7763
|
+
}
|
7764
|
+
const childNode = collected[overridesType];
|
7765
|
+
const Comp = (props) => plugin.overrides[overridesType](__spreadProps(__spreadValues({}, props), {
|
7766
|
+
children: childNode ? childNode(props) : props.children
|
7767
|
+
}));
|
7768
|
+
collected[overridesType] = Comp;
|
7769
|
+
});
|
7770
|
+
});
|
7771
|
+
return collected;
|
7772
|
+
};
|
7817
7773
|
|
7818
|
-
//
|
7819
|
-
|
7820
|
-
|
7821
|
-
|
7822
|
-
|
7823
|
-
|
7824
|
-
return;
|
7825
|
-
}
|
7826
|
-
|
7827
|
-
throw new Error(prefix);
|
7828
|
-
}
|
7829
|
-
var provided = typeof message === "function" ? message() : message;
|
7830
|
-
var value = provided ? "".concat(prefix, ": ").concat(provided) : prefix;
|
7831
|
-
throw new Error(value);
|
7832
|
-
}
|
7774
|
+
// lib/use-loaded-overrides.ts
|
7775
|
+
var useLoadedOverrides = ({
|
7776
|
+
overrides,
|
7777
|
+
plugins
|
7778
|
+
}) => {
|
7779
|
+
return (0, import_react48.useMemo)(() => {
|
7780
|
+
return loadOverrides({ overrides, plugins });
|
7781
|
+
}, [plugins, overrides]);
|
7782
|
+
};
|
7833
7783
|
|
7834
|
-
//
|
7835
|
-
|
7836
|
-
|
7837
|
-
|
7838
|
-
|
7839
|
-
|
7840
|
-
|
7841
|
-
|
7842
|
-
|
7843
|
-
|
7844
|
-
|
7845
|
-
|
7846
|
-
|
7847
|
-
|
7848
|
-
|
7849
|
-
|
7850
|
-
|
7784
|
+
// lib/use-puck.ts
|
7785
|
+
init_react_import();
|
7786
|
+
var import_react49 = require("react");
|
7787
|
+
var import_zustand6 = require("zustand");
|
7788
|
+
var generateUsePuck = (store) => {
|
7789
|
+
const history = {
|
7790
|
+
back: store.history.back,
|
7791
|
+
forward: store.history.forward,
|
7792
|
+
setHistories: store.history.setHistories,
|
7793
|
+
setHistoryIndex: store.history.setHistoryIndex,
|
7794
|
+
hasPast: store.history.hasPast(),
|
7795
|
+
hasFuture: store.history.hasFuture(),
|
7796
|
+
histories: store.history.histories,
|
7797
|
+
index: store.history.index
|
7798
|
+
};
|
7799
|
+
const storeData = {
|
7800
|
+
appState: makeStatePublic(store.state),
|
7801
|
+
config: store.config,
|
7802
|
+
dispatch: store.dispatch,
|
7803
|
+
getPermissions: store.permissions.getPermissions,
|
7804
|
+
refreshPermissions: store.permissions.refreshPermissions,
|
7805
|
+
history,
|
7806
|
+
selectedItem: store.selectedItem || null,
|
7807
|
+
getItemBySelector: (selector) => getItem(selector, store.state),
|
7808
|
+
getItemById: (id) => store.state.indexes.nodes[id].data,
|
7809
|
+
getSelectorForId: (id) => {
|
7810
|
+
const node = store.state.indexes.nodes[id];
|
7811
|
+
if (!node) return;
|
7812
|
+
const zoneCompound = `${node.parentId}:${node.zone}`;
|
7813
|
+
const index = store.state.indexes.zones[zoneCompound].contentIds.indexOf(id);
|
7814
|
+
return { zone: zoneCompound, index };
|
7851
7815
|
}
|
7852
7816
|
};
|
7853
|
-
|
7817
|
+
const get = () => storeData;
|
7818
|
+
return __spreadProps(__spreadValues({}, storeData), { get });
|
7854
7819
|
};
|
7855
|
-
var
|
7820
|
+
var UsePuckStoreContext = (0, import_react49.createContext)(
|
7821
|
+
null
|
7822
|
+
);
|
7823
|
+
var convertToPickedStore = (store) => {
|
7856
7824
|
return {
|
7857
|
-
|
7858
|
-
|
7859
|
-
|
7860
|
-
|
7825
|
+
state: store.state,
|
7826
|
+
config: store.config,
|
7827
|
+
dispatch: store.dispatch,
|
7828
|
+
permissions: store.permissions,
|
7829
|
+
history: store.history,
|
7830
|
+
selectedItem: store.selectedItem
|
7861
7831
|
};
|
7862
7832
|
};
|
7863
|
-
var
|
7864
|
-
|
7865
|
-
|
7866
|
-
|
7867
|
-
|
7868
|
-
|
7869
|
-
|
7870
|
-
|
7871
|
-
|
7872
|
-
|
7873
|
-
|
7874
|
-
|
7875
|
-
|
7833
|
+
var useRegisterUsePuckStore = (appStore) => {
|
7834
|
+
const [usePuckStore] = (0, import_react49.useState)(
|
7835
|
+
() => (0, import_zustand6.createStore)(
|
7836
|
+
() => generateUsePuck(convertToPickedStore(appStore.getState()))
|
7837
|
+
)
|
7838
|
+
);
|
7839
|
+
(0, import_react49.useEffect)(() => {
|
7840
|
+
return appStore.subscribe(
|
7841
|
+
(store) => convertToPickedStore(store),
|
7842
|
+
(pickedStore) => {
|
7843
|
+
usePuckStore.setState(generateUsePuck(pickedStore));
|
7844
|
+
}
|
7845
|
+
);
|
7846
|
+
}, []);
|
7847
|
+
return usePuckStore;
|
7876
7848
|
};
|
7877
|
-
|
7878
|
-
|
7879
|
-
|
7880
|
-
|
7881
|
-
|
7882
|
-
|
7883
|
-
|
7884
|
-
|
7885
|
-
|
7886
|
-
|
7887
|
-
|
7888
|
-
border,
|
7889
|
-
padding
|
7849
|
+
function createUsePuck() {
|
7850
|
+
return function usePuck2(selector) {
|
7851
|
+
const usePuckApi = (0, import_react49.useContext)(UsePuckStoreContext);
|
7852
|
+
if (!usePuckApi) {
|
7853
|
+
throw new Error("usePuck must be used inside <Puck>.");
|
7854
|
+
}
|
7855
|
+
const result = (0, import_zustand6.useStore)(
|
7856
|
+
usePuckApi,
|
7857
|
+
selector != null ? selector : (s) => s
|
7858
|
+
);
|
7859
|
+
return result;
|
7890
7860
|
};
|
7891
|
-
}
|
7892
|
-
|
7893
|
-
|
7894
|
-
|
7895
|
-
|
7896
|
-
|
7861
|
+
}
|
7862
|
+
function usePuck() {
|
7863
|
+
(0, import_react49.useEffect)(() => {
|
7864
|
+
console.warn(
|
7865
|
+
"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."
|
7866
|
+
);
|
7867
|
+
}, []);
|
7868
|
+
return createUsePuck()((s) => s);
|
7869
|
+
}
|
7870
|
+
function useGetPuck() {
|
7871
|
+
const usePuckApi = (0, import_react49.useContext)(UsePuckStoreContext);
|
7872
|
+
if (!usePuckApi) {
|
7873
|
+
throw new Error("usePuckGet must be used inside <Puck>.");
|
7897
7874
|
}
|
7898
|
-
|
7899
|
-
|
7900
|
-
|
7875
|
+
return usePuckApi.getState;
|
7876
|
+
}
|
7877
|
+
|
7878
|
+
// components/Puck/index.tsx
|
7879
|
+
var import_fast_deep_equal3 = __toESM(require("fast-deep-equal"));
|
7880
|
+
|
7881
|
+
// components/Puck/components/Layout/index.tsx
|
7882
|
+
init_react_import();
|
7883
|
+
var import_react56 = require("react");
|
7884
|
+
|
7885
|
+
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Layout/styles.module.css#css-module
|
7886
|
+
init_react_import();
|
7887
|
+
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" };
|
7888
|
+
|
7889
|
+
// lib/use-inject-css.ts
|
7890
|
+
init_react_import();
|
7891
|
+
var import_react50 = require("react");
|
7892
|
+
var styles = ``;
|
7893
|
+
var useInjectStyleSheet = (initialStyles, iframeEnabled) => {
|
7894
|
+
const [el, setEl] = (0, import_react50.useState)();
|
7895
|
+
(0, import_react50.useEffect)(() => {
|
7896
|
+
setEl(document.createElement("style"));
|
7897
|
+
}, []);
|
7898
|
+
(0, import_react50.useEffect)(() => {
|
7899
|
+
var _a;
|
7900
|
+
if (!el || typeof window === "undefined") {
|
7901
|
+
return;
|
7902
|
+
}
|
7903
|
+
el.innerHTML = initialStyles;
|
7904
|
+
if (iframeEnabled) {
|
7905
|
+
const frame = getFrame();
|
7906
|
+
(_a = frame == null ? void 0 : frame.head) == null ? void 0 : _a.appendChild(el);
|
7907
|
+
}
|
7908
|
+
document.head.appendChild(el);
|
7909
|
+
}, [iframeEnabled, el]);
|
7910
|
+
return el;
|
7901
7911
|
};
|
7902
|
-
var
|
7903
|
-
|
7904
|
-
top: parse(styles2.marginTop),
|
7905
|
-
right: parse(styles2.marginRight),
|
7906
|
-
bottom: parse(styles2.marginBottom),
|
7907
|
-
left: parse(styles2.marginLeft)
|
7908
|
-
};
|
7909
|
-
var padding = {
|
7910
|
-
top: parse(styles2.paddingTop),
|
7911
|
-
right: parse(styles2.paddingRight),
|
7912
|
-
bottom: parse(styles2.paddingBottom),
|
7913
|
-
left: parse(styles2.paddingLeft)
|
7914
|
-
};
|
7915
|
-
var border = {
|
7916
|
-
top: parse(styles2.borderTopWidth),
|
7917
|
-
right: parse(styles2.borderRightWidth),
|
7918
|
-
bottom: parse(styles2.borderBottomWidth),
|
7919
|
-
left: parse(styles2.borderLeftWidth)
|
7920
|
-
};
|
7921
|
-
return createBox({
|
7922
|
-
borderBox,
|
7923
|
-
margin,
|
7924
|
-
padding,
|
7925
|
-
border
|
7926
|
-
});
|
7912
|
+
var useInjectGlobalCss = (iframeEnabled) => {
|
7913
|
+
return useInjectStyleSheet(styles, iframeEnabled);
|
7927
7914
|
};
|
7928
|
-
|
7929
|
-
|
7930
|
-
|
7931
|
-
|
7915
|
+
|
7916
|
+
// components/DefaultOverride/index.tsx
|
7917
|
+
init_react_import();
|
7918
|
+
var import_jsx_runtime36 = require("react/jsx-runtime");
|
7919
|
+
var DefaultOverride = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_jsx_runtime36.Fragment, { children });
|
7920
|
+
|
7921
|
+
// lib/use-preview-mode-hotkeys.ts
|
7922
|
+
init_react_import();
|
7923
|
+
var import_react51 = require("react");
|
7924
|
+
var usePreviewModeHotkeys = () => {
|
7925
|
+
const appStore = useAppStoreApi();
|
7926
|
+
const toggleInteractive = (0, import_react51.useCallback)(() => {
|
7927
|
+
const dispatch = appStore.getState().dispatch;
|
7928
|
+
dispatch({
|
7929
|
+
type: "setUi",
|
7930
|
+
ui: (ui) => ({
|
7931
|
+
previewMode: ui.previewMode === "edit" ? "interactive" : "edit"
|
7932
|
+
})
|
7933
|
+
});
|
7934
|
+
}, [appStore]);
|
7935
|
+
useHotkey({ meta: true, i: true }, toggleInteractive);
|
7936
|
+
useHotkey({ ctrl: true, i: true }, toggleInteractive);
|
7932
7937
|
};
|
7933
7938
|
|
7934
|
-
// components/Puck/components/
|
7935
|
-
|
7939
|
+
// components/Puck/components/Header/index.tsx
|
7940
|
+
init_react_import();
|
7941
|
+
var import_react52 = require("react");
|
7936
7942
|
|
7937
|
-
// components/
|
7943
|
+
// components/MenuBar/index.tsx
|
7938
7944
|
init_react_import();
|
7939
|
-
var import_react49 = require("react");
|
7940
7945
|
|
7941
|
-
// css-module:/home/runner/work/puck/puck/packages/core/components/
|
7946
|
+
// css-module:/home/runner/work/puck/puck/packages/core/components/MenuBar/styles.module.css#css-module
|
7942
7947
|
init_react_import();
|
7943
|
-
var
|
7948
|
+
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" };
|
7944
7949
|
|
7945
|
-
// components/
|
7950
|
+
// components/MenuBar/index.tsx
|
7946
7951
|
var import_jsx_runtime37 = require("react/jsx-runtime");
|
7947
|
-
var
|
7948
|
-
|
7949
|
-
|
7950
|
-
|
7951
|
-
|
7952
|
-
|
7953
|
-
|
7954
|
-
|
7955
|
-
|
7956
|
-
|
7957
|
-
|
7958
|
-
|
7959
|
-
onClick
|
7960
|
-
}) => {
|
7961
|
-
const viewports = useAppStore((s) => s.state.ui.viewports);
|
7962
|
-
const [isActive, setIsActive] = (0, import_react49.useState)(false);
|
7963
|
-
(0, import_react49.useEffect)(() => {
|
7964
|
-
setIsActive(width === viewports.current.width);
|
7965
|
-
}, [width, viewports.current.width]);
|
7966
|
-
return /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("span", { className: getClassNameButton({ isActive }), children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
|
7967
|
-
IconButton,
|
7952
|
+
var getClassName23 = get_class_name_factory_default("MenuBar", styles_module_default18);
|
7953
|
+
function MenuBar({
|
7954
|
+
menuOpen = false,
|
7955
|
+
renderHeaderActions,
|
7956
|
+
setMenuOpen
|
7957
|
+
}) {
|
7958
|
+
const back = useAppStore((s) => s.history.back);
|
7959
|
+
const forward = useAppStore((s) => s.history.forward);
|
7960
|
+
const hasFuture = useAppStore((s) => s.history.hasFuture());
|
7961
|
+
const hasPast = useAppStore((s) => s.history.hasPast());
|
7962
|
+
return /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
|
7963
|
+
"div",
|
7968
7964
|
{
|
7969
|
-
|
7970
|
-
|
7971
|
-
|
7972
|
-
|
7973
|
-
|
7965
|
+
className: getClassName23({ menuOpen }),
|
7966
|
+
onClick: (event) => {
|
7967
|
+
var _a;
|
7968
|
+
const element = event.target;
|
7969
|
+
if (window.matchMedia("(min-width: 638px)").matches) {
|
7970
|
+
return;
|
7971
|
+
}
|
7972
|
+
if (element.tagName === "A" && ((_a = element.getAttribute("href")) == null ? void 0 : _a.startsWith("#"))) {
|
7973
|
+
setMenuOpen(false);
|
7974
|
+
}
|
7974
7975
|
},
|
7975
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime37.
|
7976
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)("div", { className: getClassName23("inner"), children: [
|
7977
|
+
/* @__PURE__ */ (0, import_jsx_runtime37.jsxs)("div", { className: getClassName23("history"), children: [
|
7978
|
+
/* @__PURE__ */ (0, import_jsx_runtime37.jsx)(IconButton, { title: "undo", disabled: !hasPast, onClick: back, children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(Undo2, { size: 21 }) }),
|
7979
|
+
/* @__PURE__ */ (0, import_jsx_runtime37.jsx)(IconButton, { title: "redo", disabled: !hasFuture, onClick: forward, children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(Redo2, { size: 21 }) })
|
7980
|
+
] }),
|
7981
|
+
/* @__PURE__ */ (0, import_jsx_runtime37.jsx)(import_jsx_runtime37.Fragment, { children: renderHeaderActions && renderHeaderActions() })
|
7982
|
+
] })
|
7976
7983
|
}
|
7977
|
-
) });
|
7978
|
-
};
|
7979
|
-
var defaultZoomOptions = [
|
7980
|
-
{ label: "25%", value: 0.25 },
|
7981
|
-
{ label: "50%", value: 0.5 },
|
7982
|
-
{ label: "75%", value: 0.75 },
|
7983
|
-
{ label: "100%", value: 1 },
|
7984
|
-
{ label: "125%", value: 1.25 },
|
7985
|
-
{ label: "150%", value: 1.5 },
|
7986
|
-
{ label: "200%", value: 2 }
|
7987
|
-
];
|
7988
|
-
var ViewportControls = ({
|
7989
|
-
autoZoom,
|
7990
|
-
zoom,
|
7991
|
-
onViewportChange,
|
7992
|
-
onZoom
|
7993
|
-
}) => {
|
7994
|
-
var _a, _b;
|
7995
|
-
const viewports = useAppStore((s) => s.viewports);
|
7996
|
-
const defaultsContainAutoZoom = defaultZoomOptions.find(
|
7997
|
-
(option) => option.value === autoZoom
|
7998
|
-
);
|
7999
|
-
const zoomOptions = (0, import_react49.useMemo)(
|
8000
|
-
() => [
|
8001
|
-
...defaultZoomOptions,
|
8002
|
-
...defaultsContainAutoZoom ? [] : [
|
8003
|
-
{
|
8004
|
-
value: autoZoom,
|
8005
|
-
label: `${(autoZoom * 100).toFixed(0)}% (Auto)`
|
8006
|
-
}
|
8007
|
-
]
|
8008
|
-
].filter((a) => a.value <= autoZoom).sort((a, b) => a.value > b.value ? 1 : -1),
|
8009
|
-
[autoZoom]
|
8010
7984
|
);
|
8011
|
-
|
8012
|
-
viewports.map((viewport, i) => /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
|
8013
|
-
ViewportButton,
|
8014
|
-
{
|
8015
|
-
height: viewport.height,
|
8016
|
-
width: viewport.width,
|
8017
|
-
title: viewport.label ? `Switch to ${viewport.label} viewport` : "Switch viewport",
|
8018
|
-
onClick: onViewportChange,
|
8019
|
-
children: typeof viewport.icon === "string" ? icons[viewport.icon] || viewport.icon : viewport.icon || icons.Smartphone
|
8020
|
-
},
|
8021
|
-
i
|
8022
|
-
)),
|
8023
|
-
/* @__PURE__ */ (0, import_jsx_runtime37.jsx)("div", { className: getClassName24("divider") }),
|
8024
|
-
/* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
|
8025
|
-
IconButton,
|
8026
|
-
{
|
8027
|
-
title: "Zoom viewport out",
|
8028
|
-
disabled: zoom <= ((_a = zoomOptions[0]) == null ? void 0 : _a.value),
|
8029
|
-
onClick: (e) => {
|
8030
|
-
e.stopPropagation();
|
8031
|
-
onZoom(
|
8032
|
-
zoomOptions[Math.max(
|
8033
|
-
zoomOptions.findIndex((option) => option.value === zoom) - 1,
|
8034
|
-
0
|
8035
|
-
)].value
|
8036
|
-
);
|
8037
|
-
},
|
8038
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(ZoomOut, { size: 16 })
|
8039
|
-
}
|
8040
|
-
),
|
8041
|
-
/* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
|
8042
|
-
IconButton,
|
8043
|
-
{
|
8044
|
-
title: "Zoom viewport in",
|
8045
|
-
disabled: zoom >= ((_b = zoomOptions[zoomOptions.length - 1]) == null ? void 0 : _b.value),
|
8046
|
-
onClick: (e) => {
|
8047
|
-
e.stopPropagation();
|
8048
|
-
onZoom(
|
8049
|
-
zoomOptions[Math.min(
|
8050
|
-
zoomOptions.findIndex((option) => option.value === zoom) + 1,
|
8051
|
-
zoomOptions.length - 1
|
8052
|
-
)].value
|
8053
|
-
);
|
8054
|
-
},
|
8055
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(ZoomIn, { size: 16 })
|
8056
|
-
}
|
8057
|
-
),
|
8058
|
-
/* @__PURE__ */ (0, import_jsx_runtime37.jsx)("div", { className: getClassName24("divider") }),
|
8059
|
-
/* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
|
8060
|
-
"select",
|
8061
|
-
{
|
8062
|
-
className: getClassName24("zoomSelect"),
|
8063
|
-
value: zoom.toString(),
|
8064
|
-
onChange: (e) => {
|
8065
|
-
onZoom(parseFloat(e.currentTarget.value));
|
8066
|
-
},
|
8067
|
-
children: zoomOptions.map((option) => /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
|
8068
|
-
"option",
|
8069
|
-
{
|
8070
|
-
value: option.value,
|
8071
|
-
label: option.label
|
8072
|
-
},
|
8073
|
-
option.label
|
8074
|
-
))
|
8075
|
-
}
|
8076
|
-
)
|
8077
|
-
] });
|
8078
|
-
};
|
8079
|
-
|
8080
|
-
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Canvas/styles.module.css#css-module
|
8081
|
-
init_react_import();
|
8082
|
-
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" };
|
7985
|
+
}
|
8083
7986
|
|
8084
|
-
//
|
7987
|
+
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Header/styles.module.css#css-module
|
8085
7988
|
init_react_import();
|
8086
|
-
var
|
8087
|
-
var getZoomConfig = (uiViewport, frame, zoom) => {
|
8088
|
-
const box = getBox(frame);
|
8089
|
-
const { width: frameWidth, height: frameHeight } = box.contentBox;
|
8090
|
-
const viewportHeight = uiViewport.height === "auto" ? frameHeight : uiViewport.height;
|
8091
|
-
let rootHeight = 0;
|
8092
|
-
let autoZoom = 1;
|
8093
|
-
if (uiViewport.width > frameWidth || viewportHeight > frameHeight) {
|
8094
|
-
const widthZoom = Math.min(frameWidth / uiViewport.width, 1);
|
8095
|
-
const heightZoom = Math.min(frameHeight / viewportHeight, 1);
|
8096
|
-
zoom = widthZoom;
|
8097
|
-
if (widthZoom < heightZoom) {
|
8098
|
-
rootHeight = viewportHeight / zoom;
|
8099
|
-
} else {
|
8100
|
-
rootHeight = viewportHeight;
|
8101
|
-
zoom = heightZoom;
|
8102
|
-
}
|
8103
|
-
autoZoom = zoom;
|
8104
|
-
} else {
|
8105
|
-
if (RESET_ZOOM_SMALLER_THAN_FRAME) {
|
8106
|
-
autoZoom = 1;
|
8107
|
-
zoom = 1;
|
8108
|
-
rootHeight = viewportHeight;
|
8109
|
-
}
|
8110
|
-
}
|
8111
|
-
return { autoZoom, rootHeight, zoom };
|
8112
|
-
};
|
7989
|
+
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" };
|
8113
7990
|
|
8114
|
-
// components/Puck/components/
|
8115
|
-
var import_shallow8 = require("zustand/react/shallow");
|
7991
|
+
// components/Puck/components/Header/index.tsx
|
8116
7992
|
var import_jsx_runtime38 = require("react/jsx-runtime");
|
8117
|
-
var
|
8118
|
-
var
|
8119
|
-
var Canvas = () => {
|
7993
|
+
var getClassName24 = get_class_name_factory_default("PuckHeader", styles_module_default19);
|
7994
|
+
var HeaderInner = () => {
|
8120
7995
|
const {
|
8121
|
-
|
8122
|
-
|
8123
|
-
|
8124
|
-
|
8125
|
-
|
8126
|
-
|
8127
|
-
|
8128
|
-
|
8129
|
-
|
8130
|
-
|
8131
|
-
|
8132
|
-
|
8133
|
-
|
8134
|
-
|
8135
|
-
|
8136
|
-
|
8137
|
-
|
7996
|
+
onPublish,
|
7997
|
+
renderHeader,
|
7998
|
+
renderHeaderActions,
|
7999
|
+
headerTitle,
|
8000
|
+
headerPath,
|
8001
|
+
iframe: _iframe
|
8002
|
+
} = usePropsContext();
|
8003
|
+
const dispatch = useAppStore((s) => s.dispatch);
|
8004
|
+
const appStore = useAppStoreApi();
|
8005
|
+
const defaultHeaderRender = (0, import_react52.useMemo)(() => {
|
8006
|
+
if (renderHeader) {
|
8007
|
+
console.warn(
|
8008
|
+
"`renderHeader` is deprecated. Please use `overrides.header` and the `usePuck` hook instead"
|
8009
|
+
);
|
8010
|
+
const RenderHeader = (_a) => {
|
8011
|
+
var _b = _a, { actions } = _b, props = __objRest(_b, ["actions"]);
|
8012
|
+
const Comp = renderHeader;
|
8013
|
+
const appState = useAppStore((s) => s.state);
|
8014
|
+
return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState, children: actions }));
|
8015
|
+
};
|
8016
|
+
return RenderHeader;
|
8017
|
+
}
|
8018
|
+
return DefaultOverride;
|
8019
|
+
}, [renderHeader]);
|
8020
|
+
const defaultHeaderActionsRender = (0, import_react52.useMemo)(() => {
|
8021
|
+
if (renderHeaderActions) {
|
8022
|
+
console.warn(
|
8023
|
+
"`renderHeaderActions` is deprecated. Please use `overrides.headerActions` and the `usePuck` hook instead."
|
8024
|
+
);
|
8025
|
+
const RenderHeader = (props) => {
|
8026
|
+
const Comp = renderHeaderActions;
|
8027
|
+
const appState = useAppStore((s) => s.state);
|
8028
|
+
return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState }));
|
8029
|
+
};
|
8030
|
+
return RenderHeader;
|
8031
|
+
}
|
8032
|
+
return DefaultOverride;
|
8033
|
+
}, [renderHeader]);
|
8034
|
+
const CustomHeader = useAppStore(
|
8035
|
+
(s) => s.overrides.header || defaultHeaderRender
|
8138
8036
|
);
|
8139
|
-
const
|
8140
|
-
(
|
8141
|
-
leftSideBarVisible: s.state.ui.leftSideBarVisible,
|
8142
|
-
rightSideBarVisible: s.state.ui.rightSideBarVisible,
|
8143
|
-
viewports: s.state.ui.viewports
|
8144
|
-
}))
|
8037
|
+
const CustomHeaderActions = useAppStore(
|
8038
|
+
(s) => s.overrides.headerActions || defaultHeaderActionsRender
|
8145
8039
|
);
|
8146
|
-
const
|
8147
|
-
const
|
8148
|
-
|
8149
|
-
const
|
8150
|
-
return
|
8151
|
-
}
|
8152
|
-
const
|
8153
|
-
|
8154
|
-
|
8040
|
+
const [menuOpen, setMenuOpen] = (0, import_react52.useState)(false);
|
8041
|
+
const rootTitle = useAppStore((s) => {
|
8042
|
+
var _a, _b;
|
8043
|
+
const rootData = (_a = s.state.indexes.nodes["root"]) == null ? void 0 : _a.data;
|
8044
|
+
return (_b = rootData.props.title) != null ? _b : "";
|
8045
|
+
});
|
8046
|
+
const leftSideBarVisible = useAppStore((s) => s.state.ui.leftSideBarVisible);
|
8047
|
+
const rightSideBarVisible = useAppStore(
|
8048
|
+
(s) => s.state.ui.rightSideBarVisible
|
8155
8049
|
);
|
8156
|
-
const
|
8157
|
-
|
8158
|
-
const
|
8159
|
-
const
|
8160
|
-
|
8161
|
-
|
8162
|
-
|
8163
|
-
|
8164
|
-
|
8165
|
-
|
8166
|
-
|
8167
|
-
setZoomConfig(
|
8168
|
-
getZoomConfig(
|
8169
|
-
newViewports == null ? void 0 : newViewports.current,
|
8170
|
-
frameRef.current,
|
8171
|
-
zoomConfig.zoom
|
8172
|
-
)
|
8173
|
-
);
|
8174
|
-
}
|
8050
|
+
const toggleSidebars = (0, import_react52.useCallback)(
|
8051
|
+
(sidebar) => {
|
8052
|
+
const widerViewport = window.matchMedia("(min-width: 638px)").matches;
|
8053
|
+
const sideBarVisible = sidebar === "left" ? leftSideBarVisible : rightSideBarVisible;
|
8054
|
+
const oppositeSideBar = sidebar === "left" ? "rightSideBarVisible" : "leftSideBarVisible";
|
8055
|
+
dispatch({
|
8056
|
+
type: "setUi",
|
8057
|
+
ui: __spreadValues({
|
8058
|
+
[`${sidebar}SideBarVisible`]: !sideBarVisible
|
8059
|
+
}, !widerViewport ? { [oppositeSideBar]: false } : {})
|
8060
|
+
});
|
8175
8061
|
},
|
8176
|
-
[
|
8062
|
+
[dispatch, leftSideBarVisible, rightSideBarVisible]
|
8177
8063
|
);
|
8178
|
-
(0,
|
8179
|
-
|
8180
|
-
|
8181
|
-
|
8182
|
-
|
8183
|
-
|
8184
|
-
|
8185
|
-
|
8186
|
-
|
8187
|
-
|
8064
|
+
return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
|
8065
|
+
CustomHeader,
|
8066
|
+
{
|
8067
|
+
actions: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(import_jsx_runtime38.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(CustomHeaderActions, { children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
|
8068
|
+
Button,
|
8069
|
+
{
|
8070
|
+
onClick: () => {
|
8071
|
+
const data = appStore.getState().state.data;
|
8072
|
+
onPublish && onPublish(data);
|
8073
|
+
},
|
8074
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(Globe, { size: "14px" }),
|
8075
|
+
children: "Publish"
|
8076
|
+
}
|
8077
|
+
) }) }),
|
8078
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
|
8079
|
+
"header",
|
8080
|
+
{
|
8081
|
+
className: getClassName24({ leftSideBarVisible, rightSideBarVisible }),
|
8082
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("div", { className: getClassName24("inner"), children: [
|
8083
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("div", { className: getClassName24("toggle"), children: [
|
8084
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)("div", { className: getClassName24("leftSideBarToggle"), children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
|
8085
|
+
IconButton,
|
8086
|
+
{
|
8087
|
+
onClick: () => {
|
8088
|
+
toggleSidebars("left");
|
8089
|
+
},
|
8090
|
+
title: "Toggle left sidebar",
|
8091
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(PanelLeft, { focusable: "false" })
|
8092
|
+
}
|
8093
|
+
) }),
|
8094
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)("div", { className: getClassName24("rightSideBarToggle"), children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
|
8095
|
+
IconButton,
|
8096
|
+
{
|
8097
|
+
onClick: () => {
|
8098
|
+
toggleSidebars("right");
|
8099
|
+
},
|
8100
|
+
title: "Toggle right sidebar",
|
8101
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(PanelRight, { focusable: "false" })
|
8102
|
+
}
|
8103
|
+
) })
|
8104
|
+
] }),
|
8105
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)("div", { className: getClassName24("title"), children: /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)(Heading, { rank: "2", size: "xs", children: [
|
8106
|
+
headerTitle || rootTitle || "Page",
|
8107
|
+
headerPath && /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)(import_jsx_runtime38.Fragment, { children: [
|
8108
|
+
" ",
|
8109
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)("code", { className: getClassName24("path"), children: headerPath })
|
8110
|
+
] })
|
8111
|
+
] }) }),
|
8112
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("div", { className: getClassName24("tools"), children: [
|
8113
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)("div", { className: getClassName24("menuButton"), children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
|
8114
|
+
IconButton,
|
8115
|
+
{
|
8116
|
+
onClick: () => {
|
8117
|
+
return setMenuOpen(!menuOpen);
|
8118
|
+
},
|
8119
|
+
title: "Toggle menu bar",
|
8120
|
+
children: menuOpen ? /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(ChevronUp, { focusable: "false" }) : /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(ChevronDown, { focusable: "false" })
|
8121
|
+
}
|
8122
|
+
) }),
|
8123
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
|
8124
|
+
MenuBar,
|
8125
|
+
{
|
8126
|
+
dispatch,
|
8127
|
+
onPublish,
|
8128
|
+
menuOpen,
|
8129
|
+
renderHeaderActions: () => /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(CustomHeaderActions, { children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
|
8130
|
+
Button,
|
8131
|
+
{
|
8132
|
+
onClick: () => {
|
8133
|
+
const data = appStore.getState().state.data;
|
8134
|
+
onPublish && onPublish(data);
|
8135
|
+
},
|
8136
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(Globe, { size: "14px" }),
|
8137
|
+
children: "Publish"
|
8138
|
+
}
|
8139
|
+
) }),
|
8140
|
+
setMenuOpen
|
8141
|
+
}
|
8142
|
+
)
|
8143
|
+
] })
|
8144
|
+
] })
|
8145
|
+
}
|
8146
|
+
)
|
8188
8147
|
}
|
8189
|
-
|
8190
|
-
|
8191
|
-
|
8192
|
-
|
8193
|
-
|
8148
|
+
);
|
8149
|
+
};
|
8150
|
+
var Header = (0, import_react52.memo)(HeaderInner);
|
8151
|
+
|
8152
|
+
// components/SidebarSection/index.tsx
|
8153
|
+
init_react_import();
|
8154
|
+
|
8155
|
+
// css-module:/home/runner/work/puck/puck/packages/core/components/SidebarSection/styles.module.css#css-module
|
8156
|
+
init_react_import();
|
8157
|
+
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" };
|
8158
|
+
|
8159
|
+
// lib/use-breadcrumbs.ts
|
8160
|
+
init_react_import();
|
8161
|
+
var import_react53 = require("react");
|
8162
|
+
var useBreadcrumbs = (renderCount) => {
|
8163
|
+
const selectedId = useAppStore((s) => {
|
8164
|
+
var _a;
|
8165
|
+
return (_a = s.selectedItem) == null ? void 0 : _a.props.id;
|
8166
|
+
});
|
8167
|
+
const config = useAppStore((s) => s.config);
|
8168
|
+
const path = useAppStore((s) => {
|
8169
|
+
var _a;
|
8170
|
+
return (_a = s.state.indexes.nodes[selectedId]) == null ? void 0 : _a.path;
|
8171
|
+
});
|
8172
|
+
const appStore = useAppStoreApi();
|
8173
|
+
return (0, import_react53.useMemo)(() => {
|
8174
|
+
const breadcrumbs = (path == null ? void 0 : path.map((zoneCompound) => {
|
8175
|
+
var _a, _b, _c;
|
8176
|
+
const [componentId] = zoneCompound.split(":");
|
8177
|
+
if (componentId === "root") {
|
8178
|
+
return {
|
8179
|
+
label: "Page",
|
8180
|
+
selector: null
|
8181
|
+
};
|
8182
|
+
}
|
8183
|
+
const node = appStore.getState().state.indexes.nodes[componentId];
|
8184
|
+
const parentId = node.path[node.path.length - 1];
|
8185
|
+
const contentIds = ((_a = appStore.getState().state.indexes.zones[parentId]) == null ? void 0 : _a.contentIds) || [];
|
8186
|
+
const index = contentIds.indexOf(componentId);
|
8187
|
+
const label = node ? (_c = (_b = config.components[node.data.type]) == null ? void 0 : _b.label) != null ? _c : node.data.type : "Component";
|
8188
|
+
return {
|
8189
|
+
label,
|
8190
|
+
selector: node ? {
|
8191
|
+
index,
|
8192
|
+
zone: node.path[node.path.length - 1]
|
8193
|
+
} : null
|
8194
|
+
};
|
8195
|
+
})) || [];
|
8196
|
+
if (renderCount) {
|
8197
|
+
return breadcrumbs.slice(breadcrumbs.length - renderCount);
|
8194
8198
|
}
|
8195
|
-
|
8196
|
-
|
8197
|
-
|
8198
|
-
|
8199
|
-
|
8200
|
-
|
8201
|
-
|
8202
|
-
|
8203
|
-
|
8204
|
-
|
8205
|
-
|
8206
|
-
|
8207
|
-
|
8208
|
-
|
8209
|
-
|
8210
|
-
|
8211
|
-
|
8212
|
-
|
8199
|
+
return breadcrumbs;
|
8200
|
+
}, [path, renderCount]);
|
8201
|
+
};
|
8202
|
+
|
8203
|
+
// components/SidebarSection/index.tsx
|
8204
|
+
var import_jsx_runtime39 = require("react/jsx-runtime");
|
8205
|
+
var getClassName25 = get_class_name_factory_default("SidebarSection", styles_module_default20);
|
8206
|
+
var SidebarSection = ({
|
8207
|
+
children,
|
8208
|
+
title,
|
8209
|
+
background,
|
8210
|
+
showBreadcrumbs,
|
8211
|
+
noBorderTop,
|
8212
|
+
noPadding,
|
8213
|
+
isLoading
|
8214
|
+
}) => {
|
8215
|
+
const setUi = useAppStore((s) => s.setUi);
|
8216
|
+
const breadcrumbs = useBreadcrumbs(1);
|
8217
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(
|
8213
8218
|
"div",
|
8214
8219
|
{
|
8215
|
-
className: getClassName25({
|
8216
|
-
|
8217
|
-
showLoader
|
8218
|
-
}),
|
8219
|
-
onClick: () => dispatch({
|
8220
|
-
type: "setUi",
|
8221
|
-
ui: { itemSelector: null },
|
8222
|
-
recordHistory: true
|
8223
|
-
}),
|
8220
|
+
className: getClassName25({ noBorderTop, noPadding }),
|
8221
|
+
style: { background },
|
8224
8222
|
children: [
|
8225
|
-
|
8226
|
-
|
8227
|
-
|
8228
|
-
|
8229
|
-
|
8230
|
-
|
8231
|
-
|
8232
|
-
|
8233
|
-
|
8234
|
-
zoom: zoomConfig.zoom
|
8235
|
-
});
|
8236
|
-
const newUi = {
|
8237
|
-
viewports: __spreadProps(__spreadValues({}, viewports), { current: uiViewport }),
|
8238
|
-
itemSelector: null
|
8239
|
-
};
|
8240
|
-
setUi(newUi);
|
8241
|
-
if (ZOOM_ON_CHANGE) {
|
8242
|
-
resetAutoZoom(__spreadProps(__spreadValues({}, viewports), { current: uiViewport }));
|
8223
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { className: getClassName25("title"), children: /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: getClassName25("breadcrumbs"), children: [
|
8224
|
+
showBreadcrumbs ? breadcrumbs.map((breadcrumb, i) => /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: getClassName25("breadcrumb"), children: [
|
8225
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
8226
|
+
"button",
|
8227
|
+
{
|
8228
|
+
type: "button",
|
8229
|
+
className: getClassName25("breadcrumbLabel"),
|
8230
|
+
onClick: () => setUi({ itemSelector: breadcrumb.selector }),
|
8231
|
+
children: breadcrumb.label
|
8243
8232
|
}
|
8244
|
-
|
8245
|
-
|
8246
|
-
|
8247
|
-
|
8248
|
-
|
8249
|
-
|
8250
|
-
) })
|
8251
|
-
/* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("div", { className: getClassName25("inner"), ref: frameRef, children: [
|
8252
|
-
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
|
8253
|
-
"div",
|
8254
|
-
{
|
8255
|
-
className: getClassName25("root"),
|
8256
|
-
style: {
|
8257
|
-
width: iframe.enabled ? viewports.current.width : "100%",
|
8258
|
-
height: zoomConfig.rootHeight,
|
8259
|
-
transform: iframe.enabled ? `scale(${zoomConfig.zoom})` : void 0,
|
8260
|
-
transition: showTransition ? "width 150ms ease-out, height 150ms ease-out, transform 150ms ease-out" : "",
|
8261
|
-
overflow: iframe.enabled ? void 0 : "auto"
|
8262
|
-
},
|
8263
|
-
suppressHydrationWarning: true,
|
8264
|
-
id: "puck-canvas-root",
|
8265
|
-
onTransitionEnd: () => {
|
8266
|
-
window.dispatchEvent(
|
8267
|
-
new CustomEvent("viewportchange", {
|
8268
|
-
bubbles: true,
|
8269
|
-
cancelable: false
|
8270
|
-
})
|
8271
|
-
);
|
8272
|
-
},
|
8273
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(CustomPreview, { children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(Preview2, {}) })
|
8274
|
-
}
|
8275
|
-
),
|
8276
|
-
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)("div", { className: getClassName25("loader"), children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(Loader, { size: 24 }) })
|
8277
|
-
] })
|
8233
|
+
),
|
8234
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(ChevronRight, { size: 16 })
|
8235
|
+
] }, i)) : null,
|
8236
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { className: getClassName25("heading"), children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Heading, { rank: "2", size: "xs", children: title }) })
|
8237
|
+
] }) }),
|
8238
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { className: getClassName25("content"), children }),
|
8239
|
+
isLoading && /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { className: getClassName25("loadingOverlay"), children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Loader, { size: 32 }) })
|
8278
8240
|
]
|
8279
8241
|
}
|
8280
8242
|
);
|
8281
8243
|
};
|
8282
8244
|
|
8283
|
-
//
|
8245
|
+
// components/Puck/components/Canvas/index.tsx
|
8284
8246
|
init_react_import();
|
8285
|
-
var import_react51 = require("react");
|
8286
8247
|
|
8287
|
-
//
|
8248
|
+
// ../../node_modules/css-box-model/dist/css-box-model.esm.js
|
8288
8249
|
init_react_import();
|
8289
|
-
|
8290
|
-
|
8291
|
-
|
8292
|
-
|
8293
|
-
|
8294
|
-
|
8295
|
-
|
8296
|
-
|
8297
|
-
|
8298
|
-
|
8299
|
-
|
8300
|
-
|
8301
|
-
|
8302
|
-
|
8303
|
-
|
8304
|
-
|
8305
|
-
|
8306
|
-
|
8307
|
-
|
8308
|
-
|
8309
|
-
|
8310
|
-
|
8311
|
-
|
8312
|
-
|
8313
|
-
|
8314
|
-
|
8250
|
+
|
8251
|
+
// ../../node_modules/tiny-invariant/dist/esm/tiny-invariant.js
|
8252
|
+
init_react_import();
|
8253
|
+
var isProduction = process.env.NODE_ENV === "production";
|
8254
|
+
var prefix = "Invariant failed";
|
8255
|
+
function invariant(condition, message) {
|
8256
|
+
if (condition) {
|
8257
|
+
return;
|
8258
|
+
}
|
8259
|
+
if (isProduction) {
|
8260
|
+
throw new Error(prefix);
|
8261
|
+
}
|
8262
|
+
var provided = typeof message === "function" ? message() : message;
|
8263
|
+
var value = provided ? "".concat(prefix, ": ").concat(provided) : prefix;
|
8264
|
+
throw new Error(value);
|
8265
|
+
}
|
8266
|
+
|
8267
|
+
// ../../node_modules/css-box-model/dist/css-box-model.esm.js
|
8268
|
+
var getRect = function getRect2(_ref) {
|
8269
|
+
var top = _ref.top, right = _ref.right, bottom = _ref.bottom, left = _ref.left;
|
8270
|
+
var width = right - left;
|
8271
|
+
var height = bottom - top;
|
8272
|
+
var rect = {
|
8273
|
+
top,
|
8274
|
+
right,
|
8275
|
+
bottom,
|
8276
|
+
left,
|
8277
|
+
width,
|
8278
|
+
height,
|
8279
|
+
x: left,
|
8280
|
+
y: top,
|
8281
|
+
center: {
|
8282
|
+
x: (right + left) / 2,
|
8283
|
+
y: (bottom + top) / 2
|
8284
|
+
}
|
8285
|
+
};
|
8286
|
+
return rect;
|
8287
|
+
};
|
8288
|
+
var expand = function expand2(target, expandBy) {
|
8289
|
+
return {
|
8290
|
+
top: target.top - expandBy.top,
|
8291
|
+
left: target.left - expandBy.left,
|
8292
|
+
bottom: target.bottom + expandBy.bottom,
|
8293
|
+
right: target.right + expandBy.right
|
8294
|
+
};
|
8295
|
+
};
|
8296
|
+
var shrink = function shrink2(target, shrinkBy) {
|
8297
|
+
return {
|
8298
|
+
top: target.top + shrinkBy.top,
|
8299
|
+
left: target.left + shrinkBy.left,
|
8300
|
+
bottom: target.bottom - shrinkBy.bottom,
|
8301
|
+
right: target.right - shrinkBy.right
|
8302
|
+
};
|
8303
|
+
};
|
8304
|
+
var noSpacing = {
|
8305
|
+
top: 0,
|
8306
|
+
right: 0,
|
8307
|
+
bottom: 0,
|
8308
|
+
left: 0
|
8309
|
+
};
|
8310
|
+
var createBox = function createBox2(_ref2) {
|
8311
|
+
var borderBox = _ref2.borderBox, _ref2$margin = _ref2.margin, margin = _ref2$margin === void 0 ? noSpacing : _ref2$margin, _ref2$border = _ref2.border, border = _ref2$border === void 0 ? noSpacing : _ref2$border, _ref2$padding = _ref2.padding, padding = _ref2$padding === void 0 ? noSpacing : _ref2$padding;
|
8312
|
+
var marginBox = getRect(expand(borderBox, margin));
|
8313
|
+
var paddingBox = getRect(shrink(borderBox, border));
|
8314
|
+
var contentBox = getRect(shrink(paddingBox, padding));
|
8315
|
+
return {
|
8316
|
+
marginBox,
|
8317
|
+
borderBox: getRect(borderBox),
|
8318
|
+
paddingBox,
|
8319
|
+
contentBox,
|
8320
|
+
margin,
|
8321
|
+
border,
|
8322
|
+
padding
|
8323
|
+
};
|
8324
|
+
};
|
8325
|
+
var parse = function parse2(raw) {
|
8326
|
+
var value = raw.slice(0, -2);
|
8327
|
+
var suffix = raw.slice(-2);
|
8328
|
+
if (suffix !== "px") {
|
8329
|
+
return 0;
|
8330
|
+
}
|
8331
|
+
var result = Number(value);
|
8332
|
+
!!isNaN(result) ? process.env.NODE_ENV !== "production" ? invariant(false, "Could not parse value [raw: " + raw + ", without suffix: " + value + "]") : invariant(false) : void 0;
|
8333
|
+
return result;
|
8334
|
+
};
|
8335
|
+
var calculateBox = function calculateBox2(borderBox, styles2) {
|
8336
|
+
var margin = {
|
8337
|
+
top: parse(styles2.marginTop),
|
8338
|
+
right: parse(styles2.marginRight),
|
8339
|
+
bottom: parse(styles2.marginBottom),
|
8340
|
+
left: parse(styles2.marginLeft)
|
8341
|
+
};
|
8342
|
+
var padding = {
|
8343
|
+
top: parse(styles2.paddingTop),
|
8344
|
+
right: parse(styles2.paddingRight),
|
8345
|
+
bottom: parse(styles2.paddingBottom),
|
8346
|
+
left: parse(styles2.paddingLeft)
|
8347
|
+
};
|
8348
|
+
var border = {
|
8349
|
+
top: parse(styles2.borderTopWidth),
|
8350
|
+
right: parse(styles2.borderRightWidth),
|
8351
|
+
bottom: parse(styles2.borderBottomWidth),
|
8352
|
+
left: parse(styles2.borderLeftWidth)
|
8353
|
+
};
|
8354
|
+
return createBox({
|
8355
|
+
borderBox,
|
8356
|
+
margin,
|
8357
|
+
padding,
|
8358
|
+
border
|
8315
8359
|
});
|
8316
|
-
|
8360
|
+
};
|
8361
|
+
var getBox = function getBox2(el) {
|
8362
|
+
var borderBox = el.getBoundingClientRect();
|
8363
|
+
var styles2 = window.getComputedStyle(el);
|
8364
|
+
return calculateBox(borderBox, styles2);
|
8317
8365
|
};
|
8318
8366
|
|
8319
|
-
//
|
8320
|
-
var
|
8321
|
-
overrides,
|
8322
|
-
plugins
|
8323
|
-
}) => {
|
8324
|
-
return (0, import_react51.useMemo)(() => {
|
8325
|
-
return loadOverrides({ overrides, plugins });
|
8326
|
-
}, [plugins, overrides]);
|
8327
|
-
};
|
8367
|
+
// components/Puck/components/Canvas/index.tsx
|
8368
|
+
var import_react55 = require("react");
|
8328
8369
|
|
8329
|
-
// components/
|
8370
|
+
// components/ViewportControls/index.tsx
|
8330
8371
|
init_react_import();
|
8331
|
-
var
|
8332
|
-
var DefaultOverride = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(import_jsx_runtime39.Fragment, { children });
|
8372
|
+
var import_react54 = require("react");
|
8333
8373
|
|
8334
|
-
//
|
8374
|
+
// css-module:/home/runner/work/puck/puck/packages/core/components/ViewportControls/styles.module.css#css-module
|
8335
8375
|
init_react_import();
|
8336
|
-
var
|
8337
|
-
var styles = ``;
|
8338
|
-
var useInjectStyleSheet = (initialStyles, iframeEnabled) => {
|
8339
|
-
const [el, setEl] = (0, import_react52.useState)();
|
8340
|
-
(0, import_react52.useEffect)(() => {
|
8341
|
-
setEl(document.createElement("style"));
|
8342
|
-
}, []);
|
8343
|
-
(0, import_react52.useEffect)(() => {
|
8344
|
-
var _a;
|
8345
|
-
if (!el || typeof window === "undefined") {
|
8346
|
-
return;
|
8347
|
-
}
|
8348
|
-
el.innerHTML = initialStyles;
|
8349
|
-
if (iframeEnabled) {
|
8350
|
-
const frame = getFrame();
|
8351
|
-
(_a = frame == null ? void 0 : frame.head) == null ? void 0 : _a.appendChild(el);
|
8352
|
-
}
|
8353
|
-
document.head.appendChild(el);
|
8354
|
-
}, [iframeEnabled, el]);
|
8355
|
-
return el;
|
8356
|
-
};
|
8357
|
-
var useInjectGlobalCss = (iframeEnabled) => {
|
8358
|
-
return useInjectStyleSheet(styles, iframeEnabled);
|
8359
|
-
};
|
8376
|
+
var styles_module_default21 = { "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" };
|
8360
8377
|
|
8361
|
-
//
|
8362
|
-
|
8363
|
-
var
|
8364
|
-
|
8365
|
-
|
8366
|
-
|
8367
|
-
const dispatch = appStore.getState().dispatch;
|
8368
|
-
dispatch({
|
8369
|
-
type: "setUi",
|
8370
|
-
ui: (ui) => ({
|
8371
|
-
previewMode: ui.previewMode === "edit" ? "interactive" : "edit"
|
8372
|
-
})
|
8373
|
-
});
|
8374
|
-
}, [appStore]);
|
8375
|
-
useHotkey({ meta: true, i: true }, toggleInteractive);
|
8376
|
-
useHotkey({ ctrl: true, i: true }, toggleInteractive);
|
8378
|
+
// components/ViewportControls/index.tsx
|
8379
|
+
var import_jsx_runtime40 = require("react/jsx-runtime");
|
8380
|
+
var icons = {
|
8381
|
+
Smartphone: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(Smartphone, { size: 16 }),
|
8382
|
+
Tablet: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(Tablet, { size: 16 }),
|
8383
|
+
Monitor: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(Monitor, { size: 16 })
|
8377
8384
|
};
|
8378
|
-
|
8379
|
-
|
8380
|
-
|
8381
|
-
|
8382
|
-
|
8383
|
-
|
8384
|
-
|
8385
|
-
|
8386
|
-
|
8387
|
-
|
8388
|
-
|
8389
|
-
|
8390
|
-
|
8391
|
-
|
8392
|
-
|
8393
|
-
|
8394
|
-
|
8395
|
-
|
8396
|
-
|
8397
|
-
|
8398
|
-
|
8399
|
-
|
8400
|
-
|
8401
|
-
|
8402
|
-
getItemBySelector: (selector) => getItem(selector, store.state),
|
8403
|
-
getItemById: (id) => store.state.indexes.nodes[id].data,
|
8404
|
-
getSelectorForId: (id) => {
|
8405
|
-
const node = store.state.indexes.nodes[id];
|
8406
|
-
if (!node) return;
|
8407
|
-
const zoneCompound = `${node.parentId}:${node.zone}`;
|
8408
|
-
const index = store.state.indexes.zones[zoneCompound].contentIds.indexOf(id);
|
8409
|
-
return { zone: zoneCompound, index };
|
8385
|
+
var getClassName26 = get_class_name_factory_default("ViewportControls", styles_module_default21);
|
8386
|
+
var getClassNameButton = get_class_name_factory_default("ViewportButton", styles_module_default21);
|
8387
|
+
var ViewportButton = ({
|
8388
|
+
children,
|
8389
|
+
height = "auto",
|
8390
|
+
title,
|
8391
|
+
width,
|
8392
|
+
onClick
|
8393
|
+
}) => {
|
8394
|
+
const viewports = useAppStore((s) => s.state.ui.viewports);
|
8395
|
+
const [isActive, setIsActive] = (0, import_react54.useState)(false);
|
8396
|
+
(0, import_react54.useEffect)(() => {
|
8397
|
+
setIsActive(width === viewports.current.width);
|
8398
|
+
}, [width, viewports.current.width]);
|
8399
|
+
return /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("span", { className: getClassNameButton({ isActive }), children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
|
8400
|
+
IconButton,
|
8401
|
+
{
|
8402
|
+
title,
|
8403
|
+
disabled: isActive,
|
8404
|
+
onClick: (e) => {
|
8405
|
+
e.stopPropagation();
|
8406
|
+
onClick({ width, height });
|
8407
|
+
},
|
8408
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("span", { className: getClassNameButton("inner"), children })
|
8410
8409
|
}
|
8411
|
-
};
|
8412
|
-
const get = () => storeData;
|
8413
|
-
return __spreadProps(__spreadValues({}, storeData), { get });
|
8414
|
-
};
|
8415
|
-
var UsePuckStoreContext = (0, import_react54.createContext)(
|
8416
|
-
null
|
8417
|
-
);
|
8418
|
-
var convertToPickedStore = (store) => {
|
8419
|
-
return {
|
8420
|
-
state: store.state,
|
8421
|
-
config: store.config,
|
8422
|
-
dispatch: store.dispatch,
|
8423
|
-
permissions: store.permissions,
|
8424
|
-
history: store.history,
|
8425
|
-
selectedItem: store.selectedItem
|
8426
|
-
};
|
8410
|
+
) });
|
8427
8411
|
};
|
8428
|
-
var
|
8429
|
-
|
8430
|
-
|
8431
|
-
|
8432
|
-
|
8412
|
+
var defaultZoomOptions = [
|
8413
|
+
{ label: "25%", value: 0.25 },
|
8414
|
+
{ label: "50%", value: 0.5 },
|
8415
|
+
{ label: "75%", value: 0.75 },
|
8416
|
+
{ label: "100%", value: 1 },
|
8417
|
+
{ label: "125%", value: 1.25 },
|
8418
|
+
{ label: "150%", value: 1.5 },
|
8419
|
+
{ label: "200%", value: 2 }
|
8420
|
+
];
|
8421
|
+
var ViewportControls = ({
|
8422
|
+
autoZoom,
|
8423
|
+
zoom,
|
8424
|
+
onViewportChange,
|
8425
|
+
onZoom
|
8426
|
+
}) => {
|
8427
|
+
var _a, _b;
|
8428
|
+
const viewports = useAppStore((s) => s.viewports);
|
8429
|
+
const defaultsContainAutoZoom = defaultZoomOptions.find(
|
8430
|
+
(option) => option.value === autoZoom
|
8433
8431
|
);
|
8434
|
-
(0, import_react54.
|
8435
|
-
|
8436
|
-
|
8437
|
-
|
8438
|
-
|
8432
|
+
const zoomOptions = (0, import_react54.useMemo)(
|
8433
|
+
() => [
|
8434
|
+
...defaultZoomOptions,
|
8435
|
+
...defaultsContainAutoZoom ? [] : [
|
8436
|
+
{
|
8437
|
+
value: autoZoom,
|
8438
|
+
label: `${(autoZoom * 100).toFixed(0)}% (Auto)`
|
8439
|
+
}
|
8440
|
+
]
|
8441
|
+
].filter((a) => a.value <= autoZoom).sort((a, b) => a.value > b.value ? 1 : -1),
|
8442
|
+
[autoZoom]
|
8443
|
+
);
|
8444
|
+
return /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)("div", { className: getClassName26(), children: [
|
8445
|
+
viewports.map((viewport, i) => /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
|
8446
|
+
ViewportButton,
|
8447
|
+
{
|
8448
|
+
height: viewport.height,
|
8449
|
+
width: viewport.width,
|
8450
|
+
title: viewport.label ? `Switch to ${viewport.label} viewport` : "Switch viewport",
|
8451
|
+
onClick: onViewportChange,
|
8452
|
+
children: typeof viewport.icon === "string" ? icons[viewport.icon] || viewport.icon : viewport.icon || icons.Smartphone
|
8453
|
+
},
|
8454
|
+
i
|
8455
|
+
)),
|
8456
|
+
/* @__PURE__ */ (0, import_jsx_runtime40.jsx)("div", { className: getClassName26("divider") }),
|
8457
|
+
/* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
|
8458
|
+
IconButton,
|
8459
|
+
{
|
8460
|
+
title: "Zoom viewport out",
|
8461
|
+
disabled: zoom <= ((_a = zoomOptions[0]) == null ? void 0 : _a.value),
|
8462
|
+
onClick: (e) => {
|
8463
|
+
e.stopPropagation();
|
8464
|
+
onZoom(
|
8465
|
+
zoomOptions[Math.max(
|
8466
|
+
zoomOptions.findIndex((option) => option.value === zoom) - 1,
|
8467
|
+
0
|
8468
|
+
)].value
|
8469
|
+
);
|
8470
|
+
},
|
8471
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(ZoomOut, { size: 16 })
|
8439
8472
|
}
|
8440
|
-
)
|
8441
|
-
|
8442
|
-
|
8473
|
+
),
|
8474
|
+
/* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
|
8475
|
+
IconButton,
|
8476
|
+
{
|
8477
|
+
title: "Zoom viewport in",
|
8478
|
+
disabled: zoom >= ((_b = zoomOptions[zoomOptions.length - 1]) == null ? void 0 : _b.value),
|
8479
|
+
onClick: (e) => {
|
8480
|
+
e.stopPropagation();
|
8481
|
+
onZoom(
|
8482
|
+
zoomOptions[Math.min(
|
8483
|
+
zoomOptions.findIndex((option) => option.value === zoom) + 1,
|
8484
|
+
zoomOptions.length - 1
|
8485
|
+
)].value
|
8486
|
+
);
|
8487
|
+
},
|
8488
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(ZoomIn, { size: 16 })
|
8489
|
+
}
|
8490
|
+
),
|
8491
|
+
/* @__PURE__ */ (0, import_jsx_runtime40.jsx)("div", { className: getClassName26("divider") }),
|
8492
|
+
/* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
|
8493
|
+
"select",
|
8494
|
+
{
|
8495
|
+
className: getClassName26("zoomSelect"),
|
8496
|
+
value: zoom.toString(),
|
8497
|
+
onChange: (e) => {
|
8498
|
+
onZoom(parseFloat(e.currentTarget.value));
|
8499
|
+
},
|
8500
|
+
children: zoomOptions.map((option) => /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
|
8501
|
+
"option",
|
8502
|
+
{
|
8503
|
+
value: option.value,
|
8504
|
+
label: option.label
|
8505
|
+
},
|
8506
|
+
option.label
|
8507
|
+
))
|
8508
|
+
}
|
8509
|
+
)
|
8510
|
+
] });
|
8443
8511
|
};
|
8444
|
-
function createUsePuck() {
|
8445
|
-
return function usePuck2(selector) {
|
8446
|
-
const usePuckApi = (0, import_react54.useContext)(UsePuckStoreContext);
|
8447
|
-
if (!usePuckApi) {
|
8448
|
-
throw new Error("usePuck must be used inside <Puck>.");
|
8449
|
-
}
|
8450
|
-
const result = (0, import_zustand6.useStore)(
|
8451
|
-
usePuckApi,
|
8452
|
-
selector != null ? selector : (s) => s
|
8453
|
-
);
|
8454
|
-
return result;
|
8455
|
-
};
|
8456
|
-
}
|
8457
|
-
function usePuck() {
|
8458
|
-
(0, import_react54.useEffect)(() => {
|
8459
|
-
console.warn(
|
8460
|
-
"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."
|
8461
|
-
);
|
8462
|
-
}, []);
|
8463
|
-
return createUsePuck()((s) => s);
|
8464
|
-
}
|
8465
|
-
function useGetPuck() {
|
8466
|
-
const usePuckApi = (0, import_react54.useContext)(UsePuckStoreContext);
|
8467
|
-
if (!usePuckApi) {
|
8468
|
-
throw new Error("usePuckGet must be used inside <Puck>.");
|
8469
|
-
}
|
8470
|
-
return usePuckApi.getState;
|
8471
|
-
}
|
8472
|
-
|
8473
|
-
// components/Puck/index.tsx
|
8474
|
-
var import_fast_deep_equal3 = __toESM(require("fast-deep-equal"));
|
8475
|
-
|
8476
|
-
// components/Puck/components/Header/index.tsx
|
8477
|
-
init_react_import();
|
8478
|
-
var import_react55 = require("react");
|
8479
8512
|
|
8480
|
-
// components/
|
8513
|
+
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Canvas/styles.module.css#css-module
|
8481
8514
|
init_react_import();
|
8515
|
+
var styles_module_default22 = { "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" };
|
8482
8516
|
|
8483
|
-
//
|
8517
|
+
// lib/get-zoom-config.ts
|
8484
8518
|
init_react_import();
|
8485
|
-
var
|
8519
|
+
var RESET_ZOOM_SMALLER_THAN_FRAME = true;
|
8520
|
+
var getZoomConfig = (uiViewport, frame, zoom) => {
|
8521
|
+
const box = getBox(frame);
|
8522
|
+
const { width: frameWidth, height: frameHeight } = box.contentBox;
|
8523
|
+
const viewportHeight = uiViewport.height === "auto" ? frameHeight : uiViewport.height;
|
8524
|
+
let rootHeight = 0;
|
8525
|
+
let autoZoom = 1;
|
8526
|
+
if (uiViewport.width > frameWidth || viewportHeight > frameHeight) {
|
8527
|
+
const widthZoom = Math.min(frameWidth / uiViewport.width, 1);
|
8528
|
+
const heightZoom = Math.min(frameHeight / viewportHeight, 1);
|
8529
|
+
zoom = widthZoom;
|
8530
|
+
if (widthZoom < heightZoom) {
|
8531
|
+
rootHeight = viewportHeight / zoom;
|
8532
|
+
} else {
|
8533
|
+
rootHeight = viewportHeight;
|
8534
|
+
zoom = heightZoom;
|
8535
|
+
}
|
8536
|
+
autoZoom = zoom;
|
8537
|
+
} else {
|
8538
|
+
if (RESET_ZOOM_SMALLER_THAN_FRAME) {
|
8539
|
+
autoZoom = 1;
|
8540
|
+
zoom = 1;
|
8541
|
+
rootHeight = viewportHeight;
|
8542
|
+
}
|
8543
|
+
}
|
8544
|
+
return { autoZoom, rootHeight, zoom };
|
8545
|
+
};
|
8486
8546
|
|
8487
|
-
// components/
|
8488
|
-
var
|
8489
|
-
var
|
8490
|
-
|
8491
|
-
|
8492
|
-
|
8493
|
-
|
8494
|
-
|
8495
|
-
|
8496
|
-
|
8497
|
-
|
8498
|
-
|
8499
|
-
|
8547
|
+
// components/Puck/components/Canvas/index.tsx
|
8548
|
+
var import_shallow8 = require("zustand/react/shallow");
|
8549
|
+
var import_jsx_runtime41 = require("react/jsx-runtime");
|
8550
|
+
var getClassName27 = get_class_name_factory_default("PuckCanvas", styles_module_default22);
|
8551
|
+
var ZOOM_ON_CHANGE = true;
|
8552
|
+
var Canvas = () => {
|
8553
|
+
const {
|
8554
|
+
dispatch,
|
8555
|
+
overrides,
|
8556
|
+
setUi,
|
8557
|
+
zoomConfig,
|
8558
|
+
setZoomConfig,
|
8559
|
+
status,
|
8560
|
+
iframe
|
8561
|
+
} = useAppStore(
|
8562
|
+
(0, import_shallow8.useShallow)((s) => ({
|
8563
|
+
dispatch: s.dispatch,
|
8564
|
+
overrides: s.overrides,
|
8565
|
+
setUi: s.setUi,
|
8566
|
+
zoomConfig: s.zoomConfig,
|
8567
|
+
setZoomConfig: s.setZoomConfig,
|
8568
|
+
status: s.status,
|
8569
|
+
iframe: s.iframe
|
8570
|
+
}))
|
8571
|
+
);
|
8572
|
+
const { leftSideBarVisible, rightSideBarVisible, viewports } = useAppStore(
|
8573
|
+
(0, import_shallow8.useShallow)((s) => ({
|
8574
|
+
leftSideBarVisible: s.state.ui.leftSideBarVisible,
|
8575
|
+
rightSideBarVisible: s.state.ui.rightSideBarVisible,
|
8576
|
+
viewports: s.state.ui.viewports
|
8577
|
+
}))
|
8578
|
+
);
|
8579
|
+
const frameRef = (0, import_react55.useRef)(null);
|
8580
|
+
const [showTransition, setShowTransition] = (0, import_react55.useState)(false);
|
8581
|
+
const defaultRender = (0, import_react55.useMemo)(() => {
|
8582
|
+
const PuckDefault = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(import_jsx_runtime41.Fragment, { children });
|
8583
|
+
return PuckDefault;
|
8584
|
+
}, []);
|
8585
|
+
const CustomPreview = (0, import_react55.useMemo)(
|
8586
|
+
() => overrides.preview || defaultRender,
|
8587
|
+
[overrides]
|
8588
|
+
);
|
8589
|
+
const getFrameDimensions = (0, import_react55.useCallback)(() => {
|
8590
|
+
if (frameRef.current) {
|
8591
|
+
const frame = frameRef.current;
|
8592
|
+
const box = getBox(frame);
|
8593
|
+
return { width: box.contentBox.width, height: box.contentBox.height };
|
8594
|
+
}
|
8595
|
+
return { width: 0, height: 0 };
|
8596
|
+
}, [frameRef]);
|
8597
|
+
const resetAutoZoom = (0, import_react55.useCallback)(
|
8598
|
+
(newViewports = viewports) => {
|
8599
|
+
if (frameRef.current) {
|
8600
|
+
setZoomConfig(
|
8601
|
+
getZoomConfig(
|
8602
|
+
newViewports == null ? void 0 : newViewports.current,
|
8603
|
+
frameRef.current,
|
8604
|
+
zoomConfig.zoom
|
8605
|
+
)
|
8606
|
+
);
|
8607
|
+
}
|
8608
|
+
},
|
8609
|
+
[frameRef, zoomConfig, viewports]
|
8610
|
+
);
|
8611
|
+
(0, import_react55.useEffect)(() => {
|
8612
|
+
setShowTransition(false);
|
8613
|
+
resetAutoZoom(viewports);
|
8614
|
+
}, [frameRef, leftSideBarVisible, rightSideBarVisible]);
|
8615
|
+
(0, import_react55.useEffect)(() => {
|
8616
|
+
const { height: frameHeight } = getFrameDimensions();
|
8617
|
+
if (viewports.current.height === "auto") {
|
8618
|
+
setZoomConfig(__spreadProps(__spreadValues({}, zoomConfig), {
|
8619
|
+
rootHeight: frameHeight / zoomConfig.zoom
|
8620
|
+
}));
|
8621
|
+
}
|
8622
|
+
}, [zoomConfig.zoom]);
|
8623
|
+
(0, import_react55.useEffect)(() => {
|
8624
|
+
if (ZOOM_ON_CHANGE) {
|
8625
|
+
setShowTransition(true);
|
8626
|
+
resetAutoZoom(viewports);
|
8627
|
+
}
|
8628
|
+
}, [viewports.current.width]);
|
8629
|
+
(0, import_react55.useEffect)(() => {
|
8630
|
+
const cb = () => {
|
8631
|
+
setShowTransition(false);
|
8632
|
+
resetAutoZoom();
|
8633
|
+
};
|
8634
|
+
window.addEventListener("resize", cb);
|
8635
|
+
return () => {
|
8636
|
+
window.removeEventListener("resize", cb);
|
8637
|
+
};
|
8638
|
+
}, []);
|
8639
|
+
const [showLoader, setShowLoader] = (0, import_react55.useState)(false);
|
8640
|
+
(0, import_react55.useEffect)(() => {
|
8641
|
+
setTimeout(() => {
|
8642
|
+
setShowLoader(true);
|
8643
|
+
}, 500);
|
8644
|
+
}, []);
|
8645
|
+
return /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(
|
8500
8646
|
"div",
|
8501
8647
|
{
|
8502
|
-
className:
|
8503
|
-
|
8504
|
-
|
8505
|
-
|
8506
|
-
|
8507
|
-
|
8508
|
-
}
|
8509
|
-
|
8510
|
-
|
8511
|
-
|
8512
|
-
|
8513
|
-
|
8514
|
-
|
8515
|
-
|
8516
|
-
|
8517
|
-
|
8518
|
-
|
8519
|
-
|
8648
|
+
className: getClassName27({
|
8649
|
+
ready: status === "READY" || !iframe.enabled || !iframe.waitForStyles,
|
8650
|
+
showLoader
|
8651
|
+
}),
|
8652
|
+
onClick: () => dispatch({
|
8653
|
+
type: "setUi",
|
8654
|
+
ui: { itemSelector: null },
|
8655
|
+
recordHistory: true
|
8656
|
+
}),
|
8657
|
+
children: [
|
8658
|
+
viewports.controlsVisible && iframe.enabled && /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { className: getClassName27("controls"), children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
|
8659
|
+
ViewportControls,
|
8660
|
+
{
|
8661
|
+
autoZoom: zoomConfig.autoZoom,
|
8662
|
+
zoom: zoomConfig.zoom,
|
8663
|
+
onViewportChange: (viewport) => {
|
8664
|
+
setShowTransition(true);
|
8665
|
+
const uiViewport = __spreadProps(__spreadValues({}, viewport), {
|
8666
|
+
height: viewport.height || "auto",
|
8667
|
+
zoom: zoomConfig.zoom
|
8668
|
+
});
|
8669
|
+
const newUi = {
|
8670
|
+
viewports: __spreadProps(__spreadValues({}, viewports), { current: uiViewport }),
|
8671
|
+
itemSelector: null
|
8672
|
+
};
|
8673
|
+
setUi(newUi);
|
8674
|
+
if (ZOOM_ON_CHANGE) {
|
8675
|
+
resetAutoZoom(__spreadProps(__spreadValues({}, viewports), { current: uiViewport }));
|
8676
|
+
}
|
8677
|
+
},
|
8678
|
+
onZoom: (zoom) => {
|
8679
|
+
setShowTransition(true);
|
8680
|
+
setZoomConfig(__spreadProps(__spreadValues({}, zoomConfig), { zoom }));
|
8681
|
+
}
|
8682
|
+
}
|
8683
|
+
) }),
|
8684
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: getClassName27("inner"), ref: frameRef, children: [
|
8685
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
|
8686
|
+
"div",
|
8687
|
+
{
|
8688
|
+
className: getClassName27("root"),
|
8689
|
+
style: {
|
8690
|
+
width: iframe.enabled ? viewports.current.width : "100%",
|
8691
|
+
height: zoomConfig.rootHeight,
|
8692
|
+
transform: iframe.enabled ? `scale(${zoomConfig.zoom})` : void 0,
|
8693
|
+
transition: showTransition ? "width 150ms ease-out, height 150ms ease-out, transform 150ms ease-out" : "",
|
8694
|
+
overflow: iframe.enabled ? void 0 : "auto"
|
8695
|
+
},
|
8696
|
+
suppressHydrationWarning: true,
|
8697
|
+
id: "puck-canvas-root",
|
8698
|
+
onTransitionEnd: () => {
|
8699
|
+
window.dispatchEvent(
|
8700
|
+
new CustomEvent("viewportchange", {
|
8701
|
+
bubbles: true,
|
8702
|
+
cancelable: false
|
8703
|
+
})
|
8704
|
+
);
|
8705
|
+
},
|
8706
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(CustomPreview, { children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Preview2, {}) })
|
8707
|
+
}
|
8708
|
+
),
|
8709
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { className: getClassName27("loader"), children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Loader, { size: 24 }) })
|
8710
|
+
] })
|
8711
|
+
]
|
8520
8712
|
}
|
8521
8713
|
);
|
8522
|
-
}
|
8714
|
+
};
|
8523
8715
|
|
8524
|
-
//
|
8716
|
+
// components/Puck/components/Nav/index.tsx
|
8525
8717
|
init_react_import();
|
8526
|
-
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" };
|
8527
8718
|
|
8528
|
-
// components/Puck/components/
|
8529
|
-
|
8530
|
-
var
|
8531
|
-
|
8532
|
-
|
8533
|
-
|
8534
|
-
|
8535
|
-
|
8536
|
-
|
8537
|
-
|
8538
|
-
|
8539
|
-
|
8540
|
-
|
8541
|
-
|
8542
|
-
|
8543
|
-
|
8544
|
-
|
8545
|
-
|
8546
|
-
|
8547
|
-
|
8548
|
-
|
8549
|
-
|
8550
|
-
|
8551
|
-
|
8552
|
-
|
8553
|
-
|
8554
|
-
|
8555
|
-
|
8556
|
-
|
8557
|
-
|
8558
|
-
|
8559
|
-
|
8560
|
-
|
8561
|
-
|
8562
|
-
|
8563
|
-
|
8564
|
-
|
8565
|
-
|
8566
|
-
|
8567
|
-
|
8568
|
-
|
8569
|
-
|
8570
|
-
|
8571
|
-
|
8572
|
-
|
8719
|
+
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Nav/styles.module.css#css-module
|
8720
|
+
init_react_import();
|
8721
|
+
var styles_module_default23 = { "Nav-list": "_Nav-list_b6txo_1", "NavSection": "_NavSection_b6txo_7", "Nav--slim": "_Nav--slim_b6txo_15", "NavSection-list": "_NavSection-list_b6txo_24", "NavSection-title": "_NavSection-title_b6txo_36", "NavItem-link": "_NavItem-link_b6txo_47", "NavItem-linkIcon": "_NavItem-linkIcon_b6txo_67", "NavItem--active": "_NavItem--active_b6txo_72", "NavItem": "_NavItem_b6txo_47", "NavItem-list": "_NavItem-list_b6txo_91" };
|
8722
|
+
|
8723
|
+
// components/Puck/components/Nav/index.tsx
|
8724
|
+
var import_jsx_runtime42 = require("react/jsx-runtime");
|
8725
|
+
var getClassName28 = get_class_name_factory_default("Nav", styles_module_default23);
|
8726
|
+
var getClassNameSection = get_class_name_factory_default("NavSection", styles_module_default23);
|
8727
|
+
var getClassNameItem3 = get_class_name_factory_default("NavItem", styles_module_default23);
|
8728
|
+
var MenuItem = ({
|
8729
|
+
label,
|
8730
|
+
icon,
|
8731
|
+
items,
|
8732
|
+
onClick,
|
8733
|
+
isActive
|
8734
|
+
}) => {
|
8735
|
+
const showChildren = isActive;
|
8736
|
+
return /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("li", { className: getClassNameItem3({ active: isActive }), children: [
|
8737
|
+
onClick && /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("div", { className: getClassNameItem3("link"), onClick, children: [
|
8738
|
+
icon && /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("span", { className: getClassNameItem3("linkIcon"), children: icon }),
|
8739
|
+
/* @__PURE__ */ (0, import_jsx_runtime42.jsx)("span", { className: getClassNameItem3("linkLabel"), children: label })
|
8740
|
+
] }),
|
8741
|
+
items && showChildren && /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("ul", { className: getClassNameItem3("list"), children: Object.entries(items).map(([key, item]) => /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(MenuItem, __spreadValues({}, item), key)) })
|
8742
|
+
] });
|
8743
|
+
};
|
8744
|
+
var NavSection = ({ title, items }) => {
|
8745
|
+
return /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("li", { className: getClassNameSection(), children: [
|
8746
|
+
title && /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("div", { className: getClassNameSection("title"), children: title }),
|
8747
|
+
/* @__PURE__ */ (0, import_jsx_runtime42.jsx)("ul", { className: getClassNameSection("list"), children: Object.entries(items).map(([key, item]) => /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(MenuItem, __spreadValues({}, item), key)) })
|
8748
|
+
] });
|
8749
|
+
};
|
8750
|
+
var Nav = ({
|
8751
|
+
navigation,
|
8752
|
+
slim
|
8753
|
+
}) => {
|
8754
|
+
return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("nav", { className: getClassName28({ slim }), children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("ul", { className: getClassName28("list"), children: Object.entries(navigation).map(([key, section]) => {
|
8755
|
+
return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(NavSection, { title: section.title, items: section.items }, key);
|
8756
|
+
}) }) });
|
8757
|
+
};
|
8758
|
+
|
8759
|
+
// components/Puck/components/Layout/index.tsx
|
8760
|
+
var import_jsx_runtime43 = require("react/jsx-runtime");
|
8761
|
+
var getClassName29 = get_class_name_factory_default("Puck", styles_module_default17);
|
8762
|
+
var getLayoutClassName = get_class_name_factory_default("PuckLayout", styles_module_default17);
|
8763
|
+
var FieldSideBar = () => {
|
8764
|
+
const title = useAppStore(
|
8765
|
+
(s) => {
|
8766
|
+
var _a, _b;
|
8767
|
+
return s.selectedItem ? (_b = (_a = s.config.components[s.selectedItem.type]) == null ? void 0 : _a["label"]) != null ? _b : s.selectedItem.type.toString() : "Page";
|
8768
|
+
}
|
8573
8769
|
);
|
8574
|
-
|
8575
|
-
|
8770
|
+
return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(SidebarSection, { noPadding: true, noBorderTop: true, showBreadcrumbs: true, title, children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Fields, {}) });
|
8771
|
+
};
|
8772
|
+
var Layout = ({ children }) => {
|
8773
|
+
const {
|
8774
|
+
iframe: _iframe,
|
8775
|
+
dnd,
|
8776
|
+
initialHistory: _initialHistory,
|
8777
|
+
plugins
|
8778
|
+
} = usePropsContext();
|
8779
|
+
const iframe = (0, import_react56.useMemo)(
|
8780
|
+
() => __spreadValues({
|
8781
|
+
enabled: true,
|
8782
|
+
waitForStyles: true
|
8783
|
+
}, _iframe),
|
8784
|
+
[_iframe]
|
8576
8785
|
);
|
8577
|
-
|
8578
|
-
const rootTitle = useAppStore((s) => {
|
8579
|
-
var _a, _b;
|
8580
|
-
const rootData = (_a = s.state.indexes.nodes["root"]) == null ? void 0 : _a.data;
|
8581
|
-
return (_b = rootData.props.title) != null ? _b : "";
|
8582
|
-
});
|
8786
|
+
useInjectGlobalCss(iframe.enabled);
|
8583
8787
|
const leftSideBarVisible = useAppStore((s) => s.state.ui.leftSideBarVisible);
|
8584
8788
|
const rightSideBarVisible = useAppStore(
|
8585
8789
|
(s) => s.state.ui.rightSideBarVisible
|
8586
8790
|
);
|
8587
|
-
const
|
8588
|
-
|
8589
|
-
|
8590
|
-
const sideBarVisible = sidebar === "left" ? leftSideBarVisible : rightSideBarVisible;
|
8591
|
-
const oppositeSideBar = sidebar === "left" ? "rightSideBarVisible" : "leftSideBarVisible";
|
8791
|
+
const dispatch = useAppStore((s) => s.dispatch);
|
8792
|
+
(0, import_react56.useEffect)(() => {
|
8793
|
+
if (!window.matchMedia("(min-width: 638px)").matches) {
|
8592
8794
|
dispatch({
|
8593
8795
|
type: "setUi",
|
8594
|
-
ui:
|
8595
|
-
|
8596
|
-
|
8796
|
+
ui: {
|
8797
|
+
leftSideBarVisible: false,
|
8798
|
+
rightSideBarVisible: false
|
8799
|
+
}
|
8597
8800
|
});
|
8598
|
-
}
|
8599
|
-
|
8801
|
+
}
|
8802
|
+
const handleResize = () => {
|
8803
|
+
if (!window.matchMedia("(min-width: 638px)").matches) {
|
8804
|
+
dispatch({
|
8805
|
+
type: "setUi",
|
8806
|
+
ui: (ui) => __spreadValues(__spreadValues({}, ui), ui.rightSideBarVisible ? { leftSideBarVisible: false } : {})
|
8807
|
+
});
|
8808
|
+
}
|
8809
|
+
};
|
8810
|
+
window.addEventListener("resize", handleResize);
|
8811
|
+
return () => {
|
8812
|
+
window.removeEventListener("resize", handleResize);
|
8813
|
+
};
|
8814
|
+
}, []);
|
8815
|
+
const overrides = useAppStore((s) => s.overrides);
|
8816
|
+
const CustomPuck = (0, import_react56.useMemo)(
|
8817
|
+
() => overrides.puck || DefaultOverride,
|
8818
|
+
[overrides]
|
8600
8819
|
);
|
8601
|
-
|
8602
|
-
|
8603
|
-
|
8604
|
-
|
8605
|
-
|
8606
|
-
|
8820
|
+
const [mounted, setMounted] = (0, import_react56.useState)(false);
|
8821
|
+
(0, import_react56.useEffect)(() => {
|
8822
|
+
setMounted(true);
|
8823
|
+
}, []);
|
8824
|
+
const ready = useAppStore((s) => s.status === "READY");
|
8825
|
+
useMonitorHotkeys();
|
8826
|
+
(0, import_react56.useEffect)(() => {
|
8827
|
+
if (ready && iframe.enabled) {
|
8828
|
+
const frameDoc = getFrame();
|
8829
|
+
if (frameDoc) {
|
8830
|
+
return monitorHotkeys(frameDoc);
|
8831
|
+
}
|
8832
|
+
}
|
8833
|
+
}, [ready, iframe.enabled]);
|
8834
|
+
usePreviewModeHotkeys();
|
8835
|
+
const [view, setView] = (0, import_react56.useState)("blocks");
|
8836
|
+
const pluginItems = (0, import_react56.useMemo)(() => {
|
8837
|
+
const details = {};
|
8838
|
+
plugins == null ? void 0 : plugins.forEach((plugin) => {
|
8839
|
+
var _a, _b;
|
8840
|
+
if (plugin.name && plugin.render) {
|
8841
|
+
details[plugin.name] = {
|
8842
|
+
label: (_a = plugin.label) != null ? _a : plugin.name,
|
8843
|
+
icon: (_b = plugin.icon) != null ? _b : /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(ToyBrick, {}),
|
8607
8844
|
onClick: () => {
|
8608
|
-
|
8609
|
-
onPublish && onPublish(data);
|
8845
|
+
setView(plugin.name);
|
8610
8846
|
},
|
8611
|
-
|
8612
|
-
|
8613
|
-
}
|
8614
|
-
|
8615
|
-
|
8616
|
-
|
8617
|
-
|
8618
|
-
|
8619
|
-
|
8620
|
-
|
8621
|
-
|
8622
|
-
|
8623
|
-
|
8624
|
-
|
8625
|
-
|
8626
|
-
|
8627
|
-
|
8628
|
-
|
8629
|
-
|
8630
|
-
|
8631
|
-
|
8632
|
-
|
8633
|
-
|
8634
|
-
|
8635
|
-
|
8636
|
-
|
8637
|
-
|
8638
|
-
|
8639
|
-
|
8640
|
-
|
8641
|
-
|
8642
|
-
|
8643
|
-
|
8644
|
-
|
8645
|
-
|
8646
|
-
|
8647
|
-
|
8648
|
-
|
8649
|
-
/* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: getClassName27("tools"), children: [
|
8650
|
-
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { className: getClassName27("menuButton"), children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
|
8651
|
-
IconButton,
|
8652
|
-
{
|
8653
|
-
onClick: () => {
|
8654
|
-
return setMenuOpen(!menuOpen);
|
8655
|
-
},
|
8656
|
-
title: "Toggle menu bar",
|
8657
|
-
children: menuOpen ? /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(ChevronUp, { focusable: "false" }) : /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(ChevronDown, { focusable: "false" })
|
8658
|
-
}
|
8659
|
-
) }),
|
8660
|
-
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
|
8661
|
-
MenuBar,
|
8662
|
-
{
|
8663
|
-
dispatch,
|
8664
|
-
onPublish,
|
8665
|
-
menuOpen,
|
8666
|
-
renderHeaderActions: () => /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(CustomHeaderActions, { children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
|
8667
|
-
Button,
|
8668
|
-
{
|
8847
|
+
isActive: view === plugin.name,
|
8848
|
+
render: plugin.render
|
8849
|
+
};
|
8850
|
+
}
|
8851
|
+
});
|
8852
|
+
return details;
|
8853
|
+
}, [plugins, view]);
|
8854
|
+
const PluginRender = (0, import_react56.useMemo)(() => {
|
8855
|
+
var _a;
|
8856
|
+
if (view === "blocks") {
|
8857
|
+
return Components;
|
8858
|
+
} else if (view === "outline") {
|
8859
|
+
return Outline;
|
8860
|
+
} else {
|
8861
|
+
return (_a = pluginItems[view]) == null ? void 0 : _a.render;
|
8862
|
+
}
|
8863
|
+
}, [view]);
|
8864
|
+
return /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("div", { className: `Puck ${getClassName29()}`, children: [
|
8865
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)(DragDropContext, { disableAutoScroll: dnd == null ? void 0 : dnd.disableAutoScroll, children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(CustomPuck, { children: children || /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
|
8866
|
+
"div",
|
8867
|
+
{
|
8868
|
+
className: getLayoutClassName({
|
8869
|
+
leftSideBarVisible,
|
8870
|
+
mounted,
|
8871
|
+
rightSideBarVisible
|
8872
|
+
}),
|
8873
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("div", { className: getLayoutClassName("inner"), children: [
|
8874
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Header, {}),
|
8875
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)("div", { className: getLayoutClassName("nav"), children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
|
8876
|
+
Nav,
|
8877
|
+
{
|
8878
|
+
slim: true,
|
8879
|
+
navigation: {
|
8880
|
+
main: {
|
8881
|
+
items: __spreadValues({
|
8882
|
+
build: {
|
8883
|
+
label: "Blocks",
|
8884
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Hammer, {}),
|
8669
8885
|
onClick: () => {
|
8670
|
-
|
8671
|
-
onPublish && onPublish(data);
|
8886
|
+
setView("blocks");
|
8672
8887
|
},
|
8673
|
-
|
8674
|
-
|
8888
|
+
isActive: view === "blocks"
|
8889
|
+
},
|
8890
|
+
outline: {
|
8891
|
+
label: "Outline",
|
8892
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Layers, {}),
|
8893
|
+
onClick: () => {
|
8894
|
+
setView("outline");
|
8895
|
+
},
|
8896
|
+
isActive: view === "outline"
|
8675
8897
|
}
|
8676
|
-
|
8677
|
-
setMenuOpen
|
8898
|
+
}, pluginItems)
|
8678
8899
|
}
|
8679
|
-
|
8680
|
-
|
8681
|
-
|
8682
|
-
|
8683
|
-
|
8684
|
-
|
8685
|
-
|
8900
|
+
}
|
8901
|
+
}
|
8902
|
+
) }),
|
8903
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)("div", { className: getLayoutClassName("leftSideBar"), children: leftSideBarVisible && /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(PluginRender, {}) }),
|
8904
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Canvas, {}),
|
8905
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)("div", { className: getLayoutClassName("rightSideBar"), children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(FieldSideBar, {}) })
|
8906
|
+
] })
|
8907
|
+
}
|
8908
|
+
) }) }),
|
8909
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)("div", { id: "puck-portal-root", className: getClassName29("portal") })
|
8910
|
+
] });
|
8686
8911
|
};
|
8687
|
-
var Header = (0, import_react55.memo)(HeaderInner);
|
8688
8912
|
|
8689
8913
|
// components/Puck/index.tsx
|
8690
|
-
var
|
8691
|
-
var
|
8692
|
-
var getLayoutClassName = get_class_name_factory_default("PuckLayout", styles_module_default14);
|
8693
|
-
var FieldSideBar = () => {
|
8694
|
-
const title = useAppStore(
|
8695
|
-
(s) => {
|
8696
|
-
var _a, _b;
|
8697
|
-
return s.selectedItem ? (_b = (_a = s.config.components[s.selectedItem.type]) == null ? void 0 : _a["label"]) != null ? _b : s.selectedItem.type.toString() : "Page";
|
8698
|
-
}
|
8699
|
-
);
|
8700
|
-
return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(SidebarSection, { noPadding: true, noBorderTop: true, showBreadcrumbs: true, title, children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(Fields, {}) });
|
8701
|
-
};
|
8702
|
-
var propsContext = (0, import_react56.createContext)({});
|
8914
|
+
var import_jsx_runtime44 = require("react/jsx-runtime");
|
8915
|
+
var propsContext = (0, import_react57.createContext)({});
|
8703
8916
|
function PropsProvider(props) {
|
8704
|
-
return /* @__PURE__ */ (0,
|
8917
|
+
return /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(propsContext.Provider, { value: props, children: props.children });
|
8705
8918
|
}
|
8706
|
-
var usePropsContext = () => (0,
|
8919
|
+
var usePropsContext = () => (0, import_react57.useContext)(propsContext);
|
8707
8920
|
function PuckProvider({ children }) {
|
8708
8921
|
const {
|
8709
8922
|
config,
|
@@ -8719,14 +8932,14 @@ function PuckProvider({ children }) {
|
|
8719
8932
|
metadata,
|
8720
8933
|
onAction
|
8721
8934
|
} = usePropsContext();
|
8722
|
-
const iframe = (0,
|
8935
|
+
const iframe = (0, import_react57.useMemo)(
|
8723
8936
|
() => __spreadValues({
|
8724
8937
|
enabled: true,
|
8725
8938
|
waitForStyles: true
|
8726
8939
|
}, _iframe),
|
8727
8940
|
[_iframe]
|
8728
8941
|
);
|
8729
|
-
const [generatedAppState] = (0,
|
8942
|
+
const [generatedAppState] = (0, import_react57.useState)(() => {
|
8730
8943
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
8731
8944
|
const initial = __spreadValues(__spreadValues({}, defaultAppState.ui), initialUi);
|
8732
8945
|
let clientUiState = {};
|
@@ -8786,7 +8999,7 @@ function PuckProvider({ children }) {
|
|
8786
8999
|
return walkAppState(newAppState, config);
|
8787
9000
|
});
|
8788
9001
|
const { appendData = true } = _initialHistory || {};
|
8789
|
-
const [blendedHistories] = (0,
|
9002
|
+
const [blendedHistories] = (0, import_react57.useState)(
|
8790
9003
|
[
|
8791
9004
|
...(_initialHistory == null ? void 0 : _initialHistory.histories) || [],
|
8792
9005
|
...appendData ? [{ state: generatedAppState }] : []
|
@@ -8806,7 +9019,7 @@ function PuckProvider({ children }) {
|
|
8806
9019
|
overrides,
|
8807
9020
|
plugins
|
8808
9021
|
});
|
8809
|
-
const generateAppStore = (0,
|
9022
|
+
const generateAppStore = (0, import_react57.useCallback)(
|
8810
9023
|
(state) => {
|
8811
9024
|
return {
|
8812
9025
|
state,
|
@@ -8830,15 +9043,15 @@ function PuckProvider({ children }) {
|
|
8830
9043
|
metadata
|
8831
9044
|
]
|
8832
9045
|
);
|
8833
|
-
const [appStore] = (0,
|
9046
|
+
const [appStore] = (0, import_react57.useState)(
|
8834
9047
|
() => createAppStore(generateAppStore(initialAppState))
|
8835
9048
|
);
|
8836
|
-
(0,
|
9049
|
+
(0, import_react57.useEffect)(() => {
|
8837
9050
|
if (process.env.NODE_ENV !== "production") {
|
8838
9051
|
window.__PUCK_INTERNAL_DO_NOT_USE = { appStore };
|
8839
9052
|
}
|
8840
9053
|
}, [appStore]);
|
8841
|
-
(0,
|
9054
|
+
(0, import_react57.useEffect)(() => {
|
8842
9055
|
const state = appStore.getState().state;
|
8843
9056
|
appStore.setState(__spreadValues({}, generateAppStore(state)));
|
8844
9057
|
}, [config, plugins, loadedOverrides, viewports, iframe, onAction, metadata]);
|
@@ -8847,8 +9060,8 @@ function PuckProvider({ children }) {
|
|
8847
9060
|
index: initialHistoryIndex,
|
8848
9061
|
initialAppState
|
8849
9062
|
});
|
8850
|
-
const previousData = (0,
|
8851
|
-
(0,
|
9063
|
+
const previousData = (0, import_react57.useRef)(null);
|
9064
|
+
(0, import_react57.useEffect)(() => {
|
8852
9065
|
appStore.subscribe(
|
8853
9066
|
(s) => s.state.data,
|
8854
9067
|
(data) => {
|
@@ -8862,99 +9075,14 @@ function PuckProvider({ children }) {
|
|
8862
9075
|
}, []);
|
8863
9076
|
useRegisterPermissionsSlice(appStore, permissions);
|
8864
9077
|
const uPuckStore = useRegisterUsePuckStore(appStore);
|
8865
|
-
(0,
|
9078
|
+
(0, import_react57.useEffect)(() => {
|
8866
9079
|
const { resolveAndCommitData } = appStore.getState();
|
8867
9080
|
resolveAndCommitData();
|
8868
9081
|
}, []);
|
8869
|
-
return /* @__PURE__ */ (0,
|
8870
|
-
}
|
8871
|
-
function PuckLayout({ children }) {
|
8872
|
-
const {
|
8873
|
-
iframe: _iframe,
|
8874
|
-
dnd,
|
8875
|
-
initialHistory: _initialHistory
|
8876
|
-
} = usePropsContext();
|
8877
|
-
const iframe = (0, import_react56.useMemo)(
|
8878
|
-
() => __spreadValues({
|
8879
|
-
enabled: true,
|
8880
|
-
waitForStyles: true
|
8881
|
-
}, _iframe),
|
8882
|
-
[_iframe]
|
8883
|
-
);
|
8884
|
-
useInjectGlobalCss(iframe.enabled);
|
8885
|
-
const leftSideBarVisible = useAppStore((s) => s.state.ui.leftSideBarVisible);
|
8886
|
-
const rightSideBarVisible = useAppStore(
|
8887
|
-
(s) => s.state.ui.rightSideBarVisible
|
8888
|
-
);
|
8889
|
-
const dispatch = useAppStore((s) => s.dispatch);
|
8890
|
-
(0, import_react56.useEffect)(() => {
|
8891
|
-
if (!window.matchMedia("(min-width: 638px)").matches) {
|
8892
|
-
dispatch({
|
8893
|
-
type: "setUi",
|
8894
|
-
ui: {
|
8895
|
-
leftSideBarVisible: false,
|
8896
|
-
rightSideBarVisible: false
|
8897
|
-
}
|
8898
|
-
});
|
8899
|
-
}
|
8900
|
-
const handleResize = () => {
|
8901
|
-
if (!window.matchMedia("(min-width: 638px)").matches) {
|
8902
|
-
dispatch({
|
8903
|
-
type: "setUi",
|
8904
|
-
ui: (ui) => __spreadValues(__spreadValues({}, ui), ui.rightSideBarVisible ? { leftSideBarVisible: false } : {})
|
8905
|
-
});
|
8906
|
-
}
|
8907
|
-
};
|
8908
|
-
window.addEventListener("resize", handleResize);
|
8909
|
-
return () => {
|
8910
|
-
window.removeEventListener("resize", handleResize);
|
8911
|
-
};
|
8912
|
-
}, []);
|
8913
|
-
const overrides = useAppStore((s) => s.overrides);
|
8914
|
-
const CustomPuck = (0, import_react56.useMemo)(
|
8915
|
-
() => overrides.puck || DefaultOverride,
|
8916
|
-
[overrides]
|
8917
|
-
);
|
8918
|
-
const [mounted, setMounted] = (0, import_react56.useState)(false);
|
8919
|
-
(0, import_react56.useEffect)(() => {
|
8920
|
-
setMounted(true);
|
8921
|
-
}, []);
|
8922
|
-
const ready = useAppStore((s) => s.status === "READY");
|
8923
|
-
useMonitorHotkeys();
|
8924
|
-
(0, import_react56.useEffect)(() => {
|
8925
|
-
if (ready && iframe.enabled) {
|
8926
|
-
const frameDoc = getFrame();
|
8927
|
-
if (frameDoc) {
|
8928
|
-
return monitorHotkeys(frameDoc);
|
8929
|
-
}
|
8930
|
-
}
|
8931
|
-
}, [ready, iframe.enabled]);
|
8932
|
-
usePreviewModeHotkeys();
|
8933
|
-
return /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("div", { className: `Puck ${getClassName28()}`, children: [
|
8934
|
-
/* @__PURE__ */ (0, import_jsx_runtime42.jsx)(DragDropContext, { disableAutoScroll: dnd == null ? void 0 : dnd.disableAutoScroll, children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(CustomPuck, { children: children || /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
|
8935
|
-
"div",
|
8936
|
-
{
|
8937
|
-
className: getLayoutClassName({
|
8938
|
-
leftSideBarVisible,
|
8939
|
-
mounted,
|
8940
|
-
rightSideBarVisible
|
8941
|
-
}),
|
8942
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("div", { className: getLayoutClassName("inner"), children: [
|
8943
|
-
/* @__PURE__ */ (0, import_jsx_runtime42.jsx)(Header, {}),
|
8944
|
-
/* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("div", { className: getLayoutClassName("leftSideBar"), children: [
|
8945
|
-
/* @__PURE__ */ (0, import_jsx_runtime42.jsx)(SidebarSection, { title: "Components", noBorderTop: true, children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(Components, {}) }),
|
8946
|
-
/* @__PURE__ */ (0, import_jsx_runtime42.jsx)(SidebarSection, { title: "Outline", children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(Outline, {}) })
|
8947
|
-
] }),
|
8948
|
-
/* @__PURE__ */ (0, import_jsx_runtime42.jsx)(Canvas, {}),
|
8949
|
-
/* @__PURE__ */ (0, import_jsx_runtime42.jsx)("div", { className: getLayoutClassName("rightSideBar"), children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(FieldSideBar, {}) })
|
8950
|
-
] })
|
8951
|
-
}
|
8952
|
-
) }) }),
|
8953
|
-
/* @__PURE__ */ (0, import_jsx_runtime42.jsx)("div", { id: "puck-portal-root", className: getClassName28("portal") })
|
8954
|
-
] });
|
9082
|
+
return /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(appStoreContext.Provider, { value: appStore, children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(UsePuckStoreContext.Provider, { value: uPuckStore, children }) });
|
8955
9083
|
}
|
8956
9084
|
function Puck(props) {
|
8957
|
-
return /* @__PURE__ */ (0,
|
9085
|
+
return /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(PropsProvider, __spreadProps(__spreadValues({}, props), { children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(PuckProvider, __spreadProps(__spreadValues({}, props), { children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(Layout, { children: props.children }) })) }));
|
8958
9086
|
}
|
8959
9087
|
Puck.Components = Components;
|
8960
9088
|
Puck.Fields = Fields;
|
@@ -9089,6 +9217,14 @@ lucide-react/dist/esm/icons/globe.js:
|
|
9089
9217
|
* See the LICENSE file in the root directory of this source tree.
|
9090
9218
|
*)
|
9091
9219
|
|
9220
|
+
lucide-react/dist/esm/icons/hammer.js:
|
9221
|
+
(**
|
9222
|
+
* @license lucide-react v0.468.0 - ISC
|
9223
|
+
*
|
9224
|
+
* This source code is licensed under the ISC license.
|
9225
|
+
* See the LICENSE file in the root directory of this source tree.
|
9226
|
+
*)
|
9227
|
+
|
9092
9228
|
lucide-react/dist/esm/icons/hash.js:
|
9093
9229
|
(**
|
9094
9230
|
* @license lucide-react v0.468.0 - ISC
|
@@ -9217,6 +9353,14 @@ lucide-react/dist/esm/icons/tablet.js:
|
|
9217
9353
|
* See the LICENSE file in the root directory of this source tree.
|
9218
9354
|
*)
|
9219
9355
|
|
9356
|
+
lucide-react/dist/esm/icons/toy-brick.js:
|
9357
|
+
(**
|
9358
|
+
* @license lucide-react v0.468.0 - ISC
|
9359
|
+
*
|
9360
|
+
* This source code is licensed under the ISC license.
|
9361
|
+
* See the LICENSE file in the root directory of this source tree.
|
9362
|
+
*)
|
9363
|
+
|
9220
9364
|
lucide-react/dist/esm/icons/trash.js:
|
9221
9365
|
(**
|
9222
9366
|
* @license lucide-react v0.468.0 - ISC
|