@measured/puck 0.19.0-canary.020071e → 0.19.0-canary.0308d24
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/index.css +13 -0
- package/dist/index.js +391 -403
- package/dist/index.mjs +231 -243
- package/package.json +1 -1
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();
|
@@ -2759,16 +2758,13 @@ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input
|
|
2759
2758
|
};
|
2760
2759
|
|
2761
2760
|
// components/Sortable/index.tsx
|
2762
|
-
var import_modifiers = require("@dnd-kit/dom/modifiers");
|
2763
2761
|
var import_jsx_runtime5 = require("react/jsx-runtime");
|
2764
2762
|
var SortableProvider = ({
|
2765
|
-
container,
|
2766
2763
|
children,
|
2767
2764
|
onDragStart,
|
2768
2765
|
onDragEnd,
|
2769
2766
|
onMove
|
2770
2767
|
}) => {
|
2771
|
-
const [move, setMove] = (0, import_react14.useState)({ source: -1, target: -1 });
|
2772
2768
|
const sensors = useSensors({
|
2773
2769
|
mouse: { distance: { value: 5 } }
|
2774
2770
|
});
|
@@ -2776,16 +2772,13 @@ var SortableProvider = ({
|
|
2776
2772
|
import_react13.DragDropProvider,
|
2777
2773
|
{
|
2778
2774
|
sensors,
|
2779
|
-
|
2780
|
-
|
2781
|
-
|
2782
|
-
|
2783
|
-
}
|
2784
|
-
})
|
2785
|
-
],
|
2786
|
-
onDragStart,
|
2775
|
+
onDragStart: (event) => {
|
2776
|
+
var _a, _b;
|
2777
|
+
return onDragStart((_b = (_a = event.operation.source) == null ? void 0 : _a.id.toString()) != null ? _b : "");
|
2778
|
+
},
|
2787
2779
|
onDragOver: (event, manager) => {
|
2788
2780
|
var _a, _b;
|
2781
|
+
event.preventDefault();
|
2789
2782
|
const { operation } = event;
|
2790
2783
|
const { source, target } = operation;
|
2791
2784
|
if (!source || !target) return;
|
@@ -2793,14 +2786,14 @@ var SortableProvider = ({
|
|
2793
2786
|
let targetIndex = target.data.index;
|
2794
2787
|
const collisionData = (_b = (_a = manager.dragOperation.data) == null ? void 0 : _a.collisionMap) == null ? void 0 : _b[target.id];
|
2795
2788
|
if (sourceIndex !== targetIndex && source.id !== target.id) {
|
2796
|
-
const collisionPosition =
|
2789
|
+
const collisionPosition = collisionData.direction === "up" ? "before" : "after";
|
2797
2790
|
if (targetIndex >= sourceIndex) {
|
2798
2791
|
targetIndex = targetIndex - 1;
|
2799
2792
|
}
|
2800
2793
|
if (collisionPosition === "after") {
|
2801
2794
|
targetIndex = targetIndex + 1;
|
2802
2795
|
}
|
2803
|
-
|
2796
|
+
onMove({
|
2804
2797
|
source: sourceIndex,
|
2805
2798
|
target: targetIndex
|
2806
2799
|
});
|
@@ -2808,12 +2801,8 @@ var SortableProvider = ({
|
|
2808
2801
|
},
|
2809
2802
|
onDragEnd: () => {
|
2810
2803
|
setTimeout(() => {
|
2811
|
-
if (move.source !== -1 && move.target !== -1) {
|
2812
|
-
onMove(move);
|
2813
|
-
}
|
2814
2804
|
onDragEnd();
|
2815
2805
|
}, 250);
|
2816
|
-
setMove({ source: -1, target: -1 });
|
2817
2806
|
},
|
2818
2807
|
children
|
2819
2808
|
}
|
@@ -2843,11 +2832,11 @@ var Sortable = ({
|
|
2843
2832
|
|
2844
2833
|
// components/AutoField/context.tsx
|
2845
2834
|
init_react_import();
|
2846
|
-
var
|
2835
|
+
var import_react14 = require("react");
|
2847
2836
|
var import_jsx_runtime6 = require("react/jsx-runtime");
|
2848
|
-
var NestedFieldContext = (0,
|
2837
|
+
var NestedFieldContext = (0, import_react14.createContext)({});
|
2849
2838
|
var useNestedFieldContext = () => {
|
2850
|
-
const context = (0,
|
2839
|
+
const context = (0, import_react14.useContext)(NestedFieldContext);
|
2851
2840
|
return __spreadProps(__spreadValues({}, context), {
|
2852
2841
|
readOnlyFields: context.readOnlyFields || {}
|
2853
2842
|
});
|
@@ -2861,7 +2850,7 @@ var NestedFieldProvider = ({
|
|
2861
2850
|
}) => {
|
2862
2851
|
const subPath = `${name}.${subName}`;
|
2863
2852
|
const wildcardSubPath = `${wildcardName}.${subName}`;
|
2864
|
-
const subReadOnlyFields = (0,
|
2853
|
+
const subReadOnlyFields = (0, import_react14.useMemo)(
|
2865
2854
|
() => Object.keys(readOnlyFields).reduce((acc, readOnlyKey) => {
|
2866
2855
|
const isLocal = readOnlyKey.indexOf(subPath) > -1 || readOnlyKey.indexOf(wildcardSubPath) > -1;
|
2867
2856
|
if (isLocal) {
|
@@ -2914,12 +2903,14 @@ var ArrayField = ({
|
|
2914
2903
|
}),
|
2915
2904
|
openId: ""
|
2916
2905
|
};
|
2917
|
-
const [localState, setLocalState] = (0,
|
2918
|
-
(0,
|
2919
|
-
|
2920
|
-
|
2906
|
+
const [localState, setLocalState] = (0, import_react15.useState)({ arrayState, value });
|
2907
|
+
(0, import_react15.useEffect)(() => {
|
2908
|
+
var _a;
|
2909
|
+
const _arrayState = (_a = appStore.getState().state.ui.arrayState[id]) != null ? _a : arrayState;
|
2910
|
+
setLocalState({ arrayState: _arrayState, value });
|
2911
|
+
}, [value]);
|
2921
2912
|
const appStore = useAppStoreApi();
|
2922
|
-
const mapArrayStateToUi = (0,
|
2913
|
+
const mapArrayStateToUi = (0, import_react15.useCallback)(
|
2923
2914
|
(partialArrayState) => {
|
2924
2915
|
const state = appStore.getState().state;
|
2925
2916
|
return {
|
@@ -2930,13 +2921,13 @@ var ArrayField = ({
|
|
2930
2921
|
},
|
2931
2922
|
[arrayState, appStore]
|
2932
2923
|
);
|
2933
|
-
const getHighestIndex = (0,
|
2924
|
+
const getHighestIndex = (0, import_react15.useCallback)(() => {
|
2934
2925
|
return arrayState.items.reduce(
|
2935
2926
|
(acc, item) => item._originalIndex > acc ? item._originalIndex : acc,
|
2936
2927
|
-1
|
2937
2928
|
);
|
2938
2929
|
}, [arrayState]);
|
2939
|
-
const regenerateArrayState = (0,
|
2930
|
+
const regenerateArrayState = (0, import_react15.useCallback)(
|
2940
2931
|
(value2) => {
|
2941
2932
|
let highestIndex = getHighestIndex();
|
2942
2933
|
const newItems = Array.from(value2 || []).map((item, idx) => {
|
@@ -2955,13 +2946,13 @@ var ArrayField = ({
|
|
2955
2946
|
},
|
2956
2947
|
[arrayState]
|
2957
2948
|
);
|
2958
|
-
(0,
|
2949
|
+
(0, import_react15.useEffect)(() => {
|
2959
2950
|
if (arrayState.items.length > 0) {
|
2960
2951
|
setUi(mapArrayStateToUi(arrayState));
|
2961
2952
|
}
|
2962
2953
|
}, []);
|
2963
|
-
const [
|
2964
|
-
const
|
2954
|
+
const [draggedItem, setDraggedItem] = (0, import_react15.useState)("");
|
2955
|
+
const isDragging = !!draggedItem;
|
2965
2956
|
const canEdit = useAppStore(
|
2966
2957
|
(s) => s.permissions.getPermissions({ item: s.selectedItem }).edit
|
2967
2958
|
);
|
@@ -2980,11 +2971,16 @@ var ArrayField = ({
|
|
2980
2971
|
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
2981
2972
|
SortableProvider,
|
2982
2973
|
{
|
2983
|
-
|
2984
|
-
|
2985
|
-
|
2974
|
+
onDragStart: (id2) => setDraggedItem(id2),
|
2975
|
+
onDragEnd: () => {
|
2976
|
+
setDraggedItem("");
|
2977
|
+
onChange(localState.value);
|
2978
|
+
},
|
2986
2979
|
onMove: (move) => {
|
2987
|
-
|
2980
|
+
if (arrayState.items[move.source]._arrayId !== draggedItem) {
|
2981
|
+
return;
|
2982
|
+
}
|
2983
|
+
const newValue = reorder(localState.value, move.source, move.target);
|
2988
2984
|
const newArrayStateItems = reorder(
|
2989
2985
|
arrayState.items,
|
2990
2986
|
move.source,
|
@@ -2997,7 +2993,6 @@ var ArrayField = ({
|
|
2997
2993
|
})
|
2998
2994
|
};
|
2999
2995
|
setUi(newUi, false);
|
3000
|
-
onChange(newValue, newUi);
|
3001
2996
|
setLocalState({
|
3002
2997
|
value: newValue,
|
3003
2998
|
arrayState: __spreadProps(__spreadValues({}, arrayState), { items: newArrayStateItems })
|
@@ -3011,164 +3006,156 @@ var ArrayField = ({
|
|
3011
3006
|
addDisabled
|
3012
3007
|
}),
|
3013
3008
|
children: [
|
3014
|
-
localState.arrayState.items.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
3015
|
-
|
3016
|
-
{
|
3017
|
-
|
3018
|
-
|
3019
|
-
|
3020
|
-
|
3021
|
-
|
3022
|
-
|
3023
|
-
|
3024
|
-
|
3009
|
+
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) => {
|
3010
|
+
const { _arrayId = `${id}-${i}`, _originalIndex = i } = item;
|
3011
|
+
const data = Array.from(localState.value || [])[i] || {};
|
3012
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
3013
|
+
Sortable,
|
3014
|
+
{
|
3015
|
+
id: _arrayId,
|
3016
|
+
index: i,
|
3017
|
+
disabled: readOnly,
|
3018
|
+
children: ({ status, ref, handleRef }) => /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
3019
|
+
"div",
|
3025
3020
|
{
|
3026
|
-
|
3027
|
-
|
3028
|
-
|
3029
|
-
|
3030
|
-
|
3031
|
-
|
3032
|
-
|
3033
|
-
|
3034
|
-
|
3035
|
-
|
3036
|
-
|
3037
|
-
|
3038
|
-
|
3039
|
-
|
3040
|
-
|
3041
|
-
{
|
3042
|
-
|
3043
|
-
|
3044
|
-
|
3045
|
-
|
3046
|
-
|
3047
|
-
|
3048
|
-
|
3049
|
-
|
3050
|
-
|
3051
|
-
|
3052
|
-
|
3053
|
-
} else {
|
3054
|
-
setUi(
|
3055
|
-
mapArrayStateToUi({
|
3056
|
-
openId: _arrayId
|
3057
|
-
})
|
3058
|
-
);
|
3059
|
-
}
|
3060
|
-
},
|
3061
|
-
className: getClassNameItem("summary"),
|
3062
|
-
children: [
|
3063
|
-
field.getItemSummary ? field.getItemSummary(data, i) : `Item #${_originalIndex}`,
|
3064
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: getClassNameItem("rhs"), children: [
|
3065
|
-
!readOnly && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: getClassNameItem("actions"), children: [
|
3066
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: getClassNameItem("action"), children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
3067
|
-
IconButton,
|
3068
|
-
{
|
3069
|
-
type: "button",
|
3070
|
-
disabled: !!addDisabled,
|
3071
|
-
onClick: (e) => {
|
3072
|
-
e.stopPropagation();
|
3073
|
-
const existingValue = [...value || []];
|
3074
|
-
existingValue.splice(
|
3075
|
-
i,
|
3076
|
-
0,
|
3077
|
-
existingValue[i]
|
3078
|
-
);
|
3079
|
-
onChange(
|
3080
|
-
existingValue,
|
3081
|
-
mapArrayStateToUi(
|
3082
|
-
regenerateArrayState(existingValue)
|
3083
|
-
)
|
3084
|
-
);
|
3085
|
-
},
|
3086
|
-
title: "Duplicate",
|
3087
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Copy, { size: 16 })
|
3088
|
-
}
|
3089
|
-
) }),
|
3090
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: getClassNameItem("action"), children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
3091
|
-
IconButton,
|
3092
|
-
{
|
3093
|
-
type: "button",
|
3094
|
-
disabled: field.min !== void 0 && field.min >= localState.arrayState.items.length,
|
3095
|
-
onClick: (e) => {
|
3096
|
-
e.stopPropagation();
|
3097
|
-
const existingValue = [...value || []];
|
3098
|
-
const existingItems = [
|
3099
|
-
...arrayState.items || []
|
3100
|
-
];
|
3101
|
-
existingValue.splice(i, 1);
|
3102
|
-
existingItems.splice(i, 1);
|
3103
|
-
onChange(
|
3104
|
-
existingValue,
|
3105
|
-
mapArrayStateToUi({
|
3106
|
-
items: existingItems
|
3107
|
-
})
|
3108
|
-
);
|
3109
|
-
},
|
3110
|
-
title: "Delete",
|
3111
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Trash, { size: 16 })
|
3112
|
-
}
|
3113
|
-
) })
|
3114
|
-
] }),
|
3115
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(DragIcon, {}) })
|
3116
|
-
] })
|
3117
|
-
]
|
3021
|
+
ref,
|
3022
|
+
className: getClassNameItem({
|
3023
|
+
isExpanded: arrayState.openId === _arrayId,
|
3024
|
+
isDragging: status === "dragging",
|
3025
|
+
readOnly
|
3026
|
+
}),
|
3027
|
+
children: [
|
3028
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
3029
|
+
"div",
|
3030
|
+
{
|
3031
|
+
ref: handleRef,
|
3032
|
+
onClick: (e) => {
|
3033
|
+
if (isDragging) return;
|
3034
|
+
e.preventDefault();
|
3035
|
+
e.stopPropagation();
|
3036
|
+
if (arrayState.openId === _arrayId) {
|
3037
|
+
setUi(
|
3038
|
+
mapArrayStateToUi({
|
3039
|
+
openId: ""
|
3040
|
+
})
|
3041
|
+
);
|
3042
|
+
} else {
|
3043
|
+
setUi(
|
3044
|
+
mapArrayStateToUi({
|
3045
|
+
openId: _arrayId
|
3046
|
+
})
|
3047
|
+
);
|
3118
3048
|
}
|
3119
|
-
|
3120
|
-
|
3121
|
-
|
3122
|
-
|
3123
|
-
|
3124
|
-
|
3125
|
-
|
3126
|
-
|
3127
|
-
const localWildcardSubPath = `${localWildcardName}.${subName}`;
|
3128
|
-
const subReadOnly = forceReadOnly ? forceReadOnly : typeof readOnlyFields[subPath] !== "undefined" ? readOnlyFields[localSubPath] : readOnlyFields[localWildcardSubPath];
|
3129
|
-
const label2 = subField.label || subName;
|
3130
|
-
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
3131
|
-
NestedFieldProvider,
|
3132
|
-
{
|
3133
|
-
name: localIndexName,
|
3134
|
-
wildcardName: localWildcardName,
|
3135
|
-
subName,
|
3136
|
-
readOnlyFields,
|
3137
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
3138
|
-
AutoFieldPrivate,
|
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,
|
3139
3057
|
{
|
3140
|
-
|
3141
|
-
|
3142
|
-
|
3143
|
-
|
3144
|
-
|
3145
|
-
|
3146
|
-
|
3147
|
-
|
3148
|
-
|
3149
|
-
onChange: (val, ui) => {
|
3150
|
-
onChange(
|
3151
|
-
replace(value, i, __spreadProps(__spreadValues({}, data), {
|
3152
|
-
[subName]: val
|
3153
|
-
})),
|
3154
|
-
ui
|
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]
|
3155
3067
|
);
|
3156
|
-
|
3068
|
+
const newUi = mapArrayStateToUi(
|
3069
|
+
regenerateArrayState(existingValue)
|
3070
|
+
);
|
3071
|
+
setUi(newUi, false);
|
3072
|
+
onChange(existingValue);
|
3073
|
+
},
|
3074
|
+
title: "Duplicate",
|
3075
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Copy, { size: 16 })
|
3157
3076
|
}
|
3158
|
-
)
|
3159
|
-
|
3160
|
-
|
3161
|
-
|
3162
|
-
|
3163
|
-
|
3164
|
-
|
3165
|
-
|
3166
|
-
|
3167
|
-
|
3168
|
-
|
3169
|
-
|
3170
|
-
|
3171
|
-
|
3077
|
+
) }),
|
3078
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: getClassNameItem("action"), children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
3079
|
+
IconButton,
|
3080
|
+
{
|
3081
|
+
type: "button",
|
3082
|
+
disabled: field.min !== void 0 && field.min >= localState.arrayState.items.length,
|
3083
|
+
onClick: (e) => {
|
3084
|
+
e.stopPropagation();
|
3085
|
+
const existingValue = [...value || []];
|
3086
|
+
const existingItems = [
|
3087
|
+
...arrayState.items || []
|
3088
|
+
];
|
3089
|
+
existingValue.splice(i, 1);
|
3090
|
+
existingItems.splice(i, 1);
|
3091
|
+
setUi(
|
3092
|
+
mapArrayStateToUi({
|
3093
|
+
items: existingItems
|
3094
|
+
}),
|
3095
|
+
false
|
3096
|
+
);
|
3097
|
+
onChange(existingValue);
|
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
|
+
]
|
3107
|
+
}
|
3108
|
+
),
|
3109
|
+
/* @__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) => {
|
3110
|
+
const subField = field.arrayFields[subName];
|
3111
|
+
const indexName = `${name}[${i}]`;
|
3112
|
+
const subPath = `${indexName}.${subName}`;
|
3113
|
+
const localIndexName = `${localName}[${i}]`;
|
3114
|
+
const localWildcardName = `${localName}[*]`;
|
3115
|
+
const localSubPath = `${localIndexName}.${subName}`;
|
3116
|
+
const localWildcardSubPath = `${localWildcardName}.${subName}`;
|
3117
|
+
const subReadOnly = forceReadOnly ? forceReadOnly : typeof readOnlyFields[subPath] !== "undefined" ? readOnlyFields[localSubPath] : readOnlyFields[localWildcardSubPath];
|
3118
|
+
const label2 = subField.label || subName;
|
3119
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
3120
|
+
NestedFieldProvider,
|
3121
|
+
{
|
3122
|
+
name: localIndexName,
|
3123
|
+
wildcardName: localWildcardName,
|
3124
|
+
subName,
|
3125
|
+
readOnlyFields,
|
3126
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
3127
|
+
AutoFieldPrivate,
|
3128
|
+
{
|
3129
|
+
name: subPath,
|
3130
|
+
label: label2,
|
3131
|
+
id: `${_arrayId}_${subName}`,
|
3132
|
+
readOnly: subReadOnly,
|
3133
|
+
field: __spreadProps(__spreadValues({}, subField), {
|
3134
|
+
label: label2
|
3135
|
+
// May be used by custom fields
|
3136
|
+
}),
|
3137
|
+
value: data[subName],
|
3138
|
+
onChange: (val, ui) => {
|
3139
|
+
onChange(
|
3140
|
+
replace(value, i, __spreadProps(__spreadValues({}, data), {
|
3141
|
+
[subName]: val
|
3142
|
+
})),
|
3143
|
+
ui
|
3144
|
+
);
|
3145
|
+
}
|
3146
|
+
}
|
3147
|
+
)
|
3148
|
+
},
|
3149
|
+
subPath
|
3150
|
+
);
|
3151
|
+
}) }) })
|
3152
|
+
]
|
3153
|
+
}
|
3154
|
+
)
|
3155
|
+
},
|
3156
|
+
_arrayId
|
3157
|
+
);
|
3158
|
+
}) }),
|
3172
3159
|
!addDisabled && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
3173
3160
|
"button",
|
3174
3161
|
{
|
@@ -3182,7 +3169,8 @@ var ArrayField = ({
|
|
3182
3169
|
field.defaultItemProps || {}
|
3183
3170
|
];
|
3184
3171
|
const newArrayState = regenerateArrayState(newValue);
|
3185
|
-
|
3172
|
+
setUi(mapArrayStateToUi(newArrayState), false);
|
3173
|
+
onChange(newValue);
|
3186
3174
|
},
|
3187
3175
|
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Plus, { size: 21 })
|
3188
3176
|
}
|
@@ -3259,11 +3247,11 @@ var DefaultField = ({
|
|
3259
3247
|
|
3260
3248
|
// components/AutoField/fields/ExternalField/index.tsx
|
3261
3249
|
init_react_import();
|
3262
|
-
var
|
3250
|
+
var import_react19 = require("react");
|
3263
3251
|
|
3264
3252
|
// components/ExternalInput/index.tsx
|
3265
3253
|
init_react_import();
|
3266
|
-
var
|
3254
|
+
var import_react18 = require("react");
|
3267
3255
|
|
3268
3256
|
// css-module:/home/runner/work/puck/puck/packages/core/components/ExternalInput/styles.module.css#css-module
|
3269
3257
|
init_react_import();
|
@@ -3271,7 +3259,7 @@ var styles_module_default6 = { "ExternalInput-actions": "_ExternalInput-actions_
|
|
3271
3259
|
|
3272
3260
|
// components/Modal/index.tsx
|
3273
3261
|
init_react_import();
|
3274
|
-
var
|
3262
|
+
var import_react16 = require("react");
|
3275
3263
|
|
3276
3264
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Modal/styles.module.css#css-module
|
3277
3265
|
init_react_import();
|
@@ -3286,8 +3274,8 @@ var Modal = ({
|
|
3286
3274
|
onClose,
|
3287
3275
|
isOpen
|
3288
3276
|
}) => {
|
3289
|
-
const [rootEl, setRootEl] = (0,
|
3290
|
-
(0,
|
3277
|
+
const [rootEl, setRootEl] = (0, import_react16.useState)(null);
|
3278
|
+
(0, import_react16.useEffect)(() => {
|
3291
3279
|
setRootEl(document.getElementById("puck-portal-root"));
|
3292
3280
|
}, []);
|
3293
3281
|
if (!rootEl) {
|
@@ -3334,7 +3322,7 @@ init_react_import();
|
|
3334
3322
|
|
3335
3323
|
// components/Button/Button.tsx
|
3336
3324
|
init_react_import();
|
3337
|
-
var
|
3325
|
+
var import_react17 = require("react");
|
3338
3326
|
|
3339
3327
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Button/Button.module.css#css-module
|
3340
3328
|
init_react_import();
|
@@ -3384,8 +3372,8 @@ var Button = (_a) => {
|
|
3384
3372
|
"size",
|
3385
3373
|
"loading"
|
3386
3374
|
]);
|
3387
|
-
const [loading, setLoading] = (0,
|
3388
|
-
(0,
|
3375
|
+
const [loading, setLoading] = (0, import_react17.useState)(loadingProp);
|
3376
|
+
(0, import_react17.useEffect)(() => setLoading(loadingProp), [loadingProp]);
|
3389
3377
|
const ElementType = href ? "a" : type ? "button" : "span";
|
3390
3378
|
const dataAttrs = filterDataAttrs(props);
|
3391
3379
|
const el = /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
|
@@ -3440,28 +3428,28 @@ var ExternalInput = ({
|
|
3440
3428
|
mapRow = (val) => val,
|
3441
3429
|
filterFields
|
3442
3430
|
} = field || {};
|
3443
|
-
const [data, setData] = (0,
|
3444
|
-
const [isOpen, setOpen] = (0,
|
3445
|
-
const [isLoading, setIsLoading] = (0,
|
3431
|
+
const [data, setData] = (0, import_react18.useState)([]);
|
3432
|
+
const [isOpen, setOpen] = (0, import_react18.useState)(false);
|
3433
|
+
const [isLoading, setIsLoading] = (0, import_react18.useState)(true);
|
3446
3434
|
const hasFilterFields = !!filterFields;
|
3447
|
-
const [filters, setFilters] = (0,
|
3448
|
-
const [filtersToggled, setFiltersToggled] = (0,
|
3449
|
-
const mappedData = (0,
|
3435
|
+
const [filters, setFilters] = (0, import_react18.useState)(field.initialFilters || {});
|
3436
|
+
const [filtersToggled, setFiltersToggled] = (0, import_react18.useState)(hasFilterFields);
|
3437
|
+
const mappedData = (0, import_react18.useMemo)(() => {
|
3450
3438
|
return data.map(mapRow);
|
3451
3439
|
}, [data]);
|
3452
|
-
const keys = (0,
|
3440
|
+
const keys = (0, import_react18.useMemo)(() => {
|
3453
3441
|
const validKeys = /* @__PURE__ */ new Set();
|
3454
3442
|
for (const item of mappedData) {
|
3455
3443
|
for (const key of Object.keys(item)) {
|
3456
|
-
if (typeof item[key] === "string" || typeof item[key] === "number" || (0,
|
3444
|
+
if (typeof item[key] === "string" || typeof item[key] === "number" || (0, import_react18.isValidElement)(item[key])) {
|
3457
3445
|
validKeys.add(key);
|
3458
3446
|
}
|
3459
3447
|
}
|
3460
3448
|
}
|
3461
3449
|
return Array.from(validKeys);
|
3462
3450
|
}, [mappedData]);
|
3463
|
-
const [searchQuery, setSearchQuery] = (0,
|
3464
|
-
const search = (0,
|
3451
|
+
const [searchQuery, setSearchQuery] = (0, import_react18.useState)(field.initialQuery || "");
|
3452
|
+
const search = (0, import_react18.useCallback)(
|
3465
3453
|
(query, filters2) => __async(void 0, null, function* () {
|
3466
3454
|
setIsLoading(true);
|
3467
3455
|
const cacheKey = `${id}-${query}-${JSON.stringify(filters2)}`;
|
@@ -3474,7 +3462,7 @@ var ExternalInput = ({
|
|
3474
3462
|
}),
|
3475
3463
|
[id, field]
|
3476
3464
|
);
|
3477
|
-
const Footer = (0,
|
3465
|
+
const Footer = (0, import_react18.useCallback)(
|
3478
3466
|
(props) => field.renderFooter ? field.renderFooter(props) : /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("span", { className: getClassNameModal("footer"), children: [
|
3479
3467
|
props.items.length,
|
3480
3468
|
" result",
|
@@ -3482,7 +3470,7 @@ var ExternalInput = ({
|
|
3482
3470
|
] }),
|
3483
3471
|
[field.renderFooter]
|
3484
3472
|
);
|
3485
|
-
(0,
|
3473
|
+
(0, import_react18.useEffect)(() => {
|
3486
3474
|
search(searchQuery, filters);
|
3487
3475
|
}, []);
|
3488
3476
|
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
@@ -3654,7 +3642,7 @@ var ExternalField = ({
|
|
3654
3642
|
var _a, _b, _c;
|
3655
3643
|
const validField = field;
|
3656
3644
|
const deprecatedField = field;
|
3657
|
-
(0,
|
3645
|
+
(0, import_react19.useEffect)(() => {
|
3658
3646
|
if (deprecatedField.adaptor) {
|
3659
3647
|
console.error(
|
3660
3648
|
"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."
|
@@ -3697,7 +3685,7 @@ var ExternalField = ({
|
|
3697
3685
|
|
3698
3686
|
// components/AutoField/fields/RadioField/index.tsx
|
3699
3687
|
init_react_import();
|
3700
|
-
var
|
3688
|
+
var import_react20 = require("react");
|
3701
3689
|
|
3702
3690
|
// lib/safe-json-parse.ts
|
3703
3691
|
init_react_import();
|
@@ -3724,7 +3712,7 @@ var RadioField = ({
|
|
3724
3712
|
labelIcon,
|
3725
3713
|
Label: Label2
|
3726
3714
|
}) => {
|
3727
|
-
const flatOptions = (0,
|
3715
|
+
const flatOptions = (0, import_react20.useMemo)(
|
3728
3716
|
() => field.type === "radio" ? field.options.map(({ value: value2 }) => value2) : [],
|
3729
3717
|
[field]
|
3730
3718
|
);
|
@@ -3774,7 +3762,7 @@ var RadioField = ({
|
|
3774
3762
|
|
3775
3763
|
// components/AutoField/fields/SelectField/index.tsx
|
3776
3764
|
init_react_import();
|
3777
|
-
var
|
3765
|
+
var import_react21 = require("react");
|
3778
3766
|
var import_jsx_runtime15 = require("react/jsx-runtime");
|
3779
3767
|
var getClassName12 = get_class_name_factory_default("Input", styles_module_default2);
|
3780
3768
|
var SelectField = ({
|
@@ -3788,7 +3776,7 @@ var SelectField = ({
|
|
3788
3776
|
readOnly,
|
3789
3777
|
id
|
3790
3778
|
}) => {
|
3791
|
-
const flatOptions = (0,
|
3779
|
+
const flatOptions = (0, import_react21.useMemo)(
|
3792
3780
|
() => field.type === "select" ? field.options.map(({ value: value2 }) => value2) : [],
|
3793
3781
|
[field]
|
3794
3782
|
);
|
@@ -3949,12 +3937,12 @@ var ObjectField = ({
|
|
3949
3937
|
|
3950
3938
|
// lib/use-safe-id.ts
|
3951
3939
|
init_react_import();
|
3952
|
-
var
|
3940
|
+
var import_react22 = __toESM(require("react"));
|
3953
3941
|
var useSafeId = () => {
|
3954
|
-
if (typeof
|
3955
|
-
return
|
3942
|
+
if (typeof import_react22.default.useId !== "undefined") {
|
3943
|
+
return import_react22.default.useId();
|
3956
3944
|
}
|
3957
|
-
const [id] = (0,
|
3945
|
+
const [id] = (0, import_react22.useState)(generateId());
|
3958
3946
|
return id;
|
3959
3947
|
};
|
3960
3948
|
|
@@ -3988,7 +3976,7 @@ var FieldLabelInternal = ({
|
|
3988
3976
|
readOnly
|
3989
3977
|
}) => {
|
3990
3978
|
const overrides = useAppStore((s) => s.overrides);
|
3991
|
-
const Wrapper = (0,
|
3979
|
+
const Wrapper = (0, import_react23.useMemo)(
|
3992
3980
|
() => overrides.fieldLabel || FieldLabel,
|
3993
3981
|
[overrides]
|
3994
3982
|
);
|
@@ -4015,7 +4003,7 @@ function AutoFieldInternal(props) {
|
|
4015
4003
|
var _a2;
|
4016
4004
|
return (_a2 = s.selectedItem) == null ? void 0 : _a2.readOnly;
|
4017
4005
|
});
|
4018
|
-
const nestedFieldContext = (0,
|
4006
|
+
const nestedFieldContext = (0, import_react23.useContext)(NestedFieldContext);
|
4019
4007
|
const { id, Label: Label2 = FieldLabelInternal } = props;
|
4020
4008
|
const field = props.field;
|
4021
4009
|
const label = field.label;
|
@@ -4049,7 +4037,7 @@ function AutoFieldInternal(props) {
|
|
4049
4037
|
Label: Label2,
|
4050
4038
|
id: resolvedId
|
4051
4039
|
});
|
4052
|
-
const onFocus = (0,
|
4040
|
+
const onFocus = (0, import_react23.useCallback)(
|
4053
4041
|
(e) => {
|
4054
4042
|
if (mergedProps.name && (e.target.nodeName === "INPUT" || e.target.nodeName === "TEXTAREA")) {
|
4055
4043
|
e.stopPropagation();
|
@@ -4063,7 +4051,7 @@ function AutoFieldInternal(props) {
|
|
4063
4051
|
},
|
4064
4052
|
[mergedProps.name]
|
4065
4053
|
);
|
4066
|
-
const onBlur = (0,
|
4054
|
+
const onBlur = (0, import_react23.useCallback)((e) => {
|
4067
4055
|
if ("name" in e.target) {
|
4068
4056
|
dispatch({
|
4069
4057
|
type: "setUi",
|
@@ -4107,15 +4095,15 @@ function AutoFieldInternal(props) {
|
|
4107
4095
|
function AutoFieldPrivate(props) {
|
4108
4096
|
const isFocused = useAppStore((s) => s.state.ui.field.focus === props.name);
|
4109
4097
|
const { value, onChange } = props;
|
4110
|
-
const [localValue, setLocalValue] = (0,
|
4111
|
-
const onChangeLocal = (0,
|
4098
|
+
const [localValue, setLocalValue] = (0, import_react23.useState)(value);
|
4099
|
+
const onChangeLocal = (0, import_react23.useCallback)(
|
4112
4100
|
(val, ui) => {
|
4113
4101
|
setLocalValue(val);
|
4114
4102
|
onChange(val, ui);
|
4115
4103
|
},
|
4116
4104
|
[onChange]
|
4117
4105
|
);
|
4118
|
-
(0,
|
4106
|
+
(0, import_react23.useEffect)(() => {
|
4119
4107
|
if (!isFocused) {
|
4120
4108
|
setLocalValue(value);
|
4121
4109
|
}
|
@@ -4127,7 +4115,7 @@ function AutoFieldPrivate(props) {
|
|
4127
4115
|
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(AutoFieldInternal, __spreadValues(__spreadValues({}, props), localProps));
|
4128
4116
|
}
|
4129
4117
|
function AutoField(props) {
|
4130
|
-
const DefaultLabel = (0,
|
4118
|
+
const DefaultLabel = (0, import_react23.useMemo)(() => {
|
4131
4119
|
const DefaultLabel2 = (labelProps) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
4132
4120
|
"div",
|
4133
4121
|
__spreadProps(__spreadValues({}, labelProps), {
|
@@ -4147,21 +4135,21 @@ init_react_import();
|
|
4147
4135
|
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" };
|
4148
4136
|
|
4149
4137
|
// components/Drawer/index.tsx
|
4150
|
-
var
|
4138
|
+
var import_react36 = require("react");
|
4151
4139
|
|
4152
4140
|
// components/DragDropContext/index.tsx
|
4153
4141
|
init_react_import();
|
4154
|
-
var
|
4155
|
-
var
|
4142
|
+
var import_react34 = require("@dnd-kit/react");
|
4143
|
+
var import_react35 = require("react");
|
4156
4144
|
var import_dom = require("@dnd-kit/dom");
|
4157
4145
|
|
4158
4146
|
// components/DropZone/index.tsx
|
4159
4147
|
init_react_import();
|
4160
|
-
var
|
4148
|
+
var import_react33 = require("react");
|
4161
4149
|
|
4162
4150
|
// components/DraggableComponent/index.tsx
|
4163
4151
|
init_react_import();
|
4164
|
-
var
|
4152
|
+
var import_react26 = require("react");
|
4165
4153
|
|
4166
4154
|
// css-module:/home/runner/work/puck/puck/packages/core/components/DraggableComponent/styles.module.css#css-module
|
4167
4155
|
init_react_import();
|
@@ -4191,11 +4179,11 @@ function getDeepScrollPosition(element) {
|
|
4191
4179
|
|
4192
4180
|
// components/DropZone/context.tsx
|
4193
4181
|
init_react_import();
|
4194
|
-
var
|
4182
|
+
var import_react24 = require("react");
|
4195
4183
|
var import_zustand3 = require("zustand");
|
4196
4184
|
var import_jsx_runtime19 = require("react/jsx-runtime");
|
4197
|
-
var dropZoneContext = (0,
|
4198
|
-
var ZoneStoreContext = (0,
|
4185
|
+
var dropZoneContext = (0, import_react24.createContext)(null);
|
4186
|
+
var ZoneStoreContext = (0, import_react24.createContext)(
|
4199
4187
|
(0, import_zustand3.createStore)(() => ({
|
4200
4188
|
zoneDepthIndex: {},
|
4201
4189
|
nextZoneDepthIndex: {},
|
@@ -4215,10 +4203,10 @@ var DropZoneProvider = ({
|
|
4215
4203
|
children,
|
4216
4204
|
value
|
4217
4205
|
}) => {
|
4218
|
-
const [hoveringComponent, setHoveringComponent] = (0,
|
4219
|
-
const [activeZones, setActiveZones] = (0,
|
4206
|
+
const [hoveringComponent, setHoveringComponent] = (0, import_react24.useState)();
|
4207
|
+
const [activeZones, setActiveZones] = (0, import_react24.useState)({});
|
4220
4208
|
const dispatch = useAppStore((s) => s.dispatch);
|
4221
|
-
const registerZone = (0,
|
4209
|
+
const registerZone = (0, import_react24.useCallback)(
|
4222
4210
|
(zoneCompound) => {
|
4223
4211
|
if (!dispatch) {
|
4224
4212
|
return;
|
@@ -4231,7 +4219,7 @@ var DropZoneProvider = ({
|
|
4231
4219
|
},
|
4232
4220
|
[setActiveZones, dispatch]
|
4233
4221
|
);
|
4234
|
-
const unregisterZone = (0,
|
4222
|
+
const unregisterZone = (0, import_react24.useCallback)(
|
4235
4223
|
(zoneCompound) => {
|
4236
4224
|
if (!dispatch) {
|
4237
4225
|
return;
|
@@ -4246,7 +4234,7 @@ var DropZoneProvider = ({
|
|
4246
4234
|
},
|
4247
4235
|
[setActiveZones, dispatch]
|
4248
4236
|
);
|
4249
|
-
const memoValue = (0,
|
4237
|
+
const memoValue = (0, import_react24.useMemo)(
|
4250
4238
|
() => __spreadValues({
|
4251
4239
|
hoveringComponent,
|
4252
4240
|
setHoveringComponent,
|
@@ -4261,11 +4249,11 @@ var DropZoneProvider = ({
|
|
4261
4249
|
|
4262
4250
|
// lib/use-context-store.ts
|
4263
4251
|
init_react_import();
|
4264
|
-
var
|
4252
|
+
var import_react25 = require("react");
|
4265
4253
|
var import_zustand4 = require("zustand");
|
4266
4254
|
var import_shallow = require("zustand/react/shallow");
|
4267
4255
|
function useContextStore(context, selector) {
|
4268
|
-
const store = (0,
|
4256
|
+
const store = (0, import_react25.useContext)(context);
|
4269
4257
|
if (!store) {
|
4270
4258
|
throw new Error("useContextStore must be used inside context");
|
4271
4259
|
}
|
@@ -4323,9 +4311,9 @@ var DraggableComponent = ({
|
|
4323
4311
|
);
|
4324
4312
|
const dispatch = useAppStore((s) => s.dispatch);
|
4325
4313
|
const iframe = useAppStore((s) => s.iframe);
|
4326
|
-
const ctx = (0,
|
4327
|
-
const [localZones, setLocalZones] = (0,
|
4328
|
-
const registerLocalZone = (0,
|
4314
|
+
const ctx = (0, import_react26.useContext)(dropZoneContext);
|
4315
|
+
const [localZones, setLocalZones] = (0, import_react26.useState)({});
|
4316
|
+
const registerLocalZone = (0, import_react26.useCallback)(
|
4329
4317
|
(zoneCompound2, active) => {
|
4330
4318
|
var _a;
|
4331
4319
|
(_a = ctx == null ? void 0 : ctx.registerLocalZone) == null ? void 0 : _a.call(ctx, zoneCompound2, active);
|
@@ -4335,7 +4323,7 @@ var DraggableComponent = ({
|
|
4335
4323
|
},
|
4336
4324
|
[setLocalZones]
|
4337
4325
|
);
|
4338
|
-
const unregisterLocalZone = (0,
|
4326
|
+
const unregisterLocalZone = (0, import_react26.useCallback)(
|
4339
4327
|
(zoneCompound2) => {
|
4340
4328
|
var _a;
|
4341
4329
|
(_a = ctx == null ? void 0 : ctx.unregisterLocalZone) == null ? void 0 : _a.call(ctx, zoneCompound2);
|
@@ -4365,7 +4353,7 @@ var DraggableComponent = ({
|
|
4365
4353
|
);
|
4366
4354
|
const canCollide = permissions.drag || userIsDragging;
|
4367
4355
|
const disabled = !isEnabled || !canCollide;
|
4368
|
-
const [dragAxis, setDragAxis] = (0,
|
4356
|
+
const [dragAxis, setDragAxis] = (0, import_react26.useState)(userDragAxis || autoDragAxis);
|
4369
4357
|
const { ref: sortableRef, status } = useSortableSafe({
|
4370
4358
|
id,
|
4371
4359
|
index,
|
@@ -4391,8 +4379,8 @@ var DraggableComponent = ({
|
|
4391
4379
|
}
|
4392
4380
|
});
|
4393
4381
|
const thisIsDragging = status === "dragging";
|
4394
|
-
const ref = (0,
|
4395
|
-
const refSetter = (0,
|
4382
|
+
const ref = (0, import_react26.useRef)(null);
|
4383
|
+
const refSetter = (0, import_react26.useCallback)(
|
4396
4384
|
(el) => {
|
4397
4385
|
sortableRef(el);
|
4398
4386
|
if (el) {
|
@@ -4401,14 +4389,14 @@ var DraggableComponent = ({
|
|
4401
4389
|
},
|
4402
4390
|
[sortableRef]
|
4403
4391
|
);
|
4404
|
-
const [portalEl, setPortalEl] = (0,
|
4405
|
-
(0,
|
4392
|
+
const [portalEl, setPortalEl] = (0, import_react26.useState)();
|
4393
|
+
(0, import_react26.useEffect)(() => {
|
4406
4394
|
var _a, _b, _c;
|
4407
4395
|
setPortalEl(
|
4408
4396
|
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
|
4409
4397
|
);
|
4410
4398
|
}, [iframe.enabled, ref.current]);
|
4411
|
-
const getStyle = (0,
|
4399
|
+
const getStyle = (0, import_react26.useCallback)(() => {
|
4412
4400
|
var _a, _b, _c;
|
4413
4401
|
if (!ref.current) return;
|
4414
4402
|
const rect = ref.current.getBoundingClientRect();
|
@@ -4428,11 +4416,11 @@ var DraggableComponent = ({
|
|
4428
4416
|
};
|
4429
4417
|
return style2;
|
4430
4418
|
}, [ref.current]);
|
4431
|
-
const [style, setStyle] = (0,
|
4432
|
-
const sync = (0,
|
4419
|
+
const [style, setStyle] = (0, import_react26.useState)();
|
4420
|
+
const sync = (0, import_react26.useCallback)(() => {
|
4433
4421
|
setStyle(getStyle());
|
4434
4422
|
}, [ref.current, iframe]);
|
4435
|
-
(0,
|
4423
|
+
(0, import_react26.useEffect)(() => {
|
4436
4424
|
if (ref.current && !userIsDragging) {
|
4437
4425
|
const observer = new ResizeObserver(sync);
|
4438
4426
|
observer.observe(ref.current);
|
@@ -4442,18 +4430,18 @@ var DraggableComponent = ({
|
|
4442
4430
|
}
|
4443
4431
|
}, [ref.current, userIsDragging]);
|
4444
4432
|
const registerNode = useAppStore((s) => s.nodes.registerNode);
|
4445
|
-
(0,
|
4433
|
+
(0, import_react26.useEffect)(() => {
|
4446
4434
|
var _a;
|
4447
4435
|
registerNode(id, { methods: { sync }, element: (_a = ref.current) != null ? _a : null });
|
4448
4436
|
return () => {
|
4449
4437
|
registerNode(id, { methods: { sync: () => null }, element: null });
|
4450
4438
|
};
|
4451
4439
|
}, [id, zoneCompound, index, componentType, sync]);
|
4452
|
-
const CustomActionBar = (0,
|
4440
|
+
const CustomActionBar = (0, import_react26.useMemo)(
|
4453
4441
|
() => overrides.actionBar || DefaultActionBar,
|
4454
4442
|
[overrides.actionBar]
|
4455
4443
|
);
|
4456
|
-
const onClick = (0,
|
4444
|
+
const onClick = (0, import_react26.useCallback)(
|
4457
4445
|
(e) => {
|
4458
4446
|
e.stopPropagation();
|
4459
4447
|
dispatch({
|
@@ -4466,7 +4454,7 @@ var DraggableComponent = ({
|
|
4466
4454
|
[index, zoneCompound, id]
|
4467
4455
|
);
|
4468
4456
|
const appStore = useAppStoreApi();
|
4469
|
-
const onSelectParent = (0,
|
4457
|
+
const onSelectParent = (0, import_react26.useCallback)(() => {
|
4470
4458
|
const { nodes } = appStore.getState().nodes;
|
4471
4459
|
const node = nodes[id];
|
4472
4460
|
const parentNode = (node == null ? void 0 : node.parentId) ? nodes[node == null ? void 0 : node.parentId] : null;
|
@@ -4483,23 +4471,23 @@ var DraggableComponent = ({
|
|
4483
4471
|
}
|
4484
4472
|
});
|
4485
4473
|
}, [ctx, path]);
|
4486
|
-
const onDuplicate = (0,
|
4474
|
+
const onDuplicate = (0, import_react26.useCallback)(() => {
|
4487
4475
|
dispatch({
|
4488
4476
|
type: "duplicate",
|
4489
4477
|
sourceIndex: index,
|
4490
4478
|
sourceZone: zoneCompound
|
4491
4479
|
});
|
4492
4480
|
}, [index, zoneCompound]);
|
4493
|
-
const onDelete = (0,
|
4481
|
+
const onDelete = (0, import_react26.useCallback)(() => {
|
4494
4482
|
dispatch({
|
4495
4483
|
type: "remove",
|
4496
4484
|
index,
|
4497
4485
|
zone: zoneCompound
|
4498
4486
|
});
|
4499
4487
|
}, [index, zoneCompound]);
|
4500
|
-
const [hover, setHover] = (0,
|
4488
|
+
const [hover, setHover] = (0, import_react26.useState)(false);
|
4501
4489
|
const indicativeHover = (ctx == null ? void 0 : ctx.hoveringComponent) === id;
|
4502
|
-
(0,
|
4490
|
+
(0, import_react26.useEffect)(() => {
|
4503
4491
|
if (!ref.current) {
|
4504
4492
|
return;
|
4505
4493
|
}
|
@@ -4549,7 +4537,7 @@ var DraggableComponent = ({
|
|
4549
4537
|
thisIsDragging,
|
4550
4538
|
inDroppableZone
|
4551
4539
|
]);
|
4552
|
-
(0,
|
4540
|
+
(0, import_react26.useEffect)(() => {
|
4553
4541
|
if (ref.current && disabled) {
|
4554
4542
|
ref.current.setAttribute("data-puck-disabled", "");
|
4555
4543
|
return () => {
|
@@ -4558,8 +4546,8 @@ var DraggableComponent = ({
|
|
4558
4546
|
};
|
4559
4547
|
}
|
4560
4548
|
}, [disabled, ref]);
|
4561
|
-
const [isVisible, setIsVisible] = (0,
|
4562
|
-
(0,
|
4549
|
+
const [isVisible, setIsVisible] = (0, import_react26.useState)(false);
|
4550
|
+
(0, import_react26.useEffect)(() => {
|
4563
4551
|
sync();
|
4564
4552
|
if ((isSelected || hover || indicativeHover) && !userIsDragging) {
|
4565
4553
|
setIsVisible(true);
|
@@ -4567,7 +4555,7 @@ var DraggableComponent = ({
|
|
4567
4555
|
setIsVisible(false);
|
4568
4556
|
}
|
4569
4557
|
}, [isSelected, hover, indicativeHover, iframe, userIsDragging]);
|
4570
|
-
const syncActionsPosition = (0,
|
4558
|
+
const syncActionsPosition = (0, import_react26.useCallback)(
|
4571
4559
|
(el) => {
|
4572
4560
|
if (el) {
|
4573
4561
|
const view = el.ownerDocument.defaultView;
|
@@ -4592,7 +4580,7 @@ var DraggableComponent = ({
|
|
4592
4580
|
},
|
4593
4581
|
[zoom]
|
4594
4582
|
);
|
4595
|
-
(0,
|
4583
|
+
(0, import_react26.useEffect)(() => {
|
4596
4584
|
if (userDragAxis) {
|
4597
4585
|
setDragAxis(userDragAxis);
|
4598
4586
|
return;
|
@@ -4685,15 +4673,15 @@ var styles_module_default12 = { "DropZone": "_DropZone_kmkdc_1", "DropZone--isAc
|
|
4685
4673
|
|
4686
4674
|
// components/DropZone/lib/use-min-empty-height.ts
|
4687
4675
|
init_react_import();
|
4688
|
-
var
|
4676
|
+
var import_react27 = require("react");
|
4689
4677
|
var useMinEmptyHeight = ({
|
4690
4678
|
zoneCompound,
|
4691
4679
|
userMinEmptyHeight,
|
4692
4680
|
ref
|
4693
4681
|
}) => {
|
4694
4682
|
const appStore = useAppStoreApi();
|
4695
|
-
const [prevHeight, setPrevHeight] = (0,
|
4696
|
-
const [isAnimating, setIsAnimating] = (0,
|
4683
|
+
const [prevHeight, setPrevHeight] = (0, import_react27.useState)(0);
|
4684
|
+
const [isAnimating, setIsAnimating] = (0, import_react27.useState)(false);
|
4697
4685
|
const { draggedItem, isZone } = useContextStore(ZoneStoreContext, (s) => {
|
4698
4686
|
var _a, _b;
|
4699
4687
|
return {
|
@@ -4701,7 +4689,7 @@ var useMinEmptyHeight = ({
|
|
4701
4689
|
isZone: ((_b = s.draggedItem) == null ? void 0 : _b.data.zone) === zoneCompound
|
4702
4690
|
};
|
4703
4691
|
});
|
4704
|
-
(0,
|
4692
|
+
(0, import_react27.useEffect)(() => {
|
4705
4693
|
if (draggedItem && ref.current) {
|
4706
4694
|
if (isZone) {
|
4707
4695
|
const rect = ref.current.getBoundingClientRect();
|
@@ -4739,15 +4727,15 @@ function assignRefs(refs, node) {
|
|
4739
4727
|
|
4740
4728
|
// components/DropZone/lib/use-content-with-preview.ts
|
4741
4729
|
init_react_import();
|
4742
|
-
var
|
4730
|
+
var import_react30 = require("react");
|
4743
4731
|
|
4744
4732
|
// lib/dnd/use-rendered-callback.ts
|
4745
4733
|
init_react_import();
|
4746
|
-
var
|
4747
|
-
var
|
4734
|
+
var import_react28 = require("@dnd-kit/react");
|
4735
|
+
var import_react29 = require("react");
|
4748
4736
|
function useRenderedCallback(callback, deps) {
|
4749
|
-
const manager = (0,
|
4750
|
-
return (0,
|
4737
|
+
const manager = (0, import_react28.useDragDropManager)();
|
4738
|
+
return (0, import_react29.useCallback)(
|
4751
4739
|
(...args) => __async(this, null, function* () {
|
4752
4740
|
yield manager == null ? void 0 : manager.renderer.rendering;
|
4753
4741
|
return callback(...args);
|
@@ -4770,8 +4758,8 @@ var useContentIdsWithPreview = (contentIds, zoneCompound) => {
|
|
4770
4758
|
}
|
4771
4759
|
);
|
4772
4760
|
const isDragging = useAppStore((s) => s.state.ui.isDragging);
|
4773
|
-
const [contentIdsWithPreview, setContentIdsWithPreview] = (0,
|
4774
|
-
const [localPreview, setLocalPreview] = (0,
|
4761
|
+
const [contentIdsWithPreview, setContentIdsWithPreview] = (0, import_react30.useState)(contentIds);
|
4762
|
+
const [localPreview, setLocalPreview] = (0, import_react30.useState)(
|
4775
4763
|
preview
|
4776
4764
|
);
|
4777
4765
|
const updateContent = useRenderedCallback(
|
@@ -4806,7 +4794,7 @@ var useContentIdsWithPreview = (contentIds, zoneCompound) => {
|
|
4806
4794
|
},
|
4807
4795
|
[draggedItemId, previewExists]
|
4808
4796
|
);
|
4809
|
-
(0,
|
4797
|
+
(0, import_react30.useEffect)(() => {
|
4810
4798
|
updateContent(contentIds, preview, isDragging);
|
4811
4799
|
}, [contentIds, preview, isDragging]);
|
4812
4800
|
return [contentIdsWithPreview, localPreview];
|
@@ -4814,16 +4802,16 @@ var useContentIdsWithPreview = (contentIds, zoneCompound) => {
|
|
4814
4802
|
|
4815
4803
|
// components/DropZone/lib/use-drag-axis.ts
|
4816
4804
|
init_react_import();
|
4817
|
-
var
|
4805
|
+
var import_react31 = require("react");
|
4818
4806
|
var GRID_DRAG_AXIS = "dynamic";
|
4819
4807
|
var FLEX_ROW_DRAG_AXIS = "x";
|
4820
4808
|
var DEFAULT_DRAG_AXIS = "y";
|
4821
4809
|
var useDragAxis = (ref, collisionAxis) => {
|
4822
4810
|
const status = useAppStore((s) => s.status);
|
4823
|
-
const [dragAxis, setDragAxis] = (0,
|
4811
|
+
const [dragAxis, setDragAxis] = (0, import_react31.useState)(
|
4824
4812
|
collisionAxis || DEFAULT_DRAG_AXIS
|
4825
4813
|
);
|
4826
|
-
const calculateDragAxis = (0,
|
4814
|
+
const calculateDragAxis = (0, import_react31.useCallback)(() => {
|
4827
4815
|
if (ref.current) {
|
4828
4816
|
const computedStyle = window.getComputedStyle(ref.current);
|
4829
4817
|
if (computedStyle.display === "grid") {
|
@@ -4835,7 +4823,7 @@ var useDragAxis = (ref, collisionAxis) => {
|
|
4835
4823
|
}
|
4836
4824
|
}
|
4837
4825
|
}, [ref.current]);
|
4838
|
-
(0,
|
4826
|
+
(0, import_react31.useEffect)(() => {
|
4839
4827
|
const onViewportChange = () => {
|
4840
4828
|
calculateDragAxis();
|
4841
4829
|
};
|
@@ -4844,7 +4832,7 @@ var useDragAxis = (ref, collisionAxis) => {
|
|
4844
4832
|
window.removeEventListener("viewportchange", onViewportChange);
|
4845
4833
|
};
|
4846
4834
|
}, []);
|
4847
|
-
(0,
|
4835
|
+
(0, import_react31.useEffect)(calculateDragAxis, [status, collisionAxis]);
|
4848
4836
|
return [dragAxis, calculateDragAxis];
|
4849
4837
|
};
|
4850
4838
|
|
@@ -4853,9 +4841,9 @@ var import_shallow3 = require("zustand/react/shallow");
|
|
4853
4841
|
|
4854
4842
|
// components/Render/index.tsx
|
4855
4843
|
init_react_import();
|
4856
|
-
var
|
4844
|
+
var import_react32 = __toESM(require("react"));
|
4857
4845
|
var import_jsx_runtime21 = require("react/jsx-runtime");
|
4858
|
-
var renderContext =
|
4846
|
+
var renderContext = import_react32.default.createContext({
|
4859
4847
|
config: { components: {} },
|
4860
4848
|
data: { root: {}, content: [] },
|
4861
4849
|
metadata: {}
|
@@ -4934,7 +4922,7 @@ var DropZoneChild = ({
|
|
4934
4922
|
dragRef: null,
|
4935
4923
|
metadata
|
4936
4924
|
};
|
4937
|
-
const ctx = (0,
|
4925
|
+
const ctx = (0, import_react33.useContext)(dropZoneContext);
|
4938
4926
|
const { depth } = ctx;
|
4939
4927
|
const contentItem = useAppStore(
|
4940
4928
|
(0, import_shallow3.useShallow)((s) => {
|
@@ -4963,7 +4951,7 @@ var DropZoneChild = ({
|
|
4963
4951
|
}
|
4964
4952
|
);
|
4965
4953
|
let label = (_b = (_a = componentConfig == null ? void 0 : componentConfig.label) != null ? _a : item == null ? void 0 : item.type.toString()) != null ? _b : "Component";
|
4966
|
-
const renderPreview = (0,
|
4954
|
+
const renderPreview = (0, import_react33.useMemo)(
|
4967
4955
|
() => function Preview4() {
|
4968
4956
|
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(DrawerItemInner, { name: label, children: overrides.componentItem });
|
4969
4957
|
},
|
@@ -5010,7 +4998,7 @@ var DropZoneChild = ({
|
|
5010
4998
|
}
|
5011
4999
|
);
|
5012
5000
|
};
|
5013
|
-
var DropZoneEdit = (0,
|
5001
|
+
var DropZoneEdit = (0, import_react33.forwardRef)(
|
5014
5002
|
function DropZoneEditInternal({
|
5015
5003
|
zone,
|
5016
5004
|
allow,
|
@@ -5020,7 +5008,7 @@ var DropZoneEdit = (0, import_react34.forwardRef)(
|
|
5020
5008
|
minEmptyHeight: userMinEmptyHeight = 128,
|
5021
5009
|
collisionAxis
|
5022
5010
|
}, userRef) {
|
5023
|
-
const ctx = (0,
|
5011
|
+
const ctx = (0, import_react33.useContext)(dropZoneContext);
|
5024
5012
|
const {
|
5025
5013
|
// These all need setting via context
|
5026
5014
|
areaId,
|
@@ -5057,7 +5045,7 @@ var DropZoneEdit = (0, import_react34.forwardRef)(
|
|
5057
5045
|
userIsDragging: !!s.draggedItem
|
5058
5046
|
};
|
5059
5047
|
});
|
5060
|
-
(0,
|
5048
|
+
(0, import_react33.useEffect)(() => {
|
5061
5049
|
if (ctx == null ? void 0 : ctx.registerZone) {
|
5062
5050
|
ctx == null ? void 0 : ctx.registerZone(zoneCompound);
|
5063
5051
|
}
|
@@ -5076,8 +5064,8 @@ var DropZoneEdit = (0, import_react34.forwardRef)(
|
|
5076
5064
|
return content.map(({ props }) => props.id);
|
5077
5065
|
})
|
5078
5066
|
);
|
5079
|
-
const ref = (0,
|
5080
|
-
const acceptsTarget = (0,
|
5067
|
+
const ref = (0, import_react33.useRef)(null);
|
5068
|
+
const acceptsTarget = (0, import_react33.useCallback)(
|
5081
5069
|
(componentType) => {
|
5082
5070
|
if (!componentType) {
|
5083
5071
|
return true;
|
@@ -5099,7 +5087,7 @@ var DropZoneEdit = (0, import_react34.forwardRef)(
|
|
5099
5087
|
},
|
5100
5088
|
[allow, disallow]
|
5101
5089
|
);
|
5102
|
-
(0,
|
5090
|
+
(0, import_react33.useEffect)(() => {
|
5103
5091
|
if (registerLocalZone) {
|
5104
5092
|
registerLocalZone(zoneCompound, acceptsTarget(draggedComponentType));
|
5105
5093
|
}
|
@@ -5189,14 +5177,14 @@ var DropZoneEdit = (0, import_react34.forwardRef)(
|
|
5189
5177
|
}
|
5190
5178
|
);
|
5191
5179
|
var DropZoneRenderPure = (props) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(DropZoneRender, __spreadValues({}, props));
|
5192
|
-
var DropZoneRender = (0,
|
5180
|
+
var DropZoneRender = (0, import_react33.forwardRef)(
|
5193
5181
|
function DropZoneRenderInternal({ className, style, zone }, ref) {
|
5194
|
-
const ctx = (0,
|
5182
|
+
const ctx = (0, import_react33.useContext)(dropZoneContext);
|
5195
5183
|
const { areaId = "root" } = ctx || {};
|
5196
|
-
const { config, data, metadata } = (0,
|
5184
|
+
const { config, data, metadata } = (0, import_react33.useContext)(renderContext);
|
5197
5185
|
let zoneCompound = rootDroppableId;
|
5198
5186
|
let content = (data == null ? void 0 : data.content) || [];
|
5199
|
-
(0,
|
5187
|
+
(0, import_react33.useEffect)(() => {
|
5200
5188
|
if (ctx == null ? void 0 : ctx.registerZone) {
|
5201
5189
|
ctx == null ? void 0 : ctx.registerZone(zoneCompound);
|
5202
5190
|
}
|
@@ -5241,9 +5229,9 @@ var DropZoneRender = (0, import_react34.forwardRef)(
|
|
5241
5229
|
}
|
5242
5230
|
);
|
5243
5231
|
var DropZonePure = (props) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(DropZone, __spreadValues({}, props));
|
5244
|
-
var DropZone = (0,
|
5232
|
+
var DropZone = (0, import_react33.forwardRef)(
|
5245
5233
|
function DropZone2(props, ref) {
|
5246
|
-
const ctx = (0,
|
5234
|
+
const ctx = (0, import_react33.useContext)(dropZoneContext);
|
5247
5235
|
if ((ctx == null ? void 0 : ctx.mode) === "edit") {
|
5248
5236
|
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_jsx_runtime22.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(DropZoneEdit, __spreadProps(__spreadValues({}, props), { ref })) });
|
5249
5237
|
}
|
@@ -5563,12 +5551,12 @@ function getDeepDir(el) {
|
|
5563
5551
|
// components/DragDropContext/index.tsx
|
5564
5552
|
var import_jsx_runtime23 = require("react/jsx-runtime");
|
5565
5553
|
var DEBUG3 = false;
|
5566
|
-
var dragListenerContext = (0,
|
5554
|
+
var dragListenerContext = (0, import_react35.createContext)({
|
5567
5555
|
dragListeners: {}
|
5568
5556
|
});
|
5569
5557
|
function useDragListener(type, fn, deps = []) {
|
5570
|
-
const { setDragListeners } = (0,
|
5571
|
-
(0,
|
5558
|
+
const { setDragListeners } = (0, import_react35.useContext)(dragListenerContext);
|
5559
|
+
(0, import_react35.useEffect)(() => {
|
5572
5560
|
if (setDragListeners) {
|
5573
5561
|
setDragListeners((old) => __spreadProps(__spreadValues({}, old), {
|
5574
5562
|
[type]: [...old[type] || [], fn]
|
@@ -5578,8 +5566,8 @@ function useDragListener(type, fn, deps = []) {
|
|
5578
5566
|
}
|
5579
5567
|
var AREA_CHANGE_DEBOUNCE_MS = 100;
|
5580
5568
|
var useTempDisableFallback = (timeout3) => {
|
5581
|
-
const lastFallbackDisable = (0,
|
5582
|
-
return (0,
|
5569
|
+
const lastFallbackDisable = (0, import_react35.useRef)(null);
|
5570
|
+
return (0, import_react35.useCallback)((manager) => {
|
5583
5571
|
collisionStore.setState({ fallbackEnabled: false });
|
5584
5572
|
const fallbackId = generateId();
|
5585
5573
|
lastFallbackDisable.current = fallbackId;
|
@@ -5601,9 +5589,9 @@ var DragDropContextClient = ({
|
|
5601
5589
|
const metadata = useAppStore((s) => s.metadata);
|
5602
5590
|
const appStore = useAppStoreApi();
|
5603
5591
|
const id = useSafeId();
|
5604
|
-
const debouncedParamsRef = (0,
|
5592
|
+
const debouncedParamsRef = (0, import_react35.useRef)(null);
|
5605
5593
|
const tempDisableFallback = useTempDisableFallback(100);
|
5606
|
-
const [zoneStore] = (0,
|
5594
|
+
const [zoneStore] = (0, import_react35.useState)(
|
5607
5595
|
() => (0, import_zustand5.createStore)(() => ({
|
5608
5596
|
zoneDepthIndex: {},
|
5609
5597
|
nextZoneDepthIndex: {},
|
@@ -5613,7 +5601,7 @@ var DragDropContextClient = ({
|
|
5613
5601
|
previewIndex: {}
|
5614
5602
|
}))
|
5615
5603
|
);
|
5616
|
-
const getChanged2 = (0,
|
5604
|
+
const getChanged2 = (0, import_react35.useCallback)(
|
5617
5605
|
(params, id2) => {
|
5618
5606
|
const { zoneDepthIndex = {}, areaDepthIndex = {} } = zoneStore.getState() || {};
|
5619
5607
|
const stateHasZone = Object.keys(zoneDepthIndex).length > 0;
|
@@ -5634,7 +5622,7 @@ var DragDropContextClient = ({
|
|
5634
5622
|
},
|
5635
5623
|
[zoneStore]
|
5636
5624
|
);
|
5637
|
-
const setDeepestAndCollide = (0,
|
5625
|
+
const setDeepestAndCollide = (0, import_react35.useCallback)(
|
5638
5626
|
(params, manager) => {
|
5639
5627
|
const { zoneChanged, areaChanged } = getChanged2(params, id);
|
5640
5628
|
if (!zoneChanged && !areaChanged) return;
|
@@ -5658,7 +5646,7 @@ var DragDropContextClient = ({
|
|
5658
5646
|
setDeepestDb.cancel();
|
5659
5647
|
debouncedParamsRef.current = null;
|
5660
5648
|
};
|
5661
|
-
(0,
|
5649
|
+
(0, import_react35.useEffect)(() => {
|
5662
5650
|
if (DEBUG3) {
|
5663
5651
|
zoneStore.subscribe(
|
5664
5652
|
(s) => {
|
@@ -5672,7 +5660,7 @@ var DragDropContextClient = ({
|
|
5672
5660
|
);
|
5673
5661
|
}
|
5674
5662
|
}, []);
|
5675
|
-
const [plugins] = (0,
|
5663
|
+
const [plugins] = (0, import_react35.useState)(() => [
|
5676
5664
|
...disableAutoScroll ? import_dom.defaultPreset.plugins.filter((plugin) => plugin !== import_dom.AutoScroller) : import_dom.defaultPreset.plugins,
|
5677
5665
|
createNestedDroppablePlugin(
|
5678
5666
|
{
|
@@ -5720,9 +5708,9 @@ var DragDropContextClient = ({
|
|
5720
5708
|
)
|
5721
5709
|
]);
|
5722
5710
|
const sensors = useSensors();
|
5723
|
-
const [dragListeners, setDragListeners] = (0,
|
5724
|
-
const dragMode = (0,
|
5725
|
-
const initialSelector = (0,
|
5711
|
+
const [dragListeners, setDragListeners] = (0, import_react35.useState)({});
|
5712
|
+
const dragMode = (0, import_react35.useRef)(null);
|
5713
|
+
const initialSelector = (0, import_react35.useRef)(void 0);
|
5726
5714
|
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { id, children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
5727
5715
|
dragListenerContext.Provider,
|
5728
5716
|
{
|
@@ -5731,7 +5719,7 @@ var DragDropContextClient = ({
|
|
5731
5719
|
setDragListeners
|
5732
5720
|
},
|
5733
5721
|
children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
5734
|
-
|
5722
|
+
import_react34.DragDropProvider,
|
5735
5723
|
{
|
5736
5724
|
plugins,
|
5737
5725
|
sensors,
|
@@ -5961,7 +5949,7 @@ var DrawerItemInner = ({
|
|
5961
5949
|
dragRef,
|
5962
5950
|
isDragDisabled
|
5963
5951
|
}) => {
|
5964
|
-
const CustomInner = (0,
|
5952
|
+
const CustomInner = (0, import_react36.useMemo)(
|
5965
5953
|
() => children || (({ children: children2 }) => /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: getClassNameItem2("default"), children: children2 })),
|
5966
5954
|
[children]
|
5967
5955
|
);
|
@@ -6015,7 +6003,7 @@ var DrawerItem = ({
|
|
6015
6003
|
isDragDisabled
|
6016
6004
|
}) => {
|
6017
6005
|
const resolvedId = id || name;
|
6018
|
-
const [dynamicId, setDynamicId] = (0,
|
6006
|
+
const [dynamicId, setDynamicId] = (0, import_react36.useState)(generateId(resolvedId));
|
6019
6007
|
if (typeof index !== "undefined") {
|
6020
6008
|
console.error(
|
6021
6009
|
"Warning: The `index` prop on Drawer.Item is deprecated and no longer required."
|
@@ -6076,7 +6064,7 @@ Drawer.Item = DrawerItem;
|
|
6076
6064
|
|
6077
6065
|
// components/Puck/index.tsx
|
6078
6066
|
init_react_import();
|
6079
|
-
var
|
6067
|
+
var import_react51 = require("react");
|
6080
6068
|
|
6081
6069
|
// components/SidebarSection/index.tsx
|
6082
6070
|
init_react_import();
|
@@ -6087,7 +6075,7 @@ var styles_module_default13 = { "SidebarSection": "_SidebarSection_8boj8_1", "Si
|
|
6087
6075
|
|
6088
6076
|
// lib/use-breadcrumbs.ts
|
6089
6077
|
init_react_import();
|
6090
|
-
var
|
6078
|
+
var import_react37 = require("react");
|
6091
6079
|
var useBreadcrumbs = (renderCount) => {
|
6092
6080
|
const selectedId = useAppStore((s) => {
|
6093
6081
|
var _a;
|
@@ -6099,7 +6087,7 @@ var useBreadcrumbs = (renderCount) => {
|
|
6099
6087
|
return (_a = s.nodes.nodes[selectedId]) == null ? void 0 : _a.path;
|
6100
6088
|
});
|
6101
6089
|
const appStore = useAppStoreApi();
|
6102
|
-
return (0,
|
6090
|
+
return (0, import_react37.useMemo)(() => {
|
6103
6091
|
const breadcrumbs = (path == null ? void 0 : path.map((zoneCompound) => {
|
6104
6092
|
var _a, _b;
|
6105
6093
|
const [componentId] = zoneCompound.split(":");
|
@@ -6224,7 +6212,7 @@ init_react_import();
|
|
6224
6212
|
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" };
|
6225
6213
|
|
6226
6214
|
// components/Puck/components/Fields/index.tsx
|
6227
|
-
var
|
6215
|
+
var import_react38 = require("react");
|
6228
6216
|
var import_shallow4 = require("zustand/react/shallow");
|
6229
6217
|
var import_jsx_runtime27 = require("react/jsx-runtime");
|
6230
6218
|
var getClassName21 = get_class_name_factory_default("PuckFields", styles_module_default16);
|
@@ -6319,7 +6307,7 @@ var FieldsChild = ({ fieldName }) => {
|
|
6319
6307
|
})
|
6320
6308
|
);
|
6321
6309
|
const appStore = useAppStoreApi();
|
6322
|
-
const onChange = (0,
|
6310
|
+
const onChange = (0, import_react38.useCallback)(createOnChange(fieldName, appStore), [
|
6323
6311
|
fieldName
|
6324
6312
|
]);
|
6325
6313
|
if (!field || !id) return null;
|
@@ -6354,7 +6342,7 @@ var Fields = ({ wrapFields = true }) => {
|
|
6354
6342
|
(0, import_shallow4.useShallow)((s) => Object.keys(s.fields.fields))
|
6355
6343
|
);
|
6356
6344
|
const isLoading = fieldsLoading || componentResolving;
|
6357
|
-
const Wrapper = (0,
|
6345
|
+
const Wrapper = (0, import_react38.useMemo)(() => overrides.fields || DefaultFields, [overrides]);
|
6358
6346
|
return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
|
6359
6347
|
"form",
|
6360
6348
|
{
|
@@ -6375,7 +6363,7 @@ init_react_import();
|
|
6375
6363
|
|
6376
6364
|
// lib/use-component-list.tsx
|
6377
6365
|
init_react_import();
|
6378
|
-
var
|
6366
|
+
var import_react39 = require("react");
|
6379
6367
|
|
6380
6368
|
// components/ComponentList/index.tsx
|
6381
6369
|
init_react_import();
|
@@ -6446,10 +6434,10 @@ ComponentList.Item = ComponentListItem;
|
|
6446
6434
|
// lib/use-component-list.tsx
|
6447
6435
|
var import_jsx_runtime29 = require("react/jsx-runtime");
|
6448
6436
|
var useComponentList = () => {
|
6449
|
-
const [componentList, setComponentList] = (0,
|
6437
|
+
const [componentList, setComponentList] = (0, import_react39.useState)();
|
6450
6438
|
const config = useAppStore((s) => s.config);
|
6451
6439
|
const uiComponentList = useAppStore((s) => s.state.ui.componentList);
|
6452
|
-
(0,
|
6440
|
+
(0, import_react39.useEffect)(() => {
|
6453
6441
|
var _a, _b, _c;
|
6454
6442
|
if (Object.keys(uiComponentList).length > 0) {
|
6455
6443
|
const matchedComponents = [];
|
@@ -6518,22 +6506,22 @@ var useComponentList = () => {
|
|
6518
6506
|
};
|
6519
6507
|
|
6520
6508
|
// components/Puck/components/Components/index.tsx
|
6521
|
-
var
|
6509
|
+
var import_react40 = require("react");
|
6522
6510
|
var import_jsx_runtime30 = require("react/jsx-runtime");
|
6523
6511
|
var Components = () => {
|
6524
6512
|
const overrides = useAppStore((s) => s.overrides);
|
6525
6513
|
const componentList = useComponentList();
|
6526
|
-
const Wrapper = (0,
|
6514
|
+
const Wrapper = (0, import_react40.useMemo)(() => overrides.components || "div", [overrides]);
|
6527
6515
|
return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Wrapper, { children: componentList ? componentList : /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(ComponentList, { id: "all" }) });
|
6528
6516
|
};
|
6529
6517
|
|
6530
6518
|
// components/Puck/components/Preview/index.tsx
|
6531
6519
|
init_react_import();
|
6532
|
-
var
|
6520
|
+
var import_react42 = require("react");
|
6533
6521
|
|
6534
6522
|
// components/AutoFrame/index.tsx
|
6535
6523
|
init_react_import();
|
6536
|
-
var
|
6524
|
+
var import_react41 = require("react");
|
6537
6525
|
var import_object_hash = __toESM(require("object-hash"));
|
6538
6526
|
var import_react_dom3 = require("react-dom");
|
6539
6527
|
var import_jsx_runtime31 = require("react/jsx-runtime");
|
@@ -6579,7 +6567,7 @@ var CopyHostStyles = ({
|
|
6579
6567
|
onStylesLoaded = () => null
|
6580
6568
|
}) => {
|
6581
6569
|
const { document: doc, window: win } = useFrame();
|
6582
|
-
(0,
|
6570
|
+
(0, import_react41.useEffect)(() => {
|
6583
6571
|
if (!win || !doc) {
|
6584
6572
|
return () => {
|
6585
6573
|
};
|
@@ -6738,8 +6726,8 @@ var CopyHostStyles = ({
|
|
6738
6726
|
}, []);
|
6739
6727
|
return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_jsx_runtime31.Fragment, { children });
|
6740
6728
|
};
|
6741
|
-
var autoFrameContext = (0,
|
6742
|
-
var useFrame = () => (0,
|
6729
|
+
var autoFrameContext = (0, import_react41.createContext)({});
|
6730
|
+
var useFrame = () => (0, import_react41.useContext)(autoFrameContext);
|
6743
6731
|
function AutoFrame(_a) {
|
6744
6732
|
var _b = _a, {
|
6745
6733
|
children,
|
@@ -6760,11 +6748,11 @@ function AutoFrame(_a) {
|
|
6760
6748
|
"onNotReady",
|
6761
6749
|
"frameRef"
|
6762
6750
|
]);
|
6763
|
-
const [loaded, setLoaded] = (0,
|
6764
|
-
const [ctx, setCtx] = (0,
|
6765
|
-
const [mountTarget, setMountTarget] = (0,
|
6766
|
-
const [stylesLoaded, setStylesLoaded] = (0,
|
6767
|
-
(0,
|
6751
|
+
const [loaded, setLoaded] = (0, import_react41.useState)(false);
|
6752
|
+
const [ctx, setCtx] = (0, import_react41.useState)({});
|
6753
|
+
const [mountTarget, setMountTarget] = (0, import_react41.useState)();
|
6754
|
+
const [stylesLoaded, setStylesLoaded] = (0, import_react41.useState)(false);
|
6755
|
+
(0, import_react41.useEffect)(() => {
|
6768
6756
|
var _a2;
|
6769
6757
|
if (frameRef.current) {
|
6770
6758
|
const doc = frameRef.current.contentDocument;
|
@@ -6816,7 +6804,7 @@ var import_jsx_runtime32 = require("react/jsx-runtime");
|
|
6816
6804
|
var getClassName23 = get_class_name_factory_default("PuckPreview", styles_module_default18);
|
6817
6805
|
var useBubbleIframeEvents = (ref) => {
|
6818
6806
|
const status = useAppStore((s) => s.status);
|
6819
|
-
(0,
|
6807
|
+
(0, import_react42.useEffect)(() => {
|
6820
6808
|
if (ref.current && status === "READY") {
|
6821
6809
|
const iframe = ref.current;
|
6822
6810
|
const handlePointerMove = (event) => {
|
@@ -6865,7 +6853,7 @@ var Preview3 = ({ id = "puck-preview" }) => {
|
|
6865
6853
|
const renderData = useAppStore(
|
6866
6854
|
(s) => s.state.ui.previewMode === "edit" ? null : s.state.data
|
6867
6855
|
);
|
6868
|
-
const Page = (0,
|
6856
|
+
const Page = (0, import_react42.useCallback)(
|
6869
6857
|
(pageProps) => {
|
6870
6858
|
var _a, _b;
|
6871
6859
|
return ((_a = config.root) == null ? void 0 : _a.render) ? (_b = config.root) == null ? void 0 : _b.render(__spreadValues({
|
@@ -6874,9 +6862,9 @@ var Preview3 = ({ id = "puck-preview" }) => {
|
|
6874
6862
|
},
|
6875
6863
|
[config.root]
|
6876
6864
|
);
|
6877
|
-
const Frame = (0,
|
6865
|
+
const Frame = (0, import_react42.useMemo)(() => overrides.iframe, [overrides]);
|
6878
6866
|
const rootProps = root.props || root;
|
6879
|
-
const ref = (0,
|
6867
|
+
const ref = (0, import_react42.useRef)(null);
|
6880
6868
|
useBubbleIframeEvents(ref);
|
6881
6869
|
const inner = !renderData ? /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
6882
6870
|
Page,
|
@@ -6891,7 +6879,7 @@ var Preview3 = ({ id = "puck-preview" }) => {
|
|
6891
6879
|
children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(DropZonePure, { zone: rootDroppableId })
|
6892
6880
|
})
|
6893
6881
|
) : /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Render, { data: renderData, config });
|
6894
|
-
(0,
|
6882
|
+
(0, import_react42.useEffect)(() => {
|
6895
6883
|
if (!iframe.enabled) {
|
6896
6884
|
setStatus("READY");
|
6897
6885
|
}
|
@@ -6982,7 +6970,7 @@ var scrollIntoView = (el) => {
|
|
6982
6970
|
};
|
6983
6971
|
|
6984
6972
|
// components/LayerTree/index.tsx
|
6985
|
-
var
|
6973
|
+
var import_react43 = require("react");
|
6986
6974
|
|
6987
6975
|
// lib/on-scroll-end.ts
|
6988
6976
|
init_react_import();
|
@@ -7017,7 +7005,7 @@ var LayerTree = ({
|
|
7017
7005
|
label
|
7018
7006
|
}) => {
|
7019
7007
|
const zones = data.zones || {};
|
7020
|
-
const ctx = (0,
|
7008
|
+
const ctx = (0, import_react43.useContext)(dropZoneContext);
|
7021
7009
|
const nodes = useAppStore((s) => s.nodes.nodes);
|
7022
7010
|
return /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(import_jsx_runtime33.Fragment, { children: [
|
7023
7011
|
label && /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { className: getClassName24("zoneTitle"), children: [
|
@@ -7129,7 +7117,7 @@ var LayerTree = ({
|
|
7129
7117
|
};
|
7130
7118
|
|
7131
7119
|
// components/Puck/components/Outline/index.tsx
|
7132
|
-
var
|
7120
|
+
var import_react44 = require("react");
|
7133
7121
|
var import_jsx_runtime34 = require("react/jsx-runtime");
|
7134
7122
|
var Outline = () => {
|
7135
7123
|
const state = useAppStore((s) => s.state);
|
@@ -7138,7 +7126,7 @@ var Outline = () => {
|
|
7138
7126
|
const { data, ui } = state;
|
7139
7127
|
const { itemSelector } = ui;
|
7140
7128
|
const appStore = useAppStoreApi();
|
7141
|
-
const setItemSelector = (0,
|
7129
|
+
const setItemSelector = (0, import_react44.useCallback)(
|
7142
7130
|
(newItemSelector) => {
|
7143
7131
|
const { dispatch } = appStore.getState();
|
7144
7132
|
dispatch({
|
@@ -7148,7 +7136,7 @@ var Outline = () => {
|
|
7148
7136
|
},
|
7149
7137
|
[appStore]
|
7150
7138
|
);
|
7151
|
-
const Wrapper = (0,
|
7139
|
+
const Wrapper = (0, import_react44.useMemo)(() => outlineOverride || "div", [outlineOverride]);
|
7152
7140
|
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: [
|
7153
7141
|
(ctx == null ? void 0 : ctx.activeZones) && (ctx == null ? void 0 : ctx.activeZones[rootDroppableId]) && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
7154
7142
|
LayerTree,
|
@@ -7304,11 +7292,11 @@ var getBox = function getBox2(el) {
|
|
7304
7292
|
};
|
7305
7293
|
|
7306
7294
|
// components/Puck/components/Canvas/index.tsx
|
7307
|
-
var
|
7295
|
+
var import_react46 = require("react");
|
7308
7296
|
|
7309
7297
|
// components/ViewportControls/index.tsx
|
7310
7298
|
init_react_import();
|
7311
|
-
var
|
7299
|
+
var import_react45 = require("react");
|
7312
7300
|
|
7313
7301
|
// css-module:/home/runner/work/puck/puck/packages/core/components/ViewportControls/styles.module.css#css-module
|
7314
7302
|
init_react_import();
|
@@ -7331,8 +7319,8 @@ var ViewportButton = ({
|
|
7331
7319
|
onClick
|
7332
7320
|
}) => {
|
7333
7321
|
const viewports = useAppStore((s) => s.state.ui.viewports);
|
7334
|
-
const [isActive, setIsActive] = (0,
|
7335
|
-
(0,
|
7322
|
+
const [isActive, setIsActive] = (0, import_react45.useState)(false);
|
7323
|
+
(0, import_react45.useEffect)(() => {
|
7336
7324
|
setIsActive(width === viewports.current.width);
|
7337
7325
|
}, [width, viewports.current.width]);
|
7338
7326
|
return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("span", { className: getClassNameButton({ isActive }), children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
@@ -7368,7 +7356,7 @@ var ViewportControls = ({
|
|
7368
7356
|
const defaultsContainAutoZoom = defaultZoomOptions.find(
|
7369
7357
|
(option) => option.value === autoZoom
|
7370
7358
|
);
|
7371
|
-
const zoomOptions = (0,
|
7359
|
+
const zoomOptions = (0, import_react45.useMemo)(
|
7372
7360
|
() => [
|
7373
7361
|
...defaultZoomOptions,
|
7374
7362
|
...defaultsContainAutoZoom ? [] : [
|
@@ -7515,17 +7503,17 @@ var Canvas = () => {
|
|
7515
7503
|
viewports: s.state.ui.viewports
|
7516
7504
|
}))
|
7517
7505
|
);
|
7518
|
-
const frameRef = (0,
|
7519
|
-
const [showTransition, setShowTransition] = (0,
|
7520
|
-
const defaultRender = (0,
|
7506
|
+
const frameRef = (0, import_react46.useRef)(null);
|
7507
|
+
const [showTransition, setShowTransition] = (0, import_react46.useState)(false);
|
7508
|
+
const defaultRender = (0, import_react46.useMemo)(() => {
|
7521
7509
|
const PuckDefault = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_jsx_runtime36.Fragment, { children });
|
7522
7510
|
return PuckDefault;
|
7523
7511
|
}, []);
|
7524
|
-
const CustomPreview = (0,
|
7512
|
+
const CustomPreview = (0, import_react46.useMemo)(
|
7525
7513
|
() => overrides.preview || defaultRender,
|
7526
7514
|
[overrides]
|
7527
7515
|
);
|
7528
|
-
const getFrameDimensions = (0,
|
7516
|
+
const getFrameDimensions = (0, import_react46.useCallback)(() => {
|
7529
7517
|
if (frameRef.current) {
|
7530
7518
|
const frame = frameRef.current;
|
7531
7519
|
const box = getBox(frame);
|
@@ -7533,7 +7521,7 @@ var Canvas = () => {
|
|
7533
7521
|
}
|
7534
7522
|
return { width: 0, height: 0 };
|
7535
7523
|
}, [frameRef]);
|
7536
|
-
const resetAutoZoom = (0,
|
7524
|
+
const resetAutoZoom = (0, import_react46.useCallback)(
|
7537
7525
|
(newViewports = viewports) => {
|
7538
7526
|
if (frameRef.current) {
|
7539
7527
|
setZoomConfig(
|
@@ -7547,11 +7535,11 @@ var Canvas = () => {
|
|
7547
7535
|
},
|
7548
7536
|
[frameRef, zoomConfig, viewports]
|
7549
7537
|
);
|
7550
|
-
(0,
|
7538
|
+
(0, import_react46.useEffect)(() => {
|
7551
7539
|
setShowTransition(false);
|
7552
7540
|
resetAutoZoom(viewports);
|
7553
7541
|
}, [frameRef, leftSideBarVisible, rightSideBarVisible]);
|
7554
|
-
(0,
|
7542
|
+
(0, import_react46.useEffect)(() => {
|
7555
7543
|
const { height: frameHeight } = getFrameDimensions();
|
7556
7544
|
if (viewports.current.height === "auto") {
|
7557
7545
|
setZoomConfig(__spreadProps(__spreadValues({}, zoomConfig), {
|
@@ -7559,13 +7547,13 @@ var Canvas = () => {
|
|
7559
7547
|
}));
|
7560
7548
|
}
|
7561
7549
|
}, [zoomConfig.zoom]);
|
7562
|
-
(0,
|
7550
|
+
(0, import_react46.useEffect)(() => {
|
7563
7551
|
if (ZOOM_ON_CHANGE) {
|
7564
7552
|
setShowTransition(true);
|
7565
7553
|
resetAutoZoom(viewports);
|
7566
7554
|
}
|
7567
7555
|
}, [viewports.current.width]);
|
7568
|
-
(0,
|
7556
|
+
(0, import_react46.useEffect)(() => {
|
7569
7557
|
const cb = () => {
|
7570
7558
|
setShowTransition(false);
|
7571
7559
|
resetAutoZoom();
|
@@ -7575,8 +7563,8 @@ var Canvas = () => {
|
|
7575
7563
|
window.removeEventListener("resize", cb);
|
7576
7564
|
};
|
7577
7565
|
}, []);
|
7578
|
-
const [showLoader, setShowLoader] = (0,
|
7579
|
-
(0,
|
7566
|
+
const [showLoader, setShowLoader] = (0, import_react46.useState)(false);
|
7567
|
+
(0, import_react46.useEffect)(() => {
|
7580
7568
|
setTimeout(() => {
|
7581
7569
|
setShowLoader(true);
|
7582
7570
|
}, 500);
|
@@ -7654,7 +7642,7 @@ var Canvas = () => {
|
|
7654
7642
|
|
7655
7643
|
// lib/use-loaded-overrides.ts
|
7656
7644
|
init_react_import();
|
7657
|
-
var
|
7645
|
+
var import_react47 = require("react");
|
7658
7646
|
|
7659
7647
|
// lib/load-overrides.ts
|
7660
7648
|
init_react_import();
|
@@ -7693,7 +7681,7 @@ var useLoadedOverrides = ({
|
|
7693
7681
|
overrides,
|
7694
7682
|
plugins
|
7695
7683
|
}) => {
|
7696
|
-
return (0,
|
7684
|
+
return (0, import_react47.useMemo)(() => {
|
7697
7685
|
return loadOverrides({ overrides, plugins });
|
7698
7686
|
}, [plugins, overrides]);
|
7699
7687
|
};
|
@@ -7705,14 +7693,14 @@ var DefaultOverride = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime37
|
|
7705
7693
|
|
7706
7694
|
// lib/use-inject-css.ts
|
7707
7695
|
init_react_import();
|
7708
|
-
var
|
7696
|
+
var import_react48 = require("react");
|
7709
7697
|
var styles = ``;
|
7710
7698
|
var useInjectStyleSheet = (initialStyles, iframeEnabled) => {
|
7711
|
-
const [el, setEl] = (0,
|
7712
|
-
(0,
|
7699
|
+
const [el, setEl] = (0, import_react48.useState)();
|
7700
|
+
(0, import_react48.useEffect)(() => {
|
7713
7701
|
setEl(document.createElement("style"));
|
7714
7702
|
}, []);
|
7715
|
-
(0,
|
7703
|
+
(0, import_react48.useEffect)(() => {
|
7716
7704
|
var _a;
|
7717
7705
|
if (!el || typeof window === "undefined") {
|
7718
7706
|
return;
|
@@ -7732,10 +7720,10 @@ var useInjectGlobalCss = (iframeEnabled) => {
|
|
7732
7720
|
|
7733
7721
|
// lib/use-preview-mode-hotkeys.ts
|
7734
7722
|
init_react_import();
|
7735
|
-
var
|
7723
|
+
var import_react49 = require("react");
|
7736
7724
|
var usePreviewModeHotkeys = () => {
|
7737
7725
|
const appStore = useAppStoreApi();
|
7738
|
-
const toggleInteractive = (0,
|
7726
|
+
const toggleInteractive = (0, import_react49.useCallback)(() => {
|
7739
7727
|
const dispatch = appStore.getState().dispatch;
|
7740
7728
|
dispatch({
|
7741
7729
|
type: "setUi",
|
@@ -7750,7 +7738,7 @@ var usePreviewModeHotkeys = () => {
|
|
7750
7738
|
|
7751
7739
|
// lib/use-puck.ts
|
7752
7740
|
init_react_import();
|
7753
|
-
var
|
7741
|
+
var import_react50 = require("react");
|
7754
7742
|
var import_zustand6 = require("zustand");
|
7755
7743
|
var generateUsePuck = (store) => {
|
7756
7744
|
const history = {
|
@@ -7775,14 +7763,14 @@ var generateUsePuck = (store) => {
|
|
7775
7763
|
const get = () => storeData;
|
7776
7764
|
return __spreadProps(__spreadValues({}, storeData), { get });
|
7777
7765
|
};
|
7778
|
-
var UsePuckStoreContext = (0,
|
7766
|
+
var UsePuckStoreContext = (0, import_react50.createContext)(
|
7779
7767
|
null
|
7780
7768
|
);
|
7781
7769
|
var useRegisterUsePuckStore = (appStore) => {
|
7782
|
-
const [usePuckStore] = (0,
|
7770
|
+
const [usePuckStore] = (0, import_react50.useState)(
|
7783
7771
|
() => (0, import_zustand6.createStore)(() => generateUsePuck(appStore.getState()))
|
7784
7772
|
);
|
7785
|
-
(0,
|
7773
|
+
(0, import_react50.useEffect)(() => {
|
7786
7774
|
return appStore.subscribe(
|
7787
7775
|
(store) => {
|
7788
7776
|
const pickedStore = {
|
@@ -7804,7 +7792,7 @@ var useRegisterUsePuckStore = (appStore) => {
|
|
7804
7792
|
};
|
7805
7793
|
function createUsePuck() {
|
7806
7794
|
return function usePuck2(selector) {
|
7807
|
-
const usePuckApi = (0,
|
7795
|
+
const usePuckApi = (0, import_react50.useContext)(UsePuckStoreContext);
|
7808
7796
|
if (!usePuckApi) {
|
7809
7797
|
throw new Error("usePuck must be used inside <Puck>.");
|
7810
7798
|
}
|
@@ -7816,7 +7804,7 @@ function createUsePuck() {
|
|
7816
7804
|
};
|
7817
7805
|
}
|
7818
7806
|
function usePuck() {
|
7819
|
-
(0,
|
7807
|
+
(0, import_react50.useEffect)(() => {
|
7820
7808
|
console.warn(
|
7821
7809
|
"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."
|
7822
7810
|
);
|
@@ -7837,11 +7825,11 @@ var FieldSideBar = () => {
|
|
7837
7825
|
);
|
7838
7826
|
return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(SidebarSection, { noPadding: true, noBorderTop: true, showBreadcrumbs: true, title, children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(Fields, {}) });
|
7839
7827
|
};
|
7840
|
-
var propsContext = (0,
|
7828
|
+
var propsContext = (0, import_react51.createContext)({});
|
7841
7829
|
function PropsProvider(props) {
|
7842
7830
|
return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(propsContext.Provider, { value: props, children: props.children });
|
7843
7831
|
}
|
7844
|
-
var usePropsContext = () => (0,
|
7832
|
+
var usePropsContext = () => (0, import_react51.useContext)(propsContext);
|
7845
7833
|
function PuckProvider({ children }) {
|
7846
7834
|
const {
|
7847
7835
|
config,
|
@@ -7861,7 +7849,7 @@ function PuckProvider({ children }) {
|
|
7861
7849
|
enabled: true,
|
7862
7850
|
waitForStyles: true
|
7863
7851
|
}, _iframe);
|
7864
|
-
const [generatedAppState] = (0,
|
7852
|
+
const [generatedAppState] = (0, import_react51.useState)(() => {
|
7865
7853
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
7866
7854
|
const initial = __spreadValues(__spreadValues({}, defaultAppState.ui), initialUi);
|
7867
7855
|
let clientUiState = {};
|
@@ -7933,7 +7921,7 @@ function PuckProvider({ children }) {
|
|
7933
7921
|
overrides,
|
7934
7922
|
plugins
|
7935
7923
|
});
|
7936
|
-
const generateAppStore = (0,
|
7924
|
+
const generateAppStore = (0, import_react51.useCallback)(() => {
|
7937
7925
|
return {
|
7938
7926
|
state: initialAppState,
|
7939
7927
|
config,
|
@@ -7954,8 +7942,8 @@ function PuckProvider({ children }) {
|
|
7954
7942
|
onAction,
|
7955
7943
|
metadata
|
7956
7944
|
]);
|
7957
|
-
const [appStore] = (0,
|
7958
|
-
(0,
|
7945
|
+
const [appStore] = (0, import_react51.useState)(() => createAppStore(generateAppStore()));
|
7946
|
+
(0, import_react51.useEffect)(() => {
|
7959
7947
|
appStore.setState(__spreadValues({}, generateAppStore()));
|
7960
7948
|
}, [
|
7961
7949
|
initialAppState,
|
@@ -7972,7 +7960,7 @@ function PuckProvider({ children }) {
|
|
7972
7960
|
index: initialHistoryIndex,
|
7973
7961
|
initialAppState
|
7974
7962
|
});
|
7975
|
-
(0,
|
7963
|
+
(0, import_react51.useEffect)(() => {
|
7976
7964
|
appStore.subscribe((s) => {
|
7977
7965
|
if (onChange) onChange(s.state.data);
|
7978
7966
|
});
|
@@ -7980,7 +7968,7 @@ function PuckProvider({ children }) {
|
|
7980
7968
|
useRegisterNodesSlice(appStore);
|
7981
7969
|
useRegisterPermissionsSlice(appStore, permissions);
|
7982
7970
|
const uPuckStore = useRegisterUsePuckStore(appStore);
|
7983
|
-
(0,
|
7971
|
+
(0, import_react51.useEffect)(() => {
|
7984
7972
|
const { state, resolveData: resolveData2 } = appStore.getState();
|
7985
7973
|
resolveData2(state);
|
7986
7974
|
}, []);
|
@@ -8007,9 +7995,9 @@ function PuckLayout({ children }) {
|
|
8007
7995
|
const rightSideBarVisible = useAppStore(
|
8008
7996
|
(s) => s.state.ui.rightSideBarVisible
|
8009
7997
|
);
|
8010
|
-
const [menuOpen, setMenuOpen] = (0,
|
7998
|
+
const [menuOpen, setMenuOpen] = (0, import_react51.useState)(false);
|
8011
7999
|
const appStore = useAppStoreApi();
|
8012
|
-
(0,
|
8000
|
+
(0, import_react51.useEffect)(() => {
|
8013
8001
|
return appStore.subscribe((s) => {
|
8014
8002
|
if (onChange) onChange(s.state.data);
|
8015
8003
|
});
|
@@ -8018,7 +8006,7 @@ function PuckLayout({ children }) {
|
|
8018
8006
|
(s) => s.state.data.root.props || s.state.data.root.props
|
8019
8007
|
);
|
8020
8008
|
const dispatch = useAppStore((s) => s.dispatch);
|
8021
|
-
const toggleSidebars = (0,
|
8009
|
+
const toggleSidebars = (0, import_react51.useCallback)(
|
8022
8010
|
(sidebar) => {
|
8023
8011
|
const widerViewport = window.matchMedia("(min-width: 638px)").matches;
|
8024
8012
|
const sideBarVisible = sidebar === "left" ? leftSideBarVisible : rightSideBarVisible;
|
@@ -8032,7 +8020,7 @@ function PuckLayout({ children }) {
|
|
8032
8020
|
},
|
8033
8021
|
[dispatch, leftSideBarVisible, rightSideBarVisible]
|
8034
8022
|
);
|
8035
|
-
(0,
|
8023
|
+
(0, import_react51.useEffect)(() => {
|
8036
8024
|
if (!window.matchMedia("(min-width: 638px)").matches) {
|
8037
8025
|
dispatch({
|
8038
8026
|
type: "setUi",
|
@@ -8055,7 +8043,7 @@ function PuckLayout({ children }) {
|
|
8055
8043
|
window.removeEventListener("resize", handleResize);
|
8056
8044
|
};
|
8057
8045
|
}, []);
|
8058
|
-
const defaultHeaderRender = (0,
|
8046
|
+
const defaultHeaderRender = (0, import_react51.useMemo)(() => {
|
8059
8047
|
if (renderHeader) {
|
8060
8048
|
console.warn(
|
8061
8049
|
"`renderHeader` is deprecated. Please use `overrides.header` and the `usePuck` hook instead"
|
@@ -8070,7 +8058,7 @@ function PuckLayout({ children }) {
|
|
8070
8058
|
}
|
8071
8059
|
return DefaultOverride;
|
8072
8060
|
}, [renderHeader]);
|
8073
|
-
const defaultHeaderActionsRender = (0,
|
8061
|
+
const defaultHeaderActionsRender = (0, import_react51.useMemo)(() => {
|
8074
8062
|
if (renderHeaderActions) {
|
8075
8063
|
console.warn(
|
8076
8064
|
"`renderHeaderActions` is deprecated. Please use `overrides.headerActions` and the `usePuck` hook instead."
|
@@ -8085,25 +8073,25 @@ function PuckLayout({ children }) {
|
|
8085
8073
|
return DefaultOverride;
|
8086
8074
|
}, [renderHeader]);
|
8087
8075
|
const overrides = useAppStore((s) => s.overrides);
|
8088
|
-
const CustomPuck = (0,
|
8076
|
+
const CustomPuck = (0, import_react51.useMemo)(
|
8089
8077
|
() => overrides.puck || DefaultOverride,
|
8090
8078
|
[overrides]
|
8091
8079
|
);
|
8092
|
-
const CustomHeader = (0,
|
8080
|
+
const CustomHeader = (0, import_react51.useMemo)(
|
8093
8081
|
() => overrides.header || defaultHeaderRender,
|
8094
8082
|
[overrides]
|
8095
8083
|
);
|
8096
|
-
const CustomHeaderActions = (0,
|
8084
|
+
const CustomHeaderActions = (0, import_react51.useMemo)(
|
8097
8085
|
() => overrides.headerActions || defaultHeaderActionsRender,
|
8098
8086
|
[overrides]
|
8099
8087
|
);
|
8100
|
-
const [mounted, setMounted] = (0,
|
8101
|
-
(0,
|
8088
|
+
const [mounted, setMounted] = (0, import_react51.useState)(false);
|
8089
|
+
(0, import_react51.useEffect)(() => {
|
8102
8090
|
setMounted(true);
|
8103
8091
|
}, []);
|
8104
8092
|
const ready = useAppStore((s) => s.status === "READY");
|
8105
8093
|
useMonitorHotkeys();
|
8106
|
-
(0,
|
8094
|
+
(0, import_react51.useEffect)(() => {
|
8107
8095
|
if (ready && iframe.enabled) {
|
8108
8096
|
const frameDoc = getFrame();
|
8109
8097
|
if (frameDoc) {
|