@measured/puck 0.20.0-canary.88a4251d → 0.20.0-canary.8c56aa8b
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-EMTLDPBH.mjs → chunk-5HI4IJHF.mjs} +147 -71
- package/dist/index.css +31 -15
- package/dist/index.d.mts +7 -3
- package/dist/index.d.ts +7 -3
- package/dist/index.js +192 -115
- package/dist/index.mjs +3 -1
- package/dist/no-external.css +31 -15
- package/dist/no-external.d.mts +2 -2
- package/dist/no-external.d.ts +2 -2
- package/dist/no-external.js +192 -115
- package/dist/no-external.mjs +3 -1
- package/dist/rsc.d.mts +2 -2
- package/dist/rsc.d.ts +2 -2
- package/dist/{walk-tree-BCI5tk0w.d.mts → walk-tree-mCPqBAls.d.mts} +13 -1
- package/dist/{walk-tree-BCI5tk0w.d.ts → walk-tree-mCPqBAls.d.ts} +13 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -171,6 +171,7 @@ __export(bundle_exports, {
|
|
|
171
171
|
createUsePuck: () => createUsePuck,
|
|
172
172
|
migrate: () => migrate,
|
|
173
173
|
overrideKeys: () => overrideKeys,
|
|
174
|
+
registerOverlayPortal: () => registerOverlayPortal,
|
|
174
175
|
renderContext: () => renderContext,
|
|
175
176
|
resolveAllData: () => resolveAllData,
|
|
176
177
|
transformProps: () => transformProps,
|
|
@@ -203,8 +204,9 @@ var overrideKeys = [
|
|
|
203
204
|
"headerActions",
|
|
204
205
|
"fields",
|
|
205
206
|
"fieldLabel",
|
|
206
|
-
"
|
|
207
|
-
"
|
|
207
|
+
"drawer",
|
|
208
|
+
"drawerItem",
|
|
209
|
+
"componentOverlay",
|
|
208
210
|
"outline",
|
|
209
211
|
"puck",
|
|
210
212
|
"preview"
|
|
@@ -4465,7 +4467,7 @@ var import_react25 = require("react");
|
|
|
4465
4467
|
|
|
4466
4468
|
// css-module:/home/runner/work/puck/puck/packages/core/components/DraggableComponent/styles.module.css#css-module
|
|
4467
4469
|
init_react_import();
|
|
4468
|
-
var styles_module_default11 = { "DraggableComponent": "
|
|
4470
|
+
var styles_module_default11 = { "DraggableComponent": "_DraggableComponent_1vaqy_1", "DraggableComponent-overlayWrapper": "_DraggableComponent-overlayWrapper_1vaqy_12", "DraggableComponent-overlay": "_DraggableComponent-overlay_1vaqy_12", "DraggableComponent-loadingOverlay": "_DraggableComponent-loadingOverlay_1vaqy_34", "DraggableComponent--hover": "_DraggableComponent--hover_1vaqy_50", "DraggableComponent--isSelected": "_DraggableComponent--isSelected_1vaqy_57", "DraggableComponent-actionsOverlay": "_DraggableComponent-actionsOverlay_1vaqy_71", "DraggableComponent-actions": "_DraggableComponent-actions_1vaqy_71" };
|
|
4469
4471
|
|
|
4470
4472
|
// components/DraggableComponent/index.tsx
|
|
4471
4473
|
var import_react_dom2 = require("react-dom");
|
|
@@ -4619,6 +4621,9 @@ var DefaultActionBar = ({
|
|
|
4619
4621
|
] }),
|
|
4620
4622
|
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(ActionBar.Group, { children })
|
|
4621
4623
|
] });
|
|
4624
|
+
var DefaultOverlay = ({
|
|
4625
|
+
children
|
|
4626
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_jsx_runtime20.Fragment, { children });
|
|
4622
4627
|
var DraggableComponent = ({
|
|
4623
4628
|
children,
|
|
4624
4629
|
depth,
|
|
@@ -4812,9 +4817,16 @@ var DraggableComponent = ({
|
|
|
4812
4817
|
() => overrides.actionBar || DefaultActionBar,
|
|
4813
4818
|
[overrides.actionBar]
|
|
4814
4819
|
);
|
|
4820
|
+
const CustomOverlay = (0, import_react25.useMemo)(
|
|
4821
|
+
() => overrides.componentOverlay || DefaultOverlay,
|
|
4822
|
+
[overrides.componentOverlay]
|
|
4823
|
+
);
|
|
4815
4824
|
const onClick = (0, import_react25.useCallback)(
|
|
4816
4825
|
(e) => {
|
|
4817
|
-
e.
|
|
4826
|
+
const el = e.target;
|
|
4827
|
+
if (!el.closest("[data-puck-overlay-portal]")) {
|
|
4828
|
+
e.stopPropagation();
|
|
4829
|
+
}
|
|
4818
4830
|
dispatch({
|
|
4819
4831
|
type: "setUi",
|
|
4820
4832
|
ui: {
|
|
@@ -5054,7 +5066,16 @@ var DraggableComponent = ({
|
|
|
5054
5066
|
)
|
|
5055
5067
|
}
|
|
5056
5068
|
),
|
|
5057
|
-
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: getClassName16("
|
|
5069
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: getClassName16("overlayWrapper"), children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
5070
|
+
CustomOverlay,
|
|
5071
|
+
{
|
|
5072
|
+
componentId: id,
|
|
5073
|
+
componentType,
|
|
5074
|
+
hover,
|
|
5075
|
+
isSelected,
|
|
5076
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: getClassName16("overlay") })
|
|
5077
|
+
}
|
|
5078
|
+
) })
|
|
5058
5079
|
]
|
|
5059
5080
|
}
|
|
5060
5081
|
),
|
|
@@ -5563,13 +5584,14 @@ var DropZoneChild = ({
|
|
|
5563
5584
|
let label = (_b = (_a = componentConfig == null ? void 0 : componentConfig.label) != null ? _a : item == null ? void 0 : item.type.toString()) != null ? _b : "Component";
|
|
5564
5585
|
const renderPreview = (0, import_react34.useMemo)(
|
|
5565
5586
|
() => function Preview3() {
|
|
5587
|
+
var _a2;
|
|
5566
5588
|
if (item && "element" in item && item.element) {
|
|
5567
5589
|
return (
|
|
5568
5590
|
// Safe to use this since the HTML is set by the user
|
|
5569
5591
|
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { dangerouslySetInnerHTML: { __html: item.element.outerHTML } })
|
|
5570
5592
|
);
|
|
5571
5593
|
}
|
|
5572
|
-
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(DrawerItemInner, { name: label, children: overrides.componentItem });
|
|
5594
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(DrawerItemInner, { name: label, children: (_a2 = overrides.componentItem) != null ? _a2 : overrides.drawerItem });
|
|
5573
5595
|
},
|
|
5574
5596
|
[componentId, label, overrides]
|
|
5575
5597
|
);
|
|
@@ -6765,7 +6787,7 @@ Drawer.Item = DrawerItem;
|
|
|
6765
6787
|
|
|
6766
6788
|
// components/Puck/index.tsx
|
|
6767
6789
|
init_react_import();
|
|
6768
|
-
var
|
|
6790
|
+
var import_react59 = require("react");
|
|
6769
6791
|
|
|
6770
6792
|
// components/SidebarSection/index.tsx
|
|
6771
6793
|
init_react_import();
|
|
@@ -7010,7 +7032,7 @@ init_react_import();
|
|
|
7010
7032
|
|
|
7011
7033
|
// lib/use-component-list.tsx
|
|
7012
7034
|
init_react_import();
|
|
7013
|
-
var
|
|
7035
|
+
var import_react43 = require("react");
|
|
7014
7036
|
|
|
7015
7037
|
// components/ComponentList/index.tsx
|
|
7016
7038
|
init_react_import();
|
|
@@ -7020,19 +7042,28 @@ init_react_import();
|
|
|
7020
7042
|
var styles_module_default16 = { "ComponentList": "_ComponentList_1rrlt_1", "ComponentList--isExpanded": "_ComponentList--isExpanded_1rrlt_5", "ComponentList-content": "_ComponentList-content_1rrlt_9", "ComponentList-title": "_ComponentList-title_1rrlt_17", "ComponentList-titleIcon": "_ComponentList-titleIcon_1rrlt_53" };
|
|
7021
7043
|
|
|
7022
7044
|
// components/ComponentList/index.tsx
|
|
7045
|
+
var import_react42 = require("react");
|
|
7023
7046
|
var import_jsx_runtime30 = require("react/jsx-runtime");
|
|
7024
7047
|
var getClassName21 = get_class_name_factory_default("ComponentList", styles_module_default16);
|
|
7025
7048
|
var ComponentListItem = ({
|
|
7026
7049
|
name,
|
|
7027
7050
|
label
|
|
7028
7051
|
}) => {
|
|
7052
|
+
var _a;
|
|
7029
7053
|
const overrides = useAppStore((s) => s.overrides);
|
|
7030
7054
|
const canInsert = useAppStore(
|
|
7031
7055
|
(s) => s.permissions.getPermissions({
|
|
7032
7056
|
type: name
|
|
7033
7057
|
}).insert
|
|
7034
7058
|
);
|
|
7035
|
-
|
|
7059
|
+
(0, import_react42.useEffect)(() => {
|
|
7060
|
+
if (overrides.componentItem) {
|
|
7061
|
+
console.warn(
|
|
7062
|
+
"The `componentItem` override has been deprecated and renamed to `drawerItem`"
|
|
7063
|
+
);
|
|
7064
|
+
}
|
|
7065
|
+
}, [overrides]);
|
|
7066
|
+
return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Drawer.Item, { label, name, isDragDisabled: !canInsert, children: (_a = overrides.componentItem) != null ? _a : overrides.drawerItem });
|
|
7036
7067
|
};
|
|
7037
7068
|
var ComponentList = ({
|
|
7038
7069
|
children,
|
|
@@ -7081,10 +7112,10 @@ ComponentList.Item = ComponentListItem;
|
|
|
7081
7112
|
// lib/use-component-list.tsx
|
|
7082
7113
|
var import_jsx_runtime31 = require("react/jsx-runtime");
|
|
7083
7114
|
var useComponentList = () => {
|
|
7084
|
-
const [componentList, setComponentList] = (0,
|
|
7115
|
+
const [componentList, setComponentList] = (0, import_react43.useState)();
|
|
7085
7116
|
const config = useAppStore((s) => s.config);
|
|
7086
7117
|
const uiComponentList = useAppStore((s) => s.state.ui.componentList);
|
|
7087
|
-
(0,
|
|
7118
|
+
(0, import_react43.useEffect)(() => {
|
|
7088
7119
|
var _a, _b, _c;
|
|
7089
7120
|
if (Object.keys(uiComponentList).length > 0) {
|
|
7090
7121
|
const matchedComponents = [];
|
|
@@ -7153,22 +7184,29 @@ var useComponentList = () => {
|
|
|
7153
7184
|
};
|
|
7154
7185
|
|
|
7155
7186
|
// components/Puck/components/Components/index.tsx
|
|
7156
|
-
var
|
|
7187
|
+
var import_react44 = require("react");
|
|
7157
7188
|
var import_jsx_runtime32 = require("react/jsx-runtime");
|
|
7158
7189
|
var Components = () => {
|
|
7159
7190
|
const overrides = useAppStore((s) => s.overrides);
|
|
7160
7191
|
const componentList = useComponentList();
|
|
7161
|
-
const Wrapper = (0,
|
|
7192
|
+
const Wrapper = (0, import_react44.useMemo)(() => {
|
|
7193
|
+
if (overrides.components) {
|
|
7194
|
+
console.warn(
|
|
7195
|
+
"The `components` override has been deprecated and renamed to `drawer`"
|
|
7196
|
+
);
|
|
7197
|
+
}
|
|
7198
|
+
return overrides.components || overrides.drawer || "div";
|
|
7199
|
+
}, [overrides]);
|
|
7162
7200
|
return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Wrapper, { children: componentList ? componentList : /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(ComponentList, { id: "all" }) });
|
|
7163
7201
|
};
|
|
7164
7202
|
|
|
7165
7203
|
// components/Puck/components/Preview/index.tsx
|
|
7166
7204
|
init_react_import();
|
|
7167
|
-
var
|
|
7205
|
+
var import_react46 = require("react");
|
|
7168
7206
|
|
|
7169
7207
|
// components/AutoFrame/index.tsx
|
|
7170
7208
|
init_react_import();
|
|
7171
|
-
var
|
|
7209
|
+
var import_react45 = require("react");
|
|
7172
7210
|
var import_object_hash = __toESM(require("object-hash"));
|
|
7173
7211
|
var import_react_dom3 = require("react-dom");
|
|
7174
7212
|
var import_jsx_runtime33 = require("react/jsx-runtime");
|
|
@@ -7221,7 +7259,7 @@ var CopyHostStyles = ({
|
|
|
7221
7259
|
onStylesLoaded = () => null
|
|
7222
7260
|
}) => {
|
|
7223
7261
|
const { document: doc, window: win } = useFrame();
|
|
7224
|
-
(0,
|
|
7262
|
+
(0, import_react45.useEffect)(() => {
|
|
7225
7263
|
if (!win || !doc) {
|
|
7226
7264
|
return () => {
|
|
7227
7265
|
};
|
|
@@ -7380,8 +7418,8 @@ var CopyHostStyles = ({
|
|
|
7380
7418
|
}, []);
|
|
7381
7419
|
return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_jsx_runtime33.Fragment, { children });
|
|
7382
7420
|
};
|
|
7383
|
-
var autoFrameContext = (0,
|
|
7384
|
-
var useFrame = () => (0,
|
|
7421
|
+
var autoFrameContext = (0, import_react45.createContext)({});
|
|
7422
|
+
var useFrame = () => (0, import_react45.useContext)(autoFrameContext);
|
|
7385
7423
|
function AutoFrame(_a) {
|
|
7386
7424
|
var _b = _a, {
|
|
7387
7425
|
children,
|
|
@@ -7402,11 +7440,11 @@ function AutoFrame(_a) {
|
|
|
7402
7440
|
"onNotReady",
|
|
7403
7441
|
"frameRef"
|
|
7404
7442
|
]);
|
|
7405
|
-
const [loaded, setLoaded] = (0,
|
|
7406
|
-
const [ctx, setCtx] = (0,
|
|
7407
|
-
const [mountTarget, setMountTarget] = (0,
|
|
7408
|
-
const [stylesLoaded, setStylesLoaded] = (0,
|
|
7409
|
-
(0,
|
|
7443
|
+
const [loaded, setLoaded] = (0, import_react45.useState)(false);
|
|
7444
|
+
const [ctx, setCtx] = (0, import_react45.useState)({});
|
|
7445
|
+
const [mountTarget, setMountTarget] = (0, import_react45.useState)();
|
|
7446
|
+
const [stylesLoaded, setStylesLoaded] = (0, import_react45.useState)(false);
|
|
7447
|
+
(0, import_react45.useEffect)(() => {
|
|
7410
7448
|
var _a2;
|
|
7411
7449
|
if (frameRef.current) {
|
|
7412
7450
|
const doc = frameRef.current.contentDocument;
|
|
@@ -7458,7 +7496,7 @@ var import_jsx_runtime34 = require("react/jsx-runtime");
|
|
|
7458
7496
|
var getClassName22 = get_class_name_factory_default("PuckPreview", styles_module_default17);
|
|
7459
7497
|
var useBubbleIframeEvents = (ref) => {
|
|
7460
7498
|
const status = useAppStore((s) => s.status);
|
|
7461
|
-
(0,
|
|
7499
|
+
(0, import_react46.useEffect)(() => {
|
|
7462
7500
|
if (ref.current && status === "READY") {
|
|
7463
7501
|
const iframe = ref.current;
|
|
7464
7502
|
const handlePointerMove = (event) => {
|
|
@@ -7507,7 +7545,7 @@ var Preview2 = ({ id = "puck-preview" }) => {
|
|
|
7507
7545
|
const renderData = useAppStore(
|
|
7508
7546
|
(s) => s.state.ui.previewMode === "edit" ? null : s.state.data
|
|
7509
7547
|
);
|
|
7510
|
-
const Page = (0,
|
|
7548
|
+
const Page = (0, import_react46.useCallback)(
|
|
7511
7549
|
(pageProps) => {
|
|
7512
7550
|
var _a, _b;
|
|
7513
7551
|
const propsWithSlots = useSlots(
|
|
@@ -7521,9 +7559,9 @@ var Preview2 = ({ id = "puck-preview" }) => {
|
|
|
7521
7559
|
},
|
|
7522
7560
|
[config]
|
|
7523
7561
|
);
|
|
7524
|
-
const Frame = (0,
|
|
7562
|
+
const Frame = (0, import_react46.useMemo)(() => overrides.iframe, [overrides]);
|
|
7525
7563
|
const rootProps = root.props || root;
|
|
7526
|
-
const ref = (0,
|
|
7564
|
+
const ref = (0, import_react46.useRef)(null);
|
|
7527
7565
|
useBubbleIframeEvents(ref);
|
|
7528
7566
|
const inner = !renderData ? /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
|
7529
7567
|
Page,
|
|
@@ -7538,7 +7576,7 @@ var Preview2 = ({ id = "puck-preview" }) => {
|
|
|
7538
7576
|
children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(DropZonePure, { zone: rootDroppableId })
|
|
7539
7577
|
})
|
|
7540
7578
|
) : /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Render, { data: renderData, config, metadata });
|
|
7541
|
-
(0,
|
|
7579
|
+
(0, import_react46.useEffect)(() => {
|
|
7542
7580
|
if (!iframe.enabled) {
|
|
7543
7581
|
setStatus("READY");
|
|
7544
7582
|
}
|
|
@@ -7549,8 +7587,11 @@ var Preview2 = ({ id = "puck-preview" }) => {
|
|
|
7549
7587
|
className: getClassName22(),
|
|
7550
7588
|
id,
|
|
7551
7589
|
"data-puck-preview": true,
|
|
7552
|
-
onClick: () => {
|
|
7553
|
-
|
|
7590
|
+
onClick: (e) => {
|
|
7591
|
+
const el = e.target;
|
|
7592
|
+
if (!el.hasAttribute("data-puck-component") && !el.hasAttribute("data-puck-dropzone")) {
|
|
7593
|
+
dispatch({ type: "setUi", ui: { itemSelector: null } });
|
|
7594
|
+
}
|
|
7554
7595
|
},
|
|
7555
7596
|
children: iframe.enabled ? /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
|
7556
7597
|
AutoFrame_default,
|
|
@@ -7608,7 +7649,7 @@ var scrollIntoView = (el) => {
|
|
|
7608
7649
|
};
|
|
7609
7650
|
|
|
7610
7651
|
// components/LayerTree/index.tsx
|
|
7611
|
-
var
|
|
7652
|
+
var import_react47 = require("react");
|
|
7612
7653
|
|
|
7613
7654
|
// lib/on-scroll-end.ts
|
|
7614
7655
|
init_react_import();
|
|
@@ -7643,7 +7684,7 @@ var Layer = ({
|
|
|
7643
7684
|
const config = useAppStore((s) => s.config);
|
|
7644
7685
|
const itemSelector = useAppStore((s) => s.state.ui.itemSelector);
|
|
7645
7686
|
const dispatch = useAppStore((s) => s.dispatch);
|
|
7646
|
-
const setItemSelector = (0,
|
|
7687
|
+
const setItemSelector = (0, import_react47.useCallback)(
|
|
7647
7688
|
(itemSelector2) => {
|
|
7648
7689
|
dispatch({ type: "setUi", ui: { itemSelector: itemSelector2 } });
|
|
7649
7690
|
},
|
|
@@ -7663,7 +7704,7 @@ var Layer = ({
|
|
|
7663
7704
|
)
|
|
7664
7705
|
);
|
|
7665
7706
|
const containsZone = zonesForItem.length > 0;
|
|
7666
|
-
const zoneStore = (0,
|
|
7707
|
+
const zoneStore = (0, import_react47.useContext)(ZoneStoreContext);
|
|
7667
7708
|
const isHovering = useContextStore(
|
|
7668
7709
|
ZoneStoreContext,
|
|
7669
7710
|
(s) => s.hoveringComponent === itemId
|
|
@@ -7790,7 +7831,7 @@ var LayerTree = ({
|
|
|
7790
7831
|
};
|
|
7791
7832
|
|
|
7792
7833
|
// components/Puck/components/Outline/index.tsx
|
|
7793
|
-
var
|
|
7834
|
+
var import_react48 = require("react");
|
|
7794
7835
|
|
|
7795
7836
|
// lib/data/find-zones-for-area.ts
|
|
7796
7837
|
init_react_import();
|
|
@@ -7808,7 +7849,7 @@ var Outline = () => {
|
|
|
7808
7849
|
const rootZones = useAppStore(
|
|
7809
7850
|
(0, import_shallow8.useShallow)((s) => findZonesForArea(s.state, "root"))
|
|
7810
7851
|
);
|
|
7811
|
-
const Wrapper = (0,
|
|
7852
|
+
const Wrapper = (0, import_react48.useMemo)(() => outlineOverride || "div", [outlineOverride]);
|
|
7812
7853
|
return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Wrapper, { children: rootZones.map((zoneCompound) => /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
7813
7854
|
LayerTree,
|
|
7814
7855
|
{
|
|
@@ -7821,11 +7862,11 @@ var Outline = () => {
|
|
|
7821
7862
|
|
|
7822
7863
|
// components/Puck/components/Canvas/index.tsx
|
|
7823
7864
|
init_react_import();
|
|
7824
|
-
var
|
|
7865
|
+
var import_react51 = require("react");
|
|
7825
7866
|
|
|
7826
7867
|
// components/ViewportControls/index.tsx
|
|
7827
7868
|
init_react_import();
|
|
7828
|
-
var
|
|
7869
|
+
var import_react49 = require("react");
|
|
7829
7870
|
|
|
7830
7871
|
// css-module:/home/runner/work/puck/puck/packages/core/components/ViewportControls/styles.module.css#css-module
|
|
7831
7872
|
init_react_import();
|
|
@@ -7848,8 +7889,8 @@ var ViewportButton = ({
|
|
|
7848
7889
|
onClick
|
|
7849
7890
|
}) => {
|
|
7850
7891
|
const viewports = useAppStore((s) => s.state.ui.viewports);
|
|
7851
|
-
const [isActive, setIsActive] = (0,
|
|
7852
|
-
(0,
|
|
7892
|
+
const [isActive, setIsActive] = (0, import_react49.useState)(false);
|
|
7893
|
+
(0, import_react49.useEffect)(() => {
|
|
7853
7894
|
setIsActive(width === viewports.current.width);
|
|
7854
7895
|
}, [width, viewports.current.width]);
|
|
7855
7896
|
return /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("span", { className: getClassNameButton({ isActive }), children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
|
|
@@ -7886,7 +7927,7 @@ var ViewportControls = ({
|
|
|
7886
7927
|
const defaultsContainAutoZoom = defaultZoomOptions.find(
|
|
7887
7928
|
(option) => option.value === autoZoom
|
|
7888
7929
|
);
|
|
7889
|
-
const zoomOptions = (0,
|
|
7930
|
+
const zoomOptions = (0, import_react49.useMemo)(
|
|
7890
7931
|
() => [
|
|
7891
7932
|
...defaultZoomOptions,
|
|
7892
7933
|
...defaultsContainAutoZoom ? [] : [
|
|
@@ -7978,14 +8019,14 @@ var import_shallow9 = require("zustand/react/shallow");
|
|
|
7978
8019
|
|
|
7979
8020
|
// lib/frame-context.tsx
|
|
7980
8021
|
init_react_import();
|
|
7981
|
-
var
|
|
8022
|
+
var import_react50 = require("react");
|
|
7982
8023
|
var import_jsx_runtime38 = require("react/jsx-runtime");
|
|
7983
|
-
var FrameContext = (0,
|
|
8024
|
+
var FrameContext = (0, import_react50.createContext)(null);
|
|
7984
8025
|
var FrameProvider = ({
|
|
7985
8026
|
children
|
|
7986
8027
|
}) => {
|
|
7987
|
-
const frameRef = (0,
|
|
7988
|
-
const value = (0,
|
|
8028
|
+
const frameRef = (0, import_react50.useRef)(null);
|
|
8029
|
+
const value = (0, import_react50.useMemo)(
|
|
7989
8030
|
() => ({
|
|
7990
8031
|
frameRef
|
|
7991
8032
|
}),
|
|
@@ -7994,7 +8035,7 @@ var FrameProvider = ({
|
|
|
7994
8035
|
return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(FrameContext.Provider, { value, children });
|
|
7995
8036
|
};
|
|
7996
8037
|
var useCanvasFrame = () => {
|
|
7997
|
-
const context = (0,
|
|
8038
|
+
const context = (0, import_react50.useContext)(FrameContext);
|
|
7998
8039
|
if (context === null) {
|
|
7999
8040
|
throw new Error("useCanvasFrame must be used within a FrameProvider");
|
|
8000
8041
|
}
|
|
@@ -8042,17 +8083,17 @@ var Canvas = () => {
|
|
|
8042
8083
|
viewports: s.state.ui.viewports
|
|
8043
8084
|
}))
|
|
8044
8085
|
);
|
|
8045
|
-
const [showTransition, setShowTransition] = (0,
|
|
8046
|
-
const isResettingZoomRef = (0,
|
|
8047
|
-
const defaultRender = (0,
|
|
8086
|
+
const [showTransition, setShowTransition] = (0, import_react51.useState)(false);
|
|
8087
|
+
const isResettingZoomRef = (0, import_react51.useRef)(false);
|
|
8088
|
+
const defaultRender = (0, import_react51.useMemo)(() => {
|
|
8048
8089
|
const PuckDefault = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(import_jsx_runtime39.Fragment, { children });
|
|
8049
8090
|
return PuckDefault;
|
|
8050
8091
|
}, []);
|
|
8051
|
-
const CustomPreview = (0,
|
|
8092
|
+
const CustomPreview = (0, import_react51.useMemo)(
|
|
8052
8093
|
() => overrides.preview || defaultRender,
|
|
8053
8094
|
[overrides]
|
|
8054
8095
|
);
|
|
8055
|
-
const getFrameDimensions = (0,
|
|
8096
|
+
const getFrameDimensions = (0, import_react51.useCallback)(() => {
|
|
8056
8097
|
if (frameRef.current) {
|
|
8057
8098
|
const frame = frameRef.current;
|
|
8058
8099
|
const box = getBox(frame);
|
|
@@ -8060,7 +8101,7 @@ var Canvas = () => {
|
|
|
8060
8101
|
}
|
|
8061
8102
|
return { width: 0, height: 0 };
|
|
8062
8103
|
}, [frameRef]);
|
|
8063
|
-
(0,
|
|
8104
|
+
(0, import_react51.useEffect)(() => {
|
|
8064
8105
|
resetAutoZoom({
|
|
8065
8106
|
isResettingRef: isResettingZoomRef,
|
|
8066
8107
|
setShowTransition,
|
|
@@ -8076,7 +8117,7 @@ var Canvas = () => {
|
|
|
8076
8117
|
resetAutoZoom,
|
|
8077
8118
|
viewports
|
|
8078
8119
|
]);
|
|
8079
|
-
(0,
|
|
8120
|
+
(0, import_react51.useEffect)(() => {
|
|
8080
8121
|
const { height: frameHeight } = getFrameDimensions();
|
|
8081
8122
|
if (viewports.current.height === "auto") {
|
|
8082
8123
|
setZoomConfig(__spreadProps(__spreadValues({}, zoomConfig), {
|
|
@@ -8084,7 +8125,7 @@ var Canvas = () => {
|
|
|
8084
8125
|
}));
|
|
8085
8126
|
}
|
|
8086
8127
|
}, [zoomConfig.zoom, getFrameDimensions, setZoomConfig]);
|
|
8087
|
-
(0,
|
|
8128
|
+
(0, import_react51.useEffect)(() => {
|
|
8088
8129
|
if (ZOOM_ON_CHANGE) {
|
|
8089
8130
|
resetAutoZoom({
|
|
8090
8131
|
isResettingRef: isResettingZoomRef,
|
|
@@ -8094,7 +8135,7 @@ var Canvas = () => {
|
|
|
8094
8135
|
});
|
|
8095
8136
|
}
|
|
8096
8137
|
}, [viewports.current.width, resetAutoZoom, viewports]);
|
|
8097
|
-
(0,
|
|
8138
|
+
(0, import_react51.useEffect)(() => {
|
|
8098
8139
|
const cb = () => {
|
|
8099
8140
|
resetAutoZoom({
|
|
8100
8141
|
isResettingRef: isResettingZoomRef,
|
|
@@ -8107,8 +8148,8 @@ var Canvas = () => {
|
|
|
8107
8148
|
window.removeEventListener("resize", cb);
|
|
8108
8149
|
};
|
|
8109
8150
|
}, [resetAutoZoom]);
|
|
8110
|
-
const [showLoader, setShowLoader] = (0,
|
|
8111
|
-
(0,
|
|
8151
|
+
const [showLoader, setShowLoader] = (0, import_react51.useState)(false);
|
|
8152
|
+
(0, import_react51.useEffect)(() => {
|
|
8112
8153
|
setTimeout(() => {
|
|
8113
8154
|
setShowLoader(true);
|
|
8114
8155
|
}, 500);
|
|
@@ -8120,11 +8161,16 @@ var Canvas = () => {
|
|
|
8120
8161
|
ready: status === "READY" || !iframe.enabled || !iframe.waitForStyles,
|
|
8121
8162
|
showLoader
|
|
8122
8163
|
}),
|
|
8123
|
-
onClick: () =>
|
|
8124
|
-
|
|
8125
|
-
|
|
8126
|
-
|
|
8127
|
-
|
|
8164
|
+
onClick: (e) => {
|
|
8165
|
+
const el = e.target;
|
|
8166
|
+
if (!el.hasAttribute("data-puck-component") && !el.hasAttribute("data-puck-dropzone")) {
|
|
8167
|
+
dispatch({
|
|
8168
|
+
type: "setUi",
|
|
8169
|
+
ui: { itemSelector: null },
|
|
8170
|
+
recordHistory: true
|
|
8171
|
+
});
|
|
8172
|
+
}
|
|
8173
|
+
},
|
|
8128
8174
|
children: [
|
|
8129
8175
|
viewports.controlsVisible && iframe.enabled && /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { className: getClassName25("controls"), children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
8130
8176
|
ViewportControls,
|
|
@@ -8188,7 +8234,7 @@ var Canvas = () => {
|
|
|
8188
8234
|
|
|
8189
8235
|
// lib/use-loaded-overrides.ts
|
|
8190
8236
|
init_react_import();
|
|
8191
|
-
var
|
|
8237
|
+
var import_react52 = require("react");
|
|
8192
8238
|
|
|
8193
8239
|
// lib/load-overrides.ts
|
|
8194
8240
|
init_react_import();
|
|
@@ -8227,7 +8273,7 @@ var useLoadedOverrides = ({
|
|
|
8227
8273
|
overrides,
|
|
8228
8274
|
plugins
|
|
8229
8275
|
}) => {
|
|
8230
|
-
return (0,
|
|
8276
|
+
return (0, import_react52.useMemo)(() => {
|
|
8231
8277
|
return loadOverrides({ overrides, plugins });
|
|
8232
8278
|
}, [plugins, overrides]);
|
|
8233
8279
|
};
|
|
@@ -8239,14 +8285,14 @@ var DefaultOverride = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime40
|
|
|
8239
8285
|
|
|
8240
8286
|
// lib/use-inject-css.ts
|
|
8241
8287
|
init_react_import();
|
|
8242
|
-
var
|
|
8288
|
+
var import_react53 = require("react");
|
|
8243
8289
|
var styles = ``;
|
|
8244
8290
|
var useInjectStyleSheet = (initialStyles, iframeEnabled) => {
|
|
8245
|
-
const [el, setEl] = (0,
|
|
8246
|
-
(0,
|
|
8291
|
+
const [el, setEl] = (0, import_react53.useState)();
|
|
8292
|
+
(0, import_react53.useEffect)(() => {
|
|
8247
8293
|
setEl(document.createElement("style"));
|
|
8248
8294
|
}, []);
|
|
8249
|
-
(0,
|
|
8295
|
+
(0, import_react53.useEffect)(() => {
|
|
8250
8296
|
var _a;
|
|
8251
8297
|
if (!el || typeof window === "undefined") {
|
|
8252
8298
|
return;
|
|
@@ -8266,10 +8312,10 @@ var useInjectGlobalCss = (iframeEnabled) => {
|
|
|
8266
8312
|
|
|
8267
8313
|
// lib/use-preview-mode-hotkeys.ts
|
|
8268
8314
|
init_react_import();
|
|
8269
|
-
var
|
|
8315
|
+
var import_react54 = require("react");
|
|
8270
8316
|
var usePreviewModeHotkeys = () => {
|
|
8271
8317
|
const appStore = useAppStoreApi();
|
|
8272
|
-
const toggleInteractive = (0,
|
|
8318
|
+
const toggleInteractive = (0, import_react54.useCallback)(() => {
|
|
8273
8319
|
const dispatch = appStore.getState().dispatch;
|
|
8274
8320
|
dispatch({
|
|
8275
8321
|
type: "setUi",
|
|
@@ -8284,7 +8330,7 @@ var usePreviewModeHotkeys = () => {
|
|
|
8284
8330
|
|
|
8285
8331
|
// lib/use-puck.ts
|
|
8286
8332
|
init_react_import();
|
|
8287
|
-
var
|
|
8333
|
+
var import_react55 = require("react");
|
|
8288
8334
|
var import_zustand6 = require("zustand");
|
|
8289
8335
|
var generateUsePuck = (store) => {
|
|
8290
8336
|
const history = {
|
|
@@ -8317,7 +8363,7 @@ var generateUsePuck = (store) => {
|
|
|
8317
8363
|
};
|
|
8318
8364
|
return storeData;
|
|
8319
8365
|
};
|
|
8320
|
-
var UsePuckStoreContext = (0,
|
|
8366
|
+
var UsePuckStoreContext = (0, import_react55.createContext)(
|
|
8321
8367
|
null
|
|
8322
8368
|
);
|
|
8323
8369
|
var convertToPickedStore = (store) => {
|
|
@@ -8331,12 +8377,12 @@ var convertToPickedStore = (store) => {
|
|
|
8331
8377
|
};
|
|
8332
8378
|
};
|
|
8333
8379
|
var useRegisterUsePuckStore = (appStore) => {
|
|
8334
|
-
const [usePuckStore] = (0,
|
|
8380
|
+
const [usePuckStore] = (0, import_react55.useState)(
|
|
8335
8381
|
() => (0, import_zustand6.createStore)(
|
|
8336
8382
|
() => generateUsePuck(convertToPickedStore(appStore.getState()))
|
|
8337
8383
|
)
|
|
8338
8384
|
);
|
|
8339
|
-
(0,
|
|
8385
|
+
(0, import_react55.useEffect)(() => {
|
|
8340
8386
|
return appStore.subscribe(
|
|
8341
8387
|
(store) => convertToPickedStore(store),
|
|
8342
8388
|
(pickedStore) => {
|
|
@@ -8348,7 +8394,7 @@ var useRegisterUsePuckStore = (appStore) => {
|
|
|
8348
8394
|
};
|
|
8349
8395
|
function createUsePuck() {
|
|
8350
8396
|
return function usePuck2(selector) {
|
|
8351
|
-
const usePuckApi = (0,
|
|
8397
|
+
const usePuckApi = (0, import_react55.useContext)(UsePuckStoreContext);
|
|
8352
8398
|
if (!usePuckApi) {
|
|
8353
8399
|
throw new Error("usePuck must be used inside <Puck>.");
|
|
8354
8400
|
}
|
|
@@ -8360,7 +8406,7 @@ function createUsePuck() {
|
|
|
8360
8406
|
};
|
|
8361
8407
|
}
|
|
8362
8408
|
function usePuck() {
|
|
8363
|
-
(0,
|
|
8409
|
+
(0, import_react55.useEffect)(() => {
|
|
8364
8410
|
console.warn(
|
|
8365
8411
|
"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."
|
|
8366
8412
|
);
|
|
@@ -8368,7 +8414,7 @@ function usePuck() {
|
|
|
8368
8414
|
return createUsePuck()((s) => s);
|
|
8369
8415
|
}
|
|
8370
8416
|
function useGetPuck() {
|
|
8371
|
-
const usePuckApi = (0,
|
|
8417
|
+
const usePuckApi = (0, import_react55.useContext)(UsePuckStoreContext);
|
|
8372
8418
|
if (!usePuckApi) {
|
|
8373
8419
|
throw new Error("usePuckGet must be used inside <Puck>.");
|
|
8374
8420
|
}
|
|
@@ -8380,7 +8426,7 @@ var import_fast_deep_equal3 = __toESM(require("fast-deep-equal"));
|
|
|
8380
8426
|
|
|
8381
8427
|
// components/Puck/components/Header/index.tsx
|
|
8382
8428
|
init_react_import();
|
|
8383
|
-
var
|
|
8429
|
+
var import_react56 = require("react");
|
|
8384
8430
|
|
|
8385
8431
|
// components/MenuBar/index.tsx
|
|
8386
8432
|
init_react_import();
|
|
@@ -8462,7 +8508,7 @@ var HeaderInner = () => {
|
|
|
8462
8508
|
} = usePropsContext();
|
|
8463
8509
|
const dispatch = useAppStore((s) => s.dispatch);
|
|
8464
8510
|
const appStore = useAppStoreApi();
|
|
8465
|
-
const defaultHeaderRender = (0,
|
|
8511
|
+
const defaultHeaderRender = (0, import_react56.useMemo)(() => {
|
|
8466
8512
|
if (renderHeader) {
|
|
8467
8513
|
console.warn(
|
|
8468
8514
|
"`renderHeader` is deprecated. Please use `overrides.header` and the `usePuck` hook instead"
|
|
@@ -8477,7 +8523,7 @@ var HeaderInner = () => {
|
|
|
8477
8523
|
}
|
|
8478
8524
|
return DefaultOverride;
|
|
8479
8525
|
}, [renderHeader]);
|
|
8480
|
-
const defaultHeaderActionsRender = (0,
|
|
8526
|
+
const defaultHeaderActionsRender = (0, import_react56.useMemo)(() => {
|
|
8481
8527
|
if (renderHeaderActions) {
|
|
8482
8528
|
console.warn(
|
|
8483
8529
|
"`renderHeaderActions` is deprecated. Please use `overrides.headerActions` and the `usePuck` hook instead."
|
|
@@ -8497,7 +8543,7 @@ var HeaderInner = () => {
|
|
|
8497
8543
|
const CustomHeaderActions = useAppStore(
|
|
8498
8544
|
(s) => s.overrides.headerActions || defaultHeaderActionsRender
|
|
8499
8545
|
);
|
|
8500
|
-
const [menuOpen, setMenuOpen] = (0,
|
|
8546
|
+
const [menuOpen, setMenuOpen] = (0, import_react56.useState)(false);
|
|
8501
8547
|
const rootTitle = useAppStore((s) => {
|
|
8502
8548
|
var _a, _b;
|
|
8503
8549
|
const rootData = (_a = s.state.indexes.nodes["root"]) == null ? void 0 : _a.data;
|
|
@@ -8507,7 +8553,7 @@ var HeaderInner = () => {
|
|
|
8507
8553
|
const rightSideBarVisible = useAppStore(
|
|
8508
8554
|
(s) => s.state.ui.rightSideBarVisible
|
|
8509
8555
|
);
|
|
8510
|
-
const toggleSidebars = (0,
|
|
8556
|
+
const toggleSidebars = (0, import_react56.useCallback)(
|
|
8511
8557
|
(sidebar) => {
|
|
8512
8558
|
const widerViewport = window.matchMedia("(min-width: 638px)").matches;
|
|
8513
8559
|
const sideBarVisible = sidebar === "left" ? leftSideBarVisible : rightSideBarVisible;
|
|
@@ -8610,14 +8656,14 @@ var HeaderInner = () => {
|
|
|
8610
8656
|
}
|
|
8611
8657
|
);
|
|
8612
8658
|
};
|
|
8613
|
-
var Header = (0,
|
|
8659
|
+
var Header = (0, import_react56.memo)(HeaderInner);
|
|
8614
8660
|
|
|
8615
8661
|
// components/Puck/components/Sidebar/index.tsx
|
|
8616
8662
|
init_react_import();
|
|
8617
8663
|
|
|
8618
8664
|
// components/Puck/components/ResizeHandle/index.tsx
|
|
8619
8665
|
init_react_import();
|
|
8620
|
-
var
|
|
8666
|
+
var import_react57 = require("react");
|
|
8621
8667
|
|
|
8622
8668
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/ResizeHandle/styles.module.css#css-module
|
|
8623
8669
|
init_react_import();
|
|
@@ -8634,11 +8680,11 @@ var ResizeHandle = ({
|
|
|
8634
8680
|
}) => {
|
|
8635
8681
|
const { frameRef } = useCanvasFrame();
|
|
8636
8682
|
const resetAutoZoom = useResetAutoZoom(frameRef);
|
|
8637
|
-
const handleRef = (0,
|
|
8638
|
-
const isDragging = (0,
|
|
8639
|
-
const startX = (0,
|
|
8640
|
-
const startWidth = (0,
|
|
8641
|
-
const handleMouseMove = (0,
|
|
8683
|
+
const handleRef = (0, import_react57.useRef)(null);
|
|
8684
|
+
const isDragging = (0, import_react57.useRef)(false);
|
|
8685
|
+
const startX = (0, import_react57.useRef)(0);
|
|
8686
|
+
const startWidth = (0, import_react57.useRef)(0);
|
|
8687
|
+
const handleMouseMove = (0, import_react57.useCallback)(
|
|
8642
8688
|
(e) => {
|
|
8643
8689
|
if (!isDragging.current) return;
|
|
8644
8690
|
const delta = e.clientX - startX.current;
|
|
@@ -8649,7 +8695,7 @@ var ResizeHandle = ({
|
|
|
8649
8695
|
},
|
|
8650
8696
|
[onResize, position]
|
|
8651
8697
|
);
|
|
8652
|
-
const handleMouseUp = (0,
|
|
8698
|
+
const handleMouseUp = (0, import_react57.useCallback)(() => {
|
|
8653
8699
|
var _a;
|
|
8654
8700
|
if (!isDragging.current) return;
|
|
8655
8701
|
isDragging.current = false;
|
|
@@ -8665,7 +8711,7 @@ var ResizeHandle = ({
|
|
|
8665
8711
|
onResizeEnd(finalWidth);
|
|
8666
8712
|
resetAutoZoom();
|
|
8667
8713
|
}, [onResizeEnd, resetAutoZoom]);
|
|
8668
|
-
const handleMouseDown = (0,
|
|
8714
|
+
const handleMouseDown = (0, import_react57.useCallback)(
|
|
8669
8715
|
(e) => {
|
|
8670
8716
|
var _a;
|
|
8671
8717
|
isDragging.current = true;
|
|
@@ -8726,14 +8772,14 @@ var Sidebar = ({
|
|
|
8726
8772
|
|
|
8727
8773
|
// lib/use-sidebar-resize.ts
|
|
8728
8774
|
init_react_import();
|
|
8729
|
-
var
|
|
8775
|
+
var import_react58 = require("react");
|
|
8730
8776
|
function useSidebarResize(position, dispatch) {
|
|
8731
|
-
const [width, setWidth] = (0,
|
|
8732
|
-
const sidebarRef = (0,
|
|
8777
|
+
const [width, setWidth] = (0, import_react58.useState)(null);
|
|
8778
|
+
const sidebarRef = (0, import_react58.useRef)(null);
|
|
8733
8779
|
const storeWidth = useAppStore(
|
|
8734
8780
|
(s) => position === "left" ? s.state.ui.leftSideBarWidth : s.state.ui.rightSideBarWidth
|
|
8735
8781
|
);
|
|
8736
|
-
(0,
|
|
8782
|
+
(0, import_react58.useEffect)(() => {
|
|
8737
8783
|
if (typeof window !== "undefined" && !storeWidth) {
|
|
8738
8784
|
try {
|
|
8739
8785
|
const savedWidths = localStorage.getItem("puck-sidebar-widths");
|
|
@@ -8757,12 +8803,12 @@ function useSidebarResize(position, dispatch) {
|
|
|
8757
8803
|
}
|
|
8758
8804
|
}
|
|
8759
8805
|
}, [dispatch, position, storeWidth]);
|
|
8760
|
-
(0,
|
|
8806
|
+
(0, import_react58.useEffect)(() => {
|
|
8761
8807
|
if (storeWidth !== void 0) {
|
|
8762
8808
|
setWidth(storeWidth);
|
|
8763
8809
|
}
|
|
8764
8810
|
}, [storeWidth]);
|
|
8765
|
-
const handleResizeEnd = (0,
|
|
8811
|
+
const handleResizeEnd = (0, import_react58.useCallback)(
|
|
8766
8812
|
(width2) => {
|
|
8767
8813
|
dispatch({
|
|
8768
8814
|
type: "setUi",
|
|
@@ -8817,11 +8863,11 @@ var FieldSideBar = () => {
|
|
|
8817
8863
|
);
|
|
8818
8864
|
return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(SidebarSection, { noPadding: true, noBorderTop: true, showBreadcrumbs: true, title, children: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(Fields, {}) });
|
|
8819
8865
|
};
|
|
8820
|
-
var propsContext = (0,
|
|
8866
|
+
var propsContext = (0, import_react59.createContext)({});
|
|
8821
8867
|
function PropsProvider(props) {
|
|
8822
8868
|
return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(propsContext.Provider, { value: props, children: props.children });
|
|
8823
8869
|
}
|
|
8824
|
-
var usePropsContext = () => (0,
|
|
8870
|
+
var usePropsContext = () => (0, import_react59.useContext)(propsContext);
|
|
8825
8871
|
function PuckProvider({ children }) {
|
|
8826
8872
|
const {
|
|
8827
8873
|
config,
|
|
@@ -8837,14 +8883,14 @@ function PuckProvider({ children }) {
|
|
|
8837
8883
|
metadata,
|
|
8838
8884
|
onAction
|
|
8839
8885
|
} = usePropsContext();
|
|
8840
|
-
const iframe = (0,
|
|
8886
|
+
const iframe = (0, import_react59.useMemo)(
|
|
8841
8887
|
() => __spreadValues({
|
|
8842
8888
|
enabled: true,
|
|
8843
8889
|
waitForStyles: true
|
|
8844
8890
|
}, _iframe),
|
|
8845
8891
|
[_iframe]
|
|
8846
8892
|
);
|
|
8847
|
-
const [generatedAppState] = (0,
|
|
8893
|
+
const [generatedAppState] = (0, import_react59.useState)(() => {
|
|
8848
8894
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
8849
8895
|
const initial = __spreadValues(__spreadValues({}, defaultAppState.ui), initialUi);
|
|
8850
8896
|
let clientUiState = {};
|
|
@@ -8873,7 +8919,7 @@ function PuckProvider({ children }) {
|
|
|
8873
8919
|
}
|
|
8874
8920
|
}
|
|
8875
8921
|
if (Object.keys((initialData == null ? void 0 : initialData.root) || {}).length > 0 && !((_g = initialData == null ? void 0 : initialData.root) == null ? void 0 : _g.props)) {
|
|
8876
|
-
console.
|
|
8922
|
+
console.warn(
|
|
8877
8923
|
"Warning: Defining props on `root` is deprecated. Please use `root.props`, or republish this page to migrate automatically."
|
|
8878
8924
|
);
|
|
8879
8925
|
}
|
|
@@ -8904,7 +8950,7 @@ function PuckProvider({ children }) {
|
|
|
8904
8950
|
return walkAppState(newAppState, config);
|
|
8905
8951
|
});
|
|
8906
8952
|
const { appendData = true } = _initialHistory || {};
|
|
8907
|
-
const [blendedHistories] = (0,
|
|
8953
|
+
const [blendedHistories] = (0, import_react59.useState)(
|
|
8908
8954
|
[
|
|
8909
8955
|
...(_initialHistory == null ? void 0 : _initialHistory.histories) || [],
|
|
8910
8956
|
...appendData ? [{ state: generatedAppState }] : []
|
|
@@ -8924,7 +8970,7 @@ function PuckProvider({ children }) {
|
|
|
8924
8970
|
overrides,
|
|
8925
8971
|
plugins
|
|
8926
8972
|
});
|
|
8927
|
-
const generateAppStore = (0,
|
|
8973
|
+
const generateAppStore = (0, import_react59.useCallback)(
|
|
8928
8974
|
(state) => {
|
|
8929
8975
|
return {
|
|
8930
8976
|
state,
|
|
@@ -8948,15 +8994,15 @@ function PuckProvider({ children }) {
|
|
|
8948
8994
|
metadata
|
|
8949
8995
|
]
|
|
8950
8996
|
);
|
|
8951
|
-
const [appStore] = (0,
|
|
8997
|
+
const [appStore] = (0, import_react59.useState)(
|
|
8952
8998
|
() => createAppStore(generateAppStore(initialAppState))
|
|
8953
8999
|
);
|
|
8954
|
-
(0,
|
|
9000
|
+
(0, import_react59.useEffect)(() => {
|
|
8955
9001
|
if (process.env.NODE_ENV !== "production") {
|
|
8956
9002
|
window.__PUCK_INTERNAL_DO_NOT_USE = { appStore };
|
|
8957
9003
|
}
|
|
8958
9004
|
}, [appStore]);
|
|
8959
|
-
(0,
|
|
9005
|
+
(0, import_react59.useEffect)(() => {
|
|
8960
9006
|
const state = appStore.getState().state;
|
|
8961
9007
|
appStore.setState(__spreadValues({}, generateAppStore(state)));
|
|
8962
9008
|
}, [config, plugins, loadedOverrides, viewports, iframe, onAction, metadata]);
|
|
@@ -8965,8 +9011,8 @@ function PuckProvider({ children }) {
|
|
|
8965
9011
|
index: initialHistoryIndex,
|
|
8966
9012
|
initialAppState
|
|
8967
9013
|
});
|
|
8968
|
-
const previousData = (0,
|
|
8969
|
-
(0,
|
|
9014
|
+
const previousData = (0, import_react59.useRef)(null);
|
|
9015
|
+
(0, import_react59.useEffect)(() => {
|
|
8970
9016
|
appStore.subscribe(
|
|
8971
9017
|
(s) => s.state.data,
|
|
8972
9018
|
(data) => {
|
|
@@ -8980,7 +9026,7 @@ function PuckProvider({ children }) {
|
|
|
8980
9026
|
}, []);
|
|
8981
9027
|
useRegisterPermissionsSlice(appStore, permissions);
|
|
8982
9028
|
const uPuckStore = useRegisterUsePuckStore(appStore);
|
|
8983
|
-
(0,
|
|
9029
|
+
(0, import_react59.useEffect)(() => {
|
|
8984
9030
|
const { resolveAndCommitData } = appStore.getState();
|
|
8985
9031
|
resolveAndCommitData();
|
|
8986
9032
|
}, []);
|
|
@@ -8992,7 +9038,7 @@ function PuckLayout({ children }) {
|
|
|
8992
9038
|
dnd,
|
|
8993
9039
|
initialHistory: _initialHistory
|
|
8994
9040
|
} = usePropsContext();
|
|
8995
|
-
const iframe = (0,
|
|
9041
|
+
const iframe = (0, import_react59.useMemo)(
|
|
8996
9042
|
() => __spreadValues({
|
|
8997
9043
|
enabled: true,
|
|
8998
9044
|
waitForStyles: true
|
|
@@ -9017,7 +9063,7 @@ function PuckLayout({ children }) {
|
|
|
9017
9063
|
sidebarRef: rightSidebarRef,
|
|
9018
9064
|
handleResizeEnd: handleRightSidebarResizeEnd
|
|
9019
9065
|
} = useSidebarResize("right", dispatch);
|
|
9020
|
-
(0,
|
|
9066
|
+
(0, import_react59.useEffect)(() => {
|
|
9021
9067
|
if (!window.matchMedia("(min-width: 638px)").matches) {
|
|
9022
9068
|
dispatch({
|
|
9023
9069
|
type: "setUi",
|
|
@@ -9041,17 +9087,17 @@ function PuckLayout({ children }) {
|
|
|
9041
9087
|
};
|
|
9042
9088
|
}, []);
|
|
9043
9089
|
const overrides = useAppStore((s) => s.overrides);
|
|
9044
|
-
const CustomPuck = (0,
|
|
9090
|
+
const CustomPuck = (0, import_react59.useMemo)(
|
|
9045
9091
|
() => overrides.puck || DefaultOverride,
|
|
9046
9092
|
[overrides]
|
|
9047
9093
|
);
|
|
9048
|
-
const [mounted, setMounted] = (0,
|
|
9049
|
-
(0,
|
|
9094
|
+
const [mounted, setMounted] = (0, import_react59.useState)(false);
|
|
9095
|
+
(0, import_react59.useEffect)(() => {
|
|
9050
9096
|
setMounted(true);
|
|
9051
9097
|
}, []);
|
|
9052
9098
|
const ready = useAppStore((s) => s.status === "READY");
|
|
9053
9099
|
useMonitorHotkeys();
|
|
9054
|
-
(0,
|
|
9100
|
+
(0, import_react59.useEffect)(() => {
|
|
9055
9101
|
if (ready && iframe.enabled) {
|
|
9056
9102
|
const frameDoc = getFrame();
|
|
9057
9103
|
if (frameDoc) {
|
|
@@ -9288,6 +9334,36 @@ function transformProps(data, propTransforms, config = { components: {} }) {
|
|
|
9288
9334
|
return updatedData;
|
|
9289
9335
|
}
|
|
9290
9336
|
|
|
9337
|
+
// lib/overlay-portal/index.tsx
|
|
9338
|
+
init_react_import();
|
|
9339
|
+
var registerOverlayPortal = (el, opts = {}) => {
|
|
9340
|
+
if (!el) return;
|
|
9341
|
+
const { disableDrag = true } = opts;
|
|
9342
|
+
const stopPropagation = (e) => {
|
|
9343
|
+
e.stopPropagation();
|
|
9344
|
+
};
|
|
9345
|
+
el.addEventListener("mouseover", stopPropagation, {
|
|
9346
|
+
capture: true
|
|
9347
|
+
});
|
|
9348
|
+
if (disableDrag) {
|
|
9349
|
+
el.addEventListener("pointerdown", stopPropagation, {
|
|
9350
|
+
capture: true
|
|
9351
|
+
});
|
|
9352
|
+
}
|
|
9353
|
+
el.setAttribute("data-puck-overlay-portal", "true");
|
|
9354
|
+
return () => {
|
|
9355
|
+
el.removeEventListener("mouseover", stopPropagation, {
|
|
9356
|
+
capture: true
|
|
9357
|
+
});
|
|
9358
|
+
if (disableDrag) {
|
|
9359
|
+
el.removeEventListener("pointerdown", stopPropagation, {
|
|
9360
|
+
capture: true
|
|
9361
|
+
});
|
|
9362
|
+
}
|
|
9363
|
+
el.removeAttribute("data-puck-overlay-portal");
|
|
9364
|
+
};
|
|
9365
|
+
};
|
|
9366
|
+
|
|
9291
9367
|
// lib/resolve-all-data.ts
|
|
9292
9368
|
init_react_import();
|
|
9293
9369
|
|
|
@@ -9366,6 +9442,7 @@ function resolveAllData(_0, _1) {
|
|
|
9366
9442
|
createUsePuck,
|
|
9367
9443
|
migrate,
|
|
9368
9444
|
overrideKeys,
|
|
9445
|
+
registerOverlayPortal,
|
|
9369
9446
|
renderContext,
|
|
9370
9447
|
resolveAllData,
|
|
9371
9448
|
transformProps,
|