@measured/puck 0.18.0-canary.f2e2eaa → 0.18.1-canary.0573b18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.css +45 -48
- package/dist/index.d.mts +5 -2
- package/dist/index.d.ts +5 -2
- package/dist/index.js +224 -144
- package/dist/index.mjs +215 -135
- package/package.json +1 -1
package/dist/index.js
CHANGED
@@ -308,7 +308,7 @@ init_react_import();
|
|
308
308
|
|
309
309
|
// css-module:/home/runner/work/puck/puck/packages/core/components/AutoField/styles.module.css#css-module
|
310
310
|
init_react_import();
|
311
|
-
var styles_module_default2 = { "InputWrapper": "
|
311
|
+
var styles_module_default2 = { "InputWrapper": "_InputWrapper_1h1p1_1", "Input-label": "_Input-label_1h1p1_5", "Input-labelIcon": "_Input-labelIcon_1h1p1_14", "Input-disabledIcon": "_Input-disabledIcon_1h1p1_21", "Input-input": "_Input-input_1h1p1_26", "Input": "_Input_1h1p1_1", "Input--readOnly": "_Input--readOnly_1h1p1_70", "Input-radioGroupItems": "_Input-radioGroupItems_1h1p1_81", "Input-radio": "_Input-radio_1h1p1_81", "Input-radioInner": "_Input-radioInner_1h1p1_98", "Input-radioInput": "_Input-radioInput_1h1p1_143" };
|
312
312
|
|
313
313
|
// components/AutoField/index.tsx
|
314
314
|
var import_react20 = require("react");
|
@@ -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);
|
@@ -3255,13 +3256,19 @@ var DraggableComponent = ({
|
|
3255
3256
|
}
|
3256
3257
|
}, [ref.current]);
|
3257
3258
|
(0, import_react23.useEffect)(() => {
|
3258
|
-
|
3259
|
-
|
3259
|
+
ctx == null ? void 0 : ctx.registerPath(
|
3260
|
+
id,
|
3261
|
+
{
|
3260
3262
|
index,
|
3261
3263
|
zone: zoneCompound
|
3262
|
-
}
|
3263
|
-
|
3264
|
-
|
3264
|
+
},
|
3265
|
+
componentType
|
3266
|
+
);
|
3267
|
+
return () => {
|
3268
|
+
var _a;
|
3269
|
+
(_a = ctx == null ? void 0 : ctx.unregisterPath) == null ? void 0 : _a.call(ctx, id);
|
3270
|
+
};
|
3271
|
+
}, [id, zoneCompound, index, componentType]);
|
3265
3272
|
const CustomActionBar = (0, import_react23.useMemo)(
|
3266
3273
|
() => overrides.actionBar || DefaultActionBar,
|
3267
3274
|
[overrides.actionBar]
|
@@ -3581,9 +3588,20 @@ var useContentWithPreview = (content, zoneCompound) => {
|
|
3581
3588
|
};
|
3582
3589
|
}
|
3583
3590
|
);
|
3591
|
+
const {
|
3592
|
+
state: {
|
3593
|
+
ui: { isDragging }
|
3594
|
+
}
|
3595
|
+
} = useAppContext();
|
3584
3596
|
const [contentWithPreview, setContentWithPreview] = (0, import_react27.useState)(content);
|
3597
|
+
const [localPreview, setLocalPreview] = (0, import_react27.useState)(
|
3598
|
+
preview
|
3599
|
+
);
|
3585
3600
|
const updateContent = useRenderedCallback(
|
3586
|
-
(content2, preview2) => {
|
3601
|
+
(content2, preview2, isDragging2) => {
|
3602
|
+
if (isDragging2 && !previewExists) {
|
3603
|
+
return;
|
3604
|
+
}
|
3587
3605
|
if (preview2) {
|
3588
3606
|
if (preview2.type === "insert") {
|
3589
3607
|
setContentWithPreview(
|
@@ -3613,13 +3631,14 @@ var useContentWithPreview = (content, zoneCompound) => {
|
|
3613
3631
|
previewExists ? content2.filter((item) => item.props.id !== draggedItemId) : content2
|
3614
3632
|
);
|
3615
3633
|
}
|
3634
|
+
setLocalPreview(preview2);
|
3616
3635
|
},
|
3617
3636
|
[draggedItemId, previewExists]
|
3618
3637
|
);
|
3619
3638
|
(0, import_react27.useEffect)(() => {
|
3620
|
-
updateContent(content, preview);
|
3621
|
-
}, [content, preview]);
|
3622
|
-
return contentWithPreview;
|
3639
|
+
updateContent(content, preview, isDragging);
|
3640
|
+
}, [content, preview, isDragging]);
|
3641
|
+
return [contentWithPreview, localPreview];
|
3623
3642
|
};
|
3624
3643
|
|
3625
3644
|
// components/DropZone/lib/use-drag-axis.ts
|
@@ -3699,8 +3718,7 @@ var DropZoneEdit = (0, import_react29.forwardRef)(
|
|
3699
3718
|
isDeepestZone,
|
3700
3719
|
inNextDeepestArea,
|
3701
3720
|
draggedComponentType,
|
3702
|
-
userIsDragging
|
3703
|
-
preview
|
3721
|
+
userIsDragging
|
3704
3722
|
} = useContextStore(ZoneStoreContext, (s) => {
|
3705
3723
|
var _a, _b, _c;
|
3706
3724
|
return {
|
@@ -3708,8 +3726,7 @@ var DropZoneEdit = (0, import_react29.forwardRef)(
|
|
3708
3726
|
inNextDeepestArea: s.nextAreaDepthIndex[areaId || ""],
|
3709
3727
|
draggedItemId: (_b = s.draggedItem) == null ? void 0 : _b.id,
|
3710
3728
|
draggedComponentType: (_c = s.draggedItem) == null ? void 0 : _c.data.componentType,
|
3711
|
-
userIsDragging: !!s.draggedItem
|
3712
|
-
preview: s.previewIndex[zoneCompound]
|
3729
|
+
userIsDragging: !!s.draggedItem
|
3713
3730
|
};
|
3714
3731
|
});
|
3715
3732
|
const { itemSelector } = appContext2.state.ui;
|
@@ -3775,7 +3792,10 @@ var DropZoneEdit = (0, import_react29.forwardRef)(
|
|
3775
3792
|
if (isEnabled) {
|
3776
3793
|
isEnabled = acceptsTarget(draggedComponentType);
|
3777
3794
|
}
|
3778
|
-
const contentWithPreview = useContentWithPreview(
|
3795
|
+
const [contentWithPreview, preview] = useContentWithPreview(
|
3796
|
+
content,
|
3797
|
+
zoneCompound
|
3798
|
+
);
|
3779
3799
|
const isDropEnabled = isEnabled && (preview ? contentWithPreview.length === 1 : contentWithPreview.length === 0);
|
3780
3800
|
const droppableConfig = {
|
3781
3801
|
id: zoneCompound,
|
@@ -3817,10 +3837,9 @@ var DropZoneEdit = (0, import_react29.forwardRef)(
|
|
3817
3837
|
},
|
3818
3838
|
"data-testid": `dropzone:${zoneCompound}`,
|
3819
3839
|
"data-puck-dropzone": zoneCompound,
|
3820
|
-
"data-puck-dnd": zoneCompound,
|
3821
3840
|
style: __spreadProps(__spreadValues({}, style), {
|
3822
3841
|
"--min-empty-height": `${minEmptyHeight}px`,
|
3823
|
-
backgroundColor: RENDER_DEBUG ? getRandomColor() : void 0
|
3842
|
+
backgroundColor: RENDER_DEBUG ? getRandomColor() : style == null ? void 0 : style.backgroundColor
|
3824
3843
|
}),
|
3825
3844
|
children: contentWithPreview.map((item, i) => {
|
3826
3845
|
var _a, _b, _c, _d, _e, _f, _g;
|
@@ -4099,6 +4118,13 @@ var getPointerCollisions = (position, manager) => {
|
|
4099
4118
|
if (elements) {
|
4100
4119
|
for (let i = 0; i < elements.length; i++) {
|
4101
4120
|
const element = elements[i];
|
4121
|
+
const dropzoneId = element.getAttribute("data-puck-dropzone");
|
4122
|
+
if (dropzoneId) {
|
4123
|
+
const droppable = manager.registry.droppables.get(dropzoneId);
|
4124
|
+
if (droppable) {
|
4125
|
+
candidates.push(droppable);
|
4126
|
+
}
|
4127
|
+
}
|
4102
4128
|
const id = element.getAttribute("data-puck-dnd");
|
4103
4129
|
if (id) {
|
4104
4130
|
const droppable = manager.registry.droppables.get(id);
|
@@ -5043,27 +5069,33 @@ var DragDropContextClient = ({
|
|
5043
5069
|
const [pathData, setPathData] = (0, import_react31.useState)();
|
5044
5070
|
const dragMode = (0, import_react31.useRef)(null);
|
5045
5071
|
const registerPath = (0, import_react31.useCallback)(
|
5046
|
-
(selector) => {
|
5047
|
-
const item = getItem(selector, data);
|
5048
|
-
if (!item) {
|
5049
|
-
return;
|
5050
|
-
}
|
5072
|
+
(id2, selector, label) => {
|
5051
5073
|
const [area] = getZoneId(selector.zone);
|
5052
5074
|
setPathData((latestPathData = {}) => {
|
5053
5075
|
const parentPathData = latestPathData[area] || { path: [] };
|
5054
5076
|
return __spreadProps(__spreadValues({}, latestPathData), {
|
5055
|
-
[
|
5077
|
+
[id2]: {
|
5056
5078
|
path: [
|
5057
5079
|
...parentPathData.path,
|
5058
5080
|
...selector.zone ? [selector.zone] : []
|
5059
5081
|
],
|
5060
|
-
label
|
5082
|
+
label
|
5061
5083
|
}
|
5062
5084
|
});
|
5063
5085
|
});
|
5064
5086
|
},
|
5065
5087
|
[data, setPathData]
|
5066
5088
|
);
|
5089
|
+
const unregisterPath = (0, import_react31.useCallback)(
|
5090
|
+
(id2) => {
|
5091
|
+
setPathData((latestPathData = {}) => {
|
5092
|
+
const newPathData = __spreadValues({}, latestPathData);
|
5093
|
+
delete newPathData[id2];
|
5094
|
+
return newPathData;
|
5095
|
+
});
|
5096
|
+
},
|
5097
|
+
[data, setPathData]
|
5098
|
+
);
|
5067
5099
|
const initialSelector = (0, import_react31.useRef)(void 0);
|
5068
5100
|
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { id, children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
5069
5101
|
dragListenerContext.Provider,
|
@@ -5260,6 +5292,7 @@ var DragDropContextClient = ({
|
|
5260
5292
|
areaId: "root",
|
5261
5293
|
depth: 0,
|
5262
5294
|
registerPath,
|
5295
|
+
unregisterPath,
|
5263
5296
|
pathData,
|
5264
5297
|
path: []
|
5265
5298
|
},
|
@@ -5408,7 +5441,7 @@ Drawer.Item = DrawerItem;
|
|
5408
5441
|
|
5409
5442
|
// components/Puck/index.tsx
|
5410
5443
|
init_react_import();
|
5411
|
-
var
|
5444
|
+
var import_react50 = require("react");
|
5412
5445
|
|
5413
5446
|
// components/SidebarSection/index.tsx
|
5414
5447
|
init_react_import();
|
@@ -5601,36 +5634,61 @@ init_react_import();
|
|
5601
5634
|
|
5602
5635
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Fields/styles.module.css#css-module
|
5603
5636
|
init_react_import();
|
5604
|
-
var styles_module_default16 = { "PuckFields": "
|
5637
|
+
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
5638
|
|
5606
5639
|
// components/Puck/components/Fields/index.tsx
|
5607
|
-
var
|
5640
|
+
var import_react37 = require("react");
|
5641
|
+
|
5642
|
+
// lib/use-resolved-fields.ts
|
5643
|
+
init_react_import();
|
5644
|
+
var import_react36 = require("react");
|
5608
5645
|
|
5609
5646
|
// lib/use-parent.ts
|
5610
5647
|
init_react_import();
|
5611
5648
|
var import_react34 = require("react");
|
5612
|
-
var
|
5649
|
+
var getParent = (itemSelector, pathData, data) => {
|
5613
5650
|
var _a;
|
5614
|
-
|
5615
|
-
const
|
5616
|
-
const
|
5617
|
-
const breadcrumbs = convertPathDataToBreadcrumbs(item, pathData, state.data);
|
5651
|
+
if (!itemSelector) return null;
|
5652
|
+
const item = getItem(itemSelector, data);
|
5653
|
+
const breadcrumbs = convertPathDataToBreadcrumbs(item, pathData, data);
|
5618
5654
|
const lastItem = breadcrumbs[breadcrumbs.length - 1];
|
5619
|
-
const parent = (lastItem == null ? void 0 : lastItem.selector) ? (_a = getItem(lastItem.selector,
|
5655
|
+
const parent = (lastItem == null ? void 0 : lastItem.selector) ? (_a = getItem(lastItem.selector, data)) != null ? _a : null : null;
|
5620
5656
|
return parent || null;
|
5621
5657
|
};
|
5658
|
+
var useGetParent = () => {
|
5659
|
+
const { state } = useAppContext();
|
5660
|
+
const { pathData } = (0, import_react34.useContext)(dropZoneContext) || {};
|
5661
|
+
return (0, import_react34.useCallback)(
|
5662
|
+
() => getParent(state.ui.itemSelector, pathData, state.data),
|
5663
|
+
[state.ui.itemSelector, pathData, state.data]
|
5664
|
+
);
|
5665
|
+
};
|
5666
|
+
var useParent = () => {
|
5667
|
+
return useGetParent()();
|
5668
|
+
};
|
5622
5669
|
|
5623
|
-
//
|
5624
|
-
|
5625
|
-
var
|
5670
|
+
// lib/use-on-value-change.ts
|
5671
|
+
init_react_import();
|
5672
|
+
var import_react35 = require("react");
|
5673
|
+
function useOnValueChange(value, onChange, compare = Object.is, deps = []) {
|
5674
|
+
const tracked = (0, import_react35.useRef)(value);
|
5675
|
+
(0, import_react35.useEffect)(() => {
|
5676
|
+
const oldValue = tracked.current;
|
5677
|
+
if (!compare(value, oldValue)) {
|
5678
|
+
tracked.current = value;
|
5679
|
+
onChange(value, oldValue);
|
5680
|
+
}
|
5681
|
+
}, [onChange, compare, value, ...deps]);
|
5682
|
+
}
|
5683
|
+
|
5684
|
+
// lib/selector-is.ts
|
5685
|
+
init_react_import();
|
5686
|
+
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);
|
5687
|
+
|
5688
|
+
// lib/use-resolved-fields.ts
|
5626
5689
|
var defaultPageFields = {
|
5627
5690
|
title: { type: "text" }
|
5628
5691
|
};
|
5629
|
-
var DefaultFields = ({
|
5630
|
-
children
|
5631
|
-
}) => {
|
5632
|
-
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_jsx_runtime27.Fragment, { children });
|
5633
|
-
};
|
5634
5692
|
var useResolvedFields = () => {
|
5635
5693
|
var _a, _b;
|
5636
5694
|
const { selectedItem, state, config } = useAppContext();
|
@@ -5638,20 +5696,21 @@ var useResolvedFields = () => {
|
|
5638
5696
|
const { data } = state;
|
5639
5697
|
const rootFields = ((_a = config.root) == null ? void 0 : _a.fields) || defaultPageFields;
|
5640
5698
|
const componentConfig = selectedItem ? config.components[selectedItem.type] : null;
|
5641
|
-
const defaultFields = (0,
|
5699
|
+
const defaultFields = (0, import_react36.useMemo)(
|
5642
5700
|
() => (selectedItem ? componentConfig == null ? void 0 : componentConfig.fields : rootFields) || {},
|
5643
5701
|
[selectedItem, rootFields, componentConfig == null ? void 0 : componentConfig.fields]
|
5644
5702
|
);
|
5645
5703
|
const rootProps = data.root.props || data.root;
|
5646
|
-
const [lastSelectedData, setLastSelectedData] = (0,
|
5647
|
-
const [resolvedFields, setResolvedFields] = (0,
|
5648
|
-
const [fieldsLoading, setFieldsLoading] = (0,
|
5704
|
+
const [lastSelectedData, setLastSelectedData] = (0, import_react36.useState)({});
|
5705
|
+
const [resolvedFields, setResolvedFields] = (0, import_react36.useState)(defaultFields);
|
5706
|
+
const [fieldsLoading, setFieldsLoading] = (0, import_react36.useState)(false);
|
5707
|
+
const lastFields = (0, import_react36.useRef)(defaultFields);
|
5649
5708
|
const defaultResolveFields = (_componentData, _params) => defaultFields;
|
5650
5709
|
const componentData = selectedItem ? selectedItem : { props: rootProps, readOnly: data.root.readOnly };
|
5651
5710
|
const hasComponentResolver = selectedItem && (componentConfig == null ? void 0 : componentConfig.resolveFields);
|
5652
5711
|
const hasRootResolver = !selectedItem && ((_b = config.root) == null ? void 0 : _b.resolveFields);
|
5653
5712
|
const hasResolver = hasComponentResolver || hasRootResolver;
|
5654
|
-
const resolveFields = (0,
|
5713
|
+
const resolveFields = (0, import_react36.useCallback)(
|
5655
5714
|
(..._0) => __async(void 0, [..._0], function* (fields = {}) {
|
5656
5715
|
var _a2;
|
5657
5716
|
const lastData = ((_a2 = lastSelectedData.props) == null ? void 0 : _a2.id) === componentData.props.id ? lastSelectedData : null;
|
@@ -5663,7 +5722,7 @@ var useResolvedFields = () => {
|
|
5663
5722
|
{
|
5664
5723
|
changed,
|
5665
5724
|
fields,
|
5666
|
-
lastFields:
|
5725
|
+
lastFields: lastFields.current,
|
5667
5726
|
lastData,
|
5668
5727
|
appState: state,
|
5669
5728
|
parent
|
@@ -5674,7 +5733,7 @@ var useResolvedFields = () => {
|
|
5674
5733
|
return yield config.root.resolveFields(componentData, {
|
5675
5734
|
changed,
|
5676
5735
|
fields,
|
5677
|
-
lastFields:
|
5736
|
+
lastFields: lastFields.current,
|
5678
5737
|
lastData,
|
5679
5738
|
appState: state,
|
5680
5739
|
parent
|
@@ -5683,40 +5742,56 @@ var useResolvedFields = () => {
|
|
5683
5742
|
return defaultResolveFields(componentData, {
|
5684
5743
|
changed,
|
5685
5744
|
fields,
|
5686
|
-
lastFields:
|
5745
|
+
lastFields: lastFields.current,
|
5687
5746
|
lastData
|
5688
5747
|
});
|
5689
5748
|
}),
|
5690
|
-
[data, config, componentData, selectedItem,
|
5749
|
+
[data, config, componentData, selectedItem, state, parent]
|
5691
5750
|
);
|
5692
|
-
const
|
5693
|
-
(0, import_react35.useEffect)(() => {
|
5694
|
-
setHasParent(!!parent);
|
5695
|
-
}, [parent]);
|
5696
|
-
(0, import_react35.useEffect)(() => {
|
5751
|
+
const triggerResolver = (0, import_react36.useCallback)(() => {
|
5697
5752
|
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" ||
|
5753
|
+
if (!((_a2 = state.ui.itemSelector) == null ? void 0 : _a2.zone) || ((_b2 = state.ui.itemSelector) == null ? void 0 : _b2.zone) === "default-zone" || parent) {
|
5699
5754
|
if (hasResolver) {
|
5700
5755
|
setFieldsLoading(true);
|
5701
5756
|
resolveFields(defaultFields).then((fields) => {
|
5702
5757
|
setResolvedFields(fields || {});
|
5758
|
+
lastFields.current = fields;
|
5703
5759
|
setFieldsLoading(false);
|
5704
5760
|
});
|
5705
|
-
|
5706
|
-
setResolvedFields(defaultFields);
|
5761
|
+
return;
|
5707
5762
|
}
|
5708
5763
|
}
|
5709
|
-
|
5710
|
-
|
5711
|
-
|
5764
|
+
setResolvedFields(defaultFields);
|
5765
|
+
}, [defaultFields, state.ui.itemSelector, hasResolver, parent]);
|
5766
|
+
useOnValueChange(
|
5712
5767
|
state.ui.itemSelector,
|
5713
|
-
|
5714
|
-
|
5715
|
-
|
5716
|
-
|
5768
|
+
() => {
|
5769
|
+
lastFields.current = defaultFields;
|
5770
|
+
},
|
5771
|
+
selectorIs
|
5772
|
+
);
|
5773
|
+
useOnValueChange(
|
5774
|
+
{ data, parent, itemSelector: state.ui.itemSelector },
|
5775
|
+
() => {
|
5776
|
+
triggerResolver();
|
5777
|
+
},
|
5778
|
+
(a, b) => JSON.stringify(a) === JSON.stringify(b)
|
5779
|
+
);
|
5780
|
+
(0, import_react36.useEffect)(() => {
|
5781
|
+
triggerResolver();
|
5782
|
+
}, []);
|
5717
5783
|
return [resolvedFields, fieldsLoading];
|
5718
5784
|
};
|
5719
|
-
|
5785
|
+
|
5786
|
+
// components/Puck/components/Fields/index.tsx
|
5787
|
+
var import_jsx_runtime27 = require("react/jsx-runtime");
|
5788
|
+
var getClassName21 = get_class_name_factory_default("PuckFields", styles_module_default16);
|
5789
|
+
var DefaultFields = ({
|
5790
|
+
children
|
5791
|
+
}) => {
|
5792
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_jsx_runtime27.Fragment, { children });
|
5793
|
+
};
|
5794
|
+
var Fields = ({ wrapFields = true }) => {
|
5720
5795
|
var _a, _b;
|
5721
5796
|
const {
|
5722
5797
|
selectedItem,
|
@@ -5734,11 +5809,11 @@ var Fields = () => {
|
|
5734
5809
|
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
5810
|
const isLoading = fieldsResolving || componentResolving;
|
5736
5811
|
const rootProps = data.root.props || data.root;
|
5737
|
-
const Wrapper = (0,
|
5812
|
+
const Wrapper = (0, import_react37.useMemo)(() => overrides.fields || DefaultFields, [overrides]);
|
5738
5813
|
return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
|
5739
5814
|
"form",
|
5740
5815
|
{
|
5741
|
-
className: getClassName21(),
|
5816
|
+
className: getClassName21({ wrapFields }),
|
5742
5817
|
onSubmit: (e) => {
|
5743
5818
|
e.preventDefault();
|
5744
5819
|
},
|
@@ -5757,7 +5832,7 @@ var Fields = () => {
|
|
5757
5832
|
const newProps = __spreadProps(__spreadValues({}, currentProps), {
|
5758
5833
|
[fieldName]: value
|
5759
5834
|
});
|
5760
|
-
if (itemSelector) {
|
5835
|
+
if (selectedItem && itemSelector) {
|
5761
5836
|
const replaceActionData = {
|
5762
5837
|
type: "replace",
|
5763
5838
|
destinationIndex: itemSelector.index,
|
@@ -5814,7 +5889,7 @@ var Fields = () => {
|
|
5814
5889
|
item: selectedItem
|
5815
5890
|
});
|
5816
5891
|
const id = `${selectedItem.props.id}_${field.type}_${fieldName}`;
|
5817
|
-
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
5892
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: getClassName21("field"), children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
5818
5893
|
AutoFieldPrivate,
|
5819
5894
|
{
|
5820
5895
|
field,
|
@@ -5823,16 +5898,15 @@ var Fields = () => {
|
|
5823
5898
|
readOnly: !edit || readOnly[fieldName],
|
5824
5899
|
value: selectedItem.props[fieldName],
|
5825
5900
|
onChange
|
5826
|
-
}
|
5827
|
-
|
5828
|
-
);
|
5901
|
+
}
|
5902
|
+
) }, id);
|
5829
5903
|
} else {
|
5830
5904
|
const readOnly = data.root.readOnly || {};
|
5831
5905
|
const { edit } = getPermissions({
|
5832
5906
|
root: true
|
5833
5907
|
});
|
5834
5908
|
const id = `root_${field.type}_${fieldName}`;
|
5835
|
-
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
5909
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: getClassName21("field"), children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
5836
5910
|
AutoFieldPrivate,
|
5837
5911
|
{
|
5838
5912
|
field,
|
@@ -5841,9 +5915,8 @@ var Fields = () => {
|
|
5841
5915
|
readOnly: !edit || readOnly[fieldName],
|
5842
5916
|
value: rootProps[fieldName],
|
5843
5917
|
onChange
|
5844
|
-
}
|
5845
|
-
|
5846
|
-
);
|
5918
|
+
}
|
5919
|
+
) }, id);
|
5847
5920
|
}
|
5848
5921
|
}) }),
|
5849
5922
|
isLoading && /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: getClassName21("loadingOverlay"), children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: getClassName21("loadingOverlayInner"), children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(Loader, { size: 16 }) }) })
|
@@ -5857,7 +5930,7 @@ init_react_import();
|
|
5857
5930
|
|
5858
5931
|
// lib/use-component-list.tsx
|
5859
5932
|
init_react_import();
|
5860
|
-
var
|
5933
|
+
var import_react38 = require("react");
|
5861
5934
|
|
5862
5935
|
// components/ComponentList/index.tsx
|
5863
5936
|
init_react_import();
|
@@ -5924,8 +5997,8 @@ ComponentList.Item = ComponentListItem;
|
|
5924
5997
|
// lib/use-component-list.tsx
|
5925
5998
|
var import_jsx_runtime29 = require("react/jsx-runtime");
|
5926
5999
|
var useComponentList = (config, ui) => {
|
5927
|
-
const [componentList, setComponentList] = (0,
|
5928
|
-
(0,
|
6000
|
+
const [componentList, setComponentList] = (0, import_react38.useState)();
|
6001
|
+
(0, import_react38.useEffect)(() => {
|
5929
6002
|
var _a, _b, _c;
|
5930
6003
|
if (Object.keys(ui.componentList).length > 0) {
|
5931
6004
|
const matchedComponents = [];
|
@@ -5994,22 +6067,22 @@ var useComponentList = (config, ui) => {
|
|
5994
6067
|
};
|
5995
6068
|
|
5996
6069
|
// components/Puck/components/Components/index.tsx
|
5997
|
-
var
|
6070
|
+
var import_react39 = require("react");
|
5998
6071
|
var import_jsx_runtime30 = require("react/jsx-runtime");
|
5999
6072
|
var Components = () => {
|
6000
6073
|
const { config, state, overrides } = useAppContext();
|
6001
6074
|
const componentList = useComponentList(config, state.ui);
|
6002
|
-
const Wrapper = (0,
|
6075
|
+
const Wrapper = (0, import_react39.useMemo)(() => overrides.components || "div", [overrides]);
|
6003
6076
|
return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Wrapper, { children: componentList ? componentList : /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(ComponentList, { id: "all" }) });
|
6004
6077
|
};
|
6005
6078
|
|
6006
6079
|
// components/Puck/components/Preview/index.tsx
|
6007
6080
|
init_react_import();
|
6008
|
-
var
|
6081
|
+
var import_react41 = require("react");
|
6009
6082
|
|
6010
6083
|
// components/AutoFrame/index.tsx
|
6011
6084
|
init_react_import();
|
6012
|
-
var
|
6085
|
+
var import_react40 = require("react");
|
6013
6086
|
var import_object_hash = __toESM(require("object-hash"));
|
6014
6087
|
var import_react_dom3 = require("react-dom");
|
6015
6088
|
var import_jsx_runtime31 = require("react/jsx-runtime");
|
@@ -6055,7 +6128,7 @@ var CopyHostStyles = ({
|
|
6055
6128
|
onStylesLoaded = () => null
|
6056
6129
|
}) => {
|
6057
6130
|
const { document: doc, window: win } = useFrame();
|
6058
|
-
(0,
|
6131
|
+
(0, import_react40.useEffect)(() => {
|
6059
6132
|
if (!win || !doc) {
|
6060
6133
|
return () => {
|
6061
6134
|
};
|
@@ -6214,8 +6287,8 @@ var CopyHostStyles = ({
|
|
6214
6287
|
}, []);
|
6215
6288
|
return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_jsx_runtime31.Fragment, { children });
|
6216
6289
|
};
|
6217
|
-
var autoFrameContext = (0,
|
6218
|
-
var useFrame = () => (0,
|
6290
|
+
var autoFrameContext = (0, import_react40.createContext)({});
|
6291
|
+
var useFrame = () => (0, import_react40.useContext)(autoFrameContext);
|
6219
6292
|
function AutoFrame(_a) {
|
6220
6293
|
var _b = _a, {
|
6221
6294
|
children,
|
@@ -6232,10 +6305,10 @@ function AutoFrame(_a) {
|
|
6232
6305
|
"onStylesLoaded",
|
6233
6306
|
"frameRef"
|
6234
6307
|
]);
|
6235
|
-
const [loaded, setLoaded] = (0,
|
6236
|
-
const [ctx, setCtx] = (0,
|
6237
|
-
const [mountTarget, setMountTarget] = (0,
|
6238
|
-
(0,
|
6308
|
+
const [loaded, setLoaded] = (0, import_react40.useState)(false);
|
6309
|
+
const [ctx, setCtx] = (0, import_react40.useState)({});
|
6310
|
+
const [mountTarget, setMountTarget] = (0, import_react40.useState)();
|
6311
|
+
(0, import_react40.useEffect)(() => {
|
6239
6312
|
var _a2;
|
6240
6313
|
if (frameRef.current) {
|
6241
6314
|
setCtx({
|
@@ -6329,15 +6402,22 @@ var import_jsx_runtime33 = require("react/jsx-runtime");
|
|
6329
6402
|
var getClassName23 = get_class_name_factory_default("PuckPreview", styles_module_default18);
|
6330
6403
|
var useBubbleIframeEvents = (ref) => {
|
6331
6404
|
const { status } = useAppContext();
|
6332
|
-
(0,
|
6405
|
+
(0, import_react41.useEffect)(() => {
|
6333
6406
|
var _a;
|
6334
6407
|
if (ref.current && status === "READY") {
|
6335
6408
|
const iframe = ref.current;
|
6336
6409
|
class BubbledPointerEventClass extends PointerEvent {
|
6337
6410
|
constructor(type, data) {
|
6338
6411
|
super(type, data);
|
6412
|
+
this._originalTarget = null;
|
6339
6413
|
this.originalTarget = data.originalTarget;
|
6340
6414
|
}
|
6415
|
+
set originalTarget(target) {
|
6416
|
+
this._originalTarget = target;
|
6417
|
+
}
|
6418
|
+
get originalTarget() {
|
6419
|
+
return this._originalTarget;
|
6420
|
+
}
|
6341
6421
|
}
|
6342
6422
|
const handlePointerMove = (event) => {
|
6343
6423
|
const evt = new BubbledPointerEventClass("pointermove", __spreadProps(__spreadValues({}, event), {
|
@@ -6368,7 +6448,7 @@ var useBubbleIframeEvents = (ref) => {
|
|
6368
6448
|
};
|
6369
6449
|
var Preview2 = ({ id = "puck-preview" }) => {
|
6370
6450
|
const { config, dispatch, state, setStatus, iframe, overrides } = useAppContext();
|
6371
|
-
const Page = (0,
|
6451
|
+
const Page = (0, import_react41.useCallback)(
|
6372
6452
|
(pageProps) => {
|
6373
6453
|
var _a, _b;
|
6374
6454
|
return ((_a = config.root) == null ? void 0 : _a.render) ? (_b = config.root) == null ? void 0 : _b.render(__spreadValues({
|
@@ -6377,9 +6457,9 @@ var Preview2 = ({ id = "puck-preview" }) => {
|
|
6377
6457
|
},
|
6378
6458
|
[config.root]
|
6379
6459
|
);
|
6380
|
-
const Frame = (0,
|
6460
|
+
const Frame = (0, import_react41.useMemo)(() => overrides.iframe, [overrides]);
|
6381
6461
|
const rootProps = state.data.root.props || state.data.root;
|
6382
|
-
const ref = (0,
|
6462
|
+
const ref = (0, import_react41.useRef)(null);
|
6383
6463
|
useBubbleIframeEvents(ref);
|
6384
6464
|
const inner = state.ui.previewMode === "edit" ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
6385
6465
|
Page,
|
@@ -6476,7 +6556,7 @@ var scrollIntoView = (el) => {
|
|
6476
6556
|
};
|
6477
6557
|
|
6478
6558
|
// components/LayerTree/index.tsx
|
6479
|
-
var
|
6559
|
+
var import_react42 = require("react");
|
6480
6560
|
|
6481
6561
|
// lib/is-child-of-zone.ts
|
6482
6562
|
init_react_import();
|
@@ -6522,7 +6602,7 @@ var LayerTree = ({
|
|
6522
6602
|
label
|
6523
6603
|
}) => {
|
6524
6604
|
const zones = data.zones || {};
|
6525
|
-
const ctx = (0,
|
6605
|
+
const ctx = (0, import_react42.useContext)(dropZoneContext);
|
6526
6606
|
return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(import_jsx_runtime34.Fragment, { children: [
|
6527
6607
|
label && /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("div", { className: getClassName24("zoneTitle"), children: [
|
6528
6608
|
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: getClassName24("zoneIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Layers, { size: "16" }) }),
|
@@ -6629,13 +6709,13 @@ var LayerTree = ({
|
|
6629
6709
|
};
|
6630
6710
|
|
6631
6711
|
// components/Puck/components/Outline/index.tsx
|
6632
|
-
var
|
6712
|
+
var import_react43 = require("react");
|
6633
6713
|
var import_jsx_runtime35 = require("react/jsx-runtime");
|
6634
6714
|
var Outline = () => {
|
6635
6715
|
const { dispatch, state, overrides, config } = useAppContext();
|
6636
6716
|
const { data, ui } = state;
|
6637
6717
|
const { itemSelector } = ui;
|
6638
|
-
const setItemSelector = (0,
|
6718
|
+
const setItemSelector = (0, import_react43.useCallback)(
|
6639
6719
|
(newItemSelector) => {
|
6640
6720
|
dispatch({
|
6641
6721
|
type: "setUi",
|
@@ -6644,7 +6724,7 @@ var Outline = () => {
|
|
6644
6724
|
},
|
6645
6725
|
[]
|
6646
6726
|
);
|
6647
|
-
const Wrapper = (0,
|
6727
|
+
const Wrapper = (0, import_react43.useMemo)(() => overrides.outline || "div", [overrides]);
|
6648
6728
|
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: [
|
6649
6729
|
(ctx == null ? void 0 : ctx.activeZones) && (ctx == null ? void 0 : ctx.activeZones[rootDroppableId]) && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
6650
6730
|
LayerTree,
|
@@ -6758,19 +6838,19 @@ function usePuckHistory({
|
|
6758
6838
|
|
6759
6839
|
// lib/use-history-store.ts
|
6760
6840
|
init_react_import();
|
6761
|
-
var
|
6841
|
+
var import_react44 = require("react");
|
6762
6842
|
var import_use_debounce3 = require("use-debounce");
|
6763
6843
|
var EMPTY_HISTORY_INDEX = 0;
|
6764
6844
|
function useHistoryStore(initialHistory) {
|
6765
6845
|
var _a, _b;
|
6766
|
-
const [histories, setHistories] = (0,
|
6846
|
+
const [histories, setHistories] = (0, import_react44.useState)(
|
6767
6847
|
(_a = initialHistory == null ? void 0 : initialHistory.histories) != null ? _a : []
|
6768
6848
|
);
|
6769
6849
|
const updateHistories = (histories2) => {
|
6770
6850
|
setHistories(histories2);
|
6771
6851
|
setIndex(histories2.length - 1);
|
6772
6852
|
};
|
6773
|
-
const [index, setIndex] = (0,
|
6853
|
+
const [index, setIndex] = (0, import_react44.useState)(
|
6774
6854
|
(_b = initialHistory == null ? void 0 : initialHistory.index) != null ? _b : EMPTY_HISTORY_INDEX
|
6775
6855
|
);
|
6776
6856
|
const hasPast = index > EMPTY_HISTORY_INDEX;
|
@@ -6930,11 +7010,11 @@ var getBox = function getBox2(el) {
|
|
6930
7010
|
};
|
6931
7011
|
|
6932
7012
|
// components/Puck/components/Canvas/index.tsx
|
6933
|
-
var
|
7013
|
+
var import_react46 = require("react");
|
6934
7014
|
|
6935
7015
|
// components/ViewportControls/index.tsx
|
6936
7016
|
init_react_import();
|
6937
|
-
var
|
7017
|
+
var import_react45 = require("react");
|
6938
7018
|
|
6939
7019
|
// css-module:/home/runner/work/puck/puck/packages/core/components/ViewportControls/styles.module.css#css-module
|
6940
7020
|
init_react_import();
|
@@ -6957,8 +7037,8 @@ var ViewportButton = ({
|
|
6957
7037
|
onClick
|
6958
7038
|
}) => {
|
6959
7039
|
const { state } = useAppContext();
|
6960
|
-
const [isActive, setIsActive] = (0,
|
6961
|
-
(0,
|
7040
|
+
const [isActive, setIsActive] = (0, import_react45.useState)(false);
|
7041
|
+
(0, import_react45.useEffect)(() => {
|
6962
7042
|
setIsActive(width === state.ui.viewports.current.width);
|
6963
7043
|
}, [width, state.ui.viewports.current.width]);
|
6964
7044
|
return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("span", { className: getClassNameButton({ isActive }), children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
@@ -6994,7 +7074,7 @@ var ViewportControls = ({
|
|
6994
7074
|
const defaultsContainAutoZoom = defaultZoomOptions.find(
|
6995
7075
|
(option) => option.value === autoZoom
|
6996
7076
|
);
|
6997
|
-
const zoomOptions = (0,
|
7077
|
+
const zoomOptions = (0, import_react45.useMemo)(
|
6998
7078
|
() => [
|
6999
7079
|
...defaultZoomOptions,
|
7000
7080
|
...defaultsContainAutoZoom ? [] : [
|
@@ -7117,17 +7197,17 @@ var Canvas = () => {
|
|
7117
7197
|
const { status, iframe } = useAppContext();
|
7118
7198
|
const { dispatch, state, overrides, setUi, zoomConfig, setZoomConfig } = useAppContext();
|
7119
7199
|
const { ui } = state;
|
7120
|
-
const frameRef = (0,
|
7121
|
-
const [showTransition, setShowTransition] = (0,
|
7122
|
-
const defaultRender = (0,
|
7200
|
+
const frameRef = (0, import_react46.useRef)(null);
|
7201
|
+
const [showTransition, setShowTransition] = (0, import_react46.useState)(false);
|
7202
|
+
const defaultRender = (0, import_react46.useMemo)(() => {
|
7123
7203
|
const PuckDefault = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(import_jsx_runtime37.Fragment, { children });
|
7124
7204
|
return PuckDefault;
|
7125
7205
|
}, []);
|
7126
|
-
const CustomPreview = (0,
|
7206
|
+
const CustomPreview = (0, import_react46.useMemo)(
|
7127
7207
|
() => overrides.preview || defaultRender,
|
7128
7208
|
[overrides]
|
7129
7209
|
);
|
7130
|
-
const getFrameDimensions = (0,
|
7210
|
+
const getFrameDimensions = (0, import_react46.useCallback)(() => {
|
7131
7211
|
if (frameRef.current) {
|
7132
7212
|
const frame = frameRef.current;
|
7133
7213
|
const box = getBox(frame);
|
@@ -7135,7 +7215,7 @@ var Canvas = () => {
|
|
7135
7215
|
}
|
7136
7216
|
return { width: 0, height: 0 };
|
7137
7217
|
}, [frameRef]);
|
7138
|
-
const resetAutoZoom = (0,
|
7218
|
+
const resetAutoZoom = (0, import_react46.useCallback)(
|
7139
7219
|
(ui2 = state.ui) => {
|
7140
7220
|
if (frameRef.current) {
|
7141
7221
|
setZoomConfig(
|
@@ -7145,11 +7225,11 @@ var Canvas = () => {
|
|
7145
7225
|
},
|
7146
7226
|
[frameRef, zoomConfig, state.ui]
|
7147
7227
|
);
|
7148
|
-
(0,
|
7228
|
+
(0, import_react46.useEffect)(() => {
|
7149
7229
|
setShowTransition(false);
|
7150
7230
|
resetAutoZoom();
|
7151
7231
|
}, [frameRef, ui.leftSideBarVisible, ui.rightSideBarVisible]);
|
7152
|
-
(0,
|
7232
|
+
(0, import_react46.useEffect)(() => {
|
7153
7233
|
const { height: frameHeight } = getFrameDimensions();
|
7154
7234
|
if (ui.viewports.current.height === "auto") {
|
7155
7235
|
setZoomConfig(__spreadProps(__spreadValues({}, zoomConfig), {
|
@@ -7157,13 +7237,13 @@ var Canvas = () => {
|
|
7157
7237
|
}));
|
7158
7238
|
}
|
7159
7239
|
}, [zoomConfig.zoom]);
|
7160
|
-
(0,
|
7240
|
+
(0, import_react46.useEffect)(() => {
|
7161
7241
|
if (ZOOM_ON_CHANGE) {
|
7162
7242
|
setShowTransition(true);
|
7163
7243
|
resetAutoZoom(ui);
|
7164
7244
|
}
|
7165
7245
|
}, [ui.viewports.current.width]);
|
7166
|
-
(0,
|
7246
|
+
(0, import_react46.useEffect)(() => {
|
7167
7247
|
const cb = () => {
|
7168
7248
|
setShowTransition(false);
|
7169
7249
|
resetAutoZoom();
|
@@ -7173,8 +7253,8 @@ var Canvas = () => {
|
|
7173
7253
|
window.removeEventListener("resize", cb);
|
7174
7254
|
};
|
7175
7255
|
}, []);
|
7176
|
-
const [showLoader, setShowLoader] = (0,
|
7177
|
-
(0,
|
7256
|
+
const [showLoader, setShowLoader] = (0, import_react46.useState)(false);
|
7257
|
+
(0, import_react46.useEffect)(() => {
|
7178
7258
|
setTimeout(() => {
|
7179
7259
|
setShowLoader(true);
|
7180
7260
|
}, 500);
|
@@ -7252,7 +7332,7 @@ var Canvas = () => {
|
|
7252
7332
|
|
7253
7333
|
// lib/use-loaded-overrides.ts
|
7254
7334
|
init_react_import();
|
7255
|
-
var
|
7335
|
+
var import_react47 = require("react");
|
7256
7336
|
|
7257
7337
|
// lib/load-overrides.ts
|
7258
7338
|
init_react_import();
|
@@ -7291,7 +7371,7 @@ var useLoadedOverrides = ({
|
|
7291
7371
|
overrides,
|
7292
7372
|
plugins
|
7293
7373
|
}) => {
|
7294
|
-
return (0,
|
7374
|
+
return (0, import_react47.useMemo)(() => {
|
7295
7375
|
return loadOverrides({ overrides, plugins });
|
7296
7376
|
}, [plugins, overrides]);
|
7297
7377
|
};
|
@@ -7303,14 +7383,14 @@ var DefaultOverride = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime38
|
|
7303
7383
|
|
7304
7384
|
// lib/use-inject-css.ts
|
7305
7385
|
init_react_import();
|
7306
|
-
var
|
7386
|
+
var import_react48 = require("react");
|
7307
7387
|
var styles = ``;
|
7308
7388
|
var useInjectStyleSheet = (initialStyles, iframeEnabled) => {
|
7309
|
-
const [el, setEl] = (0,
|
7310
|
-
(0,
|
7389
|
+
const [el, setEl] = (0, import_react48.useState)();
|
7390
|
+
(0, import_react48.useEffect)(() => {
|
7311
7391
|
setEl(document.createElement("style"));
|
7312
7392
|
}, []);
|
7313
|
-
(0,
|
7393
|
+
(0, import_react48.useEffect)(() => {
|
7314
7394
|
var _a;
|
7315
7395
|
if (!el || typeof window === "undefined") {
|
7316
7396
|
return;
|
@@ -7330,10 +7410,10 @@ var useInjectGlobalCss = (iframeEnabled) => {
|
|
7330
7410
|
|
7331
7411
|
// lib/use-preview-mode-hotkeys.ts
|
7332
7412
|
init_react_import();
|
7333
|
-
var
|
7413
|
+
var import_react49 = require("react");
|
7334
7414
|
var import_react_hotkeys_hook2 = require("react-hotkeys-hook");
|
7335
7415
|
var usePreviewModeHotkeys = (dispatch, iframeEnabled) => {
|
7336
|
-
const toggleInteractive = (0,
|
7416
|
+
const toggleInteractive = (0, import_react49.useCallback)(() => {
|
7337
7417
|
dispatch({
|
7338
7418
|
type: "setUi",
|
7339
7419
|
ui: (ui) => ({
|
@@ -7385,7 +7465,7 @@ function Puck({
|
|
7385
7465
|
waitForStyles: true
|
7386
7466
|
}, _iframe);
|
7387
7467
|
useInjectGlobalCss(iframe.enabled);
|
7388
|
-
const [generatedAppState] = (0,
|
7468
|
+
const [generatedAppState] = (0, import_react50.useState)(() => {
|
7389
7469
|
var _a2, _b2, _c, _d, _e, _f, _g, _h, _i;
|
7390
7470
|
const initial = __spreadValues(__spreadValues({}, defaultAppState.ui), initialUi);
|
7391
7471
|
let clientUiState = {};
|
@@ -7457,14 +7537,14 @@ function Puck({
|
|
7457
7537
|
histories,
|
7458
7538
|
index: initialHistoryIndex
|
7459
7539
|
});
|
7460
|
-
const [reducer] = (0,
|
7540
|
+
const [reducer] = (0, import_react50.useState)(
|
7461
7541
|
() => createReducer({
|
7462
7542
|
config,
|
7463
7543
|
record: historyStore.record,
|
7464
7544
|
onAction
|
7465
7545
|
})
|
7466
7546
|
);
|
7467
|
-
const [appState, dispatch] = (0,
|
7547
|
+
const [appState, dispatch] = (0, import_react50.useReducer)(
|
7468
7548
|
reducer,
|
7469
7549
|
flushZones(initialAppState)
|
7470
7550
|
);
|
@@ -7475,14 +7555,14 @@ function Puck({
|
|
7475
7555
|
historyStore,
|
7476
7556
|
iframeEnabled: (_a = _iframe == null ? void 0 : _iframe.enabled) != null ? _a : true
|
7477
7557
|
});
|
7478
|
-
const [menuOpen, setMenuOpen] = (0,
|
7558
|
+
const [menuOpen, setMenuOpen] = (0, import_react50.useState)(false);
|
7479
7559
|
const { itemSelector, leftSideBarVisible, rightSideBarVisible } = ui;
|
7480
7560
|
const selectedItem = itemSelector ? getItem(itemSelector, data) : null;
|
7481
|
-
(0,
|
7561
|
+
(0, import_react50.useEffect)(() => {
|
7482
7562
|
if (onChange) onChange(data);
|
7483
7563
|
}, [data]);
|
7484
7564
|
const rootProps = data.root.props || data.root;
|
7485
|
-
const toggleSidebars = (0,
|
7565
|
+
const toggleSidebars = (0, import_react50.useCallback)(
|
7486
7566
|
(sidebar) => {
|
7487
7567
|
const widerViewport = window.matchMedia("(min-width: 638px)").matches;
|
7488
7568
|
const sideBarVisible = sidebar === "left" ? leftSideBarVisible : rightSideBarVisible;
|
@@ -7496,7 +7576,7 @@ function Puck({
|
|
7496
7576
|
},
|
7497
7577
|
[dispatch, leftSideBarVisible, rightSideBarVisible]
|
7498
7578
|
);
|
7499
|
-
(0,
|
7579
|
+
(0, import_react50.useEffect)(() => {
|
7500
7580
|
if (!window.matchMedia("(min-width: 638px)").matches) {
|
7501
7581
|
dispatch({
|
7502
7582
|
type: "setUi",
|
@@ -7519,7 +7599,7 @@ function Puck({
|
|
7519
7599
|
window.removeEventListener("resize", handleResize);
|
7520
7600
|
};
|
7521
7601
|
}, []);
|
7522
|
-
const defaultHeaderRender = (0,
|
7602
|
+
const defaultHeaderRender = (0, import_react50.useMemo)(() => {
|
7523
7603
|
if (renderHeader) {
|
7524
7604
|
console.warn(
|
7525
7605
|
"`renderHeader` is deprecated. Please use `overrides.header` and the `usePuck` hook instead"
|
@@ -7533,7 +7613,7 @@ function Puck({
|
|
7533
7613
|
}
|
7534
7614
|
return DefaultOverride;
|
7535
7615
|
}, [renderHeader]);
|
7536
|
-
const defaultHeaderActionsRender = (0,
|
7616
|
+
const defaultHeaderActionsRender = (0, import_react50.useMemo)(() => {
|
7537
7617
|
if (renderHeaderActions) {
|
7538
7618
|
console.warn(
|
7539
7619
|
"`renderHeaderActions` is deprecated. Please use `overrides.headerActions` and the `usePuck` hook instead."
|
@@ -7550,20 +7630,20 @@ function Puck({
|
|
7550
7630
|
overrides,
|
7551
7631
|
plugins
|
7552
7632
|
});
|
7553
|
-
const CustomPuck = (0,
|
7633
|
+
const CustomPuck = (0, import_react50.useMemo)(
|
7554
7634
|
() => loadedOverrides.puck || DefaultOverride,
|
7555
7635
|
[loadedOverrides]
|
7556
7636
|
);
|
7557
|
-
const CustomHeader = (0,
|
7637
|
+
const CustomHeader = (0, import_react50.useMemo)(
|
7558
7638
|
() => loadedOverrides.header || defaultHeaderRender,
|
7559
7639
|
[loadedOverrides]
|
7560
7640
|
);
|
7561
|
-
const CustomHeaderActions = (0,
|
7641
|
+
const CustomHeaderActions = (0, import_react50.useMemo)(
|
7562
7642
|
() => loadedOverrides.headerActions || defaultHeaderActionsRender,
|
7563
7643
|
[loadedOverrides]
|
7564
7644
|
);
|
7565
|
-
const [mounted, setMounted] = (0,
|
7566
|
-
(0,
|
7645
|
+
const [mounted, setMounted] = (0, import_react50.useState)(false);
|
7646
|
+
(0, import_react50.useEffect)(() => {
|
7567
7647
|
setMounted(true);
|
7568
7648
|
}, []);
|
7569
7649
|
const selectedComponentConfig = selectedItem && config.components[selectedItem.type];
|