@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.mjs
CHANGED
@@ -205,7 +205,7 @@ init_react_import();
|
|
205
205
|
|
206
206
|
// css-module:/home/runner/work/puck/puck/packages/core/components/AutoField/styles.module.css#css-module
|
207
207
|
init_react_import();
|
208
|
-
var styles_module_default2 = { "InputWrapper": "
|
208
|
+
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" };
|
209
209
|
|
210
210
|
// components/AutoField/index.tsx
|
211
211
|
import {
|
@@ -1504,12 +1504,13 @@ var DefaultField = ({
|
|
1504
1504
|
field,
|
1505
1505
|
onChange,
|
1506
1506
|
readOnly,
|
1507
|
-
value,
|
1507
|
+
value: _value,
|
1508
1508
|
name,
|
1509
1509
|
label,
|
1510
1510
|
Label: Label2,
|
1511
1511
|
id
|
1512
1512
|
}) => {
|
1513
|
+
const value = _value;
|
1513
1514
|
return /* @__PURE__ */ jsx9(
|
1514
1515
|
Label2,
|
1515
1516
|
{
|
@@ -1527,7 +1528,7 @@ var DefaultField = ({
|
|
1527
1528
|
type: field.type,
|
1528
1529
|
title: label || name,
|
1529
1530
|
name,
|
1530
|
-
value:
|
1531
|
+
value: (value == null ? void 0 : value.toString) ? value.toString() : "",
|
1531
1532
|
onChange: (e) => {
|
1532
1533
|
if (field.type === "number") {
|
1533
1534
|
const numberValue = Number(e.currentTarget.value);
|
@@ -2425,7 +2426,7 @@ init_react_import();
|
|
2425
2426
|
var styles_module_default10 = { "Drawer": "_Drawer_fkqfo_1", "Drawer-draggable": "_Drawer-draggable_fkqfo_8", "Drawer-draggableBg": "_Drawer-draggableBg_fkqfo_12", "Drawer-draggableFg": "_Drawer-draggableFg_fkqfo_21", "DrawerItem-draggable": "_DrawerItem-draggable_fkqfo_25", "DrawerItem--disabled": "_DrawerItem--disabled_fkqfo_38", "DrawerItem": "_DrawerItem_fkqfo_25", "Drawer--isDraggingFrom": "_Drawer--isDraggingFrom_fkqfo_48", "DrawerItem-name": "_DrawerItem-name_fkqfo_66" };
|
2426
2427
|
|
2427
2428
|
// components/Drawer/index.tsx
|
2428
|
-
import { useMemo as useMemo9, useState as useState18 } from "react";
|
2429
|
+
import { useId as useId2, useMemo as useMemo9, useState as useState18 } from "react";
|
2429
2430
|
|
2430
2431
|
// components/DragDropContext/index.tsx
|
2431
2432
|
init_react_import();
|
@@ -2436,7 +2437,7 @@ import {
|
|
2436
2437
|
useContext as useContext7,
|
2437
2438
|
useEffect as useEffect15,
|
2438
2439
|
useId,
|
2439
|
-
useRef as
|
2440
|
+
useRef as useRef3,
|
2440
2441
|
useState as useState17
|
2441
2442
|
} from "react";
|
2442
2443
|
import { AutoScroller, defaultPreset } from "@dnd-kit/dom";
|
@@ -2449,7 +2450,7 @@ import {
|
|
2449
2450
|
useContext as useContext6,
|
2450
2451
|
useEffect as useEffect14,
|
2451
2452
|
useMemo as useMemo8,
|
2452
|
-
useRef as
|
2453
|
+
useRef as useRef2
|
2453
2454
|
} from "react";
|
2454
2455
|
|
2455
2456
|
// components/DraggableComponent/index.tsx
|
@@ -2459,7 +2460,7 @@ import {
|
|
2459
2460
|
useContext as useContext5,
|
2460
2461
|
useEffect as useEffect10,
|
2461
2462
|
useMemo as useMemo7,
|
2462
|
-
useRef
|
2463
|
+
useRef,
|
2463
2464
|
useState as useState13
|
2464
2465
|
} from "react";
|
2465
2466
|
|
@@ -3047,7 +3048,7 @@ var DraggableComponent = ({
|
|
3047
3048
|
}
|
3048
3049
|
});
|
3049
3050
|
const thisIsDragging = status === "dragging";
|
3050
|
-
const ref =
|
3051
|
+
const ref = useRef(null);
|
3051
3052
|
const refSetter = useCallback7(
|
3052
3053
|
(el) => {
|
3053
3054
|
sortableRef(el);
|
@@ -3098,13 +3099,19 @@ var DraggableComponent = ({
|
|
3098
3099
|
}
|
3099
3100
|
}, [ref.current]);
|
3100
3101
|
useEffect10(() => {
|
3101
|
-
|
3102
|
-
|
3102
|
+
ctx == null ? void 0 : ctx.registerPath(
|
3103
|
+
id,
|
3104
|
+
{
|
3103
3105
|
index,
|
3104
3106
|
zone: zoneCompound
|
3105
|
-
}
|
3106
|
-
|
3107
|
-
|
3107
|
+
},
|
3108
|
+
componentType
|
3109
|
+
);
|
3110
|
+
return () => {
|
3111
|
+
var _a;
|
3112
|
+
(_a = ctx == null ? void 0 : ctx.unregisterPath) == null ? void 0 : _a.call(ctx, id);
|
3113
|
+
};
|
3114
|
+
}, [id, zoneCompound, index, componentType]);
|
3108
3115
|
const CustomActionBar = useMemo7(
|
3109
3116
|
() => overrides.actionBar || DefaultActionBar,
|
3110
3117
|
[overrides.actionBar]
|
@@ -3424,9 +3431,20 @@ var useContentWithPreview = (content, zoneCompound) => {
|
|
3424
3431
|
};
|
3425
3432
|
}
|
3426
3433
|
);
|
3434
|
+
const {
|
3435
|
+
state: {
|
3436
|
+
ui: { isDragging }
|
3437
|
+
}
|
3438
|
+
} = useAppContext();
|
3427
3439
|
const [contentWithPreview, setContentWithPreview] = useState15(content);
|
3440
|
+
const [localPreview, setLocalPreview] = useState15(
|
3441
|
+
preview
|
3442
|
+
);
|
3428
3443
|
const updateContent = useRenderedCallback(
|
3429
|
-
(content2, preview2) => {
|
3444
|
+
(content2, preview2, isDragging2) => {
|
3445
|
+
if (isDragging2 && !previewExists) {
|
3446
|
+
return;
|
3447
|
+
}
|
3430
3448
|
if (preview2) {
|
3431
3449
|
if (preview2.type === "insert") {
|
3432
3450
|
setContentWithPreview(
|
@@ -3456,13 +3474,14 @@ var useContentWithPreview = (content, zoneCompound) => {
|
|
3456
3474
|
previewExists ? content2.filter((item) => item.props.id !== draggedItemId) : content2
|
3457
3475
|
);
|
3458
3476
|
}
|
3477
|
+
setLocalPreview(preview2);
|
3459
3478
|
},
|
3460
3479
|
[draggedItemId, previewExists]
|
3461
3480
|
);
|
3462
3481
|
useEffect12(() => {
|
3463
|
-
updateContent(content, preview);
|
3464
|
-
}, [content, preview]);
|
3465
|
-
return contentWithPreview;
|
3482
|
+
updateContent(content, preview, isDragging);
|
3483
|
+
}, [content, preview, isDragging]);
|
3484
|
+
return [contentWithPreview, localPreview];
|
3466
3485
|
};
|
3467
3486
|
|
3468
3487
|
// components/DropZone/lib/use-drag-axis.ts
|
@@ -3506,8 +3525,9 @@ import { Fragment as Fragment6, jsx as jsx22, jsxs as jsxs10 } from "react/jsx-r
|
|
3506
3525
|
var getClassName17 = get_class_name_factory_default("DropZone", styles_module_default12);
|
3507
3526
|
var getRandomColor = () => `#${Math.floor(Math.random() * 16777215).toString(16)}`;
|
3508
3527
|
var RENDER_DEBUG = false;
|
3528
|
+
var DropZoneEditPure = (props) => /* @__PURE__ */ jsx22(DropZoneEdit, __spreadValues({}, props));
|
3509
3529
|
var DropZoneEdit = forwardRef3(
|
3510
|
-
function
|
3530
|
+
function DropZoneEditInternal({
|
3511
3531
|
zone,
|
3512
3532
|
allow,
|
3513
3533
|
disallow,
|
@@ -3541,8 +3561,7 @@ var DropZoneEdit = forwardRef3(
|
|
3541
3561
|
isDeepestZone,
|
3542
3562
|
inNextDeepestArea,
|
3543
3563
|
draggedComponentType,
|
3544
|
-
userIsDragging
|
3545
|
-
preview
|
3564
|
+
userIsDragging
|
3546
3565
|
} = useContextStore(ZoneStoreContext, (s) => {
|
3547
3566
|
var _a, _b, _c;
|
3548
3567
|
return {
|
@@ -3550,8 +3569,7 @@ var DropZoneEdit = forwardRef3(
|
|
3550
3569
|
inNextDeepestArea: s.nextAreaDepthIndex[areaId || ""],
|
3551
3570
|
draggedItemId: (_b = s.draggedItem) == null ? void 0 : _b.id,
|
3552
3571
|
draggedComponentType: (_c = s.draggedItem) == null ? void 0 : _c.data.componentType,
|
3553
|
-
userIsDragging: !!s.draggedItem
|
3554
|
-
preview: s.previewIndex[zoneCompound]
|
3572
|
+
userIsDragging: !!s.draggedItem
|
3555
3573
|
};
|
3556
3574
|
});
|
3557
3575
|
const { itemSelector } = appContext2.state.ui;
|
@@ -3576,7 +3594,7 @@ var DropZoneEdit = forwardRef3(
|
|
3576
3594
|
}
|
3577
3595
|
return data.content || [];
|
3578
3596
|
}, [data, zoneCompound]);
|
3579
|
-
const ref =
|
3597
|
+
const ref = useRef2(null);
|
3580
3598
|
const acceptsTarget = useCallback10(
|
3581
3599
|
(componentType) => {
|
3582
3600
|
if (!componentType) {
|
@@ -3617,7 +3635,10 @@ var DropZoneEdit = forwardRef3(
|
|
3617
3635
|
if (isEnabled) {
|
3618
3636
|
isEnabled = acceptsTarget(draggedComponentType);
|
3619
3637
|
}
|
3620
|
-
const contentWithPreview = useContentWithPreview(
|
3638
|
+
const [contentWithPreview, preview] = useContentWithPreview(
|
3639
|
+
content,
|
3640
|
+
zoneCompound
|
3641
|
+
);
|
3621
3642
|
const isDropEnabled = isEnabled && (preview ? contentWithPreview.length === 1 : contentWithPreview.length === 0);
|
3622
3643
|
const droppableConfig = {
|
3623
3644
|
id: zoneCompound,
|
@@ -3662,13 +3683,13 @@ var DropZoneEdit = forwardRef3(
|
|
3662
3683
|
"data-puck-dnd": zoneCompound,
|
3663
3684
|
style: __spreadProps(__spreadValues({}, style), {
|
3664
3685
|
"--min-empty-height": `${minEmptyHeight}px`,
|
3665
|
-
backgroundColor: RENDER_DEBUG ? getRandomColor() : void 0
|
3686
|
+
backgroundColor: RENDER_DEBUG ? getRandomColor() : style == null ? void 0 : style.backgroundColor
|
3666
3687
|
}),
|
3667
3688
|
children: contentWithPreview.map((item, i) => {
|
3668
|
-
var _a, _b, _c, _d, _e;
|
3689
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
3669
3690
|
const componentId = item.props.id;
|
3670
3691
|
const puckProps = {
|
3671
|
-
renderDropZone:
|
3692
|
+
renderDropZone: DropZoneEditPure,
|
3672
3693
|
isEditing: true,
|
3673
3694
|
dragRef: null
|
3674
3695
|
};
|
@@ -3685,13 +3706,13 @@ var DropZoneEdit = forwardRef3(
|
|
3685
3706
|
const componentConfig = config.components[item.type];
|
3686
3707
|
let componentType = item.type;
|
3687
3708
|
let label = (_b = componentConfig == null ? void 0 : componentConfig["label"]) != null ? _b : item.type.toString();
|
3688
|
-
if (item.type === "preview"
|
3709
|
+
if (item.type === "preview") {
|
3689
3710
|
let Preview4 = function() {
|
3690
3711
|
return /* @__PURE__ */ jsx22(DrawerItemInner, { name: label, children: appContext2.overrides.componentItem });
|
3691
3712
|
};
|
3692
3713
|
var Preview3 = Preview4;
|
3693
|
-
componentType = preview.componentType;
|
3694
|
-
label = (
|
3714
|
+
componentType = (_c = preview == null ? void 0 : preview.componentType) != null ? _c : "__preview";
|
3715
|
+
label = (_f = (_e = (_d = config.components[componentType]) == null ? void 0 : _d.label) != null ? _e : componentType) != null ? _f : "Preview";
|
3695
3716
|
Render2 = Preview4;
|
3696
3717
|
}
|
3697
3718
|
return /* @__PURE__ */ jsx22(
|
@@ -3706,7 +3727,7 @@ var DropZoneEdit = forwardRef3(
|
|
3706
3727
|
zoneCompound,
|
3707
3728
|
depth: depth + 1,
|
3708
3729
|
index: i,
|
3709
|
-
isLoading: ((
|
3730
|
+
isLoading: ((_g = appContext2.componentState[componentId]) == null ? void 0 : _g.loadingCount) > 0,
|
3710
3731
|
isSelected,
|
3711
3732
|
label,
|
3712
3733
|
isEnabled,
|
@@ -3731,8 +3752,9 @@ var DropZoneEdit = forwardRef3(
|
|
3731
3752
|
);
|
3732
3753
|
}
|
3733
3754
|
);
|
3755
|
+
var DropZoneRenderPure = (props) => /* @__PURE__ */ jsx22(DropZoneRender, __spreadValues({}, props));
|
3734
3756
|
var DropZoneRender = forwardRef3(
|
3735
|
-
function
|
3757
|
+
function DropZoneRenderInternal({ className, style, zone }, ref) {
|
3736
3758
|
const ctx = useContext6(dropZoneContext);
|
3737
3759
|
const { data, areaId = "root", config } = ctx || {};
|
3738
3760
|
let zoneCompound = rootDroppableId;
|
@@ -3770,7 +3792,9 @@ var DropZoneRender = forwardRef3(
|
|
3770
3792
|
children: /* @__PURE__ */ jsx22(
|
3771
3793
|
Component.render,
|
3772
3794
|
__spreadProps(__spreadValues({}, item.props), {
|
3773
|
-
puck: {
|
3795
|
+
puck: {
|
3796
|
+
renderDropZone: DropZoneRenderPure
|
3797
|
+
}
|
3774
3798
|
})
|
3775
3799
|
)
|
3776
3800
|
},
|
@@ -4346,6 +4370,11 @@ var reduceUi = (ui, action) => {
|
|
4346
4370
|
itemSelector: { index: action.sourceIndex + 1, zone: action.sourceZone }
|
4347
4371
|
});
|
4348
4372
|
}
|
4373
|
+
if (action.type === "remove") {
|
4374
|
+
return __spreadProps(__spreadValues({}, ui), {
|
4375
|
+
itemSelector: null
|
4376
|
+
});
|
4377
|
+
}
|
4349
4378
|
return ui;
|
4350
4379
|
};
|
4351
4380
|
|
@@ -4605,6 +4634,9 @@ var _PointerSensor = class _PointerSensor extends Sensor {
|
|
4605
4634
|
}
|
4606
4635
|
}
|
4607
4636
|
handlePointerUp(event) {
|
4637
|
+
if (!this.source) {
|
4638
|
+
return;
|
4639
|
+
}
|
4608
4640
|
event.preventDefault();
|
4609
4641
|
event.stopPropagation();
|
4610
4642
|
const { status } = this.manager.dragOperation;
|
@@ -4722,7 +4754,7 @@ function useDragListener(type, fn, deps = []) {
|
|
4722
4754
|
}
|
4723
4755
|
var AREA_CHANGE_DEBOUNCE_MS = 100;
|
4724
4756
|
var useTempDisableFallback = (timeout3) => {
|
4725
|
-
const lastFallbackDisable =
|
4757
|
+
const lastFallbackDisable = useRef3(null);
|
4726
4758
|
return useCallback11((manager) => {
|
4727
4759
|
collisionStore.setState({ fallbackEnabled: false });
|
4728
4760
|
const fallbackId = generateId();
|
@@ -4742,7 +4774,7 @@ var DragDropContextClient = ({
|
|
4742
4774
|
const { state, config, dispatch, resolveData } = useAppContext();
|
4743
4775
|
const id = useId();
|
4744
4776
|
const { data } = state;
|
4745
|
-
const debouncedParamsRef =
|
4777
|
+
const debouncedParamsRef = useRef3(null);
|
4746
4778
|
const tempDisableFallback = useTempDisableFallback(100);
|
4747
4779
|
const [zoneStore] = useState17(
|
4748
4780
|
() => createStore3(() => ({
|
@@ -4881,30 +4913,36 @@ var DragDropContextClient = ({
|
|
4881
4913
|
]);
|
4882
4914
|
const [dragListeners, setDragListeners] = useState17({});
|
4883
4915
|
const [pathData, setPathData] = useState17();
|
4884
|
-
const dragMode =
|
4916
|
+
const dragMode = useRef3(null);
|
4885
4917
|
const registerPath = useCallback11(
|
4886
|
-
(selector) => {
|
4887
|
-
const item = getItem(selector, data);
|
4888
|
-
if (!item) {
|
4889
|
-
return;
|
4890
|
-
}
|
4918
|
+
(id2, selector, label) => {
|
4891
4919
|
const [area] = getZoneId(selector.zone);
|
4892
4920
|
setPathData((latestPathData = {}) => {
|
4893
4921
|
const parentPathData = latestPathData[area] || { path: [] };
|
4894
4922
|
return __spreadProps(__spreadValues({}, latestPathData), {
|
4895
|
-
[
|
4923
|
+
[id2]: {
|
4896
4924
|
path: [
|
4897
4925
|
...parentPathData.path,
|
4898
4926
|
...selector.zone ? [selector.zone] : []
|
4899
4927
|
],
|
4900
|
-
label
|
4928
|
+
label
|
4901
4929
|
}
|
4902
4930
|
});
|
4903
4931
|
});
|
4904
4932
|
},
|
4905
4933
|
[data, setPathData]
|
4906
4934
|
);
|
4907
|
-
const
|
4935
|
+
const unregisterPath = useCallback11(
|
4936
|
+
(id2) => {
|
4937
|
+
setPathData((latestPathData = {}) => {
|
4938
|
+
const newPathData = __spreadValues({}, latestPathData);
|
4939
|
+
delete newPathData[id2];
|
4940
|
+
return newPathData;
|
4941
|
+
});
|
4942
|
+
},
|
4943
|
+
[data, setPathData]
|
4944
|
+
);
|
4945
|
+
const initialSelector = useRef3(void 0);
|
4908
4946
|
return /* @__PURE__ */ jsx23("div", { id, children: /* @__PURE__ */ jsx23(
|
4909
4947
|
dragListenerContext.Provider,
|
4910
4948
|
{
|
@@ -5100,6 +5138,7 @@ var DragDropContextClient = ({
|
|
5100
5138
|
areaId: "root",
|
5101
5139
|
depth: 0,
|
5102
5140
|
registerPath,
|
5141
|
+
unregisterPath,
|
5103
5142
|
pathData,
|
5104
5143
|
path: []
|
5105
5144
|
},
|
@@ -5226,7 +5265,7 @@ var Drawer = ({
|
|
5226
5265
|
"Warning: The `direction` prop on Drawer is deprecated and no longer required to achieve multi-directional dragging."
|
5227
5266
|
);
|
5228
5267
|
}
|
5229
|
-
const
|
5268
|
+
const id = useId2();
|
5230
5269
|
const { ref } = useDroppableSafe({
|
5231
5270
|
id,
|
5232
5271
|
type: "void",
|
@@ -5249,9 +5288,9 @@ Drawer.Item = DrawerItem;
|
|
5249
5288
|
// components/Puck/index.tsx
|
5250
5289
|
init_react_import();
|
5251
5290
|
import {
|
5252
|
-
useCallback as
|
5253
|
-
useEffect as
|
5254
|
-
useMemo as
|
5291
|
+
useCallback as useCallback18,
|
5292
|
+
useEffect as useEffect24,
|
5293
|
+
useMemo as useMemo19,
|
5255
5294
|
useReducer,
|
5256
5295
|
useState as useState26
|
5257
5296
|
} from "react";
|
@@ -5447,36 +5486,61 @@ init_react_import();
|
|
5447
5486
|
|
5448
5487
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Fields/styles.module.css#css-module
|
5449
5488
|
init_react_import();
|
5450
|
-
var styles_module_default16 = { "PuckFields": "
|
5489
|
+
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" };
|
5451
5490
|
|
5452
5491
|
// components/Puck/components/Fields/index.tsx
|
5453
|
-
import {
|
5492
|
+
import { useMemo as useMemo12 } from "react";
|
5493
|
+
|
5494
|
+
// lib/use-resolved-fields.ts
|
5495
|
+
init_react_import();
|
5496
|
+
import { useCallback as useCallback13, useEffect as useEffect17, useMemo as useMemo11, useRef as useRef5, useState as useState19 } from "react";
|
5454
5497
|
|
5455
5498
|
// lib/use-parent.ts
|
5456
5499
|
init_react_import();
|
5457
|
-
import { useContext as useContext9 } from "react";
|
5458
|
-
var
|
5500
|
+
import { useCallback as useCallback12, useContext as useContext9 } from "react";
|
5501
|
+
var getParent = (itemSelector, pathData, data) => {
|
5459
5502
|
var _a;
|
5460
|
-
|
5461
|
-
const
|
5462
|
-
const
|
5463
|
-
const breadcrumbs = convertPathDataToBreadcrumbs(item, pathData, state.data);
|
5503
|
+
if (!itemSelector) return null;
|
5504
|
+
const item = getItem(itemSelector, data);
|
5505
|
+
const breadcrumbs = convertPathDataToBreadcrumbs(item, pathData, data);
|
5464
5506
|
const lastItem = breadcrumbs[breadcrumbs.length - 1];
|
5465
|
-
const parent = (lastItem == null ? void 0 : lastItem.selector) ? (_a = getItem(lastItem.selector,
|
5507
|
+
const parent = (lastItem == null ? void 0 : lastItem.selector) ? (_a = getItem(lastItem.selector, data)) != null ? _a : null : null;
|
5466
5508
|
return parent || null;
|
5467
5509
|
};
|
5510
|
+
var useGetParent = () => {
|
5511
|
+
const { state } = useAppContext();
|
5512
|
+
const { pathData } = useContext9(dropZoneContext) || {};
|
5513
|
+
return useCallback12(
|
5514
|
+
() => getParent(state.ui.itemSelector, pathData, state.data),
|
5515
|
+
[state.ui.itemSelector, pathData, state.data]
|
5516
|
+
);
|
5517
|
+
};
|
5518
|
+
var useParent = () => {
|
5519
|
+
return useGetParent()();
|
5520
|
+
};
|
5468
5521
|
|
5469
|
-
//
|
5470
|
-
|
5471
|
-
|
5522
|
+
// lib/use-on-value-change.ts
|
5523
|
+
init_react_import();
|
5524
|
+
import { useRef as useRef4, useEffect as useEffect16 } from "react";
|
5525
|
+
function useOnValueChange(value, onChange, compare = Object.is, deps = []) {
|
5526
|
+
const tracked = useRef4(value);
|
5527
|
+
useEffect16(() => {
|
5528
|
+
const oldValue = tracked.current;
|
5529
|
+
if (!compare(value, oldValue)) {
|
5530
|
+
tracked.current = value;
|
5531
|
+
onChange(value, oldValue);
|
5532
|
+
}
|
5533
|
+
}, [onChange, compare, value, ...deps]);
|
5534
|
+
}
|
5535
|
+
|
5536
|
+
// lib/selector-is.ts
|
5537
|
+
init_react_import();
|
5538
|
+
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);
|
5539
|
+
|
5540
|
+
// lib/use-resolved-fields.ts
|
5472
5541
|
var defaultPageFields = {
|
5473
5542
|
title: { type: "text" }
|
5474
5543
|
};
|
5475
|
-
var DefaultFields = ({
|
5476
|
-
children
|
5477
|
-
}) => {
|
5478
|
-
return /* @__PURE__ */ jsx27(Fragment8, { children });
|
5479
|
-
};
|
5480
5544
|
var useResolvedFields = () => {
|
5481
5545
|
var _a, _b;
|
5482
5546
|
const { selectedItem, state, config } = useAppContext();
|
@@ -5492,12 +5556,13 @@ var useResolvedFields = () => {
|
|
5492
5556
|
const [lastSelectedData, setLastSelectedData] = useState19({});
|
5493
5557
|
const [resolvedFields, setResolvedFields] = useState19(defaultFields);
|
5494
5558
|
const [fieldsLoading, setFieldsLoading] = useState19(false);
|
5559
|
+
const lastFields = useRef5(defaultFields);
|
5495
5560
|
const defaultResolveFields = (_componentData, _params) => defaultFields;
|
5496
5561
|
const componentData = selectedItem ? selectedItem : { props: rootProps, readOnly: data.root.readOnly };
|
5497
5562
|
const hasComponentResolver = selectedItem && (componentConfig == null ? void 0 : componentConfig.resolveFields);
|
5498
5563
|
const hasRootResolver = !selectedItem && ((_b = config.root) == null ? void 0 : _b.resolveFields);
|
5499
5564
|
const hasResolver = hasComponentResolver || hasRootResolver;
|
5500
|
-
const resolveFields =
|
5565
|
+
const resolveFields = useCallback13(
|
5501
5566
|
(..._0) => __async(void 0, [..._0], function* (fields = {}) {
|
5502
5567
|
var _a2;
|
5503
5568
|
const lastData = ((_a2 = lastSelectedData.props) == null ? void 0 : _a2.id) === componentData.props.id ? lastSelectedData : null;
|
@@ -5509,7 +5574,7 @@ var useResolvedFields = () => {
|
|
5509
5574
|
{
|
5510
5575
|
changed,
|
5511
5576
|
fields,
|
5512
|
-
lastFields:
|
5577
|
+
lastFields: lastFields.current,
|
5513
5578
|
lastData,
|
5514
5579
|
appState: state,
|
5515
5580
|
parent
|
@@ -5520,7 +5585,7 @@ var useResolvedFields = () => {
|
|
5520
5585
|
return yield config.root.resolveFields(componentData, {
|
5521
5586
|
changed,
|
5522
5587
|
fields,
|
5523
|
-
lastFields:
|
5588
|
+
lastFields: lastFields.current,
|
5524
5589
|
lastData,
|
5525
5590
|
appState: state,
|
5526
5591
|
parent
|
@@ -5529,26 +5594,56 @@ var useResolvedFields = () => {
|
|
5529
5594
|
return defaultResolveFields(componentData, {
|
5530
5595
|
changed,
|
5531
5596
|
fields,
|
5532
|
-
lastFields:
|
5597
|
+
lastFields: lastFields.current,
|
5533
5598
|
lastData
|
5534
5599
|
});
|
5535
5600
|
}),
|
5536
|
-
[data, config, componentData, selectedItem,
|
5601
|
+
[data, config, componentData, selectedItem, state, parent]
|
5537
5602
|
);
|
5538
|
-
|
5539
|
-
|
5540
|
-
|
5541
|
-
|
5542
|
-
|
5543
|
-
|
5544
|
-
|
5545
|
-
|
5546
|
-
|
5603
|
+
const triggerResolver = useCallback13(() => {
|
5604
|
+
var _a2, _b2;
|
5605
|
+
if (!((_a2 = state.ui.itemSelector) == null ? void 0 : _a2.zone) || ((_b2 = state.ui.itemSelector) == null ? void 0 : _b2.zone) === "default-zone" || parent) {
|
5606
|
+
if (hasResolver) {
|
5607
|
+
setFieldsLoading(true);
|
5608
|
+
resolveFields(defaultFields).then((fields) => {
|
5609
|
+
setResolvedFields(fields || {});
|
5610
|
+
lastFields.current = fields;
|
5611
|
+
setFieldsLoading(false);
|
5612
|
+
});
|
5613
|
+
return;
|
5614
|
+
}
|
5547
5615
|
}
|
5548
|
-
|
5616
|
+
setResolvedFields(defaultFields);
|
5617
|
+
}, [defaultFields, state.ui.itemSelector, hasResolver, parent]);
|
5618
|
+
useOnValueChange(
|
5619
|
+
state.ui.itemSelector,
|
5620
|
+
() => {
|
5621
|
+
lastFields.current = defaultFields;
|
5622
|
+
},
|
5623
|
+
selectorIs
|
5624
|
+
);
|
5625
|
+
useOnValueChange(
|
5626
|
+
{ data, parent, itemSelector: state.ui.itemSelector },
|
5627
|
+
() => {
|
5628
|
+
triggerResolver();
|
5629
|
+
},
|
5630
|
+
(a, b) => JSON.stringify(a) === JSON.stringify(b)
|
5631
|
+
);
|
5632
|
+
useEffect17(() => {
|
5633
|
+
triggerResolver();
|
5634
|
+
}, []);
|
5549
5635
|
return [resolvedFields, fieldsLoading];
|
5550
5636
|
};
|
5551
|
-
|
5637
|
+
|
5638
|
+
// components/Puck/components/Fields/index.tsx
|
5639
|
+
import { Fragment as Fragment8, jsx as jsx27, jsxs as jsxs14 } from "react/jsx-runtime";
|
5640
|
+
var getClassName21 = get_class_name_factory_default("PuckFields", styles_module_default16);
|
5641
|
+
var DefaultFields = ({
|
5642
|
+
children
|
5643
|
+
}) => {
|
5644
|
+
return /* @__PURE__ */ jsx27(Fragment8, { children });
|
5645
|
+
};
|
5646
|
+
var Fields = ({ wrapFields = true }) => {
|
5552
5647
|
var _a, _b;
|
5553
5648
|
const {
|
5554
5649
|
selectedItem,
|
@@ -5566,11 +5661,11 @@ var Fields = () => {
|
|
5566
5661
|
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;
|
5567
5662
|
const isLoading = fieldsResolving || componentResolving;
|
5568
5663
|
const rootProps = data.root.props || data.root;
|
5569
|
-
const Wrapper =
|
5664
|
+
const Wrapper = useMemo12(() => overrides.fields || DefaultFields, [overrides]);
|
5570
5665
|
return /* @__PURE__ */ jsxs14(
|
5571
5666
|
"form",
|
5572
5667
|
{
|
5573
|
-
className: getClassName21(),
|
5668
|
+
className: getClassName21({ wrapFields }),
|
5574
5669
|
onSubmit: (e) => {
|
5575
5670
|
e.preventDefault();
|
5576
5671
|
},
|
@@ -5646,7 +5741,7 @@ var Fields = () => {
|
|
5646
5741
|
item: selectedItem
|
5647
5742
|
});
|
5648
5743
|
const id = `${selectedItem.props.id}_${field.type}_${fieldName}`;
|
5649
|
-
return /* @__PURE__ */ jsx27(
|
5744
|
+
return /* @__PURE__ */ jsx27("div", { className: getClassName21("field"), children: /* @__PURE__ */ jsx27(
|
5650
5745
|
AutoFieldPrivate,
|
5651
5746
|
{
|
5652
5747
|
field,
|
@@ -5655,16 +5750,15 @@ var Fields = () => {
|
|
5655
5750
|
readOnly: !edit || readOnly[fieldName],
|
5656
5751
|
value: selectedItem.props[fieldName],
|
5657
5752
|
onChange
|
5658
|
-
}
|
5659
|
-
|
5660
|
-
);
|
5753
|
+
}
|
5754
|
+
) }, id);
|
5661
5755
|
} else {
|
5662
5756
|
const readOnly = data.root.readOnly || {};
|
5663
5757
|
const { edit } = getPermissions({
|
5664
5758
|
root: true
|
5665
5759
|
});
|
5666
5760
|
const id = `root_${field.type}_${fieldName}`;
|
5667
|
-
return /* @__PURE__ */ jsx27(
|
5761
|
+
return /* @__PURE__ */ jsx27("div", { className: getClassName21("field"), children: /* @__PURE__ */ jsx27(
|
5668
5762
|
AutoFieldPrivate,
|
5669
5763
|
{
|
5670
5764
|
field,
|
@@ -5673,9 +5767,8 @@ var Fields = () => {
|
|
5673
5767
|
readOnly: !edit || readOnly[fieldName],
|
5674
5768
|
value: rootProps[fieldName],
|
5675
5769
|
onChange
|
5676
|
-
}
|
5677
|
-
|
5678
|
-
);
|
5770
|
+
}
|
5771
|
+
) }, id);
|
5679
5772
|
}
|
5680
5773
|
}) }),
|
5681
5774
|
isLoading && /* @__PURE__ */ jsx27("div", { className: getClassName21("loadingOverlay"), children: /* @__PURE__ */ jsx27("div", { className: getClassName21("loadingOverlayInner"), children: /* @__PURE__ */ jsx27(Loader, { size: 16 }) }) })
|
@@ -5689,7 +5782,7 @@ init_react_import();
|
|
5689
5782
|
|
5690
5783
|
// lib/use-component-list.tsx
|
5691
5784
|
init_react_import();
|
5692
|
-
import { useEffect as
|
5785
|
+
import { useEffect as useEffect18, useState as useState20 } from "react";
|
5693
5786
|
|
5694
5787
|
// components/ComponentList/index.tsx
|
5695
5788
|
init_react_import();
|
@@ -5757,7 +5850,7 @@ ComponentList.Item = ComponentListItem;
|
|
5757
5850
|
import { jsx as jsx29 } from "react/jsx-runtime";
|
5758
5851
|
var useComponentList = (config, ui) => {
|
5759
5852
|
const [componentList, setComponentList] = useState20();
|
5760
|
-
|
5853
|
+
useEffect18(() => {
|
5761
5854
|
var _a, _b, _c;
|
5762
5855
|
if (Object.keys(ui.componentList).length > 0) {
|
5763
5856
|
const matchedComponents = [];
|
@@ -5826,25 +5919,25 @@ var useComponentList = (config, ui) => {
|
|
5826
5919
|
};
|
5827
5920
|
|
5828
5921
|
// components/Puck/components/Components/index.tsx
|
5829
|
-
import { useMemo as
|
5922
|
+
import { useMemo as useMemo13 } from "react";
|
5830
5923
|
import { jsx as jsx30 } from "react/jsx-runtime";
|
5831
5924
|
var Components = () => {
|
5832
5925
|
const { config, state, overrides } = useAppContext();
|
5833
5926
|
const componentList = useComponentList(config, state.ui);
|
5834
|
-
const Wrapper =
|
5927
|
+
const Wrapper = useMemo13(() => overrides.components || "div", [overrides]);
|
5835
5928
|
return /* @__PURE__ */ jsx30(Wrapper, { children: componentList ? componentList : /* @__PURE__ */ jsx30(ComponentList, { id: "all" }) });
|
5836
5929
|
};
|
5837
5930
|
|
5838
5931
|
// components/Puck/components/Preview/index.tsx
|
5839
5932
|
init_react_import();
|
5840
|
-
import { useCallback as
|
5933
|
+
import { useCallback as useCallback14, useEffect as useEffect20, useRef as useRef7, useMemo as useMemo14 } from "react";
|
5841
5934
|
|
5842
5935
|
// components/AutoFrame/index.tsx
|
5843
5936
|
init_react_import();
|
5844
5937
|
import {
|
5845
5938
|
createContext as createContext5,
|
5846
5939
|
useContext as useContext10,
|
5847
|
-
useEffect as
|
5940
|
+
useEffect as useEffect19,
|
5848
5941
|
useState as useState21
|
5849
5942
|
} from "react";
|
5850
5943
|
import hash from "object-hash";
|
@@ -5892,7 +5985,7 @@ var CopyHostStyles = ({
|
|
5892
5985
|
onStylesLoaded = () => null
|
5893
5986
|
}) => {
|
5894
5987
|
const { document: doc, window: win } = useFrame();
|
5895
|
-
|
5988
|
+
useEffect19(() => {
|
5896
5989
|
if (!win || !doc) {
|
5897
5990
|
return () => {
|
5898
5991
|
};
|
@@ -6072,7 +6165,7 @@ function AutoFrame(_a) {
|
|
6072
6165
|
const [loaded, setLoaded] = useState21(false);
|
6073
6166
|
const [ctx, setCtx] = useState21({});
|
6074
6167
|
const [mountTarget, setMountTarget] = useState21();
|
6075
|
-
|
6168
|
+
useEffect19(() => {
|
6076
6169
|
var _a2;
|
6077
6170
|
if (frameRef.current) {
|
6078
6171
|
setCtx({
|
@@ -6166,7 +6259,7 @@ import { Fragment as Fragment10, jsx as jsx33 } from "react/jsx-runtime";
|
|
6166
6259
|
var getClassName23 = get_class_name_factory_default("PuckPreview", styles_module_default18);
|
6167
6260
|
var useBubbleIframeEvents = (ref) => {
|
6168
6261
|
const { status } = useAppContext();
|
6169
|
-
|
6262
|
+
useEffect20(() => {
|
6170
6263
|
var _a;
|
6171
6264
|
if (ref.current && status === "READY") {
|
6172
6265
|
const iframe = ref.current;
|
@@ -6205,7 +6298,7 @@ var useBubbleIframeEvents = (ref) => {
|
|
6205
6298
|
};
|
6206
6299
|
var Preview2 = ({ id = "puck-preview" }) => {
|
6207
6300
|
const { config, dispatch, state, setStatus, iframe, overrides } = useAppContext();
|
6208
|
-
const Page =
|
6301
|
+
const Page = useCallback14(
|
6209
6302
|
(pageProps) => {
|
6210
6303
|
var _a, _b;
|
6211
6304
|
return ((_a = config.root) == null ? void 0 : _a.render) ? (_b = config.root) == null ? void 0 : _b.render(__spreadValues({
|
@@ -6214,9 +6307,9 @@ var Preview2 = ({ id = "puck-preview" }) => {
|
|
6214
6307
|
},
|
6215
6308
|
[config.root]
|
6216
6309
|
);
|
6217
|
-
const Frame =
|
6310
|
+
const Frame = useMemo14(() => overrides.iframe, [overrides]);
|
6218
6311
|
const rootProps = state.data.root.props || state.data.root;
|
6219
|
-
const ref =
|
6312
|
+
const ref = useRef7(null);
|
6220
6313
|
useBubbleIframeEvents(ref);
|
6221
6314
|
const inner = state.ui.previewMode === "edit" ? /* @__PURE__ */ jsx33(
|
6222
6315
|
Page,
|
@@ -6466,13 +6559,13 @@ var LayerTree = ({
|
|
6466
6559
|
};
|
6467
6560
|
|
6468
6561
|
// components/Puck/components/Outline/index.tsx
|
6469
|
-
import { useCallback as
|
6562
|
+
import { useCallback as useCallback15, useMemo as useMemo15 } from "react";
|
6470
6563
|
import { Fragment as Fragment12, jsx as jsx35, jsxs as jsxs17 } from "react/jsx-runtime";
|
6471
6564
|
var Outline = () => {
|
6472
6565
|
const { dispatch, state, overrides, config } = useAppContext();
|
6473
6566
|
const { data, ui } = state;
|
6474
6567
|
const { itemSelector } = ui;
|
6475
|
-
const setItemSelector =
|
6568
|
+
const setItemSelector = useCallback15(
|
6476
6569
|
(newItemSelector) => {
|
6477
6570
|
dispatch({
|
6478
6571
|
type: "setUi",
|
@@ -6481,7 +6574,7 @@ var Outline = () => {
|
|
6481
6574
|
},
|
6482
6575
|
[]
|
6483
6576
|
);
|
6484
|
-
const Wrapper =
|
6577
|
+
const Wrapper = useMemo15(() => overrides.outline || "div", [overrides]);
|
6485
6578
|
return /* @__PURE__ */ jsx35(Wrapper, { children: /* @__PURE__ */ jsx35(dropZoneContext.Consumer, { children: (ctx) => /* @__PURE__ */ jsxs17(Fragment12, { children: [
|
6486
6579
|
(ctx == null ? void 0 : ctx.activeZones) && (ctx == null ? void 0 : ctx.activeZones[rootDroppableId]) && /* @__PURE__ */ jsx35(
|
6487
6580
|
LayerTree,
|
@@ -6768,16 +6861,16 @@ var getBox = function getBox2(el) {
|
|
6768
6861
|
|
6769
6862
|
// components/Puck/components/Canvas/index.tsx
|
6770
6863
|
import {
|
6771
|
-
useCallback as
|
6772
|
-
useEffect as
|
6773
|
-
useMemo as
|
6774
|
-
useRef as
|
6864
|
+
useCallback as useCallback16,
|
6865
|
+
useEffect as useEffect22,
|
6866
|
+
useMemo as useMemo17,
|
6867
|
+
useRef as useRef8,
|
6775
6868
|
useState as useState24
|
6776
6869
|
} from "react";
|
6777
6870
|
|
6778
6871
|
// components/ViewportControls/index.tsx
|
6779
6872
|
init_react_import();
|
6780
|
-
import { useEffect as
|
6873
|
+
import { useEffect as useEffect21, useMemo as useMemo16, useState as useState23 } from "react";
|
6781
6874
|
|
6782
6875
|
// css-module:/home/runner/work/puck/puck/packages/core/components/ViewportControls/styles.module.css#css-module
|
6783
6876
|
init_react_import();
|
@@ -6801,7 +6894,7 @@ var ViewportButton = ({
|
|
6801
6894
|
}) => {
|
6802
6895
|
const { state } = useAppContext();
|
6803
6896
|
const [isActive, setIsActive] = useState23(false);
|
6804
|
-
|
6897
|
+
useEffect21(() => {
|
6805
6898
|
setIsActive(width === state.ui.viewports.current.width);
|
6806
6899
|
}, [width, state.ui.viewports.current.width]);
|
6807
6900
|
return /* @__PURE__ */ jsx36("span", { className: getClassNameButton({ isActive }), children: /* @__PURE__ */ jsx36(
|
@@ -6837,7 +6930,7 @@ var ViewportControls = ({
|
|
6837
6930
|
const defaultsContainAutoZoom = defaultZoomOptions.find(
|
6838
6931
|
(option) => option.value === autoZoom
|
6839
6932
|
);
|
6840
|
-
const zoomOptions =
|
6933
|
+
const zoomOptions = useMemo16(
|
6841
6934
|
() => [
|
6842
6935
|
...defaultZoomOptions,
|
6843
6936
|
...defaultsContainAutoZoom ? [] : [
|
@@ -6960,17 +7053,17 @@ var Canvas = () => {
|
|
6960
7053
|
const { status, iframe } = useAppContext();
|
6961
7054
|
const { dispatch, state, overrides, setUi, zoomConfig, setZoomConfig } = useAppContext();
|
6962
7055
|
const { ui } = state;
|
6963
|
-
const frameRef =
|
7056
|
+
const frameRef = useRef8(null);
|
6964
7057
|
const [showTransition, setShowTransition] = useState24(false);
|
6965
|
-
const defaultRender =
|
7058
|
+
const defaultRender = useMemo17(() => {
|
6966
7059
|
const PuckDefault = ({ children }) => /* @__PURE__ */ jsx37(Fragment13, { children });
|
6967
7060
|
return PuckDefault;
|
6968
7061
|
}, []);
|
6969
|
-
const CustomPreview =
|
7062
|
+
const CustomPreview = useMemo17(
|
6970
7063
|
() => overrides.preview || defaultRender,
|
6971
7064
|
[overrides]
|
6972
7065
|
);
|
6973
|
-
const getFrameDimensions =
|
7066
|
+
const getFrameDimensions = useCallback16(() => {
|
6974
7067
|
if (frameRef.current) {
|
6975
7068
|
const frame = frameRef.current;
|
6976
7069
|
const box = getBox(frame);
|
@@ -6978,7 +7071,7 @@ var Canvas = () => {
|
|
6978
7071
|
}
|
6979
7072
|
return { width: 0, height: 0 };
|
6980
7073
|
}, [frameRef]);
|
6981
|
-
const resetAutoZoom =
|
7074
|
+
const resetAutoZoom = useCallback16(
|
6982
7075
|
(ui2 = state.ui) => {
|
6983
7076
|
if (frameRef.current) {
|
6984
7077
|
setZoomConfig(
|
@@ -6988,11 +7081,11 @@ var Canvas = () => {
|
|
6988
7081
|
},
|
6989
7082
|
[frameRef, zoomConfig, state.ui]
|
6990
7083
|
);
|
6991
|
-
|
7084
|
+
useEffect22(() => {
|
6992
7085
|
setShowTransition(false);
|
6993
7086
|
resetAutoZoom();
|
6994
7087
|
}, [frameRef, ui.leftSideBarVisible, ui.rightSideBarVisible]);
|
6995
|
-
|
7088
|
+
useEffect22(() => {
|
6996
7089
|
const { height: frameHeight } = getFrameDimensions();
|
6997
7090
|
if (ui.viewports.current.height === "auto") {
|
6998
7091
|
setZoomConfig(__spreadProps(__spreadValues({}, zoomConfig), {
|
@@ -7000,13 +7093,13 @@ var Canvas = () => {
|
|
7000
7093
|
}));
|
7001
7094
|
}
|
7002
7095
|
}, [zoomConfig.zoom]);
|
7003
|
-
|
7096
|
+
useEffect22(() => {
|
7004
7097
|
if (ZOOM_ON_CHANGE) {
|
7005
7098
|
setShowTransition(true);
|
7006
7099
|
resetAutoZoom(ui);
|
7007
7100
|
}
|
7008
7101
|
}, [ui.viewports.current.width]);
|
7009
|
-
|
7102
|
+
useEffect22(() => {
|
7010
7103
|
const cb = () => {
|
7011
7104
|
setShowTransition(false);
|
7012
7105
|
resetAutoZoom();
|
@@ -7017,7 +7110,7 @@ var Canvas = () => {
|
|
7017
7110
|
};
|
7018
7111
|
}, []);
|
7019
7112
|
const [showLoader, setShowLoader] = useState24(false);
|
7020
|
-
|
7113
|
+
useEffect22(() => {
|
7021
7114
|
setTimeout(() => {
|
7022
7115
|
setShowLoader(true);
|
7023
7116
|
}, 500);
|
@@ -7095,7 +7188,7 @@ var Canvas = () => {
|
|
7095
7188
|
|
7096
7189
|
// lib/use-loaded-overrides.ts
|
7097
7190
|
init_react_import();
|
7098
|
-
import { useMemo as
|
7191
|
+
import { useMemo as useMemo18 } from "react";
|
7099
7192
|
|
7100
7193
|
// lib/load-overrides.ts
|
7101
7194
|
init_react_import();
|
@@ -7134,7 +7227,7 @@ var useLoadedOverrides = ({
|
|
7134
7227
|
overrides,
|
7135
7228
|
plugins
|
7136
7229
|
}) => {
|
7137
|
-
return
|
7230
|
+
return useMemo18(() => {
|
7138
7231
|
return loadOverrides({ overrides, plugins });
|
7139
7232
|
}, [plugins, overrides]);
|
7140
7233
|
};
|
@@ -7146,14 +7239,14 @@ var DefaultOverride = ({ children }) => /* @__PURE__ */ jsx38(Fragment14, { chil
|
|
7146
7239
|
|
7147
7240
|
// lib/use-inject-css.ts
|
7148
7241
|
init_react_import();
|
7149
|
-
import { useEffect as
|
7242
|
+
import { useEffect as useEffect23, useState as useState25 } from "react";
|
7150
7243
|
var styles = ``;
|
7151
7244
|
var useInjectStyleSheet = (initialStyles, iframeEnabled) => {
|
7152
7245
|
const [el, setEl] = useState25();
|
7153
|
-
|
7246
|
+
useEffect23(() => {
|
7154
7247
|
setEl(document.createElement("style"));
|
7155
7248
|
}, []);
|
7156
|
-
|
7249
|
+
useEffect23(() => {
|
7157
7250
|
var _a;
|
7158
7251
|
if (!el || typeof window === "undefined") {
|
7159
7252
|
return;
|
@@ -7173,10 +7266,10 @@ var useInjectGlobalCss = (iframeEnabled) => {
|
|
7173
7266
|
|
7174
7267
|
// lib/use-preview-mode-hotkeys.ts
|
7175
7268
|
init_react_import();
|
7176
|
-
import { useCallback as
|
7269
|
+
import { useCallback as useCallback17 } from "react";
|
7177
7270
|
import { useHotkeys as useHotkeys2 } from "react-hotkeys-hook";
|
7178
7271
|
var usePreviewModeHotkeys = (dispatch, iframeEnabled) => {
|
7179
|
-
const toggleInteractive =
|
7272
|
+
const toggleInteractive = useCallback17(() => {
|
7180
7273
|
dispatch({
|
7181
7274
|
type: "setUi",
|
7182
7275
|
ui: (ui) => ({
|
@@ -7321,11 +7414,11 @@ function Puck({
|
|
7321
7414
|
const [menuOpen, setMenuOpen] = useState26(false);
|
7322
7415
|
const { itemSelector, leftSideBarVisible, rightSideBarVisible } = ui;
|
7323
7416
|
const selectedItem = itemSelector ? getItem(itemSelector, data) : null;
|
7324
|
-
|
7417
|
+
useEffect24(() => {
|
7325
7418
|
if (onChange) onChange(data);
|
7326
7419
|
}, [data]);
|
7327
7420
|
const rootProps = data.root.props || data.root;
|
7328
|
-
const toggleSidebars =
|
7421
|
+
const toggleSidebars = useCallback18(
|
7329
7422
|
(sidebar) => {
|
7330
7423
|
const widerViewport = window.matchMedia("(min-width: 638px)").matches;
|
7331
7424
|
const sideBarVisible = sidebar === "left" ? leftSideBarVisible : rightSideBarVisible;
|
@@ -7339,7 +7432,7 @@ function Puck({
|
|
7339
7432
|
},
|
7340
7433
|
[dispatch, leftSideBarVisible, rightSideBarVisible]
|
7341
7434
|
);
|
7342
|
-
|
7435
|
+
useEffect24(() => {
|
7343
7436
|
if (!window.matchMedia("(min-width: 638px)").matches) {
|
7344
7437
|
dispatch({
|
7345
7438
|
type: "setUi",
|
@@ -7362,7 +7455,7 @@ function Puck({
|
|
7362
7455
|
window.removeEventListener("resize", handleResize);
|
7363
7456
|
};
|
7364
7457
|
}, []);
|
7365
|
-
const defaultHeaderRender =
|
7458
|
+
const defaultHeaderRender = useMemo19(() => {
|
7366
7459
|
if (renderHeader) {
|
7367
7460
|
console.warn(
|
7368
7461
|
"`renderHeader` is deprecated. Please use `overrides.header` and the `usePuck` hook instead"
|
@@ -7376,7 +7469,7 @@ function Puck({
|
|
7376
7469
|
}
|
7377
7470
|
return DefaultOverride;
|
7378
7471
|
}, [renderHeader]);
|
7379
|
-
const defaultHeaderActionsRender =
|
7472
|
+
const defaultHeaderActionsRender = useMemo19(() => {
|
7380
7473
|
if (renderHeaderActions) {
|
7381
7474
|
console.warn(
|
7382
7475
|
"`renderHeaderActions` is deprecated. Please use `overrides.headerActions` and the `usePuck` hook instead."
|
@@ -7393,20 +7486,20 @@ function Puck({
|
|
7393
7486
|
overrides,
|
7394
7487
|
plugins
|
7395
7488
|
});
|
7396
|
-
const CustomPuck =
|
7489
|
+
const CustomPuck = useMemo19(
|
7397
7490
|
() => loadedOverrides.puck || DefaultOverride,
|
7398
7491
|
[loadedOverrides]
|
7399
7492
|
);
|
7400
|
-
const CustomHeader =
|
7493
|
+
const CustomHeader = useMemo19(
|
7401
7494
|
() => loadedOverrides.header || defaultHeaderRender,
|
7402
7495
|
[loadedOverrides]
|
7403
7496
|
);
|
7404
|
-
const CustomHeaderActions =
|
7497
|
+
const CustomHeaderActions = useMemo19(
|
7405
7498
|
() => loadedOverrides.headerActions || defaultHeaderActionsRender,
|
7406
7499
|
[loadedOverrides]
|
7407
7500
|
);
|
7408
7501
|
const [mounted, setMounted] = useState26(false);
|
7409
|
-
|
7502
|
+
useEffect24(() => {
|
7410
7503
|
setMounted(true);
|
7411
7504
|
}, []);
|
7412
7505
|
const selectedComponentConfig = selectedItem && config.components[selectedItem.type];
|