@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.mjs
CHANGED
@@ -375,6 +375,20 @@ var Globe = createLucideIcon("Globe", [
|
|
375
375
|
["path", { d: "M2 12h20", key: "9i4pu4" }]
|
376
376
|
]);
|
377
377
|
|
378
|
+
// ../../node_modules/lucide-react/dist/esm/icons/hammer.js
|
379
|
+
init_react_import();
|
380
|
+
var Hammer = createLucideIcon("Hammer", [
|
381
|
+
["path", { d: "m15 12-8.373 8.373a1 1 0 1 1-3-3L12 9", key: "eefl8a" }],
|
382
|
+
["path", { d: "m18 15 4-4", key: "16gjal" }],
|
383
|
+
[
|
384
|
+
"path",
|
385
|
+
{
|
386
|
+
d: "m21.5 11.5-1.914-1.914A2 2 0 0 1 19 8.172V7l-2.26-2.26a6 6 0 0 0-4.202-1.756L9 2.96l.92.82A6.18 6.18 0 0 1 12 8.4V10l2 2h1.172a2 2 0 0 1 1.414.586L18.5 14.5",
|
387
|
+
key: "b7pghm"
|
388
|
+
}
|
389
|
+
]
|
390
|
+
]);
|
391
|
+
|
378
392
|
// ../../node_modules/lucide-react/dist/esm/icons/hash.js
|
379
393
|
init_react_import();
|
380
394
|
var Hash = createLucideIcon("Hash", [
|
@@ -522,6 +536,14 @@ var Tablet = createLucideIcon("Tablet", [
|
|
522
536
|
["line", { x1: "12", x2: "12.01", y1: "18", y2: "18", key: "1dp563" }]
|
523
537
|
]);
|
524
538
|
|
539
|
+
// ../../node_modules/lucide-react/dist/esm/icons/toy-brick.js
|
540
|
+
init_react_import();
|
541
|
+
var ToyBrick = createLucideIcon("ToyBrick", [
|
542
|
+
["rect", { width: "18", height: "12", x: "3", y: "8", rx: "1", key: "158fvp" }],
|
543
|
+
["path", { d: "M10 8V5c0-.6-.4-1-1-1H6a1 1 0 0 0-1 1v3", key: "s0042v" }],
|
544
|
+
["path", { d: "M19 8V5c0-.6-.4-1-1-1h-3a1 1 0 0 0-1 1v3", key: "9wmeh2" }]
|
545
|
+
]);
|
546
|
+
|
525
547
|
// ../../node_modules/lucide-react/dist/esm/icons/trash.js
|
526
548
|
init_react_import();
|
527
549
|
var Trash = createLucideIcon("Trash", [
|
@@ -5924,125 +5946,28 @@ import {
|
|
5924
5946
|
createContext as createContext7,
|
5925
5947
|
useCallback as useCallback18,
|
5926
5948
|
useContext as useContext12,
|
5927
|
-
useEffect as
|
5928
|
-
useMemo as
|
5949
|
+
useEffect as useEffect26,
|
5950
|
+
useMemo as useMemo22,
|
5929
5951
|
useRef as useRef8,
|
5930
|
-
useState as
|
5952
|
+
useState as useState24
|
5931
5953
|
} from "react";
|
5932
5954
|
|
5933
|
-
// components/SidebarSection/index.tsx
|
5934
|
-
init_react_import();
|
5935
|
-
|
5936
|
-
// css-module:/home/runner/work/puck/puck/packages/core/components/SidebarSection/styles.module.css#css-module
|
5937
|
-
init_react_import();
|
5938
|
-
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" };
|
5939
|
-
|
5940
|
-
// lib/use-breadcrumbs.ts
|
5941
|
-
init_react_import();
|
5942
|
-
import { useMemo as useMemo12 } from "react";
|
5943
|
-
var useBreadcrumbs = (renderCount) => {
|
5944
|
-
const selectedId = useAppStore((s) => {
|
5945
|
-
var _a;
|
5946
|
-
return (_a = s.selectedItem) == null ? void 0 : _a.props.id;
|
5947
|
-
});
|
5948
|
-
const config = useAppStore((s) => s.config);
|
5949
|
-
const path = useAppStore((s) => {
|
5950
|
-
var _a;
|
5951
|
-
return (_a = s.state.indexes.nodes[selectedId]) == null ? void 0 : _a.path;
|
5952
|
-
});
|
5953
|
-
const appStore = useAppStoreApi();
|
5954
|
-
return useMemo12(() => {
|
5955
|
-
const breadcrumbs = (path == null ? void 0 : path.map((zoneCompound) => {
|
5956
|
-
var _a, _b, _c;
|
5957
|
-
const [componentId] = zoneCompound.split(":");
|
5958
|
-
if (componentId === "root") {
|
5959
|
-
return {
|
5960
|
-
label: "Page",
|
5961
|
-
selector: null
|
5962
|
-
};
|
5963
|
-
}
|
5964
|
-
const node = appStore.getState().state.indexes.nodes[componentId];
|
5965
|
-
const parentId = node.path[node.path.length - 1];
|
5966
|
-
const contentIds = ((_a = appStore.getState().state.indexes.zones[parentId]) == null ? void 0 : _a.contentIds) || [];
|
5967
|
-
const index = contentIds.indexOf(componentId);
|
5968
|
-
const label = node ? (_c = (_b = config.components[node.data.type]) == null ? void 0 : _b.label) != null ? _c : node.data.type : "Component";
|
5969
|
-
return {
|
5970
|
-
label,
|
5971
|
-
selector: node ? {
|
5972
|
-
index,
|
5973
|
-
zone: node.path[node.path.length - 1]
|
5974
|
-
} : null
|
5975
|
-
};
|
5976
|
-
})) || [];
|
5977
|
-
if (renderCount) {
|
5978
|
-
return breadcrumbs.slice(breadcrumbs.length - renderCount);
|
5979
|
-
}
|
5980
|
-
return breadcrumbs;
|
5981
|
-
}, [path, renderCount]);
|
5982
|
-
};
|
5983
|
-
|
5984
|
-
// components/SidebarSection/index.tsx
|
5985
|
-
import { jsx as jsx26, jsxs as jsxs12 } from "react/jsx-runtime";
|
5986
|
-
var getClassName19 = get_class_name_factory_default("SidebarSection", styles_module_default13);
|
5987
|
-
var SidebarSection = ({
|
5988
|
-
children,
|
5989
|
-
title,
|
5990
|
-
background,
|
5991
|
-
showBreadcrumbs,
|
5992
|
-
noBorderTop,
|
5993
|
-
noPadding,
|
5994
|
-
isLoading
|
5995
|
-
}) => {
|
5996
|
-
const setUi = useAppStore((s) => s.setUi);
|
5997
|
-
const breadcrumbs = useBreadcrumbs(1);
|
5998
|
-
return /* @__PURE__ */ jsxs12(
|
5999
|
-
"div",
|
6000
|
-
{
|
6001
|
-
className: getClassName19({ noBorderTop, noPadding }),
|
6002
|
-
style: { background },
|
6003
|
-
children: [
|
6004
|
-
/* @__PURE__ */ jsx26("div", { className: getClassName19("title"), children: /* @__PURE__ */ jsxs12("div", { className: getClassName19("breadcrumbs"), children: [
|
6005
|
-
showBreadcrumbs ? breadcrumbs.map((breadcrumb, i) => /* @__PURE__ */ jsxs12("div", { className: getClassName19("breadcrumb"), children: [
|
6006
|
-
/* @__PURE__ */ jsx26(
|
6007
|
-
"button",
|
6008
|
-
{
|
6009
|
-
type: "button",
|
6010
|
-
className: getClassName19("breadcrumbLabel"),
|
6011
|
-
onClick: () => setUi({ itemSelector: breadcrumb.selector }),
|
6012
|
-
children: breadcrumb.label
|
6013
|
-
}
|
6014
|
-
),
|
6015
|
-
/* @__PURE__ */ jsx26(ChevronRight, { size: 16 })
|
6016
|
-
] }, i)) : null,
|
6017
|
-
/* @__PURE__ */ jsx26("div", { className: getClassName19("heading"), children: /* @__PURE__ */ jsx26(Heading, { rank: "2", size: "xs", children: title }) })
|
6018
|
-
] }) }),
|
6019
|
-
/* @__PURE__ */ jsx26("div", { className: getClassName19("content"), children }),
|
6020
|
-
isLoading && /* @__PURE__ */ jsx26("div", { className: getClassName19("loadingOverlay"), children: /* @__PURE__ */ jsx26(Loader, { size: 32 }) })
|
6021
|
-
]
|
6022
|
-
}
|
6023
|
-
);
|
6024
|
-
};
|
6025
|
-
|
6026
|
-
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/styles.module.css#css-module
|
6027
|
-
init_react_import();
|
6028
|
-
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" };
|
6029
|
-
|
6030
5955
|
// components/Puck/components/Fields/index.tsx
|
6031
5956
|
init_react_import();
|
6032
5957
|
|
6033
5958
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Fields/styles.module.css#css-module
|
6034
5959
|
init_react_import();
|
6035
|
-
var
|
5960
|
+
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" };
|
6036
5961
|
|
6037
5962
|
// components/Puck/components/Fields/index.tsx
|
6038
|
-
import { memo as memo2, useCallback as useCallback12, useMemo as
|
5963
|
+
import { memo as memo2, useCallback as useCallback12, useMemo as useMemo12 } from "react";
|
6039
5964
|
import { useShallow as useShallow5 } from "zustand/react/shallow";
|
6040
|
-
import { Fragment as Fragment7, jsx as
|
6041
|
-
var
|
5965
|
+
import { Fragment as Fragment7, jsx as jsx26, jsxs as jsxs12 } from "react/jsx-runtime";
|
5966
|
+
var getClassName19 = get_class_name_factory_default("PuckFields", styles_module_default13);
|
6042
5967
|
var DefaultFields = ({
|
6043
5968
|
children
|
6044
5969
|
}) => {
|
6045
|
-
return /* @__PURE__ */
|
5970
|
+
return /* @__PURE__ */ jsx26(Fragment7, { children });
|
6046
5971
|
};
|
6047
5972
|
var createOnChange = (fieldName, appStore) => (value, updatedUi) => __async(void 0, null, function* () {
|
6048
5973
|
let currentProps;
|
@@ -6114,7 +6039,7 @@ var FieldsChild = ({ fieldName }) => {
|
|
6114
6039
|
const { visible = true } = field != null ? field : {};
|
6115
6040
|
if (!field || !id || !visible) return null;
|
6116
6041
|
if (field.type === "slot") return null;
|
6117
|
-
return /* @__PURE__ */
|
6042
|
+
return /* @__PURE__ */ jsx26("div", { className: getClassName19("field"), children: /* @__PURE__ */ jsx26(
|
6118
6043
|
AutoFieldPrivate,
|
6119
6044
|
{
|
6120
6045
|
field,
|
@@ -6151,17 +6076,17 @@ var FieldsInternal = ({ wrapFields = true }) => {
|
|
6151
6076
|
})
|
6152
6077
|
);
|
6153
6078
|
const isLoading = fieldsLoading || componentResolving;
|
6154
|
-
const Wrapper =
|
6155
|
-
return /* @__PURE__ */
|
6079
|
+
const Wrapper = useMemo12(() => overrides.fields || DefaultFields, [overrides]);
|
6080
|
+
return /* @__PURE__ */ jsxs12(
|
6156
6081
|
"form",
|
6157
6082
|
{
|
6158
|
-
className:
|
6083
|
+
className: getClassName19({ wrapFields }),
|
6159
6084
|
onSubmit: (e) => {
|
6160
6085
|
e.preventDefault();
|
6161
6086
|
},
|
6162
6087
|
children: [
|
6163
|
-
/* @__PURE__ */
|
6164
|
-
isLoading && /* @__PURE__ */
|
6088
|
+
/* @__PURE__ */ jsx26(Wrapper, { isLoading, itemSelector, children: fieldNames.map((fieldName) => /* @__PURE__ */ jsx26(FieldsChildMemo, { fieldName }, fieldName)) }),
|
6089
|
+
isLoading && /* @__PURE__ */ jsx26("div", { className: getClassName19("loadingOverlay"), children: /* @__PURE__ */ jsx26("div", { className: getClassName19("loadingOverlayInner"), children: /* @__PURE__ */ jsx26(Loader, { size: 16 }) }) })
|
6165
6090
|
]
|
6166
6091
|
}
|
6167
6092
|
);
|
@@ -6180,11 +6105,11 @@ init_react_import();
|
|
6180
6105
|
|
6181
6106
|
// css-module:/home/runner/work/puck/puck/packages/core/components/ComponentList/styles.module.css#css-module
|
6182
6107
|
init_react_import();
|
6183
|
-
var
|
6108
|
+
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" };
|
6184
6109
|
|
6185
6110
|
// components/ComponentList/index.tsx
|
6186
|
-
import { jsx as
|
6187
|
-
var
|
6111
|
+
import { jsx as jsx27, jsxs as jsxs13 } from "react/jsx-runtime";
|
6112
|
+
var getClassName20 = get_class_name_factory_default("ComponentList", styles_module_default14);
|
6188
6113
|
var ComponentListItem = ({
|
6189
6114
|
name,
|
6190
6115
|
label
|
@@ -6195,7 +6120,7 @@ var ComponentListItem = ({
|
|
6195
6120
|
type: name
|
6196
6121
|
}).insert
|
6197
6122
|
);
|
6198
|
-
return /* @__PURE__ */
|
6123
|
+
return /* @__PURE__ */ jsx27(Drawer.Item, { label, name, isDragDisabled: !canInsert, children: overrides.componentItem });
|
6199
6124
|
};
|
6200
6125
|
var ComponentList = ({
|
6201
6126
|
children,
|
@@ -6206,12 +6131,12 @@ var ComponentList = ({
|
|
6206
6131
|
const setUi = useAppStore((s) => s.setUi);
|
6207
6132
|
const componentList = useAppStore((s) => s.state.ui.componentList);
|
6208
6133
|
const { expanded = true } = componentList[id] || {};
|
6209
|
-
return /* @__PURE__ */
|
6210
|
-
title && /* @__PURE__ */
|
6134
|
+
return /* @__PURE__ */ jsxs13("div", { className: getClassName20({ isExpanded: expanded }), children: [
|
6135
|
+
title && /* @__PURE__ */ jsxs13(
|
6211
6136
|
"button",
|
6212
6137
|
{
|
6213
6138
|
type: "button",
|
6214
|
-
className:
|
6139
|
+
className: getClassName20("title"),
|
6215
6140
|
onClick: () => setUi({
|
6216
6141
|
componentList: __spreadProps(__spreadValues({}, componentList), {
|
6217
6142
|
[id]: __spreadProps(__spreadValues({}, componentList[id]), {
|
@@ -6221,14 +6146,14 @@ var ComponentList = ({
|
|
6221
6146
|
}),
|
6222
6147
|
title: expanded ? `Collapse${title ? ` ${title}` : ""}` : `Expand${title ? ` ${title}` : ""}`,
|
6223
6148
|
children: [
|
6224
|
-
/* @__PURE__ */
|
6225
|
-
/* @__PURE__ */
|
6149
|
+
/* @__PURE__ */ jsx27("div", { children: title }),
|
6150
|
+
/* @__PURE__ */ jsx27("div", { className: getClassName20("titleIcon"), children: expanded ? /* @__PURE__ */ jsx27(ChevronUp, { size: 12 }) : /* @__PURE__ */ jsx27(ChevronDown, { size: 12 }) })
|
6226
6151
|
]
|
6227
6152
|
}
|
6228
6153
|
),
|
6229
|
-
/* @__PURE__ */
|
6154
|
+
/* @__PURE__ */ jsx27("div", { className: getClassName20("content"), children: /* @__PURE__ */ jsx27(Drawer, { children: children || Object.keys(config.components).map((componentKey) => {
|
6230
6155
|
var _a;
|
6231
|
-
return /* @__PURE__ */
|
6156
|
+
return /* @__PURE__ */ jsx27(
|
6232
6157
|
ComponentListItem,
|
6233
6158
|
{
|
6234
6159
|
label: (_a = config.components[componentKey]["label"]) != null ? _a : componentKey,
|
@@ -6242,7 +6167,7 @@ var ComponentList = ({
|
|
6242
6167
|
ComponentList.Item = ComponentListItem;
|
6243
6168
|
|
6244
6169
|
// lib/use-component-list.tsx
|
6245
|
-
import { jsx as
|
6170
|
+
import { jsx as jsx28 } from "react/jsx-runtime";
|
6246
6171
|
var useComponentList = () => {
|
6247
6172
|
const [componentList, setComponentList] = useState16();
|
6248
6173
|
const config = useAppStore((s) => s.config);
|
@@ -6257,7 +6182,7 @@ var useComponentList = () => {
|
|
6257
6182
|
if (category.visible === false || !category.components) {
|
6258
6183
|
return null;
|
6259
6184
|
}
|
6260
|
-
return /* @__PURE__ */
|
6185
|
+
return /* @__PURE__ */ jsx28(
|
6261
6186
|
ComponentList,
|
6262
6187
|
{
|
6263
6188
|
id: categoryKey,
|
@@ -6266,7 +6191,7 @@ var useComponentList = () => {
|
|
6266
6191
|
var _a2;
|
6267
6192
|
matchedComponents.push(componentName);
|
6268
6193
|
const componentConf = config.components[componentName] || {};
|
6269
|
-
return /* @__PURE__ */
|
6194
|
+
return /* @__PURE__ */ jsx28(
|
6270
6195
|
ComponentList.Item,
|
6271
6196
|
{
|
6272
6197
|
label: (_a2 = componentConf["label"]) != null ? _a2 : componentName,
|
@@ -6286,7 +6211,7 @@ var useComponentList = () => {
|
|
6286
6211
|
);
|
6287
6212
|
if (remainingComponents.length > 0 && !((_a = uiComponentList.other) == null ? void 0 : _a.components) && ((_b = uiComponentList.other) == null ? void 0 : _b.visible) !== false) {
|
6288
6213
|
_componentList.push(
|
6289
|
-
/* @__PURE__ */
|
6214
|
+
/* @__PURE__ */ jsx28(
|
6290
6215
|
ComponentList,
|
6291
6216
|
{
|
6292
6217
|
id: "other",
|
@@ -6294,7 +6219,7 @@ var useComponentList = () => {
|
|
6294
6219
|
children: remainingComponents.map((componentName, i) => {
|
6295
6220
|
var _a2;
|
6296
6221
|
const componentConf = config.components[componentName] || {};
|
6297
|
-
return /* @__PURE__ */
|
6222
|
+
return /* @__PURE__ */ jsx28(
|
6298
6223
|
ComponentList.Item,
|
6299
6224
|
{
|
6300
6225
|
name: componentName,
|
@@ -6316,18 +6241,18 @@ var useComponentList = () => {
|
|
6316
6241
|
};
|
6317
6242
|
|
6318
6243
|
// components/Puck/components/Components/index.tsx
|
6319
|
-
import { useMemo as
|
6320
|
-
import { jsx as
|
6244
|
+
import { useMemo as useMemo13 } from "react";
|
6245
|
+
import { jsx as jsx29 } from "react/jsx-runtime";
|
6321
6246
|
var Components = () => {
|
6322
6247
|
const overrides = useAppStore((s) => s.overrides);
|
6323
6248
|
const componentList = useComponentList();
|
6324
|
-
const Wrapper =
|
6325
|
-
return /* @__PURE__ */
|
6249
|
+
const Wrapper = useMemo13(() => overrides.components || "div", [overrides]);
|
6250
|
+
return /* @__PURE__ */ jsx29(Wrapper, { children: componentList ? componentList : /* @__PURE__ */ jsx29(ComponentList, { id: "all" }) });
|
6326
6251
|
};
|
6327
6252
|
|
6328
6253
|
// components/Puck/components/Preview/index.tsx
|
6329
6254
|
init_react_import();
|
6330
|
-
import { useCallback as useCallback13, useEffect as useEffect20, useRef as useRef6, useMemo as
|
6255
|
+
import { useCallback as useCallback13, useEffect as useEffect20, useRef as useRef6, useMemo as useMemo14 } from "react";
|
6331
6256
|
|
6332
6257
|
// components/AutoFrame/index.tsx
|
6333
6258
|
init_react_import();
|
@@ -6339,7 +6264,7 @@ import {
|
|
6339
6264
|
} from "react";
|
6340
6265
|
import hash from "object-hash";
|
6341
6266
|
import { createPortal as createPortal3 } from "react-dom";
|
6342
|
-
import { Fragment as Fragment8, jsx as
|
6267
|
+
import { Fragment as Fragment8, jsx as jsx30 } from "react/jsx-runtime";
|
6343
6268
|
var styleSelector = 'style, link[rel="stylesheet"]';
|
6344
6269
|
var collectStyles = (doc) => {
|
6345
6270
|
const collected = [];
|
@@ -6539,7 +6464,7 @@ var CopyHostStyles = ({
|
|
6539
6464
|
observer.disconnect();
|
6540
6465
|
};
|
6541
6466
|
}, []);
|
6542
|
-
return /* @__PURE__ */
|
6467
|
+
return /* @__PURE__ */ jsx30(Fragment8, { children });
|
6543
6468
|
};
|
6544
6469
|
var autoFrameContext = createContext5({});
|
6545
6470
|
var useFrame = () => useContext9(autoFrameContext);
|
@@ -6586,7 +6511,7 @@ function AutoFrame(_a) {
|
|
6586
6511
|
}
|
6587
6512
|
}
|
6588
6513
|
}, [frameRef, loaded, stylesLoaded]);
|
6589
|
-
return /* @__PURE__ */
|
6514
|
+
return /* @__PURE__ */ jsx30(
|
6590
6515
|
"iframe",
|
6591
6516
|
__spreadProps(__spreadValues({}, props), {
|
6592
6517
|
className,
|
@@ -6596,7 +6521,7 @@ function AutoFrame(_a) {
|
|
6596
6521
|
onLoad: () => {
|
6597
6522
|
setLoaded(true);
|
6598
6523
|
},
|
6599
|
-
children: /* @__PURE__ */
|
6524
|
+
children: /* @__PURE__ */ jsx30(autoFrameContext.Provider, { value: ctx, children: loaded && mountTarget && /* @__PURE__ */ jsx30(
|
6600
6525
|
CopyHostStyles,
|
6601
6526
|
{
|
6602
6527
|
debug,
|
@@ -6612,11 +6537,11 @@ var AutoFrame_default = AutoFrame;
|
|
6612
6537
|
|
6613
6538
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Preview/styles.module.css#css-module
|
6614
6539
|
init_react_import();
|
6615
|
-
var
|
6540
|
+
var styles_module_default15 = { "PuckPreview": "_PuckPreview_z2rgu_1", "PuckPreview-frame": "_PuckPreview-frame_z2rgu_6" };
|
6616
6541
|
|
6617
6542
|
// components/Puck/components/Preview/index.tsx
|
6618
|
-
import { Fragment as Fragment9, jsx as
|
6619
|
-
var
|
6543
|
+
import { Fragment as Fragment9, jsx as jsx31 } from "react/jsx-runtime";
|
6544
|
+
var getClassName21 = get_class_name_factory_default("PuckPreview", styles_module_default15);
|
6620
6545
|
var useBubbleIframeEvents = (ref) => {
|
6621
6546
|
const status = useAppStore((s) => s.status);
|
6622
6547
|
useEffect20(() => {
|
@@ -6678,15 +6603,15 @@ var Preview2 = ({ id = "puck-preview" }) => {
|
|
6678
6603
|
);
|
6679
6604
|
return ((_a = config.root) == null ? void 0 : _a.render) ? (_b = config.root) == null ? void 0 : _b.render(__spreadValues({
|
6680
6605
|
id: "puck-root"
|
6681
|
-
}, propsWithSlots)) : /* @__PURE__ */
|
6606
|
+
}, propsWithSlots)) : /* @__PURE__ */ jsx31(Fragment9, { children: propsWithSlots.children });
|
6682
6607
|
},
|
6683
6608
|
[config]
|
6684
6609
|
);
|
6685
|
-
const Frame =
|
6610
|
+
const Frame = useMemo14(() => overrides.iframe, [overrides]);
|
6686
6611
|
const rootProps = root.props || root;
|
6687
6612
|
const ref = useRef6(null);
|
6688
6613
|
useBubbleIframeEvents(ref);
|
6689
|
-
const inner = !renderData ? /* @__PURE__ */
|
6614
|
+
const inner = !renderData ? /* @__PURE__ */ jsx31(
|
6690
6615
|
Page,
|
6691
6616
|
__spreadProps(__spreadValues({}, rootProps), {
|
6692
6617
|
puck: {
|
@@ -6696,28 +6621,28 @@ var Preview2 = ({ id = "puck-preview" }) => {
|
|
6696
6621
|
metadata
|
6697
6622
|
},
|
6698
6623
|
editMode: true,
|
6699
|
-
children: /* @__PURE__ */
|
6624
|
+
children: /* @__PURE__ */ jsx31(DropZonePure, { zone: rootDroppableId })
|
6700
6625
|
})
|
6701
|
-
) : /* @__PURE__ */
|
6626
|
+
) : /* @__PURE__ */ jsx31(Render, { data: renderData, config });
|
6702
6627
|
useEffect20(() => {
|
6703
6628
|
if (!iframe.enabled) {
|
6704
6629
|
setStatus("READY");
|
6705
6630
|
}
|
6706
6631
|
}, [iframe.enabled]);
|
6707
|
-
return /* @__PURE__ */
|
6632
|
+
return /* @__PURE__ */ jsx31(
|
6708
6633
|
"div",
|
6709
6634
|
{
|
6710
|
-
className:
|
6635
|
+
className: getClassName21(),
|
6711
6636
|
id,
|
6712
6637
|
"data-puck-preview": true,
|
6713
6638
|
onClick: () => {
|
6714
6639
|
dispatch({ type: "setUi", ui: { itemSelector: null } });
|
6715
6640
|
},
|
6716
|
-
children: iframe.enabled ? /* @__PURE__ */
|
6641
|
+
children: iframe.enabled ? /* @__PURE__ */ jsx31(
|
6717
6642
|
AutoFrame_default,
|
6718
6643
|
{
|
6719
6644
|
id: "preview-frame",
|
6720
|
-
className:
|
6645
|
+
className: getClassName21("frame"),
|
6721
6646
|
"data-rfd-iframe": true,
|
6722
6647
|
onReady: () => {
|
6723
6648
|
setStatus("READY");
|
@@ -6726,18 +6651,18 @@ var Preview2 = ({ id = "puck-preview" }) => {
|
|
6726
6651
|
setStatus("MOUNTED");
|
6727
6652
|
},
|
6728
6653
|
frameRef: ref,
|
6729
|
-
children: /* @__PURE__ */
|
6654
|
+
children: /* @__PURE__ */ jsx31(autoFrameContext.Consumer, { children: ({ document: document2 }) => {
|
6730
6655
|
if (Frame) {
|
6731
|
-
return /* @__PURE__ */
|
6656
|
+
return /* @__PURE__ */ jsx31(Frame, { document: document2, children: inner });
|
6732
6657
|
}
|
6733
6658
|
return inner;
|
6734
6659
|
} })
|
6735
6660
|
}
|
6736
|
-
) : /* @__PURE__ */
|
6661
|
+
) : /* @__PURE__ */ jsx31(
|
6737
6662
|
"div",
|
6738
6663
|
{
|
6739
6664
|
id: "preview-frame",
|
6740
|
-
className:
|
6665
|
+
className: getClassName21("frame"),
|
6741
6666
|
ref,
|
6742
6667
|
"data-puck-entry": true,
|
6743
6668
|
children: inner
|
@@ -6755,7 +6680,7 @@ init_react_import();
|
|
6755
6680
|
|
6756
6681
|
// css-module:/home/runner/work/puck/puck/packages/core/components/LayerTree/styles.module.css#css-module
|
6757
6682
|
init_react_import();
|
6758
|
-
var
|
6683
|
+
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" };
|
6759
6684
|
|
6760
6685
|
// lib/scroll-into-view.ts
|
6761
6686
|
init_react_import();
|
@@ -6792,9 +6717,9 @@ var onScrollEnd = (frame, cb) => {
|
|
6792
6717
|
|
6793
6718
|
// components/LayerTree/index.tsx
|
6794
6719
|
import { useShallow as useShallow6 } from "zustand/react/shallow";
|
6795
|
-
import { Fragment as Fragment10, jsx as
|
6796
|
-
var
|
6797
|
-
var getClassNameLayer = get_class_name_factory_default("Layer",
|
6720
|
+
import { Fragment as Fragment10, jsx as jsx32, jsxs as jsxs14 } from "react/jsx-runtime";
|
6721
|
+
var getClassName22 = get_class_name_factory_default("LayerTree", styles_module_default16);
|
6722
|
+
var getClassNameLayer = get_class_name_factory_default("Layer", styles_module_default16);
|
6798
6723
|
var Layer = ({
|
6799
6724
|
index,
|
6800
6725
|
itemId,
|
@@ -6840,7 +6765,7 @@ var Layer = ({
|
|
6840
6765
|
});
|
6841
6766
|
const componentConfig = config.components[nodeData.data.type];
|
6842
6767
|
const label = (_a = componentConfig == null ? void 0 : componentConfig["label"]) != null ? _a : nodeData.data.type.toString();
|
6843
|
-
return /* @__PURE__ */
|
6768
|
+
return /* @__PURE__ */ jsxs14(
|
6844
6769
|
"li",
|
6845
6770
|
{
|
6846
6771
|
className: getClassNameLayer({
|
@@ -6850,7 +6775,7 @@ var Layer = ({
|
|
6850
6775
|
childIsSelected
|
6851
6776
|
}),
|
6852
6777
|
children: [
|
6853
|
-
/* @__PURE__ */
|
6778
|
+
/* @__PURE__ */ jsx32("div", { className: getClassNameLayer("inner"), children: /* @__PURE__ */ jsxs14(
|
6854
6779
|
"button",
|
6855
6780
|
{
|
6856
6781
|
type: "button",
|
@@ -6888,22 +6813,22 @@ var Layer = ({
|
|
6888
6813
|
zoneStore.setState({ hoveringComponent: null });
|
6889
6814
|
},
|
6890
6815
|
children: [
|
6891
|
-
containsZone && /* @__PURE__ */
|
6816
|
+
containsZone && /* @__PURE__ */ jsx32(
|
6892
6817
|
"div",
|
6893
6818
|
{
|
6894
6819
|
className: getClassNameLayer("chevron"),
|
6895
6820
|
title: isSelected ? "Collapse" : "Expand",
|
6896
|
-
children: /* @__PURE__ */
|
6821
|
+
children: /* @__PURE__ */ jsx32(ChevronDown, { size: "12" })
|
6897
6822
|
}
|
6898
6823
|
),
|
6899
|
-
/* @__PURE__ */
|
6900
|
-
/* @__PURE__ */
|
6901
|
-
/* @__PURE__ */
|
6824
|
+
/* @__PURE__ */ jsxs14("div", { className: getClassNameLayer("title"), children: [
|
6825
|
+
/* @__PURE__ */ jsx32("div", { className: getClassNameLayer("icon"), children: nodeData.data.type === "Text" || nodeData.data.type === "Heading" ? /* @__PURE__ */ jsx32(Type, { size: "16" }) : /* @__PURE__ */ jsx32(LayoutGrid, { size: "16" }) }),
|
6826
|
+
/* @__PURE__ */ jsx32("div", { className: getClassNameLayer("name"), children: label })
|
6902
6827
|
] })
|
6903
6828
|
]
|
6904
6829
|
}
|
6905
6830
|
) }),
|
6906
|
-
containsZone && zonesForItem.map((subzone) => /* @__PURE__ */
|
6831
|
+
containsZone && zonesForItem.map((subzone) => /* @__PURE__ */ jsx32("div", { className: getClassNameLayer("zones"), children: /* @__PURE__ */ jsx32(LayerTree, { zoneCompound: subzone }) }, subzone))
|
6907
6832
|
]
|
6908
6833
|
}
|
6909
6834
|
);
|
@@ -6921,15 +6846,15 @@ var LayerTree = ({
|
|
6921
6846
|
}
|
6922
6847
|
)
|
6923
6848
|
);
|
6924
|
-
return /* @__PURE__ */
|
6925
|
-
label && /* @__PURE__ */
|
6926
|
-
/* @__PURE__ */
|
6849
|
+
return /* @__PURE__ */ jsxs14(Fragment10, { children: [
|
6850
|
+
label && /* @__PURE__ */ jsxs14("div", { className: getClassName22("zoneTitle"), children: [
|
6851
|
+
/* @__PURE__ */ jsx32("div", { className: getClassName22("zoneIcon"), children: /* @__PURE__ */ jsx32(Layers, { size: "16" }) }),
|
6927
6852
|
label
|
6928
6853
|
] }),
|
6929
|
-
/* @__PURE__ */
|
6930
|
-
contentIds.length === 0 && /* @__PURE__ */
|
6854
|
+
/* @__PURE__ */ jsxs14("ul", { className: getClassName22(), children: [
|
6855
|
+
contentIds.length === 0 && /* @__PURE__ */ jsx32("div", { className: getClassName22("helper"), children: "No items" }),
|
6931
6856
|
contentIds.map((itemId, i) => {
|
6932
|
-
return /* @__PURE__ */
|
6857
|
+
return /* @__PURE__ */ jsx32(
|
6933
6858
|
Layer,
|
6934
6859
|
{
|
6935
6860
|
index: i,
|
@@ -6944,7 +6869,7 @@ var LayerTree = ({
|
|
6944
6869
|
};
|
6945
6870
|
|
6946
6871
|
// components/Puck/components/Outline/index.tsx
|
6947
|
-
import { useMemo as
|
6872
|
+
import { useMemo as useMemo15 } from "react";
|
6948
6873
|
|
6949
6874
|
// lib/data/find-zones-for-area.ts
|
6950
6875
|
init_react_import();
|
@@ -6956,14 +6881,14 @@ var findZonesForArea = (state, area) => {
|
|
6956
6881
|
|
6957
6882
|
// components/Puck/components/Outline/index.tsx
|
6958
6883
|
import { useShallow as useShallow7 } from "zustand/react/shallow";
|
6959
|
-
import { jsx as
|
6884
|
+
import { jsx as jsx33 } from "react/jsx-runtime";
|
6960
6885
|
var Outline = () => {
|
6961
6886
|
const outlineOverride = useAppStore((s) => s.overrides.outline);
|
6962
6887
|
const rootZones = useAppStore(
|
6963
6888
|
useShallow7((s) => findZonesForArea(s.state, "root"))
|
6964
6889
|
);
|
6965
|
-
const Wrapper =
|
6966
|
-
return /* @__PURE__ */
|
6890
|
+
const Wrapper = useMemo15(() => outlineOverride || "div", [outlineOverride]);
|
6891
|
+
return /* @__PURE__ */ jsx33(Wrapper, { children: rootZones.map((zoneCompound) => /* @__PURE__ */ jsx33(
|
6967
6892
|
LayerTree,
|
6968
6893
|
{
|
6969
6894
|
label: rootZones.length === 1 ? "" : zoneCompound.split(":")[1],
|
@@ -6973,320 +6898,828 @@ var Outline = () => {
|
|
6973
6898
|
)) });
|
6974
6899
|
};
|
6975
6900
|
|
6976
|
-
//
|
6901
|
+
// lib/use-loaded-overrides.ts
|
6977
6902
|
init_react_import();
|
6903
|
+
import { useMemo as useMemo16 } from "react";
|
6978
6904
|
|
6979
|
-
//
|
6905
|
+
// lib/load-overrides.ts
|
6980
6906
|
init_react_import();
|
6907
|
+
var loadOverrides = ({
|
6908
|
+
overrides,
|
6909
|
+
plugins
|
6910
|
+
}) => {
|
6911
|
+
const collected = __spreadValues({}, overrides);
|
6912
|
+
plugins == null ? void 0 : plugins.forEach((plugin) => {
|
6913
|
+
if (!plugin.overrides) return;
|
6914
|
+
Object.keys(plugin.overrides).forEach((_overridesType) => {
|
6915
|
+
const overridesType = _overridesType;
|
6916
|
+
if (overridesType === "fieldTypes") {
|
6917
|
+
const fieldTypes = plugin.overrides.fieldTypes;
|
6918
|
+
Object.keys(fieldTypes).forEach((fieldType) => {
|
6919
|
+
collected.fieldTypes = collected.fieldTypes || {};
|
6920
|
+
const childNode2 = collected.fieldTypes[fieldType];
|
6921
|
+
const Comp2 = (props) => fieldTypes[fieldType](__spreadProps(__spreadValues({}, props), {
|
6922
|
+
children: childNode2 ? childNode2(props) : props.children
|
6923
|
+
}));
|
6924
|
+
collected.fieldTypes[fieldType] = Comp2;
|
6925
|
+
});
|
6926
|
+
return;
|
6927
|
+
}
|
6928
|
+
const childNode = collected[overridesType];
|
6929
|
+
const Comp = (props) => plugin.overrides[overridesType](__spreadProps(__spreadValues({}, props), {
|
6930
|
+
children: childNode ? childNode(props) : props.children
|
6931
|
+
}));
|
6932
|
+
collected[overridesType] = Comp;
|
6933
|
+
});
|
6934
|
+
});
|
6935
|
+
return collected;
|
6936
|
+
};
|
6981
6937
|
|
6982
|
-
//
|
6983
|
-
|
6984
|
-
|
6985
|
-
|
6986
|
-
|
6987
|
-
|
6988
|
-
return;
|
6989
|
-
}
|
6990
|
-
|
6991
|
-
throw new Error(prefix);
|
6992
|
-
}
|
6993
|
-
var provided = typeof message === "function" ? message() : message;
|
6994
|
-
var value = provided ? "".concat(prefix, ": ").concat(provided) : prefix;
|
6995
|
-
throw new Error(value);
|
6996
|
-
}
|
6938
|
+
// lib/use-loaded-overrides.ts
|
6939
|
+
var useLoadedOverrides = ({
|
6940
|
+
overrides,
|
6941
|
+
plugins
|
6942
|
+
}) => {
|
6943
|
+
return useMemo16(() => {
|
6944
|
+
return loadOverrides({ overrides, plugins });
|
6945
|
+
}, [plugins, overrides]);
|
6946
|
+
};
|
6997
6947
|
|
6998
|
-
//
|
6999
|
-
|
7000
|
-
|
7001
|
-
|
7002
|
-
|
7003
|
-
|
7004
|
-
|
7005
|
-
|
7006
|
-
|
7007
|
-
|
7008
|
-
|
7009
|
-
|
7010
|
-
|
7011
|
-
|
7012
|
-
center: {
|
7013
|
-
x: (right + left) / 2,
|
7014
|
-
y: (bottom + top) / 2
|
7015
|
-
}
|
6948
|
+
// lib/use-puck.ts
|
6949
|
+
init_react_import();
|
6950
|
+
import { createContext as createContext6, useContext as useContext11, useEffect as useEffect21, useState as useState18 } from "react";
|
6951
|
+
import { createStore as createStore4, useStore as useStore3 } from "zustand";
|
6952
|
+
var generateUsePuck = (store) => {
|
6953
|
+
const history = {
|
6954
|
+
back: store.history.back,
|
6955
|
+
forward: store.history.forward,
|
6956
|
+
setHistories: store.history.setHistories,
|
6957
|
+
setHistoryIndex: store.history.setHistoryIndex,
|
6958
|
+
hasPast: store.history.hasPast(),
|
6959
|
+
hasFuture: store.history.hasFuture(),
|
6960
|
+
histories: store.history.histories,
|
6961
|
+
index: store.history.index
|
7016
6962
|
};
|
7017
|
-
|
7018
|
-
|
7019
|
-
|
7020
|
-
|
7021
|
-
|
7022
|
-
|
7023
|
-
|
7024
|
-
|
6963
|
+
const storeData = {
|
6964
|
+
appState: makeStatePublic(store.state),
|
6965
|
+
config: store.config,
|
6966
|
+
dispatch: store.dispatch,
|
6967
|
+
getPermissions: store.permissions.getPermissions,
|
6968
|
+
refreshPermissions: store.permissions.refreshPermissions,
|
6969
|
+
history,
|
6970
|
+
selectedItem: store.selectedItem || null,
|
6971
|
+
getItemBySelector: (selector) => getItem(selector, store.state),
|
6972
|
+
getItemById: (id) => store.state.indexes.nodes[id].data,
|
6973
|
+
getSelectorForId: (id) => {
|
6974
|
+
const node = store.state.indexes.nodes[id];
|
6975
|
+
if (!node) return;
|
6976
|
+
const zoneCompound = `${node.parentId}:${node.zone}`;
|
6977
|
+
const index = store.state.indexes.zones[zoneCompound].contentIds.indexOf(id);
|
6978
|
+
return { zone: zoneCompound, index };
|
6979
|
+
}
|
7025
6980
|
};
|
6981
|
+
const get = () => storeData;
|
6982
|
+
return __spreadProps(__spreadValues({}, storeData), { get });
|
7026
6983
|
};
|
7027
|
-
var
|
6984
|
+
var UsePuckStoreContext = createContext6(
|
6985
|
+
null
|
6986
|
+
);
|
6987
|
+
var convertToPickedStore = (store) => {
|
7028
6988
|
return {
|
7029
|
-
|
7030
|
-
|
7031
|
-
|
7032
|
-
|
6989
|
+
state: store.state,
|
6990
|
+
config: store.config,
|
6991
|
+
dispatch: store.dispatch,
|
6992
|
+
permissions: store.permissions,
|
6993
|
+
history: store.history,
|
6994
|
+
selectedItem: store.selectedItem
|
7033
6995
|
};
|
7034
6996
|
};
|
7035
|
-
var
|
7036
|
-
|
7037
|
-
|
7038
|
-
|
7039
|
-
|
6997
|
+
var useRegisterUsePuckStore = (appStore) => {
|
6998
|
+
const [usePuckStore] = useState18(
|
6999
|
+
() => createStore4(
|
7000
|
+
() => generateUsePuck(convertToPickedStore(appStore.getState()))
|
7001
|
+
)
|
7002
|
+
);
|
7003
|
+
useEffect21(() => {
|
7004
|
+
return appStore.subscribe(
|
7005
|
+
(store) => convertToPickedStore(store),
|
7006
|
+
(pickedStore) => {
|
7007
|
+
usePuckStore.setState(generateUsePuck(pickedStore));
|
7008
|
+
}
|
7009
|
+
);
|
7010
|
+
}, []);
|
7011
|
+
return usePuckStore;
|
7040
7012
|
};
|
7041
|
-
|
7042
|
-
|
7043
|
-
|
7044
|
-
|
7045
|
-
|
7046
|
-
|
7047
|
-
|
7048
|
-
|
7049
|
-
|
7050
|
-
|
7051
|
-
|
7052
|
-
border,
|
7053
|
-
padding
|
7013
|
+
function createUsePuck() {
|
7014
|
+
return function usePuck2(selector) {
|
7015
|
+
const usePuckApi = useContext11(UsePuckStoreContext);
|
7016
|
+
if (!usePuckApi) {
|
7017
|
+
throw new Error("usePuck must be used inside <Puck>.");
|
7018
|
+
}
|
7019
|
+
const result = useStore3(
|
7020
|
+
usePuckApi,
|
7021
|
+
selector != null ? selector : (s) => s
|
7022
|
+
);
|
7023
|
+
return result;
|
7054
7024
|
};
|
7055
|
-
}
|
7056
|
-
|
7057
|
-
|
7058
|
-
|
7059
|
-
|
7060
|
-
|
7025
|
+
}
|
7026
|
+
function usePuck() {
|
7027
|
+
useEffect21(() => {
|
7028
|
+
console.warn(
|
7029
|
+
"You're using the `usePuck` method without a selector, which may cause unnecessary re-renders. Replace with `createUsePuck` and provide a selector for improved performance."
|
7030
|
+
);
|
7031
|
+
}, []);
|
7032
|
+
return createUsePuck()((s) => s);
|
7033
|
+
}
|
7034
|
+
function useGetPuck() {
|
7035
|
+
const usePuckApi = useContext11(UsePuckStoreContext);
|
7036
|
+
if (!usePuckApi) {
|
7037
|
+
throw new Error("usePuckGet must be used inside <Puck>.");
|
7061
7038
|
}
|
7062
|
-
|
7063
|
-
|
7064
|
-
return result;
|
7065
|
-
};
|
7066
|
-
var calculateBox = function calculateBox2(borderBox, styles2) {
|
7067
|
-
var margin = {
|
7068
|
-
top: parse(styles2.marginTop),
|
7069
|
-
right: parse(styles2.marginRight),
|
7070
|
-
bottom: parse(styles2.marginBottom),
|
7071
|
-
left: parse(styles2.marginLeft)
|
7072
|
-
};
|
7073
|
-
var padding = {
|
7074
|
-
top: parse(styles2.paddingTop),
|
7075
|
-
right: parse(styles2.paddingRight),
|
7076
|
-
bottom: parse(styles2.paddingBottom),
|
7077
|
-
left: parse(styles2.paddingLeft)
|
7078
|
-
};
|
7079
|
-
var border = {
|
7080
|
-
top: parse(styles2.borderTopWidth),
|
7081
|
-
right: parse(styles2.borderRightWidth),
|
7082
|
-
bottom: parse(styles2.borderBottomWidth),
|
7083
|
-
left: parse(styles2.borderLeftWidth)
|
7084
|
-
};
|
7085
|
-
return createBox({
|
7086
|
-
borderBox,
|
7087
|
-
margin,
|
7088
|
-
padding,
|
7089
|
-
border
|
7090
|
-
});
|
7091
|
-
};
|
7092
|
-
var getBox = function getBox2(el) {
|
7093
|
-
var borderBox = el.getBoundingClientRect();
|
7094
|
-
var styles2 = window.getComputedStyle(el);
|
7095
|
-
return calculateBox(borderBox, styles2);
|
7096
|
-
};
|
7039
|
+
return usePuckApi.getState;
|
7040
|
+
}
|
7097
7041
|
|
7098
|
-
// components/Puck/
|
7099
|
-
import
|
7100
|
-
useCallback as useCallback15,
|
7101
|
-
useEffect as useEffect22,
|
7102
|
-
useMemo as useMemo18,
|
7103
|
-
useRef as useRef7,
|
7104
|
-
useState as useState19
|
7105
|
-
} from "react";
|
7042
|
+
// components/Puck/index.tsx
|
7043
|
+
import fdeq from "fast-deep-equal";
|
7106
7044
|
|
7107
|
-
// components/
|
7045
|
+
// components/Puck/components/Layout/index.tsx
|
7108
7046
|
init_react_import();
|
7109
|
-
import { useEffect as
|
7047
|
+
import { useEffect as useEffect25, useMemo as useMemo21, useState as useState23 } from "react";
|
7110
7048
|
|
7111
|
-
// css-module:/home/runner/work/puck/puck/packages/core/components/
|
7049
|
+
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Layout/styles.module.css#css-module
|
7112
7050
|
init_react_import();
|
7113
|
-
var
|
7051
|
+
var styles_module_default17 = { "Puck": "_Puck_n6ob8_19", "Puck-portal": "_Puck-portal_n6ob8_31", "PuckLayout-inner": "_PuckLayout-inner_n6ob8_36", "PuckLayout--mounted": "_PuckLayout--mounted_n6ob8_48", "PuckLayout--leftSideBarVisible": "_PuckLayout--leftSideBarVisible_n6ob8_53", "PuckLayout--rightSideBarVisible": "_PuckLayout--rightSideBarVisible_n6ob8_61", "PuckLayout-mounted": "_PuckLayout-mounted_n6ob8_77", "PuckLayout": "_PuckLayout_n6ob8_36", "PuckLayout-leftSideBar": "_PuckLayout-leftSideBar_n6ob8_118", "PuckLayout-rightSideBar": "_PuckLayout-rightSideBar_n6ob8_128", "PuckLayout-nav": "_PuckLayout-nav_n6ob8_137" };
|
7114
7052
|
|
7115
|
-
//
|
7116
|
-
|
7117
|
-
|
7118
|
-
|
7119
|
-
|
7120
|
-
|
7121
|
-
|
7122
|
-
|
7123
|
-
|
7124
|
-
|
7125
|
-
|
7126
|
-
|
7127
|
-
|
7128
|
-
width,
|
7129
|
-
onClick
|
7130
|
-
}) => {
|
7131
|
-
const viewports = useAppStore((s) => s.state.ui.viewports);
|
7132
|
-
const [isActive, setIsActive] = useState18(false);
|
7133
|
-
useEffect21(() => {
|
7134
|
-
setIsActive(width === viewports.current.width);
|
7135
|
-
}, [width, viewports.current.width]);
|
7136
|
-
return /* @__PURE__ */ jsx35("span", { className: getClassNameButton({ isActive }), children: /* @__PURE__ */ jsx35(
|
7137
|
-
IconButton,
|
7138
|
-
{
|
7139
|
-
title,
|
7140
|
-
disabled: isActive,
|
7141
|
-
onClick: (e) => {
|
7142
|
-
e.stopPropagation();
|
7143
|
-
onClick({ width, height });
|
7144
|
-
},
|
7145
|
-
children: /* @__PURE__ */ jsx35("span", { className: getClassNameButton("inner"), children })
|
7053
|
+
// lib/use-inject-css.ts
|
7054
|
+
init_react_import();
|
7055
|
+
import { useEffect as useEffect22, useState as useState19 } from "react";
|
7056
|
+
var styles = ``;
|
7057
|
+
var useInjectStyleSheet = (initialStyles, iframeEnabled) => {
|
7058
|
+
const [el, setEl] = useState19();
|
7059
|
+
useEffect22(() => {
|
7060
|
+
setEl(document.createElement("style"));
|
7061
|
+
}, []);
|
7062
|
+
useEffect22(() => {
|
7063
|
+
var _a;
|
7064
|
+
if (!el || typeof window === "undefined") {
|
7065
|
+
return;
|
7146
7066
|
}
|
7147
|
-
|
7067
|
+
el.innerHTML = initialStyles;
|
7068
|
+
if (iframeEnabled) {
|
7069
|
+
const frame = getFrame();
|
7070
|
+
(_a = frame == null ? void 0 : frame.head) == null ? void 0 : _a.appendChild(el);
|
7071
|
+
}
|
7072
|
+
document.head.appendChild(el);
|
7073
|
+
}, [iframeEnabled, el]);
|
7074
|
+
return el;
|
7148
7075
|
};
|
7149
|
-
var
|
7150
|
-
|
7151
|
-
{ label: "50%", value: 0.5 },
|
7152
|
-
{ label: "75%", value: 0.75 },
|
7153
|
-
{ label: "100%", value: 1 },
|
7154
|
-
{ label: "125%", value: 1.25 },
|
7155
|
-
{ label: "150%", value: 1.5 },
|
7156
|
-
{ label: "200%", value: 2 }
|
7157
|
-
];
|
7158
|
-
var ViewportControls = ({
|
7159
|
-
autoZoom,
|
7160
|
-
zoom,
|
7161
|
-
onViewportChange,
|
7162
|
-
onZoom
|
7163
|
-
}) => {
|
7164
|
-
var _a, _b;
|
7165
|
-
const viewports = useAppStore((s) => s.viewports);
|
7166
|
-
const defaultsContainAutoZoom = defaultZoomOptions.find(
|
7167
|
-
(option) => option.value === autoZoom
|
7168
|
-
);
|
7169
|
-
const zoomOptions = useMemo17(
|
7170
|
-
() => [
|
7171
|
-
...defaultZoomOptions,
|
7172
|
-
...defaultsContainAutoZoom ? [] : [
|
7173
|
-
{
|
7174
|
-
value: autoZoom,
|
7175
|
-
label: `${(autoZoom * 100).toFixed(0)}% (Auto)`
|
7176
|
-
}
|
7177
|
-
]
|
7178
|
-
].filter((a) => a.value <= autoZoom).sort((a, b) => a.value > b.value ? 1 : -1),
|
7179
|
-
[autoZoom]
|
7180
|
-
);
|
7181
|
-
return /* @__PURE__ */ jsxs16("div", { className: getClassName24(), children: [
|
7182
|
-
viewports.map((viewport, i) => /* @__PURE__ */ jsx35(
|
7183
|
-
ViewportButton,
|
7184
|
-
{
|
7185
|
-
height: viewport.height,
|
7186
|
-
width: viewport.width,
|
7187
|
-
title: viewport.label ? `Switch to ${viewport.label} viewport` : "Switch viewport",
|
7188
|
-
onClick: onViewportChange,
|
7189
|
-
children: typeof viewport.icon === "string" ? icons[viewport.icon] || viewport.icon : viewport.icon || icons.Smartphone
|
7190
|
-
},
|
7191
|
-
i
|
7192
|
-
)),
|
7193
|
-
/* @__PURE__ */ jsx35("div", { className: getClassName24("divider") }),
|
7194
|
-
/* @__PURE__ */ jsx35(
|
7195
|
-
IconButton,
|
7196
|
-
{
|
7197
|
-
title: "Zoom viewport out",
|
7198
|
-
disabled: zoom <= ((_a = zoomOptions[0]) == null ? void 0 : _a.value),
|
7199
|
-
onClick: (e) => {
|
7200
|
-
e.stopPropagation();
|
7201
|
-
onZoom(
|
7202
|
-
zoomOptions[Math.max(
|
7203
|
-
zoomOptions.findIndex((option) => option.value === zoom) - 1,
|
7204
|
-
0
|
7205
|
-
)].value
|
7206
|
-
);
|
7207
|
-
},
|
7208
|
-
children: /* @__PURE__ */ jsx35(ZoomOut, { size: 16 })
|
7209
|
-
}
|
7210
|
-
),
|
7211
|
-
/* @__PURE__ */ jsx35(
|
7212
|
-
IconButton,
|
7213
|
-
{
|
7214
|
-
title: "Zoom viewport in",
|
7215
|
-
disabled: zoom >= ((_b = zoomOptions[zoomOptions.length - 1]) == null ? void 0 : _b.value),
|
7216
|
-
onClick: (e) => {
|
7217
|
-
e.stopPropagation();
|
7218
|
-
onZoom(
|
7219
|
-
zoomOptions[Math.min(
|
7220
|
-
zoomOptions.findIndex((option) => option.value === zoom) + 1,
|
7221
|
-
zoomOptions.length - 1
|
7222
|
-
)].value
|
7223
|
-
);
|
7224
|
-
},
|
7225
|
-
children: /* @__PURE__ */ jsx35(ZoomIn, { size: 16 })
|
7226
|
-
}
|
7227
|
-
),
|
7228
|
-
/* @__PURE__ */ jsx35("div", { className: getClassName24("divider") }),
|
7229
|
-
/* @__PURE__ */ jsx35(
|
7230
|
-
"select",
|
7231
|
-
{
|
7232
|
-
className: getClassName24("zoomSelect"),
|
7233
|
-
value: zoom.toString(),
|
7234
|
-
onChange: (e) => {
|
7235
|
-
onZoom(parseFloat(e.currentTarget.value));
|
7236
|
-
},
|
7237
|
-
children: zoomOptions.map((option) => /* @__PURE__ */ jsx35(
|
7238
|
-
"option",
|
7239
|
-
{
|
7240
|
-
value: option.value,
|
7241
|
-
label: option.label
|
7242
|
-
},
|
7243
|
-
option.label
|
7244
|
-
))
|
7245
|
-
}
|
7246
|
-
)
|
7247
|
-
] });
|
7076
|
+
var useInjectGlobalCss = (iframeEnabled) => {
|
7077
|
+
return useInjectStyleSheet(styles, iframeEnabled);
|
7248
7078
|
};
|
7249
7079
|
|
7250
|
-
//
|
7080
|
+
// components/DefaultOverride/index.tsx
|
7251
7081
|
init_react_import();
|
7252
|
-
|
7082
|
+
import { Fragment as Fragment11, jsx as jsx34 } from "react/jsx-runtime";
|
7083
|
+
var DefaultOverride = ({ children }) => /* @__PURE__ */ jsx34(Fragment11, { children });
|
7253
7084
|
|
7254
|
-
// lib/
|
7085
|
+
// lib/use-preview-mode-hotkeys.ts
|
7255
7086
|
init_react_import();
|
7256
|
-
|
7257
|
-
var
|
7258
|
-
const
|
7259
|
-
const
|
7260
|
-
|
7261
|
-
|
7262
|
-
|
7263
|
-
|
7264
|
-
|
7265
|
-
|
7266
|
-
|
7267
|
-
|
7268
|
-
|
7269
|
-
|
7270
|
-
rootHeight = viewportHeight;
|
7271
|
-
zoom = heightZoom;
|
7272
|
-
}
|
7273
|
-
autoZoom = zoom;
|
7274
|
-
} else {
|
7275
|
-
if (RESET_ZOOM_SMALLER_THAN_FRAME) {
|
7276
|
-
autoZoom = 1;
|
7277
|
-
zoom = 1;
|
7278
|
-
rootHeight = viewportHeight;
|
7279
|
-
}
|
7280
|
-
}
|
7281
|
-
return { autoZoom, rootHeight, zoom };
|
7087
|
+
import { useCallback as useCallback15 } from "react";
|
7088
|
+
var usePreviewModeHotkeys = () => {
|
7089
|
+
const appStore = useAppStoreApi();
|
7090
|
+
const toggleInteractive = useCallback15(() => {
|
7091
|
+
const dispatch = appStore.getState().dispatch;
|
7092
|
+
dispatch({
|
7093
|
+
type: "setUi",
|
7094
|
+
ui: (ui) => ({
|
7095
|
+
previewMode: ui.previewMode === "edit" ? "interactive" : "edit"
|
7096
|
+
})
|
7097
|
+
});
|
7098
|
+
}, [appStore]);
|
7099
|
+
useHotkey({ meta: true, i: true }, toggleInteractive);
|
7100
|
+
useHotkey({ ctrl: true, i: true }, toggleInteractive);
|
7282
7101
|
};
|
7283
7102
|
|
7284
|
-
// components/Puck/components/
|
7285
|
-
|
7286
|
-
import {
|
7287
|
-
|
7288
|
-
|
7289
|
-
|
7103
|
+
// components/Puck/components/Header/index.tsx
|
7104
|
+
init_react_import();
|
7105
|
+
import { memo as memo3, useCallback as useCallback16, useMemo as useMemo17, useState as useState20 } from "react";
|
7106
|
+
|
7107
|
+
// components/MenuBar/index.tsx
|
7108
|
+
init_react_import();
|
7109
|
+
|
7110
|
+
// css-module:/home/runner/work/puck/puck/packages/core/components/MenuBar/styles.module.css#css-module
|
7111
|
+
init_react_import();
|
7112
|
+
var styles_module_default18 = { "MenuBar": "_MenuBar_8pf8c_1", "MenuBar--menuOpen": "_MenuBar--menuOpen_8pf8c_14", "MenuBar-inner": "_MenuBar-inner_8pf8c_29", "MenuBar-history": "_MenuBar-history_8pf8c_45" };
|
7113
|
+
|
7114
|
+
// components/MenuBar/index.tsx
|
7115
|
+
import { Fragment as Fragment12, jsx as jsx35, jsxs as jsxs15 } from "react/jsx-runtime";
|
7116
|
+
var getClassName23 = get_class_name_factory_default("MenuBar", styles_module_default18);
|
7117
|
+
function MenuBar({
|
7118
|
+
menuOpen = false,
|
7119
|
+
renderHeaderActions,
|
7120
|
+
setMenuOpen
|
7121
|
+
}) {
|
7122
|
+
const back = useAppStore((s) => s.history.back);
|
7123
|
+
const forward = useAppStore((s) => s.history.forward);
|
7124
|
+
const hasFuture = useAppStore((s) => s.history.hasFuture());
|
7125
|
+
const hasPast = useAppStore((s) => s.history.hasPast());
|
7126
|
+
return /* @__PURE__ */ jsx35(
|
7127
|
+
"div",
|
7128
|
+
{
|
7129
|
+
className: getClassName23({ menuOpen }),
|
7130
|
+
onClick: (event) => {
|
7131
|
+
var _a;
|
7132
|
+
const element = event.target;
|
7133
|
+
if (window.matchMedia("(min-width: 638px)").matches) {
|
7134
|
+
return;
|
7135
|
+
}
|
7136
|
+
if (element.tagName === "A" && ((_a = element.getAttribute("href")) == null ? void 0 : _a.startsWith("#"))) {
|
7137
|
+
setMenuOpen(false);
|
7138
|
+
}
|
7139
|
+
},
|
7140
|
+
children: /* @__PURE__ */ jsxs15("div", { className: getClassName23("inner"), children: [
|
7141
|
+
/* @__PURE__ */ jsxs15("div", { className: getClassName23("history"), children: [
|
7142
|
+
/* @__PURE__ */ jsx35(IconButton, { title: "undo", disabled: !hasPast, onClick: back, children: /* @__PURE__ */ jsx35(Undo2, { size: 21 }) }),
|
7143
|
+
/* @__PURE__ */ jsx35(IconButton, { title: "redo", disabled: !hasFuture, onClick: forward, children: /* @__PURE__ */ jsx35(Redo2, { size: 21 }) })
|
7144
|
+
] }),
|
7145
|
+
/* @__PURE__ */ jsx35(Fragment12, { children: renderHeaderActions && renderHeaderActions() })
|
7146
|
+
] })
|
7147
|
+
}
|
7148
|
+
);
|
7149
|
+
}
|
7150
|
+
|
7151
|
+
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Header/styles.module.css#css-module
|
7152
|
+
init_react_import();
|
7153
|
+
var styles_module_default19 = { "PuckHeader": "_PuckHeader_dlc6d_1", "PuckHeader-inner": "_PuckHeader-inner_dlc6d_16", "PuckHeader-toggle": "_PuckHeader-toggle_dlc6d_33", "PuckHeader--rightSideBarVisible": "_PuckHeader--rightSideBarVisible_dlc6d_40", "PuckHeader-rightSideBarToggle": "_PuckHeader-rightSideBarToggle_dlc6d_40", "PuckHeader--leftSideBarVisible": "_PuckHeader--leftSideBarVisible_dlc6d_41", "PuckHeader-leftSideBarToggle": "_PuckHeader-leftSideBarToggle_dlc6d_41", "PuckHeader-title": "_PuckHeader-title_dlc6d_45", "PuckHeader-path": "_PuckHeader-path_dlc6d_49", "PuckHeader-tools": "_PuckHeader-tools_dlc6d_56", "PuckHeader-menuButton": "_PuckHeader-menuButton_dlc6d_62", "PuckHeader--menuOpen": "_PuckHeader--menuOpen_dlc6d_67" };
|
7154
|
+
|
7155
|
+
// components/Puck/components/Header/index.tsx
|
7156
|
+
import { Fragment as Fragment13, jsx as jsx36, jsxs as jsxs16 } from "react/jsx-runtime";
|
7157
|
+
var getClassName24 = get_class_name_factory_default("PuckHeader", styles_module_default19);
|
7158
|
+
var HeaderInner = () => {
|
7159
|
+
const {
|
7160
|
+
onPublish,
|
7161
|
+
renderHeader,
|
7162
|
+
renderHeaderActions,
|
7163
|
+
headerTitle,
|
7164
|
+
headerPath,
|
7165
|
+
iframe: _iframe
|
7166
|
+
} = usePropsContext();
|
7167
|
+
const dispatch = useAppStore((s) => s.dispatch);
|
7168
|
+
const appStore = useAppStoreApi();
|
7169
|
+
const defaultHeaderRender = useMemo17(() => {
|
7170
|
+
if (renderHeader) {
|
7171
|
+
console.warn(
|
7172
|
+
"`renderHeader` is deprecated. Please use `overrides.header` and the `usePuck` hook instead"
|
7173
|
+
);
|
7174
|
+
const RenderHeader = (_a) => {
|
7175
|
+
var _b = _a, { actions } = _b, props = __objRest(_b, ["actions"]);
|
7176
|
+
const Comp = renderHeader;
|
7177
|
+
const appState = useAppStore((s) => s.state);
|
7178
|
+
return /* @__PURE__ */ jsx36(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState, children: actions }));
|
7179
|
+
};
|
7180
|
+
return RenderHeader;
|
7181
|
+
}
|
7182
|
+
return DefaultOverride;
|
7183
|
+
}, [renderHeader]);
|
7184
|
+
const defaultHeaderActionsRender = useMemo17(() => {
|
7185
|
+
if (renderHeaderActions) {
|
7186
|
+
console.warn(
|
7187
|
+
"`renderHeaderActions` is deprecated. Please use `overrides.headerActions` and the `usePuck` hook instead."
|
7188
|
+
);
|
7189
|
+
const RenderHeader = (props) => {
|
7190
|
+
const Comp = renderHeaderActions;
|
7191
|
+
const appState = useAppStore((s) => s.state);
|
7192
|
+
return /* @__PURE__ */ jsx36(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState }));
|
7193
|
+
};
|
7194
|
+
return RenderHeader;
|
7195
|
+
}
|
7196
|
+
return DefaultOverride;
|
7197
|
+
}, [renderHeader]);
|
7198
|
+
const CustomHeader = useAppStore(
|
7199
|
+
(s) => s.overrides.header || defaultHeaderRender
|
7200
|
+
);
|
7201
|
+
const CustomHeaderActions = useAppStore(
|
7202
|
+
(s) => s.overrides.headerActions || defaultHeaderActionsRender
|
7203
|
+
);
|
7204
|
+
const [menuOpen, setMenuOpen] = useState20(false);
|
7205
|
+
const rootTitle = useAppStore((s) => {
|
7206
|
+
var _a, _b;
|
7207
|
+
const rootData = (_a = s.state.indexes.nodes["root"]) == null ? void 0 : _a.data;
|
7208
|
+
return (_b = rootData.props.title) != null ? _b : "";
|
7209
|
+
});
|
7210
|
+
const leftSideBarVisible = useAppStore((s) => s.state.ui.leftSideBarVisible);
|
7211
|
+
const rightSideBarVisible = useAppStore(
|
7212
|
+
(s) => s.state.ui.rightSideBarVisible
|
7213
|
+
);
|
7214
|
+
const toggleSidebars = useCallback16(
|
7215
|
+
(sidebar) => {
|
7216
|
+
const widerViewport = window.matchMedia("(min-width: 638px)").matches;
|
7217
|
+
const sideBarVisible = sidebar === "left" ? leftSideBarVisible : rightSideBarVisible;
|
7218
|
+
const oppositeSideBar = sidebar === "left" ? "rightSideBarVisible" : "leftSideBarVisible";
|
7219
|
+
dispatch({
|
7220
|
+
type: "setUi",
|
7221
|
+
ui: __spreadValues({
|
7222
|
+
[`${sidebar}SideBarVisible`]: !sideBarVisible
|
7223
|
+
}, !widerViewport ? { [oppositeSideBar]: false } : {})
|
7224
|
+
});
|
7225
|
+
},
|
7226
|
+
[dispatch, leftSideBarVisible, rightSideBarVisible]
|
7227
|
+
);
|
7228
|
+
return /* @__PURE__ */ jsx36(
|
7229
|
+
CustomHeader,
|
7230
|
+
{
|
7231
|
+
actions: /* @__PURE__ */ jsx36(Fragment13, { children: /* @__PURE__ */ jsx36(CustomHeaderActions, { children: /* @__PURE__ */ jsx36(
|
7232
|
+
Button,
|
7233
|
+
{
|
7234
|
+
onClick: () => {
|
7235
|
+
const data = appStore.getState().state.data;
|
7236
|
+
onPublish && onPublish(data);
|
7237
|
+
},
|
7238
|
+
icon: /* @__PURE__ */ jsx36(Globe, { size: "14px" }),
|
7239
|
+
children: "Publish"
|
7240
|
+
}
|
7241
|
+
) }) }),
|
7242
|
+
children: /* @__PURE__ */ jsx36(
|
7243
|
+
"header",
|
7244
|
+
{
|
7245
|
+
className: getClassName24({ leftSideBarVisible, rightSideBarVisible }),
|
7246
|
+
children: /* @__PURE__ */ jsxs16("div", { className: getClassName24("inner"), children: [
|
7247
|
+
/* @__PURE__ */ jsxs16("div", { className: getClassName24("toggle"), children: [
|
7248
|
+
/* @__PURE__ */ jsx36("div", { className: getClassName24("leftSideBarToggle"), children: /* @__PURE__ */ jsx36(
|
7249
|
+
IconButton,
|
7250
|
+
{
|
7251
|
+
onClick: () => {
|
7252
|
+
toggleSidebars("left");
|
7253
|
+
},
|
7254
|
+
title: "Toggle left sidebar",
|
7255
|
+
children: /* @__PURE__ */ jsx36(PanelLeft, { focusable: "false" })
|
7256
|
+
}
|
7257
|
+
) }),
|
7258
|
+
/* @__PURE__ */ jsx36("div", { className: getClassName24("rightSideBarToggle"), children: /* @__PURE__ */ jsx36(
|
7259
|
+
IconButton,
|
7260
|
+
{
|
7261
|
+
onClick: () => {
|
7262
|
+
toggleSidebars("right");
|
7263
|
+
},
|
7264
|
+
title: "Toggle right sidebar",
|
7265
|
+
children: /* @__PURE__ */ jsx36(PanelRight, { focusable: "false" })
|
7266
|
+
}
|
7267
|
+
) })
|
7268
|
+
] }),
|
7269
|
+
/* @__PURE__ */ jsx36("div", { className: getClassName24("title"), children: /* @__PURE__ */ jsxs16(Heading, { rank: "2", size: "xs", children: [
|
7270
|
+
headerTitle || rootTitle || "Page",
|
7271
|
+
headerPath && /* @__PURE__ */ jsxs16(Fragment13, { children: [
|
7272
|
+
" ",
|
7273
|
+
/* @__PURE__ */ jsx36("code", { className: getClassName24("path"), children: headerPath })
|
7274
|
+
] })
|
7275
|
+
] }) }),
|
7276
|
+
/* @__PURE__ */ jsxs16("div", { className: getClassName24("tools"), children: [
|
7277
|
+
/* @__PURE__ */ jsx36("div", { className: getClassName24("menuButton"), children: /* @__PURE__ */ jsx36(
|
7278
|
+
IconButton,
|
7279
|
+
{
|
7280
|
+
onClick: () => {
|
7281
|
+
return setMenuOpen(!menuOpen);
|
7282
|
+
},
|
7283
|
+
title: "Toggle menu bar",
|
7284
|
+
children: menuOpen ? /* @__PURE__ */ jsx36(ChevronUp, { focusable: "false" }) : /* @__PURE__ */ jsx36(ChevronDown, { focusable: "false" })
|
7285
|
+
}
|
7286
|
+
) }),
|
7287
|
+
/* @__PURE__ */ jsx36(
|
7288
|
+
MenuBar,
|
7289
|
+
{
|
7290
|
+
dispatch,
|
7291
|
+
onPublish,
|
7292
|
+
menuOpen,
|
7293
|
+
renderHeaderActions: () => /* @__PURE__ */ jsx36(CustomHeaderActions, { children: /* @__PURE__ */ jsx36(
|
7294
|
+
Button,
|
7295
|
+
{
|
7296
|
+
onClick: () => {
|
7297
|
+
const data = appStore.getState().state.data;
|
7298
|
+
onPublish && onPublish(data);
|
7299
|
+
},
|
7300
|
+
icon: /* @__PURE__ */ jsx36(Globe, { size: "14px" }),
|
7301
|
+
children: "Publish"
|
7302
|
+
}
|
7303
|
+
) }),
|
7304
|
+
setMenuOpen
|
7305
|
+
}
|
7306
|
+
)
|
7307
|
+
] })
|
7308
|
+
] })
|
7309
|
+
}
|
7310
|
+
)
|
7311
|
+
}
|
7312
|
+
);
|
7313
|
+
};
|
7314
|
+
var Header = memo3(HeaderInner);
|
7315
|
+
|
7316
|
+
// components/SidebarSection/index.tsx
|
7317
|
+
init_react_import();
|
7318
|
+
|
7319
|
+
// css-module:/home/runner/work/puck/puck/packages/core/components/SidebarSection/styles.module.css#css-module
|
7320
|
+
init_react_import();
|
7321
|
+
var styles_module_default20 = { "SidebarSection": "_SidebarSection_8boj8_1", "SidebarSection-title": "_SidebarSection-title_8boj8_12", "SidebarSection--noBorderTop": "_SidebarSection--noBorderTop_8boj8_20", "SidebarSection-content": "_SidebarSection-content_8boj8_24", "SidebarSection--noPadding": "_SidebarSection--noPadding_8boj8_28", "SidebarSection-breadcrumbLabel": "_SidebarSection-breadcrumbLabel_8boj8_41", "SidebarSection-breadcrumbs": "_SidebarSection-breadcrumbs_8boj8_70", "SidebarSection-breadcrumb": "_SidebarSection-breadcrumb_8boj8_41", "SidebarSection-heading": "_SidebarSection-heading_8boj8_82", "SidebarSection-loadingOverlay": "_SidebarSection-loadingOverlay_8boj8_86" };
|
7322
|
+
|
7323
|
+
// lib/use-breadcrumbs.ts
|
7324
|
+
init_react_import();
|
7325
|
+
import { useMemo as useMemo18 } from "react";
|
7326
|
+
var useBreadcrumbs = (renderCount) => {
|
7327
|
+
const selectedId = useAppStore((s) => {
|
7328
|
+
var _a;
|
7329
|
+
return (_a = s.selectedItem) == null ? void 0 : _a.props.id;
|
7330
|
+
});
|
7331
|
+
const config = useAppStore((s) => s.config);
|
7332
|
+
const path = useAppStore((s) => {
|
7333
|
+
var _a;
|
7334
|
+
return (_a = s.state.indexes.nodes[selectedId]) == null ? void 0 : _a.path;
|
7335
|
+
});
|
7336
|
+
const appStore = useAppStoreApi();
|
7337
|
+
return useMemo18(() => {
|
7338
|
+
const breadcrumbs = (path == null ? void 0 : path.map((zoneCompound) => {
|
7339
|
+
var _a, _b, _c;
|
7340
|
+
const [componentId] = zoneCompound.split(":");
|
7341
|
+
if (componentId === "root") {
|
7342
|
+
return {
|
7343
|
+
label: "Page",
|
7344
|
+
selector: null
|
7345
|
+
};
|
7346
|
+
}
|
7347
|
+
const node = appStore.getState().state.indexes.nodes[componentId];
|
7348
|
+
const parentId = node.path[node.path.length - 1];
|
7349
|
+
const contentIds = ((_a = appStore.getState().state.indexes.zones[parentId]) == null ? void 0 : _a.contentIds) || [];
|
7350
|
+
const index = contentIds.indexOf(componentId);
|
7351
|
+
const label = node ? (_c = (_b = config.components[node.data.type]) == null ? void 0 : _b.label) != null ? _c : node.data.type : "Component";
|
7352
|
+
return {
|
7353
|
+
label,
|
7354
|
+
selector: node ? {
|
7355
|
+
index,
|
7356
|
+
zone: node.path[node.path.length - 1]
|
7357
|
+
} : null
|
7358
|
+
};
|
7359
|
+
})) || [];
|
7360
|
+
if (renderCount) {
|
7361
|
+
return breadcrumbs.slice(breadcrumbs.length - renderCount);
|
7362
|
+
}
|
7363
|
+
return breadcrumbs;
|
7364
|
+
}, [path, renderCount]);
|
7365
|
+
};
|
7366
|
+
|
7367
|
+
// components/SidebarSection/index.tsx
|
7368
|
+
import { jsx as jsx37, jsxs as jsxs17 } from "react/jsx-runtime";
|
7369
|
+
var getClassName25 = get_class_name_factory_default("SidebarSection", styles_module_default20);
|
7370
|
+
var SidebarSection = ({
|
7371
|
+
children,
|
7372
|
+
title,
|
7373
|
+
background,
|
7374
|
+
showBreadcrumbs,
|
7375
|
+
noBorderTop,
|
7376
|
+
noPadding,
|
7377
|
+
isLoading
|
7378
|
+
}) => {
|
7379
|
+
const setUi = useAppStore((s) => s.setUi);
|
7380
|
+
const breadcrumbs = useBreadcrumbs(1);
|
7381
|
+
return /* @__PURE__ */ jsxs17(
|
7382
|
+
"div",
|
7383
|
+
{
|
7384
|
+
className: getClassName25({ noBorderTop, noPadding }),
|
7385
|
+
style: { background },
|
7386
|
+
children: [
|
7387
|
+
/* @__PURE__ */ jsx37("div", { className: getClassName25("title"), children: /* @__PURE__ */ jsxs17("div", { className: getClassName25("breadcrumbs"), children: [
|
7388
|
+
showBreadcrumbs ? breadcrumbs.map((breadcrumb, i) => /* @__PURE__ */ jsxs17("div", { className: getClassName25("breadcrumb"), children: [
|
7389
|
+
/* @__PURE__ */ jsx37(
|
7390
|
+
"button",
|
7391
|
+
{
|
7392
|
+
type: "button",
|
7393
|
+
className: getClassName25("breadcrumbLabel"),
|
7394
|
+
onClick: () => setUi({ itemSelector: breadcrumb.selector }),
|
7395
|
+
children: breadcrumb.label
|
7396
|
+
}
|
7397
|
+
),
|
7398
|
+
/* @__PURE__ */ jsx37(ChevronRight, { size: 16 })
|
7399
|
+
] }, i)) : null,
|
7400
|
+
/* @__PURE__ */ jsx37("div", { className: getClassName25("heading"), children: /* @__PURE__ */ jsx37(Heading, { rank: "2", size: "xs", children: title }) })
|
7401
|
+
] }) }),
|
7402
|
+
/* @__PURE__ */ jsx37("div", { className: getClassName25("content"), children }),
|
7403
|
+
isLoading && /* @__PURE__ */ jsx37("div", { className: getClassName25("loadingOverlay"), children: /* @__PURE__ */ jsx37(Loader, { size: 32 }) })
|
7404
|
+
]
|
7405
|
+
}
|
7406
|
+
);
|
7407
|
+
};
|
7408
|
+
|
7409
|
+
// components/Puck/components/Canvas/index.tsx
|
7410
|
+
init_react_import();
|
7411
|
+
|
7412
|
+
// ../../node_modules/css-box-model/dist/css-box-model.esm.js
|
7413
|
+
init_react_import();
|
7414
|
+
|
7415
|
+
// ../../node_modules/tiny-invariant/dist/esm/tiny-invariant.js
|
7416
|
+
init_react_import();
|
7417
|
+
var isProduction = process.env.NODE_ENV === "production";
|
7418
|
+
var prefix = "Invariant failed";
|
7419
|
+
function invariant(condition, message) {
|
7420
|
+
if (condition) {
|
7421
|
+
return;
|
7422
|
+
}
|
7423
|
+
if (isProduction) {
|
7424
|
+
throw new Error(prefix);
|
7425
|
+
}
|
7426
|
+
var provided = typeof message === "function" ? message() : message;
|
7427
|
+
var value = provided ? "".concat(prefix, ": ").concat(provided) : prefix;
|
7428
|
+
throw new Error(value);
|
7429
|
+
}
|
7430
|
+
|
7431
|
+
// ../../node_modules/css-box-model/dist/css-box-model.esm.js
|
7432
|
+
var getRect = function getRect2(_ref) {
|
7433
|
+
var top = _ref.top, right = _ref.right, bottom = _ref.bottom, left = _ref.left;
|
7434
|
+
var width = right - left;
|
7435
|
+
var height = bottom - top;
|
7436
|
+
var rect = {
|
7437
|
+
top,
|
7438
|
+
right,
|
7439
|
+
bottom,
|
7440
|
+
left,
|
7441
|
+
width,
|
7442
|
+
height,
|
7443
|
+
x: left,
|
7444
|
+
y: top,
|
7445
|
+
center: {
|
7446
|
+
x: (right + left) / 2,
|
7447
|
+
y: (bottom + top) / 2
|
7448
|
+
}
|
7449
|
+
};
|
7450
|
+
return rect;
|
7451
|
+
};
|
7452
|
+
var expand = function expand2(target, expandBy) {
|
7453
|
+
return {
|
7454
|
+
top: target.top - expandBy.top,
|
7455
|
+
left: target.left - expandBy.left,
|
7456
|
+
bottom: target.bottom + expandBy.bottom,
|
7457
|
+
right: target.right + expandBy.right
|
7458
|
+
};
|
7459
|
+
};
|
7460
|
+
var shrink = function shrink2(target, shrinkBy) {
|
7461
|
+
return {
|
7462
|
+
top: target.top + shrinkBy.top,
|
7463
|
+
left: target.left + shrinkBy.left,
|
7464
|
+
bottom: target.bottom - shrinkBy.bottom,
|
7465
|
+
right: target.right - shrinkBy.right
|
7466
|
+
};
|
7467
|
+
};
|
7468
|
+
var noSpacing = {
|
7469
|
+
top: 0,
|
7470
|
+
right: 0,
|
7471
|
+
bottom: 0,
|
7472
|
+
left: 0
|
7473
|
+
};
|
7474
|
+
var createBox = function createBox2(_ref2) {
|
7475
|
+
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;
|
7476
|
+
var marginBox = getRect(expand(borderBox, margin));
|
7477
|
+
var paddingBox = getRect(shrink(borderBox, border));
|
7478
|
+
var contentBox = getRect(shrink(paddingBox, padding));
|
7479
|
+
return {
|
7480
|
+
marginBox,
|
7481
|
+
borderBox: getRect(borderBox),
|
7482
|
+
paddingBox,
|
7483
|
+
contentBox,
|
7484
|
+
margin,
|
7485
|
+
border,
|
7486
|
+
padding
|
7487
|
+
};
|
7488
|
+
};
|
7489
|
+
var parse = function parse2(raw) {
|
7490
|
+
var value = raw.slice(0, -2);
|
7491
|
+
var suffix = raw.slice(-2);
|
7492
|
+
if (suffix !== "px") {
|
7493
|
+
return 0;
|
7494
|
+
}
|
7495
|
+
var result = Number(value);
|
7496
|
+
!!isNaN(result) ? process.env.NODE_ENV !== "production" ? invariant(false, "Could not parse value [raw: " + raw + ", without suffix: " + value + "]") : invariant(false) : void 0;
|
7497
|
+
return result;
|
7498
|
+
};
|
7499
|
+
var calculateBox = function calculateBox2(borderBox, styles2) {
|
7500
|
+
var margin = {
|
7501
|
+
top: parse(styles2.marginTop),
|
7502
|
+
right: parse(styles2.marginRight),
|
7503
|
+
bottom: parse(styles2.marginBottom),
|
7504
|
+
left: parse(styles2.marginLeft)
|
7505
|
+
};
|
7506
|
+
var padding = {
|
7507
|
+
top: parse(styles2.paddingTop),
|
7508
|
+
right: parse(styles2.paddingRight),
|
7509
|
+
bottom: parse(styles2.paddingBottom),
|
7510
|
+
left: parse(styles2.paddingLeft)
|
7511
|
+
};
|
7512
|
+
var border = {
|
7513
|
+
top: parse(styles2.borderTopWidth),
|
7514
|
+
right: parse(styles2.borderRightWidth),
|
7515
|
+
bottom: parse(styles2.borderBottomWidth),
|
7516
|
+
left: parse(styles2.borderLeftWidth)
|
7517
|
+
};
|
7518
|
+
return createBox({
|
7519
|
+
borderBox,
|
7520
|
+
margin,
|
7521
|
+
padding,
|
7522
|
+
border
|
7523
|
+
});
|
7524
|
+
};
|
7525
|
+
var getBox = function getBox2(el) {
|
7526
|
+
var borderBox = el.getBoundingClientRect();
|
7527
|
+
var styles2 = window.getComputedStyle(el);
|
7528
|
+
return calculateBox(borderBox, styles2);
|
7529
|
+
};
|
7530
|
+
|
7531
|
+
// components/Puck/components/Canvas/index.tsx
|
7532
|
+
import {
|
7533
|
+
useCallback as useCallback17,
|
7534
|
+
useEffect as useEffect24,
|
7535
|
+
useMemo as useMemo20,
|
7536
|
+
useRef as useRef7,
|
7537
|
+
useState as useState22
|
7538
|
+
} from "react";
|
7539
|
+
|
7540
|
+
// components/ViewportControls/index.tsx
|
7541
|
+
init_react_import();
|
7542
|
+
import { useEffect as useEffect23, useMemo as useMemo19, useState as useState21 } from "react";
|
7543
|
+
|
7544
|
+
// css-module:/home/runner/work/puck/puck/packages/core/components/ViewportControls/styles.module.css#css-module
|
7545
|
+
init_react_import();
|
7546
|
+
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" };
|
7547
|
+
|
7548
|
+
// components/ViewportControls/index.tsx
|
7549
|
+
import { jsx as jsx38, jsxs as jsxs18 } from "react/jsx-runtime";
|
7550
|
+
var icons = {
|
7551
|
+
Smartphone: /* @__PURE__ */ jsx38(Smartphone, { size: 16 }),
|
7552
|
+
Tablet: /* @__PURE__ */ jsx38(Tablet, { size: 16 }),
|
7553
|
+
Monitor: /* @__PURE__ */ jsx38(Monitor, { size: 16 })
|
7554
|
+
};
|
7555
|
+
var getClassName26 = get_class_name_factory_default("ViewportControls", styles_module_default21);
|
7556
|
+
var getClassNameButton = get_class_name_factory_default("ViewportButton", styles_module_default21);
|
7557
|
+
var ViewportButton = ({
|
7558
|
+
children,
|
7559
|
+
height = "auto",
|
7560
|
+
title,
|
7561
|
+
width,
|
7562
|
+
onClick
|
7563
|
+
}) => {
|
7564
|
+
const viewports = useAppStore((s) => s.state.ui.viewports);
|
7565
|
+
const [isActive, setIsActive] = useState21(false);
|
7566
|
+
useEffect23(() => {
|
7567
|
+
setIsActive(width === viewports.current.width);
|
7568
|
+
}, [width, viewports.current.width]);
|
7569
|
+
return /* @__PURE__ */ jsx38("span", { className: getClassNameButton({ isActive }), children: /* @__PURE__ */ jsx38(
|
7570
|
+
IconButton,
|
7571
|
+
{
|
7572
|
+
title,
|
7573
|
+
disabled: isActive,
|
7574
|
+
onClick: (e) => {
|
7575
|
+
e.stopPropagation();
|
7576
|
+
onClick({ width, height });
|
7577
|
+
},
|
7578
|
+
children: /* @__PURE__ */ jsx38("span", { className: getClassNameButton("inner"), children })
|
7579
|
+
}
|
7580
|
+
) });
|
7581
|
+
};
|
7582
|
+
var defaultZoomOptions = [
|
7583
|
+
{ label: "25%", value: 0.25 },
|
7584
|
+
{ label: "50%", value: 0.5 },
|
7585
|
+
{ label: "75%", value: 0.75 },
|
7586
|
+
{ label: "100%", value: 1 },
|
7587
|
+
{ label: "125%", value: 1.25 },
|
7588
|
+
{ label: "150%", value: 1.5 },
|
7589
|
+
{ label: "200%", value: 2 }
|
7590
|
+
];
|
7591
|
+
var ViewportControls = ({
|
7592
|
+
autoZoom,
|
7593
|
+
zoom,
|
7594
|
+
onViewportChange,
|
7595
|
+
onZoom
|
7596
|
+
}) => {
|
7597
|
+
var _a, _b;
|
7598
|
+
const viewports = useAppStore((s) => s.viewports);
|
7599
|
+
const defaultsContainAutoZoom = defaultZoomOptions.find(
|
7600
|
+
(option) => option.value === autoZoom
|
7601
|
+
);
|
7602
|
+
const zoomOptions = useMemo19(
|
7603
|
+
() => [
|
7604
|
+
...defaultZoomOptions,
|
7605
|
+
...defaultsContainAutoZoom ? [] : [
|
7606
|
+
{
|
7607
|
+
value: autoZoom,
|
7608
|
+
label: `${(autoZoom * 100).toFixed(0)}% (Auto)`
|
7609
|
+
}
|
7610
|
+
]
|
7611
|
+
].filter((a) => a.value <= autoZoom).sort((a, b) => a.value > b.value ? 1 : -1),
|
7612
|
+
[autoZoom]
|
7613
|
+
);
|
7614
|
+
return /* @__PURE__ */ jsxs18("div", { className: getClassName26(), children: [
|
7615
|
+
viewports.map((viewport, i) => /* @__PURE__ */ jsx38(
|
7616
|
+
ViewportButton,
|
7617
|
+
{
|
7618
|
+
height: viewport.height,
|
7619
|
+
width: viewport.width,
|
7620
|
+
title: viewport.label ? `Switch to ${viewport.label} viewport` : "Switch viewport",
|
7621
|
+
onClick: onViewportChange,
|
7622
|
+
children: typeof viewport.icon === "string" ? icons[viewport.icon] || viewport.icon : viewport.icon || icons.Smartphone
|
7623
|
+
},
|
7624
|
+
i
|
7625
|
+
)),
|
7626
|
+
/* @__PURE__ */ jsx38("div", { className: getClassName26("divider") }),
|
7627
|
+
/* @__PURE__ */ jsx38(
|
7628
|
+
IconButton,
|
7629
|
+
{
|
7630
|
+
title: "Zoom viewport out",
|
7631
|
+
disabled: zoom <= ((_a = zoomOptions[0]) == null ? void 0 : _a.value),
|
7632
|
+
onClick: (e) => {
|
7633
|
+
e.stopPropagation();
|
7634
|
+
onZoom(
|
7635
|
+
zoomOptions[Math.max(
|
7636
|
+
zoomOptions.findIndex((option) => option.value === zoom) - 1,
|
7637
|
+
0
|
7638
|
+
)].value
|
7639
|
+
);
|
7640
|
+
},
|
7641
|
+
children: /* @__PURE__ */ jsx38(ZoomOut, { size: 16 })
|
7642
|
+
}
|
7643
|
+
),
|
7644
|
+
/* @__PURE__ */ jsx38(
|
7645
|
+
IconButton,
|
7646
|
+
{
|
7647
|
+
title: "Zoom viewport in",
|
7648
|
+
disabled: zoom >= ((_b = zoomOptions[zoomOptions.length - 1]) == null ? void 0 : _b.value),
|
7649
|
+
onClick: (e) => {
|
7650
|
+
e.stopPropagation();
|
7651
|
+
onZoom(
|
7652
|
+
zoomOptions[Math.min(
|
7653
|
+
zoomOptions.findIndex((option) => option.value === zoom) + 1,
|
7654
|
+
zoomOptions.length - 1
|
7655
|
+
)].value
|
7656
|
+
);
|
7657
|
+
},
|
7658
|
+
children: /* @__PURE__ */ jsx38(ZoomIn, { size: 16 })
|
7659
|
+
}
|
7660
|
+
),
|
7661
|
+
/* @__PURE__ */ jsx38("div", { className: getClassName26("divider") }),
|
7662
|
+
/* @__PURE__ */ jsx38(
|
7663
|
+
"select",
|
7664
|
+
{
|
7665
|
+
className: getClassName26("zoomSelect"),
|
7666
|
+
value: zoom.toString(),
|
7667
|
+
onChange: (e) => {
|
7668
|
+
onZoom(parseFloat(e.currentTarget.value));
|
7669
|
+
},
|
7670
|
+
children: zoomOptions.map((option) => /* @__PURE__ */ jsx38(
|
7671
|
+
"option",
|
7672
|
+
{
|
7673
|
+
value: option.value,
|
7674
|
+
label: option.label
|
7675
|
+
},
|
7676
|
+
option.label
|
7677
|
+
))
|
7678
|
+
}
|
7679
|
+
)
|
7680
|
+
] });
|
7681
|
+
};
|
7682
|
+
|
7683
|
+
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Canvas/styles.module.css#css-module
|
7684
|
+
init_react_import();
|
7685
|
+
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" };
|
7686
|
+
|
7687
|
+
// lib/get-zoom-config.ts
|
7688
|
+
init_react_import();
|
7689
|
+
var RESET_ZOOM_SMALLER_THAN_FRAME = true;
|
7690
|
+
var getZoomConfig = (uiViewport, frame, zoom) => {
|
7691
|
+
const box = getBox(frame);
|
7692
|
+
const { width: frameWidth, height: frameHeight } = box.contentBox;
|
7693
|
+
const viewportHeight = uiViewport.height === "auto" ? frameHeight : uiViewport.height;
|
7694
|
+
let rootHeight = 0;
|
7695
|
+
let autoZoom = 1;
|
7696
|
+
if (uiViewport.width > frameWidth || viewportHeight > frameHeight) {
|
7697
|
+
const widthZoom = Math.min(frameWidth / uiViewport.width, 1);
|
7698
|
+
const heightZoom = Math.min(frameHeight / viewportHeight, 1);
|
7699
|
+
zoom = widthZoom;
|
7700
|
+
if (widthZoom < heightZoom) {
|
7701
|
+
rootHeight = viewportHeight / zoom;
|
7702
|
+
} else {
|
7703
|
+
rootHeight = viewportHeight;
|
7704
|
+
zoom = heightZoom;
|
7705
|
+
}
|
7706
|
+
autoZoom = zoom;
|
7707
|
+
} else {
|
7708
|
+
if (RESET_ZOOM_SMALLER_THAN_FRAME) {
|
7709
|
+
autoZoom = 1;
|
7710
|
+
zoom = 1;
|
7711
|
+
rootHeight = viewportHeight;
|
7712
|
+
}
|
7713
|
+
}
|
7714
|
+
return { autoZoom, rootHeight, zoom };
|
7715
|
+
};
|
7716
|
+
|
7717
|
+
// components/Puck/components/Canvas/index.tsx
|
7718
|
+
import { useShallow as useShallow8 } from "zustand/react/shallow";
|
7719
|
+
import { Fragment as Fragment14, jsx as jsx39, jsxs as jsxs19 } from "react/jsx-runtime";
|
7720
|
+
var getClassName27 = get_class_name_factory_default("PuckCanvas", styles_module_default22);
|
7721
|
+
var ZOOM_ON_CHANGE = true;
|
7722
|
+
var Canvas = () => {
|
7290
7723
|
const {
|
7291
7724
|
dispatch,
|
7292
7725
|
overrides,
|
@@ -7314,564 +7747,344 @@ var Canvas = () => {
|
|
7314
7747
|
}))
|
7315
7748
|
);
|
7316
7749
|
const frameRef = useRef7(null);
|
7317
|
-
const [showTransition, setShowTransition] =
|
7318
|
-
const defaultRender =
|
7319
|
-
const PuckDefault = ({ children }) => /* @__PURE__ */
|
7750
|
+
const [showTransition, setShowTransition] = useState22(false);
|
7751
|
+
const defaultRender = useMemo20(() => {
|
7752
|
+
const PuckDefault = ({ children }) => /* @__PURE__ */ jsx39(Fragment14, { children });
|
7320
7753
|
return PuckDefault;
|
7321
7754
|
}, []);
|
7322
|
-
const CustomPreview =
|
7755
|
+
const CustomPreview = useMemo20(
|
7323
7756
|
() => overrides.preview || defaultRender,
|
7324
7757
|
[overrides]
|
7325
7758
|
);
|
7326
|
-
const getFrameDimensions =
|
7327
|
-
if (frameRef.current) {
|
7328
|
-
const frame = frameRef.current;
|
7329
|
-
const box = getBox(frame);
|
7330
|
-
return { width: box.contentBox.width, height: box.contentBox.height };
|
7331
|
-
}
|
7332
|
-
return { width: 0, height: 0 };
|
7333
|
-
}, [frameRef]);
|
7334
|
-
const resetAutoZoom = useCallback15(
|
7335
|
-
(newViewports = viewports) => {
|
7336
|
-
if (frameRef.current) {
|
7337
|
-
setZoomConfig(
|
7338
|
-
getZoomConfig(
|
7339
|
-
newViewports == null ? void 0 : newViewports.current,
|
7340
|
-
frameRef.current,
|
7341
|
-
zoomConfig.zoom
|
7342
|
-
)
|
7343
|
-
);
|
7344
|
-
}
|
7345
|
-
},
|
7346
|
-
[frameRef, zoomConfig, viewports]
|
7347
|
-
);
|
7348
|
-
useEffect22(() => {
|
7349
|
-
setShowTransition(false);
|
7350
|
-
resetAutoZoom(viewports);
|
7351
|
-
}, [frameRef, leftSideBarVisible, rightSideBarVisible]);
|
7352
|
-
useEffect22(() => {
|
7353
|
-
const { height: frameHeight } = getFrameDimensions();
|
7354
|
-
if (viewports.current.height === "auto") {
|
7355
|
-
setZoomConfig(__spreadProps(__spreadValues({}, zoomConfig), {
|
7356
|
-
rootHeight: frameHeight / zoomConfig.zoom
|
7357
|
-
}));
|
7358
|
-
}
|
7359
|
-
}, [zoomConfig.zoom]);
|
7360
|
-
useEffect22(() => {
|
7361
|
-
if (ZOOM_ON_CHANGE) {
|
7362
|
-
setShowTransition(true);
|
7363
|
-
resetAutoZoom(viewports);
|
7364
|
-
}
|
7365
|
-
}, [viewports.current.width]);
|
7366
|
-
useEffect22(() => {
|
7367
|
-
const cb = () => {
|
7368
|
-
setShowTransition(false);
|
7369
|
-
resetAutoZoom();
|
7370
|
-
};
|
7371
|
-
window.addEventListener("resize", cb);
|
7372
|
-
return () => {
|
7373
|
-
window.removeEventListener("resize", cb);
|
7374
|
-
};
|
7375
|
-
}, []);
|
7376
|
-
const [showLoader, setShowLoader] = useState19(false);
|
7377
|
-
useEffect22(() => {
|
7378
|
-
setTimeout(() => {
|
7379
|
-
setShowLoader(true);
|
7380
|
-
}, 500);
|
7381
|
-
}, []);
|
7382
|
-
return /* @__PURE__ */ jsxs17(
|
7383
|
-
"div",
|
7384
|
-
{
|
7385
|
-
className: getClassName25({
|
7386
|
-
ready: status === "READY" || !iframe.enabled || !iframe.waitForStyles,
|
7387
|
-
showLoader
|
7388
|
-
}),
|
7389
|
-
onClick: () => dispatch({
|
7390
|
-
type: "setUi",
|
7391
|
-
ui: { itemSelector: null },
|
7392
|
-
recordHistory: true
|
7393
|
-
}),
|
7394
|
-
children: [
|
7395
|
-
viewports.controlsVisible && iframe.enabled && /* @__PURE__ */ jsx36("div", { className: getClassName25("controls"), children: /* @__PURE__ */ jsx36(
|
7396
|
-
ViewportControls,
|
7397
|
-
{
|
7398
|
-
autoZoom: zoomConfig.autoZoom,
|
7399
|
-
zoom: zoomConfig.zoom,
|
7400
|
-
onViewportChange: (viewport) => {
|
7401
|
-
setShowTransition(true);
|
7402
|
-
const uiViewport = __spreadProps(__spreadValues({}, viewport), {
|
7403
|
-
height: viewport.height || "auto",
|
7404
|
-
zoom: zoomConfig.zoom
|
7405
|
-
});
|
7406
|
-
const newUi = {
|
7407
|
-
viewports: __spreadProps(__spreadValues({}, viewports), { current: uiViewport }),
|
7408
|
-
itemSelector: null
|
7409
|
-
};
|
7410
|
-
setUi(newUi);
|
7411
|
-
if (ZOOM_ON_CHANGE) {
|
7412
|
-
resetAutoZoom(__spreadProps(__spreadValues({}, viewports), { current: uiViewport }));
|
7413
|
-
}
|
7414
|
-
},
|
7415
|
-
onZoom: (zoom) => {
|
7416
|
-
setShowTransition(true);
|
7417
|
-
setZoomConfig(__spreadProps(__spreadValues({}, zoomConfig), { zoom }));
|
7418
|
-
}
|
7419
|
-
}
|
7420
|
-
) }),
|
7421
|
-
/* @__PURE__ */ jsxs17("div", { className: getClassName25("inner"), ref: frameRef, children: [
|
7422
|
-
/* @__PURE__ */ jsx36(
|
7423
|
-
"div",
|
7424
|
-
{
|
7425
|
-
className: getClassName25("root"),
|
7426
|
-
style: {
|
7427
|
-
width: iframe.enabled ? viewports.current.width : "100%",
|
7428
|
-
height: zoomConfig.rootHeight,
|
7429
|
-
transform: iframe.enabled ? `scale(${zoomConfig.zoom})` : void 0,
|
7430
|
-
transition: showTransition ? "width 150ms ease-out, height 150ms ease-out, transform 150ms ease-out" : "",
|
7431
|
-
overflow: iframe.enabled ? void 0 : "auto"
|
7432
|
-
},
|
7433
|
-
suppressHydrationWarning: true,
|
7434
|
-
id: "puck-canvas-root",
|
7435
|
-
onTransitionEnd: () => {
|
7436
|
-
window.dispatchEvent(
|
7437
|
-
new CustomEvent("viewportchange", {
|
7438
|
-
bubbles: true,
|
7439
|
-
cancelable: false
|
7440
|
-
})
|
7441
|
-
);
|
7442
|
-
},
|
7443
|
-
children: /* @__PURE__ */ jsx36(CustomPreview, { children: /* @__PURE__ */ jsx36(Preview2, {}) })
|
7444
|
-
}
|
7445
|
-
),
|
7446
|
-
/* @__PURE__ */ jsx36("div", { className: getClassName25("loader"), children: /* @__PURE__ */ jsx36(Loader, { size: 24 }) })
|
7447
|
-
] })
|
7448
|
-
]
|
7449
|
-
}
|
7450
|
-
);
|
7451
|
-
};
|
7452
|
-
|
7453
|
-
// lib/use-loaded-overrides.ts
|
7454
|
-
init_react_import();
|
7455
|
-
import { useMemo as useMemo19 } from "react";
|
7456
|
-
|
7457
|
-
// lib/load-overrides.ts
|
7458
|
-
init_react_import();
|
7459
|
-
var loadOverrides = ({
|
7460
|
-
overrides,
|
7461
|
-
plugins
|
7462
|
-
}) => {
|
7463
|
-
const collected = __spreadValues({}, overrides);
|
7464
|
-
plugins == null ? void 0 : plugins.forEach((plugin) => {
|
7465
|
-
Object.keys(plugin.overrides).forEach((_overridesType) => {
|
7466
|
-
const overridesType = _overridesType;
|
7467
|
-
if (overridesType === "fieldTypes") {
|
7468
|
-
const fieldTypes = plugin.overrides.fieldTypes;
|
7469
|
-
Object.keys(fieldTypes).forEach((fieldType) => {
|
7470
|
-
collected.fieldTypes = collected.fieldTypes || {};
|
7471
|
-
const childNode2 = collected.fieldTypes[fieldType];
|
7472
|
-
const Comp2 = (props) => fieldTypes[fieldType](__spreadProps(__spreadValues({}, props), {
|
7473
|
-
children: childNode2 ? childNode2(props) : props.children
|
7474
|
-
}));
|
7475
|
-
collected.fieldTypes[fieldType] = Comp2;
|
7476
|
-
});
|
7477
|
-
return;
|
7478
|
-
}
|
7479
|
-
const childNode = collected[overridesType];
|
7480
|
-
const Comp = (props) => plugin.overrides[overridesType](__spreadProps(__spreadValues({}, props), {
|
7481
|
-
children: childNode ? childNode(props) : props.children
|
7482
|
-
}));
|
7483
|
-
collected[overridesType] = Comp;
|
7484
|
-
});
|
7485
|
-
});
|
7486
|
-
return collected;
|
7487
|
-
};
|
7488
|
-
|
7489
|
-
// lib/use-loaded-overrides.ts
|
7490
|
-
var useLoadedOverrides = ({
|
7491
|
-
overrides,
|
7492
|
-
plugins
|
7493
|
-
}) => {
|
7494
|
-
return useMemo19(() => {
|
7495
|
-
return loadOverrides({ overrides, plugins });
|
7496
|
-
}, [plugins, overrides]);
|
7497
|
-
};
|
7498
|
-
|
7499
|
-
// components/DefaultOverride/index.tsx
|
7500
|
-
init_react_import();
|
7501
|
-
import { Fragment as Fragment12, jsx as jsx37 } from "react/jsx-runtime";
|
7502
|
-
var DefaultOverride = ({ children }) => /* @__PURE__ */ jsx37(Fragment12, { children });
|
7503
|
-
|
7504
|
-
// lib/use-inject-css.ts
|
7505
|
-
init_react_import();
|
7506
|
-
import { useEffect as useEffect23, useState as useState20 } from "react";
|
7507
|
-
var styles = ``;
|
7508
|
-
var useInjectStyleSheet = (initialStyles, iframeEnabled) => {
|
7509
|
-
const [el, setEl] = useState20();
|
7510
|
-
useEffect23(() => {
|
7511
|
-
setEl(document.createElement("style"));
|
7512
|
-
}, []);
|
7513
|
-
useEffect23(() => {
|
7514
|
-
var _a;
|
7515
|
-
if (!el || typeof window === "undefined") {
|
7516
|
-
return;
|
7517
|
-
}
|
7518
|
-
el.innerHTML = initialStyles;
|
7519
|
-
if (iframeEnabled) {
|
7520
|
-
const frame = getFrame();
|
7521
|
-
(_a = frame == null ? void 0 : frame.head) == null ? void 0 : _a.appendChild(el);
|
7522
|
-
}
|
7523
|
-
document.head.appendChild(el);
|
7524
|
-
}, [iframeEnabled, el]);
|
7525
|
-
return el;
|
7526
|
-
};
|
7527
|
-
var useInjectGlobalCss = (iframeEnabled) => {
|
7528
|
-
return useInjectStyleSheet(styles, iframeEnabled);
|
7529
|
-
};
|
7530
|
-
|
7531
|
-
// lib/use-preview-mode-hotkeys.ts
|
7532
|
-
init_react_import();
|
7533
|
-
import { useCallback as useCallback16 } from "react";
|
7534
|
-
var usePreviewModeHotkeys = () => {
|
7535
|
-
const appStore = useAppStoreApi();
|
7536
|
-
const toggleInteractive = useCallback16(() => {
|
7537
|
-
const dispatch = appStore.getState().dispatch;
|
7538
|
-
dispatch({
|
7539
|
-
type: "setUi",
|
7540
|
-
ui: (ui) => ({
|
7541
|
-
previewMode: ui.previewMode === "edit" ? "interactive" : "edit"
|
7542
|
-
})
|
7543
|
-
});
|
7544
|
-
}, [appStore]);
|
7545
|
-
useHotkey({ meta: true, i: true }, toggleInteractive);
|
7546
|
-
useHotkey({ ctrl: true, i: true }, toggleInteractive);
|
7547
|
-
};
|
7548
|
-
|
7549
|
-
// lib/use-puck.ts
|
7550
|
-
init_react_import();
|
7551
|
-
import { createContext as createContext6, useContext as useContext11, useEffect as useEffect24, useState as useState21 } from "react";
|
7552
|
-
import { createStore as createStore4, useStore as useStore3 } from "zustand";
|
7553
|
-
var generateUsePuck = (store) => {
|
7554
|
-
const history = {
|
7555
|
-
back: store.history.back,
|
7556
|
-
forward: store.history.forward,
|
7557
|
-
setHistories: store.history.setHistories,
|
7558
|
-
setHistoryIndex: store.history.setHistoryIndex,
|
7559
|
-
hasPast: store.history.hasPast(),
|
7560
|
-
hasFuture: store.history.hasFuture(),
|
7561
|
-
histories: store.history.histories,
|
7562
|
-
index: store.history.index
|
7563
|
-
};
|
7564
|
-
const storeData = {
|
7565
|
-
appState: makeStatePublic(store.state),
|
7566
|
-
config: store.config,
|
7567
|
-
dispatch: store.dispatch,
|
7568
|
-
getPermissions: store.permissions.getPermissions,
|
7569
|
-
refreshPermissions: store.permissions.refreshPermissions,
|
7570
|
-
history,
|
7571
|
-
selectedItem: store.selectedItem || null,
|
7572
|
-
getItemBySelector: (selector) => getItem(selector, store.state),
|
7573
|
-
getItemById: (id) => store.state.indexes.nodes[id].data,
|
7574
|
-
getSelectorForId: (id) => {
|
7575
|
-
const node = store.state.indexes.nodes[id];
|
7576
|
-
if (!node) return;
|
7577
|
-
const zoneCompound = `${node.parentId}:${node.zone}`;
|
7578
|
-
const index = store.state.indexes.zones[zoneCompound].contentIds.indexOf(id);
|
7579
|
-
return { zone: zoneCompound, index };
|
7759
|
+
const getFrameDimensions = useCallback17(() => {
|
7760
|
+
if (frameRef.current) {
|
7761
|
+
const frame = frameRef.current;
|
7762
|
+
const box = getBox(frame);
|
7763
|
+
return { width: box.contentBox.width, height: box.contentBox.height };
|
7580
7764
|
}
|
7581
|
-
|
7582
|
-
|
7583
|
-
|
7584
|
-
|
7585
|
-
|
7586
|
-
|
7587
|
-
|
7588
|
-
|
7589
|
-
|
7590
|
-
|
7591
|
-
|
7592
|
-
|
7593
|
-
|
7594
|
-
|
7595
|
-
|
7596
|
-
};
|
7597
|
-
};
|
7598
|
-
var useRegisterUsePuckStore = (appStore) => {
|
7599
|
-
const [usePuckStore] = useState21(
|
7600
|
-
() => createStore4(
|
7601
|
-
() => generateUsePuck(convertToPickedStore(appStore.getState()))
|
7602
|
-
)
|
7765
|
+
return { width: 0, height: 0 };
|
7766
|
+
}, [frameRef]);
|
7767
|
+
const resetAutoZoom = useCallback17(
|
7768
|
+
(newViewports = viewports) => {
|
7769
|
+
if (frameRef.current) {
|
7770
|
+
setZoomConfig(
|
7771
|
+
getZoomConfig(
|
7772
|
+
newViewports == null ? void 0 : newViewports.current,
|
7773
|
+
frameRef.current,
|
7774
|
+
zoomConfig.zoom
|
7775
|
+
)
|
7776
|
+
);
|
7777
|
+
}
|
7778
|
+
},
|
7779
|
+
[frameRef, zoomConfig, viewports]
|
7603
7780
|
);
|
7604
7781
|
useEffect24(() => {
|
7605
|
-
|
7606
|
-
|
7607
|
-
|
7608
|
-
|
7609
|
-
|
7610
|
-
)
|
7611
|
-
|
7612
|
-
|
7613
|
-
};
|
7614
|
-
function createUsePuck() {
|
7615
|
-
return function usePuck2(selector) {
|
7616
|
-
const usePuckApi = useContext11(UsePuckStoreContext);
|
7617
|
-
if (!usePuckApi) {
|
7618
|
-
throw new Error("usePuck must be used inside <Puck>.");
|
7782
|
+
setShowTransition(false);
|
7783
|
+
resetAutoZoom(viewports);
|
7784
|
+
}, [frameRef, leftSideBarVisible, rightSideBarVisible]);
|
7785
|
+
useEffect24(() => {
|
7786
|
+
const { height: frameHeight } = getFrameDimensions();
|
7787
|
+
if (viewports.current.height === "auto") {
|
7788
|
+
setZoomConfig(__spreadProps(__spreadValues({}, zoomConfig), {
|
7789
|
+
rootHeight: frameHeight / zoomConfig.zoom
|
7790
|
+
}));
|
7619
7791
|
}
|
7620
|
-
|
7621
|
-
usePuckApi,
|
7622
|
-
selector != null ? selector : (s) => s
|
7623
|
-
);
|
7624
|
-
return result;
|
7625
|
-
};
|
7626
|
-
}
|
7627
|
-
function usePuck() {
|
7792
|
+
}, [zoomConfig.zoom]);
|
7628
7793
|
useEffect24(() => {
|
7629
|
-
|
7630
|
-
|
7631
|
-
|
7794
|
+
if (ZOOM_ON_CHANGE) {
|
7795
|
+
setShowTransition(true);
|
7796
|
+
resetAutoZoom(viewports);
|
7797
|
+
}
|
7798
|
+
}, [viewports.current.width]);
|
7799
|
+
useEffect24(() => {
|
7800
|
+
const cb = () => {
|
7801
|
+
setShowTransition(false);
|
7802
|
+
resetAutoZoom();
|
7803
|
+
};
|
7804
|
+
window.addEventListener("resize", cb);
|
7805
|
+
return () => {
|
7806
|
+
window.removeEventListener("resize", cb);
|
7807
|
+
};
|
7632
7808
|
}, []);
|
7633
|
-
|
7634
|
-
|
7635
|
-
|
7636
|
-
|
7637
|
-
|
7638
|
-
|
7639
|
-
|
7640
|
-
return usePuckApi.getState;
|
7641
|
-
}
|
7642
|
-
|
7643
|
-
// components/Puck/index.tsx
|
7644
|
-
import fdeq from "fast-deep-equal";
|
7645
|
-
|
7646
|
-
// components/Puck/components/Header/index.tsx
|
7647
|
-
init_react_import();
|
7648
|
-
import { memo as memo3, useCallback as useCallback17, useMemo as useMemo20, useState as useState22 } from "react";
|
7649
|
-
|
7650
|
-
// components/MenuBar/index.tsx
|
7651
|
-
init_react_import();
|
7652
|
-
|
7653
|
-
// css-module:/home/runner/work/puck/puck/packages/core/components/MenuBar/styles.module.css#css-module
|
7654
|
-
init_react_import();
|
7655
|
-
var styles_module_default21 = { "MenuBar": "_MenuBar_8pf8c_1", "MenuBar--menuOpen": "_MenuBar--menuOpen_8pf8c_14", "MenuBar-inner": "_MenuBar-inner_8pf8c_29", "MenuBar-history": "_MenuBar-history_8pf8c_45" };
|
7656
|
-
|
7657
|
-
// components/MenuBar/index.tsx
|
7658
|
-
import { Fragment as Fragment13, jsx as jsx38, jsxs as jsxs18 } from "react/jsx-runtime";
|
7659
|
-
var getClassName26 = get_class_name_factory_default("MenuBar", styles_module_default21);
|
7660
|
-
function MenuBar({
|
7661
|
-
menuOpen = false,
|
7662
|
-
renderHeaderActions,
|
7663
|
-
setMenuOpen
|
7664
|
-
}) {
|
7665
|
-
const back = useAppStore((s) => s.history.back);
|
7666
|
-
const forward = useAppStore((s) => s.history.forward);
|
7667
|
-
const hasFuture = useAppStore((s) => s.history.hasFuture());
|
7668
|
-
const hasPast = useAppStore((s) => s.history.hasPast());
|
7669
|
-
return /* @__PURE__ */ jsx38(
|
7809
|
+
const [showLoader, setShowLoader] = useState22(false);
|
7810
|
+
useEffect24(() => {
|
7811
|
+
setTimeout(() => {
|
7812
|
+
setShowLoader(true);
|
7813
|
+
}, 500);
|
7814
|
+
}, []);
|
7815
|
+
return /* @__PURE__ */ jsxs19(
|
7670
7816
|
"div",
|
7671
7817
|
{
|
7672
|
-
className:
|
7673
|
-
|
7674
|
-
|
7675
|
-
|
7676
|
-
|
7677
|
-
|
7678
|
-
}
|
7679
|
-
|
7680
|
-
|
7681
|
-
|
7682
|
-
|
7683
|
-
|
7684
|
-
|
7685
|
-
|
7686
|
-
|
7687
|
-
|
7688
|
-
|
7689
|
-
|
7818
|
+
className: getClassName27({
|
7819
|
+
ready: status === "READY" || !iframe.enabled || !iframe.waitForStyles,
|
7820
|
+
showLoader
|
7821
|
+
}),
|
7822
|
+
onClick: () => dispatch({
|
7823
|
+
type: "setUi",
|
7824
|
+
ui: { itemSelector: null },
|
7825
|
+
recordHistory: true
|
7826
|
+
}),
|
7827
|
+
children: [
|
7828
|
+
viewports.controlsVisible && iframe.enabled && /* @__PURE__ */ jsx39("div", { className: getClassName27("controls"), children: /* @__PURE__ */ jsx39(
|
7829
|
+
ViewportControls,
|
7830
|
+
{
|
7831
|
+
autoZoom: zoomConfig.autoZoom,
|
7832
|
+
zoom: zoomConfig.zoom,
|
7833
|
+
onViewportChange: (viewport) => {
|
7834
|
+
setShowTransition(true);
|
7835
|
+
const uiViewport = __spreadProps(__spreadValues({}, viewport), {
|
7836
|
+
height: viewport.height || "auto",
|
7837
|
+
zoom: zoomConfig.zoom
|
7838
|
+
});
|
7839
|
+
const newUi = {
|
7840
|
+
viewports: __spreadProps(__spreadValues({}, viewports), { current: uiViewport }),
|
7841
|
+
itemSelector: null
|
7842
|
+
};
|
7843
|
+
setUi(newUi);
|
7844
|
+
if (ZOOM_ON_CHANGE) {
|
7845
|
+
resetAutoZoom(__spreadProps(__spreadValues({}, viewports), { current: uiViewport }));
|
7846
|
+
}
|
7847
|
+
},
|
7848
|
+
onZoom: (zoom) => {
|
7849
|
+
setShowTransition(true);
|
7850
|
+
setZoomConfig(__spreadProps(__spreadValues({}, zoomConfig), { zoom }));
|
7851
|
+
}
|
7852
|
+
}
|
7853
|
+
) }),
|
7854
|
+
/* @__PURE__ */ jsxs19("div", { className: getClassName27("inner"), ref: frameRef, children: [
|
7855
|
+
/* @__PURE__ */ jsx39(
|
7856
|
+
"div",
|
7857
|
+
{
|
7858
|
+
className: getClassName27("root"),
|
7859
|
+
style: {
|
7860
|
+
width: iframe.enabled ? viewports.current.width : "100%",
|
7861
|
+
height: zoomConfig.rootHeight,
|
7862
|
+
transform: iframe.enabled ? `scale(${zoomConfig.zoom})` : void 0,
|
7863
|
+
transition: showTransition ? "width 150ms ease-out, height 150ms ease-out, transform 150ms ease-out" : "",
|
7864
|
+
overflow: iframe.enabled ? void 0 : "auto"
|
7865
|
+
},
|
7866
|
+
suppressHydrationWarning: true,
|
7867
|
+
id: "puck-canvas-root",
|
7868
|
+
onTransitionEnd: () => {
|
7869
|
+
window.dispatchEvent(
|
7870
|
+
new CustomEvent("viewportchange", {
|
7871
|
+
bubbles: true,
|
7872
|
+
cancelable: false
|
7873
|
+
})
|
7874
|
+
);
|
7875
|
+
},
|
7876
|
+
children: /* @__PURE__ */ jsx39(CustomPreview, { children: /* @__PURE__ */ jsx39(Preview2, {}) })
|
7877
|
+
}
|
7878
|
+
),
|
7879
|
+
/* @__PURE__ */ jsx39("div", { className: getClassName27("loader"), children: /* @__PURE__ */ jsx39(Loader, { size: 24 }) })
|
7880
|
+
] })
|
7881
|
+
]
|
7690
7882
|
}
|
7691
7883
|
);
|
7692
|
-
}
|
7884
|
+
};
|
7693
7885
|
|
7694
|
-
//
|
7886
|
+
// components/Puck/components/Nav/index.tsx
|
7695
7887
|
init_react_import();
|
7696
|
-
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" };
|
7697
7888
|
|
7698
|
-
// components/Puck/components/
|
7699
|
-
|
7700
|
-
var
|
7701
|
-
|
7702
|
-
|
7703
|
-
|
7704
|
-
|
7705
|
-
|
7706
|
-
|
7707
|
-
|
7708
|
-
|
7709
|
-
|
7710
|
-
|
7711
|
-
|
7712
|
-
|
7713
|
-
|
7714
|
-
|
7715
|
-
|
7716
|
-
|
7717
|
-
|
7718
|
-
|
7719
|
-
|
7720
|
-
|
7721
|
-
|
7722
|
-
|
7723
|
-
|
7724
|
-
|
7725
|
-
|
7726
|
-
|
7727
|
-
|
7728
|
-
|
7729
|
-
|
7730
|
-
|
7731
|
-
|
7732
|
-
|
7733
|
-
|
7734
|
-
|
7735
|
-
|
7736
|
-
|
7737
|
-
|
7738
|
-
|
7739
|
-
|
7740
|
-
|
7741
|
-
|
7742
|
-
|
7889
|
+
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Nav/styles.module.css#css-module
|
7890
|
+
init_react_import();
|
7891
|
+
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" };
|
7892
|
+
|
7893
|
+
// components/Puck/components/Nav/index.tsx
|
7894
|
+
import { jsx as jsx40, jsxs as jsxs20 } from "react/jsx-runtime";
|
7895
|
+
var getClassName28 = get_class_name_factory_default("Nav", styles_module_default23);
|
7896
|
+
var getClassNameSection = get_class_name_factory_default("NavSection", styles_module_default23);
|
7897
|
+
var getClassNameItem3 = get_class_name_factory_default("NavItem", styles_module_default23);
|
7898
|
+
var MenuItem = ({
|
7899
|
+
label,
|
7900
|
+
icon,
|
7901
|
+
items,
|
7902
|
+
onClick,
|
7903
|
+
isActive
|
7904
|
+
}) => {
|
7905
|
+
const showChildren = isActive;
|
7906
|
+
return /* @__PURE__ */ jsxs20("li", { className: getClassNameItem3({ active: isActive }), children: [
|
7907
|
+
onClick && /* @__PURE__ */ jsxs20("div", { className: getClassNameItem3("link"), onClick, children: [
|
7908
|
+
icon && /* @__PURE__ */ jsx40("span", { className: getClassNameItem3("linkIcon"), children: icon }),
|
7909
|
+
/* @__PURE__ */ jsx40("span", { className: getClassNameItem3("linkLabel"), children: label })
|
7910
|
+
] }),
|
7911
|
+
items && showChildren && /* @__PURE__ */ jsx40("ul", { className: getClassNameItem3("list"), children: Object.entries(items).map(([key, item]) => /* @__PURE__ */ jsx40(MenuItem, __spreadValues({}, item), key)) })
|
7912
|
+
] });
|
7913
|
+
};
|
7914
|
+
var NavSection = ({ title, items }) => {
|
7915
|
+
return /* @__PURE__ */ jsxs20("li", { className: getClassNameSection(), children: [
|
7916
|
+
title && /* @__PURE__ */ jsx40("div", { className: getClassNameSection("title"), children: title }),
|
7917
|
+
/* @__PURE__ */ jsx40("ul", { className: getClassNameSection("list"), children: Object.entries(items).map(([key, item]) => /* @__PURE__ */ jsx40(MenuItem, __spreadValues({}, item), key)) })
|
7918
|
+
] });
|
7919
|
+
};
|
7920
|
+
var Nav = ({
|
7921
|
+
navigation,
|
7922
|
+
slim
|
7923
|
+
}) => {
|
7924
|
+
return /* @__PURE__ */ jsx40("nav", { className: getClassName28({ slim }), children: /* @__PURE__ */ jsx40("ul", { className: getClassName28("list"), children: Object.entries(navigation).map(([key, section]) => {
|
7925
|
+
return /* @__PURE__ */ jsx40(NavSection, { title: section.title, items: section.items }, key);
|
7926
|
+
}) }) });
|
7927
|
+
};
|
7928
|
+
|
7929
|
+
// components/Puck/components/Layout/index.tsx
|
7930
|
+
import { jsx as jsx41, jsxs as jsxs21 } from "react/jsx-runtime";
|
7931
|
+
var getClassName29 = get_class_name_factory_default("Puck", styles_module_default17);
|
7932
|
+
var getLayoutClassName = get_class_name_factory_default("PuckLayout", styles_module_default17);
|
7933
|
+
var FieldSideBar = () => {
|
7934
|
+
const title = useAppStore(
|
7935
|
+
(s) => {
|
7936
|
+
var _a, _b;
|
7937
|
+
return s.selectedItem ? (_b = (_a = s.config.components[s.selectedItem.type]) == null ? void 0 : _a["label"]) != null ? _b : s.selectedItem.type.toString() : "Page";
|
7938
|
+
}
|
7743
7939
|
);
|
7744
|
-
|
7745
|
-
|
7940
|
+
return /* @__PURE__ */ jsx41(SidebarSection, { noPadding: true, noBorderTop: true, showBreadcrumbs: true, title, children: /* @__PURE__ */ jsx41(Fields, {}) });
|
7941
|
+
};
|
7942
|
+
var Layout = ({ children }) => {
|
7943
|
+
const {
|
7944
|
+
iframe: _iframe,
|
7945
|
+
dnd,
|
7946
|
+
initialHistory: _initialHistory,
|
7947
|
+
plugins
|
7948
|
+
} = usePropsContext();
|
7949
|
+
const iframe = useMemo21(
|
7950
|
+
() => __spreadValues({
|
7951
|
+
enabled: true,
|
7952
|
+
waitForStyles: true
|
7953
|
+
}, _iframe),
|
7954
|
+
[_iframe]
|
7746
7955
|
);
|
7747
|
-
|
7748
|
-
const rootTitle = useAppStore((s) => {
|
7749
|
-
var _a, _b;
|
7750
|
-
const rootData = (_a = s.state.indexes.nodes["root"]) == null ? void 0 : _a.data;
|
7751
|
-
return (_b = rootData.props.title) != null ? _b : "";
|
7752
|
-
});
|
7956
|
+
useInjectGlobalCss(iframe.enabled);
|
7753
7957
|
const leftSideBarVisible = useAppStore((s) => s.state.ui.leftSideBarVisible);
|
7754
7958
|
const rightSideBarVisible = useAppStore(
|
7755
7959
|
(s) => s.state.ui.rightSideBarVisible
|
7756
7960
|
);
|
7757
|
-
const
|
7758
|
-
|
7759
|
-
|
7760
|
-
const sideBarVisible = sidebar === "left" ? leftSideBarVisible : rightSideBarVisible;
|
7761
|
-
const oppositeSideBar = sidebar === "left" ? "rightSideBarVisible" : "leftSideBarVisible";
|
7961
|
+
const dispatch = useAppStore((s) => s.dispatch);
|
7962
|
+
useEffect25(() => {
|
7963
|
+
if (!window.matchMedia("(min-width: 638px)").matches) {
|
7762
7964
|
dispatch({
|
7763
7965
|
type: "setUi",
|
7764
|
-
ui:
|
7765
|
-
|
7766
|
-
|
7966
|
+
ui: {
|
7967
|
+
leftSideBarVisible: false,
|
7968
|
+
rightSideBarVisible: false
|
7969
|
+
}
|
7767
7970
|
});
|
7768
|
-
}
|
7769
|
-
|
7971
|
+
}
|
7972
|
+
const handleResize = () => {
|
7973
|
+
if (!window.matchMedia("(min-width: 638px)").matches) {
|
7974
|
+
dispatch({
|
7975
|
+
type: "setUi",
|
7976
|
+
ui: (ui) => __spreadValues(__spreadValues({}, ui), ui.rightSideBarVisible ? { leftSideBarVisible: false } : {})
|
7977
|
+
});
|
7978
|
+
}
|
7979
|
+
};
|
7980
|
+
window.addEventListener("resize", handleResize);
|
7981
|
+
return () => {
|
7982
|
+
window.removeEventListener("resize", handleResize);
|
7983
|
+
};
|
7984
|
+
}, []);
|
7985
|
+
const overrides = useAppStore((s) => s.overrides);
|
7986
|
+
const CustomPuck = useMemo21(
|
7987
|
+
() => overrides.puck || DefaultOverride,
|
7988
|
+
[overrides]
|
7770
7989
|
);
|
7771
|
-
|
7772
|
-
|
7773
|
-
|
7774
|
-
|
7775
|
-
|
7776
|
-
|
7990
|
+
const [mounted, setMounted] = useState23(false);
|
7991
|
+
useEffect25(() => {
|
7992
|
+
setMounted(true);
|
7993
|
+
}, []);
|
7994
|
+
const ready = useAppStore((s) => s.status === "READY");
|
7995
|
+
useMonitorHotkeys();
|
7996
|
+
useEffect25(() => {
|
7997
|
+
if (ready && iframe.enabled) {
|
7998
|
+
const frameDoc = getFrame();
|
7999
|
+
if (frameDoc) {
|
8000
|
+
return monitorHotkeys(frameDoc);
|
8001
|
+
}
|
8002
|
+
}
|
8003
|
+
}, [ready, iframe.enabled]);
|
8004
|
+
usePreviewModeHotkeys();
|
8005
|
+
const [view, setView] = useState23("blocks");
|
8006
|
+
const pluginItems = useMemo21(() => {
|
8007
|
+
const details = {};
|
8008
|
+
plugins == null ? void 0 : plugins.forEach((plugin) => {
|
8009
|
+
var _a, _b;
|
8010
|
+
if (plugin.name && plugin.render) {
|
8011
|
+
details[plugin.name] = {
|
8012
|
+
label: (_a = plugin.label) != null ? _a : plugin.name,
|
8013
|
+
icon: (_b = plugin.icon) != null ? _b : /* @__PURE__ */ jsx41(ToyBrick, {}),
|
7777
8014
|
onClick: () => {
|
7778
|
-
|
7779
|
-
onPublish && onPublish(data);
|
8015
|
+
setView(plugin.name);
|
7780
8016
|
},
|
7781
|
-
|
7782
|
-
|
7783
|
-
}
|
7784
|
-
|
7785
|
-
|
7786
|
-
|
7787
|
-
|
7788
|
-
|
7789
|
-
|
7790
|
-
|
7791
|
-
|
7792
|
-
|
7793
|
-
|
7794
|
-
|
7795
|
-
|
7796
|
-
|
7797
|
-
|
7798
|
-
|
7799
|
-
|
7800
|
-
|
7801
|
-
|
7802
|
-
|
7803
|
-
|
7804
|
-
|
7805
|
-
|
7806
|
-
|
7807
|
-
|
7808
|
-
|
7809
|
-
|
7810
|
-
|
7811
|
-
|
7812
|
-
|
7813
|
-
|
7814
|
-
|
7815
|
-
|
7816
|
-
|
7817
|
-
|
7818
|
-
|
7819
|
-
/* @__PURE__ */ jsxs19("div", { className: getClassName27("tools"), children: [
|
7820
|
-
/* @__PURE__ */ jsx39("div", { className: getClassName27("menuButton"), children: /* @__PURE__ */ jsx39(
|
7821
|
-
IconButton,
|
7822
|
-
{
|
7823
|
-
onClick: () => {
|
7824
|
-
return setMenuOpen(!menuOpen);
|
7825
|
-
},
|
7826
|
-
title: "Toggle menu bar",
|
7827
|
-
children: menuOpen ? /* @__PURE__ */ jsx39(ChevronUp, { focusable: "false" }) : /* @__PURE__ */ jsx39(ChevronDown, { focusable: "false" })
|
7828
|
-
}
|
7829
|
-
) }),
|
7830
|
-
/* @__PURE__ */ jsx39(
|
7831
|
-
MenuBar,
|
7832
|
-
{
|
7833
|
-
dispatch,
|
7834
|
-
onPublish,
|
7835
|
-
menuOpen,
|
7836
|
-
renderHeaderActions: () => /* @__PURE__ */ jsx39(CustomHeaderActions, { children: /* @__PURE__ */ jsx39(
|
7837
|
-
Button,
|
7838
|
-
{
|
8017
|
+
isActive: view === plugin.name,
|
8018
|
+
render: plugin.render
|
8019
|
+
};
|
8020
|
+
}
|
8021
|
+
});
|
8022
|
+
return details;
|
8023
|
+
}, [plugins, view]);
|
8024
|
+
const PluginRender = useMemo21(() => {
|
8025
|
+
var _a;
|
8026
|
+
if (view === "blocks") {
|
8027
|
+
return Components;
|
8028
|
+
} else if (view === "outline") {
|
8029
|
+
return Outline;
|
8030
|
+
} else {
|
8031
|
+
return (_a = pluginItems[view]) == null ? void 0 : _a.render;
|
8032
|
+
}
|
8033
|
+
}, [view]);
|
8034
|
+
return /* @__PURE__ */ jsxs21("div", { className: `Puck ${getClassName29()}`, children: [
|
8035
|
+
/* @__PURE__ */ jsx41(DragDropContext, { disableAutoScroll: dnd == null ? void 0 : dnd.disableAutoScroll, children: /* @__PURE__ */ jsx41(CustomPuck, { children: children || /* @__PURE__ */ jsx41(
|
8036
|
+
"div",
|
8037
|
+
{
|
8038
|
+
className: getLayoutClassName({
|
8039
|
+
leftSideBarVisible,
|
8040
|
+
mounted,
|
8041
|
+
rightSideBarVisible
|
8042
|
+
}),
|
8043
|
+
children: /* @__PURE__ */ jsxs21("div", { className: getLayoutClassName("inner"), children: [
|
8044
|
+
/* @__PURE__ */ jsx41(Header, {}),
|
8045
|
+
/* @__PURE__ */ jsx41("div", { className: getLayoutClassName("nav"), children: /* @__PURE__ */ jsx41(
|
8046
|
+
Nav,
|
8047
|
+
{
|
8048
|
+
slim: true,
|
8049
|
+
navigation: {
|
8050
|
+
main: {
|
8051
|
+
items: __spreadValues({
|
8052
|
+
build: {
|
8053
|
+
label: "Blocks",
|
8054
|
+
icon: /* @__PURE__ */ jsx41(Hammer, {}),
|
7839
8055
|
onClick: () => {
|
7840
|
-
|
7841
|
-
onPublish && onPublish(data);
|
8056
|
+
setView("blocks");
|
7842
8057
|
},
|
7843
|
-
|
7844
|
-
|
8058
|
+
isActive: view === "blocks"
|
8059
|
+
},
|
8060
|
+
outline: {
|
8061
|
+
label: "Outline",
|
8062
|
+
icon: /* @__PURE__ */ jsx41(Layers, {}),
|
8063
|
+
onClick: () => {
|
8064
|
+
setView("outline");
|
8065
|
+
},
|
8066
|
+
isActive: view === "outline"
|
7845
8067
|
}
|
7846
|
-
|
7847
|
-
setMenuOpen
|
8068
|
+
}, pluginItems)
|
7848
8069
|
}
|
7849
|
-
|
7850
|
-
|
7851
|
-
|
7852
|
-
|
7853
|
-
|
7854
|
-
|
7855
|
-
|
8070
|
+
}
|
8071
|
+
}
|
8072
|
+
) }),
|
8073
|
+
/* @__PURE__ */ jsx41("div", { className: getLayoutClassName("leftSideBar"), children: leftSideBarVisible && /* @__PURE__ */ jsx41(PluginRender, {}) }),
|
8074
|
+
/* @__PURE__ */ jsx41(Canvas, {}),
|
8075
|
+
/* @__PURE__ */ jsx41("div", { className: getLayoutClassName("rightSideBar"), children: /* @__PURE__ */ jsx41(FieldSideBar, {}) })
|
8076
|
+
] })
|
8077
|
+
}
|
8078
|
+
) }) }),
|
8079
|
+
/* @__PURE__ */ jsx41("div", { id: "puck-portal-root", className: getClassName29("portal") })
|
8080
|
+
] });
|
7856
8081
|
};
|
7857
|
-
var Header = memo3(HeaderInner);
|
7858
8082
|
|
7859
8083
|
// components/Puck/index.tsx
|
7860
|
-
import { jsx as
|
7861
|
-
var getClassName28 = get_class_name_factory_default("Puck", styles_module_default14);
|
7862
|
-
var getLayoutClassName = get_class_name_factory_default("PuckLayout", styles_module_default14);
|
7863
|
-
var FieldSideBar = () => {
|
7864
|
-
const title = useAppStore(
|
7865
|
-
(s) => {
|
7866
|
-
var _a, _b;
|
7867
|
-
return s.selectedItem ? (_b = (_a = s.config.components[s.selectedItem.type]) == null ? void 0 : _a["label"]) != null ? _b : s.selectedItem.type.toString() : "Page";
|
7868
|
-
}
|
7869
|
-
);
|
7870
|
-
return /* @__PURE__ */ jsx40(SidebarSection, { noPadding: true, noBorderTop: true, showBreadcrumbs: true, title, children: /* @__PURE__ */ jsx40(Fields, {}) });
|
7871
|
-
};
|
8084
|
+
import { jsx as jsx42 } from "react/jsx-runtime";
|
7872
8085
|
var propsContext = createContext7({});
|
7873
8086
|
function PropsProvider(props) {
|
7874
|
-
return /* @__PURE__ */
|
8087
|
+
return /* @__PURE__ */ jsx42(propsContext.Provider, { value: props, children: props.children });
|
7875
8088
|
}
|
7876
8089
|
var usePropsContext = () => useContext12(propsContext);
|
7877
8090
|
function PuckProvider({ children }) {
|
@@ -7889,14 +8102,14 @@ function PuckProvider({ children }) {
|
|
7889
8102
|
metadata,
|
7890
8103
|
onAction
|
7891
8104
|
} = usePropsContext();
|
7892
|
-
const iframe =
|
8105
|
+
const iframe = useMemo22(
|
7893
8106
|
() => __spreadValues({
|
7894
8107
|
enabled: true,
|
7895
8108
|
waitForStyles: true
|
7896
8109
|
}, _iframe),
|
7897
8110
|
[_iframe]
|
7898
8111
|
);
|
7899
|
-
const [generatedAppState] =
|
8112
|
+
const [generatedAppState] = useState24(() => {
|
7900
8113
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
7901
8114
|
const initial = __spreadValues(__spreadValues({}, defaultAppState.ui), initialUi);
|
7902
8115
|
let clientUiState = {};
|
@@ -7956,7 +8169,7 @@ function PuckProvider({ children }) {
|
|
7956
8169
|
return walkAppState(newAppState, config);
|
7957
8170
|
});
|
7958
8171
|
const { appendData = true } = _initialHistory || {};
|
7959
|
-
const [blendedHistories] =
|
8172
|
+
const [blendedHistories] = useState24(
|
7960
8173
|
[
|
7961
8174
|
...(_initialHistory == null ? void 0 : _initialHistory.histories) || [],
|
7962
8175
|
...appendData ? [{ state: generatedAppState }] : []
|
@@ -8000,15 +8213,15 @@ function PuckProvider({ children }) {
|
|
8000
8213
|
metadata
|
8001
8214
|
]
|
8002
8215
|
);
|
8003
|
-
const [appStore] =
|
8216
|
+
const [appStore] = useState24(
|
8004
8217
|
() => createAppStore(generateAppStore(initialAppState))
|
8005
8218
|
);
|
8006
|
-
|
8219
|
+
useEffect26(() => {
|
8007
8220
|
if (process.env.NODE_ENV !== "production") {
|
8008
8221
|
window.__PUCK_INTERNAL_DO_NOT_USE = { appStore };
|
8009
8222
|
}
|
8010
8223
|
}, [appStore]);
|
8011
|
-
|
8224
|
+
useEffect26(() => {
|
8012
8225
|
const state = appStore.getState().state;
|
8013
8226
|
appStore.setState(__spreadValues({}, generateAppStore(state)));
|
8014
8227
|
}, [config, plugins, loadedOverrides, viewports, iframe, onAction, metadata]);
|
@@ -8018,7 +8231,7 @@ function PuckProvider({ children }) {
|
|
8018
8231
|
initialAppState
|
8019
8232
|
});
|
8020
8233
|
const previousData = useRef8(null);
|
8021
|
-
|
8234
|
+
useEffect26(() => {
|
8022
8235
|
appStore.subscribe(
|
8023
8236
|
(s) => s.state.data,
|
8024
8237
|
(data) => {
|
@@ -8032,99 +8245,14 @@ function PuckProvider({ children }) {
|
|
8032
8245
|
}, []);
|
8033
8246
|
useRegisterPermissionsSlice(appStore, permissions);
|
8034
8247
|
const uPuckStore = useRegisterUsePuckStore(appStore);
|
8035
|
-
|
8248
|
+
useEffect26(() => {
|
8036
8249
|
const { resolveAndCommitData } = appStore.getState();
|
8037
8250
|
resolveAndCommitData();
|
8038
8251
|
}, []);
|
8039
|
-
return /* @__PURE__ */
|
8040
|
-
}
|
8041
|
-
function PuckLayout({ children }) {
|
8042
|
-
const {
|
8043
|
-
iframe: _iframe,
|
8044
|
-
dnd,
|
8045
|
-
initialHistory: _initialHistory
|
8046
|
-
} = usePropsContext();
|
8047
|
-
const iframe = useMemo21(
|
8048
|
-
() => __spreadValues({
|
8049
|
-
enabled: true,
|
8050
|
-
waitForStyles: true
|
8051
|
-
}, _iframe),
|
8052
|
-
[_iframe]
|
8053
|
-
);
|
8054
|
-
useInjectGlobalCss(iframe.enabled);
|
8055
|
-
const leftSideBarVisible = useAppStore((s) => s.state.ui.leftSideBarVisible);
|
8056
|
-
const rightSideBarVisible = useAppStore(
|
8057
|
-
(s) => s.state.ui.rightSideBarVisible
|
8058
|
-
);
|
8059
|
-
const dispatch = useAppStore((s) => s.dispatch);
|
8060
|
-
useEffect25(() => {
|
8061
|
-
if (!window.matchMedia("(min-width: 638px)").matches) {
|
8062
|
-
dispatch({
|
8063
|
-
type: "setUi",
|
8064
|
-
ui: {
|
8065
|
-
leftSideBarVisible: false,
|
8066
|
-
rightSideBarVisible: false
|
8067
|
-
}
|
8068
|
-
});
|
8069
|
-
}
|
8070
|
-
const handleResize = () => {
|
8071
|
-
if (!window.matchMedia("(min-width: 638px)").matches) {
|
8072
|
-
dispatch({
|
8073
|
-
type: "setUi",
|
8074
|
-
ui: (ui) => __spreadValues(__spreadValues({}, ui), ui.rightSideBarVisible ? { leftSideBarVisible: false } : {})
|
8075
|
-
});
|
8076
|
-
}
|
8077
|
-
};
|
8078
|
-
window.addEventListener("resize", handleResize);
|
8079
|
-
return () => {
|
8080
|
-
window.removeEventListener("resize", handleResize);
|
8081
|
-
};
|
8082
|
-
}, []);
|
8083
|
-
const overrides = useAppStore((s) => s.overrides);
|
8084
|
-
const CustomPuck = useMemo21(
|
8085
|
-
() => overrides.puck || DefaultOverride,
|
8086
|
-
[overrides]
|
8087
|
-
);
|
8088
|
-
const [mounted, setMounted] = useState23(false);
|
8089
|
-
useEffect25(() => {
|
8090
|
-
setMounted(true);
|
8091
|
-
}, []);
|
8092
|
-
const ready = useAppStore((s) => s.status === "READY");
|
8093
|
-
useMonitorHotkeys();
|
8094
|
-
useEffect25(() => {
|
8095
|
-
if (ready && iframe.enabled) {
|
8096
|
-
const frameDoc = getFrame();
|
8097
|
-
if (frameDoc) {
|
8098
|
-
return monitorHotkeys(frameDoc);
|
8099
|
-
}
|
8100
|
-
}
|
8101
|
-
}, [ready, iframe.enabled]);
|
8102
|
-
usePreviewModeHotkeys();
|
8103
|
-
return /* @__PURE__ */ jsxs20("div", { className: `Puck ${getClassName28()}`, children: [
|
8104
|
-
/* @__PURE__ */ jsx40(DragDropContext, { disableAutoScroll: dnd == null ? void 0 : dnd.disableAutoScroll, children: /* @__PURE__ */ jsx40(CustomPuck, { children: children || /* @__PURE__ */ jsx40(
|
8105
|
-
"div",
|
8106
|
-
{
|
8107
|
-
className: getLayoutClassName({
|
8108
|
-
leftSideBarVisible,
|
8109
|
-
mounted,
|
8110
|
-
rightSideBarVisible
|
8111
|
-
}),
|
8112
|
-
children: /* @__PURE__ */ jsxs20("div", { className: getLayoutClassName("inner"), children: [
|
8113
|
-
/* @__PURE__ */ jsx40(Header, {}),
|
8114
|
-
/* @__PURE__ */ jsxs20("div", { className: getLayoutClassName("leftSideBar"), children: [
|
8115
|
-
/* @__PURE__ */ jsx40(SidebarSection, { title: "Components", noBorderTop: true, children: /* @__PURE__ */ jsx40(Components, {}) }),
|
8116
|
-
/* @__PURE__ */ jsx40(SidebarSection, { title: "Outline", children: /* @__PURE__ */ jsx40(Outline, {}) })
|
8117
|
-
] }),
|
8118
|
-
/* @__PURE__ */ jsx40(Canvas, {}),
|
8119
|
-
/* @__PURE__ */ jsx40("div", { className: getLayoutClassName("rightSideBar"), children: /* @__PURE__ */ jsx40(FieldSideBar, {}) })
|
8120
|
-
] })
|
8121
|
-
}
|
8122
|
-
) }) }),
|
8123
|
-
/* @__PURE__ */ jsx40("div", { id: "puck-portal-root", className: getClassName28("portal") })
|
8124
|
-
] });
|
8252
|
+
return /* @__PURE__ */ jsx42(appStoreContext.Provider, { value: appStore, children: /* @__PURE__ */ jsx42(UsePuckStoreContext.Provider, { value: uPuckStore, children }) });
|
8125
8253
|
}
|
8126
8254
|
function Puck(props) {
|
8127
|
-
return /* @__PURE__ */
|
8255
|
+
return /* @__PURE__ */ jsx42(PropsProvider, __spreadProps(__spreadValues({}, props), { children: /* @__PURE__ */ jsx42(PuckProvider, __spreadProps(__spreadValues({}, props), { children: /* @__PURE__ */ jsx42(Layout, { children: props.children }) })) }));
|
8128
8256
|
}
|
8129
8257
|
Puck.Components = Components;
|
8130
8258
|
Puck.Fields = Fields;
|
@@ -8258,6 +8386,14 @@ lucide-react/dist/esm/icons/globe.js:
|
|
8258
8386
|
* See the LICENSE file in the root directory of this source tree.
|
8259
8387
|
*)
|
8260
8388
|
|
8389
|
+
lucide-react/dist/esm/icons/hammer.js:
|
8390
|
+
(**
|
8391
|
+
* @license lucide-react v0.468.0 - ISC
|
8392
|
+
*
|
8393
|
+
* This source code is licensed under the ISC license.
|
8394
|
+
* See the LICENSE file in the root directory of this source tree.
|
8395
|
+
*)
|
8396
|
+
|
8261
8397
|
lucide-react/dist/esm/icons/hash.js:
|
8262
8398
|
(**
|
8263
8399
|
* @license lucide-react v0.468.0 - ISC
|
@@ -8386,6 +8522,14 @@ lucide-react/dist/esm/icons/tablet.js:
|
|
8386
8522
|
* See the LICENSE file in the root directory of this source tree.
|
8387
8523
|
*)
|
8388
8524
|
|
8525
|
+
lucide-react/dist/esm/icons/toy-brick.js:
|
8526
|
+
(**
|
8527
|
+
* @license lucide-react v0.468.0 - ISC
|
8528
|
+
*
|
8529
|
+
* This source code is licensed under the ISC license.
|
8530
|
+
* See the LICENSE file in the root directory of this source tree.
|
8531
|
+
*)
|
8532
|
+
|
8389
8533
|
lucide-react/dist/esm/icons/trash.js:
|
8390
8534
|
(**
|
8391
8535
|
* @license lucide-react v0.468.0 - ISC
|