@measured/puck 0.18.0-canary.007a413 → 0.18.0-canary.00f3e0f
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/dist/index.css +44 -47
- package/dist/index.d.mts +5 -2
- package/dist/index.d.ts +5 -2
- package/dist/index.js +231 -151
- package/dist/index.mjs +222 -142
- 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
|
@@ -3663,6 +3682,7 @@ var import_jsx_runtime22 = require("react/jsx-runtime");
|
|
3663
3682
|
var getClassName17 = get_class_name_factory_default("DropZone", styles_module_default12);
|
3664
3683
|
var getRandomColor = () => `#${Math.floor(Math.random() * 16777215).toString(16)}`;
|
3665
3684
|
var RENDER_DEBUG = false;
|
3685
|
+
var DropZoneEditPure = (props) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(DropZoneEdit, __spreadValues({}, props));
|
3666
3686
|
var DropZoneEdit = (0, import_react29.forwardRef)(
|
3667
3687
|
function DropZoneEditInternal({
|
3668
3688
|
zone,
|
@@ -3698,8 +3718,7 @@ var DropZoneEdit = (0, import_react29.forwardRef)(
|
|
3698
3718
|
isDeepestZone,
|
3699
3719
|
inNextDeepestArea,
|
3700
3720
|
draggedComponentType,
|
3701
|
-
userIsDragging
|
3702
|
-
preview
|
3721
|
+
userIsDragging
|
3703
3722
|
} = useContextStore(ZoneStoreContext, (s) => {
|
3704
3723
|
var _a, _b, _c;
|
3705
3724
|
return {
|
@@ -3707,8 +3726,7 @@ var DropZoneEdit = (0, import_react29.forwardRef)(
|
|
3707
3726
|
inNextDeepestArea: s.nextAreaDepthIndex[areaId || ""],
|
3708
3727
|
draggedItemId: (_b = s.draggedItem) == null ? void 0 : _b.id,
|
3709
3728
|
draggedComponentType: (_c = s.draggedItem) == null ? void 0 : _c.data.componentType,
|
3710
|
-
userIsDragging: !!s.draggedItem
|
3711
|
-
preview: s.previewIndex[zoneCompound]
|
3729
|
+
userIsDragging: !!s.draggedItem
|
3712
3730
|
};
|
3713
3731
|
});
|
3714
3732
|
const { itemSelector } = appContext2.state.ui;
|
@@ -3774,7 +3792,10 @@ var DropZoneEdit = (0, import_react29.forwardRef)(
|
|
3774
3792
|
if (isEnabled) {
|
3775
3793
|
isEnabled = acceptsTarget(draggedComponentType);
|
3776
3794
|
}
|
3777
|
-
const contentWithPreview = useContentWithPreview(
|
3795
|
+
const [contentWithPreview, preview] = useContentWithPreview(
|
3796
|
+
content,
|
3797
|
+
zoneCompound
|
3798
|
+
);
|
3778
3799
|
const isDropEnabled = isEnabled && (preview ? contentWithPreview.length === 1 : contentWithPreview.length === 0);
|
3779
3800
|
const droppableConfig = {
|
3780
3801
|
id: zoneCompound,
|
@@ -3816,16 +3837,15 @@ var DropZoneEdit = (0, import_react29.forwardRef)(
|
|
3816
3837
|
},
|
3817
3838
|
"data-testid": `dropzone:${zoneCompound}`,
|
3818
3839
|
"data-puck-dropzone": zoneCompound,
|
3819
|
-
"data-puck-dnd": zoneCompound,
|
3820
3840
|
style: __spreadProps(__spreadValues({}, style), {
|
3821
3841
|
"--min-empty-height": `${minEmptyHeight}px`,
|
3822
|
-
backgroundColor: RENDER_DEBUG ? getRandomColor() : void 0
|
3842
|
+
backgroundColor: RENDER_DEBUG ? getRandomColor() : style == null ? void 0 : style.backgroundColor
|
3823
3843
|
}),
|
3824
3844
|
children: contentWithPreview.map((item, i) => {
|
3825
|
-
var _a, _b, _c, _d, _e;
|
3845
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
3826
3846
|
const componentId = item.props.id;
|
3827
3847
|
const puckProps = {
|
3828
|
-
renderDropZone:
|
3848
|
+
renderDropZone: DropZoneEditPure,
|
3829
3849
|
isEditing: true,
|
3830
3850
|
dragRef: null
|
3831
3851
|
};
|
@@ -3842,13 +3862,13 @@ var DropZoneEdit = (0, import_react29.forwardRef)(
|
|
3842
3862
|
const componentConfig = config.components[item.type];
|
3843
3863
|
let componentType = item.type;
|
3844
3864
|
let label = (_b = componentConfig == null ? void 0 : componentConfig["label"]) != null ? _b : item.type.toString();
|
3845
|
-
if (item.type === "preview"
|
3865
|
+
if (item.type === "preview") {
|
3846
3866
|
let Preview4 = function() {
|
3847
3867
|
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(DrawerItemInner, { name: label, children: appContext2.overrides.componentItem });
|
3848
3868
|
};
|
3849
3869
|
var Preview3 = Preview4;
|
3850
|
-
componentType = preview.componentType;
|
3851
|
-
label = (
|
3870
|
+
componentType = (_c = preview == null ? void 0 : preview.componentType) != null ? _c : "__preview";
|
3871
|
+
label = (_f = (_e = (_d = config.components[componentType]) == null ? void 0 : _d.label) != null ? _e : componentType) != null ? _f : "Preview";
|
3852
3872
|
Render2 = Preview4;
|
3853
3873
|
}
|
3854
3874
|
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
@@ -3863,7 +3883,7 @@ var DropZoneEdit = (0, import_react29.forwardRef)(
|
|
3863
3883
|
zoneCompound,
|
3864
3884
|
depth: depth + 1,
|
3865
3885
|
index: i,
|
3866
|
-
isLoading: ((
|
3886
|
+
isLoading: ((_g = appContext2.componentState[componentId]) == null ? void 0 : _g.loadingCount) > 0,
|
3867
3887
|
isSelected,
|
3868
3888
|
label,
|
3869
3889
|
isEnabled,
|
@@ -3888,6 +3908,7 @@ var DropZoneEdit = (0, import_react29.forwardRef)(
|
|
3888
3908
|
);
|
3889
3909
|
}
|
3890
3910
|
);
|
3911
|
+
var DropZoneRenderPure = (props) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(DropZoneRender, __spreadValues({}, props));
|
3891
3912
|
var DropZoneRender = (0, import_react29.forwardRef)(
|
3892
3913
|
function DropZoneRenderInternal({ className, style, zone }, ref) {
|
3893
3914
|
const ctx = (0, import_react29.useContext)(dropZoneContext);
|
@@ -3928,7 +3949,7 @@ var DropZoneRender = (0, import_react29.forwardRef)(
|
|
3928
3949
|
Component.render,
|
3929
3950
|
__spreadProps(__spreadValues({}, item.props), {
|
3930
3951
|
puck: {
|
3931
|
-
renderDropZone:
|
3952
|
+
renderDropZone: DropZoneRenderPure
|
3932
3953
|
}
|
3933
3954
|
})
|
3934
3955
|
)
|
@@ -4097,6 +4118,13 @@ var getPointerCollisions = (position, manager) => {
|
|
4097
4118
|
if (elements) {
|
4098
4119
|
for (let i = 0; i < elements.length; i++) {
|
4099
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
|
+
}
|
4100
4128
|
const id = element.getAttribute("data-puck-dnd");
|
4101
4129
|
if (id) {
|
4102
4130
|
const droppable = manager.registry.droppables.get(id);
|
@@ -4505,6 +4533,11 @@ var reduceUi = (ui, action) => {
|
|
4505
4533
|
itemSelector: { index: action.sourceIndex + 1, zone: action.sourceZone }
|
4506
4534
|
});
|
4507
4535
|
}
|
4536
|
+
if (action.type === "remove") {
|
4537
|
+
return __spreadProps(__spreadValues({}, ui), {
|
4538
|
+
itemSelector: null
|
4539
|
+
});
|
4540
|
+
}
|
4508
4541
|
return ui;
|
4509
4542
|
};
|
4510
4543
|
|
@@ -5036,27 +5069,33 @@ var DragDropContextClient = ({
|
|
5036
5069
|
const [pathData, setPathData] = (0, import_react31.useState)();
|
5037
5070
|
const dragMode = (0, import_react31.useRef)(null);
|
5038
5071
|
const registerPath = (0, import_react31.useCallback)(
|
5039
|
-
(selector) => {
|
5040
|
-
const item = getItem(selector, data);
|
5041
|
-
if (!item) {
|
5042
|
-
return;
|
5043
|
-
}
|
5072
|
+
(id2, selector, label) => {
|
5044
5073
|
const [area] = getZoneId(selector.zone);
|
5045
5074
|
setPathData((latestPathData = {}) => {
|
5046
5075
|
const parentPathData = latestPathData[area] || { path: [] };
|
5047
5076
|
return __spreadProps(__spreadValues({}, latestPathData), {
|
5048
|
-
[
|
5077
|
+
[id2]: {
|
5049
5078
|
path: [
|
5050
5079
|
...parentPathData.path,
|
5051
5080
|
...selector.zone ? [selector.zone] : []
|
5052
5081
|
],
|
5053
|
-
label
|
5082
|
+
label
|
5054
5083
|
}
|
5055
5084
|
});
|
5056
5085
|
});
|
5057
5086
|
},
|
5058
5087
|
[data, setPathData]
|
5059
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
|
+
);
|
5060
5099
|
const initialSelector = (0, import_react31.useRef)(void 0);
|
5061
5100
|
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { id, children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
5062
5101
|
dragListenerContext.Provider,
|
@@ -5253,6 +5292,7 @@ var DragDropContextClient = ({
|
|
5253
5292
|
areaId: "root",
|
5254
5293
|
depth: 0,
|
5255
5294
|
registerPath,
|
5295
|
+
unregisterPath,
|
5256
5296
|
pathData,
|
5257
5297
|
path: []
|
5258
5298
|
},
|
@@ -5401,7 +5441,7 @@ Drawer.Item = DrawerItem;
|
|
5401
5441
|
|
5402
5442
|
// components/Puck/index.tsx
|
5403
5443
|
init_react_import();
|
5404
|
-
var
|
5444
|
+
var import_react50 = require("react");
|
5405
5445
|
|
5406
5446
|
// components/SidebarSection/index.tsx
|
5407
5447
|
init_react_import();
|
@@ -5594,36 +5634,61 @@ init_react_import();
|
|
5594
5634
|
|
5595
5635
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Fields/styles.module.css#css-module
|
5596
5636
|
init_react_import();
|
5597
|
-
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" };
|
5598
5638
|
|
5599
5639
|
// components/Puck/components/Fields/index.tsx
|
5600
|
-
var
|
5640
|
+
var import_react37 = require("react");
|
5641
|
+
|
5642
|
+
// lib/use-resolved-fields.ts
|
5643
|
+
init_react_import();
|
5644
|
+
var import_react36 = require("react");
|
5601
5645
|
|
5602
5646
|
// lib/use-parent.ts
|
5603
5647
|
init_react_import();
|
5604
5648
|
var import_react34 = require("react");
|
5605
|
-
var
|
5649
|
+
var getParent = (itemSelector, pathData, data) => {
|
5606
5650
|
var _a;
|
5607
|
-
|
5608
|
-
const
|
5609
|
-
const
|
5610
|
-
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);
|
5611
5654
|
const lastItem = breadcrumbs[breadcrumbs.length - 1];
|
5612
|
-
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;
|
5613
5656
|
return parent || null;
|
5614
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
|
+
};
|
5615
5669
|
|
5616
|
-
//
|
5617
|
-
|
5618
|
-
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
|
5619
5689
|
var defaultPageFields = {
|
5620
5690
|
title: { type: "text" }
|
5621
5691
|
};
|
5622
|
-
var DefaultFields = ({
|
5623
|
-
children
|
5624
|
-
}) => {
|
5625
|
-
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_jsx_runtime27.Fragment, { children });
|
5626
|
-
};
|
5627
5692
|
var useResolvedFields = () => {
|
5628
5693
|
var _a, _b;
|
5629
5694
|
const { selectedItem, state, config } = useAppContext();
|
@@ -5631,20 +5696,21 @@ var useResolvedFields = () => {
|
|
5631
5696
|
const { data } = state;
|
5632
5697
|
const rootFields = ((_a = config.root) == null ? void 0 : _a.fields) || defaultPageFields;
|
5633
5698
|
const componentConfig = selectedItem ? config.components[selectedItem.type] : null;
|
5634
|
-
const defaultFields = (0,
|
5699
|
+
const defaultFields = (0, import_react36.useMemo)(
|
5635
5700
|
() => (selectedItem ? componentConfig == null ? void 0 : componentConfig.fields : rootFields) || {},
|
5636
5701
|
[selectedItem, rootFields, componentConfig == null ? void 0 : componentConfig.fields]
|
5637
5702
|
);
|
5638
5703
|
const rootProps = data.root.props || data.root;
|
5639
|
-
const [lastSelectedData, setLastSelectedData] = (0,
|
5640
|
-
const [resolvedFields, setResolvedFields] = (0,
|
5641
|
-
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);
|
5642
5708
|
const defaultResolveFields = (_componentData, _params) => defaultFields;
|
5643
5709
|
const componentData = selectedItem ? selectedItem : { props: rootProps, readOnly: data.root.readOnly };
|
5644
5710
|
const hasComponentResolver = selectedItem && (componentConfig == null ? void 0 : componentConfig.resolveFields);
|
5645
5711
|
const hasRootResolver = !selectedItem && ((_b = config.root) == null ? void 0 : _b.resolveFields);
|
5646
5712
|
const hasResolver = hasComponentResolver || hasRootResolver;
|
5647
|
-
const resolveFields = (0,
|
5713
|
+
const resolveFields = (0, import_react36.useCallback)(
|
5648
5714
|
(..._0) => __async(void 0, [..._0], function* (fields = {}) {
|
5649
5715
|
var _a2;
|
5650
5716
|
const lastData = ((_a2 = lastSelectedData.props) == null ? void 0 : _a2.id) === componentData.props.id ? lastSelectedData : null;
|
@@ -5656,7 +5722,7 @@ var useResolvedFields = () => {
|
|
5656
5722
|
{
|
5657
5723
|
changed,
|
5658
5724
|
fields,
|
5659
|
-
lastFields:
|
5725
|
+
lastFields: lastFields.current,
|
5660
5726
|
lastData,
|
5661
5727
|
appState: state,
|
5662
5728
|
parent
|
@@ -5667,7 +5733,7 @@ var useResolvedFields = () => {
|
|
5667
5733
|
return yield config.root.resolveFields(componentData, {
|
5668
5734
|
changed,
|
5669
5735
|
fields,
|
5670
|
-
lastFields:
|
5736
|
+
lastFields: lastFields.current,
|
5671
5737
|
lastData,
|
5672
5738
|
appState: state,
|
5673
5739
|
parent
|
@@ -5676,40 +5742,56 @@ var useResolvedFields = () => {
|
|
5676
5742
|
return defaultResolveFields(componentData, {
|
5677
5743
|
changed,
|
5678
5744
|
fields,
|
5679
|
-
lastFields:
|
5745
|
+
lastFields: lastFields.current,
|
5680
5746
|
lastData
|
5681
5747
|
});
|
5682
5748
|
}),
|
5683
|
-
[data, config, componentData, selectedItem,
|
5749
|
+
[data, config, componentData, selectedItem, state, parent]
|
5684
5750
|
);
|
5685
|
-
const
|
5686
|
-
|
5687
|
-
|
5688
|
-
}, [parent]);
|
5689
|
-
(0, import_react35.useEffect)(() => {
|
5690
|
-
var _a2;
|
5691
|
-
if (!((_a2 = state.ui.itemSelector) == null ? void 0 : _a2.zone) || hasParent) {
|
5751
|
+
const triggerResolver = (0, import_react36.useCallback)(() => {
|
5752
|
+
var _a2, _b2;
|
5753
|
+
if (!((_a2 = state.ui.itemSelector) == null ? void 0 : _a2.zone) || ((_b2 = state.ui.itemSelector) == null ? void 0 : _b2.zone) === "default-zone" || parent) {
|
5692
5754
|
if (hasResolver) {
|
5693
5755
|
setFieldsLoading(true);
|
5694
5756
|
resolveFields(defaultFields).then((fields) => {
|
5695
5757
|
setResolvedFields(fields || {});
|
5758
|
+
lastFields.current = fields;
|
5696
5759
|
setFieldsLoading(false);
|
5697
5760
|
});
|
5698
|
-
|
5699
|
-
setResolvedFields(defaultFields);
|
5761
|
+
return;
|
5700
5762
|
}
|
5701
5763
|
}
|
5702
|
-
|
5703
|
-
|
5704
|
-
|
5764
|
+
setResolvedFields(defaultFields);
|
5765
|
+
}, [defaultFields, state.ui.itemSelector, hasResolver, parent]);
|
5766
|
+
useOnValueChange(
|
5705
5767
|
state.ui.itemSelector,
|
5706
|
-
|
5707
|
-
|
5708
|
-
|
5709
|
-
|
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
|
+
}, []);
|
5710
5783
|
return [resolvedFields, fieldsLoading];
|
5711
5784
|
};
|
5712
|
-
|
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 }) => {
|
5713
5795
|
var _a, _b;
|
5714
5796
|
const {
|
5715
5797
|
selectedItem,
|
@@ -5727,11 +5809,11 @@ var Fields = () => {
|
|
5727
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;
|
5728
5810
|
const isLoading = fieldsResolving || componentResolving;
|
5729
5811
|
const rootProps = data.root.props || data.root;
|
5730
|
-
const Wrapper = (0,
|
5812
|
+
const Wrapper = (0, import_react37.useMemo)(() => overrides.fields || DefaultFields, [overrides]);
|
5731
5813
|
return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
|
5732
5814
|
"form",
|
5733
5815
|
{
|
5734
|
-
className: getClassName21(),
|
5816
|
+
className: getClassName21({ wrapFields }),
|
5735
5817
|
onSubmit: (e) => {
|
5736
5818
|
e.preventDefault();
|
5737
5819
|
},
|
@@ -5807,7 +5889,7 @@ var Fields = () => {
|
|
5807
5889
|
item: selectedItem
|
5808
5890
|
});
|
5809
5891
|
const id = `${selectedItem.props.id}_${field.type}_${fieldName}`;
|
5810
|
-
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)(
|
5811
5893
|
AutoFieldPrivate,
|
5812
5894
|
{
|
5813
5895
|
field,
|
@@ -5816,16 +5898,15 @@ var Fields = () => {
|
|
5816
5898
|
readOnly: !edit || readOnly[fieldName],
|
5817
5899
|
value: selectedItem.props[fieldName],
|
5818
5900
|
onChange
|
5819
|
-
}
|
5820
|
-
|
5821
|
-
);
|
5901
|
+
}
|
5902
|
+
) }, id);
|
5822
5903
|
} else {
|
5823
5904
|
const readOnly = data.root.readOnly || {};
|
5824
5905
|
const { edit } = getPermissions({
|
5825
5906
|
root: true
|
5826
5907
|
});
|
5827
5908
|
const id = `root_${field.type}_${fieldName}`;
|
5828
|
-
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)(
|
5829
5910
|
AutoFieldPrivate,
|
5830
5911
|
{
|
5831
5912
|
field,
|
@@ -5834,9 +5915,8 @@ var Fields = () => {
|
|
5834
5915
|
readOnly: !edit || readOnly[fieldName],
|
5835
5916
|
value: rootProps[fieldName],
|
5836
5917
|
onChange
|
5837
|
-
}
|
5838
|
-
|
5839
|
-
);
|
5918
|
+
}
|
5919
|
+
) }, id);
|
5840
5920
|
}
|
5841
5921
|
}) }),
|
5842
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 }) }) })
|
@@ -5850,7 +5930,7 @@ init_react_import();
|
|
5850
5930
|
|
5851
5931
|
// lib/use-component-list.tsx
|
5852
5932
|
init_react_import();
|
5853
|
-
var
|
5933
|
+
var import_react38 = require("react");
|
5854
5934
|
|
5855
5935
|
// components/ComponentList/index.tsx
|
5856
5936
|
init_react_import();
|
@@ -5917,8 +5997,8 @@ ComponentList.Item = ComponentListItem;
|
|
5917
5997
|
// lib/use-component-list.tsx
|
5918
5998
|
var import_jsx_runtime29 = require("react/jsx-runtime");
|
5919
5999
|
var useComponentList = (config, ui) => {
|
5920
|
-
const [componentList, setComponentList] = (0,
|
5921
|
-
(0,
|
6000
|
+
const [componentList, setComponentList] = (0, import_react38.useState)();
|
6001
|
+
(0, import_react38.useEffect)(() => {
|
5922
6002
|
var _a, _b, _c;
|
5923
6003
|
if (Object.keys(ui.componentList).length > 0) {
|
5924
6004
|
const matchedComponents = [];
|
@@ -5987,22 +6067,22 @@ var useComponentList = (config, ui) => {
|
|
5987
6067
|
};
|
5988
6068
|
|
5989
6069
|
// components/Puck/components/Components/index.tsx
|
5990
|
-
var
|
6070
|
+
var import_react39 = require("react");
|
5991
6071
|
var import_jsx_runtime30 = require("react/jsx-runtime");
|
5992
6072
|
var Components = () => {
|
5993
6073
|
const { config, state, overrides } = useAppContext();
|
5994
6074
|
const componentList = useComponentList(config, state.ui);
|
5995
|
-
const Wrapper = (0,
|
6075
|
+
const Wrapper = (0, import_react39.useMemo)(() => overrides.components || "div", [overrides]);
|
5996
6076
|
return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Wrapper, { children: componentList ? componentList : /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(ComponentList, { id: "all" }) });
|
5997
6077
|
};
|
5998
6078
|
|
5999
6079
|
// components/Puck/components/Preview/index.tsx
|
6000
6080
|
init_react_import();
|
6001
|
-
var
|
6081
|
+
var import_react41 = require("react");
|
6002
6082
|
|
6003
6083
|
// components/AutoFrame/index.tsx
|
6004
6084
|
init_react_import();
|
6005
|
-
var
|
6085
|
+
var import_react40 = require("react");
|
6006
6086
|
var import_object_hash = __toESM(require("object-hash"));
|
6007
6087
|
var import_react_dom3 = require("react-dom");
|
6008
6088
|
var import_jsx_runtime31 = require("react/jsx-runtime");
|
@@ -6048,7 +6128,7 @@ var CopyHostStyles = ({
|
|
6048
6128
|
onStylesLoaded = () => null
|
6049
6129
|
}) => {
|
6050
6130
|
const { document: doc, window: win } = useFrame();
|
6051
|
-
(0,
|
6131
|
+
(0, import_react40.useEffect)(() => {
|
6052
6132
|
if (!win || !doc) {
|
6053
6133
|
return () => {
|
6054
6134
|
};
|
@@ -6207,8 +6287,8 @@ var CopyHostStyles = ({
|
|
6207
6287
|
}, []);
|
6208
6288
|
return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_jsx_runtime31.Fragment, { children });
|
6209
6289
|
};
|
6210
|
-
var autoFrameContext = (0,
|
6211
|
-
var useFrame = () => (0,
|
6290
|
+
var autoFrameContext = (0, import_react40.createContext)({});
|
6291
|
+
var useFrame = () => (0, import_react40.useContext)(autoFrameContext);
|
6212
6292
|
function AutoFrame(_a) {
|
6213
6293
|
var _b = _a, {
|
6214
6294
|
children,
|
@@ -6225,10 +6305,10 @@ function AutoFrame(_a) {
|
|
6225
6305
|
"onStylesLoaded",
|
6226
6306
|
"frameRef"
|
6227
6307
|
]);
|
6228
|
-
const [loaded, setLoaded] = (0,
|
6229
|
-
const [ctx, setCtx] = (0,
|
6230
|
-
const [mountTarget, setMountTarget] = (0,
|
6231
|
-
(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)(() => {
|
6232
6312
|
var _a2;
|
6233
6313
|
if (frameRef.current) {
|
6234
6314
|
setCtx({
|
@@ -6322,7 +6402,7 @@ var import_jsx_runtime33 = require("react/jsx-runtime");
|
|
6322
6402
|
var getClassName23 = get_class_name_factory_default("PuckPreview", styles_module_default18);
|
6323
6403
|
var useBubbleIframeEvents = (ref) => {
|
6324
6404
|
const { status } = useAppContext();
|
6325
|
-
(0,
|
6405
|
+
(0, import_react41.useEffect)(() => {
|
6326
6406
|
var _a;
|
6327
6407
|
if (ref.current && status === "READY") {
|
6328
6408
|
const iframe = ref.current;
|
@@ -6361,7 +6441,7 @@ var useBubbleIframeEvents = (ref) => {
|
|
6361
6441
|
};
|
6362
6442
|
var Preview2 = ({ id = "puck-preview" }) => {
|
6363
6443
|
const { config, dispatch, state, setStatus, iframe, overrides } = useAppContext();
|
6364
|
-
const Page = (0,
|
6444
|
+
const Page = (0, import_react41.useCallback)(
|
6365
6445
|
(pageProps) => {
|
6366
6446
|
var _a, _b;
|
6367
6447
|
return ((_a = config.root) == null ? void 0 : _a.render) ? (_b = config.root) == null ? void 0 : _b.render(__spreadValues({
|
@@ -6370,9 +6450,9 @@ var Preview2 = ({ id = "puck-preview" }) => {
|
|
6370
6450
|
},
|
6371
6451
|
[config.root]
|
6372
6452
|
);
|
6373
|
-
const Frame = (0,
|
6453
|
+
const Frame = (0, import_react41.useMemo)(() => overrides.iframe, [overrides]);
|
6374
6454
|
const rootProps = state.data.root.props || state.data.root;
|
6375
|
-
const ref = (0,
|
6455
|
+
const ref = (0, import_react41.useRef)(null);
|
6376
6456
|
useBubbleIframeEvents(ref);
|
6377
6457
|
const inner = state.ui.previewMode === "edit" ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
6378
6458
|
Page,
|
@@ -6469,7 +6549,7 @@ var scrollIntoView = (el) => {
|
|
6469
6549
|
};
|
6470
6550
|
|
6471
6551
|
// components/LayerTree/index.tsx
|
6472
|
-
var
|
6552
|
+
var import_react42 = require("react");
|
6473
6553
|
|
6474
6554
|
// lib/is-child-of-zone.ts
|
6475
6555
|
init_react_import();
|
@@ -6515,7 +6595,7 @@ var LayerTree = ({
|
|
6515
6595
|
label
|
6516
6596
|
}) => {
|
6517
6597
|
const zones = data.zones || {};
|
6518
|
-
const ctx = (0,
|
6598
|
+
const ctx = (0, import_react42.useContext)(dropZoneContext);
|
6519
6599
|
return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(import_jsx_runtime34.Fragment, { children: [
|
6520
6600
|
label && /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("div", { className: getClassName24("zoneTitle"), children: [
|
6521
6601
|
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: getClassName24("zoneIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Layers, { size: "16" }) }),
|
@@ -6622,13 +6702,13 @@ var LayerTree = ({
|
|
6622
6702
|
};
|
6623
6703
|
|
6624
6704
|
// components/Puck/components/Outline/index.tsx
|
6625
|
-
var
|
6705
|
+
var import_react43 = require("react");
|
6626
6706
|
var import_jsx_runtime35 = require("react/jsx-runtime");
|
6627
6707
|
var Outline = () => {
|
6628
6708
|
const { dispatch, state, overrides, config } = useAppContext();
|
6629
6709
|
const { data, ui } = state;
|
6630
6710
|
const { itemSelector } = ui;
|
6631
|
-
const setItemSelector = (0,
|
6711
|
+
const setItemSelector = (0, import_react43.useCallback)(
|
6632
6712
|
(newItemSelector) => {
|
6633
6713
|
dispatch({
|
6634
6714
|
type: "setUi",
|
@@ -6637,7 +6717,7 @@ var Outline = () => {
|
|
6637
6717
|
},
|
6638
6718
|
[]
|
6639
6719
|
);
|
6640
|
-
const Wrapper = (0,
|
6720
|
+
const Wrapper = (0, import_react43.useMemo)(() => overrides.outline || "div", [overrides]);
|
6641
6721
|
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: [
|
6642
6722
|
(ctx == null ? void 0 : ctx.activeZones) && (ctx == null ? void 0 : ctx.activeZones[rootDroppableId]) && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
6643
6723
|
LayerTree,
|
@@ -6751,19 +6831,19 @@ function usePuckHistory({
|
|
6751
6831
|
|
6752
6832
|
// lib/use-history-store.ts
|
6753
6833
|
init_react_import();
|
6754
|
-
var
|
6834
|
+
var import_react44 = require("react");
|
6755
6835
|
var import_use_debounce3 = require("use-debounce");
|
6756
6836
|
var EMPTY_HISTORY_INDEX = 0;
|
6757
6837
|
function useHistoryStore(initialHistory) {
|
6758
6838
|
var _a, _b;
|
6759
|
-
const [histories, setHistories] = (0,
|
6839
|
+
const [histories, setHistories] = (0, import_react44.useState)(
|
6760
6840
|
(_a = initialHistory == null ? void 0 : initialHistory.histories) != null ? _a : []
|
6761
6841
|
);
|
6762
6842
|
const updateHistories = (histories2) => {
|
6763
6843
|
setHistories(histories2);
|
6764
6844
|
setIndex(histories2.length - 1);
|
6765
6845
|
};
|
6766
|
-
const [index, setIndex] = (0,
|
6846
|
+
const [index, setIndex] = (0, import_react44.useState)(
|
6767
6847
|
(_b = initialHistory == null ? void 0 : initialHistory.index) != null ? _b : EMPTY_HISTORY_INDEX
|
6768
6848
|
);
|
6769
6849
|
const hasPast = index > EMPTY_HISTORY_INDEX;
|
@@ -6923,11 +7003,11 @@ var getBox = function getBox2(el) {
|
|
6923
7003
|
};
|
6924
7004
|
|
6925
7005
|
// components/Puck/components/Canvas/index.tsx
|
6926
|
-
var
|
7006
|
+
var import_react46 = require("react");
|
6927
7007
|
|
6928
7008
|
// components/ViewportControls/index.tsx
|
6929
7009
|
init_react_import();
|
6930
|
-
var
|
7010
|
+
var import_react45 = require("react");
|
6931
7011
|
|
6932
7012
|
// css-module:/home/runner/work/puck/puck/packages/core/components/ViewportControls/styles.module.css#css-module
|
6933
7013
|
init_react_import();
|
@@ -6950,8 +7030,8 @@ var ViewportButton = ({
|
|
6950
7030
|
onClick
|
6951
7031
|
}) => {
|
6952
7032
|
const { state } = useAppContext();
|
6953
|
-
const [isActive, setIsActive] = (0,
|
6954
|
-
(0,
|
7033
|
+
const [isActive, setIsActive] = (0, import_react45.useState)(false);
|
7034
|
+
(0, import_react45.useEffect)(() => {
|
6955
7035
|
setIsActive(width === state.ui.viewports.current.width);
|
6956
7036
|
}, [width, state.ui.viewports.current.width]);
|
6957
7037
|
return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("span", { className: getClassNameButton({ isActive }), children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
@@ -6987,7 +7067,7 @@ var ViewportControls = ({
|
|
6987
7067
|
const defaultsContainAutoZoom = defaultZoomOptions.find(
|
6988
7068
|
(option) => option.value === autoZoom
|
6989
7069
|
);
|
6990
|
-
const zoomOptions = (0,
|
7070
|
+
const zoomOptions = (0, import_react45.useMemo)(
|
6991
7071
|
() => [
|
6992
7072
|
...defaultZoomOptions,
|
6993
7073
|
...defaultsContainAutoZoom ? [] : [
|
@@ -7110,17 +7190,17 @@ var Canvas = () => {
|
|
7110
7190
|
const { status, iframe } = useAppContext();
|
7111
7191
|
const { dispatch, state, overrides, setUi, zoomConfig, setZoomConfig } = useAppContext();
|
7112
7192
|
const { ui } = state;
|
7113
|
-
const frameRef = (0,
|
7114
|
-
const [showTransition, setShowTransition] = (0,
|
7115
|
-
const defaultRender = (0,
|
7193
|
+
const frameRef = (0, import_react46.useRef)(null);
|
7194
|
+
const [showTransition, setShowTransition] = (0, import_react46.useState)(false);
|
7195
|
+
const defaultRender = (0, import_react46.useMemo)(() => {
|
7116
7196
|
const PuckDefault = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(import_jsx_runtime37.Fragment, { children });
|
7117
7197
|
return PuckDefault;
|
7118
7198
|
}, []);
|
7119
|
-
const CustomPreview = (0,
|
7199
|
+
const CustomPreview = (0, import_react46.useMemo)(
|
7120
7200
|
() => overrides.preview || defaultRender,
|
7121
7201
|
[overrides]
|
7122
7202
|
);
|
7123
|
-
const getFrameDimensions = (0,
|
7203
|
+
const getFrameDimensions = (0, import_react46.useCallback)(() => {
|
7124
7204
|
if (frameRef.current) {
|
7125
7205
|
const frame = frameRef.current;
|
7126
7206
|
const box = getBox(frame);
|
@@ -7128,7 +7208,7 @@ var Canvas = () => {
|
|
7128
7208
|
}
|
7129
7209
|
return { width: 0, height: 0 };
|
7130
7210
|
}, [frameRef]);
|
7131
|
-
const resetAutoZoom = (0,
|
7211
|
+
const resetAutoZoom = (0, import_react46.useCallback)(
|
7132
7212
|
(ui2 = state.ui) => {
|
7133
7213
|
if (frameRef.current) {
|
7134
7214
|
setZoomConfig(
|
@@ -7138,11 +7218,11 @@ var Canvas = () => {
|
|
7138
7218
|
},
|
7139
7219
|
[frameRef, zoomConfig, state.ui]
|
7140
7220
|
);
|
7141
|
-
(0,
|
7221
|
+
(0, import_react46.useEffect)(() => {
|
7142
7222
|
setShowTransition(false);
|
7143
7223
|
resetAutoZoom();
|
7144
7224
|
}, [frameRef, ui.leftSideBarVisible, ui.rightSideBarVisible]);
|
7145
|
-
(0,
|
7225
|
+
(0, import_react46.useEffect)(() => {
|
7146
7226
|
const { height: frameHeight } = getFrameDimensions();
|
7147
7227
|
if (ui.viewports.current.height === "auto") {
|
7148
7228
|
setZoomConfig(__spreadProps(__spreadValues({}, zoomConfig), {
|
@@ -7150,13 +7230,13 @@ var Canvas = () => {
|
|
7150
7230
|
}));
|
7151
7231
|
}
|
7152
7232
|
}, [zoomConfig.zoom]);
|
7153
|
-
(0,
|
7233
|
+
(0, import_react46.useEffect)(() => {
|
7154
7234
|
if (ZOOM_ON_CHANGE) {
|
7155
7235
|
setShowTransition(true);
|
7156
7236
|
resetAutoZoom(ui);
|
7157
7237
|
}
|
7158
7238
|
}, [ui.viewports.current.width]);
|
7159
|
-
(0,
|
7239
|
+
(0, import_react46.useEffect)(() => {
|
7160
7240
|
const cb = () => {
|
7161
7241
|
setShowTransition(false);
|
7162
7242
|
resetAutoZoom();
|
@@ -7166,8 +7246,8 @@ var Canvas = () => {
|
|
7166
7246
|
window.removeEventListener("resize", cb);
|
7167
7247
|
};
|
7168
7248
|
}, []);
|
7169
|
-
const [showLoader, setShowLoader] = (0,
|
7170
|
-
(0,
|
7249
|
+
const [showLoader, setShowLoader] = (0, import_react46.useState)(false);
|
7250
|
+
(0, import_react46.useEffect)(() => {
|
7171
7251
|
setTimeout(() => {
|
7172
7252
|
setShowLoader(true);
|
7173
7253
|
}, 500);
|
@@ -7245,7 +7325,7 @@ var Canvas = () => {
|
|
7245
7325
|
|
7246
7326
|
// lib/use-loaded-overrides.ts
|
7247
7327
|
init_react_import();
|
7248
|
-
var
|
7328
|
+
var import_react47 = require("react");
|
7249
7329
|
|
7250
7330
|
// lib/load-overrides.ts
|
7251
7331
|
init_react_import();
|
@@ -7284,7 +7364,7 @@ var useLoadedOverrides = ({
|
|
7284
7364
|
overrides,
|
7285
7365
|
plugins
|
7286
7366
|
}) => {
|
7287
|
-
return (0,
|
7367
|
+
return (0, import_react47.useMemo)(() => {
|
7288
7368
|
return loadOverrides({ overrides, plugins });
|
7289
7369
|
}, [plugins, overrides]);
|
7290
7370
|
};
|
@@ -7296,14 +7376,14 @@ var DefaultOverride = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime38
|
|
7296
7376
|
|
7297
7377
|
// lib/use-inject-css.ts
|
7298
7378
|
init_react_import();
|
7299
|
-
var
|
7379
|
+
var import_react48 = require("react");
|
7300
7380
|
var styles = ``;
|
7301
7381
|
var useInjectStyleSheet = (initialStyles, iframeEnabled) => {
|
7302
|
-
const [el, setEl] = (0,
|
7303
|
-
(0,
|
7382
|
+
const [el, setEl] = (0, import_react48.useState)();
|
7383
|
+
(0, import_react48.useEffect)(() => {
|
7304
7384
|
setEl(document.createElement("style"));
|
7305
7385
|
}, []);
|
7306
|
-
(0,
|
7386
|
+
(0, import_react48.useEffect)(() => {
|
7307
7387
|
var _a;
|
7308
7388
|
if (!el || typeof window === "undefined") {
|
7309
7389
|
return;
|
@@ -7323,10 +7403,10 @@ var useInjectGlobalCss = (iframeEnabled) => {
|
|
7323
7403
|
|
7324
7404
|
// lib/use-preview-mode-hotkeys.ts
|
7325
7405
|
init_react_import();
|
7326
|
-
var
|
7406
|
+
var import_react49 = require("react");
|
7327
7407
|
var import_react_hotkeys_hook2 = require("react-hotkeys-hook");
|
7328
7408
|
var usePreviewModeHotkeys = (dispatch, iframeEnabled) => {
|
7329
|
-
const toggleInteractive = (0,
|
7409
|
+
const toggleInteractive = (0, import_react49.useCallback)(() => {
|
7330
7410
|
dispatch({
|
7331
7411
|
type: "setUi",
|
7332
7412
|
ui: (ui) => ({
|
@@ -7378,7 +7458,7 @@ function Puck({
|
|
7378
7458
|
waitForStyles: true
|
7379
7459
|
}, _iframe);
|
7380
7460
|
useInjectGlobalCss(iframe.enabled);
|
7381
|
-
const [generatedAppState] = (0,
|
7461
|
+
const [generatedAppState] = (0, import_react50.useState)(() => {
|
7382
7462
|
var _a2, _b2, _c, _d, _e, _f, _g, _h, _i;
|
7383
7463
|
const initial = __spreadValues(__spreadValues({}, defaultAppState.ui), initialUi);
|
7384
7464
|
let clientUiState = {};
|
@@ -7450,14 +7530,14 @@ function Puck({
|
|
7450
7530
|
histories,
|
7451
7531
|
index: initialHistoryIndex
|
7452
7532
|
});
|
7453
|
-
const [reducer] = (0,
|
7533
|
+
const [reducer] = (0, import_react50.useState)(
|
7454
7534
|
() => createReducer({
|
7455
7535
|
config,
|
7456
7536
|
record: historyStore.record,
|
7457
7537
|
onAction
|
7458
7538
|
})
|
7459
7539
|
);
|
7460
|
-
const [appState, dispatch] = (0,
|
7540
|
+
const [appState, dispatch] = (0, import_react50.useReducer)(
|
7461
7541
|
reducer,
|
7462
7542
|
flushZones(initialAppState)
|
7463
7543
|
);
|
@@ -7468,14 +7548,14 @@ function Puck({
|
|
7468
7548
|
historyStore,
|
7469
7549
|
iframeEnabled: (_a = _iframe == null ? void 0 : _iframe.enabled) != null ? _a : true
|
7470
7550
|
});
|
7471
|
-
const [menuOpen, setMenuOpen] = (0,
|
7551
|
+
const [menuOpen, setMenuOpen] = (0, import_react50.useState)(false);
|
7472
7552
|
const { itemSelector, leftSideBarVisible, rightSideBarVisible } = ui;
|
7473
7553
|
const selectedItem = itemSelector ? getItem(itemSelector, data) : null;
|
7474
|
-
(0,
|
7554
|
+
(0, import_react50.useEffect)(() => {
|
7475
7555
|
if (onChange) onChange(data);
|
7476
7556
|
}, [data]);
|
7477
7557
|
const rootProps = data.root.props || data.root;
|
7478
|
-
const toggleSidebars = (0,
|
7558
|
+
const toggleSidebars = (0, import_react50.useCallback)(
|
7479
7559
|
(sidebar) => {
|
7480
7560
|
const widerViewport = window.matchMedia("(min-width: 638px)").matches;
|
7481
7561
|
const sideBarVisible = sidebar === "left" ? leftSideBarVisible : rightSideBarVisible;
|
@@ -7489,7 +7569,7 @@ function Puck({
|
|
7489
7569
|
},
|
7490
7570
|
[dispatch, leftSideBarVisible, rightSideBarVisible]
|
7491
7571
|
);
|
7492
|
-
(0,
|
7572
|
+
(0, import_react50.useEffect)(() => {
|
7493
7573
|
if (!window.matchMedia("(min-width: 638px)").matches) {
|
7494
7574
|
dispatch({
|
7495
7575
|
type: "setUi",
|
@@ -7512,7 +7592,7 @@ function Puck({
|
|
7512
7592
|
window.removeEventListener("resize", handleResize);
|
7513
7593
|
};
|
7514
7594
|
}, []);
|
7515
|
-
const defaultHeaderRender = (0,
|
7595
|
+
const defaultHeaderRender = (0, import_react50.useMemo)(() => {
|
7516
7596
|
if (renderHeader) {
|
7517
7597
|
console.warn(
|
7518
7598
|
"`renderHeader` is deprecated. Please use `overrides.header` and the `usePuck` hook instead"
|
@@ -7526,7 +7606,7 @@ function Puck({
|
|
7526
7606
|
}
|
7527
7607
|
return DefaultOverride;
|
7528
7608
|
}, [renderHeader]);
|
7529
|
-
const defaultHeaderActionsRender = (0,
|
7609
|
+
const defaultHeaderActionsRender = (0, import_react50.useMemo)(() => {
|
7530
7610
|
if (renderHeaderActions) {
|
7531
7611
|
console.warn(
|
7532
7612
|
"`renderHeaderActions` is deprecated. Please use `overrides.headerActions` and the `usePuck` hook instead."
|
@@ -7543,20 +7623,20 @@ function Puck({
|
|
7543
7623
|
overrides,
|
7544
7624
|
plugins
|
7545
7625
|
});
|
7546
|
-
const CustomPuck = (0,
|
7626
|
+
const CustomPuck = (0, import_react50.useMemo)(
|
7547
7627
|
() => loadedOverrides.puck || DefaultOverride,
|
7548
7628
|
[loadedOverrides]
|
7549
7629
|
);
|
7550
|
-
const CustomHeader = (0,
|
7630
|
+
const CustomHeader = (0, import_react50.useMemo)(
|
7551
7631
|
() => loadedOverrides.header || defaultHeaderRender,
|
7552
7632
|
[loadedOverrides]
|
7553
7633
|
);
|
7554
|
-
const CustomHeaderActions = (0,
|
7634
|
+
const CustomHeaderActions = (0, import_react50.useMemo)(
|
7555
7635
|
() => loadedOverrides.headerActions || defaultHeaderActionsRender,
|
7556
7636
|
[loadedOverrides]
|
7557
7637
|
);
|
7558
|
-
const [mounted, setMounted] = (0,
|
7559
|
-
(0,
|
7638
|
+
const [mounted, setMounted] = (0, import_react50.useState)(false);
|
7639
|
+
(0, import_react50.useEffect)(() => {
|
7560
7640
|
setMounted(true);
|
7561
7641
|
}, []);
|
7562
7642
|
const selectedComponentConfig = selectedItem && config.components[selectedItem.type];
|