@measured/puck 0.18.0-canary.1ea6f98 → 0.18.0-canary.29e5580
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 +240 -147
- package/dist/index.mjs +232 -139
- 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,8 +3682,9 @@ 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
|
-
function
|
3687
|
+
function DropZoneEditInternal({
|
3668
3688
|
zone,
|
3669
3689
|
allow,
|
3670
3690
|
disallow,
|
@@ -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,
|
@@ -3819,13 +3840,13 @@ var DropZoneEdit = (0, import_react29.forwardRef)(
|
|
3819
3840
|
"data-puck-dnd": zoneCompound,
|
3820
3841
|
style: __spreadProps(__spreadValues({}, style), {
|
3821
3842
|
"--min-empty-height": `${minEmptyHeight}px`,
|
3822
|
-
backgroundColor: RENDER_DEBUG ? getRandomColor() : void 0
|
3843
|
+
backgroundColor: RENDER_DEBUG ? getRandomColor() : style == null ? void 0 : style.backgroundColor
|
3823
3844
|
}),
|
3824
3845
|
children: contentWithPreview.map((item, i) => {
|
3825
|
-
var _a, _b, _c, _d, _e;
|
3846
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
3826
3847
|
const componentId = item.props.id;
|
3827
3848
|
const puckProps = {
|
3828
|
-
renderDropZone:
|
3849
|
+
renderDropZone: DropZoneEditPure,
|
3829
3850
|
isEditing: true,
|
3830
3851
|
dragRef: null
|
3831
3852
|
};
|
@@ -3842,13 +3863,13 @@ var DropZoneEdit = (0, import_react29.forwardRef)(
|
|
3842
3863
|
const componentConfig = config.components[item.type];
|
3843
3864
|
let componentType = item.type;
|
3844
3865
|
let label = (_b = componentConfig == null ? void 0 : componentConfig["label"]) != null ? _b : item.type.toString();
|
3845
|
-
if (item.type === "preview"
|
3866
|
+
if (item.type === "preview") {
|
3846
3867
|
let Preview4 = function() {
|
3847
3868
|
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(DrawerItemInner, { name: label, children: appContext2.overrides.componentItem });
|
3848
3869
|
};
|
3849
3870
|
var Preview3 = Preview4;
|
3850
|
-
componentType = preview.componentType;
|
3851
|
-
label = (
|
3871
|
+
componentType = (_c = preview == null ? void 0 : preview.componentType) != null ? _c : "__preview";
|
3872
|
+
label = (_f = (_e = (_d = config.components[componentType]) == null ? void 0 : _d.label) != null ? _e : componentType) != null ? _f : "Preview";
|
3852
3873
|
Render2 = Preview4;
|
3853
3874
|
}
|
3854
3875
|
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
@@ -3863,7 +3884,7 @@ var DropZoneEdit = (0, import_react29.forwardRef)(
|
|
3863
3884
|
zoneCompound,
|
3864
3885
|
depth: depth + 1,
|
3865
3886
|
index: i,
|
3866
|
-
isLoading: ((
|
3887
|
+
isLoading: ((_g = appContext2.componentState[componentId]) == null ? void 0 : _g.loadingCount) > 0,
|
3867
3888
|
isSelected,
|
3868
3889
|
label,
|
3869
3890
|
isEnabled,
|
@@ -3888,8 +3909,9 @@ var DropZoneEdit = (0, import_react29.forwardRef)(
|
|
3888
3909
|
);
|
3889
3910
|
}
|
3890
3911
|
);
|
3912
|
+
var DropZoneRenderPure = (props) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(DropZoneRender, __spreadValues({}, props));
|
3891
3913
|
var DropZoneRender = (0, import_react29.forwardRef)(
|
3892
|
-
function
|
3914
|
+
function DropZoneRenderInternal({ className, style, zone }, ref) {
|
3893
3915
|
const ctx = (0, import_react29.useContext)(dropZoneContext);
|
3894
3916
|
const { data, areaId = "root", config } = ctx || {};
|
3895
3917
|
let zoneCompound = rootDroppableId;
|
@@ -3927,7 +3949,9 @@ var DropZoneRender = (0, import_react29.forwardRef)(
|
|
3927
3949
|
children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
3928
3950
|
Component.render,
|
3929
3951
|
__spreadProps(__spreadValues({}, item.props), {
|
3930
|
-
puck: {
|
3952
|
+
puck: {
|
3953
|
+
renderDropZone: DropZoneRenderPure
|
3954
|
+
}
|
3931
3955
|
})
|
3932
3956
|
)
|
3933
3957
|
},
|
@@ -4503,6 +4527,11 @@ var reduceUi = (ui, action) => {
|
|
4503
4527
|
itemSelector: { index: action.sourceIndex + 1, zone: action.sourceZone }
|
4504
4528
|
});
|
4505
4529
|
}
|
4530
|
+
if (action.type === "remove") {
|
4531
|
+
return __spreadProps(__spreadValues({}, ui), {
|
4532
|
+
itemSelector: null
|
4533
|
+
});
|
4534
|
+
}
|
4506
4535
|
return ui;
|
4507
4536
|
};
|
4508
4537
|
|
@@ -4753,6 +4782,9 @@ var _PointerSensor = class _PointerSensor extends import_abstract10.Sensor {
|
|
4753
4782
|
}
|
4754
4783
|
}
|
4755
4784
|
handlePointerUp(event) {
|
4785
|
+
if (!this.source) {
|
4786
|
+
return;
|
4787
|
+
}
|
4756
4788
|
event.preventDefault();
|
4757
4789
|
event.stopPropagation();
|
4758
4790
|
const { status } = this.manager.dragOperation;
|
@@ -5031,27 +5063,33 @@ var DragDropContextClient = ({
|
|
5031
5063
|
const [pathData, setPathData] = (0, import_react31.useState)();
|
5032
5064
|
const dragMode = (0, import_react31.useRef)(null);
|
5033
5065
|
const registerPath = (0, import_react31.useCallback)(
|
5034
|
-
(selector) => {
|
5035
|
-
const item = getItem(selector, data);
|
5036
|
-
if (!item) {
|
5037
|
-
return;
|
5038
|
-
}
|
5066
|
+
(id2, selector, label) => {
|
5039
5067
|
const [area] = getZoneId(selector.zone);
|
5040
5068
|
setPathData((latestPathData = {}) => {
|
5041
5069
|
const parentPathData = latestPathData[area] || { path: [] };
|
5042
5070
|
return __spreadProps(__spreadValues({}, latestPathData), {
|
5043
|
-
[
|
5071
|
+
[id2]: {
|
5044
5072
|
path: [
|
5045
5073
|
...parentPathData.path,
|
5046
5074
|
...selector.zone ? [selector.zone] : []
|
5047
5075
|
],
|
5048
|
-
label
|
5076
|
+
label
|
5049
5077
|
}
|
5050
5078
|
});
|
5051
5079
|
});
|
5052
5080
|
},
|
5053
5081
|
[data, setPathData]
|
5054
5082
|
);
|
5083
|
+
const unregisterPath = (0, import_react31.useCallback)(
|
5084
|
+
(id2) => {
|
5085
|
+
setPathData((latestPathData = {}) => {
|
5086
|
+
const newPathData = __spreadValues({}, latestPathData);
|
5087
|
+
delete newPathData[id2];
|
5088
|
+
return newPathData;
|
5089
|
+
});
|
5090
|
+
},
|
5091
|
+
[data, setPathData]
|
5092
|
+
);
|
5055
5093
|
const initialSelector = (0, import_react31.useRef)(void 0);
|
5056
5094
|
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { id, children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
5057
5095
|
dragListenerContext.Provider,
|
@@ -5248,6 +5286,7 @@ var DragDropContextClient = ({
|
|
5248
5286
|
areaId: "root",
|
5249
5287
|
depth: 0,
|
5250
5288
|
registerPath,
|
5289
|
+
unregisterPath,
|
5251
5290
|
pathData,
|
5252
5291
|
path: []
|
5253
5292
|
},
|
@@ -5374,7 +5413,7 @@ var Drawer = ({
|
|
5374
5413
|
"Warning: The `direction` prop on Drawer is deprecated and no longer required to achieve multi-directional dragging."
|
5375
5414
|
);
|
5376
5415
|
}
|
5377
|
-
const
|
5416
|
+
const id = (0, import_react32.useId)();
|
5378
5417
|
const { ref } = useDroppableSafe({
|
5379
5418
|
id,
|
5380
5419
|
type: "void",
|
@@ -5396,7 +5435,7 @@ Drawer.Item = DrawerItem;
|
|
5396
5435
|
|
5397
5436
|
// components/Puck/index.tsx
|
5398
5437
|
init_react_import();
|
5399
|
-
var
|
5438
|
+
var import_react50 = require("react");
|
5400
5439
|
|
5401
5440
|
// components/SidebarSection/index.tsx
|
5402
5441
|
init_react_import();
|
@@ -5589,36 +5628,61 @@ init_react_import();
|
|
5589
5628
|
|
5590
5629
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Fields/styles.module.css#css-module
|
5591
5630
|
init_react_import();
|
5592
|
-
var styles_module_default16 = { "PuckFields": "
|
5631
|
+
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" };
|
5593
5632
|
|
5594
5633
|
// components/Puck/components/Fields/index.tsx
|
5595
|
-
var
|
5634
|
+
var import_react37 = require("react");
|
5635
|
+
|
5636
|
+
// lib/use-resolved-fields.ts
|
5637
|
+
init_react_import();
|
5638
|
+
var import_react36 = require("react");
|
5596
5639
|
|
5597
5640
|
// lib/use-parent.ts
|
5598
5641
|
init_react_import();
|
5599
5642
|
var import_react34 = require("react");
|
5600
|
-
var
|
5643
|
+
var getParent = (itemSelector, pathData, data) => {
|
5601
5644
|
var _a;
|
5602
|
-
|
5603
|
-
const
|
5604
|
-
const
|
5605
|
-
const breadcrumbs = convertPathDataToBreadcrumbs(item, pathData, state.data);
|
5645
|
+
if (!itemSelector) return null;
|
5646
|
+
const item = getItem(itemSelector, data);
|
5647
|
+
const breadcrumbs = convertPathDataToBreadcrumbs(item, pathData, data);
|
5606
5648
|
const lastItem = breadcrumbs[breadcrumbs.length - 1];
|
5607
|
-
const parent = (lastItem == null ? void 0 : lastItem.selector) ? (_a = getItem(lastItem.selector,
|
5649
|
+
const parent = (lastItem == null ? void 0 : lastItem.selector) ? (_a = getItem(lastItem.selector, data)) != null ? _a : null : null;
|
5608
5650
|
return parent || null;
|
5609
5651
|
};
|
5652
|
+
var useGetParent = () => {
|
5653
|
+
const { state } = useAppContext();
|
5654
|
+
const { pathData } = (0, import_react34.useContext)(dropZoneContext) || {};
|
5655
|
+
return (0, import_react34.useCallback)(
|
5656
|
+
() => getParent(state.ui.itemSelector, pathData, state.data),
|
5657
|
+
[state.ui.itemSelector, pathData, state.data]
|
5658
|
+
);
|
5659
|
+
};
|
5660
|
+
var useParent = () => {
|
5661
|
+
return useGetParent()();
|
5662
|
+
};
|
5610
5663
|
|
5611
|
-
//
|
5612
|
-
|
5613
|
-
var
|
5664
|
+
// lib/use-on-value-change.ts
|
5665
|
+
init_react_import();
|
5666
|
+
var import_react35 = require("react");
|
5667
|
+
function useOnValueChange(value, onChange, compare = Object.is, deps = []) {
|
5668
|
+
const tracked = (0, import_react35.useRef)(value);
|
5669
|
+
(0, import_react35.useEffect)(() => {
|
5670
|
+
const oldValue = tracked.current;
|
5671
|
+
if (!compare(value, oldValue)) {
|
5672
|
+
tracked.current = value;
|
5673
|
+
onChange(value, oldValue);
|
5674
|
+
}
|
5675
|
+
}, [onChange, compare, value, ...deps]);
|
5676
|
+
}
|
5677
|
+
|
5678
|
+
// lib/selector-is.ts
|
5679
|
+
init_react_import();
|
5680
|
+
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);
|
5681
|
+
|
5682
|
+
// lib/use-resolved-fields.ts
|
5614
5683
|
var defaultPageFields = {
|
5615
5684
|
title: { type: "text" }
|
5616
5685
|
};
|
5617
|
-
var DefaultFields = ({
|
5618
|
-
children
|
5619
|
-
}) => {
|
5620
|
-
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_jsx_runtime27.Fragment, { children });
|
5621
|
-
};
|
5622
5686
|
var useResolvedFields = () => {
|
5623
5687
|
var _a, _b;
|
5624
5688
|
const { selectedItem, state, config } = useAppContext();
|
@@ -5626,20 +5690,21 @@ var useResolvedFields = () => {
|
|
5626
5690
|
const { data } = state;
|
5627
5691
|
const rootFields = ((_a = config.root) == null ? void 0 : _a.fields) || defaultPageFields;
|
5628
5692
|
const componentConfig = selectedItem ? config.components[selectedItem.type] : null;
|
5629
|
-
const defaultFields = (0,
|
5693
|
+
const defaultFields = (0, import_react36.useMemo)(
|
5630
5694
|
() => (selectedItem ? componentConfig == null ? void 0 : componentConfig.fields : rootFields) || {},
|
5631
5695
|
[selectedItem, rootFields, componentConfig == null ? void 0 : componentConfig.fields]
|
5632
5696
|
);
|
5633
5697
|
const rootProps = data.root.props || data.root;
|
5634
|
-
const [lastSelectedData, setLastSelectedData] = (0,
|
5635
|
-
const [resolvedFields, setResolvedFields] = (0,
|
5636
|
-
const [fieldsLoading, setFieldsLoading] = (0,
|
5698
|
+
const [lastSelectedData, setLastSelectedData] = (0, import_react36.useState)({});
|
5699
|
+
const [resolvedFields, setResolvedFields] = (0, import_react36.useState)(defaultFields);
|
5700
|
+
const [fieldsLoading, setFieldsLoading] = (0, import_react36.useState)(false);
|
5701
|
+
const lastFields = (0, import_react36.useRef)(defaultFields);
|
5637
5702
|
const defaultResolveFields = (_componentData, _params) => defaultFields;
|
5638
5703
|
const componentData = selectedItem ? selectedItem : { props: rootProps, readOnly: data.root.readOnly };
|
5639
5704
|
const hasComponentResolver = selectedItem && (componentConfig == null ? void 0 : componentConfig.resolveFields);
|
5640
5705
|
const hasRootResolver = !selectedItem && ((_b = config.root) == null ? void 0 : _b.resolveFields);
|
5641
5706
|
const hasResolver = hasComponentResolver || hasRootResolver;
|
5642
|
-
const resolveFields = (0,
|
5707
|
+
const resolveFields = (0, import_react36.useCallback)(
|
5643
5708
|
(..._0) => __async(void 0, [..._0], function* (fields = {}) {
|
5644
5709
|
var _a2;
|
5645
5710
|
const lastData = ((_a2 = lastSelectedData.props) == null ? void 0 : _a2.id) === componentData.props.id ? lastSelectedData : null;
|
@@ -5651,7 +5716,7 @@ var useResolvedFields = () => {
|
|
5651
5716
|
{
|
5652
5717
|
changed,
|
5653
5718
|
fields,
|
5654
|
-
lastFields:
|
5719
|
+
lastFields: lastFields.current,
|
5655
5720
|
lastData,
|
5656
5721
|
appState: state,
|
5657
5722
|
parent
|
@@ -5662,7 +5727,7 @@ var useResolvedFields = () => {
|
|
5662
5727
|
return yield config.root.resolveFields(componentData, {
|
5663
5728
|
changed,
|
5664
5729
|
fields,
|
5665
|
-
lastFields:
|
5730
|
+
lastFields: lastFields.current,
|
5666
5731
|
lastData,
|
5667
5732
|
appState: state,
|
5668
5733
|
parent
|
@@ -5671,26 +5736,56 @@ var useResolvedFields = () => {
|
|
5671
5736
|
return defaultResolveFields(componentData, {
|
5672
5737
|
changed,
|
5673
5738
|
fields,
|
5674
|
-
lastFields:
|
5739
|
+
lastFields: lastFields.current,
|
5675
5740
|
lastData
|
5676
5741
|
});
|
5677
5742
|
}),
|
5678
|
-
[data, config, componentData, selectedItem,
|
5743
|
+
[data, config, componentData, selectedItem, state, parent]
|
5679
5744
|
);
|
5680
|
-
(0,
|
5681
|
-
|
5682
|
-
|
5683
|
-
|
5684
|
-
|
5685
|
-
|
5686
|
-
|
5687
|
-
|
5688
|
-
|
5745
|
+
const triggerResolver = (0, import_react36.useCallback)(() => {
|
5746
|
+
var _a2, _b2;
|
5747
|
+
if (!((_a2 = state.ui.itemSelector) == null ? void 0 : _a2.zone) || ((_b2 = state.ui.itemSelector) == null ? void 0 : _b2.zone) === "default-zone" || parent) {
|
5748
|
+
if (hasResolver) {
|
5749
|
+
setFieldsLoading(true);
|
5750
|
+
resolveFields(defaultFields).then((fields) => {
|
5751
|
+
setResolvedFields(fields || {});
|
5752
|
+
lastFields.current = fields;
|
5753
|
+
setFieldsLoading(false);
|
5754
|
+
});
|
5755
|
+
return;
|
5756
|
+
}
|
5689
5757
|
}
|
5690
|
-
|
5758
|
+
setResolvedFields(defaultFields);
|
5759
|
+
}, [defaultFields, state.ui.itemSelector, hasResolver, parent]);
|
5760
|
+
useOnValueChange(
|
5761
|
+
state.ui.itemSelector,
|
5762
|
+
() => {
|
5763
|
+
lastFields.current = defaultFields;
|
5764
|
+
},
|
5765
|
+
selectorIs
|
5766
|
+
);
|
5767
|
+
useOnValueChange(
|
5768
|
+
{ data, parent, itemSelector: state.ui.itemSelector },
|
5769
|
+
() => {
|
5770
|
+
triggerResolver();
|
5771
|
+
},
|
5772
|
+
(a, b) => JSON.stringify(a) === JSON.stringify(b)
|
5773
|
+
);
|
5774
|
+
(0, import_react36.useEffect)(() => {
|
5775
|
+
triggerResolver();
|
5776
|
+
}, []);
|
5691
5777
|
return [resolvedFields, fieldsLoading];
|
5692
5778
|
};
|
5693
|
-
|
5779
|
+
|
5780
|
+
// components/Puck/components/Fields/index.tsx
|
5781
|
+
var import_jsx_runtime27 = require("react/jsx-runtime");
|
5782
|
+
var getClassName21 = get_class_name_factory_default("PuckFields", styles_module_default16);
|
5783
|
+
var DefaultFields = ({
|
5784
|
+
children
|
5785
|
+
}) => {
|
5786
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_jsx_runtime27.Fragment, { children });
|
5787
|
+
};
|
5788
|
+
var Fields = ({ wrapFields = true }) => {
|
5694
5789
|
var _a, _b;
|
5695
5790
|
const {
|
5696
5791
|
selectedItem,
|
@@ -5708,11 +5803,11 @@ var Fields = () => {
|
|
5708
5803
|
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;
|
5709
5804
|
const isLoading = fieldsResolving || componentResolving;
|
5710
5805
|
const rootProps = data.root.props || data.root;
|
5711
|
-
const Wrapper = (0,
|
5806
|
+
const Wrapper = (0, import_react37.useMemo)(() => overrides.fields || DefaultFields, [overrides]);
|
5712
5807
|
return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
|
5713
5808
|
"form",
|
5714
5809
|
{
|
5715
|
-
className: getClassName21(),
|
5810
|
+
className: getClassName21({ wrapFields }),
|
5716
5811
|
onSubmit: (e) => {
|
5717
5812
|
e.preventDefault();
|
5718
5813
|
},
|
@@ -5788,7 +5883,7 @@ var Fields = () => {
|
|
5788
5883
|
item: selectedItem
|
5789
5884
|
});
|
5790
5885
|
const id = `${selectedItem.props.id}_${field.type}_${fieldName}`;
|
5791
|
-
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
5886
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: getClassName21("field"), children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
5792
5887
|
AutoFieldPrivate,
|
5793
5888
|
{
|
5794
5889
|
field,
|
@@ -5797,16 +5892,15 @@ var Fields = () => {
|
|
5797
5892
|
readOnly: !edit || readOnly[fieldName],
|
5798
5893
|
value: selectedItem.props[fieldName],
|
5799
5894
|
onChange
|
5800
|
-
}
|
5801
|
-
|
5802
|
-
);
|
5895
|
+
}
|
5896
|
+
) }, id);
|
5803
5897
|
} else {
|
5804
5898
|
const readOnly = data.root.readOnly || {};
|
5805
5899
|
const { edit } = getPermissions({
|
5806
5900
|
root: true
|
5807
5901
|
});
|
5808
5902
|
const id = `root_${field.type}_${fieldName}`;
|
5809
|
-
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
5903
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: getClassName21("field"), children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
5810
5904
|
AutoFieldPrivate,
|
5811
5905
|
{
|
5812
5906
|
field,
|
@@ -5815,9 +5909,8 @@ var Fields = () => {
|
|
5815
5909
|
readOnly: !edit || readOnly[fieldName],
|
5816
5910
|
value: rootProps[fieldName],
|
5817
5911
|
onChange
|
5818
|
-
}
|
5819
|
-
|
5820
|
-
);
|
5912
|
+
}
|
5913
|
+
) }, id);
|
5821
5914
|
}
|
5822
5915
|
}) }),
|
5823
5916
|
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 }) }) })
|
@@ -5831,7 +5924,7 @@ init_react_import();
|
|
5831
5924
|
|
5832
5925
|
// lib/use-component-list.tsx
|
5833
5926
|
init_react_import();
|
5834
|
-
var
|
5927
|
+
var import_react38 = require("react");
|
5835
5928
|
|
5836
5929
|
// components/ComponentList/index.tsx
|
5837
5930
|
init_react_import();
|
@@ -5898,8 +5991,8 @@ ComponentList.Item = ComponentListItem;
|
|
5898
5991
|
// lib/use-component-list.tsx
|
5899
5992
|
var import_jsx_runtime29 = require("react/jsx-runtime");
|
5900
5993
|
var useComponentList = (config, ui) => {
|
5901
|
-
const [componentList, setComponentList] = (0,
|
5902
|
-
(0,
|
5994
|
+
const [componentList, setComponentList] = (0, import_react38.useState)();
|
5995
|
+
(0, import_react38.useEffect)(() => {
|
5903
5996
|
var _a, _b, _c;
|
5904
5997
|
if (Object.keys(ui.componentList).length > 0) {
|
5905
5998
|
const matchedComponents = [];
|
@@ -5968,22 +6061,22 @@ var useComponentList = (config, ui) => {
|
|
5968
6061
|
};
|
5969
6062
|
|
5970
6063
|
// components/Puck/components/Components/index.tsx
|
5971
|
-
var
|
6064
|
+
var import_react39 = require("react");
|
5972
6065
|
var import_jsx_runtime30 = require("react/jsx-runtime");
|
5973
6066
|
var Components = () => {
|
5974
6067
|
const { config, state, overrides } = useAppContext();
|
5975
6068
|
const componentList = useComponentList(config, state.ui);
|
5976
|
-
const Wrapper = (0,
|
6069
|
+
const Wrapper = (0, import_react39.useMemo)(() => overrides.components || "div", [overrides]);
|
5977
6070
|
return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Wrapper, { children: componentList ? componentList : /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(ComponentList, { id: "all" }) });
|
5978
6071
|
};
|
5979
6072
|
|
5980
6073
|
// components/Puck/components/Preview/index.tsx
|
5981
6074
|
init_react_import();
|
5982
|
-
var
|
6075
|
+
var import_react41 = require("react");
|
5983
6076
|
|
5984
6077
|
// components/AutoFrame/index.tsx
|
5985
6078
|
init_react_import();
|
5986
|
-
var
|
6079
|
+
var import_react40 = require("react");
|
5987
6080
|
var import_object_hash = __toESM(require("object-hash"));
|
5988
6081
|
var import_react_dom3 = require("react-dom");
|
5989
6082
|
var import_jsx_runtime31 = require("react/jsx-runtime");
|
@@ -6029,7 +6122,7 @@ var CopyHostStyles = ({
|
|
6029
6122
|
onStylesLoaded = () => null
|
6030
6123
|
}) => {
|
6031
6124
|
const { document: doc, window: win } = useFrame();
|
6032
|
-
(0,
|
6125
|
+
(0, import_react40.useEffect)(() => {
|
6033
6126
|
if (!win || !doc) {
|
6034
6127
|
return () => {
|
6035
6128
|
};
|
@@ -6188,8 +6281,8 @@ var CopyHostStyles = ({
|
|
6188
6281
|
}, []);
|
6189
6282
|
return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_jsx_runtime31.Fragment, { children });
|
6190
6283
|
};
|
6191
|
-
var autoFrameContext = (0,
|
6192
|
-
var useFrame = () => (0,
|
6284
|
+
var autoFrameContext = (0, import_react40.createContext)({});
|
6285
|
+
var useFrame = () => (0, import_react40.useContext)(autoFrameContext);
|
6193
6286
|
function AutoFrame(_a) {
|
6194
6287
|
var _b = _a, {
|
6195
6288
|
children,
|
@@ -6206,10 +6299,10 @@ function AutoFrame(_a) {
|
|
6206
6299
|
"onStylesLoaded",
|
6207
6300
|
"frameRef"
|
6208
6301
|
]);
|
6209
|
-
const [loaded, setLoaded] = (0,
|
6210
|
-
const [ctx, setCtx] = (0,
|
6211
|
-
const [mountTarget, setMountTarget] = (0,
|
6212
|
-
(0,
|
6302
|
+
const [loaded, setLoaded] = (0, import_react40.useState)(false);
|
6303
|
+
const [ctx, setCtx] = (0, import_react40.useState)({});
|
6304
|
+
const [mountTarget, setMountTarget] = (0, import_react40.useState)();
|
6305
|
+
(0, import_react40.useEffect)(() => {
|
6213
6306
|
var _a2;
|
6214
6307
|
if (frameRef.current) {
|
6215
6308
|
setCtx({
|
@@ -6303,7 +6396,7 @@ var import_jsx_runtime33 = require("react/jsx-runtime");
|
|
6303
6396
|
var getClassName23 = get_class_name_factory_default("PuckPreview", styles_module_default18);
|
6304
6397
|
var useBubbleIframeEvents = (ref) => {
|
6305
6398
|
const { status } = useAppContext();
|
6306
|
-
(0,
|
6399
|
+
(0, import_react41.useEffect)(() => {
|
6307
6400
|
var _a;
|
6308
6401
|
if (ref.current && status === "READY") {
|
6309
6402
|
const iframe = ref.current;
|
@@ -6342,7 +6435,7 @@ var useBubbleIframeEvents = (ref) => {
|
|
6342
6435
|
};
|
6343
6436
|
var Preview2 = ({ id = "puck-preview" }) => {
|
6344
6437
|
const { config, dispatch, state, setStatus, iframe, overrides } = useAppContext();
|
6345
|
-
const Page = (0,
|
6438
|
+
const Page = (0, import_react41.useCallback)(
|
6346
6439
|
(pageProps) => {
|
6347
6440
|
var _a, _b;
|
6348
6441
|
return ((_a = config.root) == null ? void 0 : _a.render) ? (_b = config.root) == null ? void 0 : _b.render(__spreadValues({
|
@@ -6351,9 +6444,9 @@ var Preview2 = ({ id = "puck-preview" }) => {
|
|
6351
6444
|
},
|
6352
6445
|
[config.root]
|
6353
6446
|
);
|
6354
|
-
const Frame = (0,
|
6447
|
+
const Frame = (0, import_react41.useMemo)(() => overrides.iframe, [overrides]);
|
6355
6448
|
const rootProps = state.data.root.props || state.data.root;
|
6356
|
-
const ref = (0,
|
6449
|
+
const ref = (0, import_react41.useRef)(null);
|
6357
6450
|
useBubbleIframeEvents(ref);
|
6358
6451
|
const inner = state.ui.previewMode === "edit" ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
6359
6452
|
Page,
|
@@ -6450,7 +6543,7 @@ var scrollIntoView = (el) => {
|
|
6450
6543
|
};
|
6451
6544
|
|
6452
6545
|
// components/LayerTree/index.tsx
|
6453
|
-
var
|
6546
|
+
var import_react42 = require("react");
|
6454
6547
|
|
6455
6548
|
// lib/is-child-of-zone.ts
|
6456
6549
|
init_react_import();
|
@@ -6496,7 +6589,7 @@ var LayerTree = ({
|
|
6496
6589
|
label
|
6497
6590
|
}) => {
|
6498
6591
|
const zones = data.zones || {};
|
6499
|
-
const ctx = (0,
|
6592
|
+
const ctx = (0, import_react42.useContext)(dropZoneContext);
|
6500
6593
|
return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(import_jsx_runtime34.Fragment, { children: [
|
6501
6594
|
label && /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("div", { className: getClassName24("zoneTitle"), children: [
|
6502
6595
|
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: getClassName24("zoneIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Layers, { size: "16" }) }),
|
@@ -6603,13 +6696,13 @@ var LayerTree = ({
|
|
6603
6696
|
};
|
6604
6697
|
|
6605
6698
|
// components/Puck/components/Outline/index.tsx
|
6606
|
-
var
|
6699
|
+
var import_react43 = require("react");
|
6607
6700
|
var import_jsx_runtime35 = require("react/jsx-runtime");
|
6608
6701
|
var Outline = () => {
|
6609
6702
|
const { dispatch, state, overrides, config } = useAppContext();
|
6610
6703
|
const { data, ui } = state;
|
6611
6704
|
const { itemSelector } = ui;
|
6612
|
-
const setItemSelector = (0,
|
6705
|
+
const setItemSelector = (0, import_react43.useCallback)(
|
6613
6706
|
(newItemSelector) => {
|
6614
6707
|
dispatch({
|
6615
6708
|
type: "setUi",
|
@@ -6618,7 +6711,7 @@ var Outline = () => {
|
|
6618
6711
|
},
|
6619
6712
|
[]
|
6620
6713
|
);
|
6621
|
-
const Wrapper = (0,
|
6714
|
+
const Wrapper = (0, import_react43.useMemo)(() => overrides.outline || "div", [overrides]);
|
6622
6715
|
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: [
|
6623
6716
|
(ctx == null ? void 0 : ctx.activeZones) && (ctx == null ? void 0 : ctx.activeZones[rootDroppableId]) && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
6624
6717
|
LayerTree,
|
@@ -6732,19 +6825,19 @@ function usePuckHistory({
|
|
6732
6825
|
|
6733
6826
|
// lib/use-history-store.ts
|
6734
6827
|
init_react_import();
|
6735
|
-
var
|
6828
|
+
var import_react44 = require("react");
|
6736
6829
|
var import_use_debounce3 = require("use-debounce");
|
6737
6830
|
var EMPTY_HISTORY_INDEX = 0;
|
6738
6831
|
function useHistoryStore(initialHistory) {
|
6739
6832
|
var _a, _b;
|
6740
|
-
const [histories, setHistories] = (0,
|
6833
|
+
const [histories, setHistories] = (0, import_react44.useState)(
|
6741
6834
|
(_a = initialHistory == null ? void 0 : initialHistory.histories) != null ? _a : []
|
6742
6835
|
);
|
6743
6836
|
const updateHistories = (histories2) => {
|
6744
6837
|
setHistories(histories2);
|
6745
6838
|
setIndex(histories2.length - 1);
|
6746
6839
|
};
|
6747
|
-
const [index, setIndex] = (0,
|
6840
|
+
const [index, setIndex] = (0, import_react44.useState)(
|
6748
6841
|
(_b = initialHistory == null ? void 0 : initialHistory.index) != null ? _b : EMPTY_HISTORY_INDEX
|
6749
6842
|
);
|
6750
6843
|
const hasPast = index > EMPTY_HISTORY_INDEX;
|
@@ -6904,11 +6997,11 @@ var getBox = function getBox2(el) {
|
|
6904
6997
|
};
|
6905
6998
|
|
6906
6999
|
// components/Puck/components/Canvas/index.tsx
|
6907
|
-
var
|
7000
|
+
var import_react46 = require("react");
|
6908
7001
|
|
6909
7002
|
// components/ViewportControls/index.tsx
|
6910
7003
|
init_react_import();
|
6911
|
-
var
|
7004
|
+
var import_react45 = require("react");
|
6912
7005
|
|
6913
7006
|
// css-module:/home/runner/work/puck/puck/packages/core/components/ViewportControls/styles.module.css#css-module
|
6914
7007
|
init_react_import();
|
@@ -6931,8 +7024,8 @@ var ViewportButton = ({
|
|
6931
7024
|
onClick
|
6932
7025
|
}) => {
|
6933
7026
|
const { state } = useAppContext();
|
6934
|
-
const [isActive, setIsActive] = (0,
|
6935
|
-
(0,
|
7027
|
+
const [isActive, setIsActive] = (0, import_react45.useState)(false);
|
7028
|
+
(0, import_react45.useEffect)(() => {
|
6936
7029
|
setIsActive(width === state.ui.viewports.current.width);
|
6937
7030
|
}, [width, state.ui.viewports.current.width]);
|
6938
7031
|
return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("span", { className: getClassNameButton({ isActive }), children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
@@ -6968,7 +7061,7 @@ var ViewportControls = ({
|
|
6968
7061
|
const defaultsContainAutoZoom = defaultZoomOptions.find(
|
6969
7062
|
(option) => option.value === autoZoom
|
6970
7063
|
);
|
6971
|
-
const zoomOptions = (0,
|
7064
|
+
const zoomOptions = (0, import_react45.useMemo)(
|
6972
7065
|
() => [
|
6973
7066
|
...defaultZoomOptions,
|
6974
7067
|
...defaultsContainAutoZoom ? [] : [
|
@@ -7091,17 +7184,17 @@ var Canvas = () => {
|
|
7091
7184
|
const { status, iframe } = useAppContext();
|
7092
7185
|
const { dispatch, state, overrides, setUi, zoomConfig, setZoomConfig } = useAppContext();
|
7093
7186
|
const { ui } = state;
|
7094
|
-
const frameRef = (0,
|
7095
|
-
const [showTransition, setShowTransition] = (0,
|
7096
|
-
const defaultRender = (0,
|
7187
|
+
const frameRef = (0, import_react46.useRef)(null);
|
7188
|
+
const [showTransition, setShowTransition] = (0, import_react46.useState)(false);
|
7189
|
+
const defaultRender = (0, import_react46.useMemo)(() => {
|
7097
7190
|
const PuckDefault = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(import_jsx_runtime37.Fragment, { children });
|
7098
7191
|
return PuckDefault;
|
7099
7192
|
}, []);
|
7100
|
-
const CustomPreview = (0,
|
7193
|
+
const CustomPreview = (0, import_react46.useMemo)(
|
7101
7194
|
() => overrides.preview || defaultRender,
|
7102
7195
|
[overrides]
|
7103
7196
|
);
|
7104
|
-
const getFrameDimensions = (0,
|
7197
|
+
const getFrameDimensions = (0, import_react46.useCallback)(() => {
|
7105
7198
|
if (frameRef.current) {
|
7106
7199
|
const frame = frameRef.current;
|
7107
7200
|
const box = getBox(frame);
|
@@ -7109,7 +7202,7 @@ var Canvas = () => {
|
|
7109
7202
|
}
|
7110
7203
|
return { width: 0, height: 0 };
|
7111
7204
|
}, [frameRef]);
|
7112
|
-
const resetAutoZoom = (0,
|
7205
|
+
const resetAutoZoom = (0, import_react46.useCallback)(
|
7113
7206
|
(ui2 = state.ui) => {
|
7114
7207
|
if (frameRef.current) {
|
7115
7208
|
setZoomConfig(
|
@@ -7119,11 +7212,11 @@ var Canvas = () => {
|
|
7119
7212
|
},
|
7120
7213
|
[frameRef, zoomConfig, state.ui]
|
7121
7214
|
);
|
7122
|
-
(0,
|
7215
|
+
(0, import_react46.useEffect)(() => {
|
7123
7216
|
setShowTransition(false);
|
7124
7217
|
resetAutoZoom();
|
7125
7218
|
}, [frameRef, ui.leftSideBarVisible, ui.rightSideBarVisible]);
|
7126
|
-
(0,
|
7219
|
+
(0, import_react46.useEffect)(() => {
|
7127
7220
|
const { height: frameHeight } = getFrameDimensions();
|
7128
7221
|
if (ui.viewports.current.height === "auto") {
|
7129
7222
|
setZoomConfig(__spreadProps(__spreadValues({}, zoomConfig), {
|
@@ -7131,13 +7224,13 @@ var Canvas = () => {
|
|
7131
7224
|
}));
|
7132
7225
|
}
|
7133
7226
|
}, [zoomConfig.zoom]);
|
7134
|
-
(0,
|
7227
|
+
(0, import_react46.useEffect)(() => {
|
7135
7228
|
if (ZOOM_ON_CHANGE) {
|
7136
7229
|
setShowTransition(true);
|
7137
7230
|
resetAutoZoom(ui);
|
7138
7231
|
}
|
7139
7232
|
}, [ui.viewports.current.width]);
|
7140
|
-
(0,
|
7233
|
+
(0, import_react46.useEffect)(() => {
|
7141
7234
|
const cb = () => {
|
7142
7235
|
setShowTransition(false);
|
7143
7236
|
resetAutoZoom();
|
@@ -7147,8 +7240,8 @@ var Canvas = () => {
|
|
7147
7240
|
window.removeEventListener("resize", cb);
|
7148
7241
|
};
|
7149
7242
|
}, []);
|
7150
|
-
const [showLoader, setShowLoader] = (0,
|
7151
|
-
(0,
|
7243
|
+
const [showLoader, setShowLoader] = (0, import_react46.useState)(false);
|
7244
|
+
(0, import_react46.useEffect)(() => {
|
7152
7245
|
setTimeout(() => {
|
7153
7246
|
setShowLoader(true);
|
7154
7247
|
}, 500);
|
@@ -7226,7 +7319,7 @@ var Canvas = () => {
|
|
7226
7319
|
|
7227
7320
|
// lib/use-loaded-overrides.ts
|
7228
7321
|
init_react_import();
|
7229
|
-
var
|
7322
|
+
var import_react47 = require("react");
|
7230
7323
|
|
7231
7324
|
// lib/load-overrides.ts
|
7232
7325
|
init_react_import();
|
@@ -7265,7 +7358,7 @@ var useLoadedOverrides = ({
|
|
7265
7358
|
overrides,
|
7266
7359
|
plugins
|
7267
7360
|
}) => {
|
7268
|
-
return (0,
|
7361
|
+
return (0, import_react47.useMemo)(() => {
|
7269
7362
|
return loadOverrides({ overrides, plugins });
|
7270
7363
|
}, [plugins, overrides]);
|
7271
7364
|
};
|
@@ -7277,14 +7370,14 @@ var DefaultOverride = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime38
|
|
7277
7370
|
|
7278
7371
|
// lib/use-inject-css.ts
|
7279
7372
|
init_react_import();
|
7280
|
-
var
|
7373
|
+
var import_react48 = require("react");
|
7281
7374
|
var styles = ``;
|
7282
7375
|
var useInjectStyleSheet = (initialStyles, iframeEnabled) => {
|
7283
|
-
const [el, setEl] = (0,
|
7284
|
-
(0,
|
7376
|
+
const [el, setEl] = (0, import_react48.useState)();
|
7377
|
+
(0, import_react48.useEffect)(() => {
|
7285
7378
|
setEl(document.createElement("style"));
|
7286
7379
|
}, []);
|
7287
|
-
(0,
|
7380
|
+
(0, import_react48.useEffect)(() => {
|
7288
7381
|
var _a;
|
7289
7382
|
if (!el || typeof window === "undefined") {
|
7290
7383
|
return;
|
@@ -7304,10 +7397,10 @@ var useInjectGlobalCss = (iframeEnabled) => {
|
|
7304
7397
|
|
7305
7398
|
// lib/use-preview-mode-hotkeys.ts
|
7306
7399
|
init_react_import();
|
7307
|
-
var
|
7400
|
+
var import_react49 = require("react");
|
7308
7401
|
var import_react_hotkeys_hook2 = require("react-hotkeys-hook");
|
7309
7402
|
var usePreviewModeHotkeys = (dispatch, iframeEnabled) => {
|
7310
|
-
const toggleInteractive = (0,
|
7403
|
+
const toggleInteractive = (0, import_react49.useCallback)(() => {
|
7311
7404
|
dispatch({
|
7312
7405
|
type: "setUi",
|
7313
7406
|
ui: (ui) => ({
|
@@ -7359,7 +7452,7 @@ function Puck({
|
|
7359
7452
|
waitForStyles: true
|
7360
7453
|
}, _iframe);
|
7361
7454
|
useInjectGlobalCss(iframe.enabled);
|
7362
|
-
const [generatedAppState] = (0,
|
7455
|
+
const [generatedAppState] = (0, import_react50.useState)(() => {
|
7363
7456
|
var _a2, _b2, _c, _d, _e, _f, _g, _h, _i;
|
7364
7457
|
const initial = __spreadValues(__spreadValues({}, defaultAppState.ui), initialUi);
|
7365
7458
|
let clientUiState = {};
|
@@ -7431,14 +7524,14 @@ function Puck({
|
|
7431
7524
|
histories,
|
7432
7525
|
index: initialHistoryIndex
|
7433
7526
|
});
|
7434
|
-
const [reducer] = (0,
|
7527
|
+
const [reducer] = (0, import_react50.useState)(
|
7435
7528
|
() => createReducer({
|
7436
7529
|
config,
|
7437
7530
|
record: historyStore.record,
|
7438
7531
|
onAction
|
7439
7532
|
})
|
7440
7533
|
);
|
7441
|
-
const [appState, dispatch] = (0,
|
7534
|
+
const [appState, dispatch] = (0, import_react50.useReducer)(
|
7442
7535
|
reducer,
|
7443
7536
|
flushZones(initialAppState)
|
7444
7537
|
);
|
@@ -7449,14 +7542,14 @@ function Puck({
|
|
7449
7542
|
historyStore,
|
7450
7543
|
iframeEnabled: (_a = _iframe == null ? void 0 : _iframe.enabled) != null ? _a : true
|
7451
7544
|
});
|
7452
|
-
const [menuOpen, setMenuOpen] = (0,
|
7545
|
+
const [menuOpen, setMenuOpen] = (0, import_react50.useState)(false);
|
7453
7546
|
const { itemSelector, leftSideBarVisible, rightSideBarVisible } = ui;
|
7454
7547
|
const selectedItem = itemSelector ? getItem(itemSelector, data) : null;
|
7455
|
-
(0,
|
7548
|
+
(0, import_react50.useEffect)(() => {
|
7456
7549
|
if (onChange) onChange(data);
|
7457
7550
|
}, [data]);
|
7458
7551
|
const rootProps = data.root.props || data.root;
|
7459
|
-
const toggleSidebars = (0,
|
7552
|
+
const toggleSidebars = (0, import_react50.useCallback)(
|
7460
7553
|
(sidebar) => {
|
7461
7554
|
const widerViewport = window.matchMedia("(min-width: 638px)").matches;
|
7462
7555
|
const sideBarVisible = sidebar === "left" ? leftSideBarVisible : rightSideBarVisible;
|
@@ -7470,7 +7563,7 @@ function Puck({
|
|
7470
7563
|
},
|
7471
7564
|
[dispatch, leftSideBarVisible, rightSideBarVisible]
|
7472
7565
|
);
|
7473
|
-
(0,
|
7566
|
+
(0, import_react50.useEffect)(() => {
|
7474
7567
|
if (!window.matchMedia("(min-width: 638px)").matches) {
|
7475
7568
|
dispatch({
|
7476
7569
|
type: "setUi",
|
@@ -7493,7 +7586,7 @@ function Puck({
|
|
7493
7586
|
window.removeEventListener("resize", handleResize);
|
7494
7587
|
};
|
7495
7588
|
}, []);
|
7496
|
-
const defaultHeaderRender = (0,
|
7589
|
+
const defaultHeaderRender = (0, import_react50.useMemo)(() => {
|
7497
7590
|
if (renderHeader) {
|
7498
7591
|
console.warn(
|
7499
7592
|
"`renderHeader` is deprecated. Please use `overrides.header` and the `usePuck` hook instead"
|
@@ -7507,7 +7600,7 @@ function Puck({
|
|
7507
7600
|
}
|
7508
7601
|
return DefaultOverride;
|
7509
7602
|
}, [renderHeader]);
|
7510
|
-
const defaultHeaderActionsRender = (0,
|
7603
|
+
const defaultHeaderActionsRender = (0, import_react50.useMemo)(() => {
|
7511
7604
|
if (renderHeaderActions) {
|
7512
7605
|
console.warn(
|
7513
7606
|
"`renderHeaderActions` is deprecated. Please use `overrides.headerActions` and the `usePuck` hook instead."
|
@@ -7524,20 +7617,20 @@ function Puck({
|
|
7524
7617
|
overrides,
|
7525
7618
|
plugins
|
7526
7619
|
});
|
7527
|
-
const CustomPuck = (0,
|
7620
|
+
const CustomPuck = (0, import_react50.useMemo)(
|
7528
7621
|
() => loadedOverrides.puck || DefaultOverride,
|
7529
7622
|
[loadedOverrides]
|
7530
7623
|
);
|
7531
|
-
const CustomHeader = (0,
|
7624
|
+
const CustomHeader = (0, import_react50.useMemo)(
|
7532
7625
|
() => loadedOverrides.header || defaultHeaderRender,
|
7533
7626
|
[loadedOverrides]
|
7534
7627
|
);
|
7535
|
-
const CustomHeaderActions = (0,
|
7628
|
+
const CustomHeaderActions = (0, import_react50.useMemo)(
|
7536
7629
|
() => loadedOverrides.headerActions || defaultHeaderActionsRender,
|
7537
7630
|
[loadedOverrides]
|
7538
7631
|
);
|
7539
|
-
const [mounted, setMounted] = (0,
|
7540
|
-
(0,
|
7632
|
+
const [mounted, setMounted] = (0, import_react50.useState)(false);
|
7633
|
+
(0, import_react50.useEffect)(() => {
|
7541
7634
|
setMounted(true);
|
7542
7635
|
}, []);
|
7543
7636
|
const selectedComponentConfig = selectedItem && config.components[selectedItem.type];
|