@measured/puck 0.18.0-canary.066aba9 → 0.18.0-canary.9c64ea4
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/index.css +27 -34
- package/dist/index.d.mts +0 -6
- package/dist/index.d.ts +0 -6
- package/dist/index.js +707 -497
- package/dist/index.mjs +677 -467
- package/package.json +3 -2
package/dist/index.js
CHANGED
@@ -1284,7 +1284,7 @@ init_react_import();
|
|
1284
1284
|
var import_react9 = require("@dnd-kit/react");
|
1285
1285
|
var import_react10 = require("react");
|
1286
1286
|
|
1287
|
-
// lib/dnd-kit/safe.ts
|
1287
|
+
// lib/dnd/dnd-kit/safe.ts
|
1288
1288
|
init_react_import();
|
1289
1289
|
var import_react8 = require("@dnd-kit/react");
|
1290
1290
|
var import_sortable = require("@dnd-kit/react/sortable");
|
@@ -2524,21 +2524,21 @@ init_react_import();
|
|
2524
2524
|
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" };
|
2525
2525
|
|
2526
2526
|
// components/Drawer/index.tsx
|
2527
|
-
var
|
2527
|
+
var import_react31 = require("react");
|
2528
2528
|
|
2529
2529
|
// components/DragDropContext/index.tsx
|
2530
2530
|
init_react_import();
|
2531
|
-
var
|
2532
|
-
var
|
2531
|
+
var import_react29 = require("@dnd-kit/react");
|
2532
|
+
var import_react30 = require("react");
|
2533
2533
|
var import_dom = require("@dnd-kit/dom");
|
2534
2534
|
|
2535
2535
|
// components/DropZone/index.tsx
|
2536
2536
|
init_react_import();
|
2537
|
-
var
|
2537
|
+
var import_react28 = require("react");
|
2538
2538
|
|
2539
2539
|
// components/DraggableComponent/index.tsx
|
2540
2540
|
init_react_import();
|
2541
|
-
var
|
2541
|
+
var import_react22 = require("react");
|
2542
2542
|
|
2543
2543
|
// css-module:/home/runner/work/puck/puck/packages/core/components/DraggableComponent/styles.module.css#css-module
|
2544
2544
|
init_react_import();
|
@@ -2547,15 +2547,15 @@ var styles_module_default11 = { "DraggableComponent": "_DraggableComponent_1ukn8
|
|
2547
2547
|
// components/DraggableComponent/index.tsx
|
2548
2548
|
var import_react_dom2 = require("react-dom");
|
2549
2549
|
|
2550
|
-
//
|
2550
|
+
// lib/dnd/collision/dynamic/index.ts
|
2551
2551
|
init_react_import();
|
2552
2552
|
var import_abstract8 = require("@dnd-kit/abstract");
|
2553
2553
|
|
2554
|
-
//
|
2554
|
+
// lib/dnd/collision/directional/index.ts
|
2555
2555
|
init_react_import();
|
2556
2556
|
var import_abstract = require("@dnd-kit/abstract");
|
2557
2557
|
|
2558
|
-
//
|
2558
|
+
// lib/dnd/collision/collision-debug.ts
|
2559
2559
|
init_react_import();
|
2560
2560
|
var DEBUG = false;
|
2561
2561
|
var debugElements = {};
|
@@ -2604,7 +2604,7 @@ var collisionDebug = (a, b, id, color, label) => {
|
|
2604
2604
|
});
|
2605
2605
|
};
|
2606
2606
|
|
2607
|
-
//
|
2607
|
+
// lib/dnd/collision/directional/index.ts
|
2608
2608
|
var distanceChange = "increasing";
|
2609
2609
|
var directionalCollision = (input, previous) => {
|
2610
2610
|
var _a;
|
@@ -2637,7 +2637,7 @@ var directionalCollision = (input, previous) => {
|
|
2637
2637
|
return null;
|
2638
2638
|
};
|
2639
2639
|
|
2640
|
-
//
|
2640
|
+
// lib/dnd/collision/dynamic/get-direction.ts
|
2641
2641
|
init_react_import();
|
2642
2642
|
var getDirection = (dragAxis, delta) => {
|
2643
2643
|
if (dragAxis === "dynamic") {
|
@@ -2652,7 +2652,7 @@ var getDirection = (dragAxis, delta) => {
|
|
2652
2652
|
return delta.y === 0 ? null : delta.y > 0 ? "down" : "up";
|
2653
2653
|
};
|
2654
2654
|
|
2655
|
-
//
|
2655
|
+
// lib/dnd/collision/dynamic/get-midpoint-impact.ts
|
2656
2656
|
init_react_import();
|
2657
2657
|
var getMidpointImpact = (dragShape, dropShape, direction, offsetMultiplier = 0) => {
|
2658
2658
|
const dragRect = dragShape.boundingRectangle;
|
@@ -2671,7 +2671,7 @@ var getMidpointImpact = (dragShape, dropShape, direction, offsetMultiplier = 0)
|
|
2671
2671
|
return dragRect.right - offset >= dropCenter.x;
|
2672
2672
|
};
|
2673
2673
|
|
2674
|
-
//
|
2674
|
+
// lib/dnd/collision/dynamic/track-movement-interval.ts
|
2675
2675
|
init_react_import();
|
2676
2676
|
var import_geometry = require("@dnd-kit/geometry");
|
2677
2677
|
var INTERVAL_SENSITIVITY = 10;
|
@@ -2775,7 +2775,14 @@ var closestCorners = (input) => {
|
|
2775
2775
|
};
|
2776
2776
|
};
|
2777
2777
|
|
2778
|
-
//
|
2778
|
+
// lib/dnd/collision/dynamic/store.ts
|
2779
|
+
init_react_import();
|
2780
|
+
var import_vanilla = require("zustand/vanilla");
|
2781
|
+
var collisionStore = (0, import_vanilla.createStore)(() => ({
|
2782
|
+
fallbackEnabled: false
|
2783
|
+
}));
|
2784
|
+
|
2785
|
+
// lib/dnd/collision/dynamic/index.ts
|
2779
2786
|
var flushNext = "";
|
2780
2787
|
var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input) => {
|
2781
2788
|
var _a, _b, _c, _d, _e;
|
@@ -2787,6 +2794,7 @@ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input
|
|
2787
2794
|
return null;
|
2788
2795
|
}
|
2789
2796
|
const { center: dragCenter } = dragShape;
|
2797
|
+
const { fallbackEnabled } = collisionStore.getState();
|
2790
2798
|
const interval = trackMovementInterval(position.current, dragAxis);
|
2791
2799
|
dragOperation.data = __spreadProps(__spreadValues({}, dragOperation.data), {
|
2792
2800
|
direction: interval.direction
|
@@ -2832,7 +2840,7 @@ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input
|
|
2832
2840
|
flushNext = "";
|
2833
2841
|
return __spreadProps(__spreadValues({}, collision), { id: shouldFlushId ? "flush" : collision.id });
|
2834
2842
|
}
|
2835
|
-
if (((_c = dragOperation.source) == null ? void 0 : _c.id) !== droppable.id) {
|
2843
|
+
if (fallbackEnabled && ((_c = dragOperation.source) == null ? void 0 : _c.id) !== droppable.id) {
|
2836
2844
|
const xAxisIntersection = dropShape.boundingRectangle.right > dragShape.boundingRectangle.left && dropShape.boundingRectangle.left < dragShape.boundingRectangle.right;
|
2837
2845
|
const yAxisIntersection = dropShape.boundingRectangle.bottom > dragShape.boundingRectangle.top && dropShape.boundingRectangle.top < dragShape.boundingRectangle.bottom;
|
2838
2846
|
if (dragAxis === "y" && xAxisIntersection || yAxisIntersection) {
|
@@ -2893,8 +2901,102 @@ function getDeepScrollPosition(element) {
|
|
2893
2901
|
return totalScroll;
|
2894
2902
|
}
|
2895
2903
|
|
2896
|
-
// components/
|
2904
|
+
// components/DropZone/context.tsx
|
2905
|
+
init_react_import();
|
2906
|
+
var import_react20 = require("react");
|
2907
|
+
var import_zustand = require("zustand");
|
2897
2908
|
var import_jsx_runtime19 = require("react/jsx-runtime");
|
2909
|
+
var dropZoneContext = (0, import_react20.createContext)(null);
|
2910
|
+
var ZoneStoreContext = (0, import_react20.createContext)(
|
2911
|
+
(0, import_zustand.createStore)(() => ({
|
2912
|
+
zoneDepthIndex: {},
|
2913
|
+
nextZoneDepthIndex: {},
|
2914
|
+
areaDepthIndex: {},
|
2915
|
+
nextAreaDepthIndex: {},
|
2916
|
+
draggedItem: null,
|
2917
|
+
previewIndex: {}
|
2918
|
+
}))
|
2919
|
+
);
|
2920
|
+
var ZoneStoreProvider = ({
|
2921
|
+
children,
|
2922
|
+
store
|
2923
|
+
}) => {
|
2924
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(ZoneStoreContext.Provider, { value: store, children });
|
2925
|
+
};
|
2926
|
+
var DropZoneProvider = ({
|
2927
|
+
children,
|
2928
|
+
value
|
2929
|
+
}) => {
|
2930
|
+
const [hoveringComponent, setHoveringComponent] = (0, import_react20.useState)();
|
2931
|
+
const [areasWithZones, setAreasWithZones] = (0, import_react20.useState)(
|
2932
|
+
{}
|
2933
|
+
);
|
2934
|
+
const [activeZones, setActiveZones] = (0, import_react20.useState)({});
|
2935
|
+
const { dispatch } = useAppContext();
|
2936
|
+
const registerZoneArea = (0, import_react20.useCallback)(
|
2937
|
+
(area) => {
|
2938
|
+
setAreasWithZones((latest) => __spreadProps(__spreadValues({}, latest), { [area]: true }));
|
2939
|
+
},
|
2940
|
+
[setAreasWithZones]
|
2941
|
+
);
|
2942
|
+
const registerZone = (0, import_react20.useCallback)(
|
2943
|
+
(zoneCompound) => {
|
2944
|
+
if (!dispatch) {
|
2945
|
+
return;
|
2946
|
+
}
|
2947
|
+
dispatch({
|
2948
|
+
type: "registerZone",
|
2949
|
+
zone: zoneCompound
|
2950
|
+
});
|
2951
|
+
setActiveZones((latest) => __spreadProps(__spreadValues({}, latest), { [zoneCompound]: true }));
|
2952
|
+
},
|
2953
|
+
[setActiveZones, dispatch]
|
2954
|
+
);
|
2955
|
+
const unregisterZone = (0, import_react20.useCallback)(
|
2956
|
+
(zoneCompound) => {
|
2957
|
+
if (!dispatch) {
|
2958
|
+
return;
|
2959
|
+
}
|
2960
|
+
dispatch({
|
2961
|
+
type: "unregisterZone",
|
2962
|
+
zone: zoneCompound
|
2963
|
+
});
|
2964
|
+
setActiveZones((latest) => __spreadProps(__spreadValues({}, latest), {
|
2965
|
+
[zoneCompound]: false
|
2966
|
+
}));
|
2967
|
+
},
|
2968
|
+
[setActiveZones, dispatch]
|
2969
|
+
);
|
2970
|
+
const memoValue = (0, import_react20.useMemo)(
|
2971
|
+
() => __spreadValues({
|
2972
|
+
hoveringComponent,
|
2973
|
+
setHoveringComponent,
|
2974
|
+
registerZoneArea,
|
2975
|
+
areasWithZones,
|
2976
|
+
registerZone,
|
2977
|
+
unregisterZone,
|
2978
|
+
activeZones
|
2979
|
+
}, value),
|
2980
|
+
[value, hoveringComponent, areasWithZones, activeZones]
|
2981
|
+
);
|
2982
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_jsx_runtime19.Fragment, { children: memoValue && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(dropZoneContext.Provider, { value: memoValue, children }) });
|
2983
|
+
};
|
2984
|
+
|
2985
|
+
// lib/use-context-store.ts
|
2986
|
+
init_react_import();
|
2987
|
+
var import_react21 = require("react");
|
2988
|
+
var import_zustand2 = require("zustand");
|
2989
|
+
var import_shallow = require("zustand/react/shallow");
|
2990
|
+
function useContextStore(context, selector) {
|
2991
|
+
const store = (0, import_react21.useContext)(context);
|
2992
|
+
if (!store) {
|
2993
|
+
throw new Error("useContextStore must be used inside context");
|
2994
|
+
}
|
2995
|
+
return (0, import_zustand2.useStore)(store, (0, import_shallow.useShallow)(selector));
|
2996
|
+
}
|
2997
|
+
|
2998
|
+
// components/DraggableComponent/index.tsx
|
2999
|
+
var import_jsx_runtime20 = require("react/jsx-runtime");
|
2898
3000
|
var getClassName16 = get_class_name_factory_default("DraggableComponent", styles_module_default11);
|
2899
3001
|
var DEBUG2 = false;
|
2900
3002
|
var space = 8;
|
@@ -2905,12 +3007,12 @@ var DefaultActionBar = ({
|
|
2905
3007
|
label,
|
2906
3008
|
children,
|
2907
3009
|
parentAction
|
2908
|
-
}) => /* @__PURE__ */ (0,
|
2909
|
-
/* @__PURE__ */ (0,
|
3010
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(ActionBar, { children: [
|
3011
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(ActionBar.Group, { children: [
|
2910
3012
|
parentAction,
|
2911
|
-
label && /* @__PURE__ */ (0,
|
3013
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(ActionBar.Label, { label })
|
2912
3014
|
] }),
|
2913
|
-
/* @__PURE__ */ (0,
|
3015
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(ActionBar.Group, { children })
|
2914
3016
|
] });
|
2915
3017
|
var convertIdToSelector = (id, zoneCompound, data) => {
|
2916
3018
|
const content = zoneCompound && data.zones && zoneCompound !== "default-zone" ? data.zones[zoneCompound] : data.content;
|
@@ -2945,9 +3047,9 @@ var DraggableComponent = ({
|
|
2945
3047
|
iframe,
|
2946
3048
|
state
|
2947
3049
|
} = useAppContext();
|
2948
|
-
const ctx = (0,
|
2949
|
-
const [localZones, setLocalZones] = (0,
|
2950
|
-
const registerLocalZone = (0,
|
3050
|
+
const ctx = (0, import_react22.useContext)(dropZoneContext);
|
3051
|
+
const [localZones, setLocalZones] = (0, import_react22.useState)({});
|
3052
|
+
const registerLocalZone = (0, import_react22.useCallback)(
|
2951
3053
|
(zoneCompound2, active) => {
|
2952
3054
|
var _a;
|
2953
3055
|
(_a = ctx == null ? void 0 : ctx.registerLocalZone) == null ? void 0 : _a.call(ctx, zoneCompound2, active);
|
@@ -2957,7 +3059,7 @@ var DraggableComponent = ({
|
|
2957
3059
|
},
|
2958
3060
|
[setLocalZones]
|
2959
3061
|
);
|
2960
|
-
const unregisterLocalZone = (0,
|
3062
|
+
const unregisterLocalZone = (0, import_react22.useCallback)(
|
2961
3063
|
(zoneCompound2) => {
|
2962
3064
|
var _a;
|
2963
3065
|
(_a = ctx == null ? void 0 : ctx.unregisterLocalZone) == null ? void 0 : _a.call(ctx, zoneCompound2);
|
@@ -2971,8 +3073,8 @@ var DraggableComponent = ({
|
|
2971
3073
|
);
|
2972
3074
|
const containsActiveZone = Object.values(localZones).filter(Boolean).length > 0;
|
2973
3075
|
const { path = [] } = ctx || {};
|
2974
|
-
const [canDrag, setCanDrag] = (0,
|
2975
|
-
(0,
|
3076
|
+
const [canDrag, setCanDrag] = (0, import_react22.useState)(false);
|
3077
|
+
(0, import_react22.useEffect)(() => {
|
2976
3078
|
var _a;
|
2977
3079
|
const item = getItem({ index, zone: zoneCompound }, state.data);
|
2978
3080
|
if (item) {
|
@@ -2982,10 +3084,13 @@ var DraggableComponent = ({
|
|
2982
3084
|
setCanDrag((_a = perms.drag) != null ? _a : true);
|
2983
3085
|
}
|
2984
3086
|
}, [state, index, zoneCompound, getPermissions]);
|
2985
|
-
const userIsDragging =
|
3087
|
+
const userIsDragging = useContextStore(
|
3088
|
+
ZoneStoreContext,
|
3089
|
+
(s) => !!s.draggedItem
|
3090
|
+
);
|
2986
3091
|
const canCollide = canDrag || userIsDragging;
|
2987
3092
|
const disabled = !isEnabled || !canCollide;
|
2988
|
-
const [dragAxis, setDragAxis] = (0,
|
3093
|
+
const [dragAxis, setDragAxis] = (0, import_react22.useState)(userDragAxis || autoDragAxis);
|
2989
3094
|
const { ref: sortableRef, status } = useSortableSafe({
|
2990
3095
|
id,
|
2991
3096
|
index,
|
@@ -3011,8 +3116,8 @@ var DraggableComponent = ({
|
|
3011
3116
|
}
|
3012
3117
|
});
|
3013
3118
|
const thisIsDragging = status === "dragging";
|
3014
|
-
const ref = (0,
|
3015
|
-
const refSetter = (0,
|
3119
|
+
const ref = (0, import_react22.useRef)(null);
|
3120
|
+
const refSetter = (0, import_react22.useCallback)(
|
3016
3121
|
(el) => {
|
3017
3122
|
sortableRef(el);
|
3018
3123
|
if (el) {
|
@@ -3021,14 +3126,14 @@ var DraggableComponent = ({
|
|
3021
3126
|
},
|
3022
3127
|
[sortableRef]
|
3023
3128
|
);
|
3024
|
-
const [portalEl, setPortalEl] = (0,
|
3025
|
-
(0,
|
3129
|
+
const [portalEl, setPortalEl] = (0, import_react22.useState)();
|
3130
|
+
(0, import_react22.useEffect)(() => {
|
3026
3131
|
var _a, _b, _c;
|
3027
3132
|
setPortalEl(
|
3028
3133
|
iframe.enabled ? (_a = ref.current) == null ? void 0 : _a.ownerDocument.body : (_c = (_b = ref.current) == null ? void 0 : _b.closest("[data-puck-preview]")) != null ? _c : document.body
|
3029
3134
|
);
|
3030
3135
|
}, [iframe.enabled, ref.current]);
|
3031
|
-
const getStyle = (0,
|
3136
|
+
const getStyle = (0, import_react22.useCallback)(() => {
|
3032
3137
|
var _a, _b, _c;
|
3033
3138
|
if (!ref.current) return;
|
3034
3139
|
const rect = ref.current.getBoundingClientRect();
|
@@ -3048,11 +3153,11 @@ var DraggableComponent = ({
|
|
3048
3153
|
};
|
3049
3154
|
return style2;
|
3050
3155
|
}, [ref.current]);
|
3051
|
-
const [style, setStyle] = (0,
|
3052
|
-
const sync = (0,
|
3156
|
+
const [style, setStyle] = (0, import_react22.useState)();
|
3157
|
+
const sync = (0, import_react22.useCallback)(() => {
|
3053
3158
|
setStyle(getStyle());
|
3054
3159
|
}, [ref.current, iframe]);
|
3055
|
-
(0,
|
3160
|
+
(0, import_react22.useEffect)(() => {
|
3056
3161
|
if (ref.current) {
|
3057
3162
|
const observer = new ResizeObserver(sync);
|
3058
3163
|
observer.observe(ref.current);
|
@@ -3061,20 +3166,22 @@ var DraggableComponent = ({
|
|
3061
3166
|
};
|
3062
3167
|
}
|
3063
3168
|
}, [ref.current]);
|
3064
|
-
(0,
|
3065
|
-
|
3066
|
-
|
3067
|
-
|
3068
|
-
|
3169
|
+
(0, import_react22.useEffect)(() => {
|
3170
|
+
if (isSelected) {
|
3171
|
+
ctx == null ? void 0 : ctx.registerPath({
|
3172
|
+
index,
|
3173
|
+
zone: zoneCompound
|
3174
|
+
});
|
3175
|
+
}
|
3069
3176
|
}, [isSelected]);
|
3070
|
-
const CustomActionBar = (0,
|
3177
|
+
const CustomActionBar = (0, import_react22.useMemo)(
|
3071
3178
|
() => overrides.actionBar || DefaultActionBar,
|
3072
3179
|
[overrides.actionBar]
|
3073
3180
|
);
|
3074
3181
|
const permissions = getPermissions({
|
3075
3182
|
item: selectedItem
|
3076
3183
|
});
|
3077
|
-
const onClick = (0,
|
3184
|
+
const onClick = (0, import_react22.useCallback)(
|
3078
3185
|
(e) => {
|
3079
3186
|
e.stopPropagation();
|
3080
3187
|
dispatch({
|
@@ -3086,7 +3193,7 @@ var DraggableComponent = ({
|
|
3086
3193
|
},
|
3087
3194
|
[index, zoneCompound, id]
|
3088
3195
|
);
|
3089
|
-
const onSelectParent = (0,
|
3196
|
+
const onSelectParent = (0, import_react22.useCallback)(() => {
|
3090
3197
|
if (!(ctx == null ? void 0 : ctx.areaId)) {
|
3091
3198
|
return;
|
3092
3199
|
}
|
@@ -3104,23 +3211,23 @@ var DraggableComponent = ({
|
|
3104
3211
|
}
|
3105
3212
|
});
|
3106
3213
|
}, [ctx, path]);
|
3107
|
-
const onDuplicate = (0,
|
3214
|
+
const onDuplicate = (0, import_react22.useCallback)(() => {
|
3108
3215
|
dispatch({
|
3109
3216
|
type: "duplicate",
|
3110
3217
|
sourceIndex: index,
|
3111
3218
|
sourceZone: zoneCompound
|
3112
3219
|
});
|
3113
3220
|
}, [index, zoneCompound]);
|
3114
|
-
const onDelete = (0,
|
3221
|
+
const onDelete = (0, import_react22.useCallback)(() => {
|
3115
3222
|
dispatch({
|
3116
3223
|
type: "remove",
|
3117
3224
|
index,
|
3118
3225
|
zone: zoneCompound
|
3119
3226
|
});
|
3120
3227
|
}, [index, zoneCompound]);
|
3121
|
-
const [hover, setHover] = (0,
|
3228
|
+
const [hover, setHover] = (0, import_react22.useState)(false);
|
3122
3229
|
const indicativeHover = (ctx == null ? void 0 : ctx.hoveringComponent) === id;
|
3123
|
-
(0,
|
3230
|
+
(0, import_react22.useEffect)(() => {
|
3124
3231
|
if (!ref.current) {
|
3125
3232
|
return;
|
3126
3233
|
}
|
@@ -3170,7 +3277,7 @@ var DraggableComponent = ({
|
|
3170
3277
|
thisIsDragging,
|
3171
3278
|
inDroppableZone
|
3172
3279
|
]);
|
3173
|
-
(0,
|
3280
|
+
(0, import_react22.useEffect)(() => {
|
3174
3281
|
if (ref.current && disabled) {
|
3175
3282
|
ref.current.setAttribute("data-puck-disabled", "");
|
3176
3283
|
return () => {
|
@@ -3179,8 +3286,8 @@ var DraggableComponent = ({
|
|
3179
3286
|
};
|
3180
3287
|
}
|
3181
3288
|
}, [disabled, ref]);
|
3182
|
-
const [isVisible, setIsVisible] = (0,
|
3183
|
-
(0,
|
3289
|
+
const [isVisible, setIsVisible] = (0, import_react22.useState)(false);
|
3290
|
+
(0, import_react22.useEffect)(() => {
|
3184
3291
|
sync();
|
3185
3292
|
if ((isSelected || hover || indicativeHover) && !userIsDragging) {
|
3186
3293
|
setIsVisible(true);
|
@@ -3188,7 +3295,7 @@ var DraggableComponent = ({
|
|
3188
3295
|
setIsVisible(false);
|
3189
3296
|
}
|
3190
3297
|
}, [isSelected, hover, indicativeHover, iframe, state.data, userIsDragging]);
|
3191
|
-
const syncActionsPosition = (0,
|
3298
|
+
const syncActionsPosition = (0, import_react22.useCallback)(
|
3192
3299
|
(el) => {
|
3193
3300
|
if (el) {
|
3194
3301
|
const view = el.ownerDocument.defaultView;
|
@@ -3205,7 +3312,7 @@ var DraggableComponent = ({
|
|
3205
3312
|
},
|
3206
3313
|
[zoomConfig]
|
3207
3314
|
);
|
3208
|
-
(0,
|
3315
|
+
(0, import_react22.useEffect)(() => {
|
3209
3316
|
if (userDragAxis) {
|
3210
3317
|
setDragAxis(userDragAxis);
|
3211
3318
|
return;
|
@@ -3219,8 +3326,8 @@ var DraggableComponent = ({
|
|
3219
3326
|
}
|
3220
3327
|
setDragAxis(autoDragAxis);
|
3221
3328
|
}, [ref, userDragAxis, autoDragAxis]);
|
3222
|
-
const parentAction = (ctx == null ? void 0 : ctx.areaId) && (ctx == null ? void 0 : ctx.areaId) !== "root" && /* @__PURE__ */ (0,
|
3223
|
-
return /* @__PURE__ */ (0,
|
3329
|
+
const parentAction = (ctx == null ? void 0 : ctx.areaId) && (ctx == null ? void 0 : ctx.areaId) !== "root" && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(ActionBar.Action, { onClick: onSelectParent, label: "Select parent", children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(CornerLeftUp, { size: 16 }) });
|
3330
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
|
3224
3331
|
DropZoneProvider,
|
3225
3332
|
{
|
3226
3333
|
value: __spreadProps(__spreadValues({}, ctx), {
|
@@ -3234,7 +3341,7 @@ var DraggableComponent = ({
|
|
3234
3341
|
}),
|
3235
3342
|
children: [
|
3236
3343
|
isVisible && (0, import_react_dom2.createPortal)(
|
3237
|
-
/* @__PURE__ */ (0,
|
3344
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
|
3238
3345
|
"div",
|
3239
3346
|
{
|
3240
3347
|
className: getClassName16({
|
@@ -3246,15 +3353,15 @@ var DraggableComponent = ({
|
|
3246
3353
|
"data-puck-overlay": true,
|
3247
3354
|
children: [
|
3248
3355
|
debug,
|
3249
|
-
isLoading && /* @__PURE__ */ (0,
|
3250
|
-
/* @__PURE__ */ (0,
|
3356
|
+
isLoading && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: getClassName16("loadingOverlay"), children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Loader, {}) }),
|
3357
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
3251
3358
|
"div",
|
3252
3359
|
{
|
3253
3360
|
className: getClassName16("actionsOverlay"),
|
3254
3361
|
style: {
|
3255
3362
|
top: actionsOverlayTop / zoomConfig.zoom
|
3256
3363
|
},
|
3257
|
-
children: /* @__PURE__ */ (0,
|
3364
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
3258
3365
|
"div",
|
3259
3366
|
{
|
3260
3367
|
className: getClassName16("actions"),
|
@@ -3266,14 +3373,14 @@ var DraggableComponent = ({
|
|
3266
3373
|
paddingRight: actionsSide
|
3267
3374
|
},
|
3268
3375
|
ref: syncActionsPosition,
|
3269
|
-
children: /* @__PURE__ */ (0,
|
3376
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
|
3270
3377
|
CustomActionBar,
|
3271
3378
|
{
|
3272
3379
|
parentAction,
|
3273
3380
|
label: DEBUG2 ? id : label,
|
3274
3381
|
children: [
|
3275
|
-
permissions.duplicate && /* @__PURE__ */ (0,
|
3276
|
-
permissions.delete && /* @__PURE__ */ (0,
|
3382
|
+
permissions.duplicate && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(ActionBar.Action, { onClick: onDuplicate, label: "Duplicate", children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Copy, { size: 16 }) }),
|
3383
|
+
permissions.delete && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(ActionBar.Action, { onClick: onDelete, label: "Delete", children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Trash, { size: 16 }) })
|
3277
3384
|
]
|
3278
3385
|
}
|
3279
3386
|
)
|
@@ -3281,7 +3388,7 @@ var DraggableComponent = ({
|
|
3281
3388
|
)
|
3282
3389
|
}
|
3283
3390
|
),
|
3284
|
-
/* @__PURE__ */ (0,
|
3391
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: getClassName16("overlay") })
|
3285
3392
|
]
|
3286
3393
|
}
|
3287
3394
|
),
|
@@ -3297,93 +3404,26 @@ var DraggableComponent = ({
|
|
3297
3404
|
init_react_import();
|
3298
3405
|
var styles_module_default12 = { "DropZone": "_DropZone_kmkdc_1", "DropZone--isActive": "_DropZone--isActive_kmkdc_10", "DropZone--hasChildren": "_DropZone--hasChildren_kmkdc_14", "DropZone--userIsDragging": "_DropZone--userIsDragging_kmkdc_22", "DropZone--isAreaSelected": "_DropZone--isAreaSelected_kmkdc_26", "DropZone--hoveringOverArea": "_DropZone--hoveringOverArea_kmkdc_27", "DropZone--isRootZone": "_DropZone--isRootZone_kmkdc_27", "DropZone--isDestination": "_DropZone--isDestination_kmkdc_37", "DropZone-item": "_DropZone-item_kmkdc_49", "DropZone-hitbox": "_DropZone-hitbox_kmkdc_53", "DropZone--isEnabled": "_DropZone--isEnabled_kmkdc_61", "DropZone--isAnimating": "_DropZone--isAnimating_kmkdc_70" };
|
3299
3406
|
|
3300
|
-
// components/DropZone/
|
3301
|
-
init_react_import();
|
3302
|
-
var import_react21 = require("react");
|
3303
|
-
var import_jsx_runtime20 = require("react/jsx-runtime");
|
3304
|
-
var dropZoneContext = (0, import_react21.createContext)(null);
|
3305
|
-
var DropZoneProvider = ({
|
3306
|
-
children,
|
3307
|
-
value
|
3308
|
-
}) => {
|
3309
|
-
const [hoveringComponent, setHoveringComponent] = (0, import_react21.useState)();
|
3310
|
-
const [areasWithZones, setAreasWithZones] = (0, import_react21.useState)(
|
3311
|
-
{}
|
3312
|
-
);
|
3313
|
-
const [activeZones, setActiveZones] = (0, import_react21.useState)({});
|
3314
|
-
const { dispatch } = useAppContext();
|
3315
|
-
const registerZoneArea = (0, import_react21.useCallback)(
|
3316
|
-
(area) => {
|
3317
|
-
setAreasWithZones((latest) => __spreadProps(__spreadValues({}, latest), { [area]: true }));
|
3318
|
-
},
|
3319
|
-
[setAreasWithZones]
|
3320
|
-
);
|
3321
|
-
const registerZone = (0, import_react21.useCallback)(
|
3322
|
-
(zoneCompound) => {
|
3323
|
-
if (!dispatch) {
|
3324
|
-
return;
|
3325
|
-
}
|
3326
|
-
dispatch({
|
3327
|
-
type: "registerZone",
|
3328
|
-
zone: zoneCompound
|
3329
|
-
});
|
3330
|
-
setActiveZones((latest) => __spreadProps(__spreadValues({}, latest), { [zoneCompound]: true }));
|
3331
|
-
},
|
3332
|
-
[setActiveZones, dispatch]
|
3333
|
-
);
|
3334
|
-
const unregisterZone = (0, import_react21.useCallback)(
|
3335
|
-
(zoneCompound) => {
|
3336
|
-
if (!dispatch) {
|
3337
|
-
return;
|
3338
|
-
}
|
3339
|
-
dispatch({
|
3340
|
-
type: "unregisterZone",
|
3341
|
-
zone: zoneCompound
|
3342
|
-
});
|
3343
|
-
setActiveZones((latest) => __spreadProps(__spreadValues({}, latest), {
|
3344
|
-
[zoneCompound]: false
|
3345
|
-
}));
|
3346
|
-
},
|
3347
|
-
[setActiveZones, dispatch]
|
3348
|
-
);
|
3349
|
-
const memoValue = (0, import_react21.useMemo)(
|
3350
|
-
() => __spreadValues({
|
3351
|
-
hoveringComponent,
|
3352
|
-
setHoveringComponent,
|
3353
|
-
registerZoneArea,
|
3354
|
-
areasWithZones,
|
3355
|
-
registerZone,
|
3356
|
-
unregisterZone,
|
3357
|
-
activeZones
|
3358
|
-
}, value),
|
3359
|
-
[value, hoveringComponent, areasWithZones, activeZones]
|
3360
|
-
);
|
3361
|
-
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_jsx_runtime20.Fragment, { children: memoValue && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(dropZoneContext.Provider, { value: memoValue, children }) });
|
3362
|
-
};
|
3363
|
-
|
3364
|
-
// lib/insert.ts
|
3407
|
+
// components/DropZone/lib/use-min-empty-height.ts
|
3365
3408
|
init_react_import();
|
3366
|
-
var
|
3367
|
-
const result = Array.from(list);
|
3368
|
-
result.splice(index, 0, item);
|
3369
|
-
return result;
|
3370
|
-
};
|
3371
|
-
|
3372
|
-
// components/DropZone/use-min-empty-height.ts
|
3373
|
-
init_react_import();
|
3374
|
-
var import_react22 = require("react");
|
3409
|
+
var import_react23 = require("react");
|
3375
3410
|
var useMinEmptyHeight = ({
|
3376
|
-
draggedItem,
|
3377
3411
|
zoneCompound,
|
3378
3412
|
userMinEmptyHeight,
|
3379
3413
|
ref
|
3380
3414
|
}) => {
|
3381
|
-
const [prevHeight, setPrevHeight] = (0,
|
3382
|
-
const [isAnimating, setIsAnimating] = (0,
|
3383
|
-
(
|
3415
|
+
const [prevHeight, setPrevHeight] = (0, import_react23.useState)(0);
|
3416
|
+
const [isAnimating, setIsAnimating] = (0, import_react23.useState)(false);
|
3417
|
+
const { draggedItem, isZone } = useContextStore(ZoneStoreContext, (s) => {
|
3418
|
+
var _a, _b;
|
3419
|
+
return {
|
3420
|
+
draggedItem: ((_a = s.draggedItem) == null ? void 0 : _a.data.zone) === zoneCompound ? s.draggedItem : null,
|
3421
|
+
isZone: ((_b = s.draggedItem) == null ? void 0 : _b.data.zone) === zoneCompound
|
3422
|
+
};
|
3423
|
+
});
|
3424
|
+
(0, import_react23.useEffect)(() => {
|
3384
3425
|
if (draggedItem && ref.current) {
|
3385
|
-
|
3386
|
-
if (componentData.zone === zoneCompound) {
|
3426
|
+
if (isZone) {
|
3387
3427
|
const rect = ref.current.getBoundingClientRect();
|
3388
3428
|
setPrevHeight(rect.height);
|
3389
3429
|
setIsAnimating(true);
|
@@ -3413,14 +3453,129 @@ function assignRefs(refs, node) {
|
|
3413
3453
|
});
|
3414
3454
|
}
|
3415
3455
|
|
3416
|
-
// components/DropZone/
|
3417
|
-
|
3418
|
-
var
|
3419
|
-
|
3456
|
+
// components/DropZone/lib/use-content-with-preview.ts
|
3457
|
+
init_react_import();
|
3458
|
+
var import_react26 = require("react");
|
3459
|
+
|
3460
|
+
// lib/dnd/use-rendered-callback.ts
|
3461
|
+
init_react_import();
|
3462
|
+
var import_react24 = require("@dnd-kit/react");
|
3463
|
+
var import_react25 = require("react");
|
3464
|
+
function useRenderedCallback(callback, deps) {
|
3465
|
+
const manager = (0, import_react24.useDragDropManager)();
|
3466
|
+
return (0, import_react25.useCallback)(
|
3467
|
+
(...args) => __async(this, null, function* () {
|
3468
|
+
yield manager == null ? void 0 : manager.renderer.rendering;
|
3469
|
+
return callback(...args);
|
3470
|
+
}),
|
3471
|
+
[...deps, manager]
|
3472
|
+
);
|
3473
|
+
}
|
3474
|
+
|
3475
|
+
// lib/insert.ts
|
3476
|
+
init_react_import();
|
3477
|
+
var insert = (list, index, item) => {
|
3478
|
+
const result = Array.from(list);
|
3479
|
+
result.splice(index, 0, item);
|
3480
|
+
return result;
|
3481
|
+
};
|
3482
|
+
|
3483
|
+
// components/DropZone/lib/use-content-with-preview.ts
|
3484
|
+
var useContentWithPreview = (content, zoneCompound) => {
|
3485
|
+
const { draggedItemId, preview, previewExists } = useContextStore(
|
3486
|
+
ZoneStoreContext,
|
3487
|
+
(s) => {
|
3488
|
+
var _a;
|
3489
|
+
return {
|
3490
|
+
draggedItemId: (_a = s.draggedItem) == null ? void 0 : _a.id,
|
3491
|
+
preview: s.previewIndex[zoneCompound],
|
3492
|
+
previewExists: Object.keys(s.previewIndex || {}).length > 0
|
3493
|
+
};
|
3494
|
+
}
|
3495
|
+
);
|
3496
|
+
const [contentWithPreview, setContentWithPreview] = (0, import_react26.useState)(content);
|
3497
|
+
const updateContent = useRenderedCallback(
|
3498
|
+
(content2, preview2) => {
|
3499
|
+
if (preview2) {
|
3500
|
+
if (preview2.type === "insert") {
|
3501
|
+
setContentWithPreview(
|
3502
|
+
insert(
|
3503
|
+
content2.filter((item) => item.props.id !== preview2.props.id),
|
3504
|
+
preview2.index,
|
3505
|
+
{
|
3506
|
+
type: "preview",
|
3507
|
+
props: { id: preview2.props.id }
|
3508
|
+
}
|
3509
|
+
)
|
3510
|
+
);
|
3511
|
+
} else {
|
3512
|
+
setContentWithPreview(
|
3513
|
+
insert(
|
3514
|
+
content2.filter((item) => item.props.id !== preview2.props.id),
|
3515
|
+
preview2.index,
|
3516
|
+
{
|
3517
|
+
type: preview2.componentType,
|
3518
|
+
props: preview2.props
|
3519
|
+
}
|
3520
|
+
)
|
3521
|
+
);
|
3522
|
+
}
|
3523
|
+
} else {
|
3524
|
+
setContentWithPreview(
|
3525
|
+
previewExists ? content2.filter((item) => item.props.id !== draggedItemId) : content2
|
3526
|
+
);
|
3527
|
+
}
|
3528
|
+
},
|
3529
|
+
[draggedItemId, previewExists]
|
3530
|
+
);
|
3531
|
+
(0, import_react26.useEffect)(() => {
|
3532
|
+
updateContent(content, preview);
|
3533
|
+
}, [content, preview]);
|
3534
|
+
return contentWithPreview;
|
3535
|
+
};
|
3536
|
+
|
3537
|
+
// components/DropZone/lib/use-drag-axis.ts
|
3538
|
+
init_react_import();
|
3539
|
+
var import_react27 = require("react");
|
3420
3540
|
var GRID_DRAG_AXIS = "dynamic";
|
3421
3541
|
var FLEX_ROW_DRAG_AXIS = "x";
|
3422
3542
|
var DEFAULT_DRAG_AXIS = "y";
|
3423
|
-
var
|
3543
|
+
var useDragAxis = (ref, collisionAxis) => {
|
3544
|
+
const { status } = useAppContext();
|
3545
|
+
const [dragAxis, setDragAxis] = (0, import_react27.useState)(
|
3546
|
+
collisionAxis || DEFAULT_DRAG_AXIS
|
3547
|
+
);
|
3548
|
+
const calculateDragAxis = (0, import_react27.useCallback)(() => {
|
3549
|
+
if (ref.current) {
|
3550
|
+
const computedStyle = window.getComputedStyle(ref.current);
|
3551
|
+
if (computedStyle.display === "grid") {
|
3552
|
+
setDragAxis(GRID_DRAG_AXIS);
|
3553
|
+
} else if (computedStyle.display === "flex" && computedStyle.flexDirection === "row") {
|
3554
|
+
setDragAxis(FLEX_ROW_DRAG_AXIS);
|
3555
|
+
} else {
|
3556
|
+
setDragAxis(DEFAULT_DRAG_AXIS);
|
3557
|
+
}
|
3558
|
+
}
|
3559
|
+
}, [ref.current]);
|
3560
|
+
(0, import_react27.useEffect)(() => {
|
3561
|
+
const onViewportChange = () => {
|
3562
|
+
calculateDragAxis();
|
3563
|
+
};
|
3564
|
+
window.addEventListener("viewportchange", onViewportChange);
|
3565
|
+
return () => {
|
3566
|
+
window.removeEventListener("viewportchange", onViewportChange);
|
3567
|
+
};
|
3568
|
+
}, []);
|
3569
|
+
(0, import_react27.useEffect)(calculateDragAxis, [status, collisionAxis]);
|
3570
|
+
return [dragAxis, calculateDragAxis];
|
3571
|
+
};
|
3572
|
+
|
3573
|
+
// components/DropZone/index.tsx
|
3574
|
+
var import_jsx_runtime21 = require("react/jsx-runtime");
|
3575
|
+
var getClassName17 = get_class_name_factory_default("DropZone", styles_module_default12);
|
3576
|
+
var getRandomColor = () => `#${Math.floor(Math.random() * 16777215).toString(16)}`;
|
3577
|
+
var RENDER_DEBUG = false;
|
3578
|
+
var DropZoneEdit = (0, import_react28.forwardRef)(
|
3424
3579
|
function DropZoneEdit2({
|
3425
3580
|
zone,
|
3426
3581
|
allow,
|
@@ -3431,31 +3586,50 @@ var DropZoneEdit = (0, import_react23.forwardRef)(
|
|
3431
3586
|
collisionAxis
|
3432
3587
|
}, userRef) {
|
3433
3588
|
const appContext2 = useAppContext();
|
3434
|
-
const ctx = (0,
|
3589
|
+
const ctx = (0, import_react28.useContext)(dropZoneContext);
|
3435
3590
|
const {
|
3436
3591
|
// These all need setting via context
|
3437
3592
|
data,
|
3438
3593
|
config,
|
3439
3594
|
areaId,
|
3440
|
-
draggedItem,
|
3441
3595
|
registerZoneArea,
|
3442
3596
|
depth,
|
3443
3597
|
registerLocalZone,
|
3444
3598
|
unregisterLocalZone,
|
3445
|
-
deepestZone = rootDroppableId,
|
3446
|
-
deepestArea,
|
3447
|
-
nextDeepestArea,
|
3448
3599
|
path = [],
|
3449
3600
|
activeZones
|
3450
3601
|
} = ctx;
|
3451
|
-
const { itemSelector } = appContext2.state.ui;
|
3452
3602
|
let zoneCompound = rootDroppableId;
|
3453
|
-
|
3603
|
+
if (areaId) {
|
3604
|
+
if (zone !== rootDroppableId) {
|
3605
|
+
zoneCompound = `${areaId}:${zone}`;
|
3606
|
+
}
|
3607
|
+
}
|
3608
|
+
const isRootZone = zoneCompound === rootDroppableId || zone === rootDroppableId || areaId === "root";
|
3609
|
+
const {
|
3610
|
+
isDeepestZone,
|
3611
|
+
inNextDeepestArea,
|
3612
|
+
draggedComponentType,
|
3613
|
+
userIsDragging,
|
3614
|
+
preview
|
3615
|
+
} = useContextStore(ZoneStoreContext, (s) => {
|
3616
|
+
var _a, _b, _c;
|
3617
|
+
return {
|
3618
|
+
isDeepestZone: (_a = s.zoneDepthIndex[zoneCompound]) != null ? _a : false,
|
3619
|
+
inNextDeepestArea: s.nextAreaDepthIndex[areaId || ""],
|
3620
|
+
draggedItemId: (_b = s.draggedItem) == null ? void 0 : _b.id,
|
3621
|
+
draggedComponentType: (_c = s.draggedItem) == null ? void 0 : _c.data.componentType,
|
3622
|
+
userIsDragging: !!s.draggedItem,
|
3623
|
+
preview: s.previewIndex[zoneCompound]
|
3624
|
+
};
|
3625
|
+
});
|
3626
|
+
const { itemSelector } = appContext2.state.ui;
|
3627
|
+
(0, import_react28.useEffect)(() => {
|
3454
3628
|
if (areaId && registerZoneArea) {
|
3455
3629
|
registerZoneArea(areaId);
|
3456
3630
|
}
|
3457
3631
|
}, [areaId]);
|
3458
|
-
(0,
|
3632
|
+
(0, import_react28.useEffect)(() => {
|
3459
3633
|
if (ctx == null ? void 0 : ctx.registerZone) {
|
3460
3634
|
ctx == null ? void 0 : ctx.registerZone(zoneCompound);
|
3461
3635
|
}
|
@@ -3465,25 +3639,18 @@ var DropZoneEdit = (0, import_react23.forwardRef)(
|
|
3465
3639
|
}
|
3466
3640
|
};
|
3467
3641
|
}, []);
|
3468
|
-
|
3469
|
-
if (zone !== rootDroppableId) {
|
3470
|
-
zoneCompound = `${areaId}:${zone}`;
|
3471
|
-
}
|
3472
|
-
}
|
3473
|
-
const content = (0, import_react23.useMemo)(() => {
|
3642
|
+
const content = (0, import_react28.useMemo)(() => {
|
3474
3643
|
if (areaId && zone !== rootDroppableId) {
|
3475
3644
|
return setupZone(data, zoneCompound).zones[zoneCompound];
|
3476
3645
|
}
|
3477
3646
|
return data.content || [];
|
3478
3647
|
}, [data, zoneCompound]);
|
3479
|
-
const ref = (0,
|
3480
|
-
const acceptsTarget = (0,
|
3481
|
-
(
|
3482
|
-
if (!
|
3648
|
+
const ref = (0, import_react28.useRef)(null);
|
3649
|
+
const acceptsTarget = (0, import_react28.useCallback)(
|
3650
|
+
(componentType) => {
|
3651
|
+
if (!componentType) {
|
3483
3652
|
return true;
|
3484
3653
|
}
|
3485
|
-
const data2 = target.data;
|
3486
|
-
const { componentType } = data2;
|
3487
3654
|
if (disallow) {
|
3488
3655
|
const defaultedAllow = allow || [];
|
3489
3656
|
const filteredDisallow = (disallow || []).filter(
|
@@ -3501,49 +3668,26 @@ var DropZoneEdit = (0, import_react23.forwardRef)(
|
|
3501
3668
|
},
|
3502
3669
|
[allow, disallow]
|
3503
3670
|
);
|
3504
|
-
(0,
|
3671
|
+
(0, import_react28.useEffect)(() => {
|
3505
3672
|
if (registerLocalZone) {
|
3506
|
-
registerLocalZone(zoneCompound, acceptsTarget(
|
3673
|
+
registerLocalZone(zoneCompound, acceptsTarget(draggedComponentType));
|
3507
3674
|
}
|
3508
3675
|
return () => {
|
3509
3676
|
if (unregisterLocalZone) {
|
3510
3677
|
unregisterLocalZone(zoneCompound);
|
3511
3678
|
}
|
3512
3679
|
};
|
3513
|
-
}, [
|
3514
|
-
const
|
3515
|
-
const hoveringOverArea = nextDeepestArea ? nextDeepestArea === areaId : isRootZone;
|
3516
|
-
const userIsDragging = !!draggedItem;
|
3680
|
+
}, [draggedComponentType, zoneCompound]);
|
3681
|
+
const hoveringOverArea = inNextDeepestArea || isRootZone;
|
3517
3682
|
let isEnabled = true;
|
3518
|
-
if (
|
3519
|
-
isEnabled =
|
3683
|
+
if (userIsDragging) {
|
3684
|
+
isEnabled = isDeepestZone;
|
3520
3685
|
}
|
3521
3686
|
if (isEnabled) {
|
3522
|
-
isEnabled = acceptsTarget(
|
3523
|
-
}
|
3524
|
-
const
|
3525
|
-
const
|
3526
|
-
const contentWithPreview = (0, import_react23.useMemo)(() => {
|
3527
|
-
let contentWithPreview2 = preview ? content.filter((item) => item.props.id !== preview.props.id) : content;
|
3528
|
-
if (previewInZone) {
|
3529
|
-
contentWithPreview2 = content.filter(
|
3530
|
-
(item) => item.props.id !== preview.props.id
|
3531
|
-
);
|
3532
|
-
if (preview.type === "insert") {
|
3533
|
-
contentWithPreview2 = insert(contentWithPreview2, preview.index, {
|
3534
|
-
type: "preview",
|
3535
|
-
props: { id: preview.props.id }
|
3536
|
-
});
|
3537
|
-
} else {
|
3538
|
-
contentWithPreview2 = insert(contentWithPreview2, preview.index, {
|
3539
|
-
type: preview.componentType,
|
3540
|
-
props: preview.props
|
3541
|
-
});
|
3542
|
-
}
|
3543
|
-
}
|
3544
|
-
return contentWithPreview2;
|
3545
|
-
}, [preview, content]);
|
3546
|
-
const isDropEnabled = isEnabled && (previewInZone ? contentWithPreview.length === 1 : contentWithPreview.length === 0);
|
3687
|
+
isEnabled = acceptsTarget(draggedComponentType);
|
3688
|
+
}
|
3689
|
+
const contentWithPreview = useContentWithPreview(content, zoneCompound);
|
3690
|
+
const isDropEnabled = isEnabled && (preview ? contentWithPreview.length === 1 : contentWithPreview.length === 0);
|
3547
3691
|
const droppableConfig = {
|
3548
3692
|
id: zoneCompound,
|
3549
3693
|
collisionPriority: isEnabled ? depth : 0,
|
@@ -3553,45 +3697,20 @@ var DropZoneEdit = (0, import_react23.forwardRef)(
|
|
3553
3697
|
data: {
|
3554
3698
|
areaId,
|
3555
3699
|
depth,
|
3556
|
-
isDroppableTarget: acceptsTarget(
|
3700
|
+
isDroppableTarget: acceptsTarget(draggedComponentType),
|
3557
3701
|
path
|
3558
3702
|
}
|
3559
3703
|
};
|
3560
3704
|
const { ref: dropRef } = useDroppableSafe(droppableConfig);
|
3561
3705
|
const selectedItem = itemSelector ? getItem(itemSelector, data) : null;
|
3562
3706
|
const isAreaSelected = selectedItem && areaId === selectedItem.props.id;
|
3563
|
-
const [dragAxis
|
3564
|
-
collisionAxis || DEFAULT_DRAG_AXIS
|
3565
|
-
);
|
3566
|
-
const calculateDragAxis = (0, import_react23.useCallback)(() => {
|
3567
|
-
if (ref.current) {
|
3568
|
-
const computedStyle = window.getComputedStyle(ref.current);
|
3569
|
-
if (computedStyle.display === "grid") {
|
3570
|
-
setDragAxis(GRID_DRAG_AXIS);
|
3571
|
-
} else if (computedStyle.display === "flex" && computedStyle.flexDirection === "row") {
|
3572
|
-
setDragAxis(FLEX_ROW_DRAG_AXIS);
|
3573
|
-
} else {
|
3574
|
-
setDragAxis(DEFAULT_DRAG_AXIS);
|
3575
|
-
}
|
3576
|
-
}
|
3577
|
-
}, [ref.current]);
|
3578
|
-
(0, import_react23.useEffect)(calculateDragAxis, [appContext2.status, collisionAxis]);
|
3579
|
-
(0, import_react23.useEffect)(() => {
|
3580
|
-
const onViewportChange = () => {
|
3581
|
-
calculateDragAxis();
|
3582
|
-
};
|
3583
|
-
window.addEventListener("viewportchange", onViewportChange);
|
3584
|
-
return () => {
|
3585
|
-
window.removeEventListener("viewportchange", onViewportChange);
|
3586
|
-
};
|
3587
|
-
}, []);
|
3707
|
+
const [dragAxis] = useDragAxis(ref, collisionAxis);
|
3588
3708
|
const [minEmptyHeight, isAnimating] = useMinEmptyHeight({
|
3589
|
-
draggedItem,
|
3590
3709
|
zoneCompound,
|
3591
3710
|
userMinEmptyHeight,
|
3592
3711
|
ref
|
3593
3712
|
});
|
3594
|
-
return /* @__PURE__ */ (0, import_jsx_runtime21.
|
3713
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
3595
3714
|
"div",
|
3596
3715
|
{
|
3597
3716
|
className: `${getClassName17({
|
@@ -3611,88 +3730,83 @@ var DropZoneEdit = (0, import_react23.forwardRef)(
|
|
3611
3730
|
"data-puck-dropzone": zoneCompound,
|
3612
3731
|
"data-puck-dnd": zoneCompound,
|
3613
3732
|
style: __spreadProps(__spreadValues({}, style), {
|
3614
|
-
"--min-empty-height": `${minEmptyHeight}px
|
3733
|
+
"--min-empty-height": `${minEmptyHeight}px`,
|
3734
|
+
backgroundColor: RENDER_DEBUG ? getRandomColor() : void 0
|
3615
3735
|
}),
|
3616
|
-
children:
|
3617
|
-
|
3618
|
-
|
3619
|
-
|
3620
|
-
|
3621
|
-
|
3622
|
-
|
3623
|
-
|
3624
|
-
|
3625
|
-
|
3626
|
-
|
3627
|
-
|
3736
|
+
children: contentWithPreview.map((item, i) => {
|
3737
|
+
var _a, _b, _c, _d, _e;
|
3738
|
+
const componentId = item.props.id;
|
3739
|
+
const puckProps = {
|
3740
|
+
renderDropZone: DropZone,
|
3741
|
+
isEditing: true,
|
3742
|
+
dragRef: null
|
3743
|
+
};
|
3744
|
+
const defaultedProps = __spreadProps(__spreadValues(__spreadValues({}, (_a = config.components[item.type]) == null ? void 0 : _a.defaultProps), item.props), {
|
3745
|
+
puck: puckProps,
|
3746
|
+
editMode: true
|
3747
|
+
// DEPRECATED
|
3748
|
+
});
|
3749
|
+
const isSelected = (selectedItem == null ? void 0 : selectedItem.props.id) === componentId || false;
|
3750
|
+
let Render2 = config.components[item.type] && item.type !== "preview" ? config.components[item.type].render : () => /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { style: { padding: 48, textAlign: "center" }, children: [
|
3751
|
+
"No configuration for ",
|
3752
|
+
item.type
|
3753
|
+
] });
|
3754
|
+
const componentConfig = config.components[item.type];
|
3755
|
+
let componentType = item.type;
|
3756
|
+
let label = (_b = componentConfig == null ? void 0 : componentConfig["label"]) != null ? _b : item.type.toString();
|
3757
|
+
if (item.type === "preview" && preview) {
|
3758
|
+
let Preview4 = function() {
|
3759
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(DrawerItemInner, { name: label, children: appContext2.overrides.componentItem });
|
3628
3760
|
};
|
3629
|
-
|
3630
|
-
|
3631
|
-
|
3632
|
-
|
3633
|
-
|
3634
|
-
|
3635
|
-
|
3636
|
-
|
3637
|
-
|
3638
|
-
|
3639
|
-
|
3640
|
-
|
3641
|
-
|
3642
|
-
|
3643
|
-
|
3644
|
-
|
3645
|
-
|
3646
|
-
|
3647
|
-
|
3648
|
-
|
3649
|
-
|
3650
|
-
|
3651
|
-
|
3652
|
-
|
3653
|
-
|
3654
|
-
|
3655
|
-
|
3656
|
-
|
3657
|
-
|
3658
|
-
id: componentId,
|
3659
|
-
componentType,
|
3660
|
-
zoneCompound,
|
3661
|
-
depth: depth + 1,
|
3662
|
-
index: i,
|
3663
|
-
isLoading: ((_e = appContext2.componentState[componentId]) == null ? void 0 : _e.loadingCount) > 0,
|
3664
|
-
isSelected,
|
3665
|
-
label,
|
3666
|
-
isEnabled,
|
3667
|
-
autoDragAxis: dragAxis,
|
3668
|
-
userDragAxis: collisionAxis,
|
3669
|
-
inDroppableZone: acceptsTarget(draggedItem),
|
3670
|
-
children: (dragRef) => (componentConfig == null ? void 0 : componentConfig.inline) ? /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
3671
|
-
Render2,
|
3672
|
-
__spreadProps(__spreadValues({}, defaultedProps), {
|
3673
|
-
puck: __spreadProps(__spreadValues({}, defaultedProps.puck), {
|
3674
|
-
dragRef
|
3675
|
-
})
|
3761
|
+
var Preview3 = Preview4;
|
3762
|
+
componentType = preview.componentType;
|
3763
|
+
label = (_d = (_c = config.components[componentType]) == null ? void 0 : _c.label) != null ? _d : preview.componentType;
|
3764
|
+
Render2 = Preview4;
|
3765
|
+
}
|
3766
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
3767
|
+
DropZoneProvider,
|
3768
|
+
{
|
3769
|
+
value: __spreadProps(__spreadValues({}, ctx), { path: [...path, zoneCompound] }),
|
3770
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
3771
|
+
DraggableComponent,
|
3772
|
+
{
|
3773
|
+
id: componentId,
|
3774
|
+
componentType,
|
3775
|
+
zoneCompound,
|
3776
|
+
depth: depth + 1,
|
3777
|
+
index: i,
|
3778
|
+
isLoading: ((_e = appContext2.componentState[componentId]) == null ? void 0 : _e.loadingCount) > 0,
|
3779
|
+
isSelected,
|
3780
|
+
label,
|
3781
|
+
isEnabled,
|
3782
|
+
autoDragAxis: dragAxis,
|
3783
|
+
userDragAxis: collisionAxis,
|
3784
|
+
inDroppableZone: acceptsTarget(draggedComponentType),
|
3785
|
+
children: (dragRef) => (componentConfig == null ? void 0 : componentConfig.inline) ? /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
3786
|
+
Render2,
|
3787
|
+
__spreadProps(__spreadValues({}, defaultedProps), {
|
3788
|
+
puck: __spreadProps(__spreadValues({}, defaultedProps.puck), {
|
3789
|
+
dragRef
|
3676
3790
|
})
|
3677
|
-
|
3678
|
-
}
|
3679
|
-
|
3680
|
-
|
3681
|
-
|
3682
|
-
|
3683
|
-
|
3684
|
-
|
3791
|
+
})
|
3792
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { ref: dragRef, children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Render2, __spreadValues({}, defaultedProps)) })
|
3793
|
+
}
|
3794
|
+
)
|
3795
|
+
},
|
3796
|
+
componentId
|
3797
|
+
);
|
3798
|
+
})
|
3685
3799
|
}
|
3686
3800
|
);
|
3687
3801
|
}
|
3688
3802
|
);
|
3689
|
-
var DropZoneRender = (0,
|
3803
|
+
var DropZoneRender = (0, import_react28.forwardRef)(
|
3690
3804
|
function DropZoneRender2({ className, style, zone }, ref) {
|
3691
|
-
const ctx = (0,
|
3805
|
+
const ctx = (0, import_react28.useContext)(dropZoneContext);
|
3692
3806
|
const { data, areaId = "root", config } = ctx || {};
|
3693
3807
|
let zoneCompound = rootDroppableId;
|
3694
3808
|
let content = (data == null ? void 0 : data.content) || [];
|
3695
|
-
(0,
|
3809
|
+
(0, import_react28.useEffect)(() => {
|
3696
3810
|
if (ctx == null ? void 0 : ctx.registerZone) {
|
3697
3811
|
ctx == null ? void 0 : ctx.registerZone(zoneCompound);
|
3698
3812
|
}
|
@@ -3736,9 +3850,9 @@ var DropZoneRender = (0, import_react23.forwardRef)(
|
|
3736
3850
|
}) });
|
3737
3851
|
}
|
3738
3852
|
);
|
3739
|
-
var DropZone = (0,
|
3853
|
+
var DropZone = (0, import_react28.forwardRef)(
|
3740
3854
|
function DropZone2(props, ref) {
|
3741
|
-
const ctx = (0,
|
3855
|
+
const ctx = (0, import_react28.useContext)(dropZoneContext);
|
3742
3856
|
if ((ctx == null ? void 0 : ctx.mode) === "edit") {
|
3743
3857
|
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_jsx_runtime21.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(DropZoneEdit, __spreadProps(__spreadValues({}, props), { ref })) });
|
3744
3858
|
}
|
@@ -3758,7 +3872,7 @@ var getZoneId = (zoneCompound) => {
|
|
3758
3872
|
return [rootDroppableId, zoneCompound];
|
3759
3873
|
};
|
3760
3874
|
|
3761
|
-
//
|
3875
|
+
// lib/dnd/NestedDroppablePlugin.ts
|
3762
3876
|
init_react_import();
|
3763
3877
|
var import_abstract9 = require("@dnd-kit/abstract");
|
3764
3878
|
var import_state = require("@dnd-kit/state");
|
@@ -3800,7 +3914,7 @@ var getFrame = () => {
|
|
3800
3914
|
return (frameEl == null ? void 0 : frameEl.ownerDocument) || document;
|
3801
3915
|
};
|
3802
3916
|
|
3803
|
-
//
|
3917
|
+
// lib/dnd/NestedDroppablePlugin.ts
|
3804
3918
|
var depthSort = (candidates) => {
|
3805
3919
|
return candidates.sort((a, b) => {
|
3806
3920
|
const aData = a.data;
|
@@ -3915,9 +4029,7 @@ var findDeepestCandidate = (position, manager, ownerDocument) => {
|
|
3915
4029
|
area: null
|
3916
4030
|
};
|
3917
4031
|
};
|
3918
|
-
var createNestedDroppablePlugin = ({
|
3919
|
-
onChange
|
3920
|
-
}) => class NestedDroppablePlugin extends import_abstract9.Plugin {
|
4032
|
+
var createNestedDroppablePlugin = ({ onChange }, id) => class NestedDroppablePlugin extends import_abstract9.Plugin {
|
3921
4033
|
constructor(manager, options) {
|
3922
4034
|
super(manager);
|
3923
4035
|
if (typeof window === "undefined") {
|
@@ -3931,10 +4043,17 @@ var createNestedDroppablePlugin = ({
|
|
3931
4043
|
};
|
3932
4044
|
const target = event.originalTarget || event.target;
|
3933
4045
|
const ownerDocument = target == null ? void 0 : target.ownerDocument;
|
3934
|
-
|
3935
|
-
|
3936
|
-
|
4046
|
+
const elements = document.elementsFromPoint(
|
4047
|
+
event.clientX,
|
4048
|
+
event.clientY
|
3937
4049
|
);
|
4050
|
+
const overEl = elements.some((el) => el.id === id);
|
4051
|
+
if (overEl) {
|
4052
|
+
onChange(
|
4053
|
+
findDeepestCandidate(position, manager, ownerDocument),
|
4054
|
+
manager
|
4055
|
+
);
|
4056
|
+
}
|
3938
4057
|
};
|
3939
4058
|
const handleMoveThrottled = throttle(handleMove, 50);
|
3940
4059
|
const handlePointerMove = (event) => {
|
@@ -4351,7 +4470,7 @@ var insertComponent = (componentType, zone, index, {
|
|
4351
4470
|
var import_use_debounce2 = require("use-debounce");
|
4352
4471
|
var import_utilities2 = require("@dnd-kit/dom/utilities");
|
4353
4472
|
|
4354
|
-
//
|
4473
|
+
// lib/dnd/PointerSensor.ts
|
4355
4474
|
init_react_import();
|
4356
4475
|
var import_state3 = require("@dnd-kit/state");
|
4357
4476
|
var import_abstract10 = require("@dnd-kit/abstract");
|
@@ -4613,13 +4732,15 @@ function patchWindow(window2) {
|
|
4613
4732
|
}
|
4614
4733
|
|
4615
4734
|
// components/DragDropContext/index.tsx
|
4735
|
+
var import_zustand3 = require("zustand");
|
4616
4736
|
var import_jsx_runtime22 = require("react/jsx-runtime");
|
4617
|
-
var
|
4737
|
+
var DEBUG3 = false;
|
4738
|
+
var dragListenerContext = (0, import_react30.createContext)({
|
4618
4739
|
dragListeners: {}
|
4619
4740
|
});
|
4620
4741
|
function useDragListener(type, fn, deps = []) {
|
4621
|
-
const { setDragListeners } = (0,
|
4622
|
-
(0,
|
4742
|
+
const { setDragListeners } = (0, import_react30.useContext)(dragListenerContext);
|
4743
|
+
(0, import_react30.useEffect)(() => {
|
4623
4744
|
if (setDragListeners) {
|
4624
4745
|
setDragListeners((old) => __spreadProps(__spreadValues({}, old), {
|
4625
4746
|
[type]: [...old[type] || [], fn]
|
@@ -4627,80 +4748,147 @@ function useDragListener(type, fn, deps = []) {
|
|
4627
4748
|
}
|
4628
4749
|
}, deps);
|
4629
4750
|
}
|
4630
|
-
var previewContext = (0, import_react25.createContext)(null);
|
4631
4751
|
var AREA_CHANGE_DEBOUNCE_MS = 100;
|
4752
|
+
var useTempDisableFallback = (timeout3) => {
|
4753
|
+
const lastFallbackDisable = (0, import_react30.useRef)(null);
|
4754
|
+
return (0, import_react30.useCallback)((manager) => {
|
4755
|
+
collisionStore.setState({ fallbackEnabled: false });
|
4756
|
+
const fallbackId = generateId();
|
4757
|
+
lastFallbackDisable.current = fallbackId;
|
4758
|
+
setTimeout(() => {
|
4759
|
+
if (lastFallbackDisable.current === fallbackId) {
|
4760
|
+
collisionStore.setState({ fallbackEnabled: true });
|
4761
|
+
manager.collisionObserver.forceUpdate(true);
|
4762
|
+
}
|
4763
|
+
}, timeout3);
|
4764
|
+
}, []);
|
4765
|
+
};
|
4632
4766
|
var DragDropContextClient = ({
|
4633
4767
|
children,
|
4634
4768
|
disableAutoScroll
|
4635
4769
|
}) => {
|
4636
4770
|
const { state, config, dispatch, resolveData } = useAppContext();
|
4637
|
-
const
|
4638
|
-
const previewRef = (0, import_react25.useRef)(null);
|
4771
|
+
const id = (0, import_react30.useId)();
|
4639
4772
|
const { data } = state;
|
4640
|
-
const
|
4641
|
-
const
|
4642
|
-
const
|
4643
|
-
|
4644
|
-
|
4773
|
+
const debouncedParamsRef = (0, import_react30.useRef)(null);
|
4774
|
+
const tempDisableFallback = useTempDisableFallback(100);
|
4775
|
+
const [zoneStore] = (0, import_react30.useState)(
|
4776
|
+
() => (0, import_zustand3.createStore)(() => ({
|
4777
|
+
zoneDepthIndex: {},
|
4778
|
+
nextZoneDepthIndex: {},
|
4779
|
+
areaDepthIndex: {},
|
4780
|
+
nextAreaDepthIndex: {},
|
4781
|
+
draggedItem: null,
|
4782
|
+
previewIndex: {}
|
4783
|
+
}))
|
4784
|
+
);
|
4785
|
+
const getChanged2 = (0, import_react30.useCallback)(
|
4786
|
+
(params, id2) => {
|
4787
|
+
const { zoneDepthIndex = {}, areaDepthIndex = {} } = zoneStore.getState() || {};
|
4788
|
+
const stateHasZone = Object.keys(zoneDepthIndex).length > 0;
|
4789
|
+
const stateHasArea = Object.keys(areaDepthIndex).length > 0;
|
4790
|
+
let zoneChanged = false;
|
4791
|
+
let areaChanged = false;
|
4792
|
+
if (params.zone && !zoneDepthIndex[params.zone]) {
|
4793
|
+
zoneChanged = true;
|
4794
|
+
} else if (!params.zone && stateHasZone) {
|
4795
|
+
zoneChanged = true;
|
4796
|
+
}
|
4797
|
+
if (params.area && !areaDepthIndex[params.area]) {
|
4798
|
+
areaChanged = true;
|
4799
|
+
} else if (!params.area && stateHasArea) {
|
4800
|
+
areaChanged = true;
|
4801
|
+
}
|
4802
|
+
return { zoneChanged, areaChanged };
|
4803
|
+
},
|
4804
|
+
[zoneStore]
|
4805
|
+
);
|
4806
|
+
const setDeepestAndCollide = (0, import_react30.useCallback)(
|
4645
4807
|
(params, manager) => {
|
4646
|
-
|
4808
|
+
const { zoneChanged, areaChanged } = getChanged2(params, id);
|
4809
|
+
if (!zoneChanged && !areaChanged) return;
|
4810
|
+
zoneStore.setState({
|
4811
|
+
zoneDepthIndex: params.zone ? { [params.zone]: true } : {},
|
4812
|
+
areaDepthIndex: params.area ? { [params.area]: true } : {}
|
4813
|
+
});
|
4814
|
+
tempDisableFallback(manager);
|
4647
4815
|
setTimeout(() => {
|
4648
4816
|
manager.collisionObserver.forceUpdate(true);
|
4649
4817
|
}, 50);
|
4650
4818
|
debouncedParamsRef.current = null;
|
4651
4819
|
},
|
4652
|
-
[]
|
4820
|
+
[zoneStore]
|
4653
4821
|
);
|
4654
4822
|
const setDeepestDb = (0, import_use_debounce2.useDebouncedCallback)(
|
4655
4823
|
setDeepestAndCollide,
|
4656
4824
|
AREA_CHANGE_DEBOUNCE_MS
|
4657
4825
|
);
|
4658
|
-
(0, import_react25.useEffect)(() => {
|
4659
|
-
deepestRef.current = deepest;
|
4660
|
-
}, [deepest]);
|
4661
4826
|
const cancelDb = () => {
|
4662
4827
|
setDeepestDb.cancel();
|
4663
4828
|
debouncedParamsRef.current = null;
|
4664
4829
|
};
|
4665
|
-
|
4666
|
-
|
4667
|
-
|
4668
|
-
|
4669
|
-
|
4670
|
-
|
4671
|
-
|
4672
|
-
|
4673
|
-
|
4674
|
-
|
4675
|
-
}
|
4676
|
-
if (params.zone !== "void" && (lastParams == null ? void 0 : lastParams.zone) === "void") {
|
4677
|
-
setDeepest(params);
|
4678
|
-
manager.collisionObserver.forceUpdate(true);
|
4679
|
-
return;
|
4830
|
+
(0, import_react30.useEffect)(() => {
|
4831
|
+
if (DEBUG3) {
|
4832
|
+
zoneStore.subscribe(
|
4833
|
+
(s) => {
|
4834
|
+
var _a, _b;
|
4835
|
+
return console.log(
|
4836
|
+
s.previewIndex,
|
4837
|
+
(_a = Object.entries(s.zoneDepthIndex || {})[0]) == null ? void 0 : _a[0],
|
4838
|
+
(_b = Object.entries(s.areaDepthIndex || {})[0]) == null ? void 0 : _b[0]
|
4839
|
+
);
|
4680
4840
|
}
|
4681
|
-
|
4682
|
-
|
4683
|
-
|
4684
|
-
|
4685
|
-
|
4841
|
+
);
|
4842
|
+
}
|
4843
|
+
}, []);
|
4844
|
+
const [plugins] = (0, import_react30.useState)(() => [
|
4845
|
+
...disableAutoScroll ? import_dom.defaultPreset.plugins.filter((plugin) => plugin !== import_dom.AutoScroller) : import_dom.defaultPreset.plugins,
|
4846
|
+
createNestedDroppablePlugin(
|
4847
|
+
{
|
4848
|
+
onChange: (params, manager) => {
|
4849
|
+
const state2 = zoneStore.getState();
|
4850
|
+
const { zoneChanged, areaChanged } = getChanged2(params, id);
|
4851
|
+
const isDragging = manager.dragOperation.status.dragging;
|
4852
|
+
if (areaChanged || zoneChanged) {
|
4853
|
+
let nextZoneDepthIndex = {};
|
4854
|
+
let nextAreaDepthIndex = {};
|
4855
|
+
if (params.zone) {
|
4856
|
+
nextZoneDepthIndex = { [params.zone]: true };
|
4857
|
+
}
|
4858
|
+
if (params.area) {
|
4859
|
+
nextAreaDepthIndex = { [params.area]: true };
|
4860
|
+
}
|
4861
|
+
zoneStore.setState({ nextZoneDepthIndex, nextAreaDepthIndex });
|
4862
|
+
}
|
4863
|
+
if (params.zone !== "void" && (state2 == null ? void 0 : state2.zoneDepthIndex["void"])) {
|
4864
|
+
setDeepestAndCollide(params, manager);
|
4865
|
+
return;
|
4866
|
+
}
|
4867
|
+
if (areaChanged) {
|
4868
|
+
if (isDragging) {
|
4869
|
+
const debouncedParams = debouncedParamsRef.current;
|
4870
|
+
const isSameParams = debouncedParams && debouncedParams.area === params.area && debouncedParams.zone === params.zone;
|
4871
|
+
if (!isSameParams) {
|
4872
|
+
cancelDb();
|
4873
|
+
setDeepestDb(params, manager);
|
4874
|
+
debouncedParamsRef.current = params;
|
4875
|
+
}
|
4876
|
+
} else {
|
4686
4877
|
cancelDb();
|
4687
|
-
|
4688
|
-
debouncedParamsRef.current = params;
|
4878
|
+
setDeepestAndCollide(params, manager);
|
4689
4879
|
}
|
4690
|
-
|
4691
|
-
|
4880
|
+
return;
|
4881
|
+
}
|
4882
|
+
if (zoneChanged) {
|
4692
4883
|
setDeepestAndCollide(params, manager);
|
4693
4884
|
}
|
4694
|
-
|
4695
|
-
}
|
4696
|
-
if (zoneChanged) {
|
4697
|
-
setDeepestAndCollide(params, manager);
|
4885
|
+
cancelDb();
|
4698
4886
|
}
|
4699
|
-
|
4700
|
-
|
4701
|
-
|
4887
|
+
},
|
4888
|
+
id
|
4889
|
+
)
|
4702
4890
|
]);
|
4703
|
-
const [sensors] = (0,
|
4891
|
+
const [sensors] = (0, import_react30.useState)(() => [
|
4704
4892
|
PointerSensor.configure({
|
4705
4893
|
activationConstraints(event, source) {
|
4706
4894
|
var _a;
|
@@ -4719,11 +4907,10 @@ var DragDropContextClient = ({
|
|
4719
4907
|
}
|
4720
4908
|
})
|
4721
4909
|
]);
|
4722
|
-
const [
|
4723
|
-
const [
|
4724
|
-
const
|
4725
|
-
const
|
4726
|
-
const registerPath = (0, import_react25.useCallback)(
|
4910
|
+
const [dragListeners, setDragListeners] = (0, import_react30.useState)({});
|
4911
|
+
const [pathData, setPathData] = (0, import_react30.useState)();
|
4912
|
+
const dragMode = (0, import_react30.useRef)(null);
|
4913
|
+
const registerPath = (0, import_react30.useCallback)(
|
4727
4914
|
(selector) => {
|
4728
4915
|
const item = getItem(selector, data);
|
4729
4916
|
if (!item) {
|
@@ -4745,41 +4932,41 @@ var DragDropContextClient = ({
|
|
4745
4932
|
},
|
4746
4933
|
[data, setPathData]
|
4747
4934
|
);
|
4748
|
-
const initialSelector = (0,
|
4749
|
-
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
4935
|
+
const initialSelector = (0, import_react30.useRef)(void 0);
|
4936
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { id, children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
4750
4937
|
dragListenerContext.Provider,
|
4751
4938
|
{
|
4752
4939
|
value: {
|
4753
4940
|
dragListeners,
|
4754
4941
|
setDragListeners
|
4755
4942
|
},
|
4756
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
4757
|
-
|
4943
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
4944
|
+
import_react29.DragDropProvider,
|
4758
4945
|
{
|
4759
4946
|
plugins,
|
4760
4947
|
sensors,
|
4761
4948
|
onDragEnd: (event, manager) => {
|
4949
|
+
var _a;
|
4762
4950
|
const { source, target } = event.operation;
|
4763
|
-
deepestRef.current = null;
|
4764
4951
|
if (!source) {
|
4765
|
-
|
4952
|
+
zoneStore.setState({ draggedItem: null });
|
4766
4953
|
return;
|
4767
4954
|
}
|
4768
4955
|
const { zone, index } = source.data;
|
4769
|
-
const
|
4770
|
-
|
4956
|
+
const { previewIndex = {} } = zoneStore.getState() || {};
|
4957
|
+
const thisPreview = ((_a = previewIndex[zone]) == null ? void 0 : _a.props.id) === source.id ? previewIndex[zone] : null;
|
4771
4958
|
setTimeout(() => {
|
4772
|
-
var
|
4773
|
-
|
4959
|
+
var _a2, _b;
|
4960
|
+
zoneStore.setState({ draggedItem: null });
|
4774
4961
|
if (event.canceled || (target == null ? void 0 : target.type) === "void") {
|
4775
|
-
|
4776
|
-
(
|
4962
|
+
zoneStore.setState({ previewIndex: {} });
|
4963
|
+
(_a2 = dragListeners.dragend) == null ? void 0 : _a2.forEach((fn) => {
|
4777
4964
|
fn(event, manager);
|
4778
4965
|
});
|
4779
4966
|
return;
|
4780
4967
|
}
|
4781
4968
|
if (thisPreview) {
|
4782
|
-
|
4969
|
+
zoneStore.setState({ previewIndex: {} });
|
4783
4970
|
if (thisPreview.type === "insert") {
|
4784
4971
|
insertComponent(
|
4785
4972
|
thisPreview.componentType,
|
@@ -4814,8 +5001,9 @@ var DragDropContextClient = ({
|
|
4814
5001
|
}, 250);
|
4815
5002
|
},
|
4816
5003
|
onDragOver: (event, manager) => {
|
4817
|
-
var _a, _b, _c, _d;
|
5004
|
+
var _a, _b, _c, _d, _e;
|
4818
5005
|
event.preventDefault();
|
5006
|
+
const draggedItem = (_a = zoneStore.getState()) == null ? void 0 : _a.draggedItem;
|
4819
5007
|
if (!draggedItem) return;
|
4820
5008
|
cancelDb();
|
4821
5009
|
const { source, target } = event.operation;
|
@@ -4831,7 +5019,7 @@ var DragDropContextClient = ({
|
|
4831
5019
|
const targetData = target.data;
|
4832
5020
|
targetZone = targetData.zone;
|
4833
5021
|
targetIndex = targetData.index;
|
4834
|
-
const collisionData = (
|
5022
|
+
const collisionData = (_c = (_b = manager.dragOperation.data) == null ? void 0 : _b.collisionMap) == null ? void 0 : _c[targetId];
|
4835
5023
|
const collisionPosition = (collisionData == null ? void 0 : collisionData.direction) === "up" || (collisionData == null ? void 0 : collisionData.direction) === "left" ? "before" : "after";
|
4836
5024
|
if (targetIndex >= sourceIndex && sourceZone === targetZone) {
|
4837
5025
|
targetIndex = targetIndex - 1;
|
@@ -4843,23 +5031,26 @@ var DragDropContextClient = ({
|
|
4843
5031
|
targetZone = target.id.toString();
|
4844
5032
|
targetIndex = 0;
|
4845
5033
|
}
|
4846
|
-
if (targetId === sourceId || ((
|
5034
|
+
if (targetId === sourceId || ((_d = pathData == null ? void 0 : pathData[target.id]) == null ? void 0 : _d.path.find((path) => {
|
4847
5035
|
const [pathId] = path.split(":");
|
4848
5036
|
return pathId === sourceId;
|
4849
5037
|
}))) {
|
4850
5038
|
return;
|
4851
5039
|
}
|
4852
5040
|
if (dragMode.current === "new") {
|
4853
|
-
|
4854
|
-
|
4855
|
-
|
4856
|
-
|
4857
|
-
|
4858
|
-
|
4859
|
-
|
5041
|
+
zoneStore.setState({
|
5042
|
+
previewIndex: {
|
5043
|
+
[targetZone]: {
|
5044
|
+
componentType: sourceData.componentType,
|
5045
|
+
type: "insert",
|
5046
|
+
index: targetIndex,
|
5047
|
+
zone: targetZone,
|
5048
|
+
props: {
|
5049
|
+
id: source.id.toString()
|
5050
|
+
}
|
5051
|
+
}
|
4860
5052
|
}
|
4861
|
-
};
|
4862
|
-
setPreview(previewRef.current);
|
5053
|
+
});
|
4863
5054
|
} else {
|
4864
5055
|
if (!initialSelector.current) {
|
4865
5056
|
initialSelector.current = {
|
@@ -4869,17 +5060,20 @@ var DragDropContextClient = ({
|
|
4869
5060
|
}
|
4870
5061
|
const item = getItem(initialSelector.current, data);
|
4871
5062
|
if (item) {
|
4872
|
-
|
4873
|
-
|
4874
|
-
|
4875
|
-
|
4876
|
-
|
4877
|
-
|
4878
|
-
|
4879
|
-
|
5063
|
+
zoneStore.setState({
|
5064
|
+
previewIndex: {
|
5065
|
+
[targetZone]: {
|
5066
|
+
componentType: sourceData.componentType,
|
5067
|
+
type: "move",
|
5068
|
+
index: targetIndex,
|
5069
|
+
zone: targetZone,
|
5070
|
+
props: item.props
|
5071
|
+
}
|
5072
|
+
}
|
5073
|
+
});
|
4880
5074
|
}
|
4881
5075
|
}
|
4882
|
-
(
|
5076
|
+
(_e = dragListeners.dragover) == null ? void 0 : _e.forEach((fn) => {
|
4883
5077
|
fn(event, manager);
|
4884
5078
|
});
|
4885
5079
|
},
|
@@ -4889,45 +5083,61 @@ var DragDropContextClient = ({
|
|
4889
5083
|
type: "setUi",
|
4890
5084
|
ui: { itemSelector: null, isDragging: true }
|
4891
5085
|
});
|
5086
|
+
const { source } = event.operation;
|
5087
|
+
if (source && source.type !== "void") {
|
5088
|
+
const sourceData = source.data;
|
5089
|
+
const item = getItem(
|
5090
|
+
{
|
5091
|
+
zone: sourceData.zone,
|
5092
|
+
index: sourceData.index
|
5093
|
+
},
|
5094
|
+
data
|
5095
|
+
);
|
5096
|
+
if (item) {
|
5097
|
+
zoneStore.setState({
|
5098
|
+
previewIndex: {
|
5099
|
+
[sourceData.zone]: {
|
5100
|
+
componentType: sourceData.componentType,
|
5101
|
+
type: "move",
|
5102
|
+
index: sourceData.index,
|
5103
|
+
zone: sourceData.zone,
|
5104
|
+
props: item.props
|
5105
|
+
}
|
5106
|
+
}
|
5107
|
+
});
|
5108
|
+
}
|
5109
|
+
}
|
4892
5110
|
(_a = dragListeners.dragstart) == null ? void 0 : _a.forEach((fn) => {
|
4893
5111
|
fn(event, manager);
|
4894
5112
|
});
|
4895
5113
|
},
|
4896
5114
|
onBeforeDragStart: (event) => {
|
4897
5115
|
var _a;
|
4898
|
-
if (draggedItem) {
|
4899
|
-
console.warn("New drag started before previous drag cleaned up");
|
4900
|
-
}
|
4901
5116
|
const isNewComponent = ((_a = event.operation.source) == null ? void 0 : _a.data.type) === "drawer";
|
4902
5117
|
dragMode.current = isNewComponent ? "new" : "existing";
|
4903
5118
|
initialSelector.current = void 0;
|
4904
|
-
|
5119
|
+
zoneStore.setState({ draggedItem: event.operation.source });
|
4905
5120
|
},
|
4906
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
5121
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(ZoneStoreProvider, { store: zoneStore, children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
4907
5122
|
DropZoneProvider,
|
4908
5123
|
{
|
4909
5124
|
value: {
|
4910
5125
|
data,
|
4911
5126
|
config,
|
4912
|
-
draggedItem,
|
4913
5127
|
mode: "edit",
|
4914
5128
|
areaId: "root",
|
4915
5129
|
depth: 0,
|
4916
5130
|
registerPath,
|
4917
5131
|
pathData,
|
4918
|
-
deepestZone: deepest == null ? void 0 : deepest.zone,
|
4919
|
-
deepestArea: deepest == null ? void 0 : deepest.area,
|
4920
|
-
nextDeepestZone: nextDeepest == null ? void 0 : nextDeepest.zone,
|
4921
|
-
nextDeepestArea: nextDeepest == null ? void 0 : nextDeepest.area,
|
4922
5132
|
path: []
|
4923
5133
|
},
|
4924
5134
|
children
|
4925
5135
|
}
|
4926
|
-
)
|
5136
|
+
) })
|
4927
5137
|
}
|
4928
|
-
)
|
5138
|
+
)
|
4929
5139
|
}
|
4930
|
-
);
|
5140
|
+
) });
|
4931
5141
|
};
|
4932
5142
|
var DragDropContext = ({
|
4933
5143
|
children,
|
@@ -4951,7 +5161,7 @@ var DrawerItemInner = ({
|
|
4951
5161
|
dragRef,
|
4952
5162
|
isDragDisabled
|
4953
5163
|
}) => {
|
4954
|
-
const CustomInner = (0,
|
5164
|
+
const CustomInner = (0, import_react31.useMemo)(
|
4955
5165
|
() => children || (({ children: children2 }) => /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: getClassNameItem2("default"), children: children2 })),
|
4956
5166
|
[children]
|
4957
5167
|
);
|
@@ -5005,7 +5215,7 @@ var DrawerItem = ({
|
|
5005
5215
|
isDragDisabled
|
5006
5216
|
}) => {
|
5007
5217
|
const resolvedId = id || name;
|
5008
|
-
const [dynamicId, setDynamicId] = (0,
|
5218
|
+
const [dynamicId, setDynamicId] = (0, import_react31.useState)(generateId(resolvedId));
|
5009
5219
|
if (typeof index !== "undefined") {
|
5010
5220
|
console.error(
|
5011
5221
|
"Warning: The `index` prop on Drawer.Item is deprecated and no longer required."
|
@@ -5044,7 +5254,7 @@ var Drawer = ({
|
|
5044
5254
|
"Warning: The `direction` prop on Drawer is deprecated and no longer required to achieve multi-directional dragging."
|
5045
5255
|
);
|
5046
5256
|
}
|
5047
|
-
const [id] = (0,
|
5257
|
+
const [id] = (0, import_react31.useState)(generateId());
|
5048
5258
|
const { ref } = useDroppableSafe({
|
5049
5259
|
id,
|
5050
5260
|
type: "void",
|
@@ -5066,7 +5276,7 @@ Drawer.Item = DrawerItem;
|
|
5066
5276
|
|
5067
5277
|
// components/Puck/index.tsx
|
5068
5278
|
init_react_import();
|
5069
|
-
var
|
5279
|
+
var import_react47 = require("react");
|
5070
5280
|
|
5071
5281
|
// components/SidebarSection/index.tsx
|
5072
5282
|
init_react_import();
|
@@ -5077,7 +5287,7 @@ var styles_module_default13 = { "SidebarSection": "_SidebarSection_125qe_1", "Si
|
|
5077
5287
|
|
5078
5288
|
// lib/use-breadcrumbs.ts
|
5079
5289
|
init_react_import();
|
5080
|
-
var
|
5290
|
+
var import_react32 = require("react");
|
5081
5291
|
var convertPathDataToBreadcrumbs = (selectedItem, pathData, data) => {
|
5082
5292
|
const id = selectedItem ? selectedItem == null ? void 0 : selectedItem.props.id : "";
|
5083
5293
|
const currentPathData = pathData && id && pathData[id] ? __spreadValues({}, pathData[id]) : { label: "Page", path: [] };
|
@@ -5127,8 +5337,8 @@ var useBreadcrumbs = (renderCount) => {
|
|
5127
5337
|
state: { data },
|
5128
5338
|
selectedItem
|
5129
5339
|
} = useAppContext();
|
5130
|
-
const dzContext = (0,
|
5131
|
-
return (0,
|
5340
|
+
const dzContext = (0, import_react32.useContext)(dropZoneContext);
|
5341
|
+
return (0, import_react32.useMemo)(() => {
|
5132
5342
|
const breadcrumbs = convertPathDataToBreadcrumbs(
|
5133
5343
|
selectedItem,
|
5134
5344
|
dzContext == null ? void 0 : dzContext.pathData,
|
@@ -5252,7 +5462,7 @@ function MenuBar({
|
|
5252
5462
|
|
5253
5463
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/styles.module.css#css-module
|
5254
5464
|
init_react_import();
|
5255
|
-
var styles_module_default15 = { "Puck": "
|
5465
|
+
var styles_module_default15 = { "Puck": "_Puck_12s9r_19", "Puck-portal": "_Puck-portal_12s9r_24", "PuckLayout-inner": "_PuckLayout-inner_12s9r_31", "PuckLayout--mounted": "_PuckLayout--mounted_12s9r_43", "PuckLayout--leftSideBarVisible": "_PuckLayout--leftSideBarVisible_12s9r_47", "PuckLayout--rightSideBarVisible": "_PuckLayout--rightSideBarVisible_12s9r_53", "PuckLayout-mounted": "_PuckLayout-mounted_12s9r_67", "PuckLayout": "_PuckLayout_12s9r_31", "PuckLayout-header": "_PuckLayout-header_12s9r_108", "PuckLayout-headerInner": "_PuckLayout-headerInner_12s9r_117", "PuckLayout-headerToggle": "_PuckLayout-headerToggle_12s9r_127", "PuckLayout-rightSideBarToggle": "_PuckLayout-rightSideBarToggle_12s9r_134", "PuckLayout-leftSideBarToggle": "_PuckLayout-leftSideBarToggle_12s9r_135", "PuckLayout-headerTitle": "_PuckLayout-headerTitle_12s9r_139", "PuckLayout-headerPath": "_PuckLayout-headerPath_12s9r_143", "PuckLayout-headerTools": "_PuckLayout-headerTools_12s9r_150", "PuckLayout-menuButton": "_PuckLayout-menuButton_12s9r_156", "PuckLayout--menuOpen": "_PuckLayout--menuOpen_12s9r_161", "PuckLayout-leftSideBar": "_PuckLayout-leftSideBar_12s9r_135", "PuckLayout-rightSideBar": "_PuckLayout-rightSideBar_12s9r_134" };
|
5256
5466
|
|
5257
5467
|
// components/Puck/components/Fields/index.tsx
|
5258
5468
|
init_react_import();
|
@@ -5262,15 +5472,15 @@ init_react_import();
|
|
5262
5472
|
var styles_module_default16 = { "PuckFields": "_PuckFields_jp3lw_1", "PuckFields--isLoading": "_PuckFields--isLoading_jp3lw_6", "PuckFields-loadingOverlay": "_PuckFields-loadingOverlay_jp3lw_10", "PuckFields-loadingOverlayInner": "_PuckFields-loadingOverlayInner_jp3lw_25" };
|
5263
5473
|
|
5264
5474
|
// components/Puck/components/Fields/index.tsx
|
5265
|
-
var
|
5475
|
+
var import_react34 = require("react");
|
5266
5476
|
|
5267
5477
|
// lib/use-parent.ts
|
5268
5478
|
init_react_import();
|
5269
|
-
var
|
5479
|
+
var import_react33 = require("react");
|
5270
5480
|
var useParent = (itemSelector) => {
|
5271
5481
|
var _a;
|
5272
5482
|
const { selectedItem, state } = useAppContext();
|
5273
|
-
const { pathData } = (0,
|
5483
|
+
const { pathData } = (0, import_react33.useContext)(dropZoneContext) || {};
|
5274
5484
|
const item = itemSelector ? getItem(itemSelector, state.data) : selectedItem;
|
5275
5485
|
const breadcrumbs = convertPathDataToBreadcrumbs(item, pathData, state.data);
|
5276
5486
|
const lastItem = breadcrumbs[breadcrumbs.length - 1];
|
@@ -5296,20 +5506,20 @@ var useResolvedFields = () => {
|
|
5296
5506
|
const { data } = state;
|
5297
5507
|
const rootFields = ((_a = config.root) == null ? void 0 : _a.fields) || defaultPageFields;
|
5298
5508
|
const componentConfig = selectedItem ? config.components[selectedItem.type] : null;
|
5299
|
-
const defaultFields = (0,
|
5509
|
+
const defaultFields = (0, import_react34.useMemo)(
|
5300
5510
|
() => (selectedItem ? componentConfig == null ? void 0 : componentConfig.fields : rootFields) || {},
|
5301
5511
|
[selectedItem, rootFields, componentConfig == null ? void 0 : componentConfig.fields]
|
5302
5512
|
);
|
5303
5513
|
const rootProps = data.root.props || data.root;
|
5304
|
-
const [lastSelectedData, setLastSelectedData] = (0,
|
5305
|
-
const [resolvedFields, setResolvedFields] = (0,
|
5306
|
-
const [fieldsLoading, setFieldsLoading] = (0,
|
5514
|
+
const [lastSelectedData, setLastSelectedData] = (0, import_react34.useState)({});
|
5515
|
+
const [resolvedFields, setResolvedFields] = (0, import_react34.useState)(defaultFields);
|
5516
|
+
const [fieldsLoading, setFieldsLoading] = (0, import_react34.useState)(false);
|
5307
5517
|
const defaultResolveFields = (_componentData, _params) => defaultFields;
|
5308
5518
|
const componentData = selectedItem ? selectedItem : { props: rootProps, readOnly: data.root.readOnly };
|
5309
5519
|
const hasComponentResolver = selectedItem && (componentConfig == null ? void 0 : componentConfig.resolveFields);
|
5310
5520
|
const hasRootResolver = !selectedItem && ((_b = config.root) == null ? void 0 : _b.resolveFields);
|
5311
5521
|
const hasResolver = hasComponentResolver || hasRootResolver;
|
5312
|
-
const resolveFields = (0,
|
5522
|
+
const resolveFields = (0, import_react34.useCallback)(
|
5313
5523
|
(..._0) => __async(void 0, [..._0], function* (fields = {}) {
|
5314
5524
|
var _a2;
|
5315
5525
|
const lastData = ((_a2 = lastSelectedData.props) == null ? void 0 : _a2.id) === componentData.props.id ? lastSelectedData : null;
|
@@ -5347,7 +5557,7 @@ var useResolvedFields = () => {
|
|
5347
5557
|
}),
|
5348
5558
|
[data, config, componentData, selectedItem, resolvedFields, state]
|
5349
5559
|
);
|
5350
|
-
(0,
|
5560
|
+
(0, import_react34.useEffect)(() => {
|
5351
5561
|
if (hasResolver) {
|
5352
5562
|
setFieldsLoading(true);
|
5353
5563
|
resolveFields(defaultFields).then((fields) => {
|
@@ -5378,7 +5588,7 @@ var Fields = () => {
|
|
5378
5588
|
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;
|
5379
5589
|
const isLoading = fieldsResolving || componentResolving;
|
5380
5590
|
const rootProps = data.root.props || data.root;
|
5381
|
-
const Wrapper = (0,
|
5591
|
+
const Wrapper = (0, import_react34.useMemo)(() => overrides.fields || DefaultFields, [overrides]);
|
5382
5592
|
return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(
|
5383
5593
|
"form",
|
5384
5594
|
{
|
@@ -5501,7 +5711,7 @@ init_react_import();
|
|
5501
5711
|
|
5502
5712
|
// lib/use-component-list.tsx
|
5503
5713
|
init_react_import();
|
5504
|
-
var
|
5714
|
+
var import_react35 = require("react");
|
5505
5715
|
|
5506
5716
|
// components/ComponentList/index.tsx
|
5507
5717
|
init_react_import();
|
@@ -5568,8 +5778,8 @@ ComponentList.Item = ComponentListItem;
|
|
5568
5778
|
// lib/use-component-list.tsx
|
5569
5779
|
var import_jsx_runtime28 = require("react/jsx-runtime");
|
5570
5780
|
var useComponentList = (config, ui) => {
|
5571
|
-
const [componentList, setComponentList] = (0,
|
5572
|
-
(0,
|
5781
|
+
const [componentList, setComponentList] = (0, import_react35.useState)();
|
5782
|
+
(0, import_react35.useEffect)(() => {
|
5573
5783
|
var _a, _b, _c;
|
5574
5784
|
if (Object.keys(ui.componentList).length > 0) {
|
5575
5785
|
const matchedComponents = [];
|
@@ -5638,22 +5848,22 @@ var useComponentList = (config, ui) => {
|
|
5638
5848
|
};
|
5639
5849
|
|
5640
5850
|
// components/Puck/components/Components/index.tsx
|
5641
|
-
var
|
5851
|
+
var import_react36 = require("react");
|
5642
5852
|
var import_jsx_runtime29 = require("react/jsx-runtime");
|
5643
5853
|
var Components = () => {
|
5644
5854
|
const { config, state, overrides } = useAppContext();
|
5645
5855
|
const componentList = useComponentList(config, state.ui);
|
5646
|
-
const Wrapper = (0,
|
5856
|
+
const Wrapper = (0, import_react36.useMemo)(() => overrides.components || "div", [overrides]);
|
5647
5857
|
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(Wrapper, { children: componentList ? componentList : /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(ComponentList, { id: "all" }) });
|
5648
5858
|
};
|
5649
5859
|
|
5650
5860
|
// components/Puck/components/Preview/index.tsx
|
5651
5861
|
init_react_import();
|
5652
|
-
var
|
5862
|
+
var import_react38 = require("react");
|
5653
5863
|
|
5654
5864
|
// components/AutoFrame/index.tsx
|
5655
5865
|
init_react_import();
|
5656
|
-
var
|
5866
|
+
var import_react37 = require("react");
|
5657
5867
|
var import_object_hash = __toESM(require("object-hash"));
|
5658
5868
|
var import_react_dom3 = require("react-dom");
|
5659
5869
|
var import_jsx_runtime30 = require("react/jsx-runtime");
|
@@ -5699,7 +5909,7 @@ var CopyHostStyles = ({
|
|
5699
5909
|
onStylesLoaded = () => null
|
5700
5910
|
}) => {
|
5701
5911
|
const { document: doc, window: win } = useFrame();
|
5702
|
-
(0,
|
5912
|
+
(0, import_react37.useEffect)(() => {
|
5703
5913
|
if (!win || !doc) {
|
5704
5914
|
return () => {
|
5705
5915
|
};
|
@@ -5858,8 +6068,8 @@ var CopyHostStyles = ({
|
|
5858
6068
|
}, []);
|
5859
6069
|
return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_jsx_runtime30.Fragment, { children });
|
5860
6070
|
};
|
5861
|
-
var autoFrameContext = (0,
|
5862
|
-
var useFrame = () => (0,
|
6071
|
+
var autoFrameContext = (0, import_react37.createContext)({});
|
6072
|
+
var useFrame = () => (0, import_react37.useContext)(autoFrameContext);
|
5863
6073
|
function AutoFrame(_a) {
|
5864
6074
|
var _b = _a, {
|
5865
6075
|
children,
|
@@ -5876,10 +6086,10 @@ function AutoFrame(_a) {
|
|
5876
6086
|
"onStylesLoaded",
|
5877
6087
|
"frameRef"
|
5878
6088
|
]);
|
5879
|
-
const [loaded, setLoaded] = (0,
|
5880
|
-
const [ctx, setCtx] = (0,
|
5881
|
-
const [mountTarget, setMountTarget] = (0,
|
5882
|
-
(0,
|
6089
|
+
const [loaded, setLoaded] = (0, import_react37.useState)(false);
|
6090
|
+
const [ctx, setCtx] = (0, import_react37.useState)({});
|
6091
|
+
const [mountTarget, setMountTarget] = (0, import_react37.useState)();
|
6092
|
+
(0, import_react37.useEffect)(() => {
|
5883
6093
|
var _a2;
|
5884
6094
|
if (frameRef.current) {
|
5885
6095
|
setCtx({
|
@@ -5973,7 +6183,7 @@ var import_jsx_runtime32 = require("react/jsx-runtime");
|
|
5973
6183
|
var getClassName23 = get_class_name_factory_default("PuckPreview", styles_module_default18);
|
5974
6184
|
var useBubbleIframeEvents = (ref) => {
|
5975
6185
|
const { status } = useAppContext();
|
5976
|
-
(0,
|
6186
|
+
(0, import_react38.useEffect)(() => {
|
5977
6187
|
var _a;
|
5978
6188
|
if (ref.current && status === "READY") {
|
5979
6189
|
const iframe = ref.current;
|
@@ -6010,9 +6220,9 @@ var useBubbleIframeEvents = (ref) => {
|
|
6010
6220
|
}
|
6011
6221
|
}, [status]);
|
6012
6222
|
};
|
6013
|
-
var
|
6223
|
+
var Preview2 = ({ id = "puck-preview" }) => {
|
6014
6224
|
const { config, dispatch, state, setStatus, iframe, overrides } = useAppContext();
|
6015
|
-
const Page = (0,
|
6225
|
+
const Page = (0, import_react38.useCallback)(
|
6016
6226
|
(pageProps) => {
|
6017
6227
|
var _a, _b;
|
6018
6228
|
return ((_a = config.root) == null ? void 0 : _a.render) ? (_b = config.root) == null ? void 0 : _b.render(__spreadValues({
|
@@ -6021,9 +6231,9 @@ var Preview = ({ id = "puck-preview" }) => {
|
|
6021
6231
|
},
|
6022
6232
|
[config.root]
|
6023
6233
|
);
|
6024
|
-
const Frame = (0,
|
6234
|
+
const Frame = (0, import_react38.useMemo)(() => overrides.iframe, [overrides]);
|
6025
6235
|
const rootProps = state.data.root.props || state.data.root;
|
6026
|
-
const ref = (0,
|
6236
|
+
const ref = (0, import_react38.useRef)(null);
|
6027
6237
|
useBubbleIframeEvents(ref);
|
6028
6238
|
const inner = state.ui.previewMode === "edit" ? /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
6029
6239
|
Page,
|
@@ -6120,7 +6330,7 @@ var scrollIntoView = (el) => {
|
|
6120
6330
|
};
|
6121
6331
|
|
6122
6332
|
// components/LayerTree/index.tsx
|
6123
|
-
var
|
6333
|
+
var import_react39 = require("react");
|
6124
6334
|
|
6125
6335
|
// lib/is-child-of-zone.ts
|
6126
6336
|
init_react_import();
|
@@ -6166,7 +6376,7 @@ var LayerTree = ({
|
|
6166
6376
|
label
|
6167
6377
|
}) => {
|
6168
6378
|
const zones = data.zones || {};
|
6169
|
-
const ctx = (0,
|
6379
|
+
const ctx = (0, import_react39.useContext)(dropZoneContext);
|
6170
6380
|
return /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(import_jsx_runtime33.Fragment, { children: [
|
6171
6381
|
label && /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { className: getClassName24("zoneTitle"), children: [
|
6172
6382
|
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)("div", { className: getClassName24("zoneIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Layers, { size: "16" }) }),
|
@@ -6273,13 +6483,13 @@ var LayerTree = ({
|
|
6273
6483
|
};
|
6274
6484
|
|
6275
6485
|
// components/Puck/components/Outline/index.tsx
|
6276
|
-
var
|
6486
|
+
var import_react40 = require("react");
|
6277
6487
|
var import_jsx_runtime34 = require("react/jsx-runtime");
|
6278
6488
|
var Outline = () => {
|
6279
6489
|
const { dispatch, state, overrides, config } = useAppContext();
|
6280
6490
|
const { data, ui } = state;
|
6281
6491
|
const { itemSelector } = ui;
|
6282
|
-
const setItemSelector = (0,
|
6492
|
+
const setItemSelector = (0, import_react40.useCallback)(
|
6283
6493
|
(newItemSelector) => {
|
6284
6494
|
dispatch({
|
6285
6495
|
type: "setUi",
|
@@ -6288,7 +6498,7 @@ var Outline = () => {
|
|
6288
6498
|
},
|
6289
6499
|
[]
|
6290
6500
|
);
|
6291
|
-
const Wrapper = (0,
|
6501
|
+
const Wrapper = (0, import_react40.useMemo)(() => overrides.outline || "div", [overrides]);
|
6292
6502
|
return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Wrapper, { children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(dropZoneContext.Consumer, { children: (ctx) => /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(import_jsx_runtime34.Fragment, { children: [
|
6293
6503
|
(ctx == null ? void 0 : ctx.activeZones) && (ctx == null ? void 0 : ctx.activeZones[rootDroppableId]) && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
6294
6504
|
LayerTree,
|
@@ -6402,19 +6612,19 @@ function usePuckHistory({
|
|
6402
6612
|
|
6403
6613
|
// lib/use-history-store.ts
|
6404
6614
|
init_react_import();
|
6405
|
-
var
|
6615
|
+
var import_react41 = require("react");
|
6406
6616
|
var import_use_debounce3 = require("use-debounce");
|
6407
6617
|
var EMPTY_HISTORY_INDEX = 0;
|
6408
6618
|
function useHistoryStore(initialHistory) {
|
6409
6619
|
var _a, _b;
|
6410
|
-
const [histories, setHistories] = (0,
|
6620
|
+
const [histories, setHistories] = (0, import_react41.useState)(
|
6411
6621
|
(_a = initialHistory == null ? void 0 : initialHistory.histories) != null ? _a : []
|
6412
6622
|
);
|
6413
6623
|
const updateHistories = (histories2) => {
|
6414
6624
|
setHistories(histories2);
|
6415
6625
|
setIndex(histories2.length - 1);
|
6416
6626
|
};
|
6417
|
-
const [index, setIndex] = (0,
|
6627
|
+
const [index, setIndex] = (0, import_react41.useState)(
|
6418
6628
|
(_b = initialHistory == null ? void 0 : initialHistory.index) != null ? _b : EMPTY_HISTORY_INDEX
|
6419
6629
|
);
|
6420
6630
|
const hasPast = index > EMPTY_HISTORY_INDEX;
|
@@ -6574,11 +6784,11 @@ var getBox = function getBox2(el) {
|
|
6574
6784
|
};
|
6575
6785
|
|
6576
6786
|
// components/Puck/components/Canvas/index.tsx
|
6577
|
-
var
|
6787
|
+
var import_react43 = require("react");
|
6578
6788
|
|
6579
6789
|
// components/ViewportControls/index.tsx
|
6580
6790
|
init_react_import();
|
6581
|
-
var
|
6791
|
+
var import_react42 = require("react");
|
6582
6792
|
|
6583
6793
|
// css-module:/home/runner/work/puck/puck/packages/core/components/ViewportControls/styles.module.css#css-module
|
6584
6794
|
init_react_import();
|
@@ -6601,8 +6811,8 @@ var ViewportButton = ({
|
|
6601
6811
|
onClick
|
6602
6812
|
}) => {
|
6603
6813
|
const { state } = useAppContext();
|
6604
|
-
const [isActive, setIsActive] = (0,
|
6605
|
-
(0,
|
6814
|
+
const [isActive, setIsActive] = (0, import_react42.useState)(false);
|
6815
|
+
(0, import_react42.useEffect)(() => {
|
6606
6816
|
setIsActive(width === state.ui.viewports.current.width);
|
6607
6817
|
}, [width, state.ui.viewports.current.width]);
|
6608
6818
|
return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("span", { className: getClassNameButton({ isActive }), children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
@@ -6638,7 +6848,7 @@ var ViewportControls = ({
|
|
6638
6848
|
const defaultsContainAutoZoom = defaultZoomOptions.find(
|
6639
6849
|
(option) => option.value === autoZoom
|
6640
6850
|
);
|
6641
|
-
const zoomOptions = (0,
|
6851
|
+
const zoomOptions = (0, import_react42.useMemo)(
|
6642
6852
|
() => [
|
6643
6853
|
...defaultZoomOptions,
|
6644
6854
|
...defaultsContainAutoZoom ? [] : [
|
@@ -6761,17 +6971,17 @@ var Canvas = () => {
|
|
6761
6971
|
const { status, iframe } = useAppContext();
|
6762
6972
|
const { dispatch, state, overrides, setUi, zoomConfig, setZoomConfig } = useAppContext();
|
6763
6973
|
const { ui } = state;
|
6764
|
-
const frameRef = (0,
|
6765
|
-
const [showTransition, setShowTransition] = (0,
|
6766
|
-
const defaultRender = (0,
|
6974
|
+
const frameRef = (0, import_react43.useRef)(null);
|
6975
|
+
const [showTransition, setShowTransition] = (0, import_react43.useState)(false);
|
6976
|
+
const defaultRender = (0, import_react43.useMemo)(() => {
|
6767
6977
|
const PuckDefault = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_jsx_runtime36.Fragment, { children });
|
6768
6978
|
return PuckDefault;
|
6769
6979
|
}, []);
|
6770
|
-
const CustomPreview = (0,
|
6980
|
+
const CustomPreview = (0, import_react43.useMemo)(
|
6771
6981
|
() => overrides.preview || defaultRender,
|
6772
6982
|
[overrides]
|
6773
6983
|
);
|
6774
|
-
const getFrameDimensions = (0,
|
6984
|
+
const getFrameDimensions = (0, import_react43.useCallback)(() => {
|
6775
6985
|
if (frameRef.current) {
|
6776
6986
|
const frame = frameRef.current;
|
6777
6987
|
const box = getBox(frame);
|
@@ -6779,7 +6989,7 @@ var Canvas = () => {
|
|
6779
6989
|
}
|
6780
6990
|
return { width: 0, height: 0 };
|
6781
6991
|
}, [frameRef]);
|
6782
|
-
const resetAutoZoom = (0,
|
6992
|
+
const resetAutoZoom = (0, import_react43.useCallback)(
|
6783
6993
|
(ui2 = state.ui) => {
|
6784
6994
|
if (frameRef.current) {
|
6785
6995
|
setZoomConfig(
|
@@ -6789,11 +6999,11 @@ var Canvas = () => {
|
|
6789
6999
|
},
|
6790
7000
|
[frameRef, zoomConfig, state.ui]
|
6791
7001
|
);
|
6792
|
-
(0,
|
7002
|
+
(0, import_react43.useEffect)(() => {
|
6793
7003
|
setShowTransition(false);
|
6794
7004
|
resetAutoZoom();
|
6795
7005
|
}, [frameRef, ui.leftSideBarVisible, ui.rightSideBarVisible]);
|
6796
|
-
(0,
|
7006
|
+
(0, import_react43.useEffect)(() => {
|
6797
7007
|
const { height: frameHeight } = getFrameDimensions();
|
6798
7008
|
if (ui.viewports.current.height === "auto") {
|
6799
7009
|
setZoomConfig(__spreadProps(__spreadValues({}, zoomConfig), {
|
@@ -6801,13 +7011,13 @@ var Canvas = () => {
|
|
6801
7011
|
}));
|
6802
7012
|
}
|
6803
7013
|
}, [zoomConfig.zoom]);
|
6804
|
-
(0,
|
7014
|
+
(0, import_react43.useEffect)(() => {
|
6805
7015
|
if (ZOOM_ON_CHANGE) {
|
6806
7016
|
setShowTransition(true);
|
6807
7017
|
resetAutoZoom(ui);
|
6808
7018
|
}
|
6809
7019
|
}, [ui.viewports.current.width]);
|
6810
|
-
(0,
|
7020
|
+
(0, import_react43.useEffect)(() => {
|
6811
7021
|
const cb = () => {
|
6812
7022
|
setShowTransition(false);
|
6813
7023
|
resetAutoZoom();
|
@@ -6817,8 +7027,8 @@ var Canvas = () => {
|
|
6817
7027
|
window.removeEventListener("resize", cb);
|
6818
7028
|
};
|
6819
7029
|
}, []);
|
6820
|
-
const [showLoader, setShowLoader] = (0,
|
6821
|
-
(0,
|
7030
|
+
const [showLoader, setShowLoader] = (0, import_react43.useState)(false);
|
7031
|
+
(0, import_react43.useEffect)(() => {
|
6822
7032
|
setTimeout(() => {
|
6823
7033
|
setShowLoader(true);
|
6824
7034
|
}, 500);
|
@@ -6884,7 +7094,7 @@ var Canvas = () => {
|
|
6884
7094
|
})
|
6885
7095
|
);
|
6886
7096
|
},
|
6887
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(CustomPreview, { children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
7097
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(CustomPreview, { children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Preview2, {}) })
|
6888
7098
|
}
|
6889
7099
|
),
|
6890
7100
|
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: getClassName26("loader"), children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Loader, { size: 24 }) })
|
@@ -6896,7 +7106,7 @@ var Canvas = () => {
|
|
6896
7106
|
|
6897
7107
|
// lib/use-loaded-overrides.ts
|
6898
7108
|
init_react_import();
|
6899
|
-
var
|
7109
|
+
var import_react44 = require("react");
|
6900
7110
|
|
6901
7111
|
// lib/load-overrides.ts
|
6902
7112
|
init_react_import();
|
@@ -6935,7 +7145,7 @@ var useLoadedOverrides = ({
|
|
6935
7145
|
overrides,
|
6936
7146
|
plugins
|
6937
7147
|
}) => {
|
6938
|
-
return (0,
|
7148
|
+
return (0, import_react44.useMemo)(() => {
|
6939
7149
|
return loadOverrides({ overrides, plugins });
|
6940
7150
|
}, [plugins, overrides]);
|
6941
7151
|
};
|
@@ -6947,14 +7157,14 @@ var DefaultOverride = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime37
|
|
6947
7157
|
|
6948
7158
|
// lib/use-inject-css.ts
|
6949
7159
|
init_react_import();
|
6950
|
-
var
|
7160
|
+
var import_react45 = require("react");
|
6951
7161
|
var styles = ``;
|
6952
7162
|
var useInjectStyleSheet = (initialStyles, iframeEnabled) => {
|
6953
|
-
const [el, setEl] = (0,
|
6954
|
-
(0,
|
7163
|
+
const [el, setEl] = (0, import_react45.useState)();
|
7164
|
+
(0, import_react45.useEffect)(() => {
|
6955
7165
|
setEl(document.createElement("style"));
|
6956
7166
|
}, []);
|
6957
|
-
(0,
|
7167
|
+
(0, import_react45.useEffect)(() => {
|
6958
7168
|
var _a;
|
6959
7169
|
if (!el || typeof window === "undefined") {
|
6960
7170
|
return;
|
@@ -6974,10 +7184,10 @@ var useInjectGlobalCss = (iframeEnabled) => {
|
|
6974
7184
|
|
6975
7185
|
// lib/use-preview-mode-hotkeys.ts
|
6976
7186
|
init_react_import();
|
6977
|
-
var
|
7187
|
+
var import_react46 = require("react");
|
6978
7188
|
var import_react_hotkeys_hook2 = require("react-hotkeys-hook");
|
6979
7189
|
var usePreviewModeHotkeys = (dispatch, iframeEnabled) => {
|
6980
|
-
const toggleInteractive = (0,
|
7190
|
+
const toggleInteractive = (0, import_react46.useCallback)(() => {
|
6981
7191
|
dispatch({
|
6982
7192
|
type: "setUi",
|
6983
7193
|
ui: (ui) => ({
|
@@ -7029,7 +7239,7 @@ function Puck({
|
|
7029
7239
|
waitForStyles: true
|
7030
7240
|
}, _iframe);
|
7031
7241
|
useInjectGlobalCss(iframe.enabled);
|
7032
|
-
const [generatedAppState] = (0,
|
7242
|
+
const [generatedAppState] = (0, import_react47.useState)(() => {
|
7033
7243
|
var _a2, _b2, _c, _d, _e, _f, _g, _h, _i;
|
7034
7244
|
const initial = __spreadValues(__spreadValues({}, defaultAppState.ui), initialUi);
|
7035
7245
|
let clientUiState = {};
|
@@ -7101,14 +7311,14 @@ function Puck({
|
|
7101
7311
|
histories,
|
7102
7312
|
index: initialHistoryIndex
|
7103
7313
|
});
|
7104
|
-
const [reducer] = (0,
|
7314
|
+
const [reducer] = (0, import_react47.useState)(
|
7105
7315
|
() => createReducer({
|
7106
7316
|
config,
|
7107
7317
|
record: historyStore.record,
|
7108
7318
|
onAction
|
7109
7319
|
})
|
7110
7320
|
);
|
7111
|
-
const [appState, dispatch] = (0,
|
7321
|
+
const [appState, dispatch] = (0, import_react47.useReducer)(
|
7112
7322
|
reducer,
|
7113
7323
|
flushZones(initialAppState)
|
7114
7324
|
);
|
@@ -7119,14 +7329,14 @@ function Puck({
|
|
7119
7329
|
historyStore,
|
7120
7330
|
iframeEnabled: (_a = _iframe == null ? void 0 : _iframe.enabled) != null ? _a : true
|
7121
7331
|
});
|
7122
|
-
const [menuOpen, setMenuOpen] = (0,
|
7332
|
+
const [menuOpen, setMenuOpen] = (0, import_react47.useState)(false);
|
7123
7333
|
const { itemSelector, leftSideBarVisible, rightSideBarVisible } = ui;
|
7124
7334
|
const selectedItem = itemSelector ? getItem(itemSelector, data) : null;
|
7125
|
-
(0,
|
7335
|
+
(0, import_react47.useEffect)(() => {
|
7126
7336
|
if (onChange) onChange(data);
|
7127
7337
|
}, [data]);
|
7128
7338
|
const rootProps = data.root.props || data.root;
|
7129
|
-
const toggleSidebars = (0,
|
7339
|
+
const toggleSidebars = (0, import_react47.useCallback)(
|
7130
7340
|
(sidebar) => {
|
7131
7341
|
const widerViewport = window.matchMedia("(min-width: 638px)").matches;
|
7132
7342
|
const sideBarVisible = sidebar === "left" ? leftSideBarVisible : rightSideBarVisible;
|
@@ -7140,7 +7350,7 @@ function Puck({
|
|
7140
7350
|
},
|
7141
7351
|
[dispatch, leftSideBarVisible, rightSideBarVisible]
|
7142
7352
|
);
|
7143
|
-
(0,
|
7353
|
+
(0, import_react47.useEffect)(() => {
|
7144
7354
|
if (!window.matchMedia("(min-width: 638px)").matches) {
|
7145
7355
|
dispatch({
|
7146
7356
|
type: "setUi",
|
@@ -7163,7 +7373,7 @@ function Puck({
|
|
7163
7373
|
window.removeEventListener("resize", handleResize);
|
7164
7374
|
};
|
7165
7375
|
}, []);
|
7166
|
-
const defaultHeaderRender = (0,
|
7376
|
+
const defaultHeaderRender = (0, import_react47.useMemo)(() => {
|
7167
7377
|
if (renderHeader) {
|
7168
7378
|
console.warn(
|
7169
7379
|
"`renderHeader` is deprecated. Please use `overrides.header` and the `usePuck` hook instead"
|
@@ -7177,7 +7387,7 @@ function Puck({
|
|
7177
7387
|
}
|
7178
7388
|
return DefaultOverride;
|
7179
7389
|
}, [renderHeader]);
|
7180
|
-
const defaultHeaderActionsRender = (0,
|
7390
|
+
const defaultHeaderActionsRender = (0, import_react47.useMemo)(() => {
|
7181
7391
|
if (renderHeaderActions) {
|
7182
7392
|
console.warn(
|
7183
7393
|
"`renderHeaderActions` is deprecated. Please use `overrides.headerActions` and the `usePuck` hook instead."
|
@@ -7194,20 +7404,20 @@ function Puck({
|
|
7194
7404
|
overrides,
|
7195
7405
|
plugins
|
7196
7406
|
});
|
7197
|
-
const CustomPuck = (0,
|
7407
|
+
const CustomPuck = (0, import_react47.useMemo)(
|
7198
7408
|
() => loadedOverrides.puck || DefaultOverride,
|
7199
7409
|
[loadedOverrides]
|
7200
7410
|
);
|
7201
|
-
const CustomHeader = (0,
|
7411
|
+
const CustomHeader = (0, import_react47.useMemo)(
|
7202
7412
|
() => loadedOverrides.header || defaultHeaderRender,
|
7203
7413
|
[loadedOverrides]
|
7204
7414
|
);
|
7205
|
-
const CustomHeaderActions = (0,
|
7415
|
+
const CustomHeaderActions = (0, import_react47.useMemo)(
|
7206
7416
|
() => loadedOverrides.headerActions || defaultHeaderActionsRender,
|
7207
7417
|
[loadedOverrides]
|
7208
7418
|
);
|
7209
|
-
const [mounted, setMounted] = (0,
|
7210
|
-
(0,
|
7419
|
+
const [mounted, setMounted] = (0, import_react47.useState)(false);
|
7420
|
+
(0, import_react47.useEffect)(() => {
|
7211
7421
|
setMounted(true);
|
7212
7422
|
}, []);
|
7213
7423
|
const selectedComponentConfig = selectedItem && config.components[selectedItem.type];
|
@@ -7368,7 +7578,7 @@ function Puck({
|
|
7368
7578
|
Puck.Components = Components;
|
7369
7579
|
Puck.Fields = Fields;
|
7370
7580
|
Puck.Outline = Outline;
|
7371
|
-
Puck.Preview =
|
7581
|
+
Puck.Preview = Preview2;
|
7372
7582
|
|
7373
7583
|
// lib/migrate.ts
|
7374
7584
|
init_react_import();
|