@measured/puck 0.14.2 → 0.14.3-canary.73b83ef
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/index.css +0 -3
- package/dist/index.js +344 -145
- package/package.json +3 -2
package/dist/index.css
CHANGED
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
|
}
|
@@ -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
|
);
|
@@ -32627,19 +32627,218 @@ var Components = () => {
|
|
32627
32627
|
|
32628
32628
|
// components/Puck/components/Preview/index.tsx
|
32629
32629
|
init_react_import();
|
32630
|
-
var
|
32631
|
-
|
32630
|
+
var import_react23 = require("react");
|
32631
|
+
|
32632
|
+
// components/AutoFrame/index.tsx
|
32633
|
+
init_react_import();
|
32634
|
+
var import_react22 = __toESM(require("react"));
|
32635
|
+
var import_react_frame_component = __toESM(require("react-frame-component"));
|
32636
|
+
var import_object_hash = __toESM(require("object-hash"));
|
32637
|
+
var import_jsx_runtime29 = require("react/jsx-runtime");
|
32638
|
+
var styleSelector = 'style, link[rel="stylesheet"]';
|
32639
|
+
var collectStyles = (doc) => {
|
32640
|
+
const collected = [];
|
32641
|
+
doc.head.querySelectorAll(styleSelector).forEach((style) => {
|
32642
|
+
collected.push(style);
|
32643
|
+
});
|
32644
|
+
return collected;
|
32645
|
+
};
|
32646
|
+
var getStyleSheet = (el) => {
|
32647
|
+
return Array.from(document.styleSheets).find((ss) => {
|
32648
|
+
const ownerNode = ss.ownerNode;
|
32649
|
+
return ownerNode.href === el.href;
|
32650
|
+
});
|
32651
|
+
};
|
32652
|
+
var getStyles = (styleSheet) => {
|
32653
|
+
if (styleSheet) {
|
32654
|
+
try {
|
32655
|
+
return [...styleSheet.cssRules].map((rule) => rule.cssText).join("");
|
32656
|
+
} catch (e) {
|
32657
|
+
console.warn(
|
32658
|
+
"Access to stylesheet %s is denied. Ignoring\u2026",
|
32659
|
+
styleSheet.href
|
32660
|
+
);
|
32661
|
+
}
|
32662
|
+
}
|
32663
|
+
return "";
|
32664
|
+
};
|
32665
|
+
var defer = (fn) => setTimeout(fn, 0);
|
32666
|
+
var CopyHostStyles = ({
|
32667
|
+
children,
|
32668
|
+
debug = false,
|
32669
|
+
onStylesLoaded = () => null
|
32670
|
+
}) => {
|
32671
|
+
const { document: doc, window: win } = (0, import_react_frame_component.useFrame)();
|
32672
|
+
(0, import_react22.useEffect)(() => {
|
32673
|
+
if (!win || !doc) {
|
32674
|
+
return () => {
|
32675
|
+
};
|
32676
|
+
}
|
32677
|
+
let elements = [];
|
32678
|
+
const hashes = {};
|
32679
|
+
const lookupEl = (el) => elements.findIndex((elementMap) => elementMap.original === el);
|
32680
|
+
const mirrorEl = (el, inlineStyles = false) => __async(void 0, null, function* () {
|
32681
|
+
let mirror;
|
32682
|
+
if (el.nodeName === "LINK" && inlineStyles) {
|
32683
|
+
mirror = document.createElement("style");
|
32684
|
+
mirror.type = "text/css";
|
32685
|
+
let styleSheet = getStyleSheet(el);
|
32686
|
+
if (!styleSheet) {
|
32687
|
+
yield new Promise((resolve) => {
|
32688
|
+
const fn = () => {
|
32689
|
+
resolve();
|
32690
|
+
el.removeEventListener("load", fn);
|
32691
|
+
};
|
32692
|
+
el.addEventListener("load", fn);
|
32693
|
+
});
|
32694
|
+
styleSheet = getStyleSheet(el);
|
32695
|
+
}
|
32696
|
+
const styles = getStyles(styleSheet);
|
32697
|
+
if (!styles) {
|
32698
|
+
if (debug) {
|
32699
|
+
console.warn(
|
32700
|
+
`Tried to load styles for link element, but couldn't find them. Skipping...`
|
32701
|
+
);
|
32702
|
+
}
|
32703
|
+
return;
|
32704
|
+
}
|
32705
|
+
mirror.innerHTML = styles;
|
32706
|
+
mirror.setAttribute("data-href", el.getAttribute("href"));
|
32707
|
+
} else {
|
32708
|
+
mirror = el.cloneNode(true);
|
32709
|
+
}
|
32710
|
+
return mirror;
|
32711
|
+
});
|
32712
|
+
const addEl = (el) => __async(void 0, null, function* () {
|
32713
|
+
const index = lookupEl(el);
|
32714
|
+
if (index > -1) {
|
32715
|
+
if (debug)
|
32716
|
+
console.log(
|
32717
|
+
`Tried to add an element that was already mirrored. Updating instead...`
|
32718
|
+
);
|
32719
|
+
elements[index].mirror.innerText = el.innerText;
|
32720
|
+
return;
|
32721
|
+
}
|
32722
|
+
const mirror = yield mirrorEl(el);
|
32723
|
+
if (!mirror) {
|
32724
|
+
return;
|
32725
|
+
}
|
32726
|
+
const elHash = (0, import_object_hash.default)(mirror.outerHTML);
|
32727
|
+
if (hashes[elHash]) {
|
32728
|
+
if (debug)
|
32729
|
+
console.log(
|
32730
|
+
`iframe already contains element that is being mirrored. Skipping...`
|
32731
|
+
);
|
32732
|
+
return;
|
32733
|
+
}
|
32734
|
+
hashes[elHash] = true;
|
32735
|
+
doc.head.append(mirror);
|
32736
|
+
elements.push({ original: el, mirror });
|
32737
|
+
if (debug)
|
32738
|
+
console.log(`Added style node ${el.outerHTML}`);
|
32739
|
+
});
|
32740
|
+
const removeEl = (el) => {
|
32741
|
+
var _a, _b;
|
32742
|
+
const index = lookupEl(el);
|
32743
|
+
if (index === -1) {
|
32744
|
+
if (debug)
|
32745
|
+
console.log(
|
32746
|
+
`Tried to remove an element that did not exist. Skipping...`
|
32747
|
+
);
|
32748
|
+
return;
|
32749
|
+
}
|
32750
|
+
const elHash = (0, import_object_hash.default)(el.outerHTML);
|
32751
|
+
(_b = (_a = elements[index]) == null ? void 0 : _a.mirror) == null ? void 0 : _b.remove();
|
32752
|
+
delete hashes[elHash];
|
32753
|
+
if (debug)
|
32754
|
+
console.log(`Removed style node ${el.outerHTML}`);
|
32755
|
+
};
|
32756
|
+
const observer = new MutationObserver((mutations) => {
|
32757
|
+
mutations.forEach((mutation) => {
|
32758
|
+
if (mutation.type === "childList") {
|
32759
|
+
mutation.addedNodes.forEach((node) => {
|
32760
|
+
if (node.nodeType === Node.TEXT_NODE || node.nodeType === Node.ELEMENT_NODE) {
|
32761
|
+
const el = node.nodeType === Node.TEXT_NODE ? node.parentElement : node;
|
32762
|
+
if (el && el.matches(styleSelector)) {
|
32763
|
+
defer(() => addEl(el));
|
32764
|
+
}
|
32765
|
+
}
|
32766
|
+
});
|
32767
|
+
mutation.removedNodes.forEach((node) => {
|
32768
|
+
if (node.nodeType === Node.TEXT_NODE || node.nodeType === Node.ELEMENT_NODE) {
|
32769
|
+
const el = node.nodeType === Node.TEXT_NODE ? node.parentElement : node;
|
32770
|
+
if (el && el.matches(styleSelector)) {
|
32771
|
+
defer(() => removeEl(el));
|
32772
|
+
}
|
32773
|
+
}
|
32774
|
+
});
|
32775
|
+
}
|
32776
|
+
});
|
32777
|
+
});
|
32778
|
+
const parentDocument = win.parent.document;
|
32779
|
+
const collectedStyles = collectStyles(parentDocument);
|
32780
|
+
const hrefs = [];
|
32781
|
+
let stylesLoaded = 0;
|
32782
|
+
Promise.all(
|
32783
|
+
collectedStyles.map((styleNode, i) => __async(void 0, null, function* () {
|
32784
|
+
if (styleNode.nodeName === "LINK") {
|
32785
|
+
const linkHref = styleNode.href;
|
32786
|
+
if (hrefs.indexOf(linkHref) > -1) {
|
32787
|
+
return;
|
32788
|
+
}
|
32789
|
+
hrefs.push(linkHref);
|
32790
|
+
}
|
32791
|
+
const mirror = yield mirrorEl(styleNode);
|
32792
|
+
if (!mirror)
|
32793
|
+
return;
|
32794
|
+
elements.push({ original: styleNode, mirror });
|
32795
|
+
return mirror;
|
32796
|
+
}))
|
32797
|
+
).then((mirrorStyles) => {
|
32798
|
+
const filtered = mirrorStyles.filter(
|
32799
|
+
(el) => typeof el !== "undefined"
|
32800
|
+
);
|
32801
|
+
filtered.forEach((mirror) => {
|
32802
|
+
mirror.onload = () => {
|
32803
|
+
stylesLoaded = stylesLoaded + 1;
|
32804
|
+
if (stylesLoaded >= elements.length) {
|
32805
|
+
onStylesLoaded();
|
32806
|
+
}
|
32807
|
+
};
|
32808
|
+
});
|
32809
|
+
doc.head.innerHTML = "";
|
32810
|
+
doc.head.append(...filtered);
|
32811
|
+
observer.observe(parentDocument.head, { childList: true, subtree: true });
|
32812
|
+
filtered.forEach((el) => {
|
32813
|
+
const elHash = (0, import_object_hash.default)(el.outerHTML);
|
32814
|
+
hashes[elHash] = true;
|
32815
|
+
});
|
32816
|
+
});
|
32817
|
+
return () => {
|
32818
|
+
observer.disconnect();
|
32819
|
+
};
|
32820
|
+
}, []);
|
32821
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_jsx_runtime29.Fragment, { children });
|
32822
|
+
};
|
32823
|
+
var AutoFrameComponent = import_react22.default.forwardRef(
|
32824
|
+
function(_a, ref) {
|
32825
|
+
var _b = _a, { children, debug, onStylesLoaded } = _b, props = __objRest(_b, ["children", "debug", "onStylesLoaded"]);
|
32826
|
+
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 }) }));
|
32827
|
+
}
|
32828
|
+
);
|
32829
|
+
AutoFrameComponent.displayName = "AutoFrameComponent";
|
32830
|
+
var AutoFrame_default = AutoFrameComponent;
|
32632
32831
|
|
32633
32832
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Preview/styles.module.css#css-module
|
32634
32833
|
init_react_import();
|
32635
32834
|
var styles_module_default16 = { "PuckPreview": "_PuckPreview_rxwlr_1", "PuckPreview-frame": "_PuckPreview-frame_rxwlr_5" };
|
32636
32835
|
|
32637
32836
|
// components/Puck/components/Preview/index.tsx
|
32638
|
-
var
|
32837
|
+
var import_jsx_runtime30 = require("react/jsx-runtime");
|
32639
32838
|
var getClassName21 = get_class_name_factory_default("PuckPreview", styles_module_default16);
|
32640
32839
|
var Preview = ({ id = "puck-preview" }) => {
|
32641
32840
|
const { config, dispatch, state, setStatus, iframe } = useAppContext();
|
32642
|
-
const Page = (0,
|
32841
|
+
const Page = (0, import_react23.useCallback)(
|
32643
32842
|
(pageProps) => {
|
32644
32843
|
var _a, _b;
|
32645
32844
|
return ((_a = config.root) == null ? void 0 : _a.render) ? (_b = config.root) == null ? void 0 : _b.render(__spreadProps(__spreadValues({
|
@@ -32647,13 +32846,13 @@ var Preview = ({ id = "puck-preview" }) => {
|
|
32647
32846
|
}, pageProps), {
|
32648
32847
|
editMode: true,
|
32649
32848
|
puck: { renderDropZone: DropZone }
|
32650
|
-
})) : /* @__PURE__ */ (0,
|
32849
|
+
})) : /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_jsx_runtime30.Fragment, { children: pageProps.children });
|
32651
32850
|
},
|
32652
32851
|
[config.root]
|
32653
32852
|
);
|
32654
32853
|
const rootProps = state.data.root.props || state.data.root;
|
32655
|
-
const ref = (0,
|
32656
|
-
return /* @__PURE__ */ (0,
|
32854
|
+
const ref = (0, import_react23.useRef)(null);
|
32855
|
+
return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
32657
32856
|
"div",
|
32658
32857
|
{
|
32659
32858
|
className: getClassName21(),
|
@@ -32661,8 +32860,8 @@ var Preview = ({ id = "puck-preview" }) => {
|
|
32661
32860
|
onClick: () => {
|
32662
32861
|
dispatch({ type: "setUi", ui: __spreadProps(__spreadValues({}, state.ui), { itemSelector: null }) });
|
32663
32862
|
},
|
32664
|
-
children: iframe.enabled ? /* @__PURE__ */ (0,
|
32665
|
-
|
32863
|
+
children: iframe.enabled ? /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
32864
|
+
AutoFrame_default,
|
32666
32865
|
{
|
32667
32866
|
id: "preview-frame",
|
32668
32867
|
className: getClassName21("frame"),
|
@@ -32671,9 +32870,9 @@ var Preview = ({ id = "puck-preview" }) => {
|
|
32671
32870
|
onStylesLoaded: () => {
|
32672
32871
|
setStatus("READY");
|
32673
32872
|
},
|
32674
|
-
children: /* @__PURE__ */ (0,
|
32873
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Page, __spreadProps(__spreadValues({ dispatch, state }, rootProps), { children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(DropZone, { zone: rootDroppableId }) }))
|
32675
32874
|
}
|
32676
|
-
) : /* @__PURE__ */ (0,
|
32875
|
+
) : /* @__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
32876
|
}
|
32678
32877
|
);
|
32679
32878
|
};
|
@@ -32721,7 +32920,7 @@ var scrollIntoView = (el) => {
|
|
32721
32920
|
};
|
32722
32921
|
|
32723
32922
|
// components/LayerTree/index.tsx
|
32724
|
-
var
|
32923
|
+
var import_react24 = require("react");
|
32725
32924
|
|
32726
32925
|
// lib/is-child-of-zone.ts
|
32727
32926
|
init_react_import();
|
@@ -32735,7 +32934,7 @@ var isChildOfZone = (item, maybeChild, ctx) => {
|
|
32735
32934
|
};
|
32736
32935
|
|
32737
32936
|
// components/LayerTree/index.tsx
|
32738
|
-
var
|
32937
|
+
var import_jsx_runtime31 = require("react/jsx-runtime");
|
32739
32938
|
var getClassName22 = get_class_name_factory_default("LayerTree", styles_module_default17);
|
32740
32939
|
var getClassNameLayer = get_class_name_factory_default("Layer", styles_module_default17);
|
32741
32940
|
var LayerTree = ({
|
@@ -32748,15 +32947,15 @@ var LayerTree = ({
|
|
32748
32947
|
label
|
32749
32948
|
}) => {
|
32750
32949
|
const zones = data.zones || {};
|
32751
|
-
const ctx = (0,
|
32752
|
-
return /* @__PURE__ */ (0,
|
32753
|
-
label && /* @__PURE__ */ (0,
|
32754
|
-
/* @__PURE__ */ (0,
|
32950
|
+
const ctx = (0, import_react24.useContext)(dropZoneContext);
|
32951
|
+
return /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(import_jsx_runtime31.Fragment, { children: [
|
32952
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("div", { className: getClassName22("zoneTitle"), children: [
|
32953
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", { className: getClassName22("zoneIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(Layers, { size: "16" }) }),
|
32755
32954
|
" ",
|
32756
32955
|
label
|
32757
32956
|
] }),
|
32758
|
-
/* @__PURE__ */ (0,
|
32759
|
-
zoneContent.length === 0 && /* @__PURE__ */ (0,
|
32957
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("ul", { className: getClassName22(), children: [
|
32958
|
+
zoneContent.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", { className: getClassName22("helper"), children: "No items" }),
|
32760
32959
|
zoneContent.map((item, i) => {
|
32761
32960
|
var _a;
|
32762
32961
|
const isSelected = (itemSelector == null ? void 0 : itemSelector.index) === i && (itemSelector.zone === zone || itemSelector.zone === rootDroppableId && !zone);
|
@@ -32772,7 +32971,7 @@ var LayerTree = ({
|
|
32772
32971
|
const selectedItem = itemSelector && data ? getItem(itemSelector, data) : null;
|
32773
32972
|
const isHovering = hoveringComponent === item.props.id;
|
32774
32973
|
const childIsSelected = isChildOfZone(item, selectedItem, ctx);
|
32775
|
-
return /* @__PURE__ */ (0,
|
32974
|
+
return /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(
|
32776
32975
|
"li",
|
32777
32976
|
{
|
32778
32977
|
className: getClassNameLayer({
|
@@ -32782,7 +32981,7 @@ var LayerTree = ({
|
|
32782
32981
|
childIsSelected
|
32783
32982
|
}),
|
32784
32983
|
children: [
|
32785
|
-
/* @__PURE__ */ (0,
|
32984
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", { className: getClassNameLayer("inner"), children: /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(
|
32786
32985
|
"button",
|
32787
32986
|
{
|
32788
32987
|
className: getClassNameLayer("clickable"),
|
@@ -32814,22 +33013,22 @@ var LayerTree = ({
|
|
32814
33013
|
setHoveringComponent(null);
|
32815
33014
|
},
|
32816
33015
|
children: [
|
32817
|
-
containsZone && /* @__PURE__ */ (0,
|
33016
|
+
containsZone && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
32818
33017
|
"div",
|
32819
33018
|
{
|
32820
33019
|
className: getClassNameLayer("chevron"),
|
32821
33020
|
title: isSelected ? "Collapse" : "Expand",
|
32822
|
-
children: /* @__PURE__ */ (0,
|
33021
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(ChevronDown, { size: "12" })
|
32823
33022
|
}
|
32824
33023
|
),
|
32825
|
-
/* @__PURE__ */ (0,
|
32826
|
-
/* @__PURE__ */ (0,
|
32827
|
-
/* @__PURE__ */ (0,
|
33024
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("div", { className: getClassNameLayer("title"), children: [
|
33025
|
+
/* @__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" }) }),
|
33026
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", { className: getClassNameLayer("name"), children: (_a = config.components[item.type]["label"]) != null ? _a : item.type })
|
32828
33027
|
] })
|
32829
33028
|
]
|
32830
33029
|
}
|
32831
33030
|
) }),
|
32832
|
-
containsZone && Object.keys(zonesForItem).map((zoneKey, idx) => /* @__PURE__ */ (0,
|
33031
|
+
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
33032
|
LayerTree,
|
32834
33033
|
{
|
32835
33034
|
config,
|
@@ -32851,13 +33050,13 @@ var LayerTree = ({
|
|
32851
33050
|
};
|
32852
33051
|
|
32853
33052
|
// components/Puck/components/Outline/index.tsx
|
32854
|
-
var
|
32855
|
-
var
|
33053
|
+
var import_react25 = require("react");
|
33054
|
+
var import_jsx_runtime32 = require("react/jsx-runtime");
|
32856
33055
|
var Outline = () => {
|
32857
33056
|
const { dispatch, state, overrides, config } = useAppContext();
|
32858
33057
|
const { data, ui } = state;
|
32859
33058
|
const { itemSelector } = ui;
|
32860
|
-
const setItemSelector = (0,
|
33059
|
+
const setItemSelector = (0, import_react25.useCallback)(
|
32861
33060
|
(newItemSelector) => {
|
32862
33061
|
dispatch({
|
32863
33062
|
type: "setUi",
|
@@ -32866,9 +33065,9 @@ var Outline = () => {
|
|
32866
33065
|
},
|
32867
33066
|
[]
|
32868
33067
|
);
|
32869
|
-
const Wrapper = (0,
|
32870
|
-
return /* @__PURE__ */ (0,
|
32871
|
-
(ctx == null ? void 0 : ctx.activeZones) && (ctx == null ? void 0 : ctx.activeZones[rootDroppableId]) && /* @__PURE__ */ (0,
|
33068
|
+
const Wrapper = (0, import_react25.useMemo)(() => overrides.outline || "div", [overrides]);
|
33069
|
+
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: [
|
33070
|
+
(ctx == null ? void 0 : ctx.activeZones) && (ctx == null ? void 0 : ctx.activeZones[rootDroppableId]) && /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
32872
33071
|
LayerTree,
|
32873
33072
|
{
|
32874
33073
|
config,
|
@@ -32881,7 +33080,7 @@ var Outline = () => {
|
|
32881
33080
|
),
|
32882
33081
|
Object.entries(findZonesForArea(data, "root")).map(
|
32883
33082
|
([zoneKey, zone]) => {
|
32884
|
-
return /* @__PURE__ */ (0,
|
33083
|
+
return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
32885
33084
|
LayerTree,
|
32886
33085
|
{
|
32887
33086
|
config,
|
@@ -32966,12 +33165,12 @@ function usePuckHistory({
|
|
32966
33165
|
|
32967
33166
|
// lib/use-history-store.ts
|
32968
33167
|
init_react_import();
|
32969
|
-
var
|
33168
|
+
var import_react26 = require("react");
|
32970
33169
|
var import_use_debounce3 = require("use-debounce");
|
32971
33170
|
var EMPTY_HISTORY_INDEX = -1;
|
32972
33171
|
function useHistoryStore() {
|
32973
|
-
const [histories, setHistories] = (0,
|
32974
|
-
const [index, setIndex] = (0,
|
33172
|
+
const [histories, setHistories] = (0, import_react26.useState)([]);
|
33173
|
+
const [index, setIndex] = (0, import_react26.useState)(EMPTY_HISTORY_INDEX);
|
32975
33174
|
const hasPast = index > EMPTY_HISTORY_INDEX;
|
32976
33175
|
const hasFuture = index < histories.length - 1;
|
32977
33176
|
const currentHistory = histories[index];
|
@@ -33131,22 +33330,22 @@ var getBox = function getBox2(el) {
|
|
33131
33330
|
};
|
33132
33331
|
|
33133
33332
|
// components/Puck/components/Canvas/index.tsx
|
33134
|
-
var
|
33333
|
+
var import_react28 = require("react");
|
33135
33334
|
|
33136
33335
|
// components/ViewportControls/index.tsx
|
33137
33336
|
init_react_import();
|
33138
|
-
var
|
33337
|
+
var import_react27 = require("react");
|
33139
33338
|
|
33140
33339
|
// css-module:/home/runner/work/puck/puck/packages/core/components/ViewportControls/styles.module.css#css-module
|
33141
33340
|
init_react_import();
|
33142
33341
|
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
33342
|
|
33144
33343
|
// components/ViewportControls/index.tsx
|
33145
|
-
var
|
33344
|
+
var import_jsx_runtime33 = require("react/jsx-runtime");
|
33146
33345
|
var icons = {
|
33147
|
-
Smartphone: /* @__PURE__ */ (0,
|
33148
|
-
Tablet: /* @__PURE__ */ (0,
|
33149
|
-
Monitor: /* @__PURE__ */ (0,
|
33346
|
+
Smartphone: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Smartphone, { size: 16 }),
|
33347
|
+
Tablet: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Tablet, { size: 16 }),
|
33348
|
+
Monitor: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Monitor, { size: 16 })
|
33150
33349
|
};
|
33151
33350
|
var getClassName23 = get_class_name_factory_default("ViewportControls", styles_module_default18);
|
33152
33351
|
var getClassNameButton = get_class_name_factory_default("ViewportButton", styles_module_default18);
|
@@ -33158,11 +33357,11 @@ var ViewportButton = ({
|
|
33158
33357
|
onClick
|
33159
33358
|
}) => {
|
33160
33359
|
const { state } = useAppContext();
|
33161
|
-
const [isActive, setIsActive] = (0,
|
33162
|
-
(0,
|
33360
|
+
const [isActive, setIsActive] = (0, import_react27.useState)(false);
|
33361
|
+
(0, import_react27.useEffect)(() => {
|
33163
33362
|
setIsActive(width === state.ui.viewports.current.width);
|
33164
33363
|
}, [width, state.ui.viewports.current.width]);
|
33165
|
-
return /* @__PURE__ */ (0,
|
33364
|
+
return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("span", { className: getClassNameButton({ isActive }), children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
33166
33365
|
IconButton,
|
33167
33366
|
{
|
33168
33367
|
title,
|
@@ -33171,7 +33370,7 @@ var ViewportButton = ({
|
|
33171
33370
|
e.stopPropagation();
|
33172
33371
|
onClick({ width, height });
|
33173
33372
|
},
|
33174
|
-
children: /* @__PURE__ */ (0,
|
33373
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("span", { className: getClassNameButton("inner"), children })
|
33175
33374
|
}
|
33176
33375
|
) });
|
33177
33376
|
};
|
@@ -33195,7 +33394,7 @@ var ViewportControls = ({
|
|
33195
33394
|
const defaultsContainAutoZoom = defaultZoomOptions.find(
|
33196
33395
|
(option) => option.value === autoZoom
|
33197
33396
|
);
|
33198
|
-
const zoomOptions = (0,
|
33397
|
+
const zoomOptions = (0, import_react27.useMemo)(
|
33199
33398
|
() => [
|
33200
33399
|
...defaultZoomOptions,
|
33201
33400
|
...defaultsContainAutoZoom ? [] : [
|
@@ -33207,8 +33406,8 @@ var ViewportControls = ({
|
|
33207
33406
|
].filter((a) => a.value <= autoZoom).sort((a, b) => a.value > b.value ? 1 : -1),
|
33208
33407
|
[autoZoom]
|
33209
33408
|
);
|
33210
|
-
return /* @__PURE__ */ (0,
|
33211
|
-
viewports.map((viewport, i) => /* @__PURE__ */ (0,
|
33409
|
+
return /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { className: getClassName23(), children: [
|
33410
|
+
viewports.map((viewport, i) => /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
33212
33411
|
ViewportButton,
|
33213
33412
|
{
|
33214
33413
|
height: viewport.height,
|
@@ -33219,8 +33418,8 @@ var ViewportControls = ({
|
|
33219
33418
|
},
|
33220
33419
|
i
|
33221
33420
|
)),
|
33222
|
-
/* @__PURE__ */ (0,
|
33223
|
-
/* @__PURE__ */ (0,
|
33421
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)("div", { className: getClassName23("divider") }),
|
33422
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
33224
33423
|
IconButton,
|
33225
33424
|
{
|
33226
33425
|
title: "Zoom viewport out",
|
@@ -33234,10 +33433,10 @@ var ViewportControls = ({
|
|
33234
33433
|
)].value
|
33235
33434
|
);
|
33236
33435
|
},
|
33237
|
-
children: /* @__PURE__ */ (0,
|
33436
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(ZoomOut, { size: 16 })
|
33238
33437
|
}
|
33239
33438
|
),
|
33240
|
-
/* @__PURE__ */ (0,
|
33439
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
33241
33440
|
IconButton,
|
33242
33441
|
{
|
33243
33442
|
title: "Zoom viewport in",
|
@@ -33251,11 +33450,11 @@ var ViewportControls = ({
|
|
33251
33450
|
)].value
|
33252
33451
|
);
|
33253
33452
|
},
|
33254
|
-
children: /* @__PURE__ */ (0,
|
33453
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(ZoomIn, { size: 16 })
|
33255
33454
|
}
|
33256
33455
|
),
|
33257
|
-
/* @__PURE__ */ (0,
|
33258
|
-
/* @__PURE__ */ (0,
|
33456
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)("div", { className: getClassName23("divider") }),
|
33457
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
33259
33458
|
"select",
|
33260
33459
|
{
|
33261
33460
|
className: getClassName23("zoomSelect"),
|
@@ -33263,7 +33462,7 @@ var ViewportControls = ({
|
|
33263
33462
|
onChange: (e) => {
|
33264
33463
|
onZoom(parseFloat(e.currentTarget.value));
|
33265
33464
|
},
|
33266
|
-
children: zoomOptions.map((option) => /* @__PURE__ */ (0,
|
33465
|
+
children: zoomOptions.map((option) => /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
33267
33466
|
"option",
|
33268
33467
|
{
|
33269
33468
|
value: option.value,
|
@@ -33311,24 +33510,24 @@ var getZoomConfig = (uiViewport, frame, zoom) => {
|
|
33311
33510
|
};
|
33312
33511
|
|
33313
33512
|
// components/Puck/components/Canvas/index.tsx
|
33314
|
-
var
|
33513
|
+
var import_jsx_runtime34 = require("react/jsx-runtime");
|
33315
33514
|
var getClassName24 = get_class_name_factory_default("PuckCanvas", styles_module_default19);
|
33316
33515
|
var ZOOM_ON_CHANGE = true;
|
33317
33516
|
var Canvas = () => {
|
33318
33517
|
const { status, iframe } = useAppContext();
|
33319
33518
|
const { dispatch, state, overrides, setUi, zoomConfig, setZoomConfig } = useAppContext();
|
33320
33519
|
const { ui } = state;
|
33321
|
-
const frameRef = (0,
|
33322
|
-
const [showTransition, setShowTransition] = (0,
|
33323
|
-
const defaultRender = (0,
|
33324
|
-
const PuckDefault = ({ children }) => /* @__PURE__ */ (0,
|
33520
|
+
const frameRef = (0, import_react28.useRef)(null);
|
33521
|
+
const [showTransition, setShowTransition] = (0, import_react28.useState)(false);
|
33522
|
+
const defaultRender = (0, import_react28.useMemo)(() => {
|
33523
|
+
const PuckDefault = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_jsx_runtime34.Fragment, { children });
|
33325
33524
|
return PuckDefault;
|
33326
33525
|
}, []);
|
33327
|
-
const CustomPreview = (0,
|
33526
|
+
const CustomPreview = (0, import_react28.useMemo)(
|
33328
33527
|
() => overrides.preview || defaultRender,
|
33329
33528
|
[overrides]
|
33330
33529
|
);
|
33331
|
-
const getFrameDimensions = (0,
|
33530
|
+
const getFrameDimensions = (0, import_react28.useCallback)(() => {
|
33332
33531
|
if (frameRef.current) {
|
33333
33532
|
const frame = frameRef.current;
|
33334
33533
|
const box = getBox(frame);
|
@@ -33336,7 +33535,7 @@ var Canvas = () => {
|
|
33336
33535
|
}
|
33337
33536
|
return { width: 0, height: 0 };
|
33338
33537
|
}, [frameRef]);
|
33339
|
-
const resetAutoZoom = (0,
|
33538
|
+
const resetAutoZoom = (0, import_react28.useCallback)(
|
33340
33539
|
(ui2 = state.ui) => {
|
33341
33540
|
if (frameRef.current) {
|
33342
33541
|
setZoomConfig(
|
@@ -33346,11 +33545,11 @@ var Canvas = () => {
|
|
33346
33545
|
},
|
33347
33546
|
[frameRef, zoomConfig, state.ui]
|
33348
33547
|
);
|
33349
|
-
(0,
|
33548
|
+
(0, import_react28.useEffect)(() => {
|
33350
33549
|
setShowTransition(false);
|
33351
33550
|
resetAutoZoom();
|
33352
33551
|
}, [frameRef, ui.leftSideBarVisible, ui.rightSideBarVisible]);
|
33353
|
-
(0,
|
33552
|
+
(0, import_react28.useEffect)(() => {
|
33354
33553
|
const { height: frameHeight } = getFrameDimensions();
|
33355
33554
|
if (ui.viewports.current.height === "auto") {
|
33356
33555
|
setZoomConfig(__spreadProps(__spreadValues({}, zoomConfig), {
|
@@ -33358,7 +33557,7 @@ var Canvas = () => {
|
|
33358
33557
|
}));
|
33359
33558
|
}
|
33360
33559
|
}, [zoomConfig.zoom]);
|
33361
|
-
(0,
|
33560
|
+
(0, import_react28.useEffect)(() => {
|
33362
33561
|
const observer = new ResizeObserver(() => {
|
33363
33562
|
setShowTransition(false);
|
33364
33563
|
resetAutoZoom();
|
@@ -33370,7 +33569,7 @@ var Canvas = () => {
|
|
33370
33569
|
observer.disconnect();
|
33371
33570
|
};
|
33372
33571
|
}, []);
|
33373
|
-
return /* @__PURE__ */ (0,
|
33572
|
+
return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(
|
33374
33573
|
"div",
|
33375
33574
|
{
|
33376
33575
|
className: getClassName24({
|
@@ -33382,7 +33581,7 @@ var Canvas = () => {
|
|
33382
33581
|
recordHistory: true
|
33383
33582
|
}),
|
33384
33583
|
children: [
|
33385
|
-
ui.viewports.controlsVisible && iframe.enabled && /* @__PURE__ */ (0,
|
33584
|
+
ui.viewports.controlsVisible && iframe.enabled && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: getClassName24("controls"), children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
33386
33585
|
ViewportControls,
|
33387
33586
|
{
|
33388
33587
|
autoZoom: zoomConfig.autoZoom,
|
@@ -33407,7 +33606,7 @@ var Canvas = () => {
|
|
33407
33606
|
}
|
33408
33607
|
}
|
33409
33608
|
) }),
|
33410
|
-
/* @__PURE__ */ (0,
|
33609
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: getClassName24("inner"), ref: frameRef, children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
33411
33610
|
"div",
|
33412
33611
|
{
|
33413
33612
|
className: getClassName24("root"),
|
@@ -33419,7 +33618,7 @@ var Canvas = () => {
|
|
33419
33618
|
overflow: iframe.enabled ? void 0 : "auto"
|
33420
33619
|
},
|
33421
33620
|
suppressHydrationWarning: true,
|
33422
|
-
children: /* @__PURE__ */ (0,
|
33621
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(CustomPreview, { children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Preview, {}) })
|
33423
33622
|
}
|
33424
33623
|
) })
|
33425
33624
|
]
|
@@ -33428,7 +33627,7 @@ var Canvas = () => {
|
|
33428
33627
|
};
|
33429
33628
|
|
33430
33629
|
// components/Puck/index.tsx
|
33431
|
-
var
|
33630
|
+
var import_jsx_runtime35 = require("react/jsx-runtime");
|
33432
33631
|
var getClassName25 = get_class_name_factory_default("Puck", styles_module_default8);
|
33433
33632
|
function Puck({
|
33434
33633
|
children,
|
@@ -33451,10 +33650,10 @@ function Puck({
|
|
33451
33650
|
}) {
|
33452
33651
|
var _a;
|
33453
33652
|
const historyStore = useHistoryStore();
|
33454
|
-
const [reducer] = (0,
|
33653
|
+
const [reducer] = (0, import_react29.useState)(
|
33455
33654
|
() => createReducer({ config, record: historyStore.record })
|
33456
33655
|
);
|
33457
|
-
const [initialAppState] = (0,
|
33656
|
+
const [initialAppState] = (0, import_react29.useState)(() => {
|
33458
33657
|
var _a2, _b, _c, _d;
|
33459
33658
|
const initial = __spreadValues(__spreadValues({}, defaultAppState.ui), initialUi);
|
33460
33659
|
let clientUiState = {};
|
@@ -33502,7 +33701,7 @@ function Puck({
|
|
33502
33701
|
})
|
33503
33702
|
});
|
33504
33703
|
});
|
33505
|
-
const [appState, dispatch] = (0,
|
33704
|
+
const [appState, dispatch] = (0, import_react29.useReducer)(
|
33506
33705
|
reducer,
|
33507
33706
|
flushZones(initialAppState)
|
33508
33707
|
);
|
@@ -33513,9 +33712,9 @@ function Puck({
|
|
33513
33712
|
config,
|
33514
33713
|
dispatch
|
33515
33714
|
);
|
33516
|
-
const [menuOpen, setMenuOpen] = (0,
|
33715
|
+
const [menuOpen, setMenuOpen] = (0, import_react29.useState)(false);
|
33517
33716
|
const { itemSelector, leftSideBarVisible, rightSideBarVisible } = ui;
|
33518
|
-
const setItemSelector = (0,
|
33717
|
+
const setItemSelector = (0, import_react29.useCallback)(
|
33519
33718
|
(newItemSelector) => {
|
33520
33719
|
if (newItemSelector === itemSelector)
|
33521
33720
|
return;
|
@@ -33528,21 +33727,21 @@ function Puck({
|
|
33528
33727
|
[itemSelector]
|
33529
33728
|
);
|
33530
33729
|
const selectedItem = itemSelector ? getItem(itemSelector, data) : null;
|
33531
|
-
(0,
|
33730
|
+
(0, import_react29.useEffect)(() => {
|
33532
33731
|
if (onChange)
|
33533
33732
|
onChange(data);
|
33534
33733
|
}, [data]);
|
33535
33734
|
const { onDragStartOrUpdate, placeholderStyle } = usePlaceholderStyle();
|
33536
|
-
const [draggedItem, setDraggedItem] = (0,
|
33735
|
+
const [draggedItem, setDraggedItem] = (0, import_react29.useState)();
|
33537
33736
|
const rootProps = data.root.props || data.root;
|
33538
|
-
(0,
|
33737
|
+
(0, import_react29.useEffect)(() => {
|
33539
33738
|
if (Object.keys(data.root).length > 0 && !data.root.props) {
|
33540
33739
|
console.error(
|
33541
33740
|
"Warning: Defining props on `root` is deprecated. Please use `root.props`. This will be a breaking change in a future release."
|
33542
33741
|
);
|
33543
33742
|
}
|
33544
33743
|
}, []);
|
33545
|
-
const toggleSidebars = (0,
|
33744
|
+
const toggleSidebars = (0, import_react29.useCallback)(
|
33546
33745
|
(sidebar) => {
|
33547
33746
|
const widerViewport = window.matchMedia("(min-width: 638px)").matches;
|
33548
33747
|
const sideBarVisible = sidebar === "left" ? leftSideBarVisible : rightSideBarVisible;
|
@@ -33556,7 +33755,7 @@ function Puck({
|
|
33556
33755
|
},
|
33557
33756
|
[dispatch, leftSideBarVisible, rightSideBarVisible]
|
33558
33757
|
);
|
33559
|
-
(0,
|
33758
|
+
(0, import_react29.useEffect)(() => {
|
33560
33759
|
if (!window.matchMedia("(min-width: 638px)").matches) {
|
33561
33760
|
dispatch({
|
33562
33761
|
type: "setUi",
|
@@ -33579,11 +33778,11 @@ function Puck({
|
|
33579
33778
|
window.removeEventListener("resize", handleResize);
|
33580
33779
|
};
|
33581
33780
|
}, []);
|
33582
|
-
const defaultRender = (0,
|
33583
|
-
const PuckDefault = ({ children: children2 }) => /* @__PURE__ */ (0,
|
33781
|
+
const defaultRender = (0, import_react29.useMemo)(() => {
|
33782
|
+
const PuckDefault = ({ children: children2 }) => /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(import_jsx_runtime35.Fragment, { children: children2 });
|
33584
33783
|
return PuckDefault;
|
33585
33784
|
}, []);
|
33586
|
-
const defaultHeaderRender = (0,
|
33785
|
+
const defaultHeaderRender = (0, import_react29.useMemo)(() => {
|
33587
33786
|
if (renderHeader) {
|
33588
33787
|
console.warn(
|
33589
33788
|
"`renderHeader` is deprecated. Please use `overrides.header` and the `usePuck` hook instead"
|
@@ -33591,45 +33790,45 @@ function Puck({
|
|
33591
33790
|
const RenderHeader = (_a2) => {
|
33592
33791
|
var _b = _a2, { actions } = _b, props = __objRest(_b, ["actions"]);
|
33593
33792
|
const Comp = renderHeader;
|
33594
|
-
return /* @__PURE__ */ (0,
|
33793
|
+
return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState, children: actions }));
|
33595
33794
|
};
|
33596
33795
|
return RenderHeader;
|
33597
33796
|
}
|
33598
33797
|
return defaultRender;
|
33599
33798
|
}, [renderHeader]);
|
33600
|
-
const defaultHeaderActionsRender = (0,
|
33799
|
+
const defaultHeaderActionsRender = (0, import_react29.useMemo)(() => {
|
33601
33800
|
if (renderHeaderActions) {
|
33602
33801
|
console.warn(
|
33603
33802
|
"`renderHeaderActions` is deprecated. Please use `overrides.headerActions` and the `usePuck` hook instead."
|
33604
33803
|
);
|
33605
33804
|
const RenderHeader = (props) => {
|
33606
33805
|
const Comp = renderHeaderActions;
|
33607
|
-
return /* @__PURE__ */ (0,
|
33806
|
+
return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState }));
|
33608
33807
|
};
|
33609
33808
|
return RenderHeader;
|
33610
33809
|
}
|
33611
33810
|
return defaultRender;
|
33612
33811
|
}, [renderHeader]);
|
33613
|
-
const loadedOverrides = (0,
|
33812
|
+
const loadedOverrides = (0, import_react29.useMemo)(() => {
|
33614
33813
|
return loadOverrides({ overrides, plugins });
|
33615
33814
|
}, [plugins]);
|
33616
|
-
const CustomPuck = (0,
|
33815
|
+
const CustomPuck = (0, import_react29.useMemo)(
|
33617
33816
|
() => loadedOverrides.puck || defaultRender,
|
33618
33817
|
[loadedOverrides]
|
33619
33818
|
);
|
33620
|
-
const CustomHeader = (0,
|
33819
|
+
const CustomHeader = (0, import_react29.useMemo)(
|
33621
33820
|
() => loadedOverrides.header || defaultHeaderRender,
|
33622
33821
|
[loadedOverrides]
|
33623
33822
|
);
|
33624
|
-
const CustomHeaderActions = (0,
|
33823
|
+
const CustomHeaderActions = (0, import_react29.useMemo)(
|
33625
33824
|
() => loadedOverrides.headerActions || defaultHeaderActionsRender,
|
33626
33825
|
[loadedOverrides]
|
33627
33826
|
);
|
33628
|
-
const [mounted, setMounted] = (0,
|
33629
|
-
(0,
|
33827
|
+
const [mounted, setMounted] = (0, import_react29.useState)(false);
|
33828
|
+
(0, import_react29.useEffect)(() => {
|
33630
33829
|
setMounted(true);
|
33631
33830
|
}, []);
|
33632
|
-
return /* @__PURE__ */ (0,
|
33831
|
+
return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: "Puck", children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
33633
33832
|
AppProvider,
|
33634
33833
|
{
|
33635
33834
|
value: {
|
@@ -33644,7 +33843,7 @@ function Puck({
|
|
33644
33843
|
viewports,
|
33645
33844
|
iframe
|
33646
33845
|
},
|
33647
|
-
children: /* @__PURE__ */ (0,
|
33846
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
33648
33847
|
DragDropContext,
|
33649
33848
|
{
|
33650
33849
|
autoScrollerOptions: { disabled: dnd == null ? void 0 : dnd.disableAutoScroll },
|
@@ -33700,7 +33899,7 @@ function Puck({
|
|
33700
33899
|
});
|
33701
33900
|
}
|
33702
33901
|
},
|
33703
|
-
children: /* @__PURE__ */ (0,
|
33902
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
33704
33903
|
DropZoneProvider,
|
33705
33904
|
{
|
33706
33905
|
value: {
|
@@ -33714,7 +33913,7 @@ function Puck({
|
|
33714
33913
|
mode: "edit",
|
33715
33914
|
areaId: "root"
|
33716
33915
|
},
|
33717
|
-
children: /* @__PURE__ */ (0,
|
33916
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(CustomPuck, { children: children || /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(
|
33718
33917
|
"div",
|
33719
33918
|
{
|
33720
33919
|
className: getClassName25({
|
@@ -33724,65 +33923,65 @@ function Puck({
|
|
33724
33923
|
rightSideBarVisible
|
33725
33924
|
}),
|
33726
33925
|
children: [
|
33727
|
-
/* @__PURE__ */ (0,
|
33728
|
-
/* @__PURE__ */ (0,
|
33926
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { className: getClassName25("layout"), children: [
|
33927
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
33729
33928
|
CustomHeader,
|
33730
33929
|
{
|
33731
|
-
actions: /* @__PURE__ */ (0,
|
33732
|
-
/* @__PURE__ */ (0,
|
33733
|
-
/* @__PURE__ */ (0,
|
33930
|
+
actions: /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(import_jsx_runtime35.Fragment, { children: [
|
33931
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)(CustomHeaderActions, {}),
|
33932
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
33734
33933
|
Button,
|
33735
33934
|
{
|
33736
33935
|
onClick: () => {
|
33737
33936
|
onPublish && onPublish(data);
|
33738
33937
|
},
|
33739
|
-
icon: /* @__PURE__ */ (0,
|
33938
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Globe, { size: "14px" }),
|
33740
33939
|
children: "Publish"
|
33741
33940
|
}
|
33742
33941
|
)
|
33743
33942
|
] }),
|
33744
|
-
children: /* @__PURE__ */ (0,
|
33745
|
-
/* @__PURE__ */ (0,
|
33746
|
-
/* @__PURE__ */ (0,
|
33943
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("header", { className: getClassName25("header"), children: /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { className: getClassName25("headerInner"), children: [
|
33944
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { className: getClassName25("headerToggle"), children: [
|
33945
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: getClassName25("leftSideBarToggle"), children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
33747
33946
|
IconButton,
|
33748
33947
|
{
|
33749
33948
|
onClick: () => {
|
33750
33949
|
toggleSidebars("left");
|
33751
33950
|
},
|
33752
33951
|
title: "Toggle left sidebar",
|
33753
|
-
children: /* @__PURE__ */ (0,
|
33952
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(PanelLeft, { focusable: "false" })
|
33754
33953
|
}
|
33755
33954
|
) }),
|
33756
|
-
/* @__PURE__ */ (0,
|
33955
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: getClassName25("rightSideBarToggle"), children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
33757
33956
|
IconButton,
|
33758
33957
|
{
|
33759
33958
|
onClick: () => {
|
33760
33959
|
toggleSidebars("right");
|
33761
33960
|
},
|
33762
33961
|
title: "Toggle right sidebar",
|
33763
|
-
children: /* @__PURE__ */ (0,
|
33962
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(PanelRight, { focusable: "false" })
|
33764
33963
|
}
|
33765
33964
|
) })
|
33766
33965
|
] }),
|
33767
|
-
/* @__PURE__ */ (0,
|
33966
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: getClassName25("headerTitle"), children: /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(Heading, { rank: 2, size: "xs", children: [
|
33768
33967
|
headerTitle || rootProps.title || "Page",
|
33769
|
-
headerPath && /* @__PURE__ */ (0,
|
33968
|
+
headerPath && /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(import_jsx_runtime35.Fragment, { children: [
|
33770
33969
|
" ",
|
33771
|
-
/* @__PURE__ */ (0,
|
33970
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)("code", { className: getClassName25("headerPath"), children: headerPath })
|
33772
33971
|
] })
|
33773
33972
|
] }) }),
|
33774
|
-
/* @__PURE__ */ (0,
|
33775
|
-
/* @__PURE__ */ (0,
|
33973
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { className: getClassName25("headerTools"), children: [
|
33974
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: getClassName25("menuButton"), children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
33776
33975
|
IconButton,
|
33777
33976
|
{
|
33778
33977
|
onClick: () => {
|
33779
33978
|
return setMenuOpen(!menuOpen);
|
33780
33979
|
},
|
33781
33980
|
title: "Toggle menu bar",
|
33782
|
-
children: menuOpen ? /* @__PURE__ */ (0,
|
33981
|
+
children: menuOpen ? /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(ChevronUp, { focusable: "false" }) : /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(ChevronDown, { focusable: "false" })
|
33783
33982
|
}
|
33784
33983
|
) }),
|
33785
|
-
/* @__PURE__ */ (0,
|
33984
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
33786
33985
|
MenuBar,
|
33787
33986
|
{
|
33788
33987
|
appState,
|
@@ -33790,7 +33989,7 @@ function Puck({
|
|
33790
33989
|
dispatch,
|
33791
33990
|
onPublish,
|
33792
33991
|
menuOpen,
|
33793
|
-
renderHeaderActions: () => /* @__PURE__ */ (0,
|
33992
|
+
renderHeaderActions: () => /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(CustomHeaderActions, {}),
|
33794
33993
|
setMenuOpen
|
33795
33994
|
}
|
33796
33995
|
)
|
@@ -33798,23 +33997,23 @@ function Puck({
|
|
33798
33997
|
] }) })
|
33799
33998
|
}
|
33800
33999
|
),
|
33801
|
-
/* @__PURE__ */ (0,
|
33802
|
-
/* @__PURE__ */ (0,
|
33803
|
-
/* @__PURE__ */ (0,
|
34000
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { className: getClassName25("leftSideBar"), children: [
|
34001
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)(SidebarSection, { title: "Components", noBorderTop: true, children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Components, {}) }),
|
34002
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)(SidebarSection, { title: "Outline", children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Outline, {}) })
|
33804
34003
|
] }),
|
33805
|
-
/* @__PURE__ */ (0,
|
33806
|
-
/* @__PURE__ */ (0,
|
34004
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Canvas, {}),
|
34005
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: getClassName25("rightSideBar"), children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
33807
34006
|
SidebarSection,
|
33808
34007
|
{
|
33809
34008
|
noPadding: true,
|
33810
34009
|
noBorderTop: true,
|
33811
34010
|
showBreadcrumbs: true,
|
33812
34011
|
title: selectedItem ? (_a = config.components[selectedItem.type]["label"]) != null ? _a : selectedItem.type : "Page",
|
33813
|
-
children: /* @__PURE__ */ (0,
|
34012
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Fields, {})
|
33814
34013
|
}
|
33815
34014
|
) })
|
33816
34015
|
] }),
|
33817
|
-
/* @__PURE__ */ (0,
|
34016
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
33818
34017
|
"div",
|
33819
34018
|
{
|
33820
34019
|
id: "puck-portal-root",
|
@@ -33838,7 +34037,7 @@ Puck.Preview = Preview;
|
|
33838
34037
|
|
33839
34038
|
// components/Render/index.tsx
|
33840
34039
|
init_react_import();
|
33841
|
-
var
|
34040
|
+
var import_jsx_runtime36 = require("react/jsx-runtime");
|
33842
34041
|
function Render({
|
33843
34042
|
config,
|
33844
34043
|
data
|
@@ -33847,7 +34046,7 @@ function Render({
|
|
33847
34046
|
const rootProps = data.root.props || data.root;
|
33848
34047
|
const title = (rootProps == null ? void 0 : rootProps.title) || "";
|
33849
34048
|
if ((_a = config.root) == null ? void 0 : _a.render) {
|
33850
|
-
return /* @__PURE__ */ (0,
|
34049
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(DropZoneProvider, { value: { data, config, mode: "render" }, children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
33851
34050
|
config.root.render,
|
33852
34051
|
__spreadProps(__spreadValues({}, rootProps), {
|
33853
34052
|
puck: {
|
@@ -33856,11 +34055,11 @@ function Render({
|
|
33856
34055
|
title,
|
33857
34056
|
editMode: false,
|
33858
34057
|
id: "puck-root",
|
33859
|
-
children: /* @__PURE__ */ (0,
|
34058
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(DropZone, { zone: rootDroppableId })
|
33860
34059
|
})
|
33861
34060
|
) });
|
33862
34061
|
}
|
33863
|
-
return /* @__PURE__ */ (0,
|
34062
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(DropZoneProvider, { value: { data, config, mode: "render" }, children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(DropZone, { zone: rootDroppableId }) });
|
33864
34063
|
}
|
33865
34064
|
|
33866
34065
|
// lib/migrate.ts
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@measured/puck",
|
3
|
-
"version": "0.14.
|
3
|
+
"version": "0.14.3-canary.73b83ef",
|
4
4
|
"author": "Measured Corporation Ltd <hello@measured.co>",
|
5
5
|
"repository": "measuredco/puck",
|
6
6
|
"bugs": "https://github.com/measuredco/puck/issues",
|
@@ -60,9 +60,10 @@
|
|
60
60
|
"typescript": "^4.5.2"
|
61
61
|
},
|
62
62
|
"dependencies": {
|
63
|
-
"@measured/auto-frame-component": "0.1.7",
|
64
63
|
"@measured/dnd": "16.6.0-canary.4cba1d1",
|
65
64
|
"deep-diff": "^1.0.2",
|
65
|
+
"object-hash": "^3.0.0",
|
66
|
+
"react-frame-component": "^5.2.6",
|
66
67
|
"react-hotkeys-hook": "^4.4.1",
|
67
68
|
"react-spinners": "^0.13.8",
|
68
69
|
"ua-parser-js": "^1.0.37",
|