@measured/puck 0.18.0-canary.066aba9 → 0.18.0-canary.874ba1b
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 +719 -501
- package/dist/index.mjs +689 -471
- 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");
|
@@ -1575,14 +1575,18 @@ var ArrayField = ({
|
|
1575
1575
|
const subFieldName = `${name}[${i}].${fieldName}`;
|
1576
1576
|
const wildcardFieldName = `${name}[*].${fieldName}`;
|
1577
1577
|
const subReadOnly = forceReadOnly ? forceReadOnly : typeof readOnlyFields[subFieldName] !== "undefined" ? readOnlyFields[subFieldName] : readOnlyFields[wildcardFieldName];
|
1578
|
+
const label2 = subField.label || fieldName;
|
1578
1579
|
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
1579
1580
|
AutoFieldPrivate,
|
1580
1581
|
{
|
1581
1582
|
name: subFieldName,
|
1582
|
-
label:
|
1583
|
+
label: label2,
|
1583
1584
|
id: `${_arrayId}_${fieldName}`,
|
1584
1585
|
readOnly: subReadOnly,
|
1585
|
-
field: subField,
|
1586
|
+
field: __spreadProps(__spreadValues({}, subField), {
|
1587
|
+
label: label2
|
1588
|
+
// May be used by custom fields
|
1589
|
+
}),
|
1586
1590
|
value: data[fieldName],
|
1587
1591
|
onChange: (val, ui) => {
|
1588
1592
|
onChange(
|
@@ -2305,14 +2309,18 @@ var ObjectField = ({
|
|
2305
2309
|
const subFieldName = `${name}.${fieldName}`;
|
2306
2310
|
const wildcardFieldName = `${name}.${fieldName}`;
|
2307
2311
|
const subReadOnly = readOnly ? readOnly : typeof readOnlyFields[subFieldName] !== "undefined" ? readOnlyFields[subFieldName] : readOnlyFields[wildcardFieldName];
|
2312
|
+
const label2 = subField.label || fieldName;
|
2308
2313
|
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
2309
2314
|
AutoFieldPrivate,
|
2310
2315
|
{
|
2311
2316
|
name: subFieldName,
|
2312
|
-
label:
|
2317
|
+
label: label2,
|
2313
2318
|
id: `${id}_${fieldName}`,
|
2314
2319
|
readOnly: subReadOnly,
|
2315
|
-
field: subField,
|
2320
|
+
field: __spreadProps(__spreadValues({}, subField), {
|
2321
|
+
label: label2
|
2322
|
+
// May be used by custom fields
|
2323
|
+
}),
|
2316
2324
|
value: data[fieldName],
|
2317
2325
|
onChange: (val, ui) => {
|
2318
2326
|
onChange(
|
@@ -2524,21 +2532,21 @@ init_react_import();
|
|
2524
2532
|
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
2533
|
|
2526
2534
|
// components/Drawer/index.tsx
|
2527
|
-
var
|
2535
|
+
var import_react31 = require("react");
|
2528
2536
|
|
2529
2537
|
// components/DragDropContext/index.tsx
|
2530
2538
|
init_react_import();
|
2531
|
-
var
|
2532
|
-
var
|
2539
|
+
var import_react29 = require("@dnd-kit/react");
|
2540
|
+
var import_react30 = require("react");
|
2533
2541
|
var import_dom = require("@dnd-kit/dom");
|
2534
2542
|
|
2535
2543
|
// components/DropZone/index.tsx
|
2536
2544
|
init_react_import();
|
2537
|
-
var
|
2545
|
+
var import_react28 = require("react");
|
2538
2546
|
|
2539
2547
|
// components/DraggableComponent/index.tsx
|
2540
2548
|
init_react_import();
|
2541
|
-
var
|
2549
|
+
var import_react22 = require("react");
|
2542
2550
|
|
2543
2551
|
// css-module:/home/runner/work/puck/puck/packages/core/components/DraggableComponent/styles.module.css#css-module
|
2544
2552
|
init_react_import();
|
@@ -2547,15 +2555,15 @@ var styles_module_default11 = { "DraggableComponent": "_DraggableComponent_1ukn8
|
|
2547
2555
|
// components/DraggableComponent/index.tsx
|
2548
2556
|
var import_react_dom2 = require("react-dom");
|
2549
2557
|
|
2550
|
-
//
|
2558
|
+
// lib/dnd/collision/dynamic/index.ts
|
2551
2559
|
init_react_import();
|
2552
2560
|
var import_abstract8 = require("@dnd-kit/abstract");
|
2553
2561
|
|
2554
|
-
//
|
2562
|
+
// lib/dnd/collision/directional/index.ts
|
2555
2563
|
init_react_import();
|
2556
2564
|
var import_abstract = require("@dnd-kit/abstract");
|
2557
2565
|
|
2558
|
-
//
|
2566
|
+
// lib/dnd/collision/collision-debug.ts
|
2559
2567
|
init_react_import();
|
2560
2568
|
var DEBUG = false;
|
2561
2569
|
var debugElements = {};
|
@@ -2604,7 +2612,7 @@ var collisionDebug = (a, b, id, color, label) => {
|
|
2604
2612
|
});
|
2605
2613
|
};
|
2606
2614
|
|
2607
|
-
//
|
2615
|
+
// lib/dnd/collision/directional/index.ts
|
2608
2616
|
var distanceChange = "increasing";
|
2609
2617
|
var directionalCollision = (input, previous) => {
|
2610
2618
|
var _a;
|
@@ -2637,7 +2645,7 @@ var directionalCollision = (input, previous) => {
|
|
2637
2645
|
return null;
|
2638
2646
|
};
|
2639
2647
|
|
2640
|
-
//
|
2648
|
+
// lib/dnd/collision/dynamic/get-direction.ts
|
2641
2649
|
init_react_import();
|
2642
2650
|
var getDirection = (dragAxis, delta) => {
|
2643
2651
|
if (dragAxis === "dynamic") {
|
@@ -2652,7 +2660,7 @@ var getDirection = (dragAxis, delta) => {
|
|
2652
2660
|
return delta.y === 0 ? null : delta.y > 0 ? "down" : "up";
|
2653
2661
|
};
|
2654
2662
|
|
2655
|
-
//
|
2663
|
+
// lib/dnd/collision/dynamic/get-midpoint-impact.ts
|
2656
2664
|
init_react_import();
|
2657
2665
|
var getMidpointImpact = (dragShape, dropShape, direction, offsetMultiplier = 0) => {
|
2658
2666
|
const dragRect = dragShape.boundingRectangle;
|
@@ -2671,7 +2679,7 @@ var getMidpointImpact = (dragShape, dropShape, direction, offsetMultiplier = 0)
|
|
2671
2679
|
return dragRect.right - offset >= dropCenter.x;
|
2672
2680
|
};
|
2673
2681
|
|
2674
|
-
//
|
2682
|
+
// lib/dnd/collision/dynamic/track-movement-interval.ts
|
2675
2683
|
init_react_import();
|
2676
2684
|
var import_geometry = require("@dnd-kit/geometry");
|
2677
2685
|
var INTERVAL_SENSITIVITY = 10;
|
@@ -2775,7 +2783,14 @@ var closestCorners = (input) => {
|
|
2775
2783
|
};
|
2776
2784
|
};
|
2777
2785
|
|
2778
|
-
//
|
2786
|
+
// lib/dnd/collision/dynamic/store.ts
|
2787
|
+
init_react_import();
|
2788
|
+
var import_vanilla = require("zustand/vanilla");
|
2789
|
+
var collisionStore = (0, import_vanilla.createStore)(() => ({
|
2790
|
+
fallbackEnabled: false
|
2791
|
+
}));
|
2792
|
+
|
2793
|
+
// lib/dnd/collision/dynamic/index.ts
|
2779
2794
|
var flushNext = "";
|
2780
2795
|
var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input) => {
|
2781
2796
|
var _a, _b, _c, _d, _e;
|
@@ -2787,6 +2802,7 @@ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input
|
|
2787
2802
|
return null;
|
2788
2803
|
}
|
2789
2804
|
const { center: dragCenter } = dragShape;
|
2805
|
+
const { fallbackEnabled } = collisionStore.getState();
|
2790
2806
|
const interval = trackMovementInterval(position.current, dragAxis);
|
2791
2807
|
dragOperation.data = __spreadProps(__spreadValues({}, dragOperation.data), {
|
2792
2808
|
direction: interval.direction
|
@@ -2832,7 +2848,7 @@ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input
|
|
2832
2848
|
flushNext = "";
|
2833
2849
|
return __spreadProps(__spreadValues({}, collision), { id: shouldFlushId ? "flush" : collision.id });
|
2834
2850
|
}
|
2835
|
-
if (((_c = dragOperation.source) == null ? void 0 : _c.id) !== droppable.id) {
|
2851
|
+
if (fallbackEnabled && ((_c = dragOperation.source) == null ? void 0 : _c.id) !== droppable.id) {
|
2836
2852
|
const xAxisIntersection = dropShape.boundingRectangle.right > dragShape.boundingRectangle.left && dropShape.boundingRectangle.left < dragShape.boundingRectangle.right;
|
2837
2853
|
const yAxisIntersection = dropShape.boundingRectangle.bottom > dragShape.boundingRectangle.top && dropShape.boundingRectangle.top < dragShape.boundingRectangle.bottom;
|
2838
2854
|
if (dragAxis === "y" && xAxisIntersection || yAxisIntersection) {
|
@@ -2893,8 +2909,102 @@ function getDeepScrollPosition(element) {
|
|
2893
2909
|
return totalScroll;
|
2894
2910
|
}
|
2895
2911
|
|
2896
|
-
// components/
|
2912
|
+
// components/DropZone/context.tsx
|
2913
|
+
init_react_import();
|
2914
|
+
var import_react20 = require("react");
|
2915
|
+
var import_zustand = require("zustand");
|
2897
2916
|
var import_jsx_runtime19 = require("react/jsx-runtime");
|
2917
|
+
var dropZoneContext = (0, import_react20.createContext)(null);
|
2918
|
+
var ZoneStoreContext = (0, import_react20.createContext)(
|
2919
|
+
(0, import_zustand.createStore)(() => ({
|
2920
|
+
zoneDepthIndex: {},
|
2921
|
+
nextZoneDepthIndex: {},
|
2922
|
+
areaDepthIndex: {},
|
2923
|
+
nextAreaDepthIndex: {},
|
2924
|
+
draggedItem: null,
|
2925
|
+
previewIndex: {}
|
2926
|
+
}))
|
2927
|
+
);
|
2928
|
+
var ZoneStoreProvider = ({
|
2929
|
+
children,
|
2930
|
+
store
|
2931
|
+
}) => {
|
2932
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(ZoneStoreContext.Provider, { value: store, children });
|
2933
|
+
};
|
2934
|
+
var DropZoneProvider = ({
|
2935
|
+
children,
|
2936
|
+
value
|
2937
|
+
}) => {
|
2938
|
+
const [hoveringComponent, setHoveringComponent] = (0, import_react20.useState)();
|
2939
|
+
const [areasWithZones, setAreasWithZones] = (0, import_react20.useState)(
|
2940
|
+
{}
|
2941
|
+
);
|
2942
|
+
const [activeZones, setActiveZones] = (0, import_react20.useState)({});
|
2943
|
+
const { dispatch } = useAppContext();
|
2944
|
+
const registerZoneArea = (0, import_react20.useCallback)(
|
2945
|
+
(area) => {
|
2946
|
+
setAreasWithZones((latest) => __spreadProps(__spreadValues({}, latest), { [area]: true }));
|
2947
|
+
},
|
2948
|
+
[setAreasWithZones]
|
2949
|
+
);
|
2950
|
+
const registerZone = (0, import_react20.useCallback)(
|
2951
|
+
(zoneCompound) => {
|
2952
|
+
if (!dispatch) {
|
2953
|
+
return;
|
2954
|
+
}
|
2955
|
+
dispatch({
|
2956
|
+
type: "registerZone",
|
2957
|
+
zone: zoneCompound
|
2958
|
+
});
|
2959
|
+
setActiveZones((latest) => __spreadProps(__spreadValues({}, latest), { [zoneCompound]: true }));
|
2960
|
+
},
|
2961
|
+
[setActiveZones, dispatch]
|
2962
|
+
);
|
2963
|
+
const unregisterZone = (0, import_react20.useCallback)(
|
2964
|
+
(zoneCompound) => {
|
2965
|
+
if (!dispatch) {
|
2966
|
+
return;
|
2967
|
+
}
|
2968
|
+
dispatch({
|
2969
|
+
type: "unregisterZone",
|
2970
|
+
zone: zoneCompound
|
2971
|
+
});
|
2972
|
+
setActiveZones((latest) => __spreadProps(__spreadValues({}, latest), {
|
2973
|
+
[zoneCompound]: false
|
2974
|
+
}));
|
2975
|
+
},
|
2976
|
+
[setActiveZones, dispatch]
|
2977
|
+
);
|
2978
|
+
const memoValue = (0, import_react20.useMemo)(
|
2979
|
+
() => __spreadValues({
|
2980
|
+
hoveringComponent,
|
2981
|
+
setHoveringComponent,
|
2982
|
+
registerZoneArea,
|
2983
|
+
areasWithZones,
|
2984
|
+
registerZone,
|
2985
|
+
unregisterZone,
|
2986
|
+
activeZones
|
2987
|
+
}, value),
|
2988
|
+
[value, hoveringComponent, areasWithZones, activeZones]
|
2989
|
+
);
|
2990
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_jsx_runtime19.Fragment, { children: memoValue && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(dropZoneContext.Provider, { value: memoValue, children }) });
|
2991
|
+
};
|
2992
|
+
|
2993
|
+
// lib/use-context-store.ts
|
2994
|
+
init_react_import();
|
2995
|
+
var import_react21 = require("react");
|
2996
|
+
var import_zustand2 = require("zustand");
|
2997
|
+
var import_shallow = require("zustand/react/shallow");
|
2998
|
+
function useContextStore(context, selector) {
|
2999
|
+
const store = (0, import_react21.useContext)(context);
|
3000
|
+
if (!store) {
|
3001
|
+
throw new Error("useContextStore must be used inside context");
|
3002
|
+
}
|
3003
|
+
return (0, import_zustand2.useStore)(store, (0, import_shallow.useShallow)(selector));
|
3004
|
+
}
|
3005
|
+
|
3006
|
+
// components/DraggableComponent/index.tsx
|
3007
|
+
var import_jsx_runtime20 = require("react/jsx-runtime");
|
2898
3008
|
var getClassName16 = get_class_name_factory_default("DraggableComponent", styles_module_default11);
|
2899
3009
|
var DEBUG2 = false;
|
2900
3010
|
var space = 8;
|
@@ -2905,12 +3015,12 @@ var DefaultActionBar = ({
|
|
2905
3015
|
label,
|
2906
3016
|
children,
|
2907
3017
|
parentAction
|
2908
|
-
}) => /* @__PURE__ */ (0,
|
2909
|
-
/* @__PURE__ */ (0,
|
3018
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(ActionBar, { children: [
|
3019
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(ActionBar.Group, { children: [
|
2910
3020
|
parentAction,
|
2911
|
-
label && /* @__PURE__ */ (0,
|
3021
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(ActionBar.Label, { label })
|
2912
3022
|
] }),
|
2913
|
-
/* @__PURE__ */ (0,
|
3023
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(ActionBar.Group, { children })
|
2914
3024
|
] });
|
2915
3025
|
var convertIdToSelector = (id, zoneCompound, data) => {
|
2916
3026
|
const content = zoneCompound && data.zones && zoneCompound !== "default-zone" ? data.zones[zoneCompound] : data.content;
|
@@ -2945,9 +3055,9 @@ var DraggableComponent = ({
|
|
2945
3055
|
iframe,
|
2946
3056
|
state
|
2947
3057
|
} = useAppContext();
|
2948
|
-
const ctx = (0,
|
2949
|
-
const [localZones, setLocalZones] = (0,
|
2950
|
-
const registerLocalZone = (0,
|
3058
|
+
const ctx = (0, import_react22.useContext)(dropZoneContext);
|
3059
|
+
const [localZones, setLocalZones] = (0, import_react22.useState)({});
|
3060
|
+
const registerLocalZone = (0, import_react22.useCallback)(
|
2951
3061
|
(zoneCompound2, active) => {
|
2952
3062
|
var _a;
|
2953
3063
|
(_a = ctx == null ? void 0 : ctx.registerLocalZone) == null ? void 0 : _a.call(ctx, zoneCompound2, active);
|
@@ -2957,7 +3067,7 @@ var DraggableComponent = ({
|
|
2957
3067
|
},
|
2958
3068
|
[setLocalZones]
|
2959
3069
|
);
|
2960
|
-
const unregisterLocalZone = (0,
|
3070
|
+
const unregisterLocalZone = (0, import_react22.useCallback)(
|
2961
3071
|
(zoneCompound2) => {
|
2962
3072
|
var _a;
|
2963
3073
|
(_a = ctx == null ? void 0 : ctx.unregisterLocalZone) == null ? void 0 : _a.call(ctx, zoneCompound2);
|
@@ -2971,8 +3081,8 @@ var DraggableComponent = ({
|
|
2971
3081
|
);
|
2972
3082
|
const containsActiveZone = Object.values(localZones).filter(Boolean).length > 0;
|
2973
3083
|
const { path = [] } = ctx || {};
|
2974
|
-
const [canDrag, setCanDrag] = (0,
|
2975
|
-
(0,
|
3084
|
+
const [canDrag, setCanDrag] = (0, import_react22.useState)(false);
|
3085
|
+
(0, import_react22.useEffect)(() => {
|
2976
3086
|
var _a;
|
2977
3087
|
const item = getItem({ index, zone: zoneCompound }, state.data);
|
2978
3088
|
if (item) {
|
@@ -2982,10 +3092,13 @@ var DraggableComponent = ({
|
|
2982
3092
|
setCanDrag((_a = perms.drag) != null ? _a : true);
|
2983
3093
|
}
|
2984
3094
|
}, [state, index, zoneCompound, getPermissions]);
|
2985
|
-
const userIsDragging =
|
3095
|
+
const userIsDragging = useContextStore(
|
3096
|
+
ZoneStoreContext,
|
3097
|
+
(s) => !!s.draggedItem
|
3098
|
+
);
|
2986
3099
|
const canCollide = canDrag || userIsDragging;
|
2987
3100
|
const disabled = !isEnabled || !canCollide;
|
2988
|
-
const [dragAxis, setDragAxis] = (0,
|
3101
|
+
const [dragAxis, setDragAxis] = (0, import_react22.useState)(userDragAxis || autoDragAxis);
|
2989
3102
|
const { ref: sortableRef, status } = useSortableSafe({
|
2990
3103
|
id,
|
2991
3104
|
index,
|
@@ -3011,8 +3124,8 @@ var DraggableComponent = ({
|
|
3011
3124
|
}
|
3012
3125
|
});
|
3013
3126
|
const thisIsDragging = status === "dragging";
|
3014
|
-
const ref = (0,
|
3015
|
-
const refSetter = (0,
|
3127
|
+
const ref = (0, import_react22.useRef)(null);
|
3128
|
+
const refSetter = (0, import_react22.useCallback)(
|
3016
3129
|
(el) => {
|
3017
3130
|
sortableRef(el);
|
3018
3131
|
if (el) {
|
@@ -3021,14 +3134,14 @@ var DraggableComponent = ({
|
|
3021
3134
|
},
|
3022
3135
|
[sortableRef]
|
3023
3136
|
);
|
3024
|
-
const [portalEl, setPortalEl] = (0,
|
3025
|
-
(0,
|
3137
|
+
const [portalEl, setPortalEl] = (0, import_react22.useState)();
|
3138
|
+
(0, import_react22.useEffect)(() => {
|
3026
3139
|
var _a, _b, _c;
|
3027
3140
|
setPortalEl(
|
3028
3141
|
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
3142
|
);
|
3030
3143
|
}, [iframe.enabled, ref.current]);
|
3031
|
-
const getStyle = (0,
|
3144
|
+
const getStyle = (0, import_react22.useCallback)(() => {
|
3032
3145
|
var _a, _b, _c;
|
3033
3146
|
if (!ref.current) return;
|
3034
3147
|
const rect = ref.current.getBoundingClientRect();
|
@@ -3048,11 +3161,11 @@ var DraggableComponent = ({
|
|
3048
3161
|
};
|
3049
3162
|
return style2;
|
3050
3163
|
}, [ref.current]);
|
3051
|
-
const [style, setStyle] = (0,
|
3052
|
-
const sync = (0,
|
3164
|
+
const [style, setStyle] = (0, import_react22.useState)();
|
3165
|
+
const sync = (0, import_react22.useCallback)(() => {
|
3053
3166
|
setStyle(getStyle());
|
3054
3167
|
}, [ref.current, iframe]);
|
3055
|
-
(0,
|
3168
|
+
(0, import_react22.useEffect)(() => {
|
3056
3169
|
if (ref.current) {
|
3057
3170
|
const observer = new ResizeObserver(sync);
|
3058
3171
|
observer.observe(ref.current);
|
@@ -3061,20 +3174,22 @@ var DraggableComponent = ({
|
|
3061
3174
|
};
|
3062
3175
|
}
|
3063
3176
|
}, [ref.current]);
|
3064
|
-
(0,
|
3065
|
-
|
3066
|
-
|
3067
|
-
|
3068
|
-
|
3177
|
+
(0, import_react22.useEffect)(() => {
|
3178
|
+
if (isSelected) {
|
3179
|
+
ctx == null ? void 0 : ctx.registerPath({
|
3180
|
+
index,
|
3181
|
+
zone: zoneCompound
|
3182
|
+
});
|
3183
|
+
}
|
3069
3184
|
}, [isSelected]);
|
3070
|
-
const CustomActionBar = (0,
|
3185
|
+
const CustomActionBar = (0, import_react22.useMemo)(
|
3071
3186
|
() => overrides.actionBar || DefaultActionBar,
|
3072
3187
|
[overrides.actionBar]
|
3073
3188
|
);
|
3074
3189
|
const permissions = getPermissions({
|
3075
3190
|
item: selectedItem
|
3076
3191
|
});
|
3077
|
-
const onClick = (0,
|
3192
|
+
const onClick = (0, import_react22.useCallback)(
|
3078
3193
|
(e) => {
|
3079
3194
|
e.stopPropagation();
|
3080
3195
|
dispatch({
|
@@ -3086,7 +3201,7 @@ var DraggableComponent = ({
|
|
3086
3201
|
},
|
3087
3202
|
[index, zoneCompound, id]
|
3088
3203
|
);
|
3089
|
-
const onSelectParent = (0,
|
3204
|
+
const onSelectParent = (0, import_react22.useCallback)(() => {
|
3090
3205
|
if (!(ctx == null ? void 0 : ctx.areaId)) {
|
3091
3206
|
return;
|
3092
3207
|
}
|
@@ -3104,23 +3219,23 @@ var DraggableComponent = ({
|
|
3104
3219
|
}
|
3105
3220
|
});
|
3106
3221
|
}, [ctx, path]);
|
3107
|
-
const onDuplicate = (0,
|
3222
|
+
const onDuplicate = (0, import_react22.useCallback)(() => {
|
3108
3223
|
dispatch({
|
3109
3224
|
type: "duplicate",
|
3110
3225
|
sourceIndex: index,
|
3111
3226
|
sourceZone: zoneCompound
|
3112
3227
|
});
|
3113
3228
|
}, [index, zoneCompound]);
|
3114
|
-
const onDelete = (0,
|
3229
|
+
const onDelete = (0, import_react22.useCallback)(() => {
|
3115
3230
|
dispatch({
|
3116
3231
|
type: "remove",
|
3117
3232
|
index,
|
3118
3233
|
zone: zoneCompound
|
3119
3234
|
});
|
3120
3235
|
}, [index, zoneCompound]);
|
3121
|
-
const [hover, setHover] = (0,
|
3236
|
+
const [hover, setHover] = (0, import_react22.useState)(false);
|
3122
3237
|
const indicativeHover = (ctx == null ? void 0 : ctx.hoveringComponent) === id;
|
3123
|
-
(0,
|
3238
|
+
(0, import_react22.useEffect)(() => {
|
3124
3239
|
if (!ref.current) {
|
3125
3240
|
return;
|
3126
3241
|
}
|
@@ -3170,7 +3285,7 @@ var DraggableComponent = ({
|
|
3170
3285
|
thisIsDragging,
|
3171
3286
|
inDroppableZone
|
3172
3287
|
]);
|
3173
|
-
(0,
|
3288
|
+
(0, import_react22.useEffect)(() => {
|
3174
3289
|
if (ref.current && disabled) {
|
3175
3290
|
ref.current.setAttribute("data-puck-disabled", "");
|
3176
3291
|
return () => {
|
@@ -3179,8 +3294,8 @@ var DraggableComponent = ({
|
|
3179
3294
|
};
|
3180
3295
|
}
|
3181
3296
|
}, [disabled, ref]);
|
3182
|
-
const [isVisible, setIsVisible] = (0,
|
3183
|
-
(0,
|
3297
|
+
const [isVisible, setIsVisible] = (0, import_react22.useState)(false);
|
3298
|
+
(0, import_react22.useEffect)(() => {
|
3184
3299
|
sync();
|
3185
3300
|
if ((isSelected || hover || indicativeHover) && !userIsDragging) {
|
3186
3301
|
setIsVisible(true);
|
@@ -3188,7 +3303,7 @@ var DraggableComponent = ({
|
|
3188
3303
|
setIsVisible(false);
|
3189
3304
|
}
|
3190
3305
|
}, [isSelected, hover, indicativeHover, iframe, state.data, userIsDragging]);
|
3191
|
-
const syncActionsPosition = (0,
|
3306
|
+
const syncActionsPosition = (0, import_react22.useCallback)(
|
3192
3307
|
(el) => {
|
3193
3308
|
if (el) {
|
3194
3309
|
const view = el.ownerDocument.defaultView;
|
@@ -3205,7 +3320,7 @@ var DraggableComponent = ({
|
|
3205
3320
|
},
|
3206
3321
|
[zoomConfig]
|
3207
3322
|
);
|
3208
|
-
(0,
|
3323
|
+
(0, import_react22.useEffect)(() => {
|
3209
3324
|
if (userDragAxis) {
|
3210
3325
|
setDragAxis(userDragAxis);
|
3211
3326
|
return;
|
@@ -3219,8 +3334,8 @@ var DraggableComponent = ({
|
|
3219
3334
|
}
|
3220
3335
|
setDragAxis(autoDragAxis);
|
3221
3336
|
}, [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,
|
3337
|
+
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 }) });
|
3338
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
|
3224
3339
|
DropZoneProvider,
|
3225
3340
|
{
|
3226
3341
|
value: __spreadProps(__spreadValues({}, ctx), {
|
@@ -3234,7 +3349,7 @@ var DraggableComponent = ({
|
|
3234
3349
|
}),
|
3235
3350
|
children: [
|
3236
3351
|
isVisible && (0, import_react_dom2.createPortal)(
|
3237
|
-
/* @__PURE__ */ (0,
|
3352
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
|
3238
3353
|
"div",
|
3239
3354
|
{
|
3240
3355
|
className: getClassName16({
|
@@ -3246,15 +3361,15 @@ var DraggableComponent = ({
|
|
3246
3361
|
"data-puck-overlay": true,
|
3247
3362
|
children: [
|
3248
3363
|
debug,
|
3249
|
-
isLoading && /* @__PURE__ */ (0,
|
3250
|
-
/* @__PURE__ */ (0,
|
3364
|
+
isLoading && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: getClassName16("loadingOverlay"), children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Loader, {}) }),
|
3365
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
3251
3366
|
"div",
|
3252
3367
|
{
|
3253
3368
|
className: getClassName16("actionsOverlay"),
|
3254
3369
|
style: {
|
3255
3370
|
top: actionsOverlayTop / zoomConfig.zoom
|
3256
3371
|
},
|
3257
|
-
children: /* @__PURE__ */ (0,
|
3372
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
3258
3373
|
"div",
|
3259
3374
|
{
|
3260
3375
|
className: getClassName16("actions"),
|
@@ -3266,14 +3381,14 @@ var DraggableComponent = ({
|
|
3266
3381
|
paddingRight: actionsSide
|
3267
3382
|
},
|
3268
3383
|
ref: syncActionsPosition,
|
3269
|
-
children: /* @__PURE__ */ (0,
|
3384
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
|
3270
3385
|
CustomActionBar,
|
3271
3386
|
{
|
3272
3387
|
parentAction,
|
3273
3388
|
label: DEBUG2 ? id : label,
|
3274
3389
|
children: [
|
3275
|
-
permissions.duplicate && /* @__PURE__ */ (0,
|
3276
|
-
permissions.delete && /* @__PURE__ */ (0,
|
3390
|
+
permissions.duplicate && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(ActionBar.Action, { onClick: onDuplicate, label: "Duplicate", children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Copy, { size: 16 }) }),
|
3391
|
+
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
3392
|
]
|
3278
3393
|
}
|
3279
3394
|
)
|
@@ -3281,7 +3396,7 @@ var DraggableComponent = ({
|
|
3281
3396
|
)
|
3282
3397
|
}
|
3283
3398
|
),
|
3284
|
-
/* @__PURE__ */ (0,
|
3399
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: getClassName16("overlay") })
|
3285
3400
|
]
|
3286
3401
|
}
|
3287
3402
|
),
|
@@ -3297,93 +3412,26 @@ var DraggableComponent = ({
|
|
3297
3412
|
init_react_import();
|
3298
3413
|
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
3414
|
|
3300
|
-
// components/DropZone/
|
3415
|
+
// components/DropZone/lib/use-min-empty-height.ts
|
3301
3416
|
init_react_import();
|
3302
|
-
var
|
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
|
3365
|
-
init_react_import();
|
3366
|
-
var insert = (list, index, item) => {
|
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");
|
3417
|
+
var import_react23 = require("react");
|
3375
3418
|
var useMinEmptyHeight = ({
|
3376
|
-
draggedItem,
|
3377
3419
|
zoneCompound,
|
3378
3420
|
userMinEmptyHeight,
|
3379
3421
|
ref
|
3380
3422
|
}) => {
|
3381
|
-
const [prevHeight, setPrevHeight] = (0,
|
3382
|
-
const [isAnimating, setIsAnimating] = (0,
|
3383
|
-
(
|
3423
|
+
const [prevHeight, setPrevHeight] = (0, import_react23.useState)(0);
|
3424
|
+
const [isAnimating, setIsAnimating] = (0, import_react23.useState)(false);
|
3425
|
+
const { draggedItem, isZone } = useContextStore(ZoneStoreContext, (s) => {
|
3426
|
+
var _a, _b;
|
3427
|
+
return {
|
3428
|
+
draggedItem: ((_a = s.draggedItem) == null ? void 0 : _a.data.zone) === zoneCompound ? s.draggedItem : null,
|
3429
|
+
isZone: ((_b = s.draggedItem) == null ? void 0 : _b.data.zone) === zoneCompound
|
3430
|
+
};
|
3431
|
+
});
|
3432
|
+
(0, import_react23.useEffect)(() => {
|
3384
3433
|
if (draggedItem && ref.current) {
|
3385
|
-
|
3386
|
-
if (componentData.zone === zoneCompound) {
|
3434
|
+
if (isZone) {
|
3387
3435
|
const rect = ref.current.getBoundingClientRect();
|
3388
3436
|
setPrevHeight(rect.height);
|
3389
3437
|
setIsAnimating(true);
|
@@ -3413,14 +3461,129 @@ function assignRefs(refs, node) {
|
|
3413
3461
|
});
|
3414
3462
|
}
|
3415
3463
|
|
3416
|
-
// components/DropZone/
|
3417
|
-
|
3418
|
-
var
|
3419
|
-
|
3464
|
+
// components/DropZone/lib/use-content-with-preview.ts
|
3465
|
+
init_react_import();
|
3466
|
+
var import_react26 = require("react");
|
3467
|
+
|
3468
|
+
// lib/dnd/use-rendered-callback.ts
|
3469
|
+
init_react_import();
|
3470
|
+
var import_react24 = require("@dnd-kit/react");
|
3471
|
+
var import_react25 = require("react");
|
3472
|
+
function useRenderedCallback(callback, deps) {
|
3473
|
+
const manager = (0, import_react24.useDragDropManager)();
|
3474
|
+
return (0, import_react25.useCallback)(
|
3475
|
+
(...args) => __async(this, null, function* () {
|
3476
|
+
yield manager == null ? void 0 : manager.renderer.rendering;
|
3477
|
+
return callback(...args);
|
3478
|
+
}),
|
3479
|
+
[...deps, manager]
|
3480
|
+
);
|
3481
|
+
}
|
3482
|
+
|
3483
|
+
// lib/insert.ts
|
3484
|
+
init_react_import();
|
3485
|
+
var insert = (list, index, item) => {
|
3486
|
+
const result = Array.from(list);
|
3487
|
+
result.splice(index, 0, item);
|
3488
|
+
return result;
|
3489
|
+
};
|
3490
|
+
|
3491
|
+
// components/DropZone/lib/use-content-with-preview.ts
|
3492
|
+
var useContentWithPreview = (content, zoneCompound) => {
|
3493
|
+
const { draggedItemId, preview, previewExists } = useContextStore(
|
3494
|
+
ZoneStoreContext,
|
3495
|
+
(s) => {
|
3496
|
+
var _a;
|
3497
|
+
return {
|
3498
|
+
draggedItemId: (_a = s.draggedItem) == null ? void 0 : _a.id,
|
3499
|
+
preview: s.previewIndex[zoneCompound],
|
3500
|
+
previewExists: Object.keys(s.previewIndex || {}).length > 0
|
3501
|
+
};
|
3502
|
+
}
|
3503
|
+
);
|
3504
|
+
const [contentWithPreview, setContentWithPreview] = (0, import_react26.useState)(content);
|
3505
|
+
const updateContent = useRenderedCallback(
|
3506
|
+
(content2, preview2) => {
|
3507
|
+
if (preview2) {
|
3508
|
+
if (preview2.type === "insert") {
|
3509
|
+
setContentWithPreview(
|
3510
|
+
insert(
|
3511
|
+
content2.filter((item) => item.props.id !== preview2.props.id),
|
3512
|
+
preview2.index,
|
3513
|
+
{
|
3514
|
+
type: "preview",
|
3515
|
+
props: { id: preview2.props.id }
|
3516
|
+
}
|
3517
|
+
)
|
3518
|
+
);
|
3519
|
+
} else {
|
3520
|
+
setContentWithPreview(
|
3521
|
+
insert(
|
3522
|
+
content2.filter((item) => item.props.id !== preview2.props.id),
|
3523
|
+
preview2.index,
|
3524
|
+
{
|
3525
|
+
type: preview2.componentType,
|
3526
|
+
props: preview2.props
|
3527
|
+
}
|
3528
|
+
)
|
3529
|
+
);
|
3530
|
+
}
|
3531
|
+
} else {
|
3532
|
+
setContentWithPreview(
|
3533
|
+
previewExists ? content2.filter((item) => item.props.id !== draggedItemId) : content2
|
3534
|
+
);
|
3535
|
+
}
|
3536
|
+
},
|
3537
|
+
[draggedItemId, previewExists]
|
3538
|
+
);
|
3539
|
+
(0, import_react26.useEffect)(() => {
|
3540
|
+
updateContent(content, preview);
|
3541
|
+
}, [content, preview]);
|
3542
|
+
return contentWithPreview;
|
3543
|
+
};
|
3544
|
+
|
3545
|
+
// components/DropZone/lib/use-drag-axis.ts
|
3546
|
+
init_react_import();
|
3547
|
+
var import_react27 = require("react");
|
3420
3548
|
var GRID_DRAG_AXIS = "dynamic";
|
3421
3549
|
var FLEX_ROW_DRAG_AXIS = "x";
|
3422
3550
|
var DEFAULT_DRAG_AXIS = "y";
|
3423
|
-
var
|
3551
|
+
var useDragAxis = (ref, collisionAxis) => {
|
3552
|
+
const { status } = useAppContext();
|
3553
|
+
const [dragAxis, setDragAxis] = (0, import_react27.useState)(
|
3554
|
+
collisionAxis || DEFAULT_DRAG_AXIS
|
3555
|
+
);
|
3556
|
+
const calculateDragAxis = (0, import_react27.useCallback)(() => {
|
3557
|
+
if (ref.current) {
|
3558
|
+
const computedStyle = window.getComputedStyle(ref.current);
|
3559
|
+
if (computedStyle.display === "grid") {
|
3560
|
+
setDragAxis(GRID_DRAG_AXIS);
|
3561
|
+
} else if (computedStyle.display === "flex" && computedStyle.flexDirection === "row") {
|
3562
|
+
setDragAxis(FLEX_ROW_DRAG_AXIS);
|
3563
|
+
} else {
|
3564
|
+
setDragAxis(DEFAULT_DRAG_AXIS);
|
3565
|
+
}
|
3566
|
+
}
|
3567
|
+
}, [ref.current]);
|
3568
|
+
(0, import_react27.useEffect)(() => {
|
3569
|
+
const onViewportChange = () => {
|
3570
|
+
calculateDragAxis();
|
3571
|
+
};
|
3572
|
+
window.addEventListener("viewportchange", onViewportChange);
|
3573
|
+
return () => {
|
3574
|
+
window.removeEventListener("viewportchange", onViewportChange);
|
3575
|
+
};
|
3576
|
+
}, []);
|
3577
|
+
(0, import_react27.useEffect)(calculateDragAxis, [status, collisionAxis]);
|
3578
|
+
return [dragAxis, calculateDragAxis];
|
3579
|
+
};
|
3580
|
+
|
3581
|
+
// components/DropZone/index.tsx
|
3582
|
+
var import_jsx_runtime21 = require("react/jsx-runtime");
|
3583
|
+
var getClassName17 = get_class_name_factory_default("DropZone", styles_module_default12);
|
3584
|
+
var getRandomColor = () => `#${Math.floor(Math.random() * 16777215).toString(16)}`;
|
3585
|
+
var RENDER_DEBUG = false;
|
3586
|
+
var DropZoneEdit = (0, import_react28.forwardRef)(
|
3424
3587
|
function DropZoneEdit2({
|
3425
3588
|
zone,
|
3426
3589
|
allow,
|
@@ -3431,31 +3594,50 @@ var DropZoneEdit = (0, import_react23.forwardRef)(
|
|
3431
3594
|
collisionAxis
|
3432
3595
|
}, userRef) {
|
3433
3596
|
const appContext2 = useAppContext();
|
3434
|
-
const ctx = (0,
|
3597
|
+
const ctx = (0, import_react28.useContext)(dropZoneContext);
|
3435
3598
|
const {
|
3436
3599
|
// These all need setting via context
|
3437
3600
|
data,
|
3438
3601
|
config,
|
3439
3602
|
areaId,
|
3440
|
-
draggedItem,
|
3441
3603
|
registerZoneArea,
|
3442
3604
|
depth,
|
3443
3605
|
registerLocalZone,
|
3444
3606
|
unregisterLocalZone,
|
3445
|
-
deepestZone = rootDroppableId,
|
3446
|
-
deepestArea,
|
3447
|
-
nextDeepestArea,
|
3448
3607
|
path = [],
|
3449
3608
|
activeZones
|
3450
3609
|
} = ctx;
|
3451
|
-
const { itemSelector } = appContext2.state.ui;
|
3452
3610
|
let zoneCompound = rootDroppableId;
|
3453
|
-
|
3611
|
+
if (areaId) {
|
3612
|
+
if (zone !== rootDroppableId) {
|
3613
|
+
zoneCompound = `${areaId}:${zone}`;
|
3614
|
+
}
|
3615
|
+
}
|
3616
|
+
const isRootZone = zoneCompound === rootDroppableId || zone === rootDroppableId || areaId === "root";
|
3617
|
+
const {
|
3618
|
+
isDeepestZone,
|
3619
|
+
inNextDeepestArea,
|
3620
|
+
draggedComponentType,
|
3621
|
+
userIsDragging,
|
3622
|
+
preview
|
3623
|
+
} = useContextStore(ZoneStoreContext, (s) => {
|
3624
|
+
var _a, _b, _c;
|
3625
|
+
return {
|
3626
|
+
isDeepestZone: (_a = s.zoneDepthIndex[zoneCompound]) != null ? _a : false,
|
3627
|
+
inNextDeepestArea: s.nextAreaDepthIndex[areaId || ""],
|
3628
|
+
draggedItemId: (_b = s.draggedItem) == null ? void 0 : _b.id,
|
3629
|
+
draggedComponentType: (_c = s.draggedItem) == null ? void 0 : _c.data.componentType,
|
3630
|
+
userIsDragging: !!s.draggedItem,
|
3631
|
+
preview: s.previewIndex[zoneCompound]
|
3632
|
+
};
|
3633
|
+
});
|
3634
|
+
const { itemSelector } = appContext2.state.ui;
|
3635
|
+
(0, import_react28.useEffect)(() => {
|
3454
3636
|
if (areaId && registerZoneArea) {
|
3455
3637
|
registerZoneArea(areaId);
|
3456
3638
|
}
|
3457
3639
|
}, [areaId]);
|
3458
|
-
(0,
|
3640
|
+
(0, import_react28.useEffect)(() => {
|
3459
3641
|
if (ctx == null ? void 0 : ctx.registerZone) {
|
3460
3642
|
ctx == null ? void 0 : ctx.registerZone(zoneCompound);
|
3461
3643
|
}
|
@@ -3465,25 +3647,18 @@ var DropZoneEdit = (0, import_react23.forwardRef)(
|
|
3465
3647
|
}
|
3466
3648
|
};
|
3467
3649
|
}, []);
|
3468
|
-
|
3469
|
-
if (zone !== rootDroppableId) {
|
3470
|
-
zoneCompound = `${areaId}:${zone}`;
|
3471
|
-
}
|
3472
|
-
}
|
3473
|
-
const content = (0, import_react23.useMemo)(() => {
|
3650
|
+
const content = (0, import_react28.useMemo)(() => {
|
3474
3651
|
if (areaId && zone !== rootDroppableId) {
|
3475
3652
|
return setupZone(data, zoneCompound).zones[zoneCompound];
|
3476
3653
|
}
|
3477
3654
|
return data.content || [];
|
3478
3655
|
}, [data, zoneCompound]);
|
3479
|
-
const ref = (0,
|
3480
|
-
const acceptsTarget = (0,
|
3481
|
-
(
|
3482
|
-
if (!
|
3656
|
+
const ref = (0, import_react28.useRef)(null);
|
3657
|
+
const acceptsTarget = (0, import_react28.useCallback)(
|
3658
|
+
(componentType) => {
|
3659
|
+
if (!componentType) {
|
3483
3660
|
return true;
|
3484
3661
|
}
|
3485
|
-
const data2 = target.data;
|
3486
|
-
const { componentType } = data2;
|
3487
3662
|
if (disallow) {
|
3488
3663
|
const defaultedAllow = allow || [];
|
3489
3664
|
const filteredDisallow = (disallow || []).filter(
|
@@ -3501,49 +3676,26 @@ var DropZoneEdit = (0, import_react23.forwardRef)(
|
|
3501
3676
|
},
|
3502
3677
|
[allow, disallow]
|
3503
3678
|
);
|
3504
|
-
(0,
|
3679
|
+
(0, import_react28.useEffect)(() => {
|
3505
3680
|
if (registerLocalZone) {
|
3506
|
-
registerLocalZone(zoneCompound, acceptsTarget(
|
3681
|
+
registerLocalZone(zoneCompound, acceptsTarget(draggedComponentType));
|
3507
3682
|
}
|
3508
3683
|
return () => {
|
3509
3684
|
if (unregisterLocalZone) {
|
3510
3685
|
unregisterLocalZone(zoneCompound);
|
3511
3686
|
}
|
3512
3687
|
};
|
3513
|
-
}, [
|
3514
|
-
const
|
3515
|
-
const hoveringOverArea = nextDeepestArea ? nextDeepestArea === areaId : isRootZone;
|
3516
|
-
const userIsDragging = !!draggedItem;
|
3688
|
+
}, [draggedComponentType, zoneCompound]);
|
3689
|
+
const hoveringOverArea = inNextDeepestArea || isRootZone;
|
3517
3690
|
let isEnabled = true;
|
3518
|
-
if (
|
3519
|
-
isEnabled =
|
3691
|
+
if (userIsDragging) {
|
3692
|
+
isEnabled = isDeepestZone;
|
3520
3693
|
}
|
3521
3694
|
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);
|
3695
|
+
isEnabled = acceptsTarget(draggedComponentType);
|
3696
|
+
}
|
3697
|
+
const contentWithPreview = useContentWithPreview(content, zoneCompound);
|
3698
|
+
const isDropEnabled = isEnabled && (preview ? contentWithPreview.length === 1 : contentWithPreview.length === 0);
|
3547
3699
|
const droppableConfig = {
|
3548
3700
|
id: zoneCompound,
|
3549
3701
|
collisionPriority: isEnabled ? depth : 0,
|
@@ -3553,45 +3705,20 @@ var DropZoneEdit = (0, import_react23.forwardRef)(
|
|
3553
3705
|
data: {
|
3554
3706
|
areaId,
|
3555
3707
|
depth,
|
3556
|
-
isDroppableTarget: acceptsTarget(
|
3708
|
+
isDroppableTarget: acceptsTarget(draggedComponentType),
|
3557
3709
|
path
|
3558
3710
|
}
|
3559
3711
|
};
|
3560
3712
|
const { ref: dropRef } = useDroppableSafe(droppableConfig);
|
3561
3713
|
const selectedItem = itemSelector ? getItem(itemSelector, data) : null;
|
3562
3714
|
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
|
-
}, []);
|
3715
|
+
const [dragAxis] = useDragAxis(ref, collisionAxis);
|
3588
3716
|
const [minEmptyHeight, isAnimating] = useMinEmptyHeight({
|
3589
|
-
draggedItem,
|
3590
3717
|
zoneCompound,
|
3591
3718
|
userMinEmptyHeight,
|
3592
3719
|
ref
|
3593
3720
|
});
|
3594
|
-
return /* @__PURE__ */ (0, import_jsx_runtime21.
|
3721
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
3595
3722
|
"div",
|
3596
3723
|
{
|
3597
3724
|
className: `${getClassName17({
|
@@ -3611,88 +3738,83 @@ var DropZoneEdit = (0, import_react23.forwardRef)(
|
|
3611
3738
|
"data-puck-dropzone": zoneCompound,
|
3612
3739
|
"data-puck-dnd": zoneCompound,
|
3613
3740
|
style: __spreadProps(__spreadValues({}, style), {
|
3614
|
-
"--min-empty-height": `${minEmptyHeight}px
|
3741
|
+
"--min-empty-height": `${minEmptyHeight}px`,
|
3742
|
+
backgroundColor: RENDER_DEBUG ? getRandomColor() : void 0
|
3615
3743
|
}),
|
3616
|
-
children:
|
3617
|
-
|
3618
|
-
|
3619
|
-
|
3620
|
-
|
3621
|
-
|
3622
|
-
|
3623
|
-
|
3624
|
-
|
3625
|
-
|
3626
|
-
|
3627
|
-
|
3744
|
+
children: contentWithPreview.map((item, i) => {
|
3745
|
+
var _a, _b, _c, _d, _e;
|
3746
|
+
const componentId = item.props.id;
|
3747
|
+
const puckProps = {
|
3748
|
+
renderDropZone: DropZone,
|
3749
|
+
isEditing: true,
|
3750
|
+
dragRef: null
|
3751
|
+
};
|
3752
|
+
const defaultedProps = __spreadProps(__spreadValues(__spreadValues({}, (_a = config.components[item.type]) == null ? void 0 : _a.defaultProps), item.props), {
|
3753
|
+
puck: puckProps,
|
3754
|
+
editMode: true
|
3755
|
+
// DEPRECATED
|
3756
|
+
});
|
3757
|
+
const isSelected = (selectedItem == null ? void 0 : selectedItem.props.id) === componentId || false;
|
3758
|
+
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: [
|
3759
|
+
"No configuration for ",
|
3760
|
+
item.type
|
3761
|
+
] });
|
3762
|
+
const componentConfig = config.components[item.type];
|
3763
|
+
let componentType = item.type;
|
3764
|
+
let label = (_b = componentConfig == null ? void 0 : componentConfig["label"]) != null ? _b : item.type.toString();
|
3765
|
+
if (item.type === "preview" && preview) {
|
3766
|
+
let Preview4 = function() {
|
3767
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(DrawerItemInner, { name: label, children: appContext2.overrides.componentItem });
|
3628
3768
|
};
|
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
|
-
})
|
3769
|
+
var Preview3 = Preview4;
|
3770
|
+
componentType = preview.componentType;
|
3771
|
+
label = (_d = (_c = config.components[componentType]) == null ? void 0 : _c.label) != null ? _d : preview.componentType;
|
3772
|
+
Render2 = Preview4;
|
3773
|
+
}
|
3774
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
3775
|
+
DropZoneProvider,
|
3776
|
+
{
|
3777
|
+
value: __spreadProps(__spreadValues({}, ctx), { path: [...path, zoneCompound] }),
|
3778
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
3779
|
+
DraggableComponent,
|
3780
|
+
{
|
3781
|
+
id: componentId,
|
3782
|
+
componentType,
|
3783
|
+
zoneCompound,
|
3784
|
+
depth: depth + 1,
|
3785
|
+
index: i,
|
3786
|
+
isLoading: ((_e = appContext2.componentState[componentId]) == null ? void 0 : _e.loadingCount) > 0,
|
3787
|
+
isSelected,
|
3788
|
+
label,
|
3789
|
+
isEnabled,
|
3790
|
+
autoDragAxis: dragAxis,
|
3791
|
+
userDragAxis: collisionAxis,
|
3792
|
+
inDroppableZone: acceptsTarget(draggedComponentType),
|
3793
|
+
children: (dragRef) => (componentConfig == null ? void 0 : componentConfig.inline) ? /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
3794
|
+
Render2,
|
3795
|
+
__spreadProps(__spreadValues({}, defaultedProps), {
|
3796
|
+
puck: __spreadProps(__spreadValues({}, defaultedProps.puck), {
|
3797
|
+
dragRef
|
3676
3798
|
})
|
3677
|
-
|
3678
|
-
}
|
3679
|
-
|
3680
|
-
|
3681
|
-
|
3682
|
-
|
3683
|
-
|
3684
|
-
|
3799
|
+
})
|
3800
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { ref: dragRef, children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Render2, __spreadValues({}, defaultedProps)) })
|
3801
|
+
}
|
3802
|
+
)
|
3803
|
+
},
|
3804
|
+
componentId
|
3805
|
+
);
|
3806
|
+
})
|
3685
3807
|
}
|
3686
3808
|
);
|
3687
3809
|
}
|
3688
3810
|
);
|
3689
|
-
var DropZoneRender = (0,
|
3811
|
+
var DropZoneRender = (0, import_react28.forwardRef)(
|
3690
3812
|
function DropZoneRender2({ className, style, zone }, ref) {
|
3691
|
-
const ctx = (0,
|
3813
|
+
const ctx = (0, import_react28.useContext)(dropZoneContext);
|
3692
3814
|
const { data, areaId = "root", config } = ctx || {};
|
3693
3815
|
let zoneCompound = rootDroppableId;
|
3694
3816
|
let content = (data == null ? void 0 : data.content) || [];
|
3695
|
-
(0,
|
3817
|
+
(0, import_react28.useEffect)(() => {
|
3696
3818
|
if (ctx == null ? void 0 : ctx.registerZone) {
|
3697
3819
|
ctx == null ? void 0 : ctx.registerZone(zoneCompound);
|
3698
3820
|
}
|
@@ -3736,9 +3858,9 @@ var DropZoneRender = (0, import_react23.forwardRef)(
|
|
3736
3858
|
}) });
|
3737
3859
|
}
|
3738
3860
|
);
|
3739
|
-
var DropZone = (0,
|
3861
|
+
var DropZone = (0, import_react28.forwardRef)(
|
3740
3862
|
function DropZone2(props, ref) {
|
3741
|
-
const ctx = (0,
|
3863
|
+
const ctx = (0, import_react28.useContext)(dropZoneContext);
|
3742
3864
|
if ((ctx == null ? void 0 : ctx.mode) === "edit") {
|
3743
3865
|
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_jsx_runtime21.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(DropZoneEdit, __spreadProps(__spreadValues({}, props), { ref })) });
|
3744
3866
|
}
|
@@ -3758,7 +3880,7 @@ var getZoneId = (zoneCompound) => {
|
|
3758
3880
|
return [rootDroppableId, zoneCompound];
|
3759
3881
|
};
|
3760
3882
|
|
3761
|
-
//
|
3883
|
+
// lib/dnd/NestedDroppablePlugin.ts
|
3762
3884
|
init_react_import();
|
3763
3885
|
var import_abstract9 = require("@dnd-kit/abstract");
|
3764
3886
|
var import_state = require("@dnd-kit/state");
|
@@ -3800,7 +3922,7 @@ var getFrame = () => {
|
|
3800
3922
|
return (frameEl == null ? void 0 : frameEl.ownerDocument) || document;
|
3801
3923
|
};
|
3802
3924
|
|
3803
|
-
//
|
3925
|
+
// lib/dnd/NestedDroppablePlugin.ts
|
3804
3926
|
var depthSort = (candidates) => {
|
3805
3927
|
return candidates.sort((a, b) => {
|
3806
3928
|
const aData = a.data;
|
@@ -3915,9 +4037,7 @@ var findDeepestCandidate = (position, manager, ownerDocument) => {
|
|
3915
4037
|
area: null
|
3916
4038
|
};
|
3917
4039
|
};
|
3918
|
-
var createNestedDroppablePlugin = ({
|
3919
|
-
onChange
|
3920
|
-
}) => class NestedDroppablePlugin extends import_abstract9.Plugin {
|
4040
|
+
var createNestedDroppablePlugin = ({ onChange }, id) => class NestedDroppablePlugin extends import_abstract9.Plugin {
|
3921
4041
|
constructor(manager, options) {
|
3922
4042
|
super(manager);
|
3923
4043
|
if (typeof window === "undefined") {
|
@@ -3931,10 +4051,17 @@ var createNestedDroppablePlugin = ({
|
|
3931
4051
|
};
|
3932
4052
|
const target = event.originalTarget || event.target;
|
3933
4053
|
const ownerDocument = target == null ? void 0 : target.ownerDocument;
|
3934
|
-
|
3935
|
-
|
3936
|
-
|
4054
|
+
const elements = document.elementsFromPoint(
|
4055
|
+
event.clientX,
|
4056
|
+
event.clientY
|
3937
4057
|
);
|
4058
|
+
const overEl = elements.some((el) => el.id === id);
|
4059
|
+
if (overEl) {
|
4060
|
+
onChange(
|
4061
|
+
findDeepestCandidate(position, manager, ownerDocument),
|
4062
|
+
manager
|
4063
|
+
);
|
4064
|
+
}
|
3938
4065
|
};
|
3939
4066
|
const handleMoveThrottled = throttle(handleMove, 50);
|
3940
4067
|
const handlePointerMove = (event) => {
|
@@ -4351,7 +4478,7 @@ var insertComponent = (componentType, zone, index, {
|
|
4351
4478
|
var import_use_debounce2 = require("use-debounce");
|
4352
4479
|
var import_utilities2 = require("@dnd-kit/dom/utilities");
|
4353
4480
|
|
4354
|
-
//
|
4481
|
+
// lib/dnd/PointerSensor.ts
|
4355
4482
|
init_react_import();
|
4356
4483
|
var import_state3 = require("@dnd-kit/state");
|
4357
4484
|
var import_abstract10 = require("@dnd-kit/abstract");
|
@@ -4613,13 +4740,15 @@ function patchWindow(window2) {
|
|
4613
4740
|
}
|
4614
4741
|
|
4615
4742
|
// components/DragDropContext/index.tsx
|
4743
|
+
var import_zustand3 = require("zustand");
|
4616
4744
|
var import_jsx_runtime22 = require("react/jsx-runtime");
|
4617
|
-
var
|
4745
|
+
var DEBUG3 = false;
|
4746
|
+
var dragListenerContext = (0, import_react30.createContext)({
|
4618
4747
|
dragListeners: {}
|
4619
4748
|
});
|
4620
4749
|
function useDragListener(type, fn, deps = []) {
|
4621
|
-
const { setDragListeners } = (0,
|
4622
|
-
(0,
|
4750
|
+
const { setDragListeners } = (0, import_react30.useContext)(dragListenerContext);
|
4751
|
+
(0, import_react30.useEffect)(() => {
|
4623
4752
|
if (setDragListeners) {
|
4624
4753
|
setDragListeners((old) => __spreadProps(__spreadValues({}, old), {
|
4625
4754
|
[type]: [...old[type] || [], fn]
|
@@ -4627,80 +4756,147 @@ function useDragListener(type, fn, deps = []) {
|
|
4627
4756
|
}
|
4628
4757
|
}, deps);
|
4629
4758
|
}
|
4630
|
-
var previewContext = (0, import_react25.createContext)(null);
|
4631
4759
|
var AREA_CHANGE_DEBOUNCE_MS = 100;
|
4760
|
+
var useTempDisableFallback = (timeout3) => {
|
4761
|
+
const lastFallbackDisable = (0, import_react30.useRef)(null);
|
4762
|
+
return (0, import_react30.useCallback)((manager) => {
|
4763
|
+
collisionStore.setState({ fallbackEnabled: false });
|
4764
|
+
const fallbackId = generateId();
|
4765
|
+
lastFallbackDisable.current = fallbackId;
|
4766
|
+
setTimeout(() => {
|
4767
|
+
if (lastFallbackDisable.current === fallbackId) {
|
4768
|
+
collisionStore.setState({ fallbackEnabled: true });
|
4769
|
+
manager.collisionObserver.forceUpdate(true);
|
4770
|
+
}
|
4771
|
+
}, timeout3);
|
4772
|
+
}, []);
|
4773
|
+
};
|
4632
4774
|
var DragDropContextClient = ({
|
4633
4775
|
children,
|
4634
4776
|
disableAutoScroll
|
4635
4777
|
}) => {
|
4636
4778
|
const { state, config, dispatch, resolveData } = useAppContext();
|
4637
|
-
const
|
4638
|
-
const previewRef = (0, import_react25.useRef)(null);
|
4779
|
+
const id = (0, import_react30.useId)();
|
4639
4780
|
const { data } = state;
|
4640
|
-
const
|
4641
|
-
const
|
4642
|
-
const
|
4643
|
-
|
4644
|
-
|
4781
|
+
const debouncedParamsRef = (0, import_react30.useRef)(null);
|
4782
|
+
const tempDisableFallback = useTempDisableFallback(100);
|
4783
|
+
const [zoneStore] = (0, import_react30.useState)(
|
4784
|
+
() => (0, import_zustand3.createStore)(() => ({
|
4785
|
+
zoneDepthIndex: {},
|
4786
|
+
nextZoneDepthIndex: {},
|
4787
|
+
areaDepthIndex: {},
|
4788
|
+
nextAreaDepthIndex: {},
|
4789
|
+
draggedItem: null,
|
4790
|
+
previewIndex: {}
|
4791
|
+
}))
|
4792
|
+
);
|
4793
|
+
const getChanged2 = (0, import_react30.useCallback)(
|
4794
|
+
(params, id2) => {
|
4795
|
+
const { zoneDepthIndex = {}, areaDepthIndex = {} } = zoneStore.getState() || {};
|
4796
|
+
const stateHasZone = Object.keys(zoneDepthIndex).length > 0;
|
4797
|
+
const stateHasArea = Object.keys(areaDepthIndex).length > 0;
|
4798
|
+
let zoneChanged = false;
|
4799
|
+
let areaChanged = false;
|
4800
|
+
if (params.zone && !zoneDepthIndex[params.zone]) {
|
4801
|
+
zoneChanged = true;
|
4802
|
+
} else if (!params.zone && stateHasZone) {
|
4803
|
+
zoneChanged = true;
|
4804
|
+
}
|
4805
|
+
if (params.area && !areaDepthIndex[params.area]) {
|
4806
|
+
areaChanged = true;
|
4807
|
+
} else if (!params.area && stateHasArea) {
|
4808
|
+
areaChanged = true;
|
4809
|
+
}
|
4810
|
+
return { zoneChanged, areaChanged };
|
4811
|
+
},
|
4812
|
+
[zoneStore]
|
4813
|
+
);
|
4814
|
+
const setDeepestAndCollide = (0, import_react30.useCallback)(
|
4645
4815
|
(params, manager) => {
|
4646
|
-
|
4816
|
+
const { zoneChanged, areaChanged } = getChanged2(params, id);
|
4817
|
+
if (!zoneChanged && !areaChanged) return;
|
4818
|
+
zoneStore.setState({
|
4819
|
+
zoneDepthIndex: params.zone ? { [params.zone]: true } : {},
|
4820
|
+
areaDepthIndex: params.area ? { [params.area]: true } : {}
|
4821
|
+
});
|
4822
|
+
tempDisableFallback(manager);
|
4647
4823
|
setTimeout(() => {
|
4648
4824
|
manager.collisionObserver.forceUpdate(true);
|
4649
4825
|
}, 50);
|
4650
4826
|
debouncedParamsRef.current = null;
|
4651
4827
|
},
|
4652
|
-
[]
|
4828
|
+
[zoneStore]
|
4653
4829
|
);
|
4654
4830
|
const setDeepestDb = (0, import_use_debounce2.useDebouncedCallback)(
|
4655
4831
|
setDeepestAndCollide,
|
4656
4832
|
AREA_CHANGE_DEBOUNCE_MS
|
4657
4833
|
);
|
4658
|
-
(0, import_react25.useEffect)(() => {
|
4659
|
-
deepestRef.current = deepest;
|
4660
|
-
}, [deepest]);
|
4661
4834
|
const cancelDb = () => {
|
4662
4835
|
setDeepestDb.cancel();
|
4663
4836
|
debouncedParamsRef.current = null;
|
4664
4837
|
};
|
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;
|
4838
|
+
(0, import_react30.useEffect)(() => {
|
4839
|
+
if (DEBUG3) {
|
4840
|
+
zoneStore.subscribe(
|
4841
|
+
(s) => {
|
4842
|
+
var _a, _b;
|
4843
|
+
return console.log(
|
4844
|
+
s.previewIndex,
|
4845
|
+
(_a = Object.entries(s.zoneDepthIndex || {})[0]) == null ? void 0 : _a[0],
|
4846
|
+
(_b = Object.entries(s.areaDepthIndex || {})[0]) == null ? void 0 : _b[0]
|
4847
|
+
);
|
4680
4848
|
}
|
4681
|
-
|
4682
|
-
|
4683
|
-
|
4684
|
-
|
4685
|
-
|
4849
|
+
);
|
4850
|
+
}
|
4851
|
+
}, []);
|
4852
|
+
const [plugins] = (0, import_react30.useState)(() => [
|
4853
|
+
...disableAutoScroll ? import_dom.defaultPreset.plugins.filter((plugin) => plugin !== import_dom.AutoScroller) : import_dom.defaultPreset.plugins,
|
4854
|
+
createNestedDroppablePlugin(
|
4855
|
+
{
|
4856
|
+
onChange: (params, manager) => {
|
4857
|
+
const state2 = zoneStore.getState();
|
4858
|
+
const { zoneChanged, areaChanged } = getChanged2(params, id);
|
4859
|
+
const isDragging = manager.dragOperation.status.dragging;
|
4860
|
+
if (areaChanged || zoneChanged) {
|
4861
|
+
let nextZoneDepthIndex = {};
|
4862
|
+
let nextAreaDepthIndex = {};
|
4863
|
+
if (params.zone) {
|
4864
|
+
nextZoneDepthIndex = { [params.zone]: true };
|
4865
|
+
}
|
4866
|
+
if (params.area) {
|
4867
|
+
nextAreaDepthIndex = { [params.area]: true };
|
4868
|
+
}
|
4869
|
+
zoneStore.setState({ nextZoneDepthIndex, nextAreaDepthIndex });
|
4870
|
+
}
|
4871
|
+
if (params.zone !== "void" && (state2 == null ? void 0 : state2.zoneDepthIndex["void"])) {
|
4872
|
+
setDeepestAndCollide(params, manager);
|
4873
|
+
return;
|
4874
|
+
}
|
4875
|
+
if (areaChanged) {
|
4876
|
+
if (isDragging) {
|
4877
|
+
const debouncedParams = debouncedParamsRef.current;
|
4878
|
+
const isSameParams = debouncedParams && debouncedParams.area === params.area && debouncedParams.zone === params.zone;
|
4879
|
+
if (!isSameParams) {
|
4880
|
+
cancelDb();
|
4881
|
+
setDeepestDb(params, manager);
|
4882
|
+
debouncedParamsRef.current = params;
|
4883
|
+
}
|
4884
|
+
} else {
|
4686
4885
|
cancelDb();
|
4687
|
-
|
4688
|
-
debouncedParamsRef.current = params;
|
4886
|
+
setDeepestAndCollide(params, manager);
|
4689
4887
|
}
|
4690
|
-
|
4691
|
-
|
4888
|
+
return;
|
4889
|
+
}
|
4890
|
+
if (zoneChanged) {
|
4692
4891
|
setDeepestAndCollide(params, manager);
|
4693
4892
|
}
|
4694
|
-
|
4695
|
-
}
|
4696
|
-
if (zoneChanged) {
|
4697
|
-
setDeepestAndCollide(params, manager);
|
4893
|
+
cancelDb();
|
4698
4894
|
}
|
4699
|
-
|
4700
|
-
|
4701
|
-
|
4895
|
+
},
|
4896
|
+
id
|
4897
|
+
)
|
4702
4898
|
]);
|
4703
|
-
const [sensors] = (0,
|
4899
|
+
const [sensors] = (0, import_react30.useState)(() => [
|
4704
4900
|
PointerSensor.configure({
|
4705
4901
|
activationConstraints(event, source) {
|
4706
4902
|
var _a;
|
@@ -4719,11 +4915,10 @@ var DragDropContextClient = ({
|
|
4719
4915
|
}
|
4720
4916
|
})
|
4721
4917
|
]);
|
4722
|
-
const [
|
4723
|
-
const [
|
4724
|
-
const
|
4725
|
-
const
|
4726
|
-
const registerPath = (0, import_react25.useCallback)(
|
4918
|
+
const [dragListeners, setDragListeners] = (0, import_react30.useState)({});
|
4919
|
+
const [pathData, setPathData] = (0, import_react30.useState)();
|
4920
|
+
const dragMode = (0, import_react30.useRef)(null);
|
4921
|
+
const registerPath = (0, import_react30.useCallback)(
|
4727
4922
|
(selector) => {
|
4728
4923
|
const item = getItem(selector, data);
|
4729
4924
|
if (!item) {
|
@@ -4745,41 +4940,41 @@ var DragDropContextClient = ({
|
|
4745
4940
|
},
|
4746
4941
|
[data, setPathData]
|
4747
4942
|
);
|
4748
|
-
const initialSelector = (0,
|
4749
|
-
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
4943
|
+
const initialSelector = (0, import_react30.useRef)(void 0);
|
4944
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { id, children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
4750
4945
|
dragListenerContext.Provider,
|
4751
4946
|
{
|
4752
4947
|
value: {
|
4753
4948
|
dragListeners,
|
4754
4949
|
setDragListeners
|
4755
4950
|
},
|
4756
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
4757
|
-
|
4951
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
4952
|
+
import_react29.DragDropProvider,
|
4758
4953
|
{
|
4759
4954
|
plugins,
|
4760
4955
|
sensors,
|
4761
4956
|
onDragEnd: (event, manager) => {
|
4957
|
+
var _a;
|
4762
4958
|
const { source, target } = event.operation;
|
4763
|
-
deepestRef.current = null;
|
4764
4959
|
if (!source) {
|
4765
|
-
|
4960
|
+
zoneStore.setState({ draggedItem: null });
|
4766
4961
|
return;
|
4767
4962
|
}
|
4768
4963
|
const { zone, index } = source.data;
|
4769
|
-
const
|
4770
|
-
|
4964
|
+
const { previewIndex = {} } = zoneStore.getState() || {};
|
4965
|
+
const thisPreview = ((_a = previewIndex[zone]) == null ? void 0 : _a.props.id) === source.id ? previewIndex[zone] : null;
|
4771
4966
|
setTimeout(() => {
|
4772
|
-
var
|
4773
|
-
|
4967
|
+
var _a2, _b;
|
4968
|
+
zoneStore.setState({ draggedItem: null });
|
4774
4969
|
if (event.canceled || (target == null ? void 0 : target.type) === "void") {
|
4775
|
-
|
4776
|
-
(
|
4970
|
+
zoneStore.setState({ previewIndex: {} });
|
4971
|
+
(_a2 = dragListeners.dragend) == null ? void 0 : _a2.forEach((fn) => {
|
4777
4972
|
fn(event, manager);
|
4778
4973
|
});
|
4779
4974
|
return;
|
4780
4975
|
}
|
4781
4976
|
if (thisPreview) {
|
4782
|
-
|
4977
|
+
zoneStore.setState({ previewIndex: {} });
|
4783
4978
|
if (thisPreview.type === "insert") {
|
4784
4979
|
insertComponent(
|
4785
4980
|
thisPreview.componentType,
|
@@ -4814,8 +5009,9 @@ var DragDropContextClient = ({
|
|
4814
5009
|
}, 250);
|
4815
5010
|
},
|
4816
5011
|
onDragOver: (event, manager) => {
|
4817
|
-
var _a, _b, _c, _d;
|
5012
|
+
var _a, _b, _c, _d, _e;
|
4818
5013
|
event.preventDefault();
|
5014
|
+
const draggedItem = (_a = zoneStore.getState()) == null ? void 0 : _a.draggedItem;
|
4819
5015
|
if (!draggedItem) return;
|
4820
5016
|
cancelDb();
|
4821
5017
|
const { source, target } = event.operation;
|
@@ -4831,7 +5027,7 @@ var DragDropContextClient = ({
|
|
4831
5027
|
const targetData = target.data;
|
4832
5028
|
targetZone = targetData.zone;
|
4833
5029
|
targetIndex = targetData.index;
|
4834
|
-
const collisionData = (
|
5030
|
+
const collisionData = (_c = (_b = manager.dragOperation.data) == null ? void 0 : _b.collisionMap) == null ? void 0 : _c[targetId];
|
4835
5031
|
const collisionPosition = (collisionData == null ? void 0 : collisionData.direction) === "up" || (collisionData == null ? void 0 : collisionData.direction) === "left" ? "before" : "after";
|
4836
5032
|
if (targetIndex >= sourceIndex && sourceZone === targetZone) {
|
4837
5033
|
targetIndex = targetIndex - 1;
|
@@ -4843,23 +5039,26 @@ var DragDropContextClient = ({
|
|
4843
5039
|
targetZone = target.id.toString();
|
4844
5040
|
targetIndex = 0;
|
4845
5041
|
}
|
4846
|
-
if (targetId === sourceId || ((
|
5042
|
+
if (targetId === sourceId || ((_d = pathData == null ? void 0 : pathData[target.id]) == null ? void 0 : _d.path.find((path) => {
|
4847
5043
|
const [pathId] = path.split(":");
|
4848
5044
|
return pathId === sourceId;
|
4849
5045
|
}))) {
|
4850
5046
|
return;
|
4851
5047
|
}
|
4852
5048
|
if (dragMode.current === "new") {
|
4853
|
-
|
4854
|
-
|
4855
|
-
|
4856
|
-
|
4857
|
-
|
4858
|
-
|
4859
|
-
|
5049
|
+
zoneStore.setState({
|
5050
|
+
previewIndex: {
|
5051
|
+
[targetZone]: {
|
5052
|
+
componentType: sourceData.componentType,
|
5053
|
+
type: "insert",
|
5054
|
+
index: targetIndex,
|
5055
|
+
zone: targetZone,
|
5056
|
+
props: {
|
5057
|
+
id: source.id.toString()
|
5058
|
+
}
|
5059
|
+
}
|
4860
5060
|
}
|
4861
|
-
};
|
4862
|
-
setPreview(previewRef.current);
|
5061
|
+
});
|
4863
5062
|
} else {
|
4864
5063
|
if (!initialSelector.current) {
|
4865
5064
|
initialSelector.current = {
|
@@ -4869,17 +5068,20 @@ var DragDropContextClient = ({
|
|
4869
5068
|
}
|
4870
5069
|
const item = getItem(initialSelector.current, data);
|
4871
5070
|
if (item) {
|
4872
|
-
|
4873
|
-
|
4874
|
-
|
4875
|
-
|
4876
|
-
|
4877
|
-
|
4878
|
-
|
4879
|
-
|
5071
|
+
zoneStore.setState({
|
5072
|
+
previewIndex: {
|
5073
|
+
[targetZone]: {
|
5074
|
+
componentType: sourceData.componentType,
|
5075
|
+
type: "move",
|
5076
|
+
index: targetIndex,
|
5077
|
+
zone: targetZone,
|
5078
|
+
props: item.props
|
5079
|
+
}
|
5080
|
+
}
|
5081
|
+
});
|
4880
5082
|
}
|
4881
5083
|
}
|
4882
|
-
(
|
5084
|
+
(_e = dragListeners.dragover) == null ? void 0 : _e.forEach((fn) => {
|
4883
5085
|
fn(event, manager);
|
4884
5086
|
});
|
4885
5087
|
},
|
@@ -4889,45 +5091,61 @@ var DragDropContextClient = ({
|
|
4889
5091
|
type: "setUi",
|
4890
5092
|
ui: { itemSelector: null, isDragging: true }
|
4891
5093
|
});
|
5094
|
+
const { source } = event.operation;
|
5095
|
+
if (source && source.type !== "void") {
|
5096
|
+
const sourceData = source.data;
|
5097
|
+
const item = getItem(
|
5098
|
+
{
|
5099
|
+
zone: sourceData.zone,
|
5100
|
+
index: sourceData.index
|
5101
|
+
},
|
5102
|
+
data
|
5103
|
+
);
|
5104
|
+
if (item) {
|
5105
|
+
zoneStore.setState({
|
5106
|
+
previewIndex: {
|
5107
|
+
[sourceData.zone]: {
|
5108
|
+
componentType: sourceData.componentType,
|
5109
|
+
type: "move",
|
5110
|
+
index: sourceData.index,
|
5111
|
+
zone: sourceData.zone,
|
5112
|
+
props: item.props
|
5113
|
+
}
|
5114
|
+
}
|
5115
|
+
});
|
5116
|
+
}
|
5117
|
+
}
|
4892
5118
|
(_a = dragListeners.dragstart) == null ? void 0 : _a.forEach((fn) => {
|
4893
5119
|
fn(event, manager);
|
4894
5120
|
});
|
4895
5121
|
},
|
4896
5122
|
onBeforeDragStart: (event) => {
|
4897
5123
|
var _a;
|
4898
|
-
if (draggedItem) {
|
4899
|
-
console.warn("New drag started before previous drag cleaned up");
|
4900
|
-
}
|
4901
5124
|
const isNewComponent = ((_a = event.operation.source) == null ? void 0 : _a.data.type) === "drawer";
|
4902
5125
|
dragMode.current = isNewComponent ? "new" : "existing";
|
4903
5126
|
initialSelector.current = void 0;
|
4904
|
-
|
5127
|
+
zoneStore.setState({ draggedItem: event.operation.source });
|
4905
5128
|
},
|
4906
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
5129
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(ZoneStoreProvider, { store: zoneStore, children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
4907
5130
|
DropZoneProvider,
|
4908
5131
|
{
|
4909
5132
|
value: {
|
4910
5133
|
data,
|
4911
5134
|
config,
|
4912
|
-
draggedItem,
|
4913
5135
|
mode: "edit",
|
4914
5136
|
areaId: "root",
|
4915
5137
|
depth: 0,
|
4916
5138
|
registerPath,
|
4917
5139
|
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
5140
|
path: []
|
4923
5141
|
},
|
4924
5142
|
children
|
4925
5143
|
}
|
4926
|
-
)
|
5144
|
+
) })
|
4927
5145
|
}
|
4928
|
-
)
|
5146
|
+
)
|
4929
5147
|
}
|
4930
|
-
);
|
5148
|
+
) });
|
4931
5149
|
};
|
4932
5150
|
var DragDropContext = ({
|
4933
5151
|
children,
|
@@ -4951,7 +5169,7 @@ var DrawerItemInner = ({
|
|
4951
5169
|
dragRef,
|
4952
5170
|
isDragDisabled
|
4953
5171
|
}) => {
|
4954
|
-
const CustomInner = (0,
|
5172
|
+
const CustomInner = (0, import_react31.useMemo)(
|
4955
5173
|
() => children || (({ children: children2 }) => /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: getClassNameItem2("default"), children: children2 })),
|
4956
5174
|
[children]
|
4957
5175
|
);
|
@@ -5005,7 +5223,7 @@ var DrawerItem = ({
|
|
5005
5223
|
isDragDisabled
|
5006
5224
|
}) => {
|
5007
5225
|
const resolvedId = id || name;
|
5008
|
-
const [dynamicId, setDynamicId] = (0,
|
5226
|
+
const [dynamicId, setDynamicId] = (0, import_react31.useState)(generateId(resolvedId));
|
5009
5227
|
if (typeof index !== "undefined") {
|
5010
5228
|
console.error(
|
5011
5229
|
"Warning: The `index` prop on Drawer.Item is deprecated and no longer required."
|
@@ -5044,7 +5262,7 @@ var Drawer = ({
|
|
5044
5262
|
"Warning: The `direction` prop on Drawer is deprecated and no longer required to achieve multi-directional dragging."
|
5045
5263
|
);
|
5046
5264
|
}
|
5047
|
-
const [id] = (0,
|
5265
|
+
const [id] = (0, import_react31.useState)(generateId());
|
5048
5266
|
const { ref } = useDroppableSafe({
|
5049
5267
|
id,
|
5050
5268
|
type: "void",
|
@@ -5066,7 +5284,7 @@ Drawer.Item = DrawerItem;
|
|
5066
5284
|
|
5067
5285
|
// components/Puck/index.tsx
|
5068
5286
|
init_react_import();
|
5069
|
-
var
|
5287
|
+
var import_react47 = require("react");
|
5070
5288
|
|
5071
5289
|
// components/SidebarSection/index.tsx
|
5072
5290
|
init_react_import();
|
@@ -5077,7 +5295,7 @@ var styles_module_default13 = { "SidebarSection": "_SidebarSection_125qe_1", "Si
|
|
5077
5295
|
|
5078
5296
|
// lib/use-breadcrumbs.ts
|
5079
5297
|
init_react_import();
|
5080
|
-
var
|
5298
|
+
var import_react32 = require("react");
|
5081
5299
|
var convertPathDataToBreadcrumbs = (selectedItem, pathData, data) => {
|
5082
5300
|
const id = selectedItem ? selectedItem == null ? void 0 : selectedItem.props.id : "";
|
5083
5301
|
const currentPathData = pathData && id && pathData[id] ? __spreadValues({}, pathData[id]) : { label: "Page", path: [] };
|
@@ -5127,8 +5345,8 @@ var useBreadcrumbs = (renderCount) => {
|
|
5127
5345
|
state: { data },
|
5128
5346
|
selectedItem
|
5129
5347
|
} = useAppContext();
|
5130
|
-
const dzContext = (0,
|
5131
|
-
return (0,
|
5348
|
+
const dzContext = (0, import_react32.useContext)(dropZoneContext);
|
5349
|
+
return (0, import_react32.useMemo)(() => {
|
5132
5350
|
const breadcrumbs = convertPathDataToBreadcrumbs(
|
5133
5351
|
selectedItem,
|
5134
5352
|
dzContext == null ? void 0 : dzContext.pathData,
|
@@ -5252,7 +5470,7 @@ function MenuBar({
|
|
5252
5470
|
|
5253
5471
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/styles.module.css#css-module
|
5254
5472
|
init_react_import();
|
5255
|
-
var styles_module_default15 = { "Puck": "
|
5473
|
+
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
5474
|
|
5257
5475
|
// components/Puck/components/Fields/index.tsx
|
5258
5476
|
init_react_import();
|
@@ -5262,15 +5480,15 @@ init_react_import();
|
|
5262
5480
|
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
5481
|
|
5264
5482
|
// components/Puck/components/Fields/index.tsx
|
5265
|
-
var
|
5483
|
+
var import_react34 = require("react");
|
5266
5484
|
|
5267
5485
|
// lib/use-parent.ts
|
5268
5486
|
init_react_import();
|
5269
|
-
var
|
5487
|
+
var import_react33 = require("react");
|
5270
5488
|
var useParent = (itemSelector) => {
|
5271
5489
|
var _a;
|
5272
5490
|
const { selectedItem, state } = useAppContext();
|
5273
|
-
const { pathData } = (0,
|
5491
|
+
const { pathData } = (0, import_react33.useContext)(dropZoneContext) || {};
|
5274
5492
|
const item = itemSelector ? getItem(itemSelector, state.data) : selectedItem;
|
5275
5493
|
const breadcrumbs = convertPathDataToBreadcrumbs(item, pathData, state.data);
|
5276
5494
|
const lastItem = breadcrumbs[breadcrumbs.length - 1];
|
@@ -5296,20 +5514,20 @@ var useResolvedFields = () => {
|
|
5296
5514
|
const { data } = state;
|
5297
5515
|
const rootFields = ((_a = config.root) == null ? void 0 : _a.fields) || defaultPageFields;
|
5298
5516
|
const componentConfig = selectedItem ? config.components[selectedItem.type] : null;
|
5299
|
-
const defaultFields = (0,
|
5517
|
+
const defaultFields = (0, import_react34.useMemo)(
|
5300
5518
|
() => (selectedItem ? componentConfig == null ? void 0 : componentConfig.fields : rootFields) || {},
|
5301
5519
|
[selectedItem, rootFields, componentConfig == null ? void 0 : componentConfig.fields]
|
5302
5520
|
);
|
5303
5521
|
const rootProps = data.root.props || data.root;
|
5304
|
-
const [lastSelectedData, setLastSelectedData] = (0,
|
5305
|
-
const [resolvedFields, setResolvedFields] = (0,
|
5306
|
-
const [fieldsLoading, setFieldsLoading] = (0,
|
5522
|
+
const [lastSelectedData, setLastSelectedData] = (0, import_react34.useState)({});
|
5523
|
+
const [resolvedFields, setResolvedFields] = (0, import_react34.useState)(defaultFields);
|
5524
|
+
const [fieldsLoading, setFieldsLoading] = (0, import_react34.useState)(false);
|
5307
5525
|
const defaultResolveFields = (_componentData, _params) => defaultFields;
|
5308
5526
|
const componentData = selectedItem ? selectedItem : { props: rootProps, readOnly: data.root.readOnly };
|
5309
5527
|
const hasComponentResolver = selectedItem && (componentConfig == null ? void 0 : componentConfig.resolveFields);
|
5310
5528
|
const hasRootResolver = !selectedItem && ((_b = config.root) == null ? void 0 : _b.resolveFields);
|
5311
5529
|
const hasResolver = hasComponentResolver || hasRootResolver;
|
5312
|
-
const resolveFields = (0,
|
5530
|
+
const resolveFields = (0, import_react34.useCallback)(
|
5313
5531
|
(..._0) => __async(void 0, [..._0], function* (fields = {}) {
|
5314
5532
|
var _a2;
|
5315
5533
|
const lastData = ((_a2 = lastSelectedData.props) == null ? void 0 : _a2.id) === componentData.props.id ? lastSelectedData : null;
|
@@ -5347,7 +5565,7 @@ var useResolvedFields = () => {
|
|
5347
5565
|
}),
|
5348
5566
|
[data, config, componentData, selectedItem, resolvedFields, state]
|
5349
5567
|
);
|
5350
|
-
(0,
|
5568
|
+
(0, import_react34.useEffect)(() => {
|
5351
5569
|
if (hasResolver) {
|
5352
5570
|
setFieldsLoading(true);
|
5353
5571
|
resolveFields(defaultFields).then((fields) => {
|
@@ -5378,7 +5596,7 @@ var Fields = () => {
|
|
5378
5596
|
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
5597
|
const isLoading = fieldsResolving || componentResolving;
|
5380
5598
|
const rootProps = data.root.props || data.root;
|
5381
|
-
const Wrapper = (0,
|
5599
|
+
const Wrapper = (0, import_react34.useMemo)(() => overrides.fields || DefaultFields, [overrides]);
|
5382
5600
|
return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(
|
5383
5601
|
"form",
|
5384
5602
|
{
|
@@ -5501,7 +5719,7 @@ init_react_import();
|
|
5501
5719
|
|
5502
5720
|
// lib/use-component-list.tsx
|
5503
5721
|
init_react_import();
|
5504
|
-
var
|
5722
|
+
var import_react35 = require("react");
|
5505
5723
|
|
5506
5724
|
// components/ComponentList/index.tsx
|
5507
5725
|
init_react_import();
|
@@ -5568,8 +5786,8 @@ ComponentList.Item = ComponentListItem;
|
|
5568
5786
|
// lib/use-component-list.tsx
|
5569
5787
|
var import_jsx_runtime28 = require("react/jsx-runtime");
|
5570
5788
|
var useComponentList = (config, ui) => {
|
5571
|
-
const [componentList, setComponentList] = (0,
|
5572
|
-
(0,
|
5789
|
+
const [componentList, setComponentList] = (0, import_react35.useState)();
|
5790
|
+
(0, import_react35.useEffect)(() => {
|
5573
5791
|
var _a, _b, _c;
|
5574
5792
|
if (Object.keys(ui.componentList).length > 0) {
|
5575
5793
|
const matchedComponents = [];
|
@@ -5638,22 +5856,22 @@ var useComponentList = (config, ui) => {
|
|
5638
5856
|
};
|
5639
5857
|
|
5640
5858
|
// components/Puck/components/Components/index.tsx
|
5641
|
-
var
|
5859
|
+
var import_react36 = require("react");
|
5642
5860
|
var import_jsx_runtime29 = require("react/jsx-runtime");
|
5643
5861
|
var Components = () => {
|
5644
5862
|
const { config, state, overrides } = useAppContext();
|
5645
5863
|
const componentList = useComponentList(config, state.ui);
|
5646
|
-
const Wrapper = (0,
|
5864
|
+
const Wrapper = (0, import_react36.useMemo)(() => overrides.components || "div", [overrides]);
|
5647
5865
|
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(Wrapper, { children: componentList ? componentList : /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(ComponentList, { id: "all" }) });
|
5648
5866
|
};
|
5649
5867
|
|
5650
5868
|
// components/Puck/components/Preview/index.tsx
|
5651
5869
|
init_react_import();
|
5652
|
-
var
|
5870
|
+
var import_react38 = require("react");
|
5653
5871
|
|
5654
5872
|
// components/AutoFrame/index.tsx
|
5655
5873
|
init_react_import();
|
5656
|
-
var
|
5874
|
+
var import_react37 = require("react");
|
5657
5875
|
var import_object_hash = __toESM(require("object-hash"));
|
5658
5876
|
var import_react_dom3 = require("react-dom");
|
5659
5877
|
var import_jsx_runtime30 = require("react/jsx-runtime");
|
@@ -5699,7 +5917,7 @@ var CopyHostStyles = ({
|
|
5699
5917
|
onStylesLoaded = () => null
|
5700
5918
|
}) => {
|
5701
5919
|
const { document: doc, window: win } = useFrame();
|
5702
|
-
(0,
|
5920
|
+
(0, import_react37.useEffect)(() => {
|
5703
5921
|
if (!win || !doc) {
|
5704
5922
|
return () => {
|
5705
5923
|
};
|
@@ -5858,8 +6076,8 @@ var CopyHostStyles = ({
|
|
5858
6076
|
}, []);
|
5859
6077
|
return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_jsx_runtime30.Fragment, { children });
|
5860
6078
|
};
|
5861
|
-
var autoFrameContext = (0,
|
5862
|
-
var useFrame = () => (0,
|
6079
|
+
var autoFrameContext = (0, import_react37.createContext)({});
|
6080
|
+
var useFrame = () => (0, import_react37.useContext)(autoFrameContext);
|
5863
6081
|
function AutoFrame(_a) {
|
5864
6082
|
var _b = _a, {
|
5865
6083
|
children,
|
@@ -5876,10 +6094,10 @@ function AutoFrame(_a) {
|
|
5876
6094
|
"onStylesLoaded",
|
5877
6095
|
"frameRef"
|
5878
6096
|
]);
|
5879
|
-
const [loaded, setLoaded] = (0,
|
5880
|
-
const [ctx, setCtx] = (0,
|
5881
|
-
const [mountTarget, setMountTarget] = (0,
|
5882
|
-
(0,
|
6097
|
+
const [loaded, setLoaded] = (0, import_react37.useState)(false);
|
6098
|
+
const [ctx, setCtx] = (0, import_react37.useState)({});
|
6099
|
+
const [mountTarget, setMountTarget] = (0, import_react37.useState)();
|
6100
|
+
(0, import_react37.useEffect)(() => {
|
5883
6101
|
var _a2;
|
5884
6102
|
if (frameRef.current) {
|
5885
6103
|
setCtx({
|
@@ -5973,7 +6191,7 @@ var import_jsx_runtime32 = require("react/jsx-runtime");
|
|
5973
6191
|
var getClassName23 = get_class_name_factory_default("PuckPreview", styles_module_default18);
|
5974
6192
|
var useBubbleIframeEvents = (ref) => {
|
5975
6193
|
const { status } = useAppContext();
|
5976
|
-
(0,
|
6194
|
+
(0, import_react38.useEffect)(() => {
|
5977
6195
|
var _a;
|
5978
6196
|
if (ref.current && status === "READY") {
|
5979
6197
|
const iframe = ref.current;
|
@@ -6010,9 +6228,9 @@ var useBubbleIframeEvents = (ref) => {
|
|
6010
6228
|
}
|
6011
6229
|
}, [status]);
|
6012
6230
|
};
|
6013
|
-
var
|
6231
|
+
var Preview2 = ({ id = "puck-preview" }) => {
|
6014
6232
|
const { config, dispatch, state, setStatus, iframe, overrides } = useAppContext();
|
6015
|
-
const Page = (0,
|
6233
|
+
const Page = (0, import_react38.useCallback)(
|
6016
6234
|
(pageProps) => {
|
6017
6235
|
var _a, _b;
|
6018
6236
|
return ((_a = config.root) == null ? void 0 : _a.render) ? (_b = config.root) == null ? void 0 : _b.render(__spreadValues({
|
@@ -6021,9 +6239,9 @@ var Preview = ({ id = "puck-preview" }) => {
|
|
6021
6239
|
},
|
6022
6240
|
[config.root]
|
6023
6241
|
);
|
6024
|
-
const Frame = (0,
|
6242
|
+
const Frame = (0, import_react38.useMemo)(() => overrides.iframe, [overrides]);
|
6025
6243
|
const rootProps = state.data.root.props || state.data.root;
|
6026
|
-
const ref = (0,
|
6244
|
+
const ref = (0, import_react38.useRef)(null);
|
6027
6245
|
useBubbleIframeEvents(ref);
|
6028
6246
|
const inner = state.ui.previewMode === "edit" ? /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
6029
6247
|
Page,
|
@@ -6120,7 +6338,7 @@ var scrollIntoView = (el) => {
|
|
6120
6338
|
};
|
6121
6339
|
|
6122
6340
|
// components/LayerTree/index.tsx
|
6123
|
-
var
|
6341
|
+
var import_react39 = require("react");
|
6124
6342
|
|
6125
6343
|
// lib/is-child-of-zone.ts
|
6126
6344
|
init_react_import();
|
@@ -6166,7 +6384,7 @@ var LayerTree = ({
|
|
6166
6384
|
label
|
6167
6385
|
}) => {
|
6168
6386
|
const zones = data.zones || {};
|
6169
|
-
const ctx = (0,
|
6387
|
+
const ctx = (0, import_react39.useContext)(dropZoneContext);
|
6170
6388
|
return /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(import_jsx_runtime33.Fragment, { children: [
|
6171
6389
|
label && /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { className: getClassName24("zoneTitle"), children: [
|
6172
6390
|
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)("div", { className: getClassName24("zoneIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Layers, { size: "16" }) }),
|
@@ -6273,13 +6491,13 @@ var LayerTree = ({
|
|
6273
6491
|
};
|
6274
6492
|
|
6275
6493
|
// components/Puck/components/Outline/index.tsx
|
6276
|
-
var
|
6494
|
+
var import_react40 = require("react");
|
6277
6495
|
var import_jsx_runtime34 = require("react/jsx-runtime");
|
6278
6496
|
var Outline = () => {
|
6279
6497
|
const { dispatch, state, overrides, config } = useAppContext();
|
6280
6498
|
const { data, ui } = state;
|
6281
6499
|
const { itemSelector } = ui;
|
6282
|
-
const setItemSelector = (0,
|
6500
|
+
const setItemSelector = (0, import_react40.useCallback)(
|
6283
6501
|
(newItemSelector) => {
|
6284
6502
|
dispatch({
|
6285
6503
|
type: "setUi",
|
@@ -6288,7 +6506,7 @@ var Outline = () => {
|
|
6288
6506
|
},
|
6289
6507
|
[]
|
6290
6508
|
);
|
6291
|
-
const Wrapper = (0,
|
6509
|
+
const Wrapper = (0, import_react40.useMemo)(() => overrides.outline || "div", [overrides]);
|
6292
6510
|
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
6511
|
(ctx == null ? void 0 : ctx.activeZones) && (ctx == null ? void 0 : ctx.activeZones[rootDroppableId]) && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
6294
6512
|
LayerTree,
|
@@ -6402,19 +6620,19 @@ function usePuckHistory({
|
|
6402
6620
|
|
6403
6621
|
// lib/use-history-store.ts
|
6404
6622
|
init_react_import();
|
6405
|
-
var
|
6623
|
+
var import_react41 = require("react");
|
6406
6624
|
var import_use_debounce3 = require("use-debounce");
|
6407
6625
|
var EMPTY_HISTORY_INDEX = 0;
|
6408
6626
|
function useHistoryStore(initialHistory) {
|
6409
6627
|
var _a, _b;
|
6410
|
-
const [histories, setHistories] = (0,
|
6628
|
+
const [histories, setHistories] = (0, import_react41.useState)(
|
6411
6629
|
(_a = initialHistory == null ? void 0 : initialHistory.histories) != null ? _a : []
|
6412
6630
|
);
|
6413
6631
|
const updateHistories = (histories2) => {
|
6414
6632
|
setHistories(histories2);
|
6415
6633
|
setIndex(histories2.length - 1);
|
6416
6634
|
};
|
6417
|
-
const [index, setIndex] = (0,
|
6635
|
+
const [index, setIndex] = (0, import_react41.useState)(
|
6418
6636
|
(_b = initialHistory == null ? void 0 : initialHistory.index) != null ? _b : EMPTY_HISTORY_INDEX
|
6419
6637
|
);
|
6420
6638
|
const hasPast = index > EMPTY_HISTORY_INDEX;
|
@@ -6574,11 +6792,11 @@ var getBox = function getBox2(el) {
|
|
6574
6792
|
};
|
6575
6793
|
|
6576
6794
|
// components/Puck/components/Canvas/index.tsx
|
6577
|
-
var
|
6795
|
+
var import_react43 = require("react");
|
6578
6796
|
|
6579
6797
|
// components/ViewportControls/index.tsx
|
6580
6798
|
init_react_import();
|
6581
|
-
var
|
6799
|
+
var import_react42 = require("react");
|
6582
6800
|
|
6583
6801
|
// css-module:/home/runner/work/puck/puck/packages/core/components/ViewportControls/styles.module.css#css-module
|
6584
6802
|
init_react_import();
|
@@ -6601,8 +6819,8 @@ var ViewportButton = ({
|
|
6601
6819
|
onClick
|
6602
6820
|
}) => {
|
6603
6821
|
const { state } = useAppContext();
|
6604
|
-
const [isActive, setIsActive] = (0,
|
6605
|
-
(0,
|
6822
|
+
const [isActive, setIsActive] = (0, import_react42.useState)(false);
|
6823
|
+
(0, import_react42.useEffect)(() => {
|
6606
6824
|
setIsActive(width === state.ui.viewports.current.width);
|
6607
6825
|
}, [width, state.ui.viewports.current.width]);
|
6608
6826
|
return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("span", { className: getClassNameButton({ isActive }), children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
@@ -6638,7 +6856,7 @@ var ViewportControls = ({
|
|
6638
6856
|
const defaultsContainAutoZoom = defaultZoomOptions.find(
|
6639
6857
|
(option) => option.value === autoZoom
|
6640
6858
|
);
|
6641
|
-
const zoomOptions = (0,
|
6859
|
+
const zoomOptions = (0, import_react42.useMemo)(
|
6642
6860
|
() => [
|
6643
6861
|
...defaultZoomOptions,
|
6644
6862
|
...defaultsContainAutoZoom ? [] : [
|
@@ -6761,17 +6979,17 @@ var Canvas = () => {
|
|
6761
6979
|
const { status, iframe } = useAppContext();
|
6762
6980
|
const { dispatch, state, overrides, setUi, zoomConfig, setZoomConfig } = useAppContext();
|
6763
6981
|
const { ui } = state;
|
6764
|
-
const frameRef = (0,
|
6765
|
-
const [showTransition, setShowTransition] = (0,
|
6766
|
-
const defaultRender = (0,
|
6982
|
+
const frameRef = (0, import_react43.useRef)(null);
|
6983
|
+
const [showTransition, setShowTransition] = (0, import_react43.useState)(false);
|
6984
|
+
const defaultRender = (0, import_react43.useMemo)(() => {
|
6767
6985
|
const PuckDefault = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_jsx_runtime36.Fragment, { children });
|
6768
6986
|
return PuckDefault;
|
6769
6987
|
}, []);
|
6770
|
-
const CustomPreview = (0,
|
6988
|
+
const CustomPreview = (0, import_react43.useMemo)(
|
6771
6989
|
() => overrides.preview || defaultRender,
|
6772
6990
|
[overrides]
|
6773
6991
|
);
|
6774
|
-
const getFrameDimensions = (0,
|
6992
|
+
const getFrameDimensions = (0, import_react43.useCallback)(() => {
|
6775
6993
|
if (frameRef.current) {
|
6776
6994
|
const frame = frameRef.current;
|
6777
6995
|
const box = getBox(frame);
|
@@ -6779,7 +6997,7 @@ var Canvas = () => {
|
|
6779
6997
|
}
|
6780
6998
|
return { width: 0, height: 0 };
|
6781
6999
|
}, [frameRef]);
|
6782
|
-
const resetAutoZoom = (0,
|
7000
|
+
const resetAutoZoom = (0, import_react43.useCallback)(
|
6783
7001
|
(ui2 = state.ui) => {
|
6784
7002
|
if (frameRef.current) {
|
6785
7003
|
setZoomConfig(
|
@@ -6789,11 +7007,11 @@ var Canvas = () => {
|
|
6789
7007
|
},
|
6790
7008
|
[frameRef, zoomConfig, state.ui]
|
6791
7009
|
);
|
6792
|
-
(0,
|
7010
|
+
(0, import_react43.useEffect)(() => {
|
6793
7011
|
setShowTransition(false);
|
6794
7012
|
resetAutoZoom();
|
6795
7013
|
}, [frameRef, ui.leftSideBarVisible, ui.rightSideBarVisible]);
|
6796
|
-
(0,
|
7014
|
+
(0, import_react43.useEffect)(() => {
|
6797
7015
|
const { height: frameHeight } = getFrameDimensions();
|
6798
7016
|
if (ui.viewports.current.height === "auto") {
|
6799
7017
|
setZoomConfig(__spreadProps(__spreadValues({}, zoomConfig), {
|
@@ -6801,13 +7019,13 @@ var Canvas = () => {
|
|
6801
7019
|
}));
|
6802
7020
|
}
|
6803
7021
|
}, [zoomConfig.zoom]);
|
6804
|
-
(0,
|
7022
|
+
(0, import_react43.useEffect)(() => {
|
6805
7023
|
if (ZOOM_ON_CHANGE) {
|
6806
7024
|
setShowTransition(true);
|
6807
7025
|
resetAutoZoom(ui);
|
6808
7026
|
}
|
6809
7027
|
}, [ui.viewports.current.width]);
|
6810
|
-
(0,
|
7028
|
+
(0, import_react43.useEffect)(() => {
|
6811
7029
|
const cb = () => {
|
6812
7030
|
setShowTransition(false);
|
6813
7031
|
resetAutoZoom();
|
@@ -6817,8 +7035,8 @@ var Canvas = () => {
|
|
6817
7035
|
window.removeEventListener("resize", cb);
|
6818
7036
|
};
|
6819
7037
|
}, []);
|
6820
|
-
const [showLoader, setShowLoader] = (0,
|
6821
|
-
(0,
|
7038
|
+
const [showLoader, setShowLoader] = (0, import_react43.useState)(false);
|
7039
|
+
(0, import_react43.useEffect)(() => {
|
6822
7040
|
setTimeout(() => {
|
6823
7041
|
setShowLoader(true);
|
6824
7042
|
}, 500);
|
@@ -6884,7 +7102,7 @@ var Canvas = () => {
|
|
6884
7102
|
})
|
6885
7103
|
);
|
6886
7104
|
},
|
6887
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(CustomPreview, { children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
7105
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(CustomPreview, { children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Preview2, {}) })
|
6888
7106
|
}
|
6889
7107
|
),
|
6890
7108
|
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: getClassName26("loader"), children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Loader, { size: 24 }) })
|
@@ -6896,7 +7114,7 @@ var Canvas = () => {
|
|
6896
7114
|
|
6897
7115
|
// lib/use-loaded-overrides.ts
|
6898
7116
|
init_react_import();
|
6899
|
-
var
|
7117
|
+
var import_react44 = require("react");
|
6900
7118
|
|
6901
7119
|
// lib/load-overrides.ts
|
6902
7120
|
init_react_import();
|
@@ -6935,7 +7153,7 @@ var useLoadedOverrides = ({
|
|
6935
7153
|
overrides,
|
6936
7154
|
plugins
|
6937
7155
|
}) => {
|
6938
|
-
return (0,
|
7156
|
+
return (0, import_react44.useMemo)(() => {
|
6939
7157
|
return loadOverrides({ overrides, plugins });
|
6940
7158
|
}, [plugins, overrides]);
|
6941
7159
|
};
|
@@ -6947,14 +7165,14 @@ var DefaultOverride = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime37
|
|
6947
7165
|
|
6948
7166
|
// lib/use-inject-css.ts
|
6949
7167
|
init_react_import();
|
6950
|
-
var
|
7168
|
+
var import_react45 = require("react");
|
6951
7169
|
var styles = ``;
|
6952
7170
|
var useInjectStyleSheet = (initialStyles, iframeEnabled) => {
|
6953
|
-
const [el, setEl] = (0,
|
6954
|
-
(0,
|
7171
|
+
const [el, setEl] = (0, import_react45.useState)();
|
7172
|
+
(0, import_react45.useEffect)(() => {
|
6955
7173
|
setEl(document.createElement("style"));
|
6956
7174
|
}, []);
|
6957
|
-
(0,
|
7175
|
+
(0, import_react45.useEffect)(() => {
|
6958
7176
|
var _a;
|
6959
7177
|
if (!el || typeof window === "undefined") {
|
6960
7178
|
return;
|
@@ -6974,10 +7192,10 @@ var useInjectGlobalCss = (iframeEnabled) => {
|
|
6974
7192
|
|
6975
7193
|
// lib/use-preview-mode-hotkeys.ts
|
6976
7194
|
init_react_import();
|
6977
|
-
var
|
7195
|
+
var import_react46 = require("react");
|
6978
7196
|
var import_react_hotkeys_hook2 = require("react-hotkeys-hook");
|
6979
7197
|
var usePreviewModeHotkeys = (dispatch, iframeEnabled) => {
|
6980
|
-
const toggleInteractive = (0,
|
7198
|
+
const toggleInteractive = (0, import_react46.useCallback)(() => {
|
6981
7199
|
dispatch({
|
6982
7200
|
type: "setUi",
|
6983
7201
|
ui: (ui) => ({
|
@@ -7029,7 +7247,7 @@ function Puck({
|
|
7029
7247
|
waitForStyles: true
|
7030
7248
|
}, _iframe);
|
7031
7249
|
useInjectGlobalCss(iframe.enabled);
|
7032
|
-
const [generatedAppState] = (0,
|
7250
|
+
const [generatedAppState] = (0, import_react47.useState)(() => {
|
7033
7251
|
var _a2, _b2, _c, _d, _e, _f, _g, _h, _i;
|
7034
7252
|
const initial = __spreadValues(__spreadValues({}, defaultAppState.ui), initialUi);
|
7035
7253
|
let clientUiState = {};
|
@@ -7101,14 +7319,14 @@ function Puck({
|
|
7101
7319
|
histories,
|
7102
7320
|
index: initialHistoryIndex
|
7103
7321
|
});
|
7104
|
-
const [reducer] = (0,
|
7322
|
+
const [reducer] = (0, import_react47.useState)(
|
7105
7323
|
() => createReducer({
|
7106
7324
|
config,
|
7107
7325
|
record: historyStore.record,
|
7108
7326
|
onAction
|
7109
7327
|
})
|
7110
7328
|
);
|
7111
|
-
const [appState, dispatch] = (0,
|
7329
|
+
const [appState, dispatch] = (0, import_react47.useReducer)(
|
7112
7330
|
reducer,
|
7113
7331
|
flushZones(initialAppState)
|
7114
7332
|
);
|
@@ -7119,14 +7337,14 @@ function Puck({
|
|
7119
7337
|
historyStore,
|
7120
7338
|
iframeEnabled: (_a = _iframe == null ? void 0 : _iframe.enabled) != null ? _a : true
|
7121
7339
|
});
|
7122
|
-
const [menuOpen, setMenuOpen] = (0,
|
7340
|
+
const [menuOpen, setMenuOpen] = (0, import_react47.useState)(false);
|
7123
7341
|
const { itemSelector, leftSideBarVisible, rightSideBarVisible } = ui;
|
7124
7342
|
const selectedItem = itemSelector ? getItem(itemSelector, data) : null;
|
7125
|
-
(0,
|
7343
|
+
(0, import_react47.useEffect)(() => {
|
7126
7344
|
if (onChange) onChange(data);
|
7127
7345
|
}, [data]);
|
7128
7346
|
const rootProps = data.root.props || data.root;
|
7129
|
-
const toggleSidebars = (0,
|
7347
|
+
const toggleSidebars = (0, import_react47.useCallback)(
|
7130
7348
|
(sidebar) => {
|
7131
7349
|
const widerViewport = window.matchMedia("(min-width: 638px)").matches;
|
7132
7350
|
const sideBarVisible = sidebar === "left" ? leftSideBarVisible : rightSideBarVisible;
|
@@ -7140,7 +7358,7 @@ function Puck({
|
|
7140
7358
|
},
|
7141
7359
|
[dispatch, leftSideBarVisible, rightSideBarVisible]
|
7142
7360
|
);
|
7143
|
-
(0,
|
7361
|
+
(0, import_react47.useEffect)(() => {
|
7144
7362
|
if (!window.matchMedia("(min-width: 638px)").matches) {
|
7145
7363
|
dispatch({
|
7146
7364
|
type: "setUi",
|
@@ -7163,7 +7381,7 @@ function Puck({
|
|
7163
7381
|
window.removeEventListener("resize", handleResize);
|
7164
7382
|
};
|
7165
7383
|
}, []);
|
7166
|
-
const defaultHeaderRender = (0,
|
7384
|
+
const defaultHeaderRender = (0, import_react47.useMemo)(() => {
|
7167
7385
|
if (renderHeader) {
|
7168
7386
|
console.warn(
|
7169
7387
|
"`renderHeader` is deprecated. Please use `overrides.header` and the `usePuck` hook instead"
|
@@ -7177,7 +7395,7 @@ function Puck({
|
|
7177
7395
|
}
|
7178
7396
|
return DefaultOverride;
|
7179
7397
|
}, [renderHeader]);
|
7180
|
-
const defaultHeaderActionsRender = (0,
|
7398
|
+
const defaultHeaderActionsRender = (0, import_react47.useMemo)(() => {
|
7181
7399
|
if (renderHeaderActions) {
|
7182
7400
|
console.warn(
|
7183
7401
|
"`renderHeaderActions` is deprecated. Please use `overrides.headerActions` and the `usePuck` hook instead."
|
@@ -7194,20 +7412,20 @@ function Puck({
|
|
7194
7412
|
overrides,
|
7195
7413
|
plugins
|
7196
7414
|
});
|
7197
|
-
const CustomPuck = (0,
|
7415
|
+
const CustomPuck = (0, import_react47.useMemo)(
|
7198
7416
|
() => loadedOverrides.puck || DefaultOverride,
|
7199
7417
|
[loadedOverrides]
|
7200
7418
|
);
|
7201
|
-
const CustomHeader = (0,
|
7419
|
+
const CustomHeader = (0, import_react47.useMemo)(
|
7202
7420
|
() => loadedOverrides.header || defaultHeaderRender,
|
7203
7421
|
[loadedOverrides]
|
7204
7422
|
);
|
7205
|
-
const CustomHeaderActions = (0,
|
7423
|
+
const CustomHeaderActions = (0, import_react47.useMemo)(
|
7206
7424
|
() => loadedOverrides.headerActions || defaultHeaderActionsRender,
|
7207
7425
|
[loadedOverrides]
|
7208
7426
|
);
|
7209
|
-
const [mounted, setMounted] = (0,
|
7210
|
-
(0,
|
7427
|
+
const [mounted, setMounted] = (0, import_react47.useState)(false);
|
7428
|
+
(0, import_react47.useEffect)(() => {
|
7211
7429
|
setMounted(true);
|
7212
7430
|
}, []);
|
7213
7431
|
const selectedComponentConfig = selectedItem && config.components[selectedItem.type];
|
@@ -7368,7 +7586,7 @@ function Puck({
|
|
7368
7586
|
Puck.Components = Components;
|
7369
7587
|
Puck.Fields = Fields;
|
7370
7588
|
Puck.Outline = Outline;
|
7371
|
-
Puck.Preview =
|
7589
|
+
Puck.Preview = Preview2;
|
7372
7590
|
|
7373
7591
|
// lib/migrate.ts
|
7374
7592
|
init_react_import();
|