@measured/puck 0.19.0-canary.de23f9d → 0.19.0-canary.e62832e
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 +410 -365
- package/dist/index.mjs +267 -257
- package/dist/{resolve-all-data-wwgDuTnC.d.mts → resolve-all-data-3XjIPfNh.d.mts} +13 -1
- package/dist/{resolve-all-data-wwgDuTnC.d.ts → resolve-all-data-3XjIPfNh.d.ts} +13 -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 +4 -3
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
|
}
|
@@ -2145,6 +2145,7 @@ var _PointerSensor = class _PointerSensor extends import_abstract.Sensor {
|
|
2145
2145
|
this.listeners = new import_utilities.Listeners();
|
2146
2146
|
this.cleanup = /* @__PURE__ */ new Set();
|
2147
2147
|
this.source = void 0;
|
2148
|
+
this.started = false;
|
2148
2149
|
__privateAdd(this, _clearTimeout);
|
2149
2150
|
this.handleCancel = this.handleCancel.bind(this);
|
2150
2151
|
this.handlePointerUp = this.handlePointerUp.bind(this);
|
@@ -2302,6 +2303,12 @@ var _PointerSensor = class _PointerSensor extends import_abstract.Sensor {
|
|
2302
2303
|
if (!status.idle) {
|
2303
2304
|
const canceled = !status.initialized;
|
2304
2305
|
this.manager.actions.stop({ canceled });
|
2306
|
+
} else if (this.started) {
|
2307
|
+
setTimeout(() => {
|
2308
|
+
if (!this.manager.dragOperation.status.idle) {
|
2309
|
+
this.manager.actions.stop({ canceled: false });
|
2310
|
+
}
|
2311
|
+
}, 10);
|
2305
2312
|
}
|
2306
2313
|
this.cleanup.forEach((cleanup) => cleanup());
|
2307
2314
|
this.cleanup.clear();
|
@@ -2316,12 +2323,13 @@ var _PointerSensor = class _PointerSensor extends import_abstract.Sensor {
|
|
2316
2323
|
var _a;
|
2317
2324
|
const { manager, initialCoordinates } = this;
|
2318
2325
|
(_a = __privateGet(this, _clearTimeout)) == null ? void 0 : _a.call(this);
|
2319
|
-
if (!initialCoordinates || manager.dragOperation.status.initialized) {
|
2326
|
+
if (!initialCoordinates || manager.dragOperation.status.initialized || this.started) {
|
2320
2327
|
return;
|
2321
2328
|
}
|
2322
2329
|
if (event.defaultPrevented) {
|
2323
2330
|
return;
|
2324
2331
|
}
|
2332
|
+
this.started = true;
|
2325
2333
|
event.preventDefault();
|
2326
2334
|
(0, import_state2.batch)(() => {
|
2327
2335
|
manager.actions.setDragSource(source.id);
|
@@ -2349,6 +2357,9 @@ var _PointerSensor = class _PointerSensor extends import_abstract.Sensor {
|
|
2349
2357
|
]);
|
2350
2358
|
ownerDocument.body.setPointerCapture(event.pointerId);
|
2351
2359
|
this.cleanup.add(unbind);
|
2360
|
+
this.cleanup.add(() => {
|
2361
|
+
this.started = false;
|
2362
|
+
});
|
2352
2363
|
}
|
2353
2364
|
handleDragStart(event) {
|
2354
2365
|
const { target } = event;
|
@@ -2396,23 +2407,26 @@ function patchWindow(window2) {
|
|
2396
2407
|
|
2397
2408
|
// lib/dnd/use-sensors.ts
|
2398
2409
|
var import_utilities2 = require("@dnd-kit/dom/utilities");
|
2399
|
-
var useSensors = (
|
2410
|
+
var useSensors = ({
|
2411
|
+
other,
|
2412
|
+
mouse,
|
2413
|
+
touch
|
2414
|
+
} = {
|
2415
|
+
touch: { delay: { value: 200, tolerance: 10 } },
|
2416
|
+
other: { delay: { value: 200, tolerance: 10 }, distance: { value: 5 } }
|
2417
|
+
}) => {
|
2400
2418
|
const [sensors] = (0, import_react12.useState)(() => [
|
2401
2419
|
PointerSensor.configure({
|
2402
2420
|
activationConstraints(event, source) {
|
2403
2421
|
var _a;
|
2404
2422
|
const { pointerType, target } = event;
|
2405
2423
|
if (pointerType === "mouse" && (0, import_utilities2.isElement)(target) && (source.handle === target || ((_a = source.handle) == null ? void 0 : _a.contains(target)))) {
|
2406
|
-
return
|
2424
|
+
return mouse;
|
2407
2425
|
}
|
2408
|
-
const delay = { value: 200, tolerance: 10 };
|
2409
2426
|
if (pointerType === "touch") {
|
2410
|
-
return
|
2427
|
+
return touch;
|
2411
2428
|
}
|
2412
|
-
return
|
2413
|
-
delay,
|
2414
|
-
distance: { value: 5 }
|
2415
|
-
};
|
2429
|
+
return other;
|
2416
2430
|
}
|
2417
2431
|
})
|
2418
2432
|
]);
|
@@ -2755,7 +2769,6 @@ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input
|
|
2755
2769
|
};
|
2756
2770
|
|
2757
2771
|
// components/Sortable/index.tsx
|
2758
|
-
var import_modifiers = require("@dnd-kit/dom/modifiers");
|
2759
2772
|
var import_jsx_runtime5 = require("react/jsx-runtime");
|
2760
2773
|
var SortableProvider = ({
|
2761
2774
|
children,
|
@@ -2763,22 +2776,20 @@ var SortableProvider = ({
|
|
2763
2776
|
onDragEnd,
|
2764
2777
|
onMove
|
2765
2778
|
}) => {
|
2766
|
-
const
|
2767
|
-
|
2779
|
+
const sensors = useSensors({
|
2780
|
+
mouse: { distance: { value: 5 } }
|
2781
|
+
});
|
2768
2782
|
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
2769
2783
|
import_react13.DragDropProvider,
|
2770
2784
|
{
|
2771
2785
|
sensors,
|
2772
|
-
|
2773
|
-
|
2774
|
-
|
2775
|
-
|
2776
|
-
}
|
2777
|
-
})
|
2778
|
-
],
|
2779
|
-
onDragStart,
|
2786
|
+
onDragStart: (event) => {
|
2787
|
+
var _a, _b;
|
2788
|
+
return onDragStart((_b = (_a = event.operation.source) == null ? void 0 : _a.id.toString()) != null ? _b : "");
|
2789
|
+
},
|
2780
2790
|
onDragOver: (event, manager) => {
|
2781
2791
|
var _a, _b;
|
2792
|
+
event.preventDefault();
|
2782
2793
|
const { operation } = event;
|
2783
2794
|
const { source, target } = operation;
|
2784
2795
|
if (!source || !target) return;
|
@@ -2786,14 +2797,14 @@ var SortableProvider = ({
|
|
2786
2797
|
let targetIndex = target.data.index;
|
2787
2798
|
const collisionData = (_b = (_a = manager.dragOperation.data) == null ? void 0 : _a.collisionMap) == null ? void 0 : _b[target.id];
|
2788
2799
|
if (sourceIndex !== targetIndex && source.id !== target.id) {
|
2789
|
-
const collisionPosition =
|
2800
|
+
const collisionPosition = collisionData.direction === "up" ? "before" : "after";
|
2790
2801
|
if (targetIndex >= sourceIndex) {
|
2791
2802
|
targetIndex = targetIndex - 1;
|
2792
2803
|
}
|
2793
2804
|
if (collisionPosition === "after") {
|
2794
2805
|
targetIndex = targetIndex + 1;
|
2795
2806
|
}
|
2796
|
-
|
2807
|
+
onMove({
|
2797
2808
|
source: sourceIndex,
|
2798
2809
|
target: targetIndex
|
2799
2810
|
});
|
@@ -2801,12 +2812,8 @@ var SortableProvider = ({
|
|
2801
2812
|
},
|
2802
2813
|
onDragEnd: () => {
|
2803
2814
|
setTimeout(() => {
|
2804
|
-
if (move.source !== -1 && move.target !== -1) {
|
2805
|
-
onMove(move);
|
2806
|
-
}
|
2807
2815
|
onDragEnd();
|
2808
2816
|
}, 250);
|
2809
|
-
setMove({ source: -1, target: -1 });
|
2810
2817
|
},
|
2811
2818
|
children
|
2812
2819
|
}
|
@@ -2819,7 +2826,11 @@ var Sortable = ({
|
|
2819
2826
|
children,
|
2820
2827
|
type = "item"
|
2821
2828
|
}) => {
|
2822
|
-
const {
|
2829
|
+
const {
|
2830
|
+
ref: sortableRef,
|
2831
|
+
status,
|
2832
|
+
handleRef
|
2833
|
+
} = useSortableSafe({
|
2823
2834
|
id,
|
2824
2835
|
type,
|
2825
2836
|
index,
|
@@ -2827,16 +2838,16 @@ var Sortable = ({
|
|
2827
2838
|
data: { index },
|
2828
2839
|
collisionDetector: createDynamicCollisionDetector("y")
|
2829
2840
|
});
|
2830
|
-
return children({ status, ref: sortableRef });
|
2841
|
+
return children({ status, ref: sortableRef, handleRef });
|
2831
2842
|
};
|
2832
2843
|
|
2833
2844
|
// components/AutoField/context.tsx
|
2834
2845
|
init_react_import();
|
2835
|
-
var
|
2846
|
+
var import_react14 = require("react");
|
2836
2847
|
var import_jsx_runtime6 = require("react/jsx-runtime");
|
2837
|
-
var NestedFieldContext = (0,
|
2848
|
+
var NestedFieldContext = (0, import_react14.createContext)({});
|
2838
2849
|
var useNestedFieldContext = () => {
|
2839
|
-
const context = (0,
|
2850
|
+
const context = (0, import_react14.useContext)(NestedFieldContext);
|
2840
2851
|
return __spreadProps(__spreadValues({}, context), {
|
2841
2852
|
readOnlyFields: context.readOnlyFields || {}
|
2842
2853
|
});
|
@@ -2850,7 +2861,7 @@ var NestedFieldProvider = ({
|
|
2850
2861
|
}) => {
|
2851
2862
|
const subPath = `${name}.${subName}`;
|
2852
2863
|
const wildcardSubPath = `${wildcardName}.${subName}`;
|
2853
|
-
const subReadOnlyFields = (0,
|
2864
|
+
const subReadOnlyFields = (0, import_react14.useMemo)(
|
2854
2865
|
() => Object.keys(readOnlyFields).reduce((acc, readOnlyKey) => {
|
2855
2866
|
const isLocal = readOnlyKey.indexOf(subPath) > -1 || readOnlyKey.indexOf(wildcardSubPath) > -1;
|
2856
2867
|
if (isLocal) {
|
@@ -2885,6 +2896,7 @@ var ArrayField = ({
|
|
2885
2896
|
value: _value,
|
2886
2897
|
name,
|
2887
2898
|
label,
|
2899
|
+
labelIcon,
|
2888
2900
|
readOnly,
|
2889
2901
|
id,
|
2890
2902
|
Label: Label2 = (props) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", __spreadValues({}, props))
|
@@ -2902,12 +2914,14 @@ var ArrayField = ({
|
|
2902
2914
|
}),
|
2903
2915
|
openId: ""
|
2904
2916
|
};
|
2905
|
-
const [localState, setLocalState] = (0,
|
2906
|
-
(0,
|
2907
|
-
|
2908
|
-
|
2917
|
+
const [localState, setLocalState] = (0, import_react15.useState)({ arrayState, value });
|
2918
|
+
(0, import_react15.useEffect)(() => {
|
2919
|
+
var _a;
|
2920
|
+
const _arrayState = (_a = appStore.getState().state.ui.arrayState[id]) != null ? _a : arrayState;
|
2921
|
+
setLocalState({ arrayState: _arrayState, value });
|
2922
|
+
}, [value]);
|
2909
2923
|
const appStore = useAppStoreApi();
|
2910
|
-
const mapArrayStateToUi = (0,
|
2924
|
+
const mapArrayStateToUi = (0, import_react15.useCallback)(
|
2911
2925
|
(partialArrayState) => {
|
2912
2926
|
const state = appStore.getState().state;
|
2913
2927
|
return {
|
@@ -2918,13 +2932,13 @@ var ArrayField = ({
|
|
2918
2932
|
},
|
2919
2933
|
[arrayState, appStore]
|
2920
2934
|
);
|
2921
|
-
const getHighestIndex = (0,
|
2935
|
+
const getHighestIndex = (0, import_react15.useCallback)(() => {
|
2922
2936
|
return arrayState.items.reduce(
|
2923
2937
|
(acc, item) => item._originalIndex > acc ? item._originalIndex : acc,
|
2924
2938
|
-1
|
2925
2939
|
);
|
2926
2940
|
}, [arrayState]);
|
2927
|
-
const regenerateArrayState = (0,
|
2941
|
+
const regenerateArrayState = (0, import_react15.useCallback)(
|
2928
2942
|
(value2) => {
|
2929
2943
|
let highestIndex = getHighestIndex();
|
2930
2944
|
const newItems = Array.from(value2 || []).map((item, idx) => {
|
@@ -2943,12 +2957,13 @@ var ArrayField = ({
|
|
2943
2957
|
},
|
2944
2958
|
[arrayState]
|
2945
2959
|
);
|
2946
|
-
(0,
|
2960
|
+
(0, import_react15.useEffect)(() => {
|
2947
2961
|
if (arrayState.items.length > 0) {
|
2948
2962
|
setUi(mapArrayStateToUi(arrayState));
|
2949
2963
|
}
|
2950
2964
|
}, []);
|
2951
|
-
const [
|
2965
|
+
const [draggedItem, setDraggedItem] = (0, import_react15.useState)("");
|
2966
|
+
const isDragging = !!draggedItem;
|
2952
2967
|
const canEdit = useAppStore(
|
2953
2968
|
(s) => s.permissions.getPermissions({ item: s.selectedItem }).edit
|
2954
2969
|
);
|
@@ -2961,16 +2976,22 @@ var ArrayField = ({
|
|
2961
2976
|
Label2,
|
2962
2977
|
{
|
2963
2978
|
label: label || name,
|
2964
|
-
icon: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(List, { size: 16 }),
|
2979
|
+
icon: labelIcon || /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(List, { size: 16 }),
|
2965
2980
|
el: "div",
|
2966
2981
|
readOnly,
|
2967
2982
|
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
2968
2983
|
SortableProvider,
|
2969
2984
|
{
|
2970
|
-
onDragStart: () =>
|
2971
|
-
onDragEnd: () =>
|
2985
|
+
onDragStart: (id2) => setDraggedItem(id2),
|
2986
|
+
onDragEnd: () => {
|
2987
|
+
setDraggedItem("");
|
2988
|
+
onChange(localState.value);
|
2989
|
+
},
|
2972
2990
|
onMove: (move) => {
|
2973
|
-
|
2991
|
+
if (arrayState.items[move.source]._arrayId !== draggedItem) {
|
2992
|
+
return;
|
2993
|
+
}
|
2994
|
+
const newValue = reorder(localState.value, move.source, move.target);
|
2974
2995
|
const newArrayStateItems = reorder(
|
2975
2996
|
arrayState.items,
|
2976
2997
|
move.source,
|
@@ -2983,7 +3004,6 @@ var ArrayField = ({
|
|
2983
3004
|
})
|
2984
3005
|
};
|
2985
3006
|
setUi(newUi, false);
|
2986
|
-
onChange(newValue, newUi);
|
2987
3007
|
setLocalState({
|
2988
3008
|
value: newValue,
|
2989
3009
|
arrayState: __spreadProps(__spreadValues({}, arrayState), { items: newArrayStateItems })
|
@@ -2996,11 +3016,8 @@ var ArrayField = ({
|
|
2996
3016
|
hasItems: Array.isArray(value) && value.length > 0,
|
2997
3017
|
addDisabled
|
2998
3018
|
}),
|
2999
|
-
onClick: (e) => {
|
3000
|
-
e.preventDefault();
|
3001
|
-
},
|
3002
3019
|
children: [
|
3003
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: getClassName5("inner"), "data-dnd-container": true, children: localState.arrayState.items.map((item, i) => {
|
3020
|
+
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) => {
|
3004
3021
|
const { _arrayId = `${id}-${i}`, _originalIndex = i } = item;
|
3005
3022
|
const data = Array.from(localState.value || [])[i] || {};
|
3006
3023
|
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
@@ -3009,7 +3026,7 @@ var ArrayField = ({
|
|
3009
3026
|
id: _arrayId,
|
3010
3027
|
index: i,
|
3011
3028
|
disabled: readOnly,
|
3012
|
-
children: ({ status, ref }) => /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
3029
|
+
children: ({ status, ref, handleRef }) => /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
3013
3030
|
"div",
|
3014
3031
|
{
|
3015
3032
|
ref,
|
@@ -3022,6 +3039,7 @@ var ArrayField = ({
|
|
3022
3039
|
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
3023
3040
|
"div",
|
3024
3041
|
{
|
3042
|
+
ref: handleRef,
|
3025
3043
|
onClick: (e) => {
|
3026
3044
|
if (isDragging) return;
|
3027
3045
|
e.preventDefault();
|
@@ -3058,12 +3076,11 @@ var ArrayField = ({
|
|
3058
3076
|
0,
|
3059
3077
|
existingValue[i]
|
3060
3078
|
);
|
3061
|
-
|
3062
|
-
existingValue
|
3063
|
-
mapArrayStateToUi(
|
3064
|
-
regenerateArrayState(existingValue)
|
3065
|
-
)
|
3079
|
+
const newUi = mapArrayStateToUi(
|
3080
|
+
regenerateArrayState(existingValue)
|
3066
3081
|
);
|
3082
|
+
setUi(newUi, false);
|
3083
|
+
onChange(existingValue);
|
3067
3084
|
},
|
3068
3085
|
title: "Duplicate",
|
3069
3086
|
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Copy, { size: 16 })
|
@@ -3082,12 +3099,13 @@ var ArrayField = ({
|
|
3082
3099
|
];
|
3083
3100
|
existingValue.splice(i, 1);
|
3084
3101
|
existingItems.splice(i, 1);
|
3085
|
-
|
3086
|
-
existingValue,
|
3102
|
+
setUi(
|
3087
3103
|
mapArrayStateToUi({
|
3088
3104
|
items: existingItems
|
3089
|
-
})
|
3105
|
+
}),
|
3106
|
+
false
|
3090
3107
|
);
|
3108
|
+
onChange(existingValue);
|
3091
3109
|
},
|
3092
3110
|
title: "Delete",
|
3093
3111
|
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Trash, { size: 16 })
|
@@ -3099,58 +3117,49 @@ var ArrayField = ({
|
|
3099
3117
|
]
|
3100
3118
|
}
|
3101
3119
|
),
|
3102
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: getClassNameItem("body"), children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
3103
|
-
|
3104
|
-
{
|
3105
|
-
|
3106
|
-
|
3107
|
-
|
3108
|
-
|
3109
|
-
|
3110
|
-
|
3111
|
-
|
3112
|
-
|
3113
|
-
|
3114
|
-
|
3115
|
-
|
3116
|
-
|
3117
|
-
|
3118
|
-
|
3119
|
-
|
3120
|
-
|
3120
|
+
/* @__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) => {
|
3121
|
+
const subField = field.arrayFields[subName];
|
3122
|
+
const indexName = `${name}[${i}]`;
|
3123
|
+
const subPath = `${indexName}.${subName}`;
|
3124
|
+
const localIndexName = `${localName}[${i}]`;
|
3125
|
+
const localWildcardName = `${localName}[*]`;
|
3126
|
+
const localSubPath = `${localIndexName}.${subName}`;
|
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,
|
3121
3139
|
{
|
3122
|
-
name:
|
3123
|
-
|
3124
|
-
subName
|
3125
|
-
|
3126
|
-
|
3127
|
-
|
3128
|
-
|
3129
|
-
|
3130
|
-
|
3131
|
-
|
3132
|
-
|
3133
|
-
|
3134
|
-
|
3135
|
-
|
3136
|
-
|
3137
|
-
|
3138
|
-
|
3139
|
-
|
3140
|
-
|
3141
|
-
|
3142
|
-
|
3143
|
-
|
3144
|
-
|
3145
|
-
}
|
3146
|
-
}
|
3147
|
-
)
|
3148
|
-
},
|
3149
|
-
subPath
|
3150
|
-
);
|
3151
|
-
})
|
3152
|
-
}
|
3153
|
-
) })
|
3140
|
+
name: subPath,
|
3141
|
+
label: label2,
|
3142
|
+
id: `${_arrayId}_${subName}`,
|
3143
|
+
readOnly: subReadOnly,
|
3144
|
+
field: __spreadProps(__spreadValues({}, subField), {
|
3145
|
+
label: label2
|
3146
|
+
// May be used by custom fields
|
3147
|
+
}),
|
3148
|
+
value: data[subName],
|
3149
|
+
onChange: (val, ui) => {
|
3150
|
+
onChange(
|
3151
|
+
replace(value, i, __spreadProps(__spreadValues({}, data), {
|
3152
|
+
[subName]: val
|
3153
|
+
})),
|
3154
|
+
ui
|
3155
|
+
);
|
3156
|
+
}
|
3157
|
+
}
|
3158
|
+
)
|
3159
|
+
},
|
3160
|
+
subPath
|
3161
|
+
);
|
3162
|
+
}) }) })
|
3154
3163
|
]
|
3155
3164
|
}
|
3156
3165
|
)
|
@@ -3171,7 +3180,8 @@ var ArrayField = ({
|
|
3171
3180
|
field.defaultItemProps || {}
|
3172
3181
|
];
|
3173
3182
|
const newArrayState = regenerateArrayState(newValue);
|
3174
|
-
|
3183
|
+
setUi(mapArrayStateToUi(newArrayState), false);
|
3184
|
+
onChange(newValue);
|
3175
3185
|
},
|
3176
3186
|
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Plus, { size: 21 })
|
3177
3187
|
}
|
@@ -3196,6 +3206,7 @@ var DefaultField = ({
|
|
3196
3206
|
value: _value,
|
3197
3207
|
name,
|
3198
3208
|
label,
|
3209
|
+
labelIcon,
|
3199
3210
|
Label: Label2,
|
3200
3211
|
id
|
3201
3212
|
}) => {
|
@@ -3204,7 +3215,7 @@ var DefaultField = ({
|
|
3204
3215
|
Label2,
|
3205
3216
|
{
|
3206
3217
|
label: label || name,
|
3207
|
-
icon: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
|
3218
|
+
icon: labelIcon || /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
|
3208
3219
|
field.type === "text" && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Type, { size: 16 }),
|
3209
3220
|
field.type === "number" && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Hash, { size: 16 })
|
3210
3221
|
] }),
|
@@ -3247,11 +3258,11 @@ var DefaultField = ({
|
|
3247
3258
|
|
3248
3259
|
// components/AutoField/fields/ExternalField/index.tsx
|
3249
3260
|
init_react_import();
|
3250
|
-
var
|
3261
|
+
var import_react19 = require("react");
|
3251
3262
|
|
3252
3263
|
// components/ExternalInput/index.tsx
|
3253
3264
|
init_react_import();
|
3254
|
-
var
|
3265
|
+
var import_react18 = require("react");
|
3255
3266
|
|
3256
3267
|
// css-module:/home/runner/work/puck/puck/packages/core/components/ExternalInput/styles.module.css#css-module
|
3257
3268
|
init_react_import();
|
@@ -3259,7 +3270,7 @@ var styles_module_default6 = { "ExternalInput-actions": "_ExternalInput-actions_
|
|
3259
3270
|
|
3260
3271
|
// components/Modal/index.tsx
|
3261
3272
|
init_react_import();
|
3262
|
-
var
|
3273
|
+
var import_react16 = require("react");
|
3263
3274
|
|
3264
3275
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Modal/styles.module.css#css-module
|
3265
3276
|
init_react_import();
|
@@ -3274,8 +3285,8 @@ var Modal = ({
|
|
3274
3285
|
onClose,
|
3275
3286
|
isOpen
|
3276
3287
|
}) => {
|
3277
|
-
const [rootEl, setRootEl] = (0,
|
3278
|
-
(0,
|
3288
|
+
const [rootEl, setRootEl] = (0, import_react16.useState)(null);
|
3289
|
+
(0, import_react16.useEffect)(() => {
|
3279
3290
|
setRootEl(document.getElementById("puck-portal-root"));
|
3280
3291
|
}, []);
|
3281
3292
|
if (!rootEl) {
|
@@ -3322,7 +3333,7 @@ init_react_import();
|
|
3322
3333
|
|
3323
3334
|
// components/Button/Button.tsx
|
3324
3335
|
init_react_import();
|
3325
|
-
var
|
3336
|
+
var import_react17 = require("react");
|
3326
3337
|
|
3327
3338
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Button/Button.module.css#css-module
|
3328
3339
|
init_react_import();
|
@@ -3372,8 +3383,8 @@ var Button = (_a) => {
|
|
3372
3383
|
"size",
|
3373
3384
|
"loading"
|
3374
3385
|
]);
|
3375
|
-
const [loading, setLoading] = (0,
|
3376
|
-
(0,
|
3386
|
+
const [loading, setLoading] = (0, import_react17.useState)(loadingProp);
|
3387
|
+
(0, import_react17.useEffect)(() => setLoading(loadingProp), [loadingProp]);
|
3377
3388
|
const ElementType = href ? "a" : type ? "button" : "span";
|
3378
3389
|
const dataAttrs = filterDataAttrs(props);
|
3379
3390
|
const el = /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
|
@@ -3428,28 +3439,28 @@ var ExternalInput = ({
|
|
3428
3439
|
mapRow = (val) => val,
|
3429
3440
|
filterFields
|
3430
3441
|
} = field || {};
|
3431
|
-
const [data, setData] = (0,
|
3432
|
-
const [isOpen, setOpen] = (0,
|
3433
|
-
const [isLoading, setIsLoading] = (0,
|
3442
|
+
const [data, setData] = (0, import_react18.useState)([]);
|
3443
|
+
const [isOpen, setOpen] = (0, import_react18.useState)(false);
|
3444
|
+
const [isLoading, setIsLoading] = (0, import_react18.useState)(true);
|
3434
3445
|
const hasFilterFields = !!filterFields;
|
3435
|
-
const [filters, setFilters] = (0,
|
3436
|
-
const [filtersToggled, setFiltersToggled] = (0,
|
3437
|
-
const mappedData = (0,
|
3446
|
+
const [filters, setFilters] = (0, import_react18.useState)(field.initialFilters || {});
|
3447
|
+
const [filtersToggled, setFiltersToggled] = (0, import_react18.useState)(hasFilterFields);
|
3448
|
+
const mappedData = (0, import_react18.useMemo)(() => {
|
3438
3449
|
return data.map(mapRow);
|
3439
3450
|
}, [data]);
|
3440
|
-
const keys = (0,
|
3451
|
+
const keys = (0, import_react18.useMemo)(() => {
|
3441
3452
|
const validKeys = /* @__PURE__ */ new Set();
|
3442
3453
|
for (const item of mappedData) {
|
3443
3454
|
for (const key of Object.keys(item)) {
|
3444
|
-
if (typeof item[key] === "string" || typeof item[key] === "number" || (0,
|
3455
|
+
if (typeof item[key] === "string" || typeof item[key] === "number" || (0, import_react18.isValidElement)(item[key])) {
|
3445
3456
|
validKeys.add(key);
|
3446
3457
|
}
|
3447
3458
|
}
|
3448
3459
|
}
|
3449
3460
|
return Array.from(validKeys);
|
3450
3461
|
}, [mappedData]);
|
3451
|
-
const [searchQuery, setSearchQuery] = (0,
|
3452
|
-
const search = (0,
|
3462
|
+
const [searchQuery, setSearchQuery] = (0, import_react18.useState)(field.initialQuery || "");
|
3463
|
+
const search = (0, import_react18.useCallback)(
|
3453
3464
|
(query, filters2) => __async(void 0, null, function* () {
|
3454
3465
|
setIsLoading(true);
|
3455
3466
|
const cacheKey = `${id}-${query}-${JSON.stringify(filters2)}`;
|
@@ -3462,7 +3473,7 @@ var ExternalInput = ({
|
|
3462
3473
|
}),
|
3463
3474
|
[id, field]
|
3464
3475
|
);
|
3465
|
-
const Footer = (0,
|
3476
|
+
const Footer = (0, import_react18.useCallback)(
|
3466
3477
|
(props) => field.renderFooter ? field.renderFooter(props) : /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("span", { className: getClassNameModal("footer"), children: [
|
3467
3478
|
props.items.length,
|
3468
3479
|
" result",
|
@@ -3470,7 +3481,7 @@ var ExternalInput = ({
|
|
3470
3481
|
] }),
|
3471
3482
|
[field.renderFooter]
|
3472
3483
|
);
|
3473
|
-
(0,
|
3484
|
+
(0, import_react18.useEffect)(() => {
|
3474
3485
|
search(searchQuery, filters);
|
3475
3486
|
}, []);
|
3476
3487
|
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
@@ -3634,6 +3645,7 @@ var ExternalField = ({
|
|
3634
3645
|
value,
|
3635
3646
|
name,
|
3636
3647
|
label,
|
3648
|
+
labelIcon,
|
3637
3649
|
Label: Label2,
|
3638
3650
|
id,
|
3639
3651
|
readOnly
|
@@ -3641,7 +3653,7 @@ var ExternalField = ({
|
|
3641
3653
|
var _a, _b, _c;
|
3642
3654
|
const validField = field;
|
3643
3655
|
const deprecatedField = field;
|
3644
|
-
(0,
|
3656
|
+
(0, import_react19.useEffect)(() => {
|
3645
3657
|
if (deprecatedField.adaptor) {
|
3646
3658
|
console.error(
|
3647
3659
|
"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."
|
@@ -3651,32 +3663,40 @@ var ExternalField = ({
|
|
3651
3663
|
if (field.type !== "external") {
|
3652
3664
|
return null;
|
3653
3665
|
}
|
3654
|
-
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
3655
|
-
|
3666
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
3667
|
+
Label2,
|
3656
3668
|
{
|
3657
|
-
name,
|
3658
|
-
|
3659
|
-
|
3660
|
-
|
3661
|
-
|
3662
|
-
|
3663
|
-
|
3664
|
-
|
3665
|
-
|
3666
|
-
|
3667
|
-
|
3668
|
-
|
3669
|
-
|
3670
|
-
|
3671
|
-
|
3672
|
-
|
3669
|
+
label: label || name,
|
3670
|
+
icon: labelIcon || /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Link, { size: 16 }),
|
3671
|
+
el: "div",
|
3672
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
3673
|
+
ExternalInput,
|
3674
|
+
{
|
3675
|
+
name,
|
3676
|
+
field: __spreadProps(__spreadValues({}, validField), {
|
3677
|
+
// DEPRECATED
|
3678
|
+
placeholder: ((_a = deprecatedField.adaptor) == null ? void 0 : _a.name) ? `Select from ${deprecatedField.adaptor.name}` : validField.placeholder || "Select data",
|
3679
|
+
mapProp: ((_b = deprecatedField.adaptor) == null ? void 0 : _b.mapProp) || validField.mapProp,
|
3680
|
+
mapRow: validField.mapRow,
|
3681
|
+
fetchList: ((_c = deprecatedField.adaptor) == null ? void 0 : _c.fetchList) ? () => __async(void 0, null, function* () {
|
3682
|
+
return yield deprecatedField.adaptor.fetchList(
|
3683
|
+
deprecatedField.adaptorParams
|
3684
|
+
);
|
3685
|
+
}) : validField.fetchList
|
3686
|
+
}),
|
3687
|
+
onChange,
|
3688
|
+
value,
|
3689
|
+
id,
|
3690
|
+
readOnly
|
3691
|
+
}
|
3692
|
+
)
|
3673
3693
|
}
|
3674
|
-
)
|
3694
|
+
);
|
3675
3695
|
};
|
3676
3696
|
|
3677
3697
|
// components/AutoField/fields/RadioField/index.tsx
|
3678
3698
|
init_react_import();
|
3679
|
-
var
|
3699
|
+
var import_react20 = require("react");
|
3680
3700
|
|
3681
3701
|
// lib/safe-json-parse.ts
|
3682
3702
|
init_react_import();
|
@@ -3700,9 +3720,10 @@ var RadioField = ({
|
|
3700
3720
|
name,
|
3701
3721
|
id,
|
3702
3722
|
label,
|
3723
|
+
labelIcon,
|
3703
3724
|
Label: Label2
|
3704
3725
|
}) => {
|
3705
|
-
const flatOptions = (0,
|
3726
|
+
const flatOptions = (0, import_react20.useMemo)(
|
3706
3727
|
() => field.type === "radio" ? field.options.map(({ value: value2 }) => value2) : [],
|
3707
3728
|
[field]
|
3708
3729
|
);
|
@@ -3712,7 +3733,7 @@ var RadioField = ({
|
|
3712
3733
|
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
3713
3734
|
Label2,
|
3714
3735
|
{
|
3715
|
-
icon: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(CircleCheckBig, { size: 16 }),
|
3736
|
+
icon: labelIcon || /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(CircleCheckBig, { size: 16 }),
|
3716
3737
|
label: label || name,
|
3717
3738
|
readOnly,
|
3718
3739
|
el: "div",
|
@@ -3752,20 +3773,21 @@ var RadioField = ({
|
|
3752
3773
|
|
3753
3774
|
// components/AutoField/fields/SelectField/index.tsx
|
3754
3775
|
init_react_import();
|
3755
|
-
var
|
3776
|
+
var import_react21 = require("react");
|
3756
3777
|
var import_jsx_runtime15 = require("react/jsx-runtime");
|
3757
3778
|
var getClassName12 = get_class_name_factory_default("Input", styles_module_default2);
|
3758
3779
|
var SelectField = ({
|
3759
3780
|
field,
|
3760
3781
|
onChange,
|
3761
3782
|
label,
|
3783
|
+
labelIcon,
|
3762
3784
|
Label: Label2,
|
3763
3785
|
value,
|
3764
3786
|
name,
|
3765
3787
|
readOnly,
|
3766
3788
|
id
|
3767
3789
|
}) => {
|
3768
|
-
const flatOptions = (0,
|
3790
|
+
const flatOptions = (0, import_react21.useMemo)(
|
3769
3791
|
() => field.type === "select" ? field.options.map(({ value: value2 }) => value2) : [],
|
3770
3792
|
[field]
|
3771
3793
|
);
|
@@ -3776,7 +3798,7 @@ var SelectField = ({
|
|
3776
3798
|
Label2,
|
3777
3799
|
{
|
3778
3800
|
label: label || name,
|
3779
|
-
icon: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(ChevronDown, { size: 16 }),
|
3801
|
+
icon: labelIcon || /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(ChevronDown, { size: 16 }),
|
3780
3802
|
readOnly,
|
3781
3803
|
children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
3782
3804
|
"select",
|
@@ -3820,24 +3842,33 @@ var TextareaField = ({
|
|
3820
3842
|
value,
|
3821
3843
|
name,
|
3822
3844
|
label,
|
3845
|
+
labelIcon,
|
3823
3846
|
Label: Label2,
|
3824
3847
|
id
|
3825
3848
|
}) => {
|
3826
|
-
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
3827
|
-
|
3849
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
3850
|
+
Label2,
|
3828
3851
|
{
|
3829
|
-
|
3830
|
-
|
3831
|
-
autoComplete: "off",
|
3832
|
-
name,
|
3833
|
-
value: typeof value === "undefined" ? "" : value,
|
3834
|
-
onChange: (e) => onChange(e.currentTarget.value),
|
3852
|
+
label: label || name,
|
3853
|
+
icon: labelIcon || /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Type, { size: 16 }),
|
3835
3854
|
readOnly,
|
3836
|
-
|
3837
|
-
|
3838
|
-
|
3855
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
3856
|
+
"textarea",
|
3857
|
+
{
|
3858
|
+
id,
|
3859
|
+
className: getClassName13("input"),
|
3860
|
+
autoComplete: "off",
|
3861
|
+
name,
|
3862
|
+
value: typeof value === "undefined" ? "" : value,
|
3863
|
+
onChange: (e) => onChange(e.currentTarget.value),
|
3864
|
+
readOnly,
|
3865
|
+
tabIndex: readOnly ? -1 : void 0,
|
3866
|
+
rows: 5,
|
3867
|
+
placeholder: field.type === "textarea" ? field.placeholder : void 0
|
3868
|
+
}
|
3869
|
+
)
|
3839
3870
|
}
|
3840
|
-
)
|
3871
|
+
);
|
3841
3872
|
};
|
3842
3873
|
|
3843
3874
|
// components/AutoField/fields/ObjectField/index.tsx
|
@@ -3856,6 +3887,7 @@ var ObjectField = ({
|
|
3856
3887
|
value,
|
3857
3888
|
name,
|
3858
3889
|
label,
|
3890
|
+
labelIcon,
|
3859
3891
|
Label: Label2,
|
3860
3892
|
readOnly,
|
3861
3893
|
id
|
@@ -3869,7 +3901,7 @@ var ObjectField = ({
|
|
3869
3901
|
Label2,
|
3870
3902
|
{
|
3871
3903
|
label: label || name,
|
3872
|
-
icon: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(EllipsisVertical, { size: 16 }),
|
3904
|
+
icon: labelIcon || /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(EllipsisVertical, { size: 16 }),
|
3873
3905
|
el: "div",
|
3874
3906
|
readOnly,
|
3875
3907
|
children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: getClassName14(), children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("fieldset", { className: getClassName14("fieldset"), children: Object.keys(field.objectFields).map((subName) => {
|
@@ -3916,12 +3948,12 @@ var ObjectField = ({
|
|
3916
3948
|
|
3917
3949
|
// lib/use-safe-id.ts
|
3918
3950
|
init_react_import();
|
3919
|
-
var
|
3951
|
+
var import_react22 = __toESM(require("react"));
|
3920
3952
|
var useSafeId = () => {
|
3921
|
-
if (typeof
|
3922
|
-
return
|
3953
|
+
if (typeof import_react22.default.useId !== "undefined") {
|
3954
|
+
return import_react22.default.useId();
|
3923
3955
|
}
|
3924
|
-
const [id] = (0,
|
3956
|
+
const [id] = (0, import_react22.useState)(generateId());
|
3925
3957
|
return id;
|
3926
3958
|
};
|
3927
3959
|
|
@@ -3955,7 +3987,7 @@ var FieldLabelInternal = ({
|
|
3955
3987
|
readOnly
|
3956
3988
|
}) => {
|
3957
3989
|
const overrides = useAppStore((s) => s.overrides);
|
3958
|
-
const Wrapper = (0,
|
3990
|
+
const Wrapper = (0, import_react23.useMemo)(
|
3959
3991
|
() => overrides.fieldLabel || FieldLabel,
|
3960
3992
|
[overrides]
|
3961
3993
|
);
|
@@ -3982,10 +4014,11 @@ function AutoFieldInternal(props) {
|
|
3982
4014
|
var _a2;
|
3983
4015
|
return (_a2 = s.selectedItem) == null ? void 0 : _a2.readOnly;
|
3984
4016
|
});
|
3985
|
-
const nestedFieldContext = (0,
|
4017
|
+
const nestedFieldContext = (0, import_react23.useContext)(NestedFieldContext);
|
3986
4018
|
const { id, Label: Label2 = FieldLabelInternal } = props;
|
3987
4019
|
const field = props.field;
|
3988
4020
|
const label = field.label;
|
4021
|
+
const labelIcon = field.labelIcon;
|
3989
4022
|
const defaultId = useSafeId();
|
3990
4023
|
const resolvedId = id || defaultId;
|
3991
4024
|
const defaultFields = {
|
@@ -4011,10 +4044,11 @@ function AutoFieldInternal(props) {
|
|
4011
4044
|
const mergedProps = __spreadProps(__spreadValues({}, props), {
|
4012
4045
|
field,
|
4013
4046
|
label,
|
4047
|
+
labelIcon,
|
4014
4048
|
Label: Label2,
|
4015
4049
|
id: resolvedId
|
4016
4050
|
});
|
4017
|
-
const onFocus = (0,
|
4051
|
+
const onFocus = (0, import_react23.useCallback)(
|
4018
4052
|
(e) => {
|
4019
4053
|
if (mergedProps.name && (e.target.nodeName === "INPUT" || e.target.nodeName === "TEXTAREA")) {
|
4020
4054
|
e.stopPropagation();
|
@@ -4028,7 +4062,7 @@ function AutoFieldInternal(props) {
|
|
4028
4062
|
},
|
4029
4063
|
[mergedProps.name]
|
4030
4064
|
);
|
4031
|
-
const onBlur = (0,
|
4065
|
+
const onBlur = (0, import_react23.useCallback)((e) => {
|
4032
4066
|
if ("name" in e.target) {
|
4033
4067
|
dispatch({
|
4034
4068
|
type: "setUi",
|
@@ -4072,12 +4106,15 @@ function AutoFieldInternal(props) {
|
|
4072
4106
|
function AutoFieldPrivate(props) {
|
4073
4107
|
const isFocused = useAppStore((s) => s.state.ui.field.focus === props.name);
|
4074
4108
|
const { value, onChange } = props;
|
4075
|
-
const [localValue, setLocalValue] = (0,
|
4076
|
-
const onChangeLocal = (0,
|
4077
|
-
|
4078
|
-
|
4079
|
-
|
4080
|
-
|
4109
|
+
const [localValue, setLocalValue] = (0, import_react23.useState)(value);
|
4110
|
+
const onChangeLocal = (0, import_react23.useCallback)(
|
4111
|
+
(val, ui) => {
|
4112
|
+
setLocalValue(val);
|
4113
|
+
onChange(val, ui);
|
4114
|
+
},
|
4115
|
+
[onChange]
|
4116
|
+
);
|
4117
|
+
(0, import_react23.useEffect)(() => {
|
4081
4118
|
if (!isFocused) {
|
4082
4119
|
setLocalValue(value);
|
4083
4120
|
}
|
@@ -4089,7 +4126,7 @@ function AutoFieldPrivate(props) {
|
|
4089
4126
|
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(AutoFieldInternal, __spreadValues(__spreadValues({}, props), localProps));
|
4090
4127
|
}
|
4091
4128
|
function AutoField(props) {
|
4092
|
-
const DefaultLabel = (0,
|
4129
|
+
const DefaultLabel = (0, import_react23.useMemo)(() => {
|
4093
4130
|
const DefaultLabel2 = (labelProps) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
4094
4131
|
"div",
|
4095
4132
|
__spreadProps(__spreadValues({}, labelProps), {
|
@@ -4109,21 +4146,21 @@ init_react_import();
|
|
4109
4146
|
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" };
|
4110
4147
|
|
4111
4148
|
// components/Drawer/index.tsx
|
4112
|
-
var
|
4149
|
+
var import_react36 = require("react");
|
4113
4150
|
|
4114
4151
|
// components/DragDropContext/index.tsx
|
4115
4152
|
init_react_import();
|
4116
|
-
var
|
4117
|
-
var
|
4153
|
+
var import_react34 = require("@dnd-kit/react");
|
4154
|
+
var import_react35 = require("react");
|
4118
4155
|
var import_dom = require("@dnd-kit/dom");
|
4119
4156
|
|
4120
4157
|
// components/DropZone/index.tsx
|
4121
4158
|
init_react_import();
|
4122
|
-
var
|
4159
|
+
var import_react33 = require("react");
|
4123
4160
|
|
4124
4161
|
// components/DraggableComponent/index.tsx
|
4125
4162
|
init_react_import();
|
4126
|
-
var
|
4163
|
+
var import_react26 = require("react");
|
4127
4164
|
|
4128
4165
|
// css-module:/home/runner/work/puck/puck/packages/core/components/DraggableComponent/styles.module.css#css-module
|
4129
4166
|
init_react_import();
|
@@ -4153,11 +4190,11 @@ function getDeepScrollPosition(element) {
|
|
4153
4190
|
|
4154
4191
|
// components/DropZone/context.tsx
|
4155
4192
|
init_react_import();
|
4156
|
-
var
|
4193
|
+
var import_react24 = require("react");
|
4157
4194
|
var import_zustand3 = require("zustand");
|
4158
4195
|
var import_jsx_runtime19 = require("react/jsx-runtime");
|
4159
|
-
var dropZoneContext = (0,
|
4160
|
-
var ZoneStoreContext = (0,
|
4196
|
+
var dropZoneContext = (0, import_react24.createContext)(null);
|
4197
|
+
var ZoneStoreContext = (0, import_react24.createContext)(
|
4161
4198
|
(0, import_zustand3.createStore)(() => ({
|
4162
4199
|
zoneDepthIndex: {},
|
4163
4200
|
nextZoneDepthIndex: {},
|
@@ -4177,10 +4214,10 @@ var DropZoneProvider = ({
|
|
4177
4214
|
children,
|
4178
4215
|
value
|
4179
4216
|
}) => {
|
4180
|
-
const [hoveringComponent, setHoveringComponent] = (0,
|
4181
|
-
const [activeZones, setActiveZones] = (0,
|
4217
|
+
const [hoveringComponent, setHoveringComponent] = (0, import_react24.useState)();
|
4218
|
+
const [activeZones, setActiveZones] = (0, import_react24.useState)({});
|
4182
4219
|
const dispatch = useAppStore((s) => s.dispatch);
|
4183
|
-
const registerZone = (0,
|
4220
|
+
const registerZone = (0, import_react24.useCallback)(
|
4184
4221
|
(zoneCompound) => {
|
4185
4222
|
if (!dispatch) {
|
4186
4223
|
return;
|
@@ -4193,7 +4230,7 @@ var DropZoneProvider = ({
|
|
4193
4230
|
},
|
4194
4231
|
[setActiveZones, dispatch]
|
4195
4232
|
);
|
4196
|
-
const unregisterZone = (0,
|
4233
|
+
const unregisterZone = (0, import_react24.useCallback)(
|
4197
4234
|
(zoneCompound) => {
|
4198
4235
|
if (!dispatch) {
|
4199
4236
|
return;
|
@@ -4208,7 +4245,7 @@ var DropZoneProvider = ({
|
|
4208
4245
|
},
|
4209
4246
|
[setActiveZones, dispatch]
|
4210
4247
|
);
|
4211
|
-
const memoValue = (0,
|
4248
|
+
const memoValue = (0, import_react24.useMemo)(
|
4212
4249
|
() => __spreadValues({
|
4213
4250
|
hoveringComponent,
|
4214
4251
|
setHoveringComponent,
|
@@ -4223,11 +4260,11 @@ var DropZoneProvider = ({
|
|
4223
4260
|
|
4224
4261
|
// lib/use-context-store.ts
|
4225
4262
|
init_react_import();
|
4226
|
-
var
|
4263
|
+
var import_react25 = require("react");
|
4227
4264
|
var import_zustand4 = require("zustand");
|
4228
4265
|
var import_shallow = require("zustand/react/shallow");
|
4229
4266
|
function useContextStore(context, selector) {
|
4230
|
-
const store = (0,
|
4267
|
+
const store = (0, import_react25.useContext)(context);
|
4231
4268
|
if (!store) {
|
4232
4269
|
throw new Error("useContextStore must be used inside context");
|
4233
4270
|
}
|
@@ -4285,9 +4322,9 @@ var DraggableComponent = ({
|
|
4285
4322
|
);
|
4286
4323
|
const dispatch = useAppStore((s) => s.dispatch);
|
4287
4324
|
const iframe = useAppStore((s) => s.iframe);
|
4288
|
-
const ctx = (0,
|
4289
|
-
const [localZones, setLocalZones] = (0,
|
4290
|
-
const registerLocalZone = (0,
|
4325
|
+
const ctx = (0, import_react26.useContext)(dropZoneContext);
|
4326
|
+
const [localZones, setLocalZones] = (0, import_react26.useState)({});
|
4327
|
+
const registerLocalZone = (0, import_react26.useCallback)(
|
4291
4328
|
(zoneCompound2, active) => {
|
4292
4329
|
var _a;
|
4293
4330
|
(_a = ctx == null ? void 0 : ctx.registerLocalZone) == null ? void 0 : _a.call(ctx, zoneCompound2, active);
|
@@ -4297,7 +4334,7 @@ var DraggableComponent = ({
|
|
4297
4334
|
},
|
4298
4335
|
[setLocalZones]
|
4299
4336
|
);
|
4300
|
-
const unregisterLocalZone = (0,
|
4337
|
+
const unregisterLocalZone = (0, import_react26.useCallback)(
|
4301
4338
|
(zoneCompound2) => {
|
4302
4339
|
var _a;
|
4303
4340
|
(_a = ctx == null ? void 0 : ctx.unregisterLocalZone) == null ? void 0 : _a.call(ctx, zoneCompound2);
|
@@ -4327,7 +4364,7 @@ var DraggableComponent = ({
|
|
4327
4364
|
);
|
4328
4365
|
const canCollide = permissions.drag || userIsDragging;
|
4329
4366
|
const disabled = !isEnabled || !canCollide;
|
4330
|
-
const [dragAxis, setDragAxis] = (0,
|
4367
|
+
const [dragAxis, setDragAxis] = (0, import_react26.useState)(userDragAxis || autoDragAxis);
|
4331
4368
|
const { ref: sortableRef, status } = useSortableSafe({
|
4332
4369
|
id,
|
4333
4370
|
index,
|
@@ -4353,8 +4390,8 @@ var DraggableComponent = ({
|
|
4353
4390
|
}
|
4354
4391
|
});
|
4355
4392
|
const thisIsDragging = status === "dragging";
|
4356
|
-
const ref = (0,
|
4357
|
-
const refSetter = (0,
|
4393
|
+
const ref = (0, import_react26.useRef)(null);
|
4394
|
+
const refSetter = (0, import_react26.useCallback)(
|
4358
4395
|
(el) => {
|
4359
4396
|
sortableRef(el);
|
4360
4397
|
if (el) {
|
@@ -4363,14 +4400,14 @@ var DraggableComponent = ({
|
|
4363
4400
|
},
|
4364
4401
|
[sortableRef]
|
4365
4402
|
);
|
4366
|
-
const [portalEl, setPortalEl] = (0,
|
4367
|
-
(0,
|
4403
|
+
const [portalEl, setPortalEl] = (0, import_react26.useState)();
|
4404
|
+
(0, import_react26.useEffect)(() => {
|
4368
4405
|
var _a, _b, _c;
|
4369
4406
|
setPortalEl(
|
4370
4407
|
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
|
4371
4408
|
);
|
4372
4409
|
}, [iframe.enabled, ref.current]);
|
4373
|
-
const getStyle = (0,
|
4410
|
+
const getStyle = (0, import_react26.useCallback)(() => {
|
4374
4411
|
var _a, _b, _c;
|
4375
4412
|
if (!ref.current) return;
|
4376
4413
|
const rect = ref.current.getBoundingClientRect();
|
@@ -4390,11 +4427,11 @@ var DraggableComponent = ({
|
|
4390
4427
|
};
|
4391
4428
|
return style2;
|
4392
4429
|
}, [ref.current]);
|
4393
|
-
const [style, setStyle] = (0,
|
4394
|
-
const sync = (0,
|
4430
|
+
const [style, setStyle] = (0, import_react26.useState)();
|
4431
|
+
const sync = (0, import_react26.useCallback)(() => {
|
4395
4432
|
setStyle(getStyle());
|
4396
4433
|
}, [ref.current, iframe]);
|
4397
|
-
(0,
|
4434
|
+
(0, import_react26.useEffect)(() => {
|
4398
4435
|
if (ref.current && !userIsDragging) {
|
4399
4436
|
const observer = new ResizeObserver(sync);
|
4400
4437
|
observer.observe(ref.current);
|
@@ -4404,18 +4441,18 @@ var DraggableComponent = ({
|
|
4404
4441
|
}
|
4405
4442
|
}, [ref.current, userIsDragging]);
|
4406
4443
|
const registerNode = useAppStore((s) => s.nodes.registerNode);
|
4407
|
-
(0,
|
4444
|
+
(0, import_react26.useEffect)(() => {
|
4408
4445
|
var _a;
|
4409
4446
|
registerNode(id, { methods: { sync }, element: (_a = ref.current) != null ? _a : null });
|
4410
4447
|
return () => {
|
4411
4448
|
registerNode(id, { methods: { sync: () => null }, element: null });
|
4412
4449
|
};
|
4413
4450
|
}, [id, zoneCompound, index, componentType, sync]);
|
4414
|
-
const CustomActionBar = (0,
|
4451
|
+
const CustomActionBar = (0, import_react26.useMemo)(
|
4415
4452
|
() => overrides.actionBar || DefaultActionBar,
|
4416
4453
|
[overrides.actionBar]
|
4417
4454
|
);
|
4418
|
-
const onClick = (0,
|
4455
|
+
const onClick = (0, import_react26.useCallback)(
|
4419
4456
|
(e) => {
|
4420
4457
|
e.stopPropagation();
|
4421
4458
|
dispatch({
|
@@ -4428,7 +4465,7 @@ var DraggableComponent = ({
|
|
4428
4465
|
[index, zoneCompound, id]
|
4429
4466
|
);
|
4430
4467
|
const appStore = useAppStoreApi();
|
4431
|
-
const onSelectParent = (0,
|
4468
|
+
const onSelectParent = (0, import_react26.useCallback)(() => {
|
4432
4469
|
const { nodes } = appStore.getState().nodes;
|
4433
4470
|
const node = nodes[id];
|
4434
4471
|
const parentNode = (node == null ? void 0 : node.parentId) ? nodes[node == null ? void 0 : node.parentId] : null;
|
@@ -4445,23 +4482,23 @@ var DraggableComponent = ({
|
|
4445
4482
|
}
|
4446
4483
|
});
|
4447
4484
|
}, [ctx, path]);
|
4448
|
-
const onDuplicate = (0,
|
4485
|
+
const onDuplicate = (0, import_react26.useCallback)(() => {
|
4449
4486
|
dispatch({
|
4450
4487
|
type: "duplicate",
|
4451
4488
|
sourceIndex: index,
|
4452
4489
|
sourceZone: zoneCompound
|
4453
4490
|
});
|
4454
4491
|
}, [index, zoneCompound]);
|
4455
|
-
const onDelete = (0,
|
4492
|
+
const onDelete = (0, import_react26.useCallback)(() => {
|
4456
4493
|
dispatch({
|
4457
4494
|
type: "remove",
|
4458
4495
|
index,
|
4459
4496
|
zone: zoneCompound
|
4460
4497
|
});
|
4461
4498
|
}, [index, zoneCompound]);
|
4462
|
-
const [hover, setHover] = (0,
|
4499
|
+
const [hover, setHover] = (0, import_react26.useState)(false);
|
4463
4500
|
const indicativeHover = (ctx == null ? void 0 : ctx.hoveringComponent) === id;
|
4464
|
-
(0,
|
4501
|
+
(0, import_react26.useEffect)(() => {
|
4465
4502
|
if (!ref.current) {
|
4466
4503
|
return;
|
4467
4504
|
}
|
@@ -4511,7 +4548,7 @@ var DraggableComponent = ({
|
|
4511
4548
|
thisIsDragging,
|
4512
4549
|
inDroppableZone
|
4513
4550
|
]);
|
4514
|
-
(0,
|
4551
|
+
(0, import_react26.useEffect)(() => {
|
4515
4552
|
if (ref.current && disabled) {
|
4516
4553
|
ref.current.setAttribute("data-puck-disabled", "");
|
4517
4554
|
return () => {
|
@@ -4520,8 +4557,8 @@ var DraggableComponent = ({
|
|
4520
4557
|
};
|
4521
4558
|
}
|
4522
4559
|
}, [disabled, ref]);
|
4523
|
-
const [isVisible, setIsVisible] = (0,
|
4524
|
-
(0,
|
4560
|
+
const [isVisible, setIsVisible] = (0, import_react26.useState)(false);
|
4561
|
+
(0, import_react26.useEffect)(() => {
|
4525
4562
|
sync();
|
4526
4563
|
if ((isSelected || hover || indicativeHover) && !userIsDragging) {
|
4527
4564
|
setIsVisible(true);
|
@@ -4529,7 +4566,7 @@ var DraggableComponent = ({
|
|
4529
4566
|
setIsVisible(false);
|
4530
4567
|
}
|
4531
4568
|
}, [isSelected, hover, indicativeHover, iframe, userIsDragging]);
|
4532
|
-
const syncActionsPosition = (0,
|
4569
|
+
const syncActionsPosition = (0, import_react26.useCallback)(
|
4533
4570
|
(el) => {
|
4534
4571
|
if (el) {
|
4535
4572
|
const view = el.ownerDocument.defaultView;
|
@@ -4537,16 +4574,24 @@ var DraggableComponent = ({
|
|
4537
4574
|
const rect = el.getBoundingClientRect();
|
4538
4575
|
const diffLeft = rect.x;
|
4539
4576
|
const exceedsBoundsLeft = diffLeft < 0;
|
4577
|
+
const diffTop = rect.y;
|
4578
|
+
const exceedsBoundsTop = diffTop < 0;
|
4540
4579
|
if (exceedsBoundsLeft) {
|
4541
4580
|
el.style.transformOrigin = "left top";
|
4542
4581
|
el.style.left = "0px";
|
4543
4582
|
}
|
4583
|
+
if (exceedsBoundsTop) {
|
4584
|
+
el.style.top = "12px";
|
4585
|
+
if (!exceedsBoundsLeft) {
|
4586
|
+
el.style.transformOrigin = "right top";
|
4587
|
+
}
|
4588
|
+
}
|
4544
4589
|
}
|
4545
4590
|
}
|
4546
4591
|
},
|
4547
4592
|
[zoom]
|
4548
4593
|
);
|
4549
|
-
(0,
|
4594
|
+
(0, import_react26.useEffect)(() => {
|
4550
4595
|
if (userDragAxis) {
|
4551
4596
|
setDragAxis(userDragAxis);
|
4552
4597
|
return;
|
@@ -4639,15 +4684,15 @@ var styles_module_default12 = { "DropZone": "_DropZone_kmkdc_1", "DropZone--isAc
|
|
4639
4684
|
|
4640
4685
|
// components/DropZone/lib/use-min-empty-height.ts
|
4641
4686
|
init_react_import();
|
4642
|
-
var
|
4687
|
+
var import_react27 = require("react");
|
4643
4688
|
var useMinEmptyHeight = ({
|
4644
4689
|
zoneCompound,
|
4645
4690
|
userMinEmptyHeight,
|
4646
4691
|
ref
|
4647
4692
|
}) => {
|
4648
4693
|
const appStore = useAppStoreApi();
|
4649
|
-
const [prevHeight, setPrevHeight] = (0,
|
4650
|
-
const [isAnimating, setIsAnimating] = (0,
|
4694
|
+
const [prevHeight, setPrevHeight] = (0, import_react27.useState)(0);
|
4695
|
+
const [isAnimating, setIsAnimating] = (0, import_react27.useState)(false);
|
4651
4696
|
const { draggedItem, isZone } = useContextStore(ZoneStoreContext, (s) => {
|
4652
4697
|
var _a, _b;
|
4653
4698
|
return {
|
@@ -4655,7 +4700,7 @@ var useMinEmptyHeight = ({
|
|
4655
4700
|
isZone: ((_b = s.draggedItem) == null ? void 0 : _b.data.zone) === zoneCompound
|
4656
4701
|
};
|
4657
4702
|
});
|
4658
|
-
(0,
|
4703
|
+
(0, import_react27.useEffect)(() => {
|
4659
4704
|
if (draggedItem && ref.current) {
|
4660
4705
|
if (isZone) {
|
4661
4706
|
const rect = ref.current.getBoundingClientRect();
|
@@ -4693,15 +4738,15 @@ function assignRefs(refs, node) {
|
|
4693
4738
|
|
4694
4739
|
// components/DropZone/lib/use-content-with-preview.ts
|
4695
4740
|
init_react_import();
|
4696
|
-
var
|
4741
|
+
var import_react30 = require("react");
|
4697
4742
|
|
4698
4743
|
// lib/dnd/use-rendered-callback.ts
|
4699
4744
|
init_react_import();
|
4700
|
-
var
|
4701
|
-
var
|
4745
|
+
var import_react28 = require("@dnd-kit/react");
|
4746
|
+
var import_react29 = require("react");
|
4702
4747
|
function useRenderedCallback(callback, deps) {
|
4703
|
-
const manager = (0,
|
4704
|
-
return (0,
|
4748
|
+
const manager = (0, import_react28.useDragDropManager)();
|
4749
|
+
return (0, import_react29.useCallback)(
|
4705
4750
|
(...args) => __async(this, null, function* () {
|
4706
4751
|
yield manager == null ? void 0 : manager.renderer.rendering;
|
4707
4752
|
return callback(...args);
|
@@ -4724,8 +4769,8 @@ var useContentIdsWithPreview = (contentIds, zoneCompound) => {
|
|
4724
4769
|
}
|
4725
4770
|
);
|
4726
4771
|
const isDragging = useAppStore((s) => s.state.ui.isDragging);
|
4727
|
-
const [contentIdsWithPreview, setContentIdsWithPreview] = (0,
|
4728
|
-
const [localPreview, setLocalPreview] = (0,
|
4772
|
+
const [contentIdsWithPreview, setContentIdsWithPreview] = (0, import_react30.useState)(contentIds);
|
4773
|
+
const [localPreview, setLocalPreview] = (0, import_react30.useState)(
|
4729
4774
|
preview
|
4730
4775
|
);
|
4731
4776
|
const updateContent = useRenderedCallback(
|
@@ -4760,7 +4805,7 @@ var useContentIdsWithPreview = (contentIds, zoneCompound) => {
|
|
4760
4805
|
},
|
4761
4806
|
[draggedItemId, previewExists]
|
4762
4807
|
);
|
4763
|
-
(0,
|
4808
|
+
(0, import_react30.useEffect)(() => {
|
4764
4809
|
updateContent(contentIds, preview, isDragging);
|
4765
4810
|
}, [contentIds, preview, isDragging]);
|
4766
4811
|
return [contentIdsWithPreview, localPreview];
|
@@ -4768,16 +4813,16 @@ var useContentIdsWithPreview = (contentIds, zoneCompound) => {
|
|
4768
4813
|
|
4769
4814
|
// components/DropZone/lib/use-drag-axis.ts
|
4770
4815
|
init_react_import();
|
4771
|
-
var
|
4816
|
+
var import_react31 = require("react");
|
4772
4817
|
var GRID_DRAG_AXIS = "dynamic";
|
4773
4818
|
var FLEX_ROW_DRAG_AXIS = "x";
|
4774
4819
|
var DEFAULT_DRAG_AXIS = "y";
|
4775
4820
|
var useDragAxis = (ref, collisionAxis) => {
|
4776
4821
|
const status = useAppStore((s) => s.status);
|
4777
|
-
const [dragAxis, setDragAxis] = (0,
|
4822
|
+
const [dragAxis, setDragAxis] = (0, import_react31.useState)(
|
4778
4823
|
collisionAxis || DEFAULT_DRAG_AXIS
|
4779
4824
|
);
|
4780
|
-
const calculateDragAxis = (0,
|
4825
|
+
const calculateDragAxis = (0, import_react31.useCallback)(() => {
|
4781
4826
|
if (ref.current) {
|
4782
4827
|
const computedStyle = window.getComputedStyle(ref.current);
|
4783
4828
|
if (computedStyle.display === "grid") {
|
@@ -4789,7 +4834,7 @@ var useDragAxis = (ref, collisionAxis) => {
|
|
4789
4834
|
}
|
4790
4835
|
}
|
4791
4836
|
}, [ref.current]);
|
4792
|
-
(0,
|
4837
|
+
(0, import_react31.useEffect)(() => {
|
4793
4838
|
const onViewportChange = () => {
|
4794
4839
|
calculateDragAxis();
|
4795
4840
|
};
|
@@ -4798,7 +4843,7 @@ var useDragAxis = (ref, collisionAxis) => {
|
|
4798
4843
|
window.removeEventListener("viewportchange", onViewportChange);
|
4799
4844
|
};
|
4800
4845
|
}, []);
|
4801
|
-
(0,
|
4846
|
+
(0, import_react31.useEffect)(calculateDragAxis, [status, collisionAxis]);
|
4802
4847
|
return [dragAxis, calculateDragAxis];
|
4803
4848
|
};
|
4804
4849
|
|
@@ -4807,9 +4852,9 @@ var import_shallow3 = require("zustand/react/shallow");
|
|
4807
4852
|
|
4808
4853
|
// components/Render/index.tsx
|
4809
4854
|
init_react_import();
|
4810
|
-
var
|
4855
|
+
var import_react32 = __toESM(require("react"));
|
4811
4856
|
var import_jsx_runtime21 = require("react/jsx-runtime");
|
4812
|
-
var renderContext =
|
4857
|
+
var renderContext = import_react32.default.createContext({
|
4813
4858
|
config: { components: {} },
|
4814
4859
|
data: { root: {}, content: [] },
|
4815
4860
|
metadata: {}
|
@@ -4888,7 +4933,7 @@ var DropZoneChild = ({
|
|
4888
4933
|
dragRef: null,
|
4889
4934
|
metadata
|
4890
4935
|
};
|
4891
|
-
const ctx = (0,
|
4936
|
+
const ctx = (0, import_react33.useContext)(dropZoneContext);
|
4892
4937
|
const { depth } = ctx;
|
4893
4938
|
const contentItem = useAppStore(
|
4894
4939
|
(0, import_shallow3.useShallow)((s) => {
|
@@ -4917,7 +4962,7 @@ var DropZoneChild = ({
|
|
4917
4962
|
}
|
4918
4963
|
);
|
4919
4964
|
let label = (_b = (_a = componentConfig == null ? void 0 : componentConfig.label) != null ? _a : item == null ? void 0 : item.type.toString()) != null ? _b : "Component";
|
4920
|
-
const renderPreview = (0,
|
4965
|
+
const renderPreview = (0, import_react33.useMemo)(
|
4921
4966
|
() => function Preview4() {
|
4922
4967
|
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(DrawerItemInner, { name: label, children: overrides.componentItem });
|
4923
4968
|
},
|
@@ -4964,7 +5009,7 @@ var DropZoneChild = ({
|
|
4964
5009
|
}
|
4965
5010
|
);
|
4966
5011
|
};
|
4967
|
-
var DropZoneEdit = (0,
|
5012
|
+
var DropZoneEdit = (0, import_react33.forwardRef)(
|
4968
5013
|
function DropZoneEditInternal({
|
4969
5014
|
zone,
|
4970
5015
|
allow,
|
@@ -4974,7 +5019,7 @@ var DropZoneEdit = (0, import_react34.forwardRef)(
|
|
4974
5019
|
minEmptyHeight: userMinEmptyHeight = 128,
|
4975
5020
|
collisionAxis
|
4976
5021
|
}, userRef) {
|
4977
|
-
const ctx = (0,
|
5022
|
+
const ctx = (0, import_react33.useContext)(dropZoneContext);
|
4978
5023
|
const {
|
4979
5024
|
// These all need setting via context
|
4980
5025
|
areaId,
|
@@ -5011,7 +5056,7 @@ var DropZoneEdit = (0, import_react34.forwardRef)(
|
|
5011
5056
|
userIsDragging: !!s.draggedItem
|
5012
5057
|
};
|
5013
5058
|
});
|
5014
|
-
(0,
|
5059
|
+
(0, import_react33.useEffect)(() => {
|
5015
5060
|
if (ctx == null ? void 0 : ctx.registerZone) {
|
5016
5061
|
ctx == null ? void 0 : ctx.registerZone(zoneCompound);
|
5017
5062
|
}
|
@@ -5030,8 +5075,8 @@ var DropZoneEdit = (0, import_react34.forwardRef)(
|
|
5030
5075
|
return content.map(({ props }) => props.id);
|
5031
5076
|
})
|
5032
5077
|
);
|
5033
|
-
const ref = (0,
|
5034
|
-
const acceptsTarget = (0,
|
5078
|
+
const ref = (0, import_react33.useRef)(null);
|
5079
|
+
const acceptsTarget = (0, import_react33.useCallback)(
|
5035
5080
|
(componentType) => {
|
5036
5081
|
if (!componentType) {
|
5037
5082
|
return true;
|
@@ -5053,7 +5098,7 @@ var DropZoneEdit = (0, import_react34.forwardRef)(
|
|
5053
5098
|
},
|
5054
5099
|
[allow, disallow]
|
5055
5100
|
);
|
5056
|
-
(0,
|
5101
|
+
(0, import_react33.useEffect)(() => {
|
5057
5102
|
if (registerLocalZone) {
|
5058
5103
|
registerLocalZone(zoneCompound, acceptsTarget(draggedComponentType));
|
5059
5104
|
}
|
@@ -5143,14 +5188,14 @@ var DropZoneEdit = (0, import_react34.forwardRef)(
|
|
5143
5188
|
}
|
5144
5189
|
);
|
5145
5190
|
var DropZoneRenderPure = (props) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(DropZoneRender, __spreadValues({}, props));
|
5146
|
-
var DropZoneRender = (0,
|
5191
|
+
var DropZoneRender = (0, import_react33.forwardRef)(
|
5147
5192
|
function DropZoneRenderInternal({ className, style, zone }, ref) {
|
5148
|
-
const ctx = (0,
|
5193
|
+
const ctx = (0, import_react33.useContext)(dropZoneContext);
|
5149
5194
|
const { areaId = "root" } = ctx || {};
|
5150
|
-
const { config, data, metadata } = (0,
|
5195
|
+
const { config, data, metadata } = (0, import_react33.useContext)(renderContext);
|
5151
5196
|
let zoneCompound = rootDroppableId;
|
5152
5197
|
let content = (data == null ? void 0 : data.content) || [];
|
5153
|
-
(0,
|
5198
|
+
(0, import_react33.useEffect)(() => {
|
5154
5199
|
if (ctx == null ? void 0 : ctx.registerZone) {
|
5155
5200
|
ctx == null ? void 0 : ctx.registerZone(zoneCompound);
|
5156
5201
|
}
|
@@ -5195,9 +5240,9 @@ var DropZoneRender = (0, import_react34.forwardRef)(
|
|
5195
5240
|
}
|
5196
5241
|
);
|
5197
5242
|
var DropZonePure = (props) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(DropZone, __spreadValues({}, props));
|
5198
|
-
var DropZone = (0,
|
5243
|
+
var DropZone = (0, import_react33.forwardRef)(
|
5199
5244
|
function DropZone2(props, ref) {
|
5200
|
-
const ctx = (0,
|
5245
|
+
const ctx = (0, import_react33.useContext)(dropZoneContext);
|
5201
5246
|
if ((ctx == null ? void 0 : ctx.mode) === "edit") {
|
5202
5247
|
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_jsx_runtime22.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(DropZoneEdit, __spreadProps(__spreadValues({}, props), { ref })) });
|
5203
5248
|
}
|
@@ -5517,12 +5562,12 @@ function getDeepDir(el) {
|
|
5517
5562
|
// components/DragDropContext/index.tsx
|
5518
5563
|
var import_jsx_runtime23 = require("react/jsx-runtime");
|
5519
5564
|
var DEBUG3 = false;
|
5520
|
-
var dragListenerContext = (0,
|
5565
|
+
var dragListenerContext = (0, import_react35.createContext)({
|
5521
5566
|
dragListeners: {}
|
5522
5567
|
});
|
5523
5568
|
function useDragListener(type, fn, deps = []) {
|
5524
|
-
const { setDragListeners } = (0,
|
5525
|
-
(0,
|
5569
|
+
const { setDragListeners } = (0, import_react35.useContext)(dragListenerContext);
|
5570
|
+
(0, import_react35.useEffect)(() => {
|
5526
5571
|
if (setDragListeners) {
|
5527
5572
|
setDragListeners((old) => __spreadProps(__spreadValues({}, old), {
|
5528
5573
|
[type]: [...old[type] || [], fn]
|
@@ -5532,8 +5577,8 @@ function useDragListener(type, fn, deps = []) {
|
|
5532
5577
|
}
|
5533
5578
|
var AREA_CHANGE_DEBOUNCE_MS = 100;
|
5534
5579
|
var useTempDisableFallback = (timeout3) => {
|
5535
|
-
const lastFallbackDisable = (0,
|
5536
|
-
return (0,
|
5580
|
+
const lastFallbackDisable = (0, import_react35.useRef)(null);
|
5581
|
+
return (0, import_react35.useCallback)((manager) => {
|
5537
5582
|
collisionStore.setState({ fallbackEnabled: false });
|
5538
5583
|
const fallbackId = generateId();
|
5539
5584
|
lastFallbackDisable.current = fallbackId;
|
@@ -5554,10 +5599,10 @@ var DragDropContextClient = ({
|
|
5554
5599
|
const resolveData2 = useAppStore((s) => s.resolveData);
|
5555
5600
|
const metadata = useAppStore((s) => s.metadata);
|
5556
5601
|
const appStore = useAppStoreApi();
|
5557
|
-
const id = (
|
5558
|
-
const debouncedParamsRef = (0,
|
5602
|
+
const id = useSafeId();
|
5603
|
+
const debouncedParamsRef = (0, import_react35.useRef)(null);
|
5559
5604
|
const tempDisableFallback = useTempDisableFallback(100);
|
5560
|
-
const [zoneStore] = (0,
|
5605
|
+
const [zoneStore] = (0, import_react35.useState)(
|
5561
5606
|
() => (0, import_zustand5.createStore)(() => ({
|
5562
5607
|
zoneDepthIndex: {},
|
5563
5608
|
nextZoneDepthIndex: {},
|
@@ -5567,7 +5612,7 @@ var DragDropContextClient = ({
|
|
5567
5612
|
previewIndex: {}
|
5568
5613
|
}))
|
5569
5614
|
);
|
5570
|
-
const getChanged2 = (0,
|
5615
|
+
const getChanged2 = (0, import_react35.useCallback)(
|
5571
5616
|
(params, id2) => {
|
5572
5617
|
const { zoneDepthIndex = {}, areaDepthIndex = {} } = zoneStore.getState() || {};
|
5573
5618
|
const stateHasZone = Object.keys(zoneDepthIndex).length > 0;
|
@@ -5588,7 +5633,7 @@ var DragDropContextClient = ({
|
|
5588
5633
|
},
|
5589
5634
|
[zoneStore]
|
5590
5635
|
);
|
5591
|
-
const setDeepestAndCollide = (0,
|
5636
|
+
const setDeepestAndCollide = (0, import_react35.useCallback)(
|
5592
5637
|
(params, manager) => {
|
5593
5638
|
const { zoneChanged, areaChanged } = getChanged2(params, id);
|
5594
5639
|
if (!zoneChanged && !areaChanged) return;
|
@@ -5612,7 +5657,7 @@ var DragDropContextClient = ({
|
|
5612
5657
|
setDeepestDb.cancel();
|
5613
5658
|
debouncedParamsRef.current = null;
|
5614
5659
|
};
|
5615
|
-
(0,
|
5660
|
+
(0, import_react35.useEffect)(() => {
|
5616
5661
|
if (DEBUG3) {
|
5617
5662
|
zoneStore.subscribe(
|
5618
5663
|
(s) => {
|
@@ -5626,7 +5671,7 @@ var DragDropContextClient = ({
|
|
5626
5671
|
);
|
5627
5672
|
}
|
5628
5673
|
}, []);
|
5629
|
-
const [plugins] = (0,
|
5674
|
+
const [plugins] = (0, import_react35.useState)(() => [
|
5630
5675
|
...disableAutoScroll ? import_dom.defaultPreset.plugins.filter((plugin) => plugin !== import_dom.AutoScroller) : import_dom.defaultPreset.plugins,
|
5631
5676
|
createNestedDroppablePlugin(
|
5632
5677
|
{
|
@@ -5674,9 +5719,9 @@ var DragDropContextClient = ({
|
|
5674
5719
|
)
|
5675
5720
|
]);
|
5676
5721
|
const sensors = useSensors();
|
5677
|
-
const [dragListeners, setDragListeners] = (0,
|
5678
|
-
const dragMode = (0,
|
5679
|
-
const initialSelector = (0,
|
5722
|
+
const [dragListeners, setDragListeners] = (0, import_react35.useState)({});
|
5723
|
+
const dragMode = (0, import_react35.useRef)(null);
|
5724
|
+
const initialSelector = (0, import_react35.useRef)(void 0);
|
5680
5725
|
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { id, children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
5681
5726
|
dragListenerContext.Provider,
|
5682
5727
|
{
|
@@ -5685,7 +5730,7 @@ var DragDropContextClient = ({
|
|
5685
5730
|
setDragListeners
|
5686
5731
|
},
|
5687
5732
|
children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
5688
|
-
|
5733
|
+
import_react34.DragDropProvider,
|
5689
5734
|
{
|
5690
5735
|
plugins,
|
5691
5736
|
sensors,
|
@@ -5915,7 +5960,7 @@ var DrawerItemInner = ({
|
|
5915
5960
|
dragRef,
|
5916
5961
|
isDragDisabled
|
5917
5962
|
}) => {
|
5918
|
-
const CustomInner = (0,
|
5963
|
+
const CustomInner = (0, import_react36.useMemo)(
|
5919
5964
|
() => children || (({ children: children2 }) => /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: getClassNameItem2("default"), children: children2 })),
|
5920
5965
|
[children]
|
5921
5966
|
);
|
@@ -5969,7 +6014,7 @@ var DrawerItem = ({
|
|
5969
6014
|
isDragDisabled
|
5970
6015
|
}) => {
|
5971
6016
|
const resolvedId = id || name;
|
5972
|
-
const [dynamicId, setDynamicId] = (0,
|
6017
|
+
const [dynamicId, setDynamicId] = (0, import_react36.useState)(generateId(resolvedId));
|
5973
6018
|
if (typeof index !== "undefined") {
|
5974
6019
|
console.error(
|
5975
6020
|
"Warning: The `index` prop on Drawer.Item is deprecated and no longer required."
|
@@ -6008,7 +6053,7 @@ var Drawer = ({
|
|
6008
6053
|
"Warning: The `direction` prop on Drawer is deprecated and no longer required to achieve multi-directional dragging."
|
6009
6054
|
);
|
6010
6055
|
}
|
6011
|
-
const id = (
|
6056
|
+
const id = useSafeId();
|
6012
6057
|
const { ref } = useDroppableSafe({
|
6013
6058
|
id,
|
6014
6059
|
type: "void",
|
@@ -6030,7 +6075,7 @@ Drawer.Item = DrawerItem;
|
|
6030
6075
|
|
6031
6076
|
// components/Puck/index.tsx
|
6032
6077
|
init_react_import();
|
6033
|
-
var
|
6078
|
+
var import_react51 = require("react");
|
6034
6079
|
|
6035
6080
|
// components/SidebarSection/index.tsx
|
6036
6081
|
init_react_import();
|
@@ -6041,7 +6086,7 @@ var styles_module_default13 = { "SidebarSection": "_SidebarSection_8boj8_1", "Si
|
|
6041
6086
|
|
6042
6087
|
// lib/use-breadcrumbs.ts
|
6043
6088
|
init_react_import();
|
6044
|
-
var
|
6089
|
+
var import_react37 = require("react");
|
6045
6090
|
var useBreadcrumbs = (renderCount) => {
|
6046
6091
|
const selectedId = useAppStore((s) => {
|
6047
6092
|
var _a;
|
@@ -6053,7 +6098,7 @@ var useBreadcrumbs = (renderCount) => {
|
|
6053
6098
|
return (_a = s.nodes.nodes[selectedId]) == null ? void 0 : _a.path;
|
6054
6099
|
});
|
6055
6100
|
const appStore = useAppStoreApi();
|
6056
|
-
return (0,
|
6101
|
+
return (0, import_react37.useMemo)(() => {
|
6057
6102
|
const breadcrumbs = (path == null ? void 0 : path.map((zoneCompound) => {
|
6058
6103
|
var _a, _b;
|
6059
6104
|
const [componentId] = zoneCompound.split(":");
|
@@ -6178,7 +6223,7 @@ init_react_import();
|
|
6178
6223
|
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" };
|
6179
6224
|
|
6180
6225
|
// components/Puck/components/Fields/index.tsx
|
6181
|
-
var
|
6226
|
+
var import_react38 = require("react");
|
6182
6227
|
var import_shallow4 = require("zustand/react/shallow");
|
6183
6228
|
var import_jsx_runtime27 = require("react/jsx-runtime");
|
6184
6229
|
var getClassName21 = get_class_name_factory_default("PuckFields", styles_module_default16);
|
@@ -6273,7 +6318,7 @@ var FieldsChild = ({ fieldName }) => {
|
|
6273
6318
|
})
|
6274
6319
|
);
|
6275
6320
|
const appStore = useAppStoreApi();
|
6276
|
-
const onChange = (0,
|
6321
|
+
const onChange = (0, import_react38.useCallback)(createOnChange(fieldName, appStore), [
|
6277
6322
|
fieldName
|
6278
6323
|
]);
|
6279
6324
|
if (!field || !id) return null;
|
@@ -6308,7 +6353,7 @@ var Fields = ({ wrapFields = true }) => {
|
|
6308
6353
|
(0, import_shallow4.useShallow)((s) => Object.keys(s.fields.fields))
|
6309
6354
|
);
|
6310
6355
|
const isLoading = fieldsLoading || componentResolving;
|
6311
|
-
const Wrapper = (0,
|
6356
|
+
const Wrapper = (0, import_react38.useMemo)(() => overrides.fields || DefaultFields, [overrides]);
|
6312
6357
|
return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
|
6313
6358
|
"form",
|
6314
6359
|
{
|
@@ -6329,7 +6374,7 @@ init_react_import();
|
|
6329
6374
|
|
6330
6375
|
// lib/use-component-list.tsx
|
6331
6376
|
init_react_import();
|
6332
|
-
var
|
6377
|
+
var import_react39 = require("react");
|
6333
6378
|
|
6334
6379
|
// components/ComponentList/index.tsx
|
6335
6380
|
init_react_import();
|
@@ -6400,10 +6445,10 @@ ComponentList.Item = ComponentListItem;
|
|
6400
6445
|
// lib/use-component-list.tsx
|
6401
6446
|
var import_jsx_runtime29 = require("react/jsx-runtime");
|
6402
6447
|
var useComponentList = () => {
|
6403
|
-
const [componentList, setComponentList] = (0,
|
6448
|
+
const [componentList, setComponentList] = (0, import_react39.useState)();
|
6404
6449
|
const config = useAppStore((s) => s.config);
|
6405
6450
|
const uiComponentList = useAppStore((s) => s.state.ui.componentList);
|
6406
|
-
(0,
|
6451
|
+
(0, import_react39.useEffect)(() => {
|
6407
6452
|
var _a, _b, _c;
|
6408
6453
|
if (Object.keys(uiComponentList).length > 0) {
|
6409
6454
|
const matchedComponents = [];
|
@@ -6472,22 +6517,22 @@ var useComponentList = () => {
|
|
6472
6517
|
};
|
6473
6518
|
|
6474
6519
|
// components/Puck/components/Components/index.tsx
|
6475
|
-
var
|
6520
|
+
var import_react40 = require("react");
|
6476
6521
|
var import_jsx_runtime30 = require("react/jsx-runtime");
|
6477
6522
|
var Components = () => {
|
6478
6523
|
const overrides = useAppStore((s) => s.overrides);
|
6479
6524
|
const componentList = useComponentList();
|
6480
|
-
const Wrapper = (0,
|
6525
|
+
const Wrapper = (0, import_react40.useMemo)(() => overrides.components || "div", [overrides]);
|
6481
6526
|
return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Wrapper, { children: componentList ? componentList : /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(ComponentList, { id: "all" }) });
|
6482
6527
|
};
|
6483
6528
|
|
6484
6529
|
// components/Puck/components/Preview/index.tsx
|
6485
6530
|
init_react_import();
|
6486
|
-
var
|
6531
|
+
var import_react42 = require("react");
|
6487
6532
|
|
6488
6533
|
// components/AutoFrame/index.tsx
|
6489
6534
|
init_react_import();
|
6490
|
-
var
|
6535
|
+
var import_react41 = require("react");
|
6491
6536
|
var import_object_hash = __toESM(require("object-hash"));
|
6492
6537
|
var import_react_dom3 = require("react-dom");
|
6493
6538
|
var import_jsx_runtime31 = require("react/jsx-runtime");
|
@@ -6533,7 +6578,7 @@ var CopyHostStyles = ({
|
|
6533
6578
|
onStylesLoaded = () => null
|
6534
6579
|
}) => {
|
6535
6580
|
const { document: doc, window: win } = useFrame();
|
6536
|
-
(0,
|
6581
|
+
(0, import_react41.useEffect)(() => {
|
6537
6582
|
if (!win || !doc) {
|
6538
6583
|
return () => {
|
6539
6584
|
};
|
@@ -6692,8 +6737,8 @@ var CopyHostStyles = ({
|
|
6692
6737
|
}, []);
|
6693
6738
|
return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_jsx_runtime31.Fragment, { children });
|
6694
6739
|
};
|
6695
|
-
var autoFrameContext = (0,
|
6696
|
-
var useFrame = () => (0,
|
6740
|
+
var autoFrameContext = (0, import_react41.createContext)({});
|
6741
|
+
var useFrame = () => (0, import_react41.useContext)(autoFrameContext);
|
6697
6742
|
function AutoFrame(_a) {
|
6698
6743
|
var _b = _a, {
|
6699
6744
|
children,
|
@@ -6714,11 +6759,11 @@ function AutoFrame(_a) {
|
|
6714
6759
|
"onNotReady",
|
6715
6760
|
"frameRef"
|
6716
6761
|
]);
|
6717
|
-
const [loaded, setLoaded] = (0,
|
6718
|
-
const [ctx, setCtx] = (0,
|
6719
|
-
const [mountTarget, setMountTarget] = (0,
|
6720
|
-
const [stylesLoaded, setStylesLoaded] = (0,
|
6721
|
-
(0,
|
6762
|
+
const [loaded, setLoaded] = (0, import_react41.useState)(false);
|
6763
|
+
const [ctx, setCtx] = (0, import_react41.useState)({});
|
6764
|
+
const [mountTarget, setMountTarget] = (0, import_react41.useState)();
|
6765
|
+
const [stylesLoaded, setStylesLoaded] = (0, import_react41.useState)(false);
|
6766
|
+
(0, import_react41.useEffect)(() => {
|
6722
6767
|
var _a2;
|
6723
6768
|
if (frameRef.current) {
|
6724
6769
|
const doc = frameRef.current.contentDocument;
|
@@ -6770,7 +6815,7 @@ var import_jsx_runtime32 = require("react/jsx-runtime");
|
|
6770
6815
|
var getClassName23 = get_class_name_factory_default("PuckPreview", styles_module_default18);
|
6771
6816
|
var useBubbleIframeEvents = (ref) => {
|
6772
6817
|
const status = useAppStore((s) => s.status);
|
6773
|
-
(0,
|
6818
|
+
(0, import_react42.useEffect)(() => {
|
6774
6819
|
if (ref.current && status === "READY") {
|
6775
6820
|
const iframe = ref.current;
|
6776
6821
|
const handlePointerMove = (event) => {
|
@@ -6819,7 +6864,7 @@ var Preview3 = ({ id = "puck-preview" }) => {
|
|
6819
6864
|
const renderData = useAppStore(
|
6820
6865
|
(s) => s.state.ui.previewMode === "edit" ? null : s.state.data
|
6821
6866
|
);
|
6822
|
-
const Page = (0,
|
6867
|
+
const Page = (0, import_react42.useCallback)(
|
6823
6868
|
(pageProps) => {
|
6824
6869
|
var _a, _b;
|
6825
6870
|
return ((_a = config.root) == null ? void 0 : _a.render) ? (_b = config.root) == null ? void 0 : _b.render(__spreadValues({
|
@@ -6828,9 +6873,9 @@ var Preview3 = ({ id = "puck-preview" }) => {
|
|
6828
6873
|
},
|
6829
6874
|
[config.root]
|
6830
6875
|
);
|
6831
|
-
const Frame = (0,
|
6876
|
+
const Frame = (0, import_react42.useMemo)(() => overrides.iframe, [overrides]);
|
6832
6877
|
const rootProps = root.props || root;
|
6833
|
-
const ref = (0,
|
6878
|
+
const ref = (0, import_react42.useRef)(null);
|
6834
6879
|
useBubbleIframeEvents(ref);
|
6835
6880
|
const inner = !renderData ? /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
6836
6881
|
Page,
|
@@ -6845,7 +6890,7 @@ var Preview3 = ({ id = "puck-preview" }) => {
|
|
6845
6890
|
children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(DropZonePure, { zone: rootDroppableId })
|
6846
6891
|
})
|
6847
6892
|
) : /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Render, { data: renderData, config });
|
6848
|
-
(0,
|
6893
|
+
(0, import_react42.useEffect)(() => {
|
6849
6894
|
if (!iframe.enabled) {
|
6850
6895
|
setStatus("READY");
|
6851
6896
|
}
|
@@ -6936,7 +6981,7 @@ var scrollIntoView = (el) => {
|
|
6936
6981
|
};
|
6937
6982
|
|
6938
6983
|
// components/LayerTree/index.tsx
|
6939
|
-
var
|
6984
|
+
var import_react43 = require("react");
|
6940
6985
|
|
6941
6986
|
// lib/on-scroll-end.ts
|
6942
6987
|
init_react_import();
|
@@ -6971,7 +7016,7 @@ var LayerTree = ({
|
|
6971
7016
|
label
|
6972
7017
|
}) => {
|
6973
7018
|
const zones = data.zones || {};
|
6974
|
-
const ctx = (0,
|
7019
|
+
const ctx = (0, import_react43.useContext)(dropZoneContext);
|
6975
7020
|
const nodes = useAppStore((s) => s.nodes.nodes);
|
6976
7021
|
return /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(import_jsx_runtime33.Fragment, { children: [
|
6977
7022
|
label && /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { className: getClassName24("zoneTitle"), children: [
|
@@ -7083,7 +7128,7 @@ var LayerTree = ({
|
|
7083
7128
|
};
|
7084
7129
|
|
7085
7130
|
// components/Puck/components/Outline/index.tsx
|
7086
|
-
var
|
7131
|
+
var import_react44 = require("react");
|
7087
7132
|
var import_jsx_runtime34 = require("react/jsx-runtime");
|
7088
7133
|
var Outline = () => {
|
7089
7134
|
const state = useAppStore((s) => s.state);
|
@@ -7092,7 +7137,7 @@ var Outline = () => {
|
|
7092
7137
|
const { data, ui } = state;
|
7093
7138
|
const { itemSelector } = ui;
|
7094
7139
|
const appStore = useAppStoreApi();
|
7095
|
-
const setItemSelector = (0,
|
7140
|
+
const setItemSelector = (0, import_react44.useCallback)(
|
7096
7141
|
(newItemSelector) => {
|
7097
7142
|
const { dispatch } = appStore.getState();
|
7098
7143
|
dispatch({
|
@@ -7102,7 +7147,7 @@ var Outline = () => {
|
|
7102
7147
|
},
|
7103
7148
|
[appStore]
|
7104
7149
|
);
|
7105
|
-
const Wrapper = (0,
|
7150
|
+
const Wrapper = (0, import_react44.useMemo)(() => outlineOverride || "div", [outlineOverride]);
|
7106
7151
|
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: [
|
7107
7152
|
(ctx == null ? void 0 : ctx.activeZones) && (ctx == null ? void 0 : ctx.activeZones[rootDroppableId]) && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
7108
7153
|
LayerTree,
|
@@ -7258,11 +7303,11 @@ var getBox = function getBox2(el) {
|
|
7258
7303
|
};
|
7259
7304
|
|
7260
7305
|
// components/Puck/components/Canvas/index.tsx
|
7261
|
-
var
|
7306
|
+
var import_react46 = require("react");
|
7262
7307
|
|
7263
7308
|
// components/ViewportControls/index.tsx
|
7264
7309
|
init_react_import();
|
7265
|
-
var
|
7310
|
+
var import_react45 = require("react");
|
7266
7311
|
|
7267
7312
|
// css-module:/home/runner/work/puck/puck/packages/core/components/ViewportControls/styles.module.css#css-module
|
7268
7313
|
init_react_import();
|
@@ -7285,8 +7330,8 @@ var ViewportButton = ({
|
|
7285
7330
|
onClick
|
7286
7331
|
}) => {
|
7287
7332
|
const viewports = useAppStore((s) => s.state.ui.viewports);
|
7288
|
-
const [isActive, setIsActive] = (0,
|
7289
|
-
(0,
|
7333
|
+
const [isActive, setIsActive] = (0, import_react45.useState)(false);
|
7334
|
+
(0, import_react45.useEffect)(() => {
|
7290
7335
|
setIsActive(width === viewports.current.width);
|
7291
7336
|
}, [width, viewports.current.width]);
|
7292
7337
|
return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("span", { className: getClassNameButton({ isActive }), children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
@@ -7322,7 +7367,7 @@ var ViewportControls = ({
|
|
7322
7367
|
const defaultsContainAutoZoom = defaultZoomOptions.find(
|
7323
7368
|
(option) => option.value === autoZoom
|
7324
7369
|
);
|
7325
|
-
const zoomOptions = (0,
|
7370
|
+
const zoomOptions = (0, import_react45.useMemo)(
|
7326
7371
|
() => [
|
7327
7372
|
...defaultZoomOptions,
|
7328
7373
|
...defaultsContainAutoZoom ? [] : [
|
@@ -7469,17 +7514,17 @@ var Canvas = () => {
|
|
7469
7514
|
viewports: s.state.ui.viewports
|
7470
7515
|
}))
|
7471
7516
|
);
|
7472
|
-
const frameRef = (0,
|
7473
|
-
const [showTransition, setShowTransition] = (0,
|
7474
|
-
const defaultRender = (0,
|
7517
|
+
const frameRef = (0, import_react46.useRef)(null);
|
7518
|
+
const [showTransition, setShowTransition] = (0, import_react46.useState)(false);
|
7519
|
+
const defaultRender = (0, import_react46.useMemo)(() => {
|
7475
7520
|
const PuckDefault = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_jsx_runtime36.Fragment, { children });
|
7476
7521
|
return PuckDefault;
|
7477
7522
|
}, []);
|
7478
|
-
const CustomPreview = (0,
|
7523
|
+
const CustomPreview = (0, import_react46.useMemo)(
|
7479
7524
|
() => overrides.preview || defaultRender,
|
7480
7525
|
[overrides]
|
7481
7526
|
);
|
7482
|
-
const getFrameDimensions = (0,
|
7527
|
+
const getFrameDimensions = (0, import_react46.useCallback)(() => {
|
7483
7528
|
if (frameRef.current) {
|
7484
7529
|
const frame = frameRef.current;
|
7485
7530
|
const box = getBox(frame);
|
@@ -7487,7 +7532,7 @@ var Canvas = () => {
|
|
7487
7532
|
}
|
7488
7533
|
return { width: 0, height: 0 };
|
7489
7534
|
}, [frameRef]);
|
7490
|
-
const resetAutoZoom = (0,
|
7535
|
+
const resetAutoZoom = (0, import_react46.useCallback)(
|
7491
7536
|
(newViewports = viewports) => {
|
7492
7537
|
if (frameRef.current) {
|
7493
7538
|
setZoomConfig(
|
@@ -7501,11 +7546,11 @@ var Canvas = () => {
|
|
7501
7546
|
},
|
7502
7547
|
[frameRef, zoomConfig, viewports]
|
7503
7548
|
);
|
7504
|
-
(0,
|
7549
|
+
(0, import_react46.useEffect)(() => {
|
7505
7550
|
setShowTransition(false);
|
7506
7551
|
resetAutoZoom(viewports);
|
7507
7552
|
}, [frameRef, leftSideBarVisible, rightSideBarVisible]);
|
7508
|
-
(0,
|
7553
|
+
(0, import_react46.useEffect)(() => {
|
7509
7554
|
const { height: frameHeight } = getFrameDimensions();
|
7510
7555
|
if (viewports.current.height === "auto") {
|
7511
7556
|
setZoomConfig(__spreadProps(__spreadValues({}, zoomConfig), {
|
@@ -7513,13 +7558,13 @@ var Canvas = () => {
|
|
7513
7558
|
}));
|
7514
7559
|
}
|
7515
7560
|
}, [zoomConfig.zoom]);
|
7516
|
-
(0,
|
7561
|
+
(0, import_react46.useEffect)(() => {
|
7517
7562
|
if (ZOOM_ON_CHANGE) {
|
7518
7563
|
setShowTransition(true);
|
7519
7564
|
resetAutoZoom(viewports);
|
7520
7565
|
}
|
7521
7566
|
}, [viewports.current.width]);
|
7522
|
-
(0,
|
7567
|
+
(0, import_react46.useEffect)(() => {
|
7523
7568
|
const cb = () => {
|
7524
7569
|
setShowTransition(false);
|
7525
7570
|
resetAutoZoom();
|
@@ -7529,8 +7574,8 @@ var Canvas = () => {
|
|
7529
7574
|
window.removeEventListener("resize", cb);
|
7530
7575
|
};
|
7531
7576
|
}, []);
|
7532
|
-
const [showLoader, setShowLoader] = (0,
|
7533
|
-
(0,
|
7577
|
+
const [showLoader, setShowLoader] = (0, import_react46.useState)(false);
|
7578
|
+
(0, import_react46.useEffect)(() => {
|
7534
7579
|
setTimeout(() => {
|
7535
7580
|
setShowLoader(true);
|
7536
7581
|
}, 500);
|
@@ -7608,7 +7653,7 @@ var Canvas = () => {
|
|
7608
7653
|
|
7609
7654
|
// lib/use-loaded-overrides.ts
|
7610
7655
|
init_react_import();
|
7611
|
-
var
|
7656
|
+
var import_react47 = require("react");
|
7612
7657
|
|
7613
7658
|
// lib/load-overrides.ts
|
7614
7659
|
init_react_import();
|
@@ -7647,7 +7692,7 @@ var useLoadedOverrides = ({
|
|
7647
7692
|
overrides,
|
7648
7693
|
plugins
|
7649
7694
|
}) => {
|
7650
|
-
return (0,
|
7695
|
+
return (0, import_react47.useMemo)(() => {
|
7651
7696
|
return loadOverrides({ overrides, plugins });
|
7652
7697
|
}, [plugins, overrides]);
|
7653
7698
|
};
|
@@ -7659,14 +7704,14 @@ var DefaultOverride = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime37
|
|
7659
7704
|
|
7660
7705
|
// lib/use-inject-css.ts
|
7661
7706
|
init_react_import();
|
7662
|
-
var
|
7707
|
+
var import_react48 = require("react");
|
7663
7708
|
var styles = ``;
|
7664
7709
|
var useInjectStyleSheet = (initialStyles, iframeEnabled) => {
|
7665
|
-
const [el, setEl] = (0,
|
7666
|
-
(0,
|
7710
|
+
const [el, setEl] = (0, import_react48.useState)();
|
7711
|
+
(0, import_react48.useEffect)(() => {
|
7667
7712
|
setEl(document.createElement("style"));
|
7668
7713
|
}, []);
|
7669
|
-
(0,
|
7714
|
+
(0, import_react48.useEffect)(() => {
|
7670
7715
|
var _a;
|
7671
7716
|
if (!el || typeof window === "undefined") {
|
7672
7717
|
return;
|
@@ -7686,10 +7731,10 @@ var useInjectGlobalCss = (iframeEnabled) => {
|
|
7686
7731
|
|
7687
7732
|
// lib/use-preview-mode-hotkeys.ts
|
7688
7733
|
init_react_import();
|
7689
|
-
var
|
7734
|
+
var import_react49 = require("react");
|
7690
7735
|
var usePreviewModeHotkeys = () => {
|
7691
7736
|
const appStore = useAppStoreApi();
|
7692
|
-
const toggleInteractive = (0,
|
7737
|
+
const toggleInteractive = (0, import_react49.useCallback)(() => {
|
7693
7738
|
const dispatch = appStore.getState().dispatch;
|
7694
7739
|
dispatch({
|
7695
7740
|
type: "setUi",
|
@@ -7704,7 +7749,7 @@ var usePreviewModeHotkeys = () => {
|
|
7704
7749
|
|
7705
7750
|
// lib/use-puck.ts
|
7706
7751
|
init_react_import();
|
7707
|
-
var
|
7752
|
+
var import_react50 = require("react");
|
7708
7753
|
var import_zustand6 = require("zustand");
|
7709
7754
|
var generateUsePuck = (store) => {
|
7710
7755
|
const history = {
|
@@ -7729,14 +7774,14 @@ var generateUsePuck = (store) => {
|
|
7729
7774
|
const get = () => storeData;
|
7730
7775
|
return __spreadProps(__spreadValues({}, storeData), { get });
|
7731
7776
|
};
|
7732
|
-
var UsePuckStoreContext = (0,
|
7777
|
+
var UsePuckStoreContext = (0, import_react50.createContext)(
|
7733
7778
|
null
|
7734
7779
|
);
|
7735
7780
|
var useRegisterUsePuckStore = (appStore) => {
|
7736
|
-
const [usePuckStore] = (0,
|
7781
|
+
const [usePuckStore] = (0, import_react50.useState)(
|
7737
7782
|
() => (0, import_zustand6.createStore)(() => generateUsePuck(appStore.getState()))
|
7738
7783
|
);
|
7739
|
-
(0,
|
7784
|
+
(0, import_react50.useEffect)(() => {
|
7740
7785
|
return appStore.subscribe(
|
7741
7786
|
(store) => {
|
7742
7787
|
const pickedStore = {
|
@@ -7758,7 +7803,7 @@ var useRegisterUsePuckStore = (appStore) => {
|
|
7758
7803
|
};
|
7759
7804
|
function createUsePuck() {
|
7760
7805
|
return function usePuck2(selector) {
|
7761
|
-
const usePuckApi = (0,
|
7806
|
+
const usePuckApi = (0, import_react50.useContext)(UsePuckStoreContext);
|
7762
7807
|
if (!usePuckApi) {
|
7763
7808
|
throw new Error("usePuck must be used inside <Puck>.");
|
7764
7809
|
}
|
@@ -7770,7 +7815,7 @@ function createUsePuck() {
|
|
7770
7815
|
};
|
7771
7816
|
}
|
7772
7817
|
function usePuck() {
|
7773
|
-
(0,
|
7818
|
+
(0, import_react50.useEffect)(() => {
|
7774
7819
|
console.warn(
|
7775
7820
|
"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."
|
7776
7821
|
);
|
@@ -7791,11 +7836,11 @@ var FieldSideBar = () => {
|
|
7791
7836
|
);
|
7792
7837
|
return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(SidebarSection, { noPadding: true, noBorderTop: true, showBreadcrumbs: true, title, children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(Fields, {}) });
|
7793
7838
|
};
|
7794
|
-
var propsContext = (0,
|
7839
|
+
var propsContext = (0, import_react51.createContext)({});
|
7795
7840
|
function PropsProvider(props) {
|
7796
7841
|
return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(propsContext.Provider, { value: props, children: props.children });
|
7797
7842
|
}
|
7798
|
-
var usePropsContext = () => (0,
|
7843
|
+
var usePropsContext = () => (0, import_react51.useContext)(propsContext);
|
7799
7844
|
function PuckProvider({ children }) {
|
7800
7845
|
const {
|
7801
7846
|
config,
|
@@ -7815,7 +7860,7 @@ function PuckProvider({ children }) {
|
|
7815
7860
|
enabled: true,
|
7816
7861
|
waitForStyles: true
|
7817
7862
|
}, _iframe);
|
7818
|
-
const [generatedAppState] = (0,
|
7863
|
+
const [generatedAppState] = (0, import_react51.useState)(() => {
|
7819
7864
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
7820
7865
|
const initial = __spreadValues(__spreadValues({}, defaultAppState.ui), initialUi);
|
7821
7866
|
let clientUiState = {};
|
@@ -7887,7 +7932,7 @@ function PuckProvider({ children }) {
|
|
7887
7932
|
overrides,
|
7888
7933
|
plugins
|
7889
7934
|
});
|
7890
|
-
const generateAppStore = (0,
|
7935
|
+
const generateAppStore = (0, import_react51.useCallback)(() => {
|
7891
7936
|
return {
|
7892
7937
|
state: initialAppState,
|
7893
7938
|
config,
|
@@ -7908,8 +7953,8 @@ function PuckProvider({ children }) {
|
|
7908
7953
|
onAction,
|
7909
7954
|
metadata
|
7910
7955
|
]);
|
7911
|
-
const [appStore] = (0,
|
7912
|
-
(0,
|
7956
|
+
const [appStore] = (0, import_react51.useState)(() => createAppStore(generateAppStore()));
|
7957
|
+
(0, import_react51.useEffect)(() => {
|
7913
7958
|
appStore.setState(__spreadValues({}, generateAppStore()));
|
7914
7959
|
}, [
|
7915
7960
|
initialAppState,
|
@@ -7926,7 +7971,7 @@ function PuckProvider({ children }) {
|
|
7926
7971
|
index: initialHistoryIndex,
|
7927
7972
|
initialAppState
|
7928
7973
|
});
|
7929
|
-
(0,
|
7974
|
+
(0, import_react51.useEffect)(() => {
|
7930
7975
|
appStore.subscribe((s) => {
|
7931
7976
|
if (onChange) onChange(s.state.data);
|
7932
7977
|
});
|
@@ -7934,7 +7979,7 @@ function PuckProvider({ children }) {
|
|
7934
7979
|
useRegisterNodesSlice(appStore);
|
7935
7980
|
useRegisterPermissionsSlice(appStore, permissions);
|
7936
7981
|
const uPuckStore = useRegisterUsePuckStore(appStore);
|
7937
|
-
(0,
|
7982
|
+
(0, import_react51.useEffect)(() => {
|
7938
7983
|
const { state, resolveData: resolveData2 } = appStore.getState();
|
7939
7984
|
resolveData2(state);
|
7940
7985
|
}, []);
|
@@ -7961,9 +8006,9 @@ function PuckLayout({ children }) {
|
|
7961
8006
|
const rightSideBarVisible = useAppStore(
|
7962
8007
|
(s) => s.state.ui.rightSideBarVisible
|
7963
8008
|
);
|
7964
|
-
const [menuOpen, setMenuOpen] = (0,
|
8009
|
+
const [menuOpen, setMenuOpen] = (0, import_react51.useState)(false);
|
7965
8010
|
const appStore = useAppStoreApi();
|
7966
|
-
(0,
|
8011
|
+
(0, import_react51.useEffect)(() => {
|
7967
8012
|
return appStore.subscribe((s) => {
|
7968
8013
|
if (onChange) onChange(s.state.data);
|
7969
8014
|
});
|
@@ -7972,7 +8017,7 @@ function PuckLayout({ children }) {
|
|
7972
8017
|
(s) => s.state.data.root.props || s.state.data.root.props
|
7973
8018
|
);
|
7974
8019
|
const dispatch = useAppStore((s) => s.dispatch);
|
7975
|
-
const toggleSidebars = (0,
|
8020
|
+
const toggleSidebars = (0, import_react51.useCallback)(
|
7976
8021
|
(sidebar) => {
|
7977
8022
|
const widerViewport = window.matchMedia("(min-width: 638px)").matches;
|
7978
8023
|
const sideBarVisible = sidebar === "left" ? leftSideBarVisible : rightSideBarVisible;
|
@@ -7986,7 +8031,7 @@ function PuckLayout({ children }) {
|
|
7986
8031
|
},
|
7987
8032
|
[dispatch, leftSideBarVisible, rightSideBarVisible]
|
7988
8033
|
);
|
7989
|
-
(0,
|
8034
|
+
(0, import_react51.useEffect)(() => {
|
7990
8035
|
if (!window.matchMedia("(min-width: 638px)").matches) {
|
7991
8036
|
dispatch({
|
7992
8037
|
type: "setUi",
|
@@ -8009,7 +8054,7 @@ function PuckLayout({ children }) {
|
|
8009
8054
|
window.removeEventListener("resize", handleResize);
|
8010
8055
|
};
|
8011
8056
|
}, []);
|
8012
|
-
const defaultHeaderRender = (0,
|
8057
|
+
const defaultHeaderRender = (0, import_react51.useMemo)(() => {
|
8013
8058
|
if (renderHeader) {
|
8014
8059
|
console.warn(
|
8015
8060
|
"`renderHeader` is deprecated. Please use `overrides.header` and the `usePuck` hook instead"
|
@@ -8024,7 +8069,7 @@ function PuckLayout({ children }) {
|
|
8024
8069
|
}
|
8025
8070
|
return DefaultOverride;
|
8026
8071
|
}, [renderHeader]);
|
8027
|
-
const defaultHeaderActionsRender = (0,
|
8072
|
+
const defaultHeaderActionsRender = (0, import_react51.useMemo)(() => {
|
8028
8073
|
if (renderHeaderActions) {
|
8029
8074
|
console.warn(
|
8030
8075
|
"`renderHeaderActions` is deprecated. Please use `overrides.headerActions` and the `usePuck` hook instead."
|
@@ -8039,25 +8084,25 @@ function PuckLayout({ children }) {
|
|
8039
8084
|
return DefaultOverride;
|
8040
8085
|
}, [renderHeader]);
|
8041
8086
|
const overrides = useAppStore((s) => s.overrides);
|
8042
|
-
const CustomPuck = (0,
|
8087
|
+
const CustomPuck = (0, import_react51.useMemo)(
|
8043
8088
|
() => overrides.puck || DefaultOverride,
|
8044
8089
|
[overrides]
|
8045
8090
|
);
|
8046
|
-
const CustomHeader = (0,
|
8091
|
+
const CustomHeader = (0, import_react51.useMemo)(
|
8047
8092
|
() => overrides.header || defaultHeaderRender,
|
8048
8093
|
[overrides]
|
8049
8094
|
);
|
8050
|
-
const CustomHeaderActions = (0,
|
8095
|
+
const CustomHeaderActions = (0, import_react51.useMemo)(
|
8051
8096
|
() => overrides.headerActions || defaultHeaderActionsRender,
|
8052
8097
|
[overrides]
|
8053
8098
|
);
|
8054
|
-
const [mounted, setMounted] = (0,
|
8055
|
-
(0,
|
8099
|
+
const [mounted, setMounted] = (0, import_react51.useState)(false);
|
8100
|
+
(0, import_react51.useEffect)(() => {
|
8056
8101
|
setMounted(true);
|
8057
8102
|
}, []);
|
8058
8103
|
const ready = useAppStore((s) => s.status === "READY");
|
8059
8104
|
useMonitorHotkeys();
|
8060
|
-
(0,
|
8105
|
+
(0, import_react51.useEffect)(() => {
|
8061
8106
|
if (ready && iframe.enabled) {
|
8062
8107
|
const frameDoc = getFrame();
|
8063
8108
|
if (frameDoc) {
|