@measured/puck 0.14.3-canary.9df6633 → 0.15.0-canary.aedd401
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -4
- package/dist/{Config-09628f3c.d.ts → Config-550396e1.d.ts} +4 -8
- package/dist/index.d.ts +7 -7
- package/dist/index.js +394 -179
- package/dist/rsc.d.ts +1 -1
- package/package.json +3 -2
package/dist/index.js
CHANGED
@@ -8033,9 +8033,9 @@ var require_react_dom_development = __commonJS({
|
|
8033
8033
|
if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== "undefined" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart === "function") {
|
8034
8034
|
__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());
|
8035
8035
|
}
|
8036
|
-
var
|
8036
|
+
var React3 = require("react");
|
8037
8037
|
var Scheduler = require_scheduler();
|
8038
|
-
var ReactSharedInternals =
|
8038
|
+
var ReactSharedInternals = React3.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
|
8039
8039
|
var suppressWarning = false;
|
8040
8040
|
function setSuppressWarning(newSuppressWarning) {
|
8041
8041
|
{
|
@@ -8084,7 +8084,7 @@ var require_react_dom_development = __commonJS({
|
|
8084
8084
|
var HostPortal = 4;
|
8085
8085
|
var HostComponent = 5;
|
8086
8086
|
var HostText = 6;
|
8087
|
-
var
|
8087
|
+
var Fragment18 = 7;
|
8088
8088
|
var Mode = 8;
|
8089
8089
|
var ContextConsumer = 9;
|
8090
8090
|
var ContextProvider = 10;
|
@@ -9240,7 +9240,7 @@ var require_react_dom_development = __commonJS({
|
|
9240
9240
|
return "DehydratedFragment";
|
9241
9241
|
case ForwardRef:
|
9242
9242
|
return getWrappedName$1(type, type.render, "ForwardRef");
|
9243
|
-
case
|
9243
|
+
case Fragment18:
|
9244
9244
|
return "Fragment";
|
9245
9245
|
case HostComponent:
|
9246
9246
|
return type;
|
@@ -9640,7 +9640,7 @@ var require_react_dom_development = __commonJS({
|
|
9640
9640
|
{
|
9641
9641
|
if (props.value == null) {
|
9642
9642
|
if (typeof props.children === "object" && props.children !== null) {
|
9643
|
-
|
9643
|
+
React3.Children.forEach(props.children, function(child) {
|
9644
9644
|
if (child == null) {
|
9645
9645
|
return;
|
9646
9646
|
}
|
@@ -18087,7 +18087,7 @@ var require_react_dom_development = __commonJS({
|
|
18087
18087
|
}
|
18088
18088
|
}
|
18089
18089
|
var fakeInternalInstance = {};
|
18090
|
-
var emptyRefsObject = new
|
18090
|
+
var emptyRefsObject = new React3.Component().refs;
|
18091
18091
|
var didWarnAboutStateAssignmentForComponent;
|
18092
18092
|
var didWarnAboutUninitializedState;
|
18093
18093
|
var didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate;
|
@@ -18911,7 +18911,7 @@ var require_react_dom_development = __commonJS({
|
|
18911
18911
|
}
|
18912
18912
|
}
|
18913
18913
|
function updateFragment2(returnFiber, current2, fragment, lanes, key) {
|
18914
|
-
if (current2 === null || current2.tag !==
|
18914
|
+
if (current2 === null || current2.tag !== Fragment18) {
|
18915
18915
|
var created = createFiberFromFragment(fragment, returnFiber.mode, lanes, key);
|
18916
18916
|
created.return = returnFiber;
|
18917
18917
|
return created;
|
@@ -19314,7 +19314,7 @@ var require_react_dom_development = __commonJS({
|
|
19314
19314
|
if (child.key === key) {
|
19315
19315
|
var elementType = element.type;
|
19316
19316
|
if (elementType === REACT_FRAGMENT_TYPE) {
|
19317
|
-
if (child.tag ===
|
19317
|
+
if (child.tag === Fragment18) {
|
19318
19318
|
deleteRemainingChildren(returnFiber, child.sibling);
|
19319
19319
|
var existing = useFiber(child, element.props.children);
|
19320
19320
|
existing.return = returnFiber;
|
@@ -23489,7 +23489,7 @@ var require_react_dom_development = __commonJS({
|
|
23489
23489
|
var _resolvedProps2 = workInProgress2.elementType === type ? _unresolvedProps2 : resolveDefaultProps(type, _unresolvedProps2);
|
23490
23490
|
return updateForwardRef(current2, workInProgress2, type, _resolvedProps2, renderLanes2);
|
23491
23491
|
}
|
23492
|
-
case
|
23492
|
+
case Fragment18:
|
23493
23493
|
return updateFragment(current2, workInProgress2, renderLanes2);
|
23494
23494
|
case Mode:
|
23495
23495
|
return updateMode(current2, workInProgress2, renderLanes2);
|
@@ -23762,7 +23762,7 @@ var require_react_dom_development = __commonJS({
|
|
23762
23762
|
case SimpleMemoComponent:
|
23763
23763
|
case FunctionComponent:
|
23764
23764
|
case ForwardRef:
|
23765
|
-
case
|
23765
|
+
case Fragment18:
|
23766
23766
|
case Mode:
|
23767
23767
|
case Profiler:
|
23768
23768
|
case ContextConsumer:
|
@@ -28021,7 +28021,7 @@ var require_react_dom_development = __commonJS({
|
|
28021
28021
|
return fiber;
|
28022
28022
|
}
|
28023
28023
|
function createFiberFromFragment(elements, mode, lanes, key) {
|
28024
|
-
var fiber = createFiber(
|
28024
|
+
var fiber = createFiber(Fragment18, elements, key, mode);
|
28025
28025
|
fiber.lanes = lanes;
|
28026
28026
|
return fiber;
|
28027
28027
|
}
|
@@ -29314,7 +29314,7 @@ var defaultViewports = [
|
|
29314
29314
|
var import_ua_parser_js = require("ua-parser-js");
|
29315
29315
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
29316
29316
|
var defaultAppState = {
|
29317
|
-
data: { content: [], root: { props: {
|
29317
|
+
data: { content: [], root: { props: {} } },
|
29318
29318
|
ui: {
|
29319
29319
|
leftSideBarVisible: true,
|
29320
29320
|
rightSideBarVisible: true,
|
@@ -30528,7 +30528,7 @@ var IconButton = ({
|
|
30528
30528
|
|
30529
30529
|
// components/Puck/index.tsx
|
30530
30530
|
init_react_import();
|
30531
|
-
var
|
30531
|
+
var import_react29 = require("react");
|
30532
30532
|
|
30533
30533
|
// lib/use-placeholder-style.ts
|
30534
30534
|
init_react_import();
|
@@ -31213,7 +31213,7 @@ var useResolvedData = (appState, config, dispatch) => {
|
|
31213
31213
|
const [componentState, setComponentState] = (0, import_react13.useState)({});
|
31214
31214
|
const deferredSetStates = {};
|
31215
31215
|
const setComponentLoading = (0, import_react13.useCallback)(
|
31216
|
-
(id, loading,
|
31216
|
+
(id, loading, defer2 = 0) => {
|
31217
31217
|
if (deferredSetStates[id]) {
|
31218
31218
|
clearTimeout(deferredSetStates[id]);
|
31219
31219
|
delete deferredSetStates[id];
|
@@ -31223,7 +31223,7 @@ var useResolvedData = (appState, config, dispatch) => {
|
|
31223
31223
|
[id]: __spreadProps(__spreadValues({}, prev[id]), { loading })
|
31224
31224
|
}));
|
31225
31225
|
delete deferredSetStates[id];
|
31226
|
-
},
|
31226
|
+
}, defer2);
|
31227
31227
|
},
|
31228
31228
|
[]
|
31229
31229
|
);
|
@@ -31309,7 +31309,7 @@ var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
31309
31309
|
var getClassName9 = get_class_name_factory_default("MenuBar", styles_module_default7);
|
31310
31310
|
var MenuBar = ({
|
31311
31311
|
appState,
|
31312
|
-
data = { content: [], root: {
|
31312
|
+
data = { content: [], root: {} },
|
31313
31313
|
dispatch,
|
31314
31314
|
menuOpen = false,
|
31315
31315
|
onPublish,
|
@@ -31354,17 +31354,7 @@ var MenuBar = ({
|
|
31354
31354
|
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_jsx_runtime13.Fragment, { children: renderHeaderActions && renderHeaderActions({
|
31355
31355
|
state: appState,
|
31356
31356
|
dispatch
|
31357
|
-
}) })
|
31358
|
-
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
31359
|
-
Button,
|
31360
|
-
{
|
31361
|
-
onClick: () => {
|
31362
|
-
onPublish && onPublish(data);
|
31363
|
-
},
|
31364
|
-
icon: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Globe, { size: "14px" }),
|
31365
|
-
children: "Publish"
|
31366
|
-
}
|
31367
|
-
) })
|
31357
|
+
}) })
|
31368
31358
|
] })
|
31369
31359
|
}
|
31370
31360
|
);
|
@@ -32627,19 +32617,218 @@ var Components = () => {
|
|
32627
32617
|
|
32628
32618
|
// components/Puck/components/Preview/index.tsx
|
32629
32619
|
init_react_import();
|
32630
|
-
var
|
32631
|
-
|
32620
|
+
var import_react23 = require("react");
|
32621
|
+
|
32622
|
+
// components/AutoFrame/index.tsx
|
32623
|
+
init_react_import();
|
32624
|
+
var import_react22 = __toESM(require("react"));
|
32625
|
+
var import_react_frame_component = __toESM(require("react-frame-component"));
|
32626
|
+
var import_object_hash = __toESM(require("object-hash"));
|
32627
|
+
var import_jsx_runtime29 = require("react/jsx-runtime");
|
32628
|
+
var styleSelector = 'style, link[rel="stylesheet"]';
|
32629
|
+
var collectStyles = (doc) => {
|
32630
|
+
const collected = [];
|
32631
|
+
doc.head.querySelectorAll(styleSelector).forEach((style) => {
|
32632
|
+
collected.push(style);
|
32633
|
+
});
|
32634
|
+
return collected;
|
32635
|
+
};
|
32636
|
+
var getStyleSheet = (el) => {
|
32637
|
+
return Array.from(document.styleSheets).find((ss) => {
|
32638
|
+
const ownerNode = ss.ownerNode;
|
32639
|
+
return ownerNode.href === el.href;
|
32640
|
+
});
|
32641
|
+
};
|
32642
|
+
var getStyles = (styleSheet) => {
|
32643
|
+
if (styleSheet) {
|
32644
|
+
try {
|
32645
|
+
return [...styleSheet.cssRules].map((rule) => rule.cssText).join("");
|
32646
|
+
} catch (e) {
|
32647
|
+
console.warn(
|
32648
|
+
"Access to stylesheet %s is denied. Ignoring\u2026",
|
32649
|
+
styleSheet.href
|
32650
|
+
);
|
32651
|
+
}
|
32652
|
+
}
|
32653
|
+
return "";
|
32654
|
+
};
|
32655
|
+
var defer = (fn) => setTimeout(fn, 0);
|
32656
|
+
var CopyHostStyles = ({
|
32657
|
+
children,
|
32658
|
+
debug = false,
|
32659
|
+
onStylesLoaded = () => null
|
32660
|
+
}) => {
|
32661
|
+
const { document: doc, window: win } = (0, import_react_frame_component.useFrame)();
|
32662
|
+
(0, import_react22.useEffect)(() => {
|
32663
|
+
if (!win || !doc) {
|
32664
|
+
return () => {
|
32665
|
+
};
|
32666
|
+
}
|
32667
|
+
let elements = [];
|
32668
|
+
const hashes = {};
|
32669
|
+
const lookupEl = (el) => elements.findIndex((elementMap) => elementMap.original === el);
|
32670
|
+
const mirrorEl = (el, inlineStyles = false) => __async(void 0, null, function* () {
|
32671
|
+
let mirror;
|
32672
|
+
if (el.nodeName === "LINK" && inlineStyles) {
|
32673
|
+
mirror = document.createElement("style");
|
32674
|
+
mirror.type = "text/css";
|
32675
|
+
let styleSheet = getStyleSheet(el);
|
32676
|
+
if (!styleSheet) {
|
32677
|
+
yield new Promise((resolve) => {
|
32678
|
+
const fn = () => {
|
32679
|
+
resolve();
|
32680
|
+
el.removeEventListener("load", fn);
|
32681
|
+
};
|
32682
|
+
el.addEventListener("load", fn);
|
32683
|
+
});
|
32684
|
+
styleSheet = getStyleSheet(el);
|
32685
|
+
}
|
32686
|
+
const styles = getStyles(styleSheet);
|
32687
|
+
if (!styles) {
|
32688
|
+
if (debug) {
|
32689
|
+
console.warn(
|
32690
|
+
`Tried to load styles for link element, but couldn't find them. Skipping...`
|
32691
|
+
);
|
32692
|
+
}
|
32693
|
+
return;
|
32694
|
+
}
|
32695
|
+
mirror.innerHTML = styles;
|
32696
|
+
mirror.setAttribute("data-href", el.getAttribute("href"));
|
32697
|
+
} else {
|
32698
|
+
mirror = el.cloneNode(true);
|
32699
|
+
}
|
32700
|
+
return mirror;
|
32701
|
+
});
|
32702
|
+
const addEl = (el) => __async(void 0, null, function* () {
|
32703
|
+
const index = lookupEl(el);
|
32704
|
+
if (index > -1) {
|
32705
|
+
if (debug)
|
32706
|
+
console.log(
|
32707
|
+
`Tried to add an element that was already mirrored. Updating instead...`
|
32708
|
+
);
|
32709
|
+
elements[index].mirror.innerText = el.innerText;
|
32710
|
+
return;
|
32711
|
+
}
|
32712
|
+
const mirror = yield mirrorEl(el);
|
32713
|
+
if (!mirror) {
|
32714
|
+
return;
|
32715
|
+
}
|
32716
|
+
const elHash = (0, import_object_hash.default)(mirror.outerHTML);
|
32717
|
+
if (hashes[elHash]) {
|
32718
|
+
if (debug)
|
32719
|
+
console.log(
|
32720
|
+
`iframe already contains element that is being mirrored. Skipping...`
|
32721
|
+
);
|
32722
|
+
return;
|
32723
|
+
}
|
32724
|
+
hashes[elHash] = true;
|
32725
|
+
doc.head.append(mirror);
|
32726
|
+
elements.push({ original: el, mirror });
|
32727
|
+
if (debug)
|
32728
|
+
console.log(`Added style node ${el.outerHTML}`);
|
32729
|
+
});
|
32730
|
+
const removeEl = (el) => {
|
32731
|
+
var _a, _b;
|
32732
|
+
const index = lookupEl(el);
|
32733
|
+
if (index === -1) {
|
32734
|
+
if (debug)
|
32735
|
+
console.log(
|
32736
|
+
`Tried to remove an element that did not exist. Skipping...`
|
32737
|
+
);
|
32738
|
+
return;
|
32739
|
+
}
|
32740
|
+
const elHash = (0, import_object_hash.default)(el.outerHTML);
|
32741
|
+
(_b = (_a = elements[index]) == null ? void 0 : _a.mirror) == null ? void 0 : _b.remove();
|
32742
|
+
delete hashes[elHash];
|
32743
|
+
if (debug)
|
32744
|
+
console.log(`Removed style node ${el.outerHTML}`);
|
32745
|
+
};
|
32746
|
+
const observer = new MutationObserver((mutations) => {
|
32747
|
+
mutations.forEach((mutation) => {
|
32748
|
+
if (mutation.type === "childList") {
|
32749
|
+
mutation.addedNodes.forEach((node) => {
|
32750
|
+
if (node.nodeType === Node.TEXT_NODE || node.nodeType === Node.ELEMENT_NODE) {
|
32751
|
+
const el = node.nodeType === Node.TEXT_NODE ? node.parentElement : node;
|
32752
|
+
if (el && el.matches(styleSelector)) {
|
32753
|
+
defer(() => addEl(el));
|
32754
|
+
}
|
32755
|
+
}
|
32756
|
+
});
|
32757
|
+
mutation.removedNodes.forEach((node) => {
|
32758
|
+
if (node.nodeType === Node.TEXT_NODE || node.nodeType === Node.ELEMENT_NODE) {
|
32759
|
+
const el = node.nodeType === Node.TEXT_NODE ? node.parentElement : node;
|
32760
|
+
if (el && el.matches(styleSelector)) {
|
32761
|
+
defer(() => removeEl(el));
|
32762
|
+
}
|
32763
|
+
}
|
32764
|
+
});
|
32765
|
+
}
|
32766
|
+
});
|
32767
|
+
});
|
32768
|
+
const parentDocument = win.parent.document;
|
32769
|
+
const collectedStyles = collectStyles(parentDocument);
|
32770
|
+
const hrefs = [];
|
32771
|
+
let stylesLoaded = 0;
|
32772
|
+
Promise.all(
|
32773
|
+
collectedStyles.map((styleNode, i) => __async(void 0, null, function* () {
|
32774
|
+
if (styleNode.nodeName === "LINK") {
|
32775
|
+
const linkHref = styleNode.href;
|
32776
|
+
if (hrefs.indexOf(linkHref) > -1) {
|
32777
|
+
return;
|
32778
|
+
}
|
32779
|
+
hrefs.push(linkHref);
|
32780
|
+
}
|
32781
|
+
const mirror = yield mirrorEl(styleNode);
|
32782
|
+
if (!mirror)
|
32783
|
+
return;
|
32784
|
+
elements.push({ original: styleNode, mirror });
|
32785
|
+
return mirror;
|
32786
|
+
}))
|
32787
|
+
).then((mirrorStyles) => {
|
32788
|
+
const filtered = mirrorStyles.filter(
|
32789
|
+
(el) => typeof el !== "undefined"
|
32790
|
+
);
|
32791
|
+
filtered.forEach((mirror) => {
|
32792
|
+
mirror.onload = () => {
|
32793
|
+
stylesLoaded = stylesLoaded + 1;
|
32794
|
+
if (stylesLoaded >= elements.length) {
|
32795
|
+
onStylesLoaded();
|
32796
|
+
}
|
32797
|
+
};
|
32798
|
+
});
|
32799
|
+
doc.head.innerHTML = "";
|
32800
|
+
doc.head.append(...filtered);
|
32801
|
+
observer.observe(parentDocument.head, { childList: true, subtree: true });
|
32802
|
+
filtered.forEach((el) => {
|
32803
|
+
const elHash = (0, import_object_hash.default)(el.outerHTML);
|
32804
|
+
hashes[elHash] = true;
|
32805
|
+
});
|
32806
|
+
});
|
32807
|
+
return () => {
|
32808
|
+
observer.disconnect();
|
32809
|
+
};
|
32810
|
+
}, []);
|
32811
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_jsx_runtime29.Fragment, { children });
|
32812
|
+
};
|
32813
|
+
var AutoFrameComponent = import_react22.default.forwardRef(
|
32814
|
+
function(_a, ref) {
|
32815
|
+
var _b = _a, { children, debug, onStylesLoaded } = _b, props = __objRest(_b, ["children", "debug", "onStylesLoaded"]);
|
32816
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_react_frame_component.default, __spreadProps(__spreadValues({}, props), { ref, children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(CopyHostStyles, { debug, onStylesLoaded, children }) }));
|
32817
|
+
}
|
32818
|
+
);
|
32819
|
+
AutoFrameComponent.displayName = "AutoFrameComponent";
|
32820
|
+
var AutoFrame_default = AutoFrameComponent;
|
32632
32821
|
|
32633
32822
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Preview/styles.module.css#css-module
|
32634
32823
|
init_react_import();
|
32635
32824
|
var styles_module_default16 = { "PuckPreview": "_PuckPreview_rxwlr_1", "PuckPreview-frame": "_PuckPreview-frame_rxwlr_5" };
|
32636
32825
|
|
32637
32826
|
// components/Puck/components/Preview/index.tsx
|
32638
|
-
var
|
32827
|
+
var import_jsx_runtime30 = require("react/jsx-runtime");
|
32639
32828
|
var getClassName21 = get_class_name_factory_default("PuckPreview", styles_module_default16);
|
32640
32829
|
var Preview = ({ id = "puck-preview" }) => {
|
32641
32830
|
const { config, dispatch, state, setStatus, iframe } = useAppContext();
|
32642
|
-
const Page = (0,
|
32831
|
+
const Page = (0, import_react23.useCallback)(
|
32643
32832
|
(pageProps) => {
|
32644
32833
|
var _a, _b;
|
32645
32834
|
return ((_a = config.root) == null ? void 0 : _a.render) ? (_b = config.root) == null ? void 0 : _b.render(__spreadProps(__spreadValues({
|
@@ -32647,13 +32836,13 @@ var Preview = ({ id = "puck-preview" }) => {
|
|
32647
32836
|
}, pageProps), {
|
32648
32837
|
editMode: true,
|
32649
32838
|
puck: { renderDropZone: DropZone }
|
32650
|
-
})) : /* @__PURE__ */ (0,
|
32839
|
+
})) : /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_jsx_runtime30.Fragment, { children: pageProps.children });
|
32651
32840
|
},
|
32652
32841
|
[config.root]
|
32653
32842
|
);
|
32654
32843
|
const rootProps = state.data.root.props || state.data.root;
|
32655
|
-
const ref = (0,
|
32656
|
-
return /* @__PURE__ */ (0,
|
32844
|
+
const ref = (0, import_react23.useRef)(null);
|
32845
|
+
return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
32657
32846
|
"div",
|
32658
32847
|
{
|
32659
32848
|
className: getClassName21(),
|
@@ -32661,8 +32850,8 @@ var Preview = ({ id = "puck-preview" }) => {
|
|
32661
32850
|
onClick: () => {
|
32662
32851
|
dispatch({ type: "setUi", ui: __spreadProps(__spreadValues({}, state.ui), { itemSelector: null }) });
|
32663
32852
|
},
|
32664
|
-
children: iframe.enabled ? /* @__PURE__ */ (0,
|
32665
|
-
|
32853
|
+
children: iframe.enabled ? /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
32854
|
+
AutoFrame_default,
|
32666
32855
|
{
|
32667
32856
|
id: "preview-frame",
|
32668
32857
|
className: getClassName21("frame"),
|
@@ -32671,9 +32860,9 @@ var Preview = ({ id = "puck-preview" }) => {
|
|
32671
32860
|
onStylesLoaded: () => {
|
32672
32861
|
setStatus("READY");
|
32673
32862
|
},
|
32674
|
-
children: /* @__PURE__ */ (0,
|
32863
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Page, __spreadProps(__spreadValues({ dispatch, state }, rootProps), { children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(DropZone, { zone: rootDroppableId }) }))
|
32675
32864
|
}
|
32676
|
-
) : /* @__PURE__ */ (0,
|
32865
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("div", { id: "preview-frame", className: getClassName21("frame"), children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Page, __spreadProps(__spreadValues({ dispatch, state }, rootProps), { children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(DropZone, { zone: rootDroppableId }) })) })
|
32677
32866
|
}
|
32678
32867
|
);
|
32679
32868
|
};
|
@@ -32721,7 +32910,7 @@ var scrollIntoView = (el) => {
|
|
32721
32910
|
};
|
32722
32911
|
|
32723
32912
|
// components/LayerTree/index.tsx
|
32724
|
-
var
|
32913
|
+
var import_react24 = require("react");
|
32725
32914
|
|
32726
32915
|
// lib/is-child-of-zone.ts
|
32727
32916
|
init_react_import();
|
@@ -32735,7 +32924,7 @@ var isChildOfZone = (item, maybeChild, ctx) => {
|
|
32735
32924
|
};
|
32736
32925
|
|
32737
32926
|
// components/LayerTree/index.tsx
|
32738
|
-
var
|
32927
|
+
var import_jsx_runtime31 = require("react/jsx-runtime");
|
32739
32928
|
var getClassName22 = get_class_name_factory_default("LayerTree", styles_module_default17);
|
32740
32929
|
var getClassNameLayer = get_class_name_factory_default("Layer", styles_module_default17);
|
32741
32930
|
var LayerTree = ({
|
@@ -32748,15 +32937,15 @@ var LayerTree = ({
|
|
32748
32937
|
label
|
32749
32938
|
}) => {
|
32750
32939
|
const zones = data.zones || {};
|
32751
|
-
const ctx = (0,
|
32752
|
-
return /* @__PURE__ */ (0,
|
32753
|
-
label && /* @__PURE__ */ (0,
|
32754
|
-
/* @__PURE__ */ (0,
|
32940
|
+
const ctx = (0, import_react24.useContext)(dropZoneContext);
|
32941
|
+
return /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(import_jsx_runtime31.Fragment, { children: [
|
32942
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("div", { className: getClassName22("zoneTitle"), children: [
|
32943
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", { className: getClassName22("zoneIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(Layers, { size: "16" }) }),
|
32755
32944
|
" ",
|
32756
32945
|
label
|
32757
32946
|
] }),
|
32758
|
-
/* @__PURE__ */ (0,
|
32759
|
-
zoneContent.length === 0 && /* @__PURE__ */ (0,
|
32947
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("ul", { className: getClassName22(), children: [
|
32948
|
+
zoneContent.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", { className: getClassName22("helper"), children: "No items" }),
|
32760
32949
|
zoneContent.map((item, i) => {
|
32761
32950
|
var _a;
|
32762
32951
|
const isSelected = (itemSelector == null ? void 0 : itemSelector.index) === i && (itemSelector.zone === zone || itemSelector.zone === rootDroppableId && !zone);
|
@@ -32772,7 +32961,7 @@ var LayerTree = ({
|
|
32772
32961
|
const selectedItem = itemSelector && data ? getItem(itemSelector, data) : null;
|
32773
32962
|
const isHovering = hoveringComponent === item.props.id;
|
32774
32963
|
const childIsSelected = isChildOfZone(item, selectedItem, ctx);
|
32775
|
-
return /* @__PURE__ */ (0,
|
32964
|
+
return /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(
|
32776
32965
|
"li",
|
32777
32966
|
{
|
32778
32967
|
className: getClassNameLayer({
|
@@ -32782,7 +32971,7 @@ var LayerTree = ({
|
|
32782
32971
|
childIsSelected
|
32783
32972
|
}),
|
32784
32973
|
children: [
|
32785
|
-
/* @__PURE__ */ (0,
|
32974
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", { className: getClassNameLayer("inner"), children: /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(
|
32786
32975
|
"button",
|
32787
32976
|
{
|
32788
32977
|
className: getClassNameLayer("clickable"),
|
@@ -32814,22 +33003,22 @@ var LayerTree = ({
|
|
32814
33003
|
setHoveringComponent(null);
|
32815
33004
|
},
|
32816
33005
|
children: [
|
32817
|
-
containsZone && /* @__PURE__ */ (0,
|
33006
|
+
containsZone && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
32818
33007
|
"div",
|
32819
33008
|
{
|
32820
33009
|
className: getClassNameLayer("chevron"),
|
32821
33010
|
title: isSelected ? "Collapse" : "Expand",
|
32822
|
-
children: /* @__PURE__ */ (0,
|
33011
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(ChevronDown, { size: "12" })
|
32823
33012
|
}
|
32824
33013
|
),
|
32825
|
-
/* @__PURE__ */ (0,
|
32826
|
-
/* @__PURE__ */ (0,
|
32827
|
-
/* @__PURE__ */ (0,
|
33014
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("div", { className: getClassNameLayer("title"), children: [
|
33015
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", { className: getClassNameLayer("icon"), children: item.type === "Text" || item.type === "Heading" ? /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(Type, { size: "16" }) : /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(LayoutGrid, { size: "16" }) }),
|
33016
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", { className: getClassNameLayer("name"), children: (_a = config.components[item.type]["label"]) != null ? _a : item.type })
|
32828
33017
|
] })
|
32829
33018
|
]
|
32830
33019
|
}
|
32831
33020
|
) }),
|
32832
|
-
containsZone && Object.keys(zonesForItem).map((zoneKey, idx) => /* @__PURE__ */ (0,
|
33021
|
+
containsZone && Object.keys(zonesForItem).map((zoneKey, idx) => /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", { className: getClassNameLayer("zones"), children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
32833
33022
|
LayerTree,
|
32834
33023
|
{
|
32835
33024
|
config,
|
@@ -32851,13 +33040,13 @@ var LayerTree = ({
|
|
32851
33040
|
};
|
32852
33041
|
|
32853
33042
|
// components/Puck/components/Outline/index.tsx
|
32854
|
-
var
|
32855
|
-
var
|
33043
|
+
var import_react25 = require("react");
|
33044
|
+
var import_jsx_runtime32 = require("react/jsx-runtime");
|
32856
33045
|
var Outline = () => {
|
32857
33046
|
const { dispatch, state, overrides, config } = useAppContext();
|
32858
33047
|
const { data, ui } = state;
|
32859
33048
|
const { itemSelector } = ui;
|
32860
|
-
const setItemSelector = (0,
|
33049
|
+
const setItemSelector = (0, import_react25.useCallback)(
|
32861
33050
|
(newItemSelector) => {
|
32862
33051
|
dispatch({
|
32863
33052
|
type: "setUi",
|
@@ -32866,9 +33055,9 @@ var Outline = () => {
|
|
32866
33055
|
},
|
32867
33056
|
[]
|
32868
33057
|
);
|
32869
|
-
const Wrapper = (0,
|
32870
|
-
return /* @__PURE__ */ (0,
|
32871
|
-
(ctx == null ? void 0 : ctx.activeZones) && (ctx == null ? void 0 : ctx.activeZones[rootDroppableId]) && /* @__PURE__ */ (0,
|
33058
|
+
const Wrapper = (0, import_react25.useMemo)(() => overrides.outline || "div", [overrides]);
|
33059
|
+
return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Wrapper, { children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(dropZoneContext.Consumer, { children: (ctx) => /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)(import_jsx_runtime32.Fragment, { children: [
|
33060
|
+
(ctx == null ? void 0 : ctx.activeZones) && (ctx == null ? void 0 : ctx.activeZones[rootDroppableId]) && /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
32872
33061
|
LayerTree,
|
32873
33062
|
{
|
32874
33063
|
config,
|
@@ -32881,7 +33070,7 @@ var Outline = () => {
|
|
32881
33070
|
),
|
32882
33071
|
Object.entries(findZonesForArea(data, "root")).map(
|
32883
33072
|
([zoneKey, zone]) => {
|
32884
|
-
return /* @__PURE__ */ (0,
|
33073
|
+
return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
32885
33074
|
LayerTree,
|
32886
33075
|
{
|
32887
33076
|
config,
|
@@ -32966,12 +33155,12 @@ function usePuckHistory({
|
|
32966
33155
|
|
32967
33156
|
// lib/use-history-store.ts
|
32968
33157
|
init_react_import();
|
32969
|
-
var
|
33158
|
+
var import_react26 = require("react");
|
32970
33159
|
var import_use_debounce3 = require("use-debounce");
|
32971
33160
|
var EMPTY_HISTORY_INDEX = -1;
|
32972
33161
|
function useHistoryStore() {
|
32973
|
-
const [histories, setHistories] = (0,
|
32974
|
-
const [index, setIndex] = (0,
|
33162
|
+
const [histories, setHistories] = (0, import_react26.useState)([]);
|
33163
|
+
const [index, setIndex] = (0, import_react26.useState)(EMPTY_HISTORY_INDEX);
|
32975
33164
|
const hasPast = index > EMPTY_HISTORY_INDEX;
|
32976
33165
|
const hasFuture = index < histories.length - 1;
|
32977
33166
|
const currentHistory = histories[index];
|
@@ -33131,22 +33320,22 @@ var getBox = function getBox2(el) {
|
|
33131
33320
|
};
|
33132
33321
|
|
33133
33322
|
// components/Puck/components/Canvas/index.tsx
|
33134
|
-
var
|
33323
|
+
var import_react28 = require("react");
|
33135
33324
|
|
33136
33325
|
// components/ViewportControls/index.tsx
|
33137
33326
|
init_react_import();
|
33138
|
-
var
|
33327
|
+
var import_react27 = require("react");
|
33139
33328
|
|
33140
33329
|
// css-module:/home/runner/work/puck/puck/packages/core/components/ViewportControls/styles.module.css#css-module
|
33141
33330
|
init_react_import();
|
33142
33331
|
var styles_module_default18 = { "ViewportControls": "_ViewportControls_3zdvn_1", "ViewportControls-divider": "_ViewportControls-divider_3zdvn_15", "ViewportControls-zoomSelect": "_ViewportControls-zoomSelect_3zdvn_21", "ViewportButton--isActive": "_ViewportButton--isActive_3zdvn_33", "ViewportButton-inner": "_ViewportButton-inner_3zdvn_33" };
|
33143
33332
|
|
33144
33333
|
// components/ViewportControls/index.tsx
|
33145
|
-
var
|
33334
|
+
var import_jsx_runtime33 = require("react/jsx-runtime");
|
33146
33335
|
var icons = {
|
33147
|
-
Smartphone: /* @__PURE__ */ (0,
|
33148
|
-
Tablet: /* @__PURE__ */ (0,
|
33149
|
-
Monitor: /* @__PURE__ */ (0,
|
33336
|
+
Smartphone: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Smartphone, { size: 16 }),
|
33337
|
+
Tablet: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Tablet, { size: 16 }),
|
33338
|
+
Monitor: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Monitor, { size: 16 })
|
33150
33339
|
};
|
33151
33340
|
var getClassName23 = get_class_name_factory_default("ViewportControls", styles_module_default18);
|
33152
33341
|
var getClassNameButton = get_class_name_factory_default("ViewportButton", styles_module_default18);
|
@@ -33158,11 +33347,11 @@ var ViewportButton = ({
|
|
33158
33347
|
onClick
|
33159
33348
|
}) => {
|
33160
33349
|
const { state } = useAppContext();
|
33161
|
-
const [isActive, setIsActive] = (0,
|
33162
|
-
(0,
|
33350
|
+
const [isActive, setIsActive] = (0, import_react27.useState)(false);
|
33351
|
+
(0, import_react27.useEffect)(() => {
|
33163
33352
|
setIsActive(width === state.ui.viewports.current.width);
|
33164
33353
|
}, [width, state.ui.viewports.current.width]);
|
33165
|
-
return /* @__PURE__ */ (0,
|
33354
|
+
return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("span", { className: getClassNameButton({ isActive }), children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
33166
33355
|
IconButton,
|
33167
33356
|
{
|
33168
33357
|
title,
|
@@ -33171,7 +33360,7 @@ var ViewportButton = ({
|
|
33171
33360
|
e.stopPropagation();
|
33172
33361
|
onClick({ width, height });
|
33173
33362
|
},
|
33174
|
-
children: /* @__PURE__ */ (0,
|
33363
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("span", { className: getClassNameButton("inner"), children })
|
33175
33364
|
}
|
33176
33365
|
) });
|
33177
33366
|
};
|
@@ -33195,7 +33384,7 @@ var ViewportControls = ({
|
|
33195
33384
|
const defaultsContainAutoZoom = defaultZoomOptions.find(
|
33196
33385
|
(option) => option.value === autoZoom
|
33197
33386
|
);
|
33198
|
-
const zoomOptions = (0,
|
33387
|
+
const zoomOptions = (0, import_react27.useMemo)(
|
33199
33388
|
() => [
|
33200
33389
|
...defaultZoomOptions,
|
33201
33390
|
...defaultsContainAutoZoom ? [] : [
|
@@ -33207,8 +33396,8 @@ var ViewportControls = ({
|
|
33207
33396
|
].filter((a) => a.value <= autoZoom).sort((a, b) => a.value > b.value ? 1 : -1),
|
33208
33397
|
[autoZoom]
|
33209
33398
|
);
|
33210
|
-
return /* @__PURE__ */ (0,
|
33211
|
-
viewports.map((viewport, i) => /* @__PURE__ */ (0,
|
33399
|
+
return /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { className: getClassName23(), children: [
|
33400
|
+
viewports.map((viewport, i) => /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
33212
33401
|
ViewportButton,
|
33213
33402
|
{
|
33214
33403
|
height: viewport.height,
|
@@ -33219,8 +33408,8 @@ var ViewportControls = ({
|
|
33219
33408
|
},
|
33220
33409
|
i
|
33221
33410
|
)),
|
33222
|
-
/* @__PURE__ */ (0,
|
33223
|
-
/* @__PURE__ */ (0,
|
33411
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)("div", { className: getClassName23("divider") }),
|
33412
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
33224
33413
|
IconButton,
|
33225
33414
|
{
|
33226
33415
|
title: "Zoom viewport out",
|
@@ -33234,10 +33423,10 @@ var ViewportControls = ({
|
|
33234
33423
|
)].value
|
33235
33424
|
);
|
33236
33425
|
},
|
33237
|
-
children: /* @__PURE__ */ (0,
|
33426
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(ZoomOut, { size: 16 })
|
33238
33427
|
}
|
33239
33428
|
),
|
33240
|
-
/* @__PURE__ */ (0,
|
33429
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
33241
33430
|
IconButton,
|
33242
33431
|
{
|
33243
33432
|
title: "Zoom viewport in",
|
@@ -33251,11 +33440,11 @@ var ViewportControls = ({
|
|
33251
33440
|
)].value
|
33252
33441
|
);
|
33253
33442
|
},
|
33254
|
-
children: /* @__PURE__ */ (0,
|
33443
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(ZoomIn, { size: 16 })
|
33255
33444
|
}
|
33256
33445
|
),
|
33257
|
-
/* @__PURE__ */ (0,
|
33258
|
-
/* @__PURE__ */ (0,
|
33446
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)("div", { className: getClassName23("divider") }),
|
33447
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
33259
33448
|
"select",
|
33260
33449
|
{
|
33261
33450
|
className: getClassName23("zoomSelect"),
|
@@ -33263,7 +33452,7 @@ var ViewportControls = ({
|
|
33263
33452
|
onChange: (e) => {
|
33264
33453
|
onZoom(parseFloat(e.currentTarget.value));
|
33265
33454
|
},
|
33266
|
-
children: zoomOptions.map((option) => /* @__PURE__ */ (0,
|
33455
|
+
children: zoomOptions.map((option) => /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
33267
33456
|
"option",
|
33268
33457
|
{
|
33269
33458
|
value: option.value,
|
@@ -33311,24 +33500,24 @@ var getZoomConfig = (uiViewport, frame, zoom) => {
|
|
33311
33500
|
};
|
33312
33501
|
|
33313
33502
|
// components/Puck/components/Canvas/index.tsx
|
33314
|
-
var
|
33503
|
+
var import_jsx_runtime34 = require("react/jsx-runtime");
|
33315
33504
|
var getClassName24 = get_class_name_factory_default("PuckCanvas", styles_module_default19);
|
33316
33505
|
var ZOOM_ON_CHANGE = true;
|
33317
33506
|
var Canvas = () => {
|
33318
33507
|
const { status, iframe } = useAppContext();
|
33319
33508
|
const { dispatch, state, overrides, setUi, zoomConfig, setZoomConfig } = useAppContext();
|
33320
33509
|
const { ui } = state;
|
33321
|
-
const frameRef = (0,
|
33322
|
-
const [showTransition, setShowTransition] = (0,
|
33323
|
-
const defaultRender = (0,
|
33324
|
-
const PuckDefault = ({ children }) => /* @__PURE__ */ (0,
|
33510
|
+
const frameRef = (0, import_react28.useRef)(null);
|
33511
|
+
const [showTransition, setShowTransition] = (0, import_react28.useState)(false);
|
33512
|
+
const defaultRender = (0, import_react28.useMemo)(() => {
|
33513
|
+
const PuckDefault = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_jsx_runtime34.Fragment, { children });
|
33325
33514
|
return PuckDefault;
|
33326
33515
|
}, []);
|
33327
|
-
const CustomPreview = (0,
|
33516
|
+
const CustomPreview = (0, import_react28.useMemo)(
|
33328
33517
|
() => overrides.preview || defaultRender,
|
33329
33518
|
[overrides]
|
33330
33519
|
);
|
33331
|
-
const getFrameDimensions = (0,
|
33520
|
+
const getFrameDimensions = (0, import_react28.useCallback)(() => {
|
33332
33521
|
if (frameRef.current) {
|
33333
33522
|
const frame = frameRef.current;
|
33334
33523
|
const box = getBox(frame);
|
@@ -33336,7 +33525,7 @@ var Canvas = () => {
|
|
33336
33525
|
}
|
33337
33526
|
return { width: 0, height: 0 };
|
33338
33527
|
}, [frameRef]);
|
33339
|
-
const resetAutoZoom = (0,
|
33528
|
+
const resetAutoZoom = (0, import_react28.useCallback)(
|
33340
33529
|
(ui2 = state.ui) => {
|
33341
33530
|
if (frameRef.current) {
|
33342
33531
|
setZoomConfig(
|
@@ -33346,11 +33535,11 @@ var Canvas = () => {
|
|
33346
33535
|
},
|
33347
33536
|
[frameRef, zoomConfig, state.ui]
|
33348
33537
|
);
|
33349
|
-
(0,
|
33538
|
+
(0, import_react28.useEffect)(() => {
|
33350
33539
|
setShowTransition(false);
|
33351
33540
|
resetAutoZoom();
|
33352
33541
|
}, [frameRef, ui.leftSideBarVisible, ui.rightSideBarVisible]);
|
33353
|
-
(0,
|
33542
|
+
(0, import_react28.useEffect)(() => {
|
33354
33543
|
const { height: frameHeight } = getFrameDimensions();
|
33355
33544
|
if (ui.viewports.current.height === "auto") {
|
33356
33545
|
setZoomConfig(__spreadProps(__spreadValues({}, zoomConfig), {
|
@@ -33358,7 +33547,7 @@ var Canvas = () => {
|
|
33358
33547
|
}));
|
33359
33548
|
}
|
33360
33549
|
}, [zoomConfig.zoom]);
|
33361
|
-
(0,
|
33550
|
+
(0, import_react28.useEffect)(() => {
|
33362
33551
|
const observer = new ResizeObserver(() => {
|
33363
33552
|
setShowTransition(false);
|
33364
33553
|
resetAutoZoom();
|
@@ -33370,7 +33559,7 @@ var Canvas = () => {
|
|
33370
33559
|
observer.disconnect();
|
33371
33560
|
};
|
33372
33561
|
}, []);
|
33373
|
-
return /* @__PURE__ */ (0,
|
33562
|
+
return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(
|
33374
33563
|
"div",
|
33375
33564
|
{
|
33376
33565
|
className: getClassName24({
|
@@ -33382,7 +33571,7 @@ var Canvas = () => {
|
|
33382
33571
|
recordHistory: true
|
33383
33572
|
}),
|
33384
33573
|
children: [
|
33385
|
-
ui.viewports.controlsVisible && iframe.enabled && /* @__PURE__ */ (0,
|
33574
|
+
ui.viewports.controlsVisible && iframe.enabled && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: getClassName24("controls"), children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
33386
33575
|
ViewportControls,
|
33387
33576
|
{
|
33388
33577
|
autoZoom: zoomConfig.autoZoom,
|
@@ -33407,7 +33596,7 @@ var Canvas = () => {
|
|
33407
33596
|
}
|
33408
33597
|
}
|
33409
33598
|
) }),
|
33410
|
-
/* @__PURE__ */ (0,
|
33599
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: getClassName24("inner"), ref: frameRef, children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
33411
33600
|
"div",
|
33412
33601
|
{
|
33413
33602
|
className: getClassName24("root"),
|
@@ -33419,7 +33608,7 @@ var Canvas = () => {
|
|
33419
33608
|
overflow: iframe.enabled ? void 0 : "auto"
|
33420
33609
|
},
|
33421
33610
|
suppressHydrationWarning: true,
|
33422
|
-
children: /* @__PURE__ */ (0,
|
33611
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(CustomPreview, { children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Preview, {}) })
|
33423
33612
|
}
|
33424
33613
|
) })
|
33425
33614
|
]
|
@@ -33428,12 +33617,12 @@ var Canvas = () => {
|
|
33428
33617
|
};
|
33429
33618
|
|
33430
33619
|
// components/Puck/index.tsx
|
33431
|
-
var
|
33620
|
+
var import_jsx_runtime35 = require("react/jsx-runtime");
|
33432
33621
|
var getClassName25 = get_class_name_factory_default("Puck", styles_module_default8);
|
33433
33622
|
function Puck({
|
33434
33623
|
children,
|
33435
33624
|
config,
|
33436
|
-
data: initialData = { content: [], root: {
|
33625
|
+
data: initialData = { content: [], root: {} },
|
33437
33626
|
ui: initialUi,
|
33438
33627
|
onChange,
|
33439
33628
|
onPublish,
|
@@ -33451,11 +33640,11 @@ function Puck({
|
|
33451
33640
|
}) {
|
33452
33641
|
var _a;
|
33453
33642
|
const historyStore = useHistoryStore();
|
33454
|
-
const [reducer] = (0,
|
33643
|
+
const [reducer] = (0, import_react29.useState)(
|
33455
33644
|
() => createReducer({ config, record: historyStore.record })
|
33456
33645
|
);
|
33457
|
-
const [initialAppState] = (0,
|
33458
|
-
var _a2, _b, _c, _d;
|
33646
|
+
const [initialAppState] = (0, import_react29.useState)(() => {
|
33647
|
+
var _a2, _b, _c, _d, _e, _f;
|
33459
33648
|
const initial = __spreadValues(__spreadValues({}, defaultAppState.ui), initialUi);
|
33460
33649
|
let clientUiState = {};
|
33461
33650
|
if (typeof window !== "undefined") {
|
@@ -33482,8 +33671,13 @@ function Puck({
|
|
33482
33671
|
};
|
33483
33672
|
}
|
33484
33673
|
}
|
33674
|
+
const rootProps2 = ((_e = initialData == null ? void 0 : initialData.root) == null ? void 0 : _e.props) || initialData.root || {};
|
33675
|
+
const defaultedRootProps = __spreadValues(__spreadValues({}, (_f = config.root) == null ? void 0 : _f.defaultProps), rootProps2);
|
33485
33676
|
return __spreadProps(__spreadValues({}, defaultAppState), {
|
33486
|
-
data: initialData,
|
33677
|
+
data: __spreadProps(__spreadValues({}, initialData), {
|
33678
|
+
root: defaultedRootProps,
|
33679
|
+
content: initialData.content || []
|
33680
|
+
}),
|
33487
33681
|
ui: __spreadProps(__spreadValues(__spreadValues({}, initial), clientUiState), {
|
33488
33682
|
// Store categories under componentList on state to allow render functions and plugins to modify
|
33489
33683
|
componentList: config.categories ? Object.entries(config.categories).reduce(
|
@@ -33502,7 +33696,7 @@ function Puck({
|
|
33502
33696
|
})
|
33503
33697
|
});
|
33504
33698
|
});
|
33505
|
-
const [appState, dispatch] = (0,
|
33699
|
+
const [appState, dispatch] = (0, import_react29.useReducer)(
|
33506
33700
|
reducer,
|
33507
33701
|
flushZones(initialAppState)
|
33508
33702
|
);
|
@@ -33513,9 +33707,9 @@ function Puck({
|
|
33513
33707
|
config,
|
33514
33708
|
dispatch
|
33515
33709
|
);
|
33516
|
-
const [menuOpen, setMenuOpen] = (0,
|
33710
|
+
const [menuOpen, setMenuOpen] = (0, import_react29.useState)(false);
|
33517
33711
|
const { itemSelector, leftSideBarVisible, rightSideBarVisible } = ui;
|
33518
|
-
const setItemSelector = (0,
|
33712
|
+
const setItemSelector = (0, import_react29.useCallback)(
|
33519
33713
|
(newItemSelector) => {
|
33520
33714
|
if (newItemSelector === itemSelector)
|
33521
33715
|
return;
|
@@ -33528,21 +33722,21 @@ function Puck({
|
|
33528
33722
|
[itemSelector]
|
33529
33723
|
);
|
33530
33724
|
const selectedItem = itemSelector ? getItem(itemSelector, data) : null;
|
33531
|
-
(0,
|
33725
|
+
(0, import_react29.useEffect)(() => {
|
33532
33726
|
if (onChange)
|
33533
33727
|
onChange(data);
|
33534
33728
|
}, [data]);
|
33535
33729
|
const { onDragStartOrUpdate, placeholderStyle } = usePlaceholderStyle();
|
33536
|
-
const [draggedItem, setDraggedItem] = (0,
|
33730
|
+
const [draggedItem, setDraggedItem] = (0, import_react29.useState)();
|
33537
33731
|
const rootProps = data.root.props || data.root;
|
33538
|
-
(0,
|
33732
|
+
(0, import_react29.useEffect)(() => {
|
33539
33733
|
if (Object.keys(data.root).length > 0 && !data.root.props) {
|
33540
33734
|
console.error(
|
33541
33735
|
"Warning: Defining props on `root` is deprecated. Please use `root.props`. This will be a breaking change in a future release."
|
33542
33736
|
);
|
33543
33737
|
}
|
33544
33738
|
}, []);
|
33545
|
-
const toggleSidebars = (0,
|
33739
|
+
const toggleSidebars = (0, import_react29.useCallback)(
|
33546
33740
|
(sidebar) => {
|
33547
33741
|
const widerViewport = window.matchMedia("(min-width: 638px)").matches;
|
33548
33742
|
const sideBarVisible = sidebar === "left" ? leftSideBarVisible : rightSideBarVisible;
|
@@ -33556,7 +33750,7 @@ function Puck({
|
|
33556
33750
|
},
|
33557
33751
|
[dispatch, leftSideBarVisible, rightSideBarVisible]
|
33558
33752
|
);
|
33559
|
-
(0,
|
33753
|
+
(0, import_react29.useEffect)(() => {
|
33560
33754
|
if (!window.matchMedia("(min-width: 638px)").matches) {
|
33561
33755
|
dispatch({
|
33562
33756
|
type: "setUi",
|
@@ -33579,11 +33773,11 @@ function Puck({
|
|
33579
33773
|
window.removeEventListener("resize", handleResize);
|
33580
33774
|
};
|
33581
33775
|
}, []);
|
33582
|
-
const defaultRender = (0,
|
33583
|
-
const PuckDefault = ({ children: children2 }) => /* @__PURE__ */ (0,
|
33776
|
+
const defaultRender = (0, import_react29.useMemo)(() => {
|
33777
|
+
const PuckDefault = ({ children: children2 }) => /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(import_jsx_runtime35.Fragment, { children: children2 });
|
33584
33778
|
return PuckDefault;
|
33585
33779
|
}, []);
|
33586
|
-
const defaultHeaderRender = (0,
|
33780
|
+
const defaultHeaderRender = (0, import_react29.useMemo)(() => {
|
33587
33781
|
if (renderHeader) {
|
33588
33782
|
console.warn(
|
33589
33783
|
"`renderHeader` is deprecated. Please use `overrides.header` and the `usePuck` hook instead"
|
@@ -33591,45 +33785,45 @@ function Puck({
|
|
33591
33785
|
const RenderHeader = (_a2) => {
|
33592
33786
|
var _b = _a2, { actions } = _b, props = __objRest(_b, ["actions"]);
|
33593
33787
|
const Comp = renderHeader;
|
33594
|
-
return /* @__PURE__ */ (0,
|
33788
|
+
return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState, children: actions }));
|
33595
33789
|
};
|
33596
33790
|
return RenderHeader;
|
33597
33791
|
}
|
33598
33792
|
return defaultRender;
|
33599
33793
|
}, [renderHeader]);
|
33600
|
-
const defaultHeaderActionsRender = (0,
|
33794
|
+
const defaultHeaderActionsRender = (0, import_react29.useMemo)(() => {
|
33601
33795
|
if (renderHeaderActions) {
|
33602
33796
|
console.warn(
|
33603
33797
|
"`renderHeaderActions` is deprecated. Please use `overrides.headerActions` and the `usePuck` hook instead."
|
33604
33798
|
);
|
33605
33799
|
const RenderHeader = (props) => {
|
33606
33800
|
const Comp = renderHeaderActions;
|
33607
|
-
return /* @__PURE__ */ (0,
|
33801
|
+
return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState }));
|
33608
33802
|
};
|
33609
33803
|
return RenderHeader;
|
33610
33804
|
}
|
33611
33805
|
return defaultRender;
|
33612
33806
|
}, [renderHeader]);
|
33613
|
-
const loadedOverrides = (0,
|
33807
|
+
const loadedOverrides = (0, import_react29.useMemo)(() => {
|
33614
33808
|
return loadOverrides({ overrides, plugins });
|
33615
33809
|
}, [plugins]);
|
33616
|
-
const CustomPuck = (0,
|
33810
|
+
const CustomPuck = (0, import_react29.useMemo)(
|
33617
33811
|
() => loadedOverrides.puck || defaultRender,
|
33618
33812
|
[loadedOverrides]
|
33619
33813
|
);
|
33620
|
-
const CustomHeader = (0,
|
33814
|
+
const CustomHeader = (0, import_react29.useMemo)(
|
33621
33815
|
() => loadedOverrides.header || defaultHeaderRender,
|
33622
33816
|
[loadedOverrides]
|
33623
33817
|
);
|
33624
|
-
const CustomHeaderActions = (0,
|
33818
|
+
const CustomHeaderActions = (0, import_react29.useMemo)(
|
33625
33819
|
() => loadedOverrides.headerActions || defaultHeaderActionsRender,
|
33626
33820
|
[loadedOverrides]
|
33627
33821
|
);
|
33628
|
-
const [mounted, setMounted] = (0,
|
33629
|
-
(0,
|
33822
|
+
const [mounted, setMounted] = (0, import_react29.useState)(false);
|
33823
|
+
(0, import_react29.useEffect)(() => {
|
33630
33824
|
setMounted(true);
|
33631
33825
|
}, []);
|
33632
|
-
return /* @__PURE__ */ (0,
|
33826
|
+
return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: "Puck", children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
33633
33827
|
AppProvider,
|
33634
33828
|
{
|
33635
33829
|
value: {
|
@@ -33644,7 +33838,7 @@ function Puck({
|
|
33644
33838
|
viewports,
|
33645
33839
|
iframe
|
33646
33840
|
},
|
33647
|
-
children: /* @__PURE__ */ (0,
|
33841
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
33648
33842
|
DragDropContext,
|
33649
33843
|
{
|
33650
33844
|
autoScrollerOptions: { disabled: dnd == null ? void 0 : dnd.disableAutoScroll },
|
@@ -33700,7 +33894,7 @@ function Puck({
|
|
33700
33894
|
});
|
33701
33895
|
}
|
33702
33896
|
},
|
33703
|
-
children: /* @__PURE__ */ (0,
|
33897
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
33704
33898
|
DropZoneProvider,
|
33705
33899
|
{
|
33706
33900
|
value: {
|
@@ -33714,7 +33908,7 @@ function Puck({
|
|
33714
33908
|
mode: "edit",
|
33715
33909
|
areaId: "root"
|
33716
33910
|
},
|
33717
|
-
children: /* @__PURE__ */ (0,
|
33911
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(CustomPuck, { children: children || /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(
|
33718
33912
|
"div",
|
33719
33913
|
{
|
33720
33914
|
className: getClassName25({
|
@@ -33724,65 +33918,62 @@ function Puck({
|
|
33724
33918
|
rightSideBarVisible
|
33725
33919
|
}),
|
33726
33920
|
children: [
|
33727
|
-
/* @__PURE__ */ (0,
|
33728
|
-
/* @__PURE__ */ (0,
|
33921
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { className: getClassName25("layout"), children: [
|
33922
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
33729
33923
|
CustomHeader,
|
33730
33924
|
{
|
33731
|
-
actions: /* @__PURE__ */ (0,
|
33732
|
-
|
33733
|
-
|
33734
|
-
|
33735
|
-
|
33736
|
-
|
33737
|
-
|
33738
|
-
|
33739
|
-
|
33740
|
-
|
33741
|
-
|
33742
|
-
)
|
33743
|
-
|
33744
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("header", { className: getClassName25("header"), children: /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("div", { className: getClassName25("headerInner"), children: [
|
33745
|
-
/* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("div", { className: getClassName25("headerToggle"), children: [
|
33746
|
-
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: getClassName25("leftSideBarToggle"), children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
33925
|
+
actions: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(import_jsx_runtime35.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(CustomHeaderActions, { children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
33926
|
+
Button,
|
33927
|
+
{
|
33928
|
+
onClick: () => {
|
33929
|
+
onPublish && onPublish(data);
|
33930
|
+
},
|
33931
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Globe, { size: "14px" }),
|
33932
|
+
children: "Publish"
|
33933
|
+
}
|
33934
|
+
) }) }),
|
33935
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("header", { className: getClassName25("header"), children: /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { className: getClassName25("headerInner"), children: [
|
33936
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { className: getClassName25("headerToggle"), children: [
|
33937
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: getClassName25("leftSideBarToggle"), children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
33747
33938
|
IconButton,
|
33748
33939
|
{
|
33749
33940
|
onClick: () => {
|
33750
33941
|
toggleSidebars("left");
|
33751
33942
|
},
|
33752
33943
|
title: "Toggle left sidebar",
|
33753
|
-
children: /* @__PURE__ */ (0,
|
33944
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(PanelLeft, { focusable: "false" })
|
33754
33945
|
}
|
33755
33946
|
) }),
|
33756
|
-
/* @__PURE__ */ (0,
|
33947
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: getClassName25("rightSideBarToggle"), children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
33757
33948
|
IconButton,
|
33758
33949
|
{
|
33759
33950
|
onClick: () => {
|
33760
33951
|
toggleSidebars("right");
|
33761
33952
|
},
|
33762
33953
|
title: "Toggle right sidebar",
|
33763
|
-
children: /* @__PURE__ */ (0,
|
33954
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(PanelRight, { focusable: "false" })
|
33764
33955
|
}
|
33765
33956
|
) })
|
33766
33957
|
] }),
|
33767
|
-
/* @__PURE__ */ (0,
|
33958
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: getClassName25("headerTitle"), children: /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(Heading, { rank: 2, size: "xs", children: [
|
33768
33959
|
headerTitle || rootProps.title || "Page",
|
33769
|
-
headerPath && /* @__PURE__ */ (0,
|
33960
|
+
headerPath && /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(import_jsx_runtime35.Fragment, { children: [
|
33770
33961
|
" ",
|
33771
|
-
/* @__PURE__ */ (0,
|
33962
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)("code", { className: getClassName25("headerPath"), children: headerPath })
|
33772
33963
|
] })
|
33773
33964
|
] }) }),
|
33774
|
-
/* @__PURE__ */ (0,
|
33775
|
-
/* @__PURE__ */ (0,
|
33965
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { className: getClassName25("headerTools"), children: [
|
33966
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: getClassName25("menuButton"), children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
33776
33967
|
IconButton,
|
33777
33968
|
{
|
33778
33969
|
onClick: () => {
|
33779
33970
|
return setMenuOpen(!menuOpen);
|
33780
33971
|
},
|
33781
33972
|
title: "Toggle menu bar",
|
33782
|
-
children: menuOpen ? /* @__PURE__ */ (0,
|
33973
|
+
children: menuOpen ? /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(ChevronUp, { focusable: "false" }) : /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(ChevronDown, { focusable: "false" })
|
33783
33974
|
}
|
33784
33975
|
) }),
|
33785
|
-
/* @__PURE__ */ (0,
|
33976
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
33786
33977
|
MenuBar,
|
33787
33978
|
{
|
33788
33979
|
appState,
|
@@ -33790,7 +33981,16 @@ function Puck({
|
|
33790
33981
|
dispatch,
|
33791
33982
|
onPublish,
|
33792
33983
|
menuOpen,
|
33793
|
-
renderHeaderActions: () => /* @__PURE__ */ (0,
|
33984
|
+
renderHeaderActions: () => /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(CustomHeaderActions, { children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
33985
|
+
Button,
|
33986
|
+
{
|
33987
|
+
onClick: () => {
|
33988
|
+
onPublish && onPublish(data);
|
33989
|
+
},
|
33990
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Globe, { size: "14px" }),
|
33991
|
+
children: "Publish"
|
33992
|
+
}
|
33993
|
+
) }),
|
33794
33994
|
setMenuOpen
|
33795
33995
|
}
|
33796
33996
|
)
|
@@ -33798,23 +33998,23 @@ function Puck({
|
|
33798
33998
|
] }) })
|
33799
33999
|
}
|
33800
34000
|
),
|
33801
|
-
/* @__PURE__ */ (0,
|
33802
|
-
/* @__PURE__ */ (0,
|
33803
|
-
/* @__PURE__ */ (0,
|
34001
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { className: getClassName25("leftSideBar"), children: [
|
34002
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)(SidebarSection, { title: "Components", noBorderTop: true, children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Components, {}) }),
|
34003
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)(SidebarSection, { title: "Outline", children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Outline, {}) })
|
33804
34004
|
] }),
|
33805
|
-
/* @__PURE__ */ (0,
|
33806
|
-
/* @__PURE__ */ (0,
|
34005
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Canvas, {}),
|
34006
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: getClassName25("rightSideBar"), children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
33807
34007
|
SidebarSection,
|
33808
34008
|
{
|
33809
34009
|
noPadding: true,
|
33810
34010
|
noBorderTop: true,
|
33811
34011
|
showBreadcrumbs: true,
|
33812
34012
|
title: selectedItem ? (_a = config.components[selectedItem.type]["label"]) != null ? _a : selectedItem.type : "Page",
|
33813
|
-
children: /* @__PURE__ */ (0,
|
34013
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Fields, {})
|
33814
34014
|
}
|
33815
34015
|
) })
|
33816
34016
|
] }),
|
33817
|
-
/* @__PURE__ */ (0,
|
34017
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
33818
34018
|
"div",
|
33819
34019
|
{
|
33820
34020
|
id: "puck-portal-root",
|
@@ -33838,16 +34038,20 @@ Puck.Preview = Preview;
|
|
33838
34038
|
|
33839
34039
|
// components/Render/index.tsx
|
33840
34040
|
init_react_import();
|
33841
|
-
var
|
34041
|
+
var import_jsx_runtime36 = require("react/jsx-runtime");
|
33842
34042
|
function Render({
|
33843
34043
|
config,
|
33844
34044
|
data
|
33845
34045
|
}) {
|
33846
34046
|
var _a;
|
33847
|
-
const
|
34047
|
+
const defaultedData = __spreadProps(__spreadValues({}, data), {
|
34048
|
+
root: data.root || {},
|
34049
|
+
content: data.content || []
|
34050
|
+
});
|
34051
|
+
const rootProps = defaultedData.root.props || defaultedData.root;
|
33848
34052
|
const title = (rootProps == null ? void 0 : rootProps.title) || "";
|
33849
34053
|
if ((_a = config.root) == null ? void 0 : _a.render) {
|
33850
|
-
return /* @__PURE__ */ (0,
|
34054
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(DropZoneProvider, { value: { data: defaultedData, config, mode: "render" }, children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
33851
34055
|
config.root.render,
|
33852
34056
|
__spreadProps(__spreadValues({}, rootProps), {
|
33853
34057
|
puck: {
|
@@ -33856,11 +34060,11 @@ function Render({
|
|
33856
34060
|
title,
|
33857
34061
|
editMode: false,
|
33858
34062
|
id: "puck-root",
|
33859
|
-
children: /* @__PURE__ */ (0,
|
34063
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(DropZone, { zone: rootDroppableId })
|
33860
34064
|
})
|
33861
34065
|
) });
|
33862
34066
|
}
|
33863
|
-
return /* @__PURE__ */ (0,
|
34067
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(DropZoneProvider, { value: { data: defaultedData, config, mode: "render" }, children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(DropZone, { zone: rootDroppableId }) });
|
33864
34068
|
}
|
33865
34069
|
|
33866
34070
|
// lib/migrate.ts
|
@@ -33888,6 +34092,15 @@ function migrate(data) {
|
|
33888
34092
|
|
33889
34093
|
// lib/transform-props.ts
|
33890
34094
|
init_react_import();
|
34095
|
+
|
34096
|
+
// lib/default-data.ts
|
34097
|
+
init_react_import();
|
34098
|
+
var defaultData = (data) => __spreadProps(__spreadValues({}, data), {
|
34099
|
+
root: data.root || {},
|
34100
|
+
content: data.content || []
|
34101
|
+
});
|
34102
|
+
|
34103
|
+
// lib/transform-props.ts
|
33891
34104
|
function transformProps(data, propTransforms) {
|
33892
34105
|
const mapItem = (item) => {
|
33893
34106
|
if (propTransforms[item.type]) {
|
@@ -33897,18 +34110,19 @@ function transformProps(data, propTransforms) {
|
|
33897
34110
|
}
|
33898
34111
|
return item;
|
33899
34112
|
};
|
33900
|
-
const
|
33901
|
-
|
34113
|
+
const defaultedData = defaultData(data);
|
34114
|
+
const rootProps = defaultedData.root.props || defaultedData.root;
|
34115
|
+
let newRoot = __spreadValues({}, defaultedData.root);
|
33902
34116
|
if (propTransforms["root"]) {
|
33903
|
-
if (
|
34117
|
+
if (defaultedData.root.props) {
|
33904
34118
|
newRoot.props = propTransforms["root"](rootProps);
|
33905
34119
|
} else {
|
33906
34120
|
newRoot = propTransforms["root"](rootProps);
|
33907
34121
|
}
|
33908
34122
|
}
|
33909
|
-
const afterPropTransforms = __spreadProps(__spreadValues({},
|
34123
|
+
const afterPropTransforms = __spreadProps(__spreadValues({}, defaultedData), {
|
33910
34124
|
root: newRoot,
|
33911
|
-
content:
|
34125
|
+
content: defaultedData.content.map(mapItem),
|
33912
34126
|
zones: Object.keys(data.zones || {}).reduce(
|
33913
34127
|
(acc, zoneKey) => __spreadProps(__spreadValues({}, acc), {
|
33914
34128
|
[zoneKey]: data.zones[zoneKey].map(mapItem)
|
@@ -33923,7 +34137,8 @@ function transformProps(data, propTransforms) {
|
|
33923
34137
|
init_react_import();
|
33924
34138
|
function resolveAllData(data, config, onResolveStart, onResolveEnd) {
|
33925
34139
|
return __async(this, null, function* () {
|
33926
|
-
const
|
34140
|
+
const defaultedData = defaultData(data);
|
34141
|
+
const dynamicRoot = yield resolveRootData(defaultedData, config);
|
33927
34142
|
const { zones = {} } = data;
|
33928
34143
|
const zoneKeys = Object.keys(zones);
|
33929
34144
|
const resolvedZones = {};
|
@@ -33936,10 +34151,10 @@ function resolveAllData(data, config, onResolveStart, onResolveEnd) {
|
|
33936
34151
|
onResolveEnd
|
33937
34152
|
);
|
33938
34153
|
}
|
33939
|
-
return __spreadProps(__spreadValues({},
|
34154
|
+
return __spreadProps(__spreadValues({}, defaultedData), {
|
33940
34155
|
root: dynamicRoot,
|
33941
34156
|
content: yield resolveAllComponentData(
|
33942
|
-
|
34157
|
+
defaultedData.content,
|
33943
34158
|
config,
|
33944
34159
|
onResolveStart,
|
33945
34160
|
onResolveEnd
|