@measured/puck 0.18.0-canary.cfe4ca8 → 0.18.0-canary.df3d1c2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +149 -106
- package/dist/index.mjs +140 -97
- package/package.json +1 -1
package/dist/index.js
CHANGED
@@ -1697,12 +1697,13 @@ var DefaultField = ({
|
|
1697
1697
|
field,
|
1698
1698
|
onChange,
|
1699
1699
|
readOnly,
|
1700
|
-
value,
|
1700
|
+
value: _value,
|
1701
1701
|
name,
|
1702
1702
|
label,
|
1703
1703
|
Label: Label2,
|
1704
1704
|
id
|
1705
1705
|
}) => {
|
1706
|
+
const value = _value;
|
1706
1707
|
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
1707
1708
|
Label2,
|
1708
1709
|
{
|
@@ -1720,7 +1721,7 @@ var DefaultField = ({
|
|
1720
1721
|
type: field.type,
|
1721
1722
|
title: label || name,
|
1722
1723
|
name,
|
1723
|
-
value:
|
1724
|
+
value: (value == null ? void 0 : value.toString) ? value.toString() : "",
|
1724
1725
|
onChange: (e) => {
|
1725
1726
|
if (field.type === "number") {
|
1726
1727
|
const numberValue = Number(e.currentTarget.value);
|
@@ -5408,7 +5409,7 @@ Drawer.Item = DrawerItem;
|
|
5408
5409
|
|
5409
5410
|
// components/Puck/index.tsx
|
5410
5411
|
init_react_import();
|
5411
|
-
var
|
5412
|
+
var import_react50 = require("react");
|
5412
5413
|
|
5413
5414
|
// components/SidebarSection/index.tsx
|
5414
5415
|
init_react_import();
|
@@ -5604,33 +5605,58 @@ init_react_import();
|
|
5604
5605
|
var styles_module_default16 = { "PuckFields": "_PuckFields_10bh7_1", "PuckFields--isLoading": "_PuckFields--isLoading_10bh7_6", "PuckFields-loadingOverlay": "_PuckFields-loadingOverlay_10bh7_10", "PuckFields-loadingOverlayInner": "_PuckFields-loadingOverlayInner_10bh7_25", "PuckFields-field": "_PuckFields-field_10bh7_32", "PuckFields--wrapFields": "_PuckFields--wrapFields_10bh7_36" };
|
5605
5606
|
|
5606
5607
|
// components/Puck/components/Fields/index.tsx
|
5607
|
-
var
|
5608
|
+
var import_react37 = require("react");
|
5609
|
+
|
5610
|
+
// lib/use-resolved-fields.ts
|
5611
|
+
init_react_import();
|
5612
|
+
var import_react36 = require("react");
|
5608
5613
|
|
5609
5614
|
// lib/use-parent.ts
|
5610
5615
|
init_react_import();
|
5611
5616
|
var import_react34 = require("react");
|
5612
|
-
var
|
5617
|
+
var getParent = (itemSelector, pathData, data) => {
|
5613
5618
|
var _a;
|
5614
|
-
|
5615
|
-
const
|
5616
|
-
const
|
5617
|
-
const breadcrumbs = convertPathDataToBreadcrumbs(item, pathData, state.data);
|
5619
|
+
if (!itemSelector) return null;
|
5620
|
+
const item = getItem(itemSelector, data);
|
5621
|
+
const breadcrumbs = convertPathDataToBreadcrumbs(item, pathData, data);
|
5618
5622
|
const lastItem = breadcrumbs[breadcrumbs.length - 1];
|
5619
|
-
const parent = (lastItem == null ? void 0 : lastItem.selector) ? (_a = getItem(lastItem.selector,
|
5623
|
+
const parent = (lastItem == null ? void 0 : lastItem.selector) ? (_a = getItem(lastItem.selector, data)) != null ? _a : null : null;
|
5620
5624
|
return parent || null;
|
5621
5625
|
};
|
5626
|
+
var useGetParent = () => {
|
5627
|
+
const { state } = useAppContext();
|
5628
|
+
const { pathData } = (0, import_react34.useContext)(dropZoneContext) || {};
|
5629
|
+
return (0, import_react34.useCallback)(
|
5630
|
+
() => getParent(state.ui.itemSelector, pathData, state.data),
|
5631
|
+
[state.ui.itemSelector, pathData, state.data]
|
5632
|
+
);
|
5633
|
+
};
|
5634
|
+
var useParent = () => {
|
5635
|
+
return useGetParent()();
|
5636
|
+
};
|
5622
5637
|
|
5623
|
-
//
|
5624
|
-
|
5625
|
-
var
|
5638
|
+
// lib/use-on-value-change.ts
|
5639
|
+
init_react_import();
|
5640
|
+
var import_react35 = require("react");
|
5641
|
+
function useOnValueChange(value, onChange, compare = Object.is, deps = []) {
|
5642
|
+
const tracked = (0, import_react35.useRef)(value);
|
5643
|
+
(0, import_react35.useEffect)(() => {
|
5644
|
+
const oldValue = tracked.current;
|
5645
|
+
if (!compare(value, oldValue)) {
|
5646
|
+
tracked.current = value;
|
5647
|
+
onChange(value, oldValue);
|
5648
|
+
}
|
5649
|
+
}, [onChange, compare, value, ...deps]);
|
5650
|
+
}
|
5651
|
+
|
5652
|
+
// lib/selector-is.ts
|
5653
|
+
init_react_import();
|
5654
|
+
var selectorIs = (a, b) => (a == null ? void 0 : a.zone) === (b == null ? void 0 : b.zone) && (a == null ? void 0 : a.index) === (b == null ? void 0 : b.index);
|
5655
|
+
|
5656
|
+
// lib/use-resolved-fields.ts
|
5626
5657
|
var defaultPageFields = {
|
5627
5658
|
title: { type: "text" }
|
5628
5659
|
};
|
5629
|
-
var DefaultFields = ({
|
5630
|
-
children
|
5631
|
-
}) => {
|
5632
|
-
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_jsx_runtime27.Fragment, { children });
|
5633
|
-
};
|
5634
5660
|
var useResolvedFields = () => {
|
5635
5661
|
var _a, _b;
|
5636
5662
|
const { selectedItem, state, config } = useAppContext();
|
@@ -5638,20 +5664,21 @@ var useResolvedFields = () => {
|
|
5638
5664
|
const { data } = state;
|
5639
5665
|
const rootFields = ((_a = config.root) == null ? void 0 : _a.fields) || defaultPageFields;
|
5640
5666
|
const componentConfig = selectedItem ? config.components[selectedItem.type] : null;
|
5641
|
-
const defaultFields = (0,
|
5667
|
+
const defaultFields = (0, import_react36.useMemo)(
|
5642
5668
|
() => (selectedItem ? componentConfig == null ? void 0 : componentConfig.fields : rootFields) || {},
|
5643
5669
|
[selectedItem, rootFields, componentConfig == null ? void 0 : componentConfig.fields]
|
5644
5670
|
);
|
5645
5671
|
const rootProps = data.root.props || data.root;
|
5646
|
-
const [lastSelectedData, setLastSelectedData] = (0,
|
5647
|
-
const [resolvedFields, setResolvedFields] = (0,
|
5648
|
-
const [fieldsLoading, setFieldsLoading] = (0,
|
5672
|
+
const [lastSelectedData, setLastSelectedData] = (0, import_react36.useState)({});
|
5673
|
+
const [resolvedFields, setResolvedFields] = (0, import_react36.useState)(defaultFields);
|
5674
|
+
const [fieldsLoading, setFieldsLoading] = (0, import_react36.useState)(false);
|
5675
|
+
const lastFields = (0, import_react36.useRef)(defaultFields);
|
5649
5676
|
const defaultResolveFields = (_componentData, _params) => defaultFields;
|
5650
5677
|
const componentData = selectedItem ? selectedItem : { props: rootProps, readOnly: data.root.readOnly };
|
5651
5678
|
const hasComponentResolver = selectedItem && (componentConfig == null ? void 0 : componentConfig.resolveFields);
|
5652
5679
|
const hasRootResolver = !selectedItem && ((_b = config.root) == null ? void 0 : _b.resolveFields);
|
5653
5680
|
const hasResolver = hasComponentResolver || hasRootResolver;
|
5654
|
-
const resolveFields = (0,
|
5681
|
+
const resolveFields = (0, import_react36.useCallback)(
|
5655
5682
|
(..._0) => __async(void 0, [..._0], function* (fields = {}) {
|
5656
5683
|
var _a2;
|
5657
5684
|
const lastData = ((_a2 = lastSelectedData.props) == null ? void 0 : _a2.id) === componentData.props.id ? lastSelectedData : null;
|
@@ -5663,7 +5690,7 @@ var useResolvedFields = () => {
|
|
5663
5690
|
{
|
5664
5691
|
changed,
|
5665
5692
|
fields,
|
5666
|
-
lastFields:
|
5693
|
+
lastFields: lastFields.current,
|
5667
5694
|
lastData,
|
5668
5695
|
appState: state,
|
5669
5696
|
parent
|
@@ -5674,7 +5701,7 @@ var useResolvedFields = () => {
|
|
5674
5701
|
return yield config.root.resolveFields(componentData, {
|
5675
5702
|
changed,
|
5676
5703
|
fields,
|
5677
|
-
lastFields:
|
5704
|
+
lastFields: lastFields.current,
|
5678
5705
|
lastData,
|
5679
5706
|
appState: state,
|
5680
5707
|
parent
|
@@ -5683,39 +5710,55 @@ var useResolvedFields = () => {
|
|
5683
5710
|
return defaultResolveFields(componentData, {
|
5684
5711
|
changed,
|
5685
5712
|
fields,
|
5686
|
-
lastFields:
|
5713
|
+
lastFields: lastFields.current,
|
5687
5714
|
lastData
|
5688
5715
|
});
|
5689
5716
|
}),
|
5690
|
-
[data, config, componentData, selectedItem,
|
5717
|
+
[data, config, componentData, selectedItem, state, parent]
|
5691
5718
|
);
|
5692
|
-
const
|
5693
|
-
(0, import_react35.useEffect)(() => {
|
5694
|
-
setHasParent(!!parent);
|
5695
|
-
}, [parent]);
|
5696
|
-
(0, import_react35.useEffect)(() => {
|
5719
|
+
const triggerResolver = (0, import_react36.useCallback)(() => {
|
5697
5720
|
var _a2, _b2;
|
5698
|
-
if (!((_a2 = state.ui.itemSelector) == null ? void 0 : _a2.zone) || ((_b2 = state.ui.itemSelector) == null ? void 0 : _b2.zone) === "default-zone" ||
|
5721
|
+
if (!((_a2 = state.ui.itemSelector) == null ? void 0 : _a2.zone) || ((_b2 = state.ui.itemSelector) == null ? void 0 : _b2.zone) === "default-zone" || parent) {
|
5699
5722
|
if (hasResolver) {
|
5700
5723
|
setFieldsLoading(true);
|
5701
5724
|
resolveFields(defaultFields).then((fields) => {
|
5702
5725
|
setResolvedFields(fields || {});
|
5726
|
+
lastFields.current = fields;
|
5703
5727
|
setFieldsLoading(false);
|
5704
5728
|
});
|
5705
5729
|
return;
|
5706
5730
|
}
|
5707
5731
|
}
|
5708
5732
|
setResolvedFields(defaultFields);
|
5709
|
-
}, [
|
5710
|
-
|
5711
|
-
defaultFields,
|
5733
|
+
}, [defaultFields, state.ui.itemSelector, hasResolver, parent]);
|
5734
|
+
useOnValueChange(
|
5712
5735
|
state.ui.itemSelector,
|
5713
|
-
|
5714
|
-
|
5715
|
-
|
5716
|
-
|
5736
|
+
() => {
|
5737
|
+
lastFields.current = defaultFields;
|
5738
|
+
},
|
5739
|
+
selectorIs
|
5740
|
+
);
|
5741
|
+
useOnValueChange(
|
5742
|
+
{ data, parent, itemSelector: state.ui.itemSelector },
|
5743
|
+
() => {
|
5744
|
+
triggerResolver();
|
5745
|
+
},
|
5746
|
+
(a, b) => JSON.stringify(a) === JSON.stringify(b)
|
5747
|
+
);
|
5748
|
+
(0, import_react36.useEffect)(() => {
|
5749
|
+
triggerResolver();
|
5750
|
+
}, []);
|
5717
5751
|
return [resolvedFields, fieldsLoading];
|
5718
5752
|
};
|
5753
|
+
|
5754
|
+
// components/Puck/components/Fields/index.tsx
|
5755
|
+
var import_jsx_runtime27 = require("react/jsx-runtime");
|
5756
|
+
var getClassName21 = get_class_name_factory_default("PuckFields", styles_module_default16);
|
5757
|
+
var DefaultFields = ({
|
5758
|
+
children
|
5759
|
+
}) => {
|
5760
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_jsx_runtime27.Fragment, { children });
|
5761
|
+
};
|
5719
5762
|
var Fields = ({ wrapFields = true }) => {
|
5720
5763
|
var _a, _b;
|
5721
5764
|
const {
|
@@ -5734,7 +5777,7 @@ var Fields = ({ wrapFields = true }) => {
|
|
5734
5777
|
const componentResolving = selectedItem ? ((_a = componentState[selectedItem == null ? void 0 : selectedItem.props.id]) == null ? void 0 : _a.loadingCount) > 0 : ((_b = componentState["puck-root"]) == null ? void 0 : _b.loadingCount) > 0;
|
5735
5778
|
const isLoading = fieldsResolving || componentResolving;
|
5736
5779
|
const rootProps = data.root.props || data.root;
|
5737
|
-
const Wrapper = (0,
|
5780
|
+
const Wrapper = (0, import_react37.useMemo)(() => overrides.fields || DefaultFields, [overrides]);
|
5738
5781
|
return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
|
5739
5782
|
"form",
|
5740
5783
|
{
|
@@ -5855,7 +5898,7 @@ init_react_import();
|
|
5855
5898
|
|
5856
5899
|
// lib/use-component-list.tsx
|
5857
5900
|
init_react_import();
|
5858
|
-
var
|
5901
|
+
var import_react38 = require("react");
|
5859
5902
|
|
5860
5903
|
// components/ComponentList/index.tsx
|
5861
5904
|
init_react_import();
|
@@ -5922,8 +5965,8 @@ ComponentList.Item = ComponentListItem;
|
|
5922
5965
|
// lib/use-component-list.tsx
|
5923
5966
|
var import_jsx_runtime29 = require("react/jsx-runtime");
|
5924
5967
|
var useComponentList = (config, ui) => {
|
5925
|
-
const [componentList, setComponentList] = (0,
|
5926
|
-
(0,
|
5968
|
+
const [componentList, setComponentList] = (0, import_react38.useState)();
|
5969
|
+
(0, import_react38.useEffect)(() => {
|
5927
5970
|
var _a, _b, _c;
|
5928
5971
|
if (Object.keys(ui.componentList).length > 0) {
|
5929
5972
|
const matchedComponents = [];
|
@@ -5992,22 +6035,22 @@ var useComponentList = (config, ui) => {
|
|
5992
6035
|
};
|
5993
6036
|
|
5994
6037
|
// components/Puck/components/Components/index.tsx
|
5995
|
-
var
|
6038
|
+
var import_react39 = require("react");
|
5996
6039
|
var import_jsx_runtime30 = require("react/jsx-runtime");
|
5997
6040
|
var Components = () => {
|
5998
6041
|
const { config, state, overrides } = useAppContext();
|
5999
6042
|
const componentList = useComponentList(config, state.ui);
|
6000
|
-
const Wrapper = (0,
|
6043
|
+
const Wrapper = (0, import_react39.useMemo)(() => overrides.components || "div", [overrides]);
|
6001
6044
|
return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Wrapper, { children: componentList ? componentList : /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(ComponentList, { id: "all" }) });
|
6002
6045
|
};
|
6003
6046
|
|
6004
6047
|
// components/Puck/components/Preview/index.tsx
|
6005
6048
|
init_react_import();
|
6006
|
-
var
|
6049
|
+
var import_react41 = require("react");
|
6007
6050
|
|
6008
6051
|
// components/AutoFrame/index.tsx
|
6009
6052
|
init_react_import();
|
6010
|
-
var
|
6053
|
+
var import_react40 = require("react");
|
6011
6054
|
var import_object_hash = __toESM(require("object-hash"));
|
6012
6055
|
var import_react_dom3 = require("react-dom");
|
6013
6056
|
var import_jsx_runtime31 = require("react/jsx-runtime");
|
@@ -6053,7 +6096,7 @@ var CopyHostStyles = ({
|
|
6053
6096
|
onStylesLoaded = () => null
|
6054
6097
|
}) => {
|
6055
6098
|
const { document: doc, window: win } = useFrame();
|
6056
|
-
(0,
|
6099
|
+
(0, import_react40.useEffect)(() => {
|
6057
6100
|
if (!win || !doc) {
|
6058
6101
|
return () => {
|
6059
6102
|
};
|
@@ -6212,8 +6255,8 @@ var CopyHostStyles = ({
|
|
6212
6255
|
}, []);
|
6213
6256
|
return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_jsx_runtime31.Fragment, { children });
|
6214
6257
|
};
|
6215
|
-
var autoFrameContext = (0,
|
6216
|
-
var useFrame = () => (0,
|
6258
|
+
var autoFrameContext = (0, import_react40.createContext)({});
|
6259
|
+
var useFrame = () => (0, import_react40.useContext)(autoFrameContext);
|
6217
6260
|
function AutoFrame(_a) {
|
6218
6261
|
var _b = _a, {
|
6219
6262
|
children,
|
@@ -6230,10 +6273,10 @@ function AutoFrame(_a) {
|
|
6230
6273
|
"onStylesLoaded",
|
6231
6274
|
"frameRef"
|
6232
6275
|
]);
|
6233
|
-
const [loaded, setLoaded] = (0,
|
6234
|
-
const [ctx, setCtx] = (0,
|
6235
|
-
const [mountTarget, setMountTarget] = (0,
|
6236
|
-
(0,
|
6276
|
+
const [loaded, setLoaded] = (0, import_react40.useState)(false);
|
6277
|
+
const [ctx, setCtx] = (0, import_react40.useState)({});
|
6278
|
+
const [mountTarget, setMountTarget] = (0, import_react40.useState)();
|
6279
|
+
(0, import_react40.useEffect)(() => {
|
6237
6280
|
var _a2;
|
6238
6281
|
if (frameRef.current) {
|
6239
6282
|
setCtx({
|
@@ -6327,7 +6370,7 @@ var import_jsx_runtime33 = require("react/jsx-runtime");
|
|
6327
6370
|
var getClassName23 = get_class_name_factory_default("PuckPreview", styles_module_default18);
|
6328
6371
|
var useBubbleIframeEvents = (ref) => {
|
6329
6372
|
const { status } = useAppContext();
|
6330
|
-
(0,
|
6373
|
+
(0, import_react41.useEffect)(() => {
|
6331
6374
|
var _a;
|
6332
6375
|
if (ref.current && status === "READY") {
|
6333
6376
|
const iframe = ref.current;
|
@@ -6366,7 +6409,7 @@ var useBubbleIframeEvents = (ref) => {
|
|
6366
6409
|
};
|
6367
6410
|
var Preview2 = ({ id = "puck-preview" }) => {
|
6368
6411
|
const { config, dispatch, state, setStatus, iframe, overrides } = useAppContext();
|
6369
|
-
const Page = (0,
|
6412
|
+
const Page = (0, import_react41.useCallback)(
|
6370
6413
|
(pageProps) => {
|
6371
6414
|
var _a, _b;
|
6372
6415
|
return ((_a = config.root) == null ? void 0 : _a.render) ? (_b = config.root) == null ? void 0 : _b.render(__spreadValues({
|
@@ -6375,9 +6418,9 @@ var Preview2 = ({ id = "puck-preview" }) => {
|
|
6375
6418
|
},
|
6376
6419
|
[config.root]
|
6377
6420
|
);
|
6378
|
-
const Frame = (0,
|
6421
|
+
const Frame = (0, import_react41.useMemo)(() => overrides.iframe, [overrides]);
|
6379
6422
|
const rootProps = state.data.root.props || state.data.root;
|
6380
|
-
const ref = (0,
|
6423
|
+
const ref = (0, import_react41.useRef)(null);
|
6381
6424
|
useBubbleIframeEvents(ref);
|
6382
6425
|
const inner = state.ui.previewMode === "edit" ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
6383
6426
|
Page,
|
@@ -6474,7 +6517,7 @@ var scrollIntoView = (el) => {
|
|
6474
6517
|
};
|
6475
6518
|
|
6476
6519
|
// components/LayerTree/index.tsx
|
6477
|
-
var
|
6520
|
+
var import_react42 = require("react");
|
6478
6521
|
|
6479
6522
|
// lib/is-child-of-zone.ts
|
6480
6523
|
init_react_import();
|
@@ -6520,7 +6563,7 @@ var LayerTree = ({
|
|
6520
6563
|
label
|
6521
6564
|
}) => {
|
6522
6565
|
const zones = data.zones || {};
|
6523
|
-
const ctx = (0,
|
6566
|
+
const ctx = (0, import_react42.useContext)(dropZoneContext);
|
6524
6567
|
return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(import_jsx_runtime34.Fragment, { children: [
|
6525
6568
|
label && /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("div", { className: getClassName24("zoneTitle"), children: [
|
6526
6569
|
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: getClassName24("zoneIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Layers, { size: "16" }) }),
|
@@ -6627,13 +6670,13 @@ var LayerTree = ({
|
|
6627
6670
|
};
|
6628
6671
|
|
6629
6672
|
// components/Puck/components/Outline/index.tsx
|
6630
|
-
var
|
6673
|
+
var import_react43 = require("react");
|
6631
6674
|
var import_jsx_runtime35 = require("react/jsx-runtime");
|
6632
6675
|
var Outline = () => {
|
6633
6676
|
const { dispatch, state, overrides, config } = useAppContext();
|
6634
6677
|
const { data, ui } = state;
|
6635
6678
|
const { itemSelector } = ui;
|
6636
|
-
const setItemSelector = (0,
|
6679
|
+
const setItemSelector = (0, import_react43.useCallback)(
|
6637
6680
|
(newItemSelector) => {
|
6638
6681
|
dispatch({
|
6639
6682
|
type: "setUi",
|
@@ -6642,7 +6685,7 @@ var Outline = () => {
|
|
6642
6685
|
},
|
6643
6686
|
[]
|
6644
6687
|
);
|
6645
|
-
const Wrapper = (0,
|
6688
|
+
const Wrapper = (0, import_react43.useMemo)(() => overrides.outline || "div", [overrides]);
|
6646
6689
|
return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Wrapper, { children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(dropZoneContext.Consumer, { children: (ctx) => /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(import_jsx_runtime35.Fragment, { children: [
|
6647
6690
|
(ctx == null ? void 0 : ctx.activeZones) && (ctx == null ? void 0 : ctx.activeZones[rootDroppableId]) && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
6648
6691
|
LayerTree,
|
@@ -6756,19 +6799,19 @@ function usePuckHistory({
|
|
6756
6799
|
|
6757
6800
|
// lib/use-history-store.ts
|
6758
6801
|
init_react_import();
|
6759
|
-
var
|
6802
|
+
var import_react44 = require("react");
|
6760
6803
|
var import_use_debounce3 = require("use-debounce");
|
6761
6804
|
var EMPTY_HISTORY_INDEX = 0;
|
6762
6805
|
function useHistoryStore(initialHistory) {
|
6763
6806
|
var _a, _b;
|
6764
|
-
const [histories, setHistories] = (0,
|
6807
|
+
const [histories, setHistories] = (0, import_react44.useState)(
|
6765
6808
|
(_a = initialHistory == null ? void 0 : initialHistory.histories) != null ? _a : []
|
6766
6809
|
);
|
6767
6810
|
const updateHistories = (histories2) => {
|
6768
6811
|
setHistories(histories2);
|
6769
6812
|
setIndex(histories2.length - 1);
|
6770
6813
|
};
|
6771
|
-
const [index, setIndex] = (0,
|
6814
|
+
const [index, setIndex] = (0, import_react44.useState)(
|
6772
6815
|
(_b = initialHistory == null ? void 0 : initialHistory.index) != null ? _b : EMPTY_HISTORY_INDEX
|
6773
6816
|
);
|
6774
6817
|
const hasPast = index > EMPTY_HISTORY_INDEX;
|
@@ -6928,11 +6971,11 @@ var getBox = function getBox2(el) {
|
|
6928
6971
|
};
|
6929
6972
|
|
6930
6973
|
// components/Puck/components/Canvas/index.tsx
|
6931
|
-
var
|
6974
|
+
var import_react46 = require("react");
|
6932
6975
|
|
6933
6976
|
// components/ViewportControls/index.tsx
|
6934
6977
|
init_react_import();
|
6935
|
-
var
|
6978
|
+
var import_react45 = require("react");
|
6936
6979
|
|
6937
6980
|
// css-module:/home/runner/work/puck/puck/packages/core/components/ViewportControls/styles.module.css#css-module
|
6938
6981
|
init_react_import();
|
@@ -6955,8 +6998,8 @@ var ViewportButton = ({
|
|
6955
6998
|
onClick
|
6956
6999
|
}) => {
|
6957
7000
|
const { state } = useAppContext();
|
6958
|
-
const [isActive, setIsActive] = (0,
|
6959
|
-
(0,
|
7001
|
+
const [isActive, setIsActive] = (0, import_react45.useState)(false);
|
7002
|
+
(0, import_react45.useEffect)(() => {
|
6960
7003
|
setIsActive(width === state.ui.viewports.current.width);
|
6961
7004
|
}, [width, state.ui.viewports.current.width]);
|
6962
7005
|
return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("span", { className: getClassNameButton({ isActive }), children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
@@ -6992,7 +7035,7 @@ var ViewportControls = ({
|
|
6992
7035
|
const defaultsContainAutoZoom = defaultZoomOptions.find(
|
6993
7036
|
(option) => option.value === autoZoom
|
6994
7037
|
);
|
6995
|
-
const zoomOptions = (0,
|
7038
|
+
const zoomOptions = (0, import_react45.useMemo)(
|
6996
7039
|
() => [
|
6997
7040
|
...defaultZoomOptions,
|
6998
7041
|
...defaultsContainAutoZoom ? [] : [
|
@@ -7115,17 +7158,17 @@ var Canvas = () => {
|
|
7115
7158
|
const { status, iframe } = useAppContext();
|
7116
7159
|
const { dispatch, state, overrides, setUi, zoomConfig, setZoomConfig } = useAppContext();
|
7117
7160
|
const { ui } = state;
|
7118
|
-
const frameRef = (0,
|
7119
|
-
const [showTransition, setShowTransition] = (0,
|
7120
|
-
const defaultRender = (0,
|
7161
|
+
const frameRef = (0, import_react46.useRef)(null);
|
7162
|
+
const [showTransition, setShowTransition] = (0, import_react46.useState)(false);
|
7163
|
+
const defaultRender = (0, import_react46.useMemo)(() => {
|
7121
7164
|
const PuckDefault = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(import_jsx_runtime37.Fragment, { children });
|
7122
7165
|
return PuckDefault;
|
7123
7166
|
}, []);
|
7124
|
-
const CustomPreview = (0,
|
7167
|
+
const CustomPreview = (0, import_react46.useMemo)(
|
7125
7168
|
() => overrides.preview || defaultRender,
|
7126
7169
|
[overrides]
|
7127
7170
|
);
|
7128
|
-
const getFrameDimensions = (0,
|
7171
|
+
const getFrameDimensions = (0, import_react46.useCallback)(() => {
|
7129
7172
|
if (frameRef.current) {
|
7130
7173
|
const frame = frameRef.current;
|
7131
7174
|
const box = getBox(frame);
|
@@ -7133,7 +7176,7 @@ var Canvas = () => {
|
|
7133
7176
|
}
|
7134
7177
|
return { width: 0, height: 0 };
|
7135
7178
|
}, [frameRef]);
|
7136
|
-
const resetAutoZoom = (0,
|
7179
|
+
const resetAutoZoom = (0, import_react46.useCallback)(
|
7137
7180
|
(ui2 = state.ui) => {
|
7138
7181
|
if (frameRef.current) {
|
7139
7182
|
setZoomConfig(
|
@@ -7143,11 +7186,11 @@ var Canvas = () => {
|
|
7143
7186
|
},
|
7144
7187
|
[frameRef, zoomConfig, state.ui]
|
7145
7188
|
);
|
7146
|
-
(0,
|
7189
|
+
(0, import_react46.useEffect)(() => {
|
7147
7190
|
setShowTransition(false);
|
7148
7191
|
resetAutoZoom();
|
7149
7192
|
}, [frameRef, ui.leftSideBarVisible, ui.rightSideBarVisible]);
|
7150
|
-
(0,
|
7193
|
+
(0, import_react46.useEffect)(() => {
|
7151
7194
|
const { height: frameHeight } = getFrameDimensions();
|
7152
7195
|
if (ui.viewports.current.height === "auto") {
|
7153
7196
|
setZoomConfig(__spreadProps(__spreadValues({}, zoomConfig), {
|
@@ -7155,13 +7198,13 @@ var Canvas = () => {
|
|
7155
7198
|
}));
|
7156
7199
|
}
|
7157
7200
|
}, [zoomConfig.zoom]);
|
7158
|
-
(0,
|
7201
|
+
(0, import_react46.useEffect)(() => {
|
7159
7202
|
if (ZOOM_ON_CHANGE) {
|
7160
7203
|
setShowTransition(true);
|
7161
7204
|
resetAutoZoom(ui);
|
7162
7205
|
}
|
7163
7206
|
}, [ui.viewports.current.width]);
|
7164
|
-
(0,
|
7207
|
+
(0, import_react46.useEffect)(() => {
|
7165
7208
|
const cb = () => {
|
7166
7209
|
setShowTransition(false);
|
7167
7210
|
resetAutoZoom();
|
@@ -7171,8 +7214,8 @@ var Canvas = () => {
|
|
7171
7214
|
window.removeEventListener("resize", cb);
|
7172
7215
|
};
|
7173
7216
|
}, []);
|
7174
|
-
const [showLoader, setShowLoader] = (0,
|
7175
|
-
(0,
|
7217
|
+
const [showLoader, setShowLoader] = (0, import_react46.useState)(false);
|
7218
|
+
(0, import_react46.useEffect)(() => {
|
7176
7219
|
setTimeout(() => {
|
7177
7220
|
setShowLoader(true);
|
7178
7221
|
}, 500);
|
@@ -7250,7 +7293,7 @@ var Canvas = () => {
|
|
7250
7293
|
|
7251
7294
|
// lib/use-loaded-overrides.ts
|
7252
7295
|
init_react_import();
|
7253
|
-
var
|
7296
|
+
var import_react47 = require("react");
|
7254
7297
|
|
7255
7298
|
// lib/load-overrides.ts
|
7256
7299
|
init_react_import();
|
@@ -7289,7 +7332,7 @@ var useLoadedOverrides = ({
|
|
7289
7332
|
overrides,
|
7290
7333
|
plugins
|
7291
7334
|
}) => {
|
7292
|
-
return (0,
|
7335
|
+
return (0, import_react47.useMemo)(() => {
|
7293
7336
|
return loadOverrides({ overrides, plugins });
|
7294
7337
|
}, [plugins, overrides]);
|
7295
7338
|
};
|
@@ -7301,14 +7344,14 @@ var DefaultOverride = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime38
|
|
7301
7344
|
|
7302
7345
|
// lib/use-inject-css.ts
|
7303
7346
|
init_react_import();
|
7304
|
-
var
|
7347
|
+
var import_react48 = require("react");
|
7305
7348
|
var styles = ``;
|
7306
7349
|
var useInjectStyleSheet = (initialStyles, iframeEnabled) => {
|
7307
|
-
const [el, setEl] = (0,
|
7308
|
-
(0,
|
7350
|
+
const [el, setEl] = (0, import_react48.useState)();
|
7351
|
+
(0, import_react48.useEffect)(() => {
|
7309
7352
|
setEl(document.createElement("style"));
|
7310
7353
|
}, []);
|
7311
|
-
(0,
|
7354
|
+
(0, import_react48.useEffect)(() => {
|
7312
7355
|
var _a;
|
7313
7356
|
if (!el || typeof window === "undefined") {
|
7314
7357
|
return;
|
@@ -7328,10 +7371,10 @@ var useInjectGlobalCss = (iframeEnabled) => {
|
|
7328
7371
|
|
7329
7372
|
// lib/use-preview-mode-hotkeys.ts
|
7330
7373
|
init_react_import();
|
7331
|
-
var
|
7374
|
+
var import_react49 = require("react");
|
7332
7375
|
var import_react_hotkeys_hook2 = require("react-hotkeys-hook");
|
7333
7376
|
var usePreviewModeHotkeys = (dispatch, iframeEnabled) => {
|
7334
|
-
const toggleInteractive = (0,
|
7377
|
+
const toggleInteractive = (0, import_react49.useCallback)(() => {
|
7335
7378
|
dispatch({
|
7336
7379
|
type: "setUi",
|
7337
7380
|
ui: (ui) => ({
|
@@ -7383,7 +7426,7 @@ function Puck({
|
|
7383
7426
|
waitForStyles: true
|
7384
7427
|
}, _iframe);
|
7385
7428
|
useInjectGlobalCss(iframe.enabled);
|
7386
|
-
const [generatedAppState] = (0,
|
7429
|
+
const [generatedAppState] = (0, import_react50.useState)(() => {
|
7387
7430
|
var _a2, _b2, _c, _d, _e, _f, _g, _h, _i;
|
7388
7431
|
const initial = __spreadValues(__spreadValues({}, defaultAppState.ui), initialUi);
|
7389
7432
|
let clientUiState = {};
|
@@ -7455,14 +7498,14 @@ function Puck({
|
|
7455
7498
|
histories,
|
7456
7499
|
index: initialHistoryIndex
|
7457
7500
|
});
|
7458
|
-
const [reducer] = (0,
|
7501
|
+
const [reducer] = (0, import_react50.useState)(
|
7459
7502
|
() => createReducer({
|
7460
7503
|
config,
|
7461
7504
|
record: historyStore.record,
|
7462
7505
|
onAction
|
7463
7506
|
})
|
7464
7507
|
);
|
7465
|
-
const [appState, dispatch] = (0,
|
7508
|
+
const [appState, dispatch] = (0, import_react50.useReducer)(
|
7466
7509
|
reducer,
|
7467
7510
|
flushZones(initialAppState)
|
7468
7511
|
);
|
@@ -7473,14 +7516,14 @@ function Puck({
|
|
7473
7516
|
historyStore,
|
7474
7517
|
iframeEnabled: (_a = _iframe == null ? void 0 : _iframe.enabled) != null ? _a : true
|
7475
7518
|
});
|
7476
|
-
const [menuOpen, setMenuOpen] = (0,
|
7519
|
+
const [menuOpen, setMenuOpen] = (0, import_react50.useState)(false);
|
7477
7520
|
const { itemSelector, leftSideBarVisible, rightSideBarVisible } = ui;
|
7478
7521
|
const selectedItem = itemSelector ? getItem(itemSelector, data) : null;
|
7479
|
-
(0,
|
7522
|
+
(0, import_react50.useEffect)(() => {
|
7480
7523
|
if (onChange) onChange(data);
|
7481
7524
|
}, [data]);
|
7482
7525
|
const rootProps = data.root.props || data.root;
|
7483
|
-
const toggleSidebars = (0,
|
7526
|
+
const toggleSidebars = (0, import_react50.useCallback)(
|
7484
7527
|
(sidebar) => {
|
7485
7528
|
const widerViewport = window.matchMedia("(min-width: 638px)").matches;
|
7486
7529
|
const sideBarVisible = sidebar === "left" ? leftSideBarVisible : rightSideBarVisible;
|
@@ -7494,7 +7537,7 @@ function Puck({
|
|
7494
7537
|
},
|
7495
7538
|
[dispatch, leftSideBarVisible, rightSideBarVisible]
|
7496
7539
|
);
|
7497
|
-
(0,
|
7540
|
+
(0, import_react50.useEffect)(() => {
|
7498
7541
|
if (!window.matchMedia("(min-width: 638px)").matches) {
|
7499
7542
|
dispatch({
|
7500
7543
|
type: "setUi",
|
@@ -7517,7 +7560,7 @@ function Puck({
|
|
7517
7560
|
window.removeEventListener("resize", handleResize);
|
7518
7561
|
};
|
7519
7562
|
}, []);
|
7520
|
-
const defaultHeaderRender = (0,
|
7563
|
+
const defaultHeaderRender = (0, import_react50.useMemo)(() => {
|
7521
7564
|
if (renderHeader) {
|
7522
7565
|
console.warn(
|
7523
7566
|
"`renderHeader` is deprecated. Please use `overrides.header` and the `usePuck` hook instead"
|
@@ -7531,7 +7574,7 @@ function Puck({
|
|
7531
7574
|
}
|
7532
7575
|
return DefaultOverride;
|
7533
7576
|
}, [renderHeader]);
|
7534
|
-
const defaultHeaderActionsRender = (0,
|
7577
|
+
const defaultHeaderActionsRender = (0, import_react50.useMemo)(() => {
|
7535
7578
|
if (renderHeaderActions) {
|
7536
7579
|
console.warn(
|
7537
7580
|
"`renderHeaderActions` is deprecated. Please use `overrides.headerActions` and the `usePuck` hook instead."
|
@@ -7548,20 +7591,20 @@ function Puck({
|
|
7548
7591
|
overrides,
|
7549
7592
|
plugins
|
7550
7593
|
});
|
7551
|
-
const CustomPuck = (0,
|
7594
|
+
const CustomPuck = (0, import_react50.useMemo)(
|
7552
7595
|
() => loadedOverrides.puck || DefaultOverride,
|
7553
7596
|
[loadedOverrides]
|
7554
7597
|
);
|
7555
|
-
const CustomHeader = (0,
|
7598
|
+
const CustomHeader = (0, import_react50.useMemo)(
|
7556
7599
|
() => loadedOverrides.header || defaultHeaderRender,
|
7557
7600
|
[loadedOverrides]
|
7558
7601
|
);
|
7559
|
-
const CustomHeaderActions = (0,
|
7602
|
+
const CustomHeaderActions = (0, import_react50.useMemo)(
|
7560
7603
|
() => loadedOverrides.headerActions || defaultHeaderActionsRender,
|
7561
7604
|
[loadedOverrides]
|
7562
7605
|
);
|
7563
|
-
const [mounted, setMounted] = (0,
|
7564
|
-
(0,
|
7606
|
+
const [mounted, setMounted] = (0, import_react50.useState)(false);
|
7607
|
+
(0, import_react50.useEffect)(() => {
|
7565
7608
|
setMounted(true);
|
7566
7609
|
}, []);
|
7567
7610
|
const selectedComponentConfig = selectedItem && config.components[selectedItem.type];
|
package/dist/index.mjs
CHANGED
@@ -1504,12 +1504,13 @@ var DefaultField = ({
|
|
1504
1504
|
field,
|
1505
1505
|
onChange,
|
1506
1506
|
readOnly,
|
1507
|
-
value,
|
1507
|
+
value: _value,
|
1508
1508
|
name,
|
1509
1509
|
label,
|
1510
1510
|
Label: Label2,
|
1511
1511
|
id
|
1512
1512
|
}) => {
|
1513
|
+
const value = _value;
|
1513
1514
|
return /* @__PURE__ */ jsx9(
|
1514
1515
|
Label2,
|
1515
1516
|
{
|
@@ -1527,7 +1528,7 @@ var DefaultField = ({
|
|
1527
1528
|
type: field.type,
|
1528
1529
|
title: label || name,
|
1529
1530
|
name,
|
1530
|
-
value:
|
1531
|
+
value: (value == null ? void 0 : value.toString) ? value.toString() : "",
|
1531
1532
|
onChange: (e) => {
|
1532
1533
|
if (field.type === "number") {
|
1533
1534
|
const numberValue = Number(e.currentTarget.value);
|
@@ -2436,7 +2437,7 @@ import {
|
|
2436
2437
|
useContext as useContext7,
|
2437
2438
|
useEffect as useEffect15,
|
2438
2439
|
useId,
|
2439
|
-
useRef as
|
2440
|
+
useRef as useRef3,
|
2440
2441
|
useState as useState17
|
2441
2442
|
} from "react";
|
2442
2443
|
import { AutoScroller, defaultPreset } from "@dnd-kit/dom";
|
@@ -2449,7 +2450,7 @@ import {
|
|
2449
2450
|
useContext as useContext6,
|
2450
2451
|
useEffect as useEffect14,
|
2451
2452
|
useMemo as useMemo8,
|
2452
|
-
useRef as
|
2453
|
+
useRef as useRef2
|
2453
2454
|
} from "react";
|
2454
2455
|
|
2455
2456
|
// components/DraggableComponent/index.tsx
|
@@ -2459,7 +2460,7 @@ import {
|
|
2459
2460
|
useContext as useContext5,
|
2460
2461
|
useEffect as useEffect10,
|
2461
2462
|
useMemo as useMemo7,
|
2462
|
-
useRef
|
2463
|
+
useRef,
|
2463
2464
|
useState as useState13
|
2464
2465
|
} from "react";
|
2465
2466
|
|
@@ -3047,7 +3048,7 @@ var DraggableComponent = ({
|
|
3047
3048
|
}
|
3048
3049
|
});
|
3049
3050
|
const thisIsDragging = status === "dragging";
|
3050
|
-
const ref =
|
3051
|
+
const ref = useRef(null);
|
3051
3052
|
const refSetter = useCallback7(
|
3052
3053
|
(el) => {
|
3053
3054
|
sortableRef(el);
|
@@ -3577,7 +3578,7 @@ var DropZoneEdit = forwardRef3(
|
|
3577
3578
|
}
|
3578
3579
|
return data.content || [];
|
3579
3580
|
}, [data, zoneCompound]);
|
3580
|
-
const ref =
|
3581
|
+
const ref = useRef2(null);
|
3581
3582
|
const acceptsTarget = useCallback10(
|
3582
3583
|
(componentType) => {
|
3583
3584
|
if (!componentType) {
|
@@ -4734,7 +4735,7 @@ function useDragListener(type, fn, deps = []) {
|
|
4734
4735
|
}
|
4735
4736
|
var AREA_CHANGE_DEBOUNCE_MS = 100;
|
4736
4737
|
var useTempDisableFallback = (timeout3) => {
|
4737
|
-
const lastFallbackDisable =
|
4738
|
+
const lastFallbackDisable = useRef3(null);
|
4738
4739
|
return useCallback11((manager) => {
|
4739
4740
|
collisionStore.setState({ fallbackEnabled: false });
|
4740
4741
|
const fallbackId = generateId();
|
@@ -4754,7 +4755,7 @@ var DragDropContextClient = ({
|
|
4754
4755
|
const { state, config, dispatch, resolveData } = useAppContext();
|
4755
4756
|
const id = useId();
|
4756
4757
|
const { data } = state;
|
4757
|
-
const debouncedParamsRef =
|
4758
|
+
const debouncedParamsRef = useRef3(null);
|
4758
4759
|
const tempDisableFallback = useTempDisableFallback(100);
|
4759
4760
|
const [zoneStore] = useState17(
|
4760
4761
|
() => createStore3(() => ({
|
@@ -4893,7 +4894,7 @@ var DragDropContextClient = ({
|
|
4893
4894
|
]);
|
4894
4895
|
const [dragListeners, setDragListeners] = useState17({});
|
4895
4896
|
const [pathData, setPathData] = useState17();
|
4896
|
-
const dragMode =
|
4897
|
+
const dragMode = useRef3(null);
|
4897
4898
|
const registerPath = useCallback11(
|
4898
4899
|
(selector) => {
|
4899
4900
|
const item = getItem(selector, data);
|
@@ -4916,7 +4917,7 @@ var DragDropContextClient = ({
|
|
4916
4917
|
},
|
4917
4918
|
[data, setPathData]
|
4918
4919
|
);
|
4919
|
-
const initialSelector =
|
4920
|
+
const initialSelector = useRef3(void 0);
|
4920
4921
|
return /* @__PURE__ */ jsx23("div", { id, children: /* @__PURE__ */ jsx23(
|
4921
4922
|
dragListenerContext.Provider,
|
4922
4923
|
{
|
@@ -5261,9 +5262,9 @@ Drawer.Item = DrawerItem;
|
|
5261
5262
|
// components/Puck/index.tsx
|
5262
5263
|
init_react_import();
|
5263
5264
|
import {
|
5264
|
-
useCallback as
|
5265
|
-
useEffect as
|
5266
|
-
useMemo as
|
5265
|
+
useCallback as useCallback18,
|
5266
|
+
useEffect as useEffect24,
|
5267
|
+
useMemo as useMemo19,
|
5267
5268
|
useReducer,
|
5268
5269
|
useState as useState26
|
5269
5270
|
} from "react";
|
@@ -5462,33 +5463,58 @@ init_react_import();
|
|
5462
5463
|
var styles_module_default16 = { "PuckFields": "_PuckFields_10bh7_1", "PuckFields--isLoading": "_PuckFields--isLoading_10bh7_6", "PuckFields-loadingOverlay": "_PuckFields-loadingOverlay_10bh7_10", "PuckFields-loadingOverlayInner": "_PuckFields-loadingOverlayInner_10bh7_25", "PuckFields-field": "_PuckFields-field_10bh7_32", "PuckFields--wrapFields": "_PuckFields--wrapFields_10bh7_36" };
|
5463
5464
|
|
5464
5465
|
// components/Puck/components/Fields/index.tsx
|
5465
|
-
import {
|
5466
|
+
import { useMemo as useMemo12 } from "react";
|
5467
|
+
|
5468
|
+
// lib/use-resolved-fields.ts
|
5469
|
+
init_react_import();
|
5470
|
+
import { useCallback as useCallback13, useEffect as useEffect17, useMemo as useMemo11, useRef as useRef5, useState as useState19 } from "react";
|
5466
5471
|
|
5467
5472
|
// lib/use-parent.ts
|
5468
5473
|
init_react_import();
|
5469
|
-
import { useContext as useContext9 } from "react";
|
5470
|
-
var
|
5474
|
+
import { useCallback as useCallback12, useContext as useContext9 } from "react";
|
5475
|
+
var getParent = (itemSelector, pathData, data) => {
|
5471
5476
|
var _a;
|
5472
|
-
|
5473
|
-
const
|
5474
|
-
const
|
5475
|
-
const breadcrumbs = convertPathDataToBreadcrumbs(item, pathData, state.data);
|
5477
|
+
if (!itemSelector) return null;
|
5478
|
+
const item = getItem(itemSelector, data);
|
5479
|
+
const breadcrumbs = convertPathDataToBreadcrumbs(item, pathData, data);
|
5476
5480
|
const lastItem = breadcrumbs[breadcrumbs.length - 1];
|
5477
|
-
const parent = (lastItem == null ? void 0 : lastItem.selector) ? (_a = getItem(lastItem.selector,
|
5481
|
+
const parent = (lastItem == null ? void 0 : lastItem.selector) ? (_a = getItem(lastItem.selector, data)) != null ? _a : null : null;
|
5478
5482
|
return parent || null;
|
5479
5483
|
};
|
5484
|
+
var useGetParent = () => {
|
5485
|
+
const { state } = useAppContext();
|
5486
|
+
const { pathData } = useContext9(dropZoneContext) || {};
|
5487
|
+
return useCallback12(
|
5488
|
+
() => getParent(state.ui.itemSelector, pathData, state.data),
|
5489
|
+
[state.ui.itemSelector, pathData, state.data]
|
5490
|
+
);
|
5491
|
+
};
|
5492
|
+
var useParent = () => {
|
5493
|
+
return useGetParent()();
|
5494
|
+
};
|
5480
5495
|
|
5481
|
-
//
|
5482
|
-
|
5483
|
-
|
5496
|
+
// lib/use-on-value-change.ts
|
5497
|
+
init_react_import();
|
5498
|
+
import { useRef as useRef4, useEffect as useEffect16 } from "react";
|
5499
|
+
function useOnValueChange(value, onChange, compare = Object.is, deps = []) {
|
5500
|
+
const tracked = useRef4(value);
|
5501
|
+
useEffect16(() => {
|
5502
|
+
const oldValue = tracked.current;
|
5503
|
+
if (!compare(value, oldValue)) {
|
5504
|
+
tracked.current = value;
|
5505
|
+
onChange(value, oldValue);
|
5506
|
+
}
|
5507
|
+
}, [onChange, compare, value, ...deps]);
|
5508
|
+
}
|
5509
|
+
|
5510
|
+
// lib/selector-is.ts
|
5511
|
+
init_react_import();
|
5512
|
+
var selectorIs = (a, b) => (a == null ? void 0 : a.zone) === (b == null ? void 0 : b.zone) && (a == null ? void 0 : a.index) === (b == null ? void 0 : b.index);
|
5513
|
+
|
5514
|
+
// lib/use-resolved-fields.ts
|
5484
5515
|
var defaultPageFields = {
|
5485
5516
|
title: { type: "text" }
|
5486
5517
|
};
|
5487
|
-
var DefaultFields = ({
|
5488
|
-
children
|
5489
|
-
}) => {
|
5490
|
-
return /* @__PURE__ */ jsx27(Fragment8, { children });
|
5491
|
-
};
|
5492
5518
|
var useResolvedFields = () => {
|
5493
5519
|
var _a, _b;
|
5494
5520
|
const { selectedItem, state, config } = useAppContext();
|
@@ -5504,12 +5530,13 @@ var useResolvedFields = () => {
|
|
5504
5530
|
const [lastSelectedData, setLastSelectedData] = useState19({});
|
5505
5531
|
const [resolvedFields, setResolvedFields] = useState19(defaultFields);
|
5506
5532
|
const [fieldsLoading, setFieldsLoading] = useState19(false);
|
5533
|
+
const lastFields = useRef5(defaultFields);
|
5507
5534
|
const defaultResolveFields = (_componentData, _params) => defaultFields;
|
5508
5535
|
const componentData = selectedItem ? selectedItem : { props: rootProps, readOnly: data.root.readOnly };
|
5509
5536
|
const hasComponentResolver = selectedItem && (componentConfig == null ? void 0 : componentConfig.resolveFields);
|
5510
5537
|
const hasRootResolver = !selectedItem && ((_b = config.root) == null ? void 0 : _b.resolveFields);
|
5511
5538
|
const hasResolver = hasComponentResolver || hasRootResolver;
|
5512
|
-
const resolveFields =
|
5539
|
+
const resolveFields = useCallback13(
|
5513
5540
|
(..._0) => __async(void 0, [..._0], function* (fields = {}) {
|
5514
5541
|
var _a2;
|
5515
5542
|
const lastData = ((_a2 = lastSelectedData.props) == null ? void 0 : _a2.id) === componentData.props.id ? lastSelectedData : null;
|
@@ -5521,7 +5548,7 @@ var useResolvedFields = () => {
|
|
5521
5548
|
{
|
5522
5549
|
changed,
|
5523
5550
|
fields,
|
5524
|
-
lastFields:
|
5551
|
+
lastFields: lastFields.current,
|
5525
5552
|
lastData,
|
5526
5553
|
appState: state,
|
5527
5554
|
parent
|
@@ -5532,7 +5559,7 @@ var useResolvedFields = () => {
|
|
5532
5559
|
return yield config.root.resolveFields(componentData, {
|
5533
5560
|
changed,
|
5534
5561
|
fields,
|
5535
|
-
lastFields:
|
5562
|
+
lastFields: lastFields.current,
|
5536
5563
|
lastData,
|
5537
5564
|
appState: state,
|
5538
5565
|
parent
|
@@ -5541,39 +5568,55 @@ var useResolvedFields = () => {
|
|
5541
5568
|
return defaultResolveFields(componentData, {
|
5542
5569
|
changed,
|
5543
5570
|
fields,
|
5544
|
-
lastFields:
|
5571
|
+
lastFields: lastFields.current,
|
5545
5572
|
lastData
|
5546
5573
|
});
|
5547
5574
|
}),
|
5548
|
-
[data, config, componentData, selectedItem,
|
5575
|
+
[data, config, componentData, selectedItem, state, parent]
|
5549
5576
|
);
|
5550
|
-
const
|
5551
|
-
useEffect16(() => {
|
5552
|
-
setHasParent(!!parent);
|
5553
|
-
}, [parent]);
|
5554
|
-
useEffect16(() => {
|
5577
|
+
const triggerResolver = useCallback13(() => {
|
5555
5578
|
var _a2, _b2;
|
5556
|
-
if (!((_a2 = state.ui.itemSelector) == null ? void 0 : _a2.zone) || ((_b2 = state.ui.itemSelector) == null ? void 0 : _b2.zone) === "default-zone" ||
|
5579
|
+
if (!((_a2 = state.ui.itemSelector) == null ? void 0 : _a2.zone) || ((_b2 = state.ui.itemSelector) == null ? void 0 : _b2.zone) === "default-zone" || parent) {
|
5557
5580
|
if (hasResolver) {
|
5558
5581
|
setFieldsLoading(true);
|
5559
5582
|
resolveFields(defaultFields).then((fields) => {
|
5560
5583
|
setResolvedFields(fields || {});
|
5584
|
+
lastFields.current = fields;
|
5561
5585
|
setFieldsLoading(false);
|
5562
5586
|
});
|
5563
5587
|
return;
|
5564
5588
|
}
|
5565
5589
|
}
|
5566
5590
|
setResolvedFields(defaultFields);
|
5567
|
-
}, [
|
5568
|
-
|
5569
|
-
defaultFields,
|
5591
|
+
}, [defaultFields, state.ui.itemSelector, hasResolver, parent]);
|
5592
|
+
useOnValueChange(
|
5570
5593
|
state.ui.itemSelector,
|
5571
|
-
|
5572
|
-
|
5573
|
-
|
5574
|
-
|
5594
|
+
() => {
|
5595
|
+
lastFields.current = defaultFields;
|
5596
|
+
},
|
5597
|
+
selectorIs
|
5598
|
+
);
|
5599
|
+
useOnValueChange(
|
5600
|
+
{ data, parent, itemSelector: state.ui.itemSelector },
|
5601
|
+
() => {
|
5602
|
+
triggerResolver();
|
5603
|
+
},
|
5604
|
+
(a, b) => JSON.stringify(a) === JSON.stringify(b)
|
5605
|
+
);
|
5606
|
+
useEffect17(() => {
|
5607
|
+
triggerResolver();
|
5608
|
+
}, []);
|
5575
5609
|
return [resolvedFields, fieldsLoading];
|
5576
5610
|
};
|
5611
|
+
|
5612
|
+
// components/Puck/components/Fields/index.tsx
|
5613
|
+
import { Fragment as Fragment8, jsx as jsx27, jsxs as jsxs14 } from "react/jsx-runtime";
|
5614
|
+
var getClassName21 = get_class_name_factory_default("PuckFields", styles_module_default16);
|
5615
|
+
var DefaultFields = ({
|
5616
|
+
children
|
5617
|
+
}) => {
|
5618
|
+
return /* @__PURE__ */ jsx27(Fragment8, { children });
|
5619
|
+
};
|
5577
5620
|
var Fields = ({ wrapFields = true }) => {
|
5578
5621
|
var _a, _b;
|
5579
5622
|
const {
|
@@ -5592,7 +5635,7 @@ var Fields = ({ wrapFields = true }) => {
|
|
5592
5635
|
const componentResolving = selectedItem ? ((_a = componentState[selectedItem == null ? void 0 : selectedItem.props.id]) == null ? void 0 : _a.loadingCount) > 0 : ((_b = componentState["puck-root"]) == null ? void 0 : _b.loadingCount) > 0;
|
5593
5636
|
const isLoading = fieldsResolving || componentResolving;
|
5594
5637
|
const rootProps = data.root.props || data.root;
|
5595
|
-
const Wrapper =
|
5638
|
+
const Wrapper = useMemo12(() => overrides.fields || DefaultFields, [overrides]);
|
5596
5639
|
return /* @__PURE__ */ jsxs14(
|
5597
5640
|
"form",
|
5598
5641
|
{
|
@@ -5713,7 +5756,7 @@ init_react_import();
|
|
5713
5756
|
|
5714
5757
|
// lib/use-component-list.tsx
|
5715
5758
|
init_react_import();
|
5716
|
-
import { useEffect as
|
5759
|
+
import { useEffect as useEffect18, useState as useState20 } from "react";
|
5717
5760
|
|
5718
5761
|
// components/ComponentList/index.tsx
|
5719
5762
|
init_react_import();
|
@@ -5781,7 +5824,7 @@ ComponentList.Item = ComponentListItem;
|
|
5781
5824
|
import { jsx as jsx29 } from "react/jsx-runtime";
|
5782
5825
|
var useComponentList = (config, ui) => {
|
5783
5826
|
const [componentList, setComponentList] = useState20();
|
5784
|
-
|
5827
|
+
useEffect18(() => {
|
5785
5828
|
var _a, _b, _c;
|
5786
5829
|
if (Object.keys(ui.componentList).length > 0) {
|
5787
5830
|
const matchedComponents = [];
|
@@ -5850,25 +5893,25 @@ var useComponentList = (config, ui) => {
|
|
5850
5893
|
};
|
5851
5894
|
|
5852
5895
|
// components/Puck/components/Components/index.tsx
|
5853
|
-
import { useMemo as
|
5896
|
+
import { useMemo as useMemo13 } from "react";
|
5854
5897
|
import { jsx as jsx30 } from "react/jsx-runtime";
|
5855
5898
|
var Components = () => {
|
5856
5899
|
const { config, state, overrides } = useAppContext();
|
5857
5900
|
const componentList = useComponentList(config, state.ui);
|
5858
|
-
const Wrapper =
|
5901
|
+
const Wrapper = useMemo13(() => overrides.components || "div", [overrides]);
|
5859
5902
|
return /* @__PURE__ */ jsx30(Wrapper, { children: componentList ? componentList : /* @__PURE__ */ jsx30(ComponentList, { id: "all" }) });
|
5860
5903
|
};
|
5861
5904
|
|
5862
5905
|
// components/Puck/components/Preview/index.tsx
|
5863
5906
|
init_react_import();
|
5864
|
-
import { useCallback as
|
5907
|
+
import { useCallback as useCallback14, useEffect as useEffect20, useRef as useRef7, useMemo as useMemo14 } from "react";
|
5865
5908
|
|
5866
5909
|
// components/AutoFrame/index.tsx
|
5867
5910
|
init_react_import();
|
5868
5911
|
import {
|
5869
5912
|
createContext as createContext5,
|
5870
5913
|
useContext as useContext10,
|
5871
|
-
useEffect as
|
5914
|
+
useEffect as useEffect19,
|
5872
5915
|
useState as useState21
|
5873
5916
|
} from "react";
|
5874
5917
|
import hash from "object-hash";
|
@@ -5916,7 +5959,7 @@ var CopyHostStyles = ({
|
|
5916
5959
|
onStylesLoaded = () => null
|
5917
5960
|
}) => {
|
5918
5961
|
const { document: doc, window: win } = useFrame();
|
5919
|
-
|
5962
|
+
useEffect19(() => {
|
5920
5963
|
if (!win || !doc) {
|
5921
5964
|
return () => {
|
5922
5965
|
};
|
@@ -6096,7 +6139,7 @@ function AutoFrame(_a) {
|
|
6096
6139
|
const [loaded, setLoaded] = useState21(false);
|
6097
6140
|
const [ctx, setCtx] = useState21({});
|
6098
6141
|
const [mountTarget, setMountTarget] = useState21();
|
6099
|
-
|
6142
|
+
useEffect19(() => {
|
6100
6143
|
var _a2;
|
6101
6144
|
if (frameRef.current) {
|
6102
6145
|
setCtx({
|
@@ -6190,7 +6233,7 @@ import { Fragment as Fragment10, jsx as jsx33 } from "react/jsx-runtime";
|
|
6190
6233
|
var getClassName23 = get_class_name_factory_default("PuckPreview", styles_module_default18);
|
6191
6234
|
var useBubbleIframeEvents = (ref) => {
|
6192
6235
|
const { status } = useAppContext();
|
6193
|
-
|
6236
|
+
useEffect20(() => {
|
6194
6237
|
var _a;
|
6195
6238
|
if (ref.current && status === "READY") {
|
6196
6239
|
const iframe = ref.current;
|
@@ -6229,7 +6272,7 @@ var useBubbleIframeEvents = (ref) => {
|
|
6229
6272
|
};
|
6230
6273
|
var Preview2 = ({ id = "puck-preview" }) => {
|
6231
6274
|
const { config, dispatch, state, setStatus, iframe, overrides } = useAppContext();
|
6232
|
-
const Page =
|
6275
|
+
const Page = useCallback14(
|
6233
6276
|
(pageProps) => {
|
6234
6277
|
var _a, _b;
|
6235
6278
|
return ((_a = config.root) == null ? void 0 : _a.render) ? (_b = config.root) == null ? void 0 : _b.render(__spreadValues({
|
@@ -6238,9 +6281,9 @@ var Preview2 = ({ id = "puck-preview" }) => {
|
|
6238
6281
|
},
|
6239
6282
|
[config.root]
|
6240
6283
|
);
|
6241
|
-
const Frame =
|
6284
|
+
const Frame = useMemo14(() => overrides.iframe, [overrides]);
|
6242
6285
|
const rootProps = state.data.root.props || state.data.root;
|
6243
|
-
const ref =
|
6286
|
+
const ref = useRef7(null);
|
6244
6287
|
useBubbleIframeEvents(ref);
|
6245
6288
|
const inner = state.ui.previewMode === "edit" ? /* @__PURE__ */ jsx33(
|
6246
6289
|
Page,
|
@@ -6490,13 +6533,13 @@ var LayerTree = ({
|
|
6490
6533
|
};
|
6491
6534
|
|
6492
6535
|
// components/Puck/components/Outline/index.tsx
|
6493
|
-
import { useCallback as
|
6536
|
+
import { useCallback as useCallback15, useMemo as useMemo15 } from "react";
|
6494
6537
|
import { Fragment as Fragment12, jsx as jsx35, jsxs as jsxs17 } from "react/jsx-runtime";
|
6495
6538
|
var Outline = () => {
|
6496
6539
|
const { dispatch, state, overrides, config } = useAppContext();
|
6497
6540
|
const { data, ui } = state;
|
6498
6541
|
const { itemSelector } = ui;
|
6499
|
-
const setItemSelector =
|
6542
|
+
const setItemSelector = useCallback15(
|
6500
6543
|
(newItemSelector) => {
|
6501
6544
|
dispatch({
|
6502
6545
|
type: "setUi",
|
@@ -6505,7 +6548,7 @@ var Outline = () => {
|
|
6505
6548
|
},
|
6506
6549
|
[]
|
6507
6550
|
);
|
6508
|
-
const Wrapper =
|
6551
|
+
const Wrapper = useMemo15(() => overrides.outline || "div", [overrides]);
|
6509
6552
|
return /* @__PURE__ */ jsx35(Wrapper, { children: /* @__PURE__ */ jsx35(dropZoneContext.Consumer, { children: (ctx) => /* @__PURE__ */ jsxs17(Fragment12, { children: [
|
6510
6553
|
(ctx == null ? void 0 : ctx.activeZones) && (ctx == null ? void 0 : ctx.activeZones[rootDroppableId]) && /* @__PURE__ */ jsx35(
|
6511
6554
|
LayerTree,
|
@@ -6792,16 +6835,16 @@ var getBox = function getBox2(el) {
|
|
6792
6835
|
|
6793
6836
|
// components/Puck/components/Canvas/index.tsx
|
6794
6837
|
import {
|
6795
|
-
useCallback as
|
6796
|
-
useEffect as
|
6797
|
-
useMemo as
|
6798
|
-
useRef as
|
6838
|
+
useCallback as useCallback16,
|
6839
|
+
useEffect as useEffect22,
|
6840
|
+
useMemo as useMemo17,
|
6841
|
+
useRef as useRef8,
|
6799
6842
|
useState as useState24
|
6800
6843
|
} from "react";
|
6801
6844
|
|
6802
6845
|
// components/ViewportControls/index.tsx
|
6803
6846
|
init_react_import();
|
6804
|
-
import { useEffect as
|
6847
|
+
import { useEffect as useEffect21, useMemo as useMemo16, useState as useState23 } from "react";
|
6805
6848
|
|
6806
6849
|
// css-module:/home/runner/work/puck/puck/packages/core/components/ViewportControls/styles.module.css#css-module
|
6807
6850
|
init_react_import();
|
@@ -6825,7 +6868,7 @@ var ViewportButton = ({
|
|
6825
6868
|
}) => {
|
6826
6869
|
const { state } = useAppContext();
|
6827
6870
|
const [isActive, setIsActive] = useState23(false);
|
6828
|
-
|
6871
|
+
useEffect21(() => {
|
6829
6872
|
setIsActive(width === state.ui.viewports.current.width);
|
6830
6873
|
}, [width, state.ui.viewports.current.width]);
|
6831
6874
|
return /* @__PURE__ */ jsx36("span", { className: getClassNameButton({ isActive }), children: /* @__PURE__ */ jsx36(
|
@@ -6861,7 +6904,7 @@ var ViewportControls = ({
|
|
6861
6904
|
const defaultsContainAutoZoom = defaultZoomOptions.find(
|
6862
6905
|
(option) => option.value === autoZoom
|
6863
6906
|
);
|
6864
|
-
const zoomOptions =
|
6907
|
+
const zoomOptions = useMemo16(
|
6865
6908
|
() => [
|
6866
6909
|
...defaultZoomOptions,
|
6867
6910
|
...defaultsContainAutoZoom ? [] : [
|
@@ -6984,17 +7027,17 @@ var Canvas = () => {
|
|
6984
7027
|
const { status, iframe } = useAppContext();
|
6985
7028
|
const { dispatch, state, overrides, setUi, zoomConfig, setZoomConfig } = useAppContext();
|
6986
7029
|
const { ui } = state;
|
6987
|
-
const frameRef =
|
7030
|
+
const frameRef = useRef8(null);
|
6988
7031
|
const [showTransition, setShowTransition] = useState24(false);
|
6989
|
-
const defaultRender =
|
7032
|
+
const defaultRender = useMemo17(() => {
|
6990
7033
|
const PuckDefault = ({ children }) => /* @__PURE__ */ jsx37(Fragment13, { children });
|
6991
7034
|
return PuckDefault;
|
6992
7035
|
}, []);
|
6993
|
-
const CustomPreview =
|
7036
|
+
const CustomPreview = useMemo17(
|
6994
7037
|
() => overrides.preview || defaultRender,
|
6995
7038
|
[overrides]
|
6996
7039
|
);
|
6997
|
-
const getFrameDimensions =
|
7040
|
+
const getFrameDimensions = useCallback16(() => {
|
6998
7041
|
if (frameRef.current) {
|
6999
7042
|
const frame = frameRef.current;
|
7000
7043
|
const box = getBox(frame);
|
@@ -7002,7 +7045,7 @@ var Canvas = () => {
|
|
7002
7045
|
}
|
7003
7046
|
return { width: 0, height: 0 };
|
7004
7047
|
}, [frameRef]);
|
7005
|
-
const resetAutoZoom =
|
7048
|
+
const resetAutoZoom = useCallback16(
|
7006
7049
|
(ui2 = state.ui) => {
|
7007
7050
|
if (frameRef.current) {
|
7008
7051
|
setZoomConfig(
|
@@ -7012,11 +7055,11 @@ var Canvas = () => {
|
|
7012
7055
|
},
|
7013
7056
|
[frameRef, zoomConfig, state.ui]
|
7014
7057
|
);
|
7015
|
-
|
7058
|
+
useEffect22(() => {
|
7016
7059
|
setShowTransition(false);
|
7017
7060
|
resetAutoZoom();
|
7018
7061
|
}, [frameRef, ui.leftSideBarVisible, ui.rightSideBarVisible]);
|
7019
|
-
|
7062
|
+
useEffect22(() => {
|
7020
7063
|
const { height: frameHeight } = getFrameDimensions();
|
7021
7064
|
if (ui.viewports.current.height === "auto") {
|
7022
7065
|
setZoomConfig(__spreadProps(__spreadValues({}, zoomConfig), {
|
@@ -7024,13 +7067,13 @@ var Canvas = () => {
|
|
7024
7067
|
}));
|
7025
7068
|
}
|
7026
7069
|
}, [zoomConfig.zoom]);
|
7027
|
-
|
7070
|
+
useEffect22(() => {
|
7028
7071
|
if (ZOOM_ON_CHANGE) {
|
7029
7072
|
setShowTransition(true);
|
7030
7073
|
resetAutoZoom(ui);
|
7031
7074
|
}
|
7032
7075
|
}, [ui.viewports.current.width]);
|
7033
|
-
|
7076
|
+
useEffect22(() => {
|
7034
7077
|
const cb = () => {
|
7035
7078
|
setShowTransition(false);
|
7036
7079
|
resetAutoZoom();
|
@@ -7041,7 +7084,7 @@ var Canvas = () => {
|
|
7041
7084
|
};
|
7042
7085
|
}, []);
|
7043
7086
|
const [showLoader, setShowLoader] = useState24(false);
|
7044
|
-
|
7087
|
+
useEffect22(() => {
|
7045
7088
|
setTimeout(() => {
|
7046
7089
|
setShowLoader(true);
|
7047
7090
|
}, 500);
|
@@ -7119,7 +7162,7 @@ var Canvas = () => {
|
|
7119
7162
|
|
7120
7163
|
// lib/use-loaded-overrides.ts
|
7121
7164
|
init_react_import();
|
7122
|
-
import { useMemo as
|
7165
|
+
import { useMemo as useMemo18 } from "react";
|
7123
7166
|
|
7124
7167
|
// lib/load-overrides.ts
|
7125
7168
|
init_react_import();
|
@@ -7158,7 +7201,7 @@ var useLoadedOverrides = ({
|
|
7158
7201
|
overrides,
|
7159
7202
|
plugins
|
7160
7203
|
}) => {
|
7161
|
-
return
|
7204
|
+
return useMemo18(() => {
|
7162
7205
|
return loadOverrides({ overrides, plugins });
|
7163
7206
|
}, [plugins, overrides]);
|
7164
7207
|
};
|
@@ -7170,14 +7213,14 @@ var DefaultOverride = ({ children }) => /* @__PURE__ */ jsx38(Fragment14, { chil
|
|
7170
7213
|
|
7171
7214
|
// lib/use-inject-css.ts
|
7172
7215
|
init_react_import();
|
7173
|
-
import { useEffect as
|
7216
|
+
import { useEffect as useEffect23, useState as useState25 } from "react";
|
7174
7217
|
var styles = ``;
|
7175
7218
|
var useInjectStyleSheet = (initialStyles, iframeEnabled) => {
|
7176
7219
|
const [el, setEl] = useState25();
|
7177
|
-
|
7220
|
+
useEffect23(() => {
|
7178
7221
|
setEl(document.createElement("style"));
|
7179
7222
|
}, []);
|
7180
|
-
|
7223
|
+
useEffect23(() => {
|
7181
7224
|
var _a;
|
7182
7225
|
if (!el || typeof window === "undefined") {
|
7183
7226
|
return;
|
@@ -7197,10 +7240,10 @@ var useInjectGlobalCss = (iframeEnabled) => {
|
|
7197
7240
|
|
7198
7241
|
// lib/use-preview-mode-hotkeys.ts
|
7199
7242
|
init_react_import();
|
7200
|
-
import { useCallback as
|
7243
|
+
import { useCallback as useCallback17 } from "react";
|
7201
7244
|
import { useHotkeys as useHotkeys2 } from "react-hotkeys-hook";
|
7202
7245
|
var usePreviewModeHotkeys = (dispatch, iframeEnabled) => {
|
7203
|
-
const toggleInteractive =
|
7246
|
+
const toggleInteractive = useCallback17(() => {
|
7204
7247
|
dispatch({
|
7205
7248
|
type: "setUi",
|
7206
7249
|
ui: (ui) => ({
|
@@ -7345,11 +7388,11 @@ function Puck({
|
|
7345
7388
|
const [menuOpen, setMenuOpen] = useState26(false);
|
7346
7389
|
const { itemSelector, leftSideBarVisible, rightSideBarVisible } = ui;
|
7347
7390
|
const selectedItem = itemSelector ? getItem(itemSelector, data) : null;
|
7348
|
-
|
7391
|
+
useEffect24(() => {
|
7349
7392
|
if (onChange) onChange(data);
|
7350
7393
|
}, [data]);
|
7351
7394
|
const rootProps = data.root.props || data.root;
|
7352
|
-
const toggleSidebars =
|
7395
|
+
const toggleSidebars = useCallback18(
|
7353
7396
|
(sidebar) => {
|
7354
7397
|
const widerViewport = window.matchMedia("(min-width: 638px)").matches;
|
7355
7398
|
const sideBarVisible = sidebar === "left" ? leftSideBarVisible : rightSideBarVisible;
|
@@ -7363,7 +7406,7 @@ function Puck({
|
|
7363
7406
|
},
|
7364
7407
|
[dispatch, leftSideBarVisible, rightSideBarVisible]
|
7365
7408
|
);
|
7366
|
-
|
7409
|
+
useEffect24(() => {
|
7367
7410
|
if (!window.matchMedia("(min-width: 638px)").matches) {
|
7368
7411
|
dispatch({
|
7369
7412
|
type: "setUi",
|
@@ -7386,7 +7429,7 @@ function Puck({
|
|
7386
7429
|
window.removeEventListener("resize", handleResize);
|
7387
7430
|
};
|
7388
7431
|
}, []);
|
7389
|
-
const defaultHeaderRender =
|
7432
|
+
const defaultHeaderRender = useMemo19(() => {
|
7390
7433
|
if (renderHeader) {
|
7391
7434
|
console.warn(
|
7392
7435
|
"`renderHeader` is deprecated. Please use `overrides.header` and the `usePuck` hook instead"
|
@@ -7400,7 +7443,7 @@ function Puck({
|
|
7400
7443
|
}
|
7401
7444
|
return DefaultOverride;
|
7402
7445
|
}, [renderHeader]);
|
7403
|
-
const defaultHeaderActionsRender =
|
7446
|
+
const defaultHeaderActionsRender = useMemo19(() => {
|
7404
7447
|
if (renderHeaderActions) {
|
7405
7448
|
console.warn(
|
7406
7449
|
"`renderHeaderActions` is deprecated. Please use `overrides.headerActions` and the `usePuck` hook instead."
|
@@ -7417,20 +7460,20 @@ function Puck({
|
|
7417
7460
|
overrides,
|
7418
7461
|
plugins
|
7419
7462
|
});
|
7420
|
-
const CustomPuck =
|
7463
|
+
const CustomPuck = useMemo19(
|
7421
7464
|
() => loadedOverrides.puck || DefaultOverride,
|
7422
7465
|
[loadedOverrides]
|
7423
7466
|
);
|
7424
|
-
const CustomHeader =
|
7467
|
+
const CustomHeader = useMemo19(
|
7425
7468
|
() => loadedOverrides.header || defaultHeaderRender,
|
7426
7469
|
[loadedOverrides]
|
7427
7470
|
);
|
7428
|
-
const CustomHeaderActions =
|
7471
|
+
const CustomHeaderActions = useMemo19(
|
7429
7472
|
() => loadedOverrides.headerActions || defaultHeaderActionsRender,
|
7430
7473
|
[loadedOverrides]
|
7431
7474
|
);
|
7432
7475
|
const [mounted, setMounted] = useState26(false);
|
7433
|
-
|
7476
|
+
useEffect24(() => {
|
7434
7477
|
setMounted(true);
|
7435
7478
|
}, []);
|
7436
7479
|
const selectedComponentConfig = selectedItem && config.components[selectedItem.type];
|
package/package.json
CHANGED