@measured/puck 0.19.0-canary.24030a9 → 0.19.0-canary.46835fd
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-T6VJEBJD.mjs → chunk-7N5DRY4G.mjs} +44 -8
- package/dist/index.css +13 -0
- package/dist/index.d.mts +3 -14
- package/dist/index.d.ts +3 -14
- package/dist/index.js +415 -424
- package/dist/index.mjs +258 -302
- package/dist/{resolve-all-data-DleIzc4N.d.mts → resolve-all-data-3XjIPfNh.d.mts} +12 -1
- package/dist/{resolve-all-data-DleIzc4N.d.ts → resolve-all-data-3XjIPfNh.d.ts} +12 -1
- package/dist/rsc.d.mts +2 -2
- package/dist/rsc.d.ts +2 -2
- package/dist/rsc.js +37 -2
- package/dist/rsc.mjs +5 -3
- package/package.json +2 -2
package/dist/index.js
CHANGED
@@ -311,7 +311,7 @@ init_react_import();
|
|
311
311
|
var styles_module_default2 = { "InputWrapper": "_InputWrapper_g5w3n_1", "Input-label": "_Input-label_g5w3n_5", "Input-labelIcon": "_Input-labelIcon_g5w3n_14", "Input-disabledIcon": "_Input-disabledIcon_g5w3n_21", "Input-input": "_Input-input_g5w3n_26", "Input": "_Input_g5w3n_1", "Input--readOnly": "_Input--readOnly_g5w3n_74", "Input-radioGroupItems": "_Input-radioGroupItems_g5w3n_85", "Input-radio": "_Input-radio_g5w3n_85", "Input-radioInner": "_Input-radioInner_g5w3n_102", "Input-radioInput": "_Input-radioInput_g5w3n_147" };
|
312
312
|
|
313
313
|
// components/AutoField/index.tsx
|
314
|
-
var
|
314
|
+
var import_react23 = require("react");
|
315
315
|
|
316
316
|
// components/AutoField/fields/index.tsx
|
317
317
|
init_react_import();
|
@@ -771,7 +771,7 @@ var IconButton = ({
|
|
771
771
|
};
|
772
772
|
|
773
773
|
// components/AutoField/fields/ArrayField/index.tsx
|
774
|
-
var
|
774
|
+
var import_react15 = require("react");
|
775
775
|
|
776
776
|
// components/DragIcon/index.tsx
|
777
777
|
init_react_import();
|
@@ -2098,7 +2098,6 @@ function useAppStoreApi() {
|
|
2098
2098
|
// components/Sortable/index.tsx
|
2099
2099
|
init_react_import();
|
2100
2100
|
var import_react13 = require("@dnd-kit/react");
|
2101
|
-
var import_react14 = require("react");
|
2102
2101
|
|
2103
2102
|
// lib/dnd/dnd-kit/safe.ts
|
2104
2103
|
init_react_import();
|
@@ -2121,7 +2120,8 @@ function useDraggableSafe(input) {
|
|
2121
2120
|
function useSortableSafe(input) {
|
2122
2121
|
if (typeof window === "undefined") {
|
2123
2122
|
return { ref: () => {
|
2124
|
-
}, status: "idle"
|
2123
|
+
}, status: "idle", handleRef: () => {
|
2124
|
+
} };
|
2125
2125
|
}
|
2126
2126
|
return (0, import_sortable.useSortable)(input);
|
2127
2127
|
}
|
@@ -2396,23 +2396,26 @@ function patchWindow(window2) {
|
|
2396
2396
|
|
2397
2397
|
// lib/dnd/use-sensors.ts
|
2398
2398
|
var import_utilities2 = require("@dnd-kit/dom/utilities");
|
2399
|
-
var useSensors = (
|
2399
|
+
var useSensors = ({
|
2400
|
+
other,
|
2401
|
+
mouse,
|
2402
|
+
touch
|
2403
|
+
} = {
|
2404
|
+
touch: { delay: { value: 200, tolerance: 10 } },
|
2405
|
+
other: { delay: { value: 200, tolerance: 10 }, distance: { value: 5 } }
|
2406
|
+
}) => {
|
2400
2407
|
const [sensors] = (0, import_react12.useState)(() => [
|
2401
2408
|
PointerSensor.configure({
|
2402
2409
|
activationConstraints(event, source) {
|
2403
2410
|
var _a;
|
2404
2411
|
const { pointerType, target } = event;
|
2405
2412
|
if (pointerType === "mouse" && (0, import_utilities2.isElement)(target) && (source.handle === target || ((_a = source.handle) == null ? void 0 : _a.contains(target)))) {
|
2406
|
-
return
|
2413
|
+
return mouse;
|
2407
2414
|
}
|
2408
|
-
const delay = { value: 200, tolerance: 10 };
|
2409
2415
|
if (pointerType === "touch") {
|
2410
|
-
return
|
2416
|
+
return touch;
|
2411
2417
|
}
|
2412
|
-
return
|
2413
|
-
delay,
|
2414
|
-
distance: { value: 5 }
|
2415
|
-
};
|
2418
|
+
return other;
|
2416
2419
|
}
|
2417
2420
|
})
|
2418
2421
|
]);
|
@@ -2755,31 +2758,24 @@ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input
|
|
2755
2758
|
};
|
2756
2759
|
|
2757
2760
|
// components/Sortable/index.tsx
|
2758
|
-
var import_modifiers = require("@dnd-kit/dom/modifiers");
|
2759
2761
|
var import_jsx_runtime5 = require("react/jsx-runtime");
|
2760
2762
|
var SortableProvider = ({
|
2761
|
-
container,
|
2762
2763
|
children,
|
2763
2764
|
onDragStart,
|
2764
2765
|
onDragEnd,
|
2765
2766
|
onMove
|
2766
2767
|
}) => {
|
2767
|
-
const
|
2768
|
-
|
2768
|
+
const sensors = useSensors({
|
2769
|
+
mouse: { distance: { value: 5 } }
|
2770
|
+
});
|
2769
2771
|
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
2770
2772
|
import_react13.DragDropProvider,
|
2771
2773
|
{
|
2772
2774
|
sensors,
|
2773
|
-
modifiers: [
|
2774
|
-
import_modifiers.RestrictToElement.configure({
|
2775
|
-
element() {
|
2776
|
-
return container.current;
|
2777
|
-
}
|
2778
|
-
})
|
2779
|
-
],
|
2780
2775
|
onDragStart,
|
2781
2776
|
onDragOver: (event, manager) => {
|
2782
2777
|
var _a, _b;
|
2778
|
+
event.preventDefault();
|
2783
2779
|
const { operation } = event;
|
2784
2780
|
const { source, target } = operation;
|
2785
2781
|
if (!source || !target) return;
|
@@ -2787,14 +2783,14 @@ var SortableProvider = ({
|
|
2787
2783
|
let targetIndex = target.data.index;
|
2788
2784
|
const collisionData = (_b = (_a = manager.dragOperation.data) == null ? void 0 : _a.collisionMap) == null ? void 0 : _b[target.id];
|
2789
2785
|
if (sourceIndex !== targetIndex && source.id !== target.id) {
|
2790
|
-
const collisionPosition =
|
2786
|
+
const collisionPosition = collisionData.direction === "up" ? "before" : "after";
|
2791
2787
|
if (targetIndex >= sourceIndex) {
|
2792
2788
|
targetIndex = targetIndex - 1;
|
2793
2789
|
}
|
2794
2790
|
if (collisionPosition === "after") {
|
2795
2791
|
targetIndex = targetIndex + 1;
|
2796
2792
|
}
|
2797
|
-
|
2793
|
+
onMove({
|
2798
2794
|
source: sourceIndex,
|
2799
2795
|
target: targetIndex
|
2800
2796
|
});
|
@@ -2802,12 +2798,8 @@ var SortableProvider = ({
|
|
2802
2798
|
},
|
2803
2799
|
onDragEnd: () => {
|
2804
2800
|
setTimeout(() => {
|
2805
|
-
if (move.source !== -1 && move.target !== -1) {
|
2806
|
-
onMove(move);
|
2807
|
-
}
|
2808
2801
|
onDragEnd();
|
2809
2802
|
}, 250);
|
2810
|
-
setMove({ source: -1, target: -1 });
|
2811
2803
|
},
|
2812
2804
|
children
|
2813
2805
|
}
|
@@ -2820,7 +2812,11 @@ var Sortable = ({
|
|
2820
2812
|
children,
|
2821
2813
|
type = "item"
|
2822
2814
|
}) => {
|
2823
|
-
const {
|
2815
|
+
const {
|
2816
|
+
ref: sortableRef,
|
2817
|
+
status,
|
2818
|
+
handleRef
|
2819
|
+
} = useSortableSafe({
|
2824
2820
|
id,
|
2825
2821
|
type,
|
2826
2822
|
index,
|
@@ -2828,16 +2824,16 @@ var Sortable = ({
|
|
2828
2824
|
data: { index },
|
2829
2825
|
collisionDetector: createDynamicCollisionDetector("y")
|
2830
2826
|
});
|
2831
|
-
return children({ status, ref: sortableRef });
|
2827
|
+
return children({ status, ref: sortableRef, handleRef });
|
2832
2828
|
};
|
2833
2829
|
|
2834
2830
|
// components/AutoField/context.tsx
|
2835
2831
|
init_react_import();
|
2836
|
-
var
|
2832
|
+
var import_react14 = require("react");
|
2837
2833
|
var import_jsx_runtime6 = require("react/jsx-runtime");
|
2838
|
-
var NestedFieldContext = (0,
|
2834
|
+
var NestedFieldContext = (0, import_react14.createContext)({});
|
2839
2835
|
var useNestedFieldContext = () => {
|
2840
|
-
const context = (0,
|
2836
|
+
const context = (0, import_react14.useContext)(NestedFieldContext);
|
2841
2837
|
return __spreadProps(__spreadValues({}, context), {
|
2842
2838
|
readOnlyFields: context.readOnlyFields || {}
|
2843
2839
|
});
|
@@ -2851,7 +2847,7 @@ var NestedFieldProvider = ({
|
|
2851
2847
|
}) => {
|
2852
2848
|
const subPath = `${name}.${subName}`;
|
2853
2849
|
const wildcardSubPath = `${wildcardName}.${subName}`;
|
2854
|
-
const subReadOnlyFields = (0,
|
2850
|
+
const subReadOnlyFields = (0, import_react14.useMemo)(
|
2855
2851
|
() => Object.keys(readOnlyFields).reduce((acc, readOnlyKey) => {
|
2856
2852
|
const isLocal = readOnlyKey.indexOf(subPath) > -1 || readOnlyKey.indexOf(wildcardSubPath) > -1;
|
2857
2853
|
if (isLocal) {
|
@@ -2904,12 +2900,14 @@ var ArrayField = ({
|
|
2904
2900
|
}),
|
2905
2901
|
openId: ""
|
2906
2902
|
};
|
2907
|
-
const [localState, setLocalState] = (0,
|
2908
|
-
(0,
|
2909
|
-
|
2910
|
-
|
2903
|
+
const [localState, setLocalState] = (0, import_react15.useState)({ arrayState, value });
|
2904
|
+
(0, import_react15.useEffect)(() => {
|
2905
|
+
var _a;
|
2906
|
+
const _arrayState = (_a = appStore.getState().state.ui.arrayState[id]) != null ? _a : arrayState;
|
2907
|
+
setLocalState({ arrayState: _arrayState, value });
|
2908
|
+
}, [value]);
|
2911
2909
|
const appStore = useAppStoreApi();
|
2912
|
-
const mapArrayStateToUi = (0,
|
2910
|
+
const mapArrayStateToUi = (0, import_react15.useCallback)(
|
2913
2911
|
(partialArrayState) => {
|
2914
2912
|
const state = appStore.getState().state;
|
2915
2913
|
return {
|
@@ -2920,13 +2918,13 @@ var ArrayField = ({
|
|
2920
2918
|
},
|
2921
2919
|
[arrayState, appStore]
|
2922
2920
|
);
|
2923
|
-
const getHighestIndex = (0,
|
2921
|
+
const getHighestIndex = (0, import_react15.useCallback)(() => {
|
2924
2922
|
return arrayState.items.reduce(
|
2925
2923
|
(acc, item) => item._originalIndex > acc ? item._originalIndex : acc,
|
2926
2924
|
-1
|
2927
2925
|
);
|
2928
2926
|
}, [arrayState]);
|
2929
|
-
const regenerateArrayState = (0,
|
2927
|
+
const regenerateArrayState = (0, import_react15.useCallback)(
|
2930
2928
|
(value2) => {
|
2931
2929
|
let highestIndex = getHighestIndex();
|
2932
2930
|
const newItems = Array.from(value2 || []).map((item, idx) => {
|
@@ -2945,13 +2943,12 @@ var ArrayField = ({
|
|
2945
2943
|
},
|
2946
2944
|
[arrayState]
|
2947
2945
|
);
|
2948
|
-
(0,
|
2946
|
+
(0, import_react15.useEffect)(() => {
|
2949
2947
|
if (arrayState.items.length > 0) {
|
2950
2948
|
setUi(mapArrayStateToUi(arrayState));
|
2951
2949
|
}
|
2952
2950
|
}, []);
|
2953
|
-
const [isDragging, setIsDragging] = (0,
|
2954
|
-
const dndContainerRef = (0, import_react16.useRef)(null);
|
2951
|
+
const [isDragging, setIsDragging] = (0, import_react15.useState)(false);
|
2955
2952
|
const canEdit = useAppStore(
|
2956
2953
|
(s) => s.permissions.getPermissions({ item: s.selectedItem }).edit
|
2957
2954
|
);
|
@@ -2970,11 +2967,13 @@ var ArrayField = ({
|
|
2970
2967
|
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
2971
2968
|
SortableProvider,
|
2972
2969
|
{
|
2973
|
-
container: dndContainerRef,
|
2974
2970
|
onDragStart: () => setIsDragging(true),
|
2975
|
-
onDragEnd: () =>
|
2971
|
+
onDragEnd: () => {
|
2972
|
+
setIsDragging(false);
|
2973
|
+
onChange(localState.value);
|
2974
|
+
},
|
2976
2975
|
onMove: (move) => {
|
2977
|
-
const newValue = reorder(value, move.source, move.target);
|
2976
|
+
const newValue = reorder(localState.value, move.source, move.target);
|
2978
2977
|
const newArrayStateItems = reorder(
|
2979
2978
|
arrayState.items,
|
2980
2979
|
move.source,
|
@@ -2987,7 +2986,6 @@ var ArrayField = ({
|
|
2987
2986
|
})
|
2988
2987
|
};
|
2989
2988
|
setUi(newUi, false);
|
2990
|
-
onChange(newValue, newUi);
|
2991
2989
|
setLocalState({
|
2992
2990
|
value: newValue,
|
2993
2991
|
arrayState: __spreadProps(__spreadValues({}, arrayState), { items: newArrayStateItems })
|
@@ -3001,172 +2999,156 @@ var ArrayField = ({
|
|
3001
2999
|
addDisabled
|
3002
3000
|
}),
|
3003
3001
|
children: [
|
3004
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
3005
|
-
|
3006
|
-
{
|
3007
|
-
|
3008
|
-
|
3009
|
-
|
3010
|
-
|
3011
|
-
|
3012
|
-
|
3013
|
-
|
3014
|
-
|
3002
|
+
localState.arrayState.items.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: getClassName5("inner"), "data-dnd-container": true, children: localState.arrayState.items.map((item, i) => {
|
3003
|
+
const { _arrayId = `${id}-${i}`, _originalIndex = i } = item;
|
3004
|
+
const data = Array.from(localState.value || [])[i] || {};
|
3005
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
3006
|
+
Sortable,
|
3007
|
+
{
|
3008
|
+
id: _arrayId,
|
3009
|
+
index: i,
|
3010
|
+
disabled: readOnly,
|
3011
|
+
children: ({ status, ref, handleRef }) => /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
3012
|
+
"div",
|
3015
3013
|
{
|
3016
|
-
|
3017
|
-
|
3018
|
-
|
3019
|
-
|
3020
|
-
|
3021
|
-
|
3022
|
-
|
3023
|
-
|
3024
|
-
|
3025
|
-
|
3026
|
-
|
3027
|
-
|
3028
|
-
|
3029
|
-
|
3030
|
-
|
3031
|
-
{
|
3032
|
-
|
3033
|
-
|
3034
|
-
|
3035
|
-
|
3036
|
-
|
3037
|
-
|
3038
|
-
|
3039
|
-
|
3040
|
-
|
3041
|
-
|
3042
|
-
|
3043
|
-
setUi(
|
3044
|
-
mapArrayStateToUi({
|
3045
|
-
openId: _arrayId
|
3046
|
-
})
|
3047
|
-
);
|
3048
|
-
}
|
3049
|
-
},
|
3050
|
-
className: getClassNameItem("summary"),
|
3051
|
-
children: [
|
3052
|
-
field.getItemSummary ? field.getItemSummary(data, i) : `Item #${_originalIndex}`,
|
3053
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: getClassNameItem("rhs"), children: [
|
3054
|
-
!readOnly && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: getClassNameItem("actions"), children: [
|
3055
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: getClassNameItem("action"), children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
3056
|
-
IconButton,
|
3057
|
-
{
|
3058
|
-
type: "button",
|
3059
|
-
disabled: !!addDisabled,
|
3060
|
-
onClick: (e) => {
|
3061
|
-
e.stopPropagation();
|
3062
|
-
const existingValue = [...value || []];
|
3063
|
-
existingValue.splice(
|
3064
|
-
i,
|
3065
|
-
0,
|
3066
|
-
existingValue[i]
|
3067
|
-
);
|
3068
|
-
onChange(
|
3069
|
-
existingValue,
|
3070
|
-
mapArrayStateToUi(
|
3071
|
-
regenerateArrayState(existingValue)
|
3072
|
-
)
|
3073
|
-
);
|
3074
|
-
},
|
3075
|
-
title: "Duplicate",
|
3076
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Copy, { size: 16 })
|
3077
|
-
}
|
3078
|
-
) }),
|
3079
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: getClassNameItem("action"), children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
3080
|
-
IconButton,
|
3081
|
-
{
|
3082
|
-
type: "button",
|
3083
|
-
disabled: field.min !== void 0 && field.min >= localState.arrayState.items.length,
|
3084
|
-
onClick: (e) => {
|
3085
|
-
e.stopPropagation();
|
3086
|
-
const existingValue = [...value || []];
|
3087
|
-
const existingItems = [
|
3088
|
-
...arrayState.items || []
|
3089
|
-
];
|
3090
|
-
existingValue.splice(i, 1);
|
3091
|
-
existingItems.splice(i, 1);
|
3092
|
-
onChange(
|
3093
|
-
existingValue,
|
3094
|
-
mapArrayStateToUi({
|
3095
|
-
items: existingItems
|
3096
|
-
})
|
3097
|
-
);
|
3098
|
-
},
|
3099
|
-
title: "Delete",
|
3100
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Trash, { size: 16 })
|
3101
|
-
}
|
3102
|
-
) })
|
3103
|
-
] }),
|
3104
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(DragIcon, {}) })
|
3105
|
-
] })
|
3106
|
-
]
|
3014
|
+
ref,
|
3015
|
+
className: getClassNameItem({
|
3016
|
+
isExpanded: arrayState.openId === _arrayId,
|
3017
|
+
isDragging: status === "dragging",
|
3018
|
+
readOnly
|
3019
|
+
}),
|
3020
|
+
children: [
|
3021
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
3022
|
+
"div",
|
3023
|
+
{
|
3024
|
+
ref: handleRef,
|
3025
|
+
onClick: (e) => {
|
3026
|
+
if (isDragging) return;
|
3027
|
+
e.preventDefault();
|
3028
|
+
e.stopPropagation();
|
3029
|
+
if (arrayState.openId === _arrayId) {
|
3030
|
+
setUi(
|
3031
|
+
mapArrayStateToUi({
|
3032
|
+
openId: ""
|
3033
|
+
})
|
3034
|
+
);
|
3035
|
+
} else {
|
3036
|
+
setUi(
|
3037
|
+
mapArrayStateToUi({
|
3038
|
+
openId: _arrayId
|
3039
|
+
})
|
3040
|
+
);
|
3107
3041
|
}
|
3108
|
-
|
3109
|
-
|
3110
|
-
|
3111
|
-
{
|
3112
|
-
|
3113
|
-
|
3114
|
-
|
3115
|
-
|
3116
|
-
children: Object.keys(field.arrayFields).map((subName) => {
|
3117
|
-
const subField = field.arrayFields[subName];
|
3118
|
-
const indexName = `${name}[${i}]`;
|
3119
|
-
const subPath = `${indexName}.${subName}`;
|
3120
|
-
const localIndexName = `${localName}[${i}]`;
|
3121
|
-
const localWildcardName = `${localName}[*]`;
|
3122
|
-
const localSubPath = `${localIndexName}.${subName}`;
|
3123
|
-
const localWildcardSubPath = `${localWildcardName}.${subName}`;
|
3124
|
-
const subReadOnly = forceReadOnly ? forceReadOnly : typeof readOnlyFields[subPath] !== "undefined" ? readOnlyFields[localSubPath] : readOnlyFields[localWildcardSubPath];
|
3125
|
-
const label2 = subField.label || subName;
|
3126
|
-
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
3127
|
-
NestedFieldProvider,
|
3042
|
+
},
|
3043
|
+
className: getClassNameItem("summary"),
|
3044
|
+
children: [
|
3045
|
+
field.getItemSummary ? field.getItemSummary(data, i) : `Item #${_originalIndex}`,
|
3046
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: getClassNameItem("rhs"), children: [
|
3047
|
+
!readOnly && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: getClassNameItem("actions"), children: [
|
3048
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: getClassNameItem("action"), children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
3049
|
+
IconButton,
|
3128
3050
|
{
|
3129
|
-
|
3130
|
-
|
3131
|
-
|
3132
|
-
|
3133
|
-
|
3134
|
-
|
3135
|
-
|
3136
|
-
|
3137
|
-
|
3138
|
-
|
3139
|
-
|
3140
|
-
|
3141
|
-
|
3142
|
-
|
3051
|
+
type: "button",
|
3052
|
+
disabled: !!addDisabled,
|
3053
|
+
onClick: (e) => {
|
3054
|
+
e.stopPropagation();
|
3055
|
+
const existingValue = [...value || []];
|
3056
|
+
existingValue.splice(
|
3057
|
+
i,
|
3058
|
+
0,
|
3059
|
+
existingValue[i]
|
3060
|
+
);
|
3061
|
+
const newUi = mapArrayStateToUi(
|
3062
|
+
regenerateArrayState(existingValue)
|
3063
|
+
);
|
3064
|
+
setUi(newUi, false);
|
3065
|
+
onChange(existingValue);
|
3066
|
+
},
|
3067
|
+
title: "Duplicate",
|
3068
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Copy, { size: 16 })
|
3069
|
+
}
|
3070
|
+
) }),
|
3071
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: getClassNameItem("action"), children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
3072
|
+
IconButton,
|
3073
|
+
{
|
3074
|
+
type: "button",
|
3075
|
+
disabled: field.min !== void 0 && field.min >= localState.arrayState.items.length,
|
3076
|
+
onClick: (e) => {
|
3077
|
+
e.stopPropagation();
|
3078
|
+
const existingValue = [...value || []];
|
3079
|
+
const existingItems = [
|
3080
|
+
...arrayState.items || []
|
3081
|
+
];
|
3082
|
+
existingValue.splice(i, 1);
|
3083
|
+
existingItems.splice(i, 1);
|
3084
|
+
setUi(
|
3085
|
+
mapArrayStateToUi({
|
3086
|
+
items: existingItems
|
3143
3087
|
}),
|
3144
|
-
|
3145
|
-
|
3146
|
-
|
3147
|
-
|
3148
|
-
|
3149
|
-
|
3150
|
-
|
3151
|
-
|
3152
|
-
|
3153
|
-
|
3154
|
-
|
3155
|
-
|
3156
|
-
|
3157
|
-
|
3158
|
-
|
3159
|
-
|
3160
|
-
|
3161
|
-
|
3162
|
-
|
3163
|
-
|
3164
|
-
|
3165
|
-
|
3166
|
-
|
3167
|
-
|
3168
|
-
|
3169
|
-
|
3088
|
+
false
|
3089
|
+
);
|
3090
|
+
onChange(existingValue);
|
3091
|
+
},
|
3092
|
+
title: "Delete",
|
3093
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Trash, { size: 16 })
|
3094
|
+
}
|
3095
|
+
) })
|
3096
|
+
] }),
|
3097
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(DragIcon, {}) })
|
3098
|
+
] })
|
3099
|
+
]
|
3100
|
+
}
|
3101
|
+
),
|
3102
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: getClassNameItem("body"), children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("fieldset", { className: getClassNameItem("fieldset"), children: Object.keys(field.arrayFields).map((subName) => {
|
3103
|
+
const subField = field.arrayFields[subName];
|
3104
|
+
const indexName = `${name}[${i}]`;
|
3105
|
+
const subPath = `${indexName}.${subName}`;
|
3106
|
+
const localIndexName = `${localName}[${i}]`;
|
3107
|
+
const localWildcardName = `${localName}[*]`;
|
3108
|
+
const localSubPath = `${localIndexName}.${subName}`;
|
3109
|
+
const localWildcardSubPath = `${localWildcardName}.${subName}`;
|
3110
|
+
const subReadOnly = forceReadOnly ? forceReadOnly : typeof readOnlyFields[subPath] !== "undefined" ? readOnlyFields[localSubPath] : readOnlyFields[localWildcardSubPath];
|
3111
|
+
const label2 = subField.label || subName;
|
3112
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
3113
|
+
NestedFieldProvider,
|
3114
|
+
{
|
3115
|
+
name: localIndexName,
|
3116
|
+
wildcardName: localWildcardName,
|
3117
|
+
subName,
|
3118
|
+
readOnlyFields,
|
3119
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
3120
|
+
AutoFieldPrivate,
|
3121
|
+
{
|
3122
|
+
name: subPath,
|
3123
|
+
label: label2,
|
3124
|
+
id: `${_arrayId}_${subName}`,
|
3125
|
+
readOnly: subReadOnly,
|
3126
|
+
field: __spreadProps(__spreadValues({}, subField), {
|
3127
|
+
label: label2
|
3128
|
+
// May be used by custom fields
|
3129
|
+
}),
|
3130
|
+
value: data[subName],
|
3131
|
+
onChange: (val, ui) => {
|
3132
|
+
onChange(
|
3133
|
+
replace(value, i, __spreadProps(__spreadValues({}, data), {
|
3134
|
+
[subName]: val
|
3135
|
+
})),
|
3136
|
+
ui
|
3137
|
+
);
|
3138
|
+
}
|
3139
|
+
}
|
3140
|
+
)
|
3141
|
+
},
|
3142
|
+
subPath
|
3143
|
+
);
|
3144
|
+
}) }) })
|
3145
|
+
]
|
3146
|
+
}
|
3147
|
+
)
|
3148
|
+
},
|
3149
|
+
_arrayId
|
3150
|
+
);
|
3151
|
+
}) }),
|
3170
3152
|
!addDisabled && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
3171
3153
|
"button",
|
3172
3154
|
{
|
@@ -3180,7 +3162,8 @@ var ArrayField = ({
|
|
3180
3162
|
field.defaultItemProps || {}
|
3181
3163
|
];
|
3182
3164
|
const newArrayState = regenerateArrayState(newValue);
|
3183
|
-
|
3165
|
+
setUi(mapArrayStateToUi(newArrayState), false);
|
3166
|
+
onChange(newValue);
|
3184
3167
|
},
|
3185
3168
|
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Plus, { size: 21 })
|
3186
3169
|
}
|
@@ -3257,11 +3240,11 @@ var DefaultField = ({
|
|
3257
3240
|
|
3258
3241
|
// components/AutoField/fields/ExternalField/index.tsx
|
3259
3242
|
init_react_import();
|
3260
|
-
var
|
3243
|
+
var import_react19 = require("react");
|
3261
3244
|
|
3262
3245
|
// components/ExternalInput/index.tsx
|
3263
3246
|
init_react_import();
|
3264
|
-
var
|
3247
|
+
var import_react18 = require("react");
|
3265
3248
|
|
3266
3249
|
// css-module:/home/runner/work/puck/puck/packages/core/components/ExternalInput/styles.module.css#css-module
|
3267
3250
|
init_react_import();
|
@@ -3269,7 +3252,7 @@ var styles_module_default6 = { "ExternalInput-actions": "_ExternalInput-actions_
|
|
3269
3252
|
|
3270
3253
|
// components/Modal/index.tsx
|
3271
3254
|
init_react_import();
|
3272
|
-
var
|
3255
|
+
var import_react16 = require("react");
|
3273
3256
|
|
3274
3257
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Modal/styles.module.css#css-module
|
3275
3258
|
init_react_import();
|
@@ -3284,8 +3267,8 @@ var Modal = ({
|
|
3284
3267
|
onClose,
|
3285
3268
|
isOpen
|
3286
3269
|
}) => {
|
3287
|
-
const [rootEl, setRootEl] = (0,
|
3288
|
-
(0,
|
3270
|
+
const [rootEl, setRootEl] = (0, import_react16.useState)(null);
|
3271
|
+
(0, import_react16.useEffect)(() => {
|
3289
3272
|
setRootEl(document.getElementById("puck-portal-root"));
|
3290
3273
|
}, []);
|
3291
3274
|
if (!rootEl) {
|
@@ -3332,7 +3315,7 @@ init_react_import();
|
|
3332
3315
|
|
3333
3316
|
// components/Button/Button.tsx
|
3334
3317
|
init_react_import();
|
3335
|
-
var
|
3318
|
+
var import_react17 = require("react");
|
3336
3319
|
|
3337
3320
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Button/Button.module.css#css-module
|
3338
3321
|
init_react_import();
|
@@ -3382,8 +3365,8 @@ var Button = (_a) => {
|
|
3382
3365
|
"size",
|
3383
3366
|
"loading"
|
3384
3367
|
]);
|
3385
|
-
const [loading, setLoading] = (0,
|
3386
|
-
(0,
|
3368
|
+
const [loading, setLoading] = (0, import_react17.useState)(loadingProp);
|
3369
|
+
(0, import_react17.useEffect)(() => setLoading(loadingProp), [loadingProp]);
|
3387
3370
|
const ElementType = href ? "a" : type ? "button" : "span";
|
3388
3371
|
const dataAttrs = filterDataAttrs(props);
|
3389
3372
|
const el = /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
|
@@ -3438,28 +3421,28 @@ var ExternalInput = ({
|
|
3438
3421
|
mapRow = (val) => val,
|
3439
3422
|
filterFields
|
3440
3423
|
} = field || {};
|
3441
|
-
const [data, setData] = (0,
|
3442
|
-
const [isOpen, setOpen] = (0,
|
3443
|
-
const [isLoading, setIsLoading] = (0,
|
3424
|
+
const [data, setData] = (0, import_react18.useState)([]);
|
3425
|
+
const [isOpen, setOpen] = (0, import_react18.useState)(false);
|
3426
|
+
const [isLoading, setIsLoading] = (0, import_react18.useState)(true);
|
3444
3427
|
const hasFilterFields = !!filterFields;
|
3445
|
-
const [filters, setFilters] = (0,
|
3446
|
-
const [filtersToggled, setFiltersToggled] = (0,
|
3447
|
-
const mappedData = (0,
|
3428
|
+
const [filters, setFilters] = (0, import_react18.useState)(field.initialFilters || {});
|
3429
|
+
const [filtersToggled, setFiltersToggled] = (0, import_react18.useState)(hasFilterFields);
|
3430
|
+
const mappedData = (0, import_react18.useMemo)(() => {
|
3448
3431
|
return data.map(mapRow);
|
3449
3432
|
}, [data]);
|
3450
|
-
const keys = (0,
|
3433
|
+
const keys = (0, import_react18.useMemo)(() => {
|
3451
3434
|
const validKeys = /* @__PURE__ */ new Set();
|
3452
3435
|
for (const item of mappedData) {
|
3453
3436
|
for (const key of Object.keys(item)) {
|
3454
|
-
if (typeof item[key] === "string" || typeof item[key] === "number" || (0,
|
3437
|
+
if (typeof item[key] === "string" || typeof item[key] === "number" || (0, import_react18.isValidElement)(item[key])) {
|
3455
3438
|
validKeys.add(key);
|
3456
3439
|
}
|
3457
3440
|
}
|
3458
3441
|
}
|
3459
3442
|
return Array.from(validKeys);
|
3460
3443
|
}, [mappedData]);
|
3461
|
-
const [searchQuery, setSearchQuery] = (0,
|
3462
|
-
const search = (0,
|
3444
|
+
const [searchQuery, setSearchQuery] = (0, import_react18.useState)(field.initialQuery || "");
|
3445
|
+
const search = (0, import_react18.useCallback)(
|
3463
3446
|
(query, filters2) => __async(void 0, null, function* () {
|
3464
3447
|
setIsLoading(true);
|
3465
3448
|
const cacheKey = `${id}-${query}-${JSON.stringify(filters2)}`;
|
@@ -3472,7 +3455,7 @@ var ExternalInput = ({
|
|
3472
3455
|
}),
|
3473
3456
|
[id, field]
|
3474
3457
|
);
|
3475
|
-
const Footer = (0,
|
3458
|
+
const Footer = (0, import_react18.useCallback)(
|
3476
3459
|
(props) => field.renderFooter ? field.renderFooter(props) : /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("span", { className: getClassNameModal("footer"), children: [
|
3477
3460
|
props.items.length,
|
3478
3461
|
" result",
|
@@ -3480,7 +3463,7 @@ var ExternalInput = ({
|
|
3480
3463
|
] }),
|
3481
3464
|
[field.renderFooter]
|
3482
3465
|
);
|
3483
|
-
(0,
|
3466
|
+
(0, import_react18.useEffect)(() => {
|
3484
3467
|
search(searchQuery, filters);
|
3485
3468
|
}, []);
|
3486
3469
|
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
@@ -3652,7 +3635,7 @@ var ExternalField = ({
|
|
3652
3635
|
var _a, _b, _c;
|
3653
3636
|
const validField = field;
|
3654
3637
|
const deprecatedField = field;
|
3655
|
-
(0,
|
3638
|
+
(0, import_react19.useEffect)(() => {
|
3656
3639
|
if (deprecatedField.adaptor) {
|
3657
3640
|
console.error(
|
3658
3641
|
"Warning: The `adaptor` API is deprecated. Please use updated APIs on the `external` field instead. This will be a breaking change in a future release."
|
@@ -3695,7 +3678,7 @@ var ExternalField = ({
|
|
3695
3678
|
|
3696
3679
|
// components/AutoField/fields/RadioField/index.tsx
|
3697
3680
|
init_react_import();
|
3698
|
-
var
|
3681
|
+
var import_react20 = require("react");
|
3699
3682
|
|
3700
3683
|
// lib/safe-json-parse.ts
|
3701
3684
|
init_react_import();
|
@@ -3722,7 +3705,7 @@ var RadioField = ({
|
|
3722
3705
|
labelIcon,
|
3723
3706
|
Label: Label2
|
3724
3707
|
}) => {
|
3725
|
-
const flatOptions = (0,
|
3708
|
+
const flatOptions = (0, import_react20.useMemo)(
|
3726
3709
|
() => field.type === "radio" ? field.options.map(({ value: value2 }) => value2) : [],
|
3727
3710
|
[field]
|
3728
3711
|
);
|
@@ -3772,7 +3755,7 @@ var RadioField = ({
|
|
3772
3755
|
|
3773
3756
|
// components/AutoField/fields/SelectField/index.tsx
|
3774
3757
|
init_react_import();
|
3775
|
-
var
|
3758
|
+
var import_react21 = require("react");
|
3776
3759
|
var import_jsx_runtime15 = require("react/jsx-runtime");
|
3777
3760
|
var getClassName12 = get_class_name_factory_default("Input", styles_module_default2);
|
3778
3761
|
var SelectField = ({
|
@@ -3786,7 +3769,7 @@ var SelectField = ({
|
|
3786
3769
|
readOnly,
|
3787
3770
|
id
|
3788
3771
|
}) => {
|
3789
|
-
const flatOptions = (0,
|
3772
|
+
const flatOptions = (0, import_react21.useMemo)(
|
3790
3773
|
() => field.type === "select" ? field.options.map(({ value: value2 }) => value2) : [],
|
3791
3774
|
[field]
|
3792
3775
|
);
|
@@ -3947,12 +3930,12 @@ var ObjectField = ({
|
|
3947
3930
|
|
3948
3931
|
// lib/use-safe-id.ts
|
3949
3932
|
init_react_import();
|
3950
|
-
var
|
3933
|
+
var import_react22 = __toESM(require("react"));
|
3951
3934
|
var useSafeId = () => {
|
3952
|
-
if (typeof
|
3953
|
-
return
|
3935
|
+
if (typeof import_react22.default.useId !== "undefined") {
|
3936
|
+
return import_react22.default.useId();
|
3954
3937
|
}
|
3955
|
-
const [id] = (0,
|
3938
|
+
const [id] = (0, import_react22.useState)(generateId());
|
3956
3939
|
return id;
|
3957
3940
|
};
|
3958
3941
|
|
@@ -3986,7 +3969,7 @@ var FieldLabelInternal = ({
|
|
3986
3969
|
readOnly
|
3987
3970
|
}) => {
|
3988
3971
|
const overrides = useAppStore((s) => s.overrides);
|
3989
|
-
const Wrapper = (0,
|
3972
|
+
const Wrapper = (0, import_react23.useMemo)(
|
3990
3973
|
() => overrides.fieldLabel || FieldLabel,
|
3991
3974
|
[overrides]
|
3992
3975
|
);
|
@@ -4013,7 +3996,7 @@ function AutoFieldInternal(props) {
|
|
4013
3996
|
var _a2;
|
4014
3997
|
return (_a2 = s.selectedItem) == null ? void 0 : _a2.readOnly;
|
4015
3998
|
});
|
4016
|
-
const nestedFieldContext = (0,
|
3999
|
+
const nestedFieldContext = (0, import_react23.useContext)(NestedFieldContext);
|
4017
4000
|
const { id, Label: Label2 = FieldLabelInternal } = props;
|
4018
4001
|
const field = props.field;
|
4019
4002
|
const label = field.label;
|
@@ -4047,7 +4030,7 @@ function AutoFieldInternal(props) {
|
|
4047
4030
|
Label: Label2,
|
4048
4031
|
id: resolvedId
|
4049
4032
|
});
|
4050
|
-
const onFocus = (0,
|
4033
|
+
const onFocus = (0, import_react23.useCallback)(
|
4051
4034
|
(e) => {
|
4052
4035
|
if (mergedProps.name && (e.target.nodeName === "INPUT" || e.target.nodeName === "TEXTAREA")) {
|
4053
4036
|
e.stopPropagation();
|
@@ -4061,7 +4044,7 @@ function AutoFieldInternal(props) {
|
|
4061
4044
|
},
|
4062
4045
|
[mergedProps.name]
|
4063
4046
|
);
|
4064
|
-
const onBlur = (0,
|
4047
|
+
const onBlur = (0, import_react23.useCallback)((e) => {
|
4065
4048
|
if ("name" in e.target) {
|
4066
4049
|
dispatch({
|
4067
4050
|
type: "setUi",
|
@@ -4105,15 +4088,15 @@ function AutoFieldInternal(props) {
|
|
4105
4088
|
function AutoFieldPrivate(props) {
|
4106
4089
|
const isFocused = useAppStore((s) => s.state.ui.field.focus === props.name);
|
4107
4090
|
const { value, onChange } = props;
|
4108
|
-
const [localValue, setLocalValue] = (0,
|
4109
|
-
const onChangeLocal = (0,
|
4091
|
+
const [localValue, setLocalValue] = (0, import_react23.useState)(value);
|
4092
|
+
const onChangeLocal = (0, import_react23.useCallback)(
|
4110
4093
|
(val, ui) => {
|
4111
4094
|
setLocalValue(val);
|
4112
4095
|
onChange(val, ui);
|
4113
4096
|
},
|
4114
4097
|
[onChange]
|
4115
4098
|
);
|
4116
|
-
(0,
|
4099
|
+
(0, import_react23.useEffect)(() => {
|
4117
4100
|
if (!isFocused) {
|
4118
4101
|
setLocalValue(value);
|
4119
4102
|
}
|
@@ -4125,7 +4108,7 @@ function AutoFieldPrivate(props) {
|
|
4125
4108
|
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(AutoFieldInternal, __spreadValues(__spreadValues({}, props), localProps));
|
4126
4109
|
}
|
4127
4110
|
function AutoField(props) {
|
4128
|
-
const DefaultLabel = (0,
|
4111
|
+
const DefaultLabel = (0, import_react23.useMemo)(() => {
|
4129
4112
|
const DefaultLabel2 = (labelProps) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
4130
4113
|
"div",
|
4131
4114
|
__spreadProps(__spreadValues({}, labelProps), {
|
@@ -4145,21 +4128,21 @@ init_react_import();
|
|
4145
4128
|
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" };
|
4146
4129
|
|
4147
4130
|
// components/Drawer/index.tsx
|
4148
|
-
var
|
4131
|
+
var import_react36 = require("react");
|
4149
4132
|
|
4150
4133
|
// components/DragDropContext/index.tsx
|
4151
4134
|
init_react_import();
|
4152
|
-
var
|
4153
|
-
var
|
4135
|
+
var import_react34 = require("@dnd-kit/react");
|
4136
|
+
var import_react35 = require("react");
|
4154
4137
|
var import_dom = require("@dnd-kit/dom");
|
4155
4138
|
|
4156
4139
|
// components/DropZone/index.tsx
|
4157
4140
|
init_react_import();
|
4158
|
-
var
|
4141
|
+
var import_react33 = require("react");
|
4159
4142
|
|
4160
4143
|
// components/DraggableComponent/index.tsx
|
4161
4144
|
init_react_import();
|
4162
|
-
var
|
4145
|
+
var import_react26 = require("react");
|
4163
4146
|
|
4164
4147
|
// css-module:/home/runner/work/puck/puck/packages/core/components/DraggableComponent/styles.module.css#css-module
|
4165
4148
|
init_react_import();
|
@@ -4189,11 +4172,11 @@ function getDeepScrollPosition(element) {
|
|
4189
4172
|
|
4190
4173
|
// components/DropZone/context.tsx
|
4191
4174
|
init_react_import();
|
4192
|
-
var
|
4175
|
+
var import_react24 = require("react");
|
4193
4176
|
var import_zustand3 = require("zustand");
|
4194
4177
|
var import_jsx_runtime19 = require("react/jsx-runtime");
|
4195
|
-
var dropZoneContext = (0,
|
4196
|
-
var ZoneStoreContext = (0,
|
4178
|
+
var dropZoneContext = (0, import_react24.createContext)(null);
|
4179
|
+
var ZoneStoreContext = (0, import_react24.createContext)(
|
4197
4180
|
(0, import_zustand3.createStore)(() => ({
|
4198
4181
|
zoneDepthIndex: {},
|
4199
4182
|
nextZoneDepthIndex: {},
|
@@ -4213,10 +4196,10 @@ var DropZoneProvider = ({
|
|
4213
4196
|
children,
|
4214
4197
|
value
|
4215
4198
|
}) => {
|
4216
|
-
const [hoveringComponent, setHoveringComponent] = (0,
|
4217
|
-
const [activeZones, setActiveZones] = (0,
|
4199
|
+
const [hoveringComponent, setHoveringComponent] = (0, import_react24.useState)();
|
4200
|
+
const [activeZones, setActiveZones] = (0, import_react24.useState)({});
|
4218
4201
|
const dispatch = useAppStore((s) => s.dispatch);
|
4219
|
-
const registerZone = (0,
|
4202
|
+
const registerZone = (0, import_react24.useCallback)(
|
4220
4203
|
(zoneCompound) => {
|
4221
4204
|
if (!dispatch) {
|
4222
4205
|
return;
|
@@ -4229,7 +4212,7 @@ var DropZoneProvider = ({
|
|
4229
4212
|
},
|
4230
4213
|
[setActiveZones, dispatch]
|
4231
4214
|
);
|
4232
|
-
const unregisterZone = (0,
|
4215
|
+
const unregisterZone = (0, import_react24.useCallback)(
|
4233
4216
|
(zoneCompound) => {
|
4234
4217
|
if (!dispatch) {
|
4235
4218
|
return;
|
@@ -4244,7 +4227,7 @@ var DropZoneProvider = ({
|
|
4244
4227
|
},
|
4245
4228
|
[setActiveZones, dispatch]
|
4246
4229
|
);
|
4247
|
-
const memoValue = (0,
|
4230
|
+
const memoValue = (0, import_react24.useMemo)(
|
4248
4231
|
() => __spreadValues({
|
4249
4232
|
hoveringComponent,
|
4250
4233
|
setHoveringComponent,
|
@@ -4259,11 +4242,11 @@ var DropZoneProvider = ({
|
|
4259
4242
|
|
4260
4243
|
// lib/use-context-store.ts
|
4261
4244
|
init_react_import();
|
4262
|
-
var
|
4245
|
+
var import_react25 = require("react");
|
4263
4246
|
var import_zustand4 = require("zustand");
|
4264
4247
|
var import_shallow = require("zustand/react/shallow");
|
4265
4248
|
function useContextStore(context, selector) {
|
4266
|
-
const store = (0,
|
4249
|
+
const store = (0, import_react25.useContext)(context);
|
4267
4250
|
if (!store) {
|
4268
4251
|
throw new Error("useContextStore must be used inside context");
|
4269
4252
|
}
|
@@ -4321,9 +4304,9 @@ var DraggableComponent = ({
|
|
4321
4304
|
);
|
4322
4305
|
const dispatch = useAppStore((s) => s.dispatch);
|
4323
4306
|
const iframe = useAppStore((s) => s.iframe);
|
4324
|
-
const ctx = (0,
|
4325
|
-
const [localZones, setLocalZones] = (0,
|
4326
|
-
const registerLocalZone = (0,
|
4307
|
+
const ctx = (0, import_react26.useContext)(dropZoneContext);
|
4308
|
+
const [localZones, setLocalZones] = (0, import_react26.useState)({});
|
4309
|
+
const registerLocalZone = (0, import_react26.useCallback)(
|
4327
4310
|
(zoneCompound2, active) => {
|
4328
4311
|
var _a;
|
4329
4312
|
(_a = ctx == null ? void 0 : ctx.registerLocalZone) == null ? void 0 : _a.call(ctx, zoneCompound2, active);
|
@@ -4333,7 +4316,7 @@ var DraggableComponent = ({
|
|
4333
4316
|
},
|
4334
4317
|
[setLocalZones]
|
4335
4318
|
);
|
4336
|
-
const unregisterLocalZone = (0,
|
4319
|
+
const unregisterLocalZone = (0, import_react26.useCallback)(
|
4337
4320
|
(zoneCompound2) => {
|
4338
4321
|
var _a;
|
4339
4322
|
(_a = ctx == null ? void 0 : ctx.unregisterLocalZone) == null ? void 0 : _a.call(ctx, zoneCompound2);
|
@@ -4363,7 +4346,7 @@ var DraggableComponent = ({
|
|
4363
4346
|
);
|
4364
4347
|
const canCollide = permissions.drag || userIsDragging;
|
4365
4348
|
const disabled = !isEnabled || !canCollide;
|
4366
|
-
const [dragAxis, setDragAxis] = (0,
|
4349
|
+
const [dragAxis, setDragAxis] = (0, import_react26.useState)(userDragAxis || autoDragAxis);
|
4367
4350
|
const { ref: sortableRef, status } = useSortableSafe({
|
4368
4351
|
id,
|
4369
4352
|
index,
|
@@ -4389,8 +4372,8 @@ var DraggableComponent = ({
|
|
4389
4372
|
}
|
4390
4373
|
});
|
4391
4374
|
const thisIsDragging = status === "dragging";
|
4392
|
-
const ref = (0,
|
4393
|
-
const refSetter = (0,
|
4375
|
+
const ref = (0, import_react26.useRef)(null);
|
4376
|
+
const refSetter = (0, import_react26.useCallback)(
|
4394
4377
|
(el) => {
|
4395
4378
|
sortableRef(el);
|
4396
4379
|
if (el) {
|
@@ -4399,14 +4382,14 @@ var DraggableComponent = ({
|
|
4399
4382
|
},
|
4400
4383
|
[sortableRef]
|
4401
4384
|
);
|
4402
|
-
const [portalEl, setPortalEl] = (0,
|
4403
|
-
(0,
|
4385
|
+
const [portalEl, setPortalEl] = (0, import_react26.useState)();
|
4386
|
+
(0, import_react26.useEffect)(() => {
|
4404
4387
|
var _a, _b, _c;
|
4405
4388
|
setPortalEl(
|
4406
4389
|
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
|
4407
4390
|
);
|
4408
4391
|
}, [iframe.enabled, ref.current]);
|
4409
|
-
const getStyle = (0,
|
4392
|
+
const getStyle = (0, import_react26.useCallback)(() => {
|
4410
4393
|
var _a, _b, _c;
|
4411
4394
|
if (!ref.current) return;
|
4412
4395
|
const rect = ref.current.getBoundingClientRect();
|
@@ -4426,11 +4409,11 @@ var DraggableComponent = ({
|
|
4426
4409
|
};
|
4427
4410
|
return style2;
|
4428
4411
|
}, [ref.current]);
|
4429
|
-
const [style, setStyle] = (0,
|
4430
|
-
const sync = (0,
|
4412
|
+
const [style, setStyle] = (0, import_react26.useState)();
|
4413
|
+
const sync = (0, import_react26.useCallback)(() => {
|
4431
4414
|
setStyle(getStyle());
|
4432
4415
|
}, [ref.current, iframe]);
|
4433
|
-
(0,
|
4416
|
+
(0, import_react26.useEffect)(() => {
|
4434
4417
|
if (ref.current && !userIsDragging) {
|
4435
4418
|
const observer = new ResizeObserver(sync);
|
4436
4419
|
observer.observe(ref.current);
|
@@ -4440,18 +4423,18 @@ var DraggableComponent = ({
|
|
4440
4423
|
}
|
4441
4424
|
}, [ref.current, userIsDragging]);
|
4442
4425
|
const registerNode = useAppStore((s) => s.nodes.registerNode);
|
4443
|
-
(0,
|
4426
|
+
(0, import_react26.useEffect)(() => {
|
4444
4427
|
var _a;
|
4445
4428
|
registerNode(id, { methods: { sync }, element: (_a = ref.current) != null ? _a : null });
|
4446
4429
|
return () => {
|
4447
4430
|
registerNode(id, { methods: { sync: () => null }, element: null });
|
4448
4431
|
};
|
4449
4432
|
}, [id, zoneCompound, index, componentType, sync]);
|
4450
|
-
const CustomActionBar = (0,
|
4433
|
+
const CustomActionBar = (0, import_react26.useMemo)(
|
4451
4434
|
() => overrides.actionBar || DefaultActionBar,
|
4452
4435
|
[overrides.actionBar]
|
4453
4436
|
);
|
4454
|
-
const onClick = (0,
|
4437
|
+
const onClick = (0, import_react26.useCallback)(
|
4455
4438
|
(e) => {
|
4456
4439
|
e.stopPropagation();
|
4457
4440
|
dispatch({
|
@@ -4464,7 +4447,7 @@ var DraggableComponent = ({
|
|
4464
4447
|
[index, zoneCompound, id]
|
4465
4448
|
);
|
4466
4449
|
const appStore = useAppStoreApi();
|
4467
|
-
const onSelectParent = (0,
|
4450
|
+
const onSelectParent = (0, import_react26.useCallback)(() => {
|
4468
4451
|
const { nodes } = appStore.getState().nodes;
|
4469
4452
|
const node = nodes[id];
|
4470
4453
|
const parentNode = (node == null ? void 0 : node.parentId) ? nodes[node == null ? void 0 : node.parentId] : null;
|
@@ -4481,23 +4464,23 @@ var DraggableComponent = ({
|
|
4481
4464
|
}
|
4482
4465
|
});
|
4483
4466
|
}, [ctx, path]);
|
4484
|
-
const onDuplicate = (0,
|
4467
|
+
const onDuplicate = (0, import_react26.useCallback)(() => {
|
4485
4468
|
dispatch({
|
4486
4469
|
type: "duplicate",
|
4487
4470
|
sourceIndex: index,
|
4488
4471
|
sourceZone: zoneCompound
|
4489
4472
|
});
|
4490
4473
|
}, [index, zoneCompound]);
|
4491
|
-
const onDelete = (0,
|
4474
|
+
const onDelete = (0, import_react26.useCallback)(() => {
|
4492
4475
|
dispatch({
|
4493
4476
|
type: "remove",
|
4494
4477
|
index,
|
4495
4478
|
zone: zoneCompound
|
4496
4479
|
});
|
4497
4480
|
}, [index, zoneCompound]);
|
4498
|
-
const [hover, setHover] = (0,
|
4481
|
+
const [hover, setHover] = (0, import_react26.useState)(false);
|
4499
4482
|
const indicativeHover = (ctx == null ? void 0 : ctx.hoveringComponent) === id;
|
4500
|
-
(0,
|
4483
|
+
(0, import_react26.useEffect)(() => {
|
4501
4484
|
if (!ref.current) {
|
4502
4485
|
return;
|
4503
4486
|
}
|
@@ -4547,7 +4530,7 @@ var DraggableComponent = ({
|
|
4547
4530
|
thisIsDragging,
|
4548
4531
|
inDroppableZone
|
4549
4532
|
]);
|
4550
|
-
(0,
|
4533
|
+
(0, import_react26.useEffect)(() => {
|
4551
4534
|
if (ref.current && disabled) {
|
4552
4535
|
ref.current.setAttribute("data-puck-disabled", "");
|
4553
4536
|
return () => {
|
@@ -4556,8 +4539,8 @@ var DraggableComponent = ({
|
|
4556
4539
|
};
|
4557
4540
|
}
|
4558
4541
|
}, [disabled, ref]);
|
4559
|
-
const [isVisible, setIsVisible] = (0,
|
4560
|
-
(0,
|
4542
|
+
const [isVisible, setIsVisible] = (0, import_react26.useState)(false);
|
4543
|
+
(0, import_react26.useEffect)(() => {
|
4561
4544
|
sync();
|
4562
4545
|
if ((isSelected || hover || indicativeHover) && !userIsDragging) {
|
4563
4546
|
setIsVisible(true);
|
@@ -4565,7 +4548,7 @@ var DraggableComponent = ({
|
|
4565
4548
|
setIsVisible(false);
|
4566
4549
|
}
|
4567
4550
|
}, [isSelected, hover, indicativeHover, iframe, userIsDragging]);
|
4568
|
-
const syncActionsPosition = (0,
|
4551
|
+
const syncActionsPosition = (0, import_react26.useCallback)(
|
4569
4552
|
(el) => {
|
4570
4553
|
if (el) {
|
4571
4554
|
const view = el.ownerDocument.defaultView;
|
@@ -4573,16 +4556,24 @@ var DraggableComponent = ({
|
|
4573
4556
|
const rect = el.getBoundingClientRect();
|
4574
4557
|
const diffLeft = rect.x;
|
4575
4558
|
const exceedsBoundsLeft = diffLeft < 0;
|
4559
|
+
const diffTop = rect.y;
|
4560
|
+
const exceedsBoundsTop = diffTop < 0;
|
4576
4561
|
if (exceedsBoundsLeft) {
|
4577
4562
|
el.style.transformOrigin = "left top";
|
4578
4563
|
el.style.left = "0px";
|
4579
4564
|
}
|
4565
|
+
if (exceedsBoundsTop) {
|
4566
|
+
el.style.top = "12px";
|
4567
|
+
if (!exceedsBoundsLeft) {
|
4568
|
+
el.style.transformOrigin = "right top";
|
4569
|
+
}
|
4570
|
+
}
|
4580
4571
|
}
|
4581
4572
|
}
|
4582
4573
|
},
|
4583
4574
|
[zoom]
|
4584
4575
|
);
|
4585
|
-
(0,
|
4576
|
+
(0, import_react26.useEffect)(() => {
|
4586
4577
|
if (userDragAxis) {
|
4587
4578
|
setDragAxis(userDragAxis);
|
4588
4579
|
return;
|
@@ -4675,15 +4666,15 @@ var styles_module_default12 = { "DropZone": "_DropZone_kmkdc_1", "DropZone--isAc
|
|
4675
4666
|
|
4676
4667
|
// components/DropZone/lib/use-min-empty-height.ts
|
4677
4668
|
init_react_import();
|
4678
|
-
var
|
4669
|
+
var import_react27 = require("react");
|
4679
4670
|
var useMinEmptyHeight = ({
|
4680
4671
|
zoneCompound,
|
4681
4672
|
userMinEmptyHeight,
|
4682
4673
|
ref
|
4683
4674
|
}) => {
|
4684
4675
|
const appStore = useAppStoreApi();
|
4685
|
-
const [prevHeight, setPrevHeight] = (0,
|
4686
|
-
const [isAnimating, setIsAnimating] = (0,
|
4676
|
+
const [prevHeight, setPrevHeight] = (0, import_react27.useState)(0);
|
4677
|
+
const [isAnimating, setIsAnimating] = (0, import_react27.useState)(false);
|
4687
4678
|
const { draggedItem, isZone } = useContextStore(ZoneStoreContext, (s) => {
|
4688
4679
|
var _a, _b;
|
4689
4680
|
return {
|
@@ -4691,7 +4682,7 @@ var useMinEmptyHeight = ({
|
|
4691
4682
|
isZone: ((_b = s.draggedItem) == null ? void 0 : _b.data.zone) === zoneCompound
|
4692
4683
|
};
|
4693
4684
|
});
|
4694
|
-
(0,
|
4685
|
+
(0, import_react27.useEffect)(() => {
|
4695
4686
|
if (draggedItem && ref.current) {
|
4696
4687
|
if (isZone) {
|
4697
4688
|
const rect = ref.current.getBoundingClientRect();
|
@@ -4729,15 +4720,15 @@ function assignRefs(refs, node) {
|
|
4729
4720
|
|
4730
4721
|
// components/DropZone/lib/use-content-with-preview.ts
|
4731
4722
|
init_react_import();
|
4732
|
-
var
|
4723
|
+
var import_react30 = require("react");
|
4733
4724
|
|
4734
4725
|
// lib/dnd/use-rendered-callback.ts
|
4735
4726
|
init_react_import();
|
4736
|
-
var
|
4737
|
-
var
|
4727
|
+
var import_react28 = require("@dnd-kit/react");
|
4728
|
+
var import_react29 = require("react");
|
4738
4729
|
function useRenderedCallback(callback, deps) {
|
4739
|
-
const manager = (0,
|
4740
|
-
return (0,
|
4730
|
+
const manager = (0, import_react28.useDragDropManager)();
|
4731
|
+
return (0, import_react29.useCallback)(
|
4741
4732
|
(...args) => __async(this, null, function* () {
|
4742
4733
|
yield manager == null ? void 0 : manager.renderer.rendering;
|
4743
4734
|
return callback(...args);
|
@@ -4760,8 +4751,8 @@ var useContentIdsWithPreview = (contentIds, zoneCompound) => {
|
|
4760
4751
|
}
|
4761
4752
|
);
|
4762
4753
|
const isDragging = useAppStore((s) => s.state.ui.isDragging);
|
4763
|
-
const [contentIdsWithPreview, setContentIdsWithPreview] = (0,
|
4764
|
-
const [localPreview, setLocalPreview] = (0,
|
4754
|
+
const [contentIdsWithPreview, setContentIdsWithPreview] = (0, import_react30.useState)(contentIds);
|
4755
|
+
const [localPreview, setLocalPreview] = (0, import_react30.useState)(
|
4765
4756
|
preview
|
4766
4757
|
);
|
4767
4758
|
const updateContent = useRenderedCallback(
|
@@ -4796,7 +4787,7 @@ var useContentIdsWithPreview = (contentIds, zoneCompound) => {
|
|
4796
4787
|
},
|
4797
4788
|
[draggedItemId, previewExists]
|
4798
4789
|
);
|
4799
|
-
(0,
|
4790
|
+
(0, import_react30.useEffect)(() => {
|
4800
4791
|
updateContent(contentIds, preview, isDragging);
|
4801
4792
|
}, [contentIds, preview, isDragging]);
|
4802
4793
|
return [contentIdsWithPreview, localPreview];
|
@@ -4804,16 +4795,16 @@ var useContentIdsWithPreview = (contentIds, zoneCompound) => {
|
|
4804
4795
|
|
4805
4796
|
// components/DropZone/lib/use-drag-axis.ts
|
4806
4797
|
init_react_import();
|
4807
|
-
var
|
4798
|
+
var import_react31 = require("react");
|
4808
4799
|
var GRID_DRAG_AXIS = "dynamic";
|
4809
4800
|
var FLEX_ROW_DRAG_AXIS = "x";
|
4810
4801
|
var DEFAULT_DRAG_AXIS = "y";
|
4811
4802
|
var useDragAxis = (ref, collisionAxis) => {
|
4812
4803
|
const status = useAppStore((s) => s.status);
|
4813
|
-
const [dragAxis, setDragAxis] = (0,
|
4804
|
+
const [dragAxis, setDragAxis] = (0, import_react31.useState)(
|
4814
4805
|
collisionAxis || DEFAULT_DRAG_AXIS
|
4815
4806
|
);
|
4816
|
-
const calculateDragAxis = (0,
|
4807
|
+
const calculateDragAxis = (0, import_react31.useCallback)(() => {
|
4817
4808
|
if (ref.current) {
|
4818
4809
|
const computedStyle = window.getComputedStyle(ref.current);
|
4819
4810
|
if (computedStyle.display === "grid") {
|
@@ -4825,7 +4816,7 @@ var useDragAxis = (ref, collisionAxis) => {
|
|
4825
4816
|
}
|
4826
4817
|
}
|
4827
4818
|
}, [ref.current]);
|
4828
|
-
(0,
|
4819
|
+
(0, import_react31.useEffect)(() => {
|
4829
4820
|
const onViewportChange = () => {
|
4830
4821
|
calculateDragAxis();
|
4831
4822
|
};
|
@@ -4834,7 +4825,7 @@ var useDragAxis = (ref, collisionAxis) => {
|
|
4834
4825
|
window.removeEventListener("viewportchange", onViewportChange);
|
4835
4826
|
};
|
4836
4827
|
}, []);
|
4837
|
-
(0,
|
4828
|
+
(0, import_react31.useEffect)(calculateDragAxis, [status, collisionAxis]);
|
4838
4829
|
return [dragAxis, calculateDragAxis];
|
4839
4830
|
};
|
4840
4831
|
|
@@ -4843,9 +4834,9 @@ var import_shallow3 = require("zustand/react/shallow");
|
|
4843
4834
|
|
4844
4835
|
// components/Render/index.tsx
|
4845
4836
|
init_react_import();
|
4846
|
-
var
|
4837
|
+
var import_react32 = __toESM(require("react"));
|
4847
4838
|
var import_jsx_runtime21 = require("react/jsx-runtime");
|
4848
|
-
var renderContext =
|
4839
|
+
var renderContext = import_react32.default.createContext({
|
4849
4840
|
config: { components: {} },
|
4850
4841
|
data: { root: {}, content: [] },
|
4851
4842
|
metadata: {}
|
@@ -4924,7 +4915,7 @@ var DropZoneChild = ({
|
|
4924
4915
|
dragRef: null,
|
4925
4916
|
metadata
|
4926
4917
|
};
|
4927
|
-
const ctx = (0,
|
4918
|
+
const ctx = (0, import_react33.useContext)(dropZoneContext);
|
4928
4919
|
const { depth } = ctx;
|
4929
4920
|
const contentItem = useAppStore(
|
4930
4921
|
(0, import_shallow3.useShallow)((s) => {
|
@@ -4953,7 +4944,7 @@ var DropZoneChild = ({
|
|
4953
4944
|
}
|
4954
4945
|
);
|
4955
4946
|
let label = (_b = (_a = componentConfig == null ? void 0 : componentConfig.label) != null ? _a : item == null ? void 0 : item.type.toString()) != null ? _b : "Component";
|
4956
|
-
const renderPreview = (0,
|
4947
|
+
const renderPreview = (0, import_react33.useMemo)(
|
4957
4948
|
() => function Preview4() {
|
4958
4949
|
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(DrawerItemInner, { name: label, children: overrides.componentItem });
|
4959
4950
|
},
|
@@ -5000,7 +4991,7 @@ var DropZoneChild = ({
|
|
5000
4991
|
}
|
5001
4992
|
);
|
5002
4993
|
};
|
5003
|
-
var DropZoneEdit = (0,
|
4994
|
+
var DropZoneEdit = (0, import_react33.forwardRef)(
|
5004
4995
|
function DropZoneEditInternal({
|
5005
4996
|
zone,
|
5006
4997
|
allow,
|
@@ -5010,7 +5001,7 @@ var DropZoneEdit = (0, import_react34.forwardRef)(
|
|
5010
5001
|
minEmptyHeight: userMinEmptyHeight = 128,
|
5011
5002
|
collisionAxis
|
5012
5003
|
}, userRef) {
|
5013
|
-
const ctx = (0,
|
5004
|
+
const ctx = (0, import_react33.useContext)(dropZoneContext);
|
5014
5005
|
const {
|
5015
5006
|
// These all need setting via context
|
5016
5007
|
areaId,
|
@@ -5047,7 +5038,7 @@ var DropZoneEdit = (0, import_react34.forwardRef)(
|
|
5047
5038
|
userIsDragging: !!s.draggedItem
|
5048
5039
|
};
|
5049
5040
|
});
|
5050
|
-
(0,
|
5041
|
+
(0, import_react33.useEffect)(() => {
|
5051
5042
|
if (ctx == null ? void 0 : ctx.registerZone) {
|
5052
5043
|
ctx == null ? void 0 : ctx.registerZone(zoneCompound);
|
5053
5044
|
}
|
@@ -5066,8 +5057,8 @@ var DropZoneEdit = (0, import_react34.forwardRef)(
|
|
5066
5057
|
return content.map(({ props }) => props.id);
|
5067
5058
|
})
|
5068
5059
|
);
|
5069
|
-
const ref = (0,
|
5070
|
-
const acceptsTarget = (0,
|
5060
|
+
const ref = (0, import_react33.useRef)(null);
|
5061
|
+
const acceptsTarget = (0, import_react33.useCallback)(
|
5071
5062
|
(componentType) => {
|
5072
5063
|
if (!componentType) {
|
5073
5064
|
return true;
|
@@ -5089,7 +5080,7 @@ var DropZoneEdit = (0, import_react34.forwardRef)(
|
|
5089
5080
|
},
|
5090
5081
|
[allow, disallow]
|
5091
5082
|
);
|
5092
|
-
(0,
|
5083
|
+
(0, import_react33.useEffect)(() => {
|
5093
5084
|
if (registerLocalZone) {
|
5094
5085
|
registerLocalZone(zoneCompound, acceptsTarget(draggedComponentType));
|
5095
5086
|
}
|
@@ -5179,14 +5170,14 @@ var DropZoneEdit = (0, import_react34.forwardRef)(
|
|
5179
5170
|
}
|
5180
5171
|
);
|
5181
5172
|
var DropZoneRenderPure = (props) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(DropZoneRender, __spreadValues({}, props));
|
5182
|
-
var DropZoneRender = (0,
|
5173
|
+
var DropZoneRender = (0, import_react33.forwardRef)(
|
5183
5174
|
function DropZoneRenderInternal({ className, style, zone }, ref) {
|
5184
|
-
const ctx = (0,
|
5175
|
+
const ctx = (0, import_react33.useContext)(dropZoneContext);
|
5185
5176
|
const { areaId = "root" } = ctx || {};
|
5186
|
-
const { config, data, metadata } = (0,
|
5177
|
+
const { config, data, metadata } = (0, import_react33.useContext)(renderContext);
|
5187
5178
|
let zoneCompound = rootDroppableId;
|
5188
5179
|
let content = (data == null ? void 0 : data.content) || [];
|
5189
|
-
(0,
|
5180
|
+
(0, import_react33.useEffect)(() => {
|
5190
5181
|
if (ctx == null ? void 0 : ctx.registerZone) {
|
5191
5182
|
ctx == null ? void 0 : ctx.registerZone(zoneCompound);
|
5192
5183
|
}
|
@@ -5231,9 +5222,9 @@ var DropZoneRender = (0, import_react34.forwardRef)(
|
|
5231
5222
|
}
|
5232
5223
|
);
|
5233
5224
|
var DropZonePure = (props) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(DropZone, __spreadValues({}, props));
|
5234
|
-
var DropZone = (0,
|
5225
|
+
var DropZone = (0, import_react33.forwardRef)(
|
5235
5226
|
function DropZone2(props, ref) {
|
5236
|
-
const ctx = (0,
|
5227
|
+
const ctx = (0, import_react33.useContext)(dropZoneContext);
|
5237
5228
|
if ((ctx == null ? void 0 : ctx.mode) === "edit") {
|
5238
5229
|
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_jsx_runtime22.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(DropZoneEdit, __spreadProps(__spreadValues({}, props), { ref })) });
|
5239
5230
|
}
|
@@ -5553,12 +5544,12 @@ function getDeepDir(el) {
|
|
5553
5544
|
// components/DragDropContext/index.tsx
|
5554
5545
|
var import_jsx_runtime23 = require("react/jsx-runtime");
|
5555
5546
|
var DEBUG3 = false;
|
5556
|
-
var dragListenerContext = (0,
|
5547
|
+
var dragListenerContext = (0, import_react35.createContext)({
|
5557
5548
|
dragListeners: {}
|
5558
5549
|
});
|
5559
5550
|
function useDragListener(type, fn, deps = []) {
|
5560
|
-
const { setDragListeners } = (0,
|
5561
|
-
(0,
|
5551
|
+
const { setDragListeners } = (0, import_react35.useContext)(dragListenerContext);
|
5552
|
+
(0, import_react35.useEffect)(() => {
|
5562
5553
|
if (setDragListeners) {
|
5563
5554
|
setDragListeners((old) => __spreadProps(__spreadValues({}, old), {
|
5564
5555
|
[type]: [...old[type] || [], fn]
|
@@ -5568,8 +5559,8 @@ function useDragListener(type, fn, deps = []) {
|
|
5568
5559
|
}
|
5569
5560
|
var AREA_CHANGE_DEBOUNCE_MS = 100;
|
5570
5561
|
var useTempDisableFallback = (timeout3) => {
|
5571
|
-
const lastFallbackDisable = (0,
|
5572
|
-
return (0,
|
5562
|
+
const lastFallbackDisable = (0, import_react35.useRef)(null);
|
5563
|
+
return (0, import_react35.useCallback)((manager) => {
|
5573
5564
|
collisionStore.setState({ fallbackEnabled: false });
|
5574
5565
|
const fallbackId = generateId();
|
5575
5566
|
lastFallbackDisable.current = fallbackId;
|
@@ -5590,10 +5581,10 @@ var DragDropContextClient = ({
|
|
5590
5581
|
const resolveData2 = useAppStore((s) => s.resolveData);
|
5591
5582
|
const metadata = useAppStore((s) => s.metadata);
|
5592
5583
|
const appStore = useAppStoreApi();
|
5593
|
-
const id = (
|
5594
|
-
const debouncedParamsRef = (0,
|
5584
|
+
const id = useSafeId();
|
5585
|
+
const debouncedParamsRef = (0, import_react35.useRef)(null);
|
5595
5586
|
const tempDisableFallback = useTempDisableFallback(100);
|
5596
|
-
const [zoneStore] = (0,
|
5587
|
+
const [zoneStore] = (0, import_react35.useState)(
|
5597
5588
|
() => (0, import_zustand5.createStore)(() => ({
|
5598
5589
|
zoneDepthIndex: {},
|
5599
5590
|
nextZoneDepthIndex: {},
|
@@ -5603,7 +5594,7 @@ var DragDropContextClient = ({
|
|
5603
5594
|
previewIndex: {}
|
5604
5595
|
}))
|
5605
5596
|
);
|
5606
|
-
const getChanged2 = (0,
|
5597
|
+
const getChanged2 = (0, import_react35.useCallback)(
|
5607
5598
|
(params, id2) => {
|
5608
5599
|
const { zoneDepthIndex = {}, areaDepthIndex = {} } = zoneStore.getState() || {};
|
5609
5600
|
const stateHasZone = Object.keys(zoneDepthIndex).length > 0;
|
@@ -5624,7 +5615,7 @@ var DragDropContextClient = ({
|
|
5624
5615
|
},
|
5625
5616
|
[zoneStore]
|
5626
5617
|
);
|
5627
|
-
const setDeepestAndCollide = (0,
|
5618
|
+
const setDeepestAndCollide = (0, import_react35.useCallback)(
|
5628
5619
|
(params, manager) => {
|
5629
5620
|
const { zoneChanged, areaChanged } = getChanged2(params, id);
|
5630
5621
|
if (!zoneChanged && !areaChanged) return;
|
@@ -5648,7 +5639,7 @@ var DragDropContextClient = ({
|
|
5648
5639
|
setDeepestDb.cancel();
|
5649
5640
|
debouncedParamsRef.current = null;
|
5650
5641
|
};
|
5651
|
-
(0,
|
5642
|
+
(0, import_react35.useEffect)(() => {
|
5652
5643
|
if (DEBUG3) {
|
5653
5644
|
zoneStore.subscribe(
|
5654
5645
|
(s) => {
|
@@ -5662,7 +5653,7 @@ var DragDropContextClient = ({
|
|
5662
5653
|
);
|
5663
5654
|
}
|
5664
5655
|
}, []);
|
5665
|
-
const [plugins] = (0,
|
5656
|
+
const [plugins] = (0, import_react35.useState)(() => [
|
5666
5657
|
...disableAutoScroll ? import_dom.defaultPreset.plugins.filter((plugin) => plugin !== import_dom.AutoScroller) : import_dom.defaultPreset.plugins,
|
5667
5658
|
createNestedDroppablePlugin(
|
5668
5659
|
{
|
@@ -5710,9 +5701,9 @@ var DragDropContextClient = ({
|
|
5710
5701
|
)
|
5711
5702
|
]);
|
5712
5703
|
const sensors = useSensors();
|
5713
|
-
const [dragListeners, setDragListeners] = (0,
|
5714
|
-
const dragMode = (0,
|
5715
|
-
const initialSelector = (0,
|
5704
|
+
const [dragListeners, setDragListeners] = (0, import_react35.useState)({});
|
5705
|
+
const dragMode = (0, import_react35.useRef)(null);
|
5706
|
+
const initialSelector = (0, import_react35.useRef)(void 0);
|
5716
5707
|
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { id, children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
5717
5708
|
dragListenerContext.Provider,
|
5718
5709
|
{
|
@@ -5721,7 +5712,7 @@ var DragDropContextClient = ({
|
|
5721
5712
|
setDragListeners
|
5722
5713
|
},
|
5723
5714
|
children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
5724
|
-
|
5715
|
+
import_react34.DragDropProvider,
|
5725
5716
|
{
|
5726
5717
|
plugins,
|
5727
5718
|
sensors,
|
@@ -5951,7 +5942,7 @@ var DrawerItemInner = ({
|
|
5951
5942
|
dragRef,
|
5952
5943
|
isDragDisabled
|
5953
5944
|
}) => {
|
5954
|
-
const CustomInner = (0,
|
5945
|
+
const CustomInner = (0, import_react36.useMemo)(
|
5955
5946
|
() => children || (({ children: children2 }) => /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: getClassNameItem2("default"), children: children2 })),
|
5956
5947
|
[children]
|
5957
5948
|
);
|
@@ -6005,7 +5996,7 @@ var DrawerItem = ({
|
|
6005
5996
|
isDragDisabled
|
6006
5997
|
}) => {
|
6007
5998
|
const resolvedId = id || name;
|
6008
|
-
const [dynamicId, setDynamicId] = (0,
|
5999
|
+
const [dynamicId, setDynamicId] = (0, import_react36.useState)(generateId(resolvedId));
|
6009
6000
|
if (typeof index !== "undefined") {
|
6010
6001
|
console.error(
|
6011
6002
|
"Warning: The `index` prop on Drawer.Item is deprecated and no longer required."
|
@@ -6044,7 +6035,7 @@ var Drawer = ({
|
|
6044
6035
|
"Warning: The `direction` prop on Drawer is deprecated and no longer required to achieve multi-directional dragging."
|
6045
6036
|
);
|
6046
6037
|
}
|
6047
|
-
const id = (
|
6038
|
+
const id = useSafeId();
|
6048
6039
|
const { ref } = useDroppableSafe({
|
6049
6040
|
id,
|
6050
6041
|
type: "void",
|
@@ -6066,7 +6057,7 @@ Drawer.Item = DrawerItem;
|
|
6066
6057
|
|
6067
6058
|
// components/Puck/index.tsx
|
6068
6059
|
init_react_import();
|
6069
|
-
var
|
6060
|
+
var import_react51 = require("react");
|
6070
6061
|
|
6071
6062
|
// components/SidebarSection/index.tsx
|
6072
6063
|
init_react_import();
|
@@ -6077,7 +6068,7 @@ var styles_module_default13 = { "SidebarSection": "_SidebarSection_8boj8_1", "Si
|
|
6077
6068
|
|
6078
6069
|
// lib/use-breadcrumbs.ts
|
6079
6070
|
init_react_import();
|
6080
|
-
var
|
6071
|
+
var import_react37 = require("react");
|
6081
6072
|
var useBreadcrumbs = (renderCount) => {
|
6082
6073
|
const selectedId = useAppStore((s) => {
|
6083
6074
|
var _a;
|
@@ -6089,7 +6080,7 @@ var useBreadcrumbs = (renderCount) => {
|
|
6089
6080
|
return (_a = s.nodes.nodes[selectedId]) == null ? void 0 : _a.path;
|
6090
6081
|
});
|
6091
6082
|
const appStore = useAppStoreApi();
|
6092
|
-
return (0,
|
6083
|
+
return (0, import_react37.useMemo)(() => {
|
6093
6084
|
const breadcrumbs = (path == null ? void 0 : path.map((zoneCompound) => {
|
6094
6085
|
var _a, _b;
|
6095
6086
|
const [componentId] = zoneCompound.split(":");
|
@@ -6214,7 +6205,7 @@ init_react_import();
|
|
6214
6205
|
var styles_module_default16 = { "PuckFields": "_PuckFields_10bh7_1", "PuckFields--isLoading": "_PuckFields--isLoading_10bh7_6", "PuckFields-loadingOverlay": "_PuckFields-loadingOverlay_10bh7_10", "PuckFields-loadingOverlayInner": "_PuckFields-loadingOverlayInner_10bh7_25", "PuckFields-field": "_PuckFields-field_10bh7_32", "PuckFields--wrapFields": "_PuckFields--wrapFields_10bh7_36" };
|
6215
6206
|
|
6216
6207
|
// components/Puck/components/Fields/index.tsx
|
6217
|
-
var
|
6208
|
+
var import_react38 = require("react");
|
6218
6209
|
var import_shallow4 = require("zustand/react/shallow");
|
6219
6210
|
var import_jsx_runtime27 = require("react/jsx-runtime");
|
6220
6211
|
var getClassName21 = get_class_name_factory_default("PuckFields", styles_module_default16);
|
@@ -6309,7 +6300,7 @@ var FieldsChild = ({ fieldName }) => {
|
|
6309
6300
|
})
|
6310
6301
|
);
|
6311
6302
|
const appStore = useAppStoreApi();
|
6312
|
-
const onChange = (0,
|
6303
|
+
const onChange = (0, import_react38.useCallback)(createOnChange(fieldName, appStore), [
|
6313
6304
|
fieldName
|
6314
6305
|
]);
|
6315
6306
|
if (!field || !id) return null;
|
@@ -6344,7 +6335,7 @@ var Fields = ({ wrapFields = true }) => {
|
|
6344
6335
|
(0, import_shallow4.useShallow)((s) => Object.keys(s.fields.fields))
|
6345
6336
|
);
|
6346
6337
|
const isLoading = fieldsLoading || componentResolving;
|
6347
|
-
const Wrapper = (0,
|
6338
|
+
const Wrapper = (0, import_react38.useMemo)(() => overrides.fields || DefaultFields, [overrides]);
|
6348
6339
|
return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
|
6349
6340
|
"form",
|
6350
6341
|
{
|
@@ -6365,7 +6356,7 @@ init_react_import();
|
|
6365
6356
|
|
6366
6357
|
// lib/use-component-list.tsx
|
6367
6358
|
init_react_import();
|
6368
|
-
var
|
6359
|
+
var import_react39 = require("react");
|
6369
6360
|
|
6370
6361
|
// components/ComponentList/index.tsx
|
6371
6362
|
init_react_import();
|
@@ -6436,10 +6427,10 @@ ComponentList.Item = ComponentListItem;
|
|
6436
6427
|
// lib/use-component-list.tsx
|
6437
6428
|
var import_jsx_runtime29 = require("react/jsx-runtime");
|
6438
6429
|
var useComponentList = () => {
|
6439
|
-
const [componentList, setComponentList] = (0,
|
6430
|
+
const [componentList, setComponentList] = (0, import_react39.useState)();
|
6440
6431
|
const config = useAppStore((s) => s.config);
|
6441
6432
|
const uiComponentList = useAppStore((s) => s.state.ui.componentList);
|
6442
|
-
(0,
|
6433
|
+
(0, import_react39.useEffect)(() => {
|
6443
6434
|
var _a, _b, _c;
|
6444
6435
|
if (Object.keys(uiComponentList).length > 0) {
|
6445
6436
|
const matchedComponents = [];
|
@@ -6508,22 +6499,22 @@ var useComponentList = () => {
|
|
6508
6499
|
};
|
6509
6500
|
|
6510
6501
|
// components/Puck/components/Components/index.tsx
|
6511
|
-
var
|
6502
|
+
var import_react40 = require("react");
|
6512
6503
|
var import_jsx_runtime30 = require("react/jsx-runtime");
|
6513
6504
|
var Components = () => {
|
6514
6505
|
const overrides = useAppStore((s) => s.overrides);
|
6515
6506
|
const componentList = useComponentList();
|
6516
|
-
const Wrapper = (0,
|
6507
|
+
const Wrapper = (0, import_react40.useMemo)(() => overrides.components || "div", [overrides]);
|
6517
6508
|
return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Wrapper, { children: componentList ? componentList : /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(ComponentList, { id: "all" }) });
|
6518
6509
|
};
|
6519
6510
|
|
6520
6511
|
// components/Puck/components/Preview/index.tsx
|
6521
6512
|
init_react_import();
|
6522
|
-
var
|
6513
|
+
var import_react42 = require("react");
|
6523
6514
|
|
6524
6515
|
// components/AutoFrame/index.tsx
|
6525
6516
|
init_react_import();
|
6526
|
-
var
|
6517
|
+
var import_react41 = require("react");
|
6527
6518
|
var import_object_hash = __toESM(require("object-hash"));
|
6528
6519
|
var import_react_dom3 = require("react-dom");
|
6529
6520
|
var import_jsx_runtime31 = require("react/jsx-runtime");
|
@@ -6569,7 +6560,7 @@ var CopyHostStyles = ({
|
|
6569
6560
|
onStylesLoaded = () => null
|
6570
6561
|
}) => {
|
6571
6562
|
const { document: doc, window: win } = useFrame();
|
6572
|
-
(0,
|
6563
|
+
(0, import_react41.useEffect)(() => {
|
6573
6564
|
if (!win || !doc) {
|
6574
6565
|
return () => {
|
6575
6566
|
};
|
@@ -6728,8 +6719,8 @@ var CopyHostStyles = ({
|
|
6728
6719
|
}, []);
|
6729
6720
|
return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_jsx_runtime31.Fragment, { children });
|
6730
6721
|
};
|
6731
|
-
var autoFrameContext = (0,
|
6732
|
-
var useFrame = () => (0,
|
6722
|
+
var autoFrameContext = (0, import_react41.createContext)({});
|
6723
|
+
var useFrame = () => (0, import_react41.useContext)(autoFrameContext);
|
6733
6724
|
function AutoFrame(_a) {
|
6734
6725
|
var _b = _a, {
|
6735
6726
|
children,
|
@@ -6750,11 +6741,11 @@ function AutoFrame(_a) {
|
|
6750
6741
|
"onNotReady",
|
6751
6742
|
"frameRef"
|
6752
6743
|
]);
|
6753
|
-
const [loaded, setLoaded] = (0,
|
6754
|
-
const [ctx, setCtx] = (0,
|
6755
|
-
const [mountTarget, setMountTarget] = (0,
|
6756
|
-
const [stylesLoaded, setStylesLoaded] = (0,
|
6757
|
-
(0,
|
6744
|
+
const [loaded, setLoaded] = (0, import_react41.useState)(false);
|
6745
|
+
const [ctx, setCtx] = (0, import_react41.useState)({});
|
6746
|
+
const [mountTarget, setMountTarget] = (0, import_react41.useState)();
|
6747
|
+
const [stylesLoaded, setStylesLoaded] = (0, import_react41.useState)(false);
|
6748
|
+
(0, import_react41.useEffect)(() => {
|
6758
6749
|
var _a2;
|
6759
6750
|
if (frameRef.current) {
|
6760
6751
|
const doc = frameRef.current.contentDocument;
|
@@ -6806,7 +6797,7 @@ var import_jsx_runtime32 = require("react/jsx-runtime");
|
|
6806
6797
|
var getClassName23 = get_class_name_factory_default("PuckPreview", styles_module_default18);
|
6807
6798
|
var useBubbleIframeEvents = (ref) => {
|
6808
6799
|
const status = useAppStore((s) => s.status);
|
6809
|
-
(0,
|
6800
|
+
(0, import_react42.useEffect)(() => {
|
6810
6801
|
if (ref.current && status === "READY") {
|
6811
6802
|
const iframe = ref.current;
|
6812
6803
|
const handlePointerMove = (event) => {
|
@@ -6855,7 +6846,7 @@ var Preview3 = ({ id = "puck-preview" }) => {
|
|
6855
6846
|
const renderData = useAppStore(
|
6856
6847
|
(s) => s.state.ui.previewMode === "edit" ? null : s.state.data
|
6857
6848
|
);
|
6858
|
-
const Page = (0,
|
6849
|
+
const Page = (0, import_react42.useCallback)(
|
6859
6850
|
(pageProps) => {
|
6860
6851
|
var _a, _b;
|
6861
6852
|
return ((_a = config.root) == null ? void 0 : _a.render) ? (_b = config.root) == null ? void 0 : _b.render(__spreadValues({
|
@@ -6864,9 +6855,9 @@ var Preview3 = ({ id = "puck-preview" }) => {
|
|
6864
6855
|
},
|
6865
6856
|
[config.root]
|
6866
6857
|
);
|
6867
|
-
const Frame = (0,
|
6858
|
+
const Frame = (0, import_react42.useMemo)(() => overrides.iframe, [overrides]);
|
6868
6859
|
const rootProps = root.props || root;
|
6869
|
-
const ref = (0,
|
6860
|
+
const ref = (0, import_react42.useRef)(null);
|
6870
6861
|
useBubbleIframeEvents(ref);
|
6871
6862
|
const inner = !renderData ? /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
6872
6863
|
Page,
|
@@ -6881,7 +6872,7 @@ var Preview3 = ({ id = "puck-preview" }) => {
|
|
6881
6872
|
children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(DropZonePure, { zone: rootDroppableId })
|
6882
6873
|
})
|
6883
6874
|
) : /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Render, { data: renderData, config });
|
6884
|
-
(0,
|
6875
|
+
(0, import_react42.useEffect)(() => {
|
6885
6876
|
if (!iframe.enabled) {
|
6886
6877
|
setStatus("READY");
|
6887
6878
|
}
|
@@ -6972,7 +6963,7 @@ var scrollIntoView = (el) => {
|
|
6972
6963
|
};
|
6973
6964
|
|
6974
6965
|
// components/LayerTree/index.tsx
|
6975
|
-
var
|
6966
|
+
var import_react43 = require("react");
|
6976
6967
|
|
6977
6968
|
// lib/on-scroll-end.ts
|
6978
6969
|
init_react_import();
|
@@ -7007,7 +6998,7 @@ var LayerTree = ({
|
|
7007
6998
|
label
|
7008
6999
|
}) => {
|
7009
7000
|
const zones = data.zones || {};
|
7010
|
-
const ctx = (0,
|
7001
|
+
const ctx = (0, import_react43.useContext)(dropZoneContext);
|
7011
7002
|
const nodes = useAppStore((s) => s.nodes.nodes);
|
7012
7003
|
return /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(import_jsx_runtime33.Fragment, { children: [
|
7013
7004
|
label && /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { className: getClassName24("zoneTitle"), children: [
|
@@ -7119,7 +7110,7 @@ var LayerTree = ({
|
|
7119
7110
|
};
|
7120
7111
|
|
7121
7112
|
// components/Puck/components/Outline/index.tsx
|
7122
|
-
var
|
7113
|
+
var import_react44 = require("react");
|
7123
7114
|
var import_jsx_runtime34 = require("react/jsx-runtime");
|
7124
7115
|
var Outline = () => {
|
7125
7116
|
const state = useAppStore((s) => s.state);
|
@@ -7128,7 +7119,7 @@ var Outline = () => {
|
|
7128
7119
|
const { data, ui } = state;
|
7129
7120
|
const { itemSelector } = ui;
|
7130
7121
|
const appStore = useAppStoreApi();
|
7131
|
-
const setItemSelector = (0,
|
7122
|
+
const setItemSelector = (0, import_react44.useCallback)(
|
7132
7123
|
(newItemSelector) => {
|
7133
7124
|
const { dispatch } = appStore.getState();
|
7134
7125
|
dispatch({
|
@@ -7138,7 +7129,7 @@ var Outline = () => {
|
|
7138
7129
|
},
|
7139
7130
|
[appStore]
|
7140
7131
|
);
|
7141
|
-
const Wrapper = (0,
|
7132
|
+
const Wrapper = (0, import_react44.useMemo)(() => outlineOverride || "div", [outlineOverride]);
|
7142
7133
|
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: [
|
7143
7134
|
(ctx == null ? void 0 : ctx.activeZones) && (ctx == null ? void 0 : ctx.activeZones[rootDroppableId]) && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
7144
7135
|
LayerTree,
|
@@ -7294,11 +7285,11 @@ var getBox = function getBox2(el) {
|
|
7294
7285
|
};
|
7295
7286
|
|
7296
7287
|
// components/Puck/components/Canvas/index.tsx
|
7297
|
-
var
|
7288
|
+
var import_react46 = require("react");
|
7298
7289
|
|
7299
7290
|
// components/ViewportControls/index.tsx
|
7300
7291
|
init_react_import();
|
7301
|
-
var
|
7292
|
+
var import_react45 = require("react");
|
7302
7293
|
|
7303
7294
|
// css-module:/home/runner/work/puck/puck/packages/core/components/ViewportControls/styles.module.css#css-module
|
7304
7295
|
init_react_import();
|
@@ -7321,8 +7312,8 @@ var ViewportButton = ({
|
|
7321
7312
|
onClick
|
7322
7313
|
}) => {
|
7323
7314
|
const viewports = useAppStore((s) => s.state.ui.viewports);
|
7324
|
-
const [isActive, setIsActive] = (0,
|
7325
|
-
(0,
|
7315
|
+
const [isActive, setIsActive] = (0, import_react45.useState)(false);
|
7316
|
+
(0, import_react45.useEffect)(() => {
|
7326
7317
|
setIsActive(width === viewports.current.width);
|
7327
7318
|
}, [width, viewports.current.width]);
|
7328
7319
|
return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("span", { className: getClassNameButton({ isActive }), children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
@@ -7358,7 +7349,7 @@ var ViewportControls = ({
|
|
7358
7349
|
const defaultsContainAutoZoom = defaultZoomOptions.find(
|
7359
7350
|
(option) => option.value === autoZoom
|
7360
7351
|
);
|
7361
|
-
const zoomOptions = (0,
|
7352
|
+
const zoomOptions = (0, import_react45.useMemo)(
|
7362
7353
|
() => [
|
7363
7354
|
...defaultZoomOptions,
|
7364
7355
|
...defaultsContainAutoZoom ? [] : [
|
@@ -7505,17 +7496,17 @@ var Canvas = () => {
|
|
7505
7496
|
viewports: s.state.ui.viewports
|
7506
7497
|
}))
|
7507
7498
|
);
|
7508
|
-
const frameRef = (0,
|
7509
|
-
const [showTransition, setShowTransition] = (0,
|
7510
|
-
const defaultRender = (0,
|
7499
|
+
const frameRef = (0, import_react46.useRef)(null);
|
7500
|
+
const [showTransition, setShowTransition] = (0, import_react46.useState)(false);
|
7501
|
+
const defaultRender = (0, import_react46.useMemo)(() => {
|
7511
7502
|
const PuckDefault = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_jsx_runtime36.Fragment, { children });
|
7512
7503
|
return PuckDefault;
|
7513
7504
|
}, []);
|
7514
|
-
const CustomPreview = (0,
|
7505
|
+
const CustomPreview = (0, import_react46.useMemo)(
|
7515
7506
|
() => overrides.preview || defaultRender,
|
7516
7507
|
[overrides]
|
7517
7508
|
);
|
7518
|
-
const getFrameDimensions = (0,
|
7509
|
+
const getFrameDimensions = (0, import_react46.useCallback)(() => {
|
7519
7510
|
if (frameRef.current) {
|
7520
7511
|
const frame = frameRef.current;
|
7521
7512
|
const box = getBox(frame);
|
@@ -7523,7 +7514,7 @@ var Canvas = () => {
|
|
7523
7514
|
}
|
7524
7515
|
return { width: 0, height: 0 };
|
7525
7516
|
}, [frameRef]);
|
7526
|
-
const resetAutoZoom = (0,
|
7517
|
+
const resetAutoZoom = (0, import_react46.useCallback)(
|
7527
7518
|
(newViewports = viewports) => {
|
7528
7519
|
if (frameRef.current) {
|
7529
7520
|
setZoomConfig(
|
@@ -7537,11 +7528,11 @@ var Canvas = () => {
|
|
7537
7528
|
},
|
7538
7529
|
[frameRef, zoomConfig, viewports]
|
7539
7530
|
);
|
7540
|
-
(0,
|
7531
|
+
(0, import_react46.useEffect)(() => {
|
7541
7532
|
setShowTransition(false);
|
7542
7533
|
resetAutoZoom(viewports);
|
7543
7534
|
}, [frameRef, leftSideBarVisible, rightSideBarVisible]);
|
7544
|
-
(0,
|
7535
|
+
(0, import_react46.useEffect)(() => {
|
7545
7536
|
const { height: frameHeight } = getFrameDimensions();
|
7546
7537
|
if (viewports.current.height === "auto") {
|
7547
7538
|
setZoomConfig(__spreadProps(__spreadValues({}, zoomConfig), {
|
@@ -7549,13 +7540,13 @@ var Canvas = () => {
|
|
7549
7540
|
}));
|
7550
7541
|
}
|
7551
7542
|
}, [zoomConfig.zoom]);
|
7552
|
-
(0,
|
7543
|
+
(0, import_react46.useEffect)(() => {
|
7553
7544
|
if (ZOOM_ON_CHANGE) {
|
7554
7545
|
setShowTransition(true);
|
7555
7546
|
resetAutoZoom(viewports);
|
7556
7547
|
}
|
7557
7548
|
}, [viewports.current.width]);
|
7558
|
-
(0,
|
7549
|
+
(0, import_react46.useEffect)(() => {
|
7559
7550
|
const cb = () => {
|
7560
7551
|
setShowTransition(false);
|
7561
7552
|
resetAutoZoom();
|
@@ -7565,8 +7556,8 @@ var Canvas = () => {
|
|
7565
7556
|
window.removeEventListener("resize", cb);
|
7566
7557
|
};
|
7567
7558
|
}, []);
|
7568
|
-
const [showLoader, setShowLoader] = (0,
|
7569
|
-
(0,
|
7559
|
+
const [showLoader, setShowLoader] = (0, import_react46.useState)(false);
|
7560
|
+
(0, import_react46.useEffect)(() => {
|
7570
7561
|
setTimeout(() => {
|
7571
7562
|
setShowLoader(true);
|
7572
7563
|
}, 500);
|
@@ -7644,7 +7635,7 @@ var Canvas = () => {
|
|
7644
7635
|
|
7645
7636
|
// lib/use-loaded-overrides.ts
|
7646
7637
|
init_react_import();
|
7647
|
-
var
|
7638
|
+
var import_react47 = require("react");
|
7648
7639
|
|
7649
7640
|
// lib/load-overrides.ts
|
7650
7641
|
init_react_import();
|
@@ -7683,7 +7674,7 @@ var useLoadedOverrides = ({
|
|
7683
7674
|
overrides,
|
7684
7675
|
plugins
|
7685
7676
|
}) => {
|
7686
|
-
return (0,
|
7677
|
+
return (0, import_react47.useMemo)(() => {
|
7687
7678
|
return loadOverrides({ overrides, plugins });
|
7688
7679
|
}, [plugins, overrides]);
|
7689
7680
|
};
|
@@ -7695,14 +7686,14 @@ var DefaultOverride = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime37
|
|
7695
7686
|
|
7696
7687
|
// lib/use-inject-css.ts
|
7697
7688
|
init_react_import();
|
7698
|
-
var
|
7689
|
+
var import_react48 = require("react");
|
7699
7690
|
var styles = ``;
|
7700
7691
|
var useInjectStyleSheet = (initialStyles, iframeEnabled) => {
|
7701
|
-
const [el, setEl] = (0,
|
7702
|
-
(0,
|
7692
|
+
const [el, setEl] = (0, import_react48.useState)();
|
7693
|
+
(0, import_react48.useEffect)(() => {
|
7703
7694
|
setEl(document.createElement("style"));
|
7704
7695
|
}, []);
|
7705
|
-
(0,
|
7696
|
+
(0, import_react48.useEffect)(() => {
|
7706
7697
|
var _a;
|
7707
7698
|
if (!el || typeof window === "undefined") {
|
7708
7699
|
return;
|
@@ -7722,10 +7713,10 @@ var useInjectGlobalCss = (iframeEnabled) => {
|
|
7722
7713
|
|
7723
7714
|
// lib/use-preview-mode-hotkeys.ts
|
7724
7715
|
init_react_import();
|
7725
|
-
var
|
7716
|
+
var import_react49 = require("react");
|
7726
7717
|
var usePreviewModeHotkeys = () => {
|
7727
7718
|
const appStore = useAppStoreApi();
|
7728
|
-
const toggleInteractive = (0,
|
7719
|
+
const toggleInteractive = (0, import_react49.useCallback)(() => {
|
7729
7720
|
const dispatch = appStore.getState().dispatch;
|
7730
7721
|
dispatch({
|
7731
7722
|
type: "setUi",
|
@@ -7740,7 +7731,7 @@ var usePreviewModeHotkeys = () => {
|
|
7740
7731
|
|
7741
7732
|
// lib/use-puck.ts
|
7742
7733
|
init_react_import();
|
7743
|
-
var
|
7734
|
+
var import_react50 = require("react");
|
7744
7735
|
var import_zustand6 = require("zustand");
|
7745
7736
|
var generateUsePuck = (store) => {
|
7746
7737
|
const history = {
|
@@ -7765,14 +7756,14 @@ var generateUsePuck = (store) => {
|
|
7765
7756
|
const get = () => storeData;
|
7766
7757
|
return __spreadProps(__spreadValues({}, storeData), { get });
|
7767
7758
|
};
|
7768
|
-
var UsePuckStoreContext = (0,
|
7759
|
+
var UsePuckStoreContext = (0, import_react50.createContext)(
|
7769
7760
|
null
|
7770
7761
|
);
|
7771
7762
|
var useRegisterUsePuckStore = (appStore) => {
|
7772
|
-
const [usePuckStore] = (0,
|
7763
|
+
const [usePuckStore] = (0, import_react50.useState)(
|
7773
7764
|
() => (0, import_zustand6.createStore)(() => generateUsePuck(appStore.getState()))
|
7774
7765
|
);
|
7775
|
-
(0,
|
7766
|
+
(0, import_react50.useEffect)(() => {
|
7776
7767
|
return appStore.subscribe(
|
7777
7768
|
(store) => {
|
7778
7769
|
const pickedStore = {
|
@@ -7794,7 +7785,7 @@ var useRegisterUsePuckStore = (appStore) => {
|
|
7794
7785
|
};
|
7795
7786
|
function createUsePuck() {
|
7796
7787
|
return function usePuck2(selector) {
|
7797
|
-
const usePuckApi = (0,
|
7788
|
+
const usePuckApi = (0, import_react50.useContext)(UsePuckStoreContext);
|
7798
7789
|
if (!usePuckApi) {
|
7799
7790
|
throw new Error("usePuck must be used inside <Puck>.");
|
7800
7791
|
}
|
@@ -7806,7 +7797,7 @@ function createUsePuck() {
|
|
7806
7797
|
};
|
7807
7798
|
}
|
7808
7799
|
function usePuck() {
|
7809
|
-
(0,
|
7800
|
+
(0, import_react50.useEffect)(() => {
|
7810
7801
|
console.warn(
|
7811
7802
|
"You're using the `usePuck` method without a selector, which may cause unnecessary re-renders. Replace with `createUsePuck` and provide a selector for improved performance."
|
7812
7803
|
);
|
@@ -7827,11 +7818,11 @@ var FieldSideBar = () => {
|
|
7827
7818
|
);
|
7828
7819
|
return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(SidebarSection, { noPadding: true, noBorderTop: true, showBreadcrumbs: true, title, children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(Fields, {}) });
|
7829
7820
|
};
|
7830
|
-
var propsContext = (0,
|
7821
|
+
var propsContext = (0, import_react51.createContext)({});
|
7831
7822
|
function PropsProvider(props) {
|
7832
7823
|
return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(propsContext.Provider, { value: props, children: props.children });
|
7833
7824
|
}
|
7834
|
-
var usePropsContext = () => (0,
|
7825
|
+
var usePropsContext = () => (0, import_react51.useContext)(propsContext);
|
7835
7826
|
function PuckProvider({ children }) {
|
7836
7827
|
const {
|
7837
7828
|
config,
|
@@ -7851,7 +7842,7 @@ function PuckProvider({ children }) {
|
|
7851
7842
|
enabled: true,
|
7852
7843
|
waitForStyles: true
|
7853
7844
|
}, _iframe);
|
7854
|
-
const [generatedAppState] = (0,
|
7845
|
+
const [generatedAppState] = (0, import_react51.useState)(() => {
|
7855
7846
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
7856
7847
|
const initial = __spreadValues(__spreadValues({}, defaultAppState.ui), initialUi);
|
7857
7848
|
let clientUiState = {};
|
@@ -7923,7 +7914,7 @@ function PuckProvider({ children }) {
|
|
7923
7914
|
overrides,
|
7924
7915
|
plugins
|
7925
7916
|
});
|
7926
|
-
const generateAppStore = (0,
|
7917
|
+
const generateAppStore = (0, import_react51.useCallback)(() => {
|
7927
7918
|
return {
|
7928
7919
|
state: initialAppState,
|
7929
7920
|
config,
|
@@ -7944,8 +7935,8 @@ function PuckProvider({ children }) {
|
|
7944
7935
|
onAction,
|
7945
7936
|
metadata
|
7946
7937
|
]);
|
7947
|
-
const [appStore] = (0,
|
7948
|
-
(0,
|
7938
|
+
const [appStore] = (0, import_react51.useState)(() => createAppStore(generateAppStore()));
|
7939
|
+
(0, import_react51.useEffect)(() => {
|
7949
7940
|
appStore.setState(__spreadValues({}, generateAppStore()));
|
7950
7941
|
}, [
|
7951
7942
|
initialAppState,
|
@@ -7962,7 +7953,7 @@ function PuckProvider({ children }) {
|
|
7962
7953
|
index: initialHistoryIndex,
|
7963
7954
|
initialAppState
|
7964
7955
|
});
|
7965
|
-
(0,
|
7956
|
+
(0, import_react51.useEffect)(() => {
|
7966
7957
|
appStore.subscribe((s) => {
|
7967
7958
|
if (onChange) onChange(s.state.data);
|
7968
7959
|
});
|
@@ -7970,7 +7961,7 @@ function PuckProvider({ children }) {
|
|
7970
7961
|
useRegisterNodesSlice(appStore);
|
7971
7962
|
useRegisterPermissionsSlice(appStore, permissions);
|
7972
7963
|
const uPuckStore = useRegisterUsePuckStore(appStore);
|
7973
|
-
(0,
|
7964
|
+
(0, import_react51.useEffect)(() => {
|
7974
7965
|
const { state, resolveData: resolveData2 } = appStore.getState();
|
7975
7966
|
resolveData2(state);
|
7976
7967
|
}, []);
|
@@ -7997,9 +7988,9 @@ function PuckLayout({ children }) {
|
|
7997
7988
|
const rightSideBarVisible = useAppStore(
|
7998
7989
|
(s) => s.state.ui.rightSideBarVisible
|
7999
7990
|
);
|
8000
|
-
const [menuOpen, setMenuOpen] = (0,
|
7991
|
+
const [menuOpen, setMenuOpen] = (0, import_react51.useState)(false);
|
8001
7992
|
const appStore = useAppStoreApi();
|
8002
|
-
(0,
|
7993
|
+
(0, import_react51.useEffect)(() => {
|
8003
7994
|
return appStore.subscribe((s) => {
|
8004
7995
|
if (onChange) onChange(s.state.data);
|
8005
7996
|
});
|
@@ -8008,7 +7999,7 @@ function PuckLayout({ children }) {
|
|
8008
7999
|
(s) => s.state.data.root.props || s.state.data.root.props
|
8009
8000
|
);
|
8010
8001
|
const dispatch = useAppStore((s) => s.dispatch);
|
8011
|
-
const toggleSidebars = (0,
|
8002
|
+
const toggleSidebars = (0, import_react51.useCallback)(
|
8012
8003
|
(sidebar) => {
|
8013
8004
|
const widerViewport = window.matchMedia("(min-width: 638px)").matches;
|
8014
8005
|
const sideBarVisible = sidebar === "left" ? leftSideBarVisible : rightSideBarVisible;
|
@@ -8022,7 +8013,7 @@ function PuckLayout({ children }) {
|
|
8022
8013
|
},
|
8023
8014
|
[dispatch, leftSideBarVisible, rightSideBarVisible]
|
8024
8015
|
);
|
8025
|
-
(0,
|
8016
|
+
(0, import_react51.useEffect)(() => {
|
8026
8017
|
if (!window.matchMedia("(min-width: 638px)").matches) {
|
8027
8018
|
dispatch({
|
8028
8019
|
type: "setUi",
|
@@ -8045,7 +8036,7 @@ function PuckLayout({ children }) {
|
|
8045
8036
|
window.removeEventListener("resize", handleResize);
|
8046
8037
|
};
|
8047
8038
|
}, []);
|
8048
|
-
const defaultHeaderRender = (0,
|
8039
|
+
const defaultHeaderRender = (0, import_react51.useMemo)(() => {
|
8049
8040
|
if (renderHeader) {
|
8050
8041
|
console.warn(
|
8051
8042
|
"`renderHeader` is deprecated. Please use `overrides.header` and the `usePuck` hook instead"
|
@@ -8060,7 +8051,7 @@ function PuckLayout({ children }) {
|
|
8060
8051
|
}
|
8061
8052
|
return DefaultOverride;
|
8062
8053
|
}, [renderHeader]);
|
8063
|
-
const defaultHeaderActionsRender = (0,
|
8054
|
+
const defaultHeaderActionsRender = (0, import_react51.useMemo)(() => {
|
8064
8055
|
if (renderHeaderActions) {
|
8065
8056
|
console.warn(
|
8066
8057
|
"`renderHeaderActions` is deprecated. Please use `overrides.headerActions` and the `usePuck` hook instead."
|
@@ -8075,25 +8066,25 @@ function PuckLayout({ children }) {
|
|
8075
8066
|
return DefaultOverride;
|
8076
8067
|
}, [renderHeader]);
|
8077
8068
|
const overrides = useAppStore((s) => s.overrides);
|
8078
|
-
const CustomPuck = (0,
|
8069
|
+
const CustomPuck = (0, import_react51.useMemo)(
|
8079
8070
|
() => overrides.puck || DefaultOverride,
|
8080
8071
|
[overrides]
|
8081
8072
|
);
|
8082
|
-
const CustomHeader = (0,
|
8073
|
+
const CustomHeader = (0, import_react51.useMemo)(
|
8083
8074
|
() => overrides.header || defaultHeaderRender,
|
8084
8075
|
[overrides]
|
8085
8076
|
);
|
8086
|
-
const CustomHeaderActions = (0,
|
8077
|
+
const CustomHeaderActions = (0, import_react51.useMemo)(
|
8087
8078
|
() => overrides.headerActions || defaultHeaderActionsRender,
|
8088
8079
|
[overrides]
|
8089
8080
|
);
|
8090
|
-
const [mounted, setMounted] = (0,
|
8091
|
-
(0,
|
8081
|
+
const [mounted, setMounted] = (0, import_react51.useState)(false);
|
8082
|
+
(0, import_react51.useEffect)(() => {
|
8092
8083
|
setMounted(true);
|
8093
8084
|
}, []);
|
8094
8085
|
const ready = useAppStore((s) => s.status === "READY");
|
8095
8086
|
useMonitorHotkeys();
|
8096
|
-
(0,
|
8087
|
+
(0, import_react51.useEffect)(() => {
|
8097
8088
|
if (ready && iframe.enabled) {
|
8098
8089
|
const frameDoc = getFrame();
|
8099
8090
|
if (frameDoc) {
|