@measured/puck 0.19.0-canary.cc5dc01 → 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.mjs
CHANGED
@@ -8,7 +8,6 @@ import {
|
|
8
8
|
__spreadProps,
|
9
9
|
__spreadValues,
|
10
10
|
__toESM,
|
11
|
-
defaultData,
|
12
11
|
getChanged,
|
13
12
|
init_react_import,
|
14
13
|
resolveAllData,
|
@@ -17,8 +16,9 @@ import {
|
|
17
16
|
rootAreaId,
|
18
17
|
rootDroppableId,
|
19
18
|
rootZone,
|
20
|
-
setupZone
|
21
|
-
|
19
|
+
setupZone,
|
20
|
+
transformProps
|
21
|
+
} from "./chunk-7N5DRY4G.mjs";
|
22
22
|
|
23
23
|
// ../../node_modules/classnames/index.js
|
24
24
|
var require_classnames = __commonJS({
|
@@ -215,7 +215,7 @@ import {
|
|
215
215
|
useContext as useContext3,
|
216
216
|
useEffect as useEffect11,
|
217
217
|
useMemo as useMemo5,
|
218
|
-
useState as
|
218
|
+
useState as useState8
|
219
219
|
} from "react";
|
220
220
|
|
221
221
|
// components/AutoField/fields/index.tsx
|
@@ -676,7 +676,7 @@ var IconButton = ({
|
|
676
676
|
};
|
677
677
|
|
678
678
|
// components/AutoField/fields/ArrayField/index.tsx
|
679
|
-
import { useCallback as useCallback2, useEffect as useEffect6, useState as
|
679
|
+
import { useCallback as useCallback2, useEffect as useEffect6, useState as useState3 } from "react";
|
680
680
|
|
681
681
|
// components/DragIcon/index.tsx
|
682
682
|
init_react_import();
|
@@ -1891,7 +1891,6 @@ function useAppStoreApi() {
|
|
1891
1891
|
// components/Sortable/index.tsx
|
1892
1892
|
init_react_import();
|
1893
1893
|
import { DragDropProvider } from "@dnd-kit/react";
|
1894
|
-
import { useState as useState3 } from "react";
|
1895
1894
|
|
1896
1895
|
// lib/dnd/dnd-kit/safe.ts
|
1897
1896
|
init_react_import();
|
@@ -1917,7 +1916,8 @@ function useDraggableSafe(input) {
|
|
1917
1916
|
function useSortableSafe(input) {
|
1918
1917
|
if (typeof window === "undefined") {
|
1919
1918
|
return { ref: () => {
|
1920
|
-
}, status: "idle"
|
1919
|
+
}, status: "idle", handleRef: () => {
|
1920
|
+
} };
|
1921
1921
|
}
|
1922
1922
|
return useSortable(input);
|
1923
1923
|
}
|
@@ -1950,6 +1950,7 @@ var _PointerSensor = class _PointerSensor extends Sensor {
|
|
1950
1950
|
this.listeners = new Listeners();
|
1951
1951
|
this.cleanup = /* @__PURE__ */ new Set();
|
1952
1952
|
this.source = void 0;
|
1953
|
+
this.started = false;
|
1953
1954
|
__privateAdd(this, _clearTimeout);
|
1954
1955
|
this.handleCancel = this.handleCancel.bind(this);
|
1955
1956
|
this.handlePointerUp = this.handlePointerUp.bind(this);
|
@@ -2107,6 +2108,12 @@ var _PointerSensor = class _PointerSensor extends Sensor {
|
|
2107
2108
|
if (!status.idle) {
|
2108
2109
|
const canceled = !status.initialized;
|
2109
2110
|
this.manager.actions.stop({ canceled });
|
2111
|
+
} else if (this.started) {
|
2112
|
+
setTimeout(() => {
|
2113
|
+
if (!this.manager.dragOperation.status.idle) {
|
2114
|
+
this.manager.actions.stop({ canceled: false });
|
2115
|
+
}
|
2116
|
+
}, 10);
|
2110
2117
|
}
|
2111
2118
|
this.cleanup.forEach((cleanup) => cleanup());
|
2112
2119
|
this.cleanup.clear();
|
@@ -2121,12 +2128,13 @@ var _PointerSensor = class _PointerSensor extends Sensor {
|
|
2121
2128
|
var _a;
|
2122
2129
|
const { manager, initialCoordinates } = this;
|
2123
2130
|
(_a = __privateGet(this, _clearTimeout)) == null ? void 0 : _a.call(this);
|
2124
|
-
if (!initialCoordinates || manager.dragOperation.status.initialized) {
|
2131
|
+
if (!initialCoordinates || manager.dragOperation.status.initialized || this.started) {
|
2125
2132
|
return;
|
2126
2133
|
}
|
2127
2134
|
if (event.defaultPrevented) {
|
2128
2135
|
return;
|
2129
2136
|
}
|
2137
|
+
this.started = true;
|
2130
2138
|
event.preventDefault();
|
2131
2139
|
batch(() => {
|
2132
2140
|
manager.actions.setDragSource(source.id);
|
@@ -2154,6 +2162,9 @@ var _PointerSensor = class _PointerSensor extends Sensor {
|
|
2154
2162
|
]);
|
2155
2163
|
ownerDocument.body.setPointerCapture(event.pointerId);
|
2156
2164
|
this.cleanup.add(unbind);
|
2165
|
+
this.cleanup.add(() => {
|
2166
|
+
this.started = false;
|
2167
|
+
});
|
2157
2168
|
}
|
2158
2169
|
handleDragStart(event) {
|
2159
2170
|
const { target } = event;
|
@@ -2201,23 +2212,26 @@ function patchWindow(window2) {
|
|
2201
2212
|
|
2202
2213
|
// lib/dnd/use-sensors.ts
|
2203
2214
|
import { isElement as isElement2 } from "@dnd-kit/dom/utilities";
|
2204
|
-
var useSensors = (
|
2215
|
+
var useSensors = ({
|
2216
|
+
other,
|
2217
|
+
mouse,
|
2218
|
+
touch
|
2219
|
+
} = {
|
2220
|
+
touch: { delay: { value: 200, tolerance: 10 } },
|
2221
|
+
other: { delay: { value: 200, tolerance: 10 }, distance: { value: 5 } }
|
2222
|
+
}) => {
|
2205
2223
|
const [sensors] = useState2(() => [
|
2206
2224
|
PointerSensor.configure({
|
2207
2225
|
activationConstraints(event, source) {
|
2208
2226
|
var _a;
|
2209
2227
|
const { pointerType, target } = event;
|
2210
2228
|
if (pointerType === "mouse" && isElement2(target) && (source.handle === target || ((_a = source.handle) == null ? void 0 : _a.contains(target)))) {
|
2211
|
-
return
|
2229
|
+
return mouse;
|
2212
2230
|
}
|
2213
|
-
const delay = { value: 200, tolerance: 10 };
|
2214
2231
|
if (pointerType === "touch") {
|
2215
|
-
return
|
2232
|
+
return touch;
|
2216
2233
|
}
|
2217
|
-
return
|
2218
|
-
delay,
|
2219
|
-
distance: { value: 5 }
|
2220
|
-
};
|
2234
|
+
return other;
|
2221
2235
|
}
|
2222
2236
|
})
|
2223
2237
|
]);
|
@@ -2563,7 +2577,6 @@ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input
|
|
2563
2577
|
};
|
2564
2578
|
|
2565
2579
|
// components/Sortable/index.tsx
|
2566
|
-
import { RestrictToElement } from "@dnd-kit/dom/modifiers";
|
2567
2580
|
import { jsx as jsx5 } from "react/jsx-runtime";
|
2568
2581
|
var SortableProvider = ({
|
2569
2582
|
children,
|
@@ -2571,22 +2584,20 @@ var SortableProvider = ({
|
|
2571
2584
|
onDragEnd,
|
2572
2585
|
onMove
|
2573
2586
|
}) => {
|
2574
|
-
const
|
2575
|
-
|
2587
|
+
const sensors = useSensors({
|
2588
|
+
mouse: { distance: { value: 5 } }
|
2589
|
+
});
|
2576
2590
|
return /* @__PURE__ */ jsx5(
|
2577
2591
|
DragDropProvider,
|
2578
2592
|
{
|
2579
2593
|
sensors,
|
2580
|
-
|
2581
|
-
|
2582
|
-
|
2583
|
-
|
2584
|
-
}
|
2585
|
-
})
|
2586
|
-
],
|
2587
|
-
onDragStart,
|
2594
|
+
onDragStart: (event) => {
|
2595
|
+
var _a, _b;
|
2596
|
+
return onDragStart((_b = (_a = event.operation.source) == null ? void 0 : _a.id.toString()) != null ? _b : "");
|
2597
|
+
},
|
2588
2598
|
onDragOver: (event, manager) => {
|
2589
2599
|
var _a, _b;
|
2600
|
+
event.preventDefault();
|
2590
2601
|
const { operation } = event;
|
2591
2602
|
const { source, target } = operation;
|
2592
2603
|
if (!source || !target) return;
|
@@ -2594,14 +2605,14 @@ var SortableProvider = ({
|
|
2594
2605
|
let targetIndex = target.data.index;
|
2595
2606
|
const collisionData = (_b = (_a = manager.dragOperation.data) == null ? void 0 : _a.collisionMap) == null ? void 0 : _b[target.id];
|
2596
2607
|
if (sourceIndex !== targetIndex && source.id !== target.id) {
|
2597
|
-
const collisionPosition =
|
2608
|
+
const collisionPosition = collisionData.direction === "up" ? "before" : "after";
|
2598
2609
|
if (targetIndex >= sourceIndex) {
|
2599
2610
|
targetIndex = targetIndex - 1;
|
2600
2611
|
}
|
2601
2612
|
if (collisionPosition === "after") {
|
2602
2613
|
targetIndex = targetIndex + 1;
|
2603
2614
|
}
|
2604
|
-
|
2615
|
+
onMove({
|
2605
2616
|
source: sourceIndex,
|
2606
2617
|
target: targetIndex
|
2607
2618
|
});
|
@@ -2609,12 +2620,8 @@ var SortableProvider = ({
|
|
2609
2620
|
},
|
2610
2621
|
onDragEnd: () => {
|
2611
2622
|
setTimeout(() => {
|
2612
|
-
if (move.source !== -1 && move.target !== -1) {
|
2613
|
-
onMove(move);
|
2614
|
-
}
|
2615
2623
|
onDragEnd();
|
2616
2624
|
}, 250);
|
2617
|
-
setMove({ source: -1, target: -1 });
|
2618
2625
|
},
|
2619
2626
|
children
|
2620
2627
|
}
|
@@ -2627,7 +2634,11 @@ var Sortable = ({
|
|
2627
2634
|
children,
|
2628
2635
|
type = "item"
|
2629
2636
|
}) => {
|
2630
|
-
const {
|
2637
|
+
const {
|
2638
|
+
ref: sortableRef,
|
2639
|
+
status,
|
2640
|
+
handleRef
|
2641
|
+
} = useSortableSafe({
|
2631
2642
|
id,
|
2632
2643
|
type,
|
2633
2644
|
index,
|
@@ -2635,7 +2646,7 @@ var Sortable = ({
|
|
2635
2646
|
data: { index },
|
2636
2647
|
collisionDetector: createDynamicCollisionDetector("y")
|
2637
2648
|
});
|
2638
|
-
return children({ status, ref: sortableRef });
|
2649
|
+
return children({ status, ref: sortableRef, handleRef });
|
2639
2650
|
};
|
2640
2651
|
|
2641
2652
|
// components/AutoField/context.tsx
|
@@ -2693,6 +2704,7 @@ var ArrayField = ({
|
|
2693
2704
|
value: _value,
|
2694
2705
|
name,
|
2695
2706
|
label,
|
2707
|
+
labelIcon,
|
2696
2708
|
readOnly,
|
2697
2709
|
id,
|
2698
2710
|
Label: Label2 = (props) => /* @__PURE__ */ jsx7("div", __spreadValues({}, props))
|
@@ -2710,10 +2722,12 @@ var ArrayField = ({
|
|
2710
2722
|
}),
|
2711
2723
|
openId: ""
|
2712
2724
|
};
|
2713
|
-
const [localState, setLocalState] =
|
2725
|
+
const [localState, setLocalState] = useState3({ arrayState, value });
|
2714
2726
|
useEffect6(() => {
|
2715
|
-
|
2716
|
-
|
2727
|
+
var _a;
|
2728
|
+
const _arrayState = (_a = appStore.getState().state.ui.arrayState[id]) != null ? _a : arrayState;
|
2729
|
+
setLocalState({ arrayState: _arrayState, value });
|
2730
|
+
}, [value]);
|
2717
2731
|
const appStore = useAppStoreApi();
|
2718
2732
|
const mapArrayStateToUi = useCallback2(
|
2719
2733
|
(partialArrayState) => {
|
@@ -2756,7 +2770,8 @@ var ArrayField = ({
|
|
2756
2770
|
setUi(mapArrayStateToUi(arrayState));
|
2757
2771
|
}
|
2758
2772
|
}, []);
|
2759
|
-
const [
|
2773
|
+
const [draggedItem, setDraggedItem] = useState3("");
|
2774
|
+
const isDragging = !!draggedItem;
|
2760
2775
|
const canEdit = useAppStore(
|
2761
2776
|
(s) => s.permissions.getPermissions({ item: s.selectedItem }).edit
|
2762
2777
|
);
|
@@ -2769,16 +2784,22 @@ var ArrayField = ({
|
|
2769
2784
|
Label2,
|
2770
2785
|
{
|
2771
2786
|
label: label || name,
|
2772
|
-
icon: /* @__PURE__ */ jsx7(List, { size: 16 }),
|
2787
|
+
icon: labelIcon || /* @__PURE__ */ jsx7(List, { size: 16 }),
|
2773
2788
|
el: "div",
|
2774
2789
|
readOnly,
|
2775
2790
|
children: /* @__PURE__ */ jsx7(
|
2776
2791
|
SortableProvider,
|
2777
2792
|
{
|
2778
|
-
onDragStart: () =>
|
2779
|
-
onDragEnd: () =>
|
2793
|
+
onDragStart: (id2) => setDraggedItem(id2),
|
2794
|
+
onDragEnd: () => {
|
2795
|
+
setDraggedItem("");
|
2796
|
+
onChange(localState.value);
|
2797
|
+
},
|
2780
2798
|
onMove: (move) => {
|
2781
|
-
|
2799
|
+
if (arrayState.items[move.source]._arrayId !== draggedItem) {
|
2800
|
+
return;
|
2801
|
+
}
|
2802
|
+
const newValue = reorder(localState.value, move.source, move.target);
|
2782
2803
|
const newArrayStateItems = reorder(
|
2783
2804
|
arrayState.items,
|
2784
2805
|
move.source,
|
@@ -2791,7 +2812,6 @@ var ArrayField = ({
|
|
2791
2812
|
})
|
2792
2813
|
};
|
2793
2814
|
setUi(newUi, false);
|
2794
|
-
onChange(newValue, newUi);
|
2795
2815
|
setLocalState({
|
2796
2816
|
value: newValue,
|
2797
2817
|
arrayState: __spreadProps(__spreadValues({}, arrayState), { items: newArrayStateItems })
|
@@ -2804,11 +2824,8 @@ var ArrayField = ({
|
|
2804
2824
|
hasItems: Array.isArray(value) && value.length > 0,
|
2805
2825
|
addDisabled
|
2806
2826
|
}),
|
2807
|
-
onClick: (e) => {
|
2808
|
-
e.preventDefault();
|
2809
|
-
},
|
2810
2827
|
children: [
|
2811
|
-
/* @__PURE__ */ jsx7("div", { className: getClassName5("inner"), "data-dnd-container": true, children: localState.arrayState.items.map((item, i) => {
|
2828
|
+
localState.arrayState.items.length > 0 && /* @__PURE__ */ jsx7("div", { className: getClassName5("inner"), "data-dnd-container": true, children: localState.arrayState.items.map((item, i) => {
|
2812
2829
|
const { _arrayId = `${id}-${i}`, _originalIndex = i } = item;
|
2813
2830
|
const data = Array.from(localState.value || [])[i] || {};
|
2814
2831
|
return /* @__PURE__ */ jsx7(
|
@@ -2817,7 +2834,7 @@ var ArrayField = ({
|
|
2817
2834
|
id: _arrayId,
|
2818
2835
|
index: i,
|
2819
2836
|
disabled: readOnly,
|
2820
|
-
children: ({ status, ref }) => /* @__PURE__ */ jsxs3(
|
2837
|
+
children: ({ status, ref, handleRef }) => /* @__PURE__ */ jsxs3(
|
2821
2838
|
"div",
|
2822
2839
|
{
|
2823
2840
|
ref,
|
@@ -2830,6 +2847,7 @@ var ArrayField = ({
|
|
2830
2847
|
/* @__PURE__ */ jsxs3(
|
2831
2848
|
"div",
|
2832
2849
|
{
|
2850
|
+
ref: handleRef,
|
2833
2851
|
onClick: (e) => {
|
2834
2852
|
if (isDragging) return;
|
2835
2853
|
e.preventDefault();
|
@@ -2866,12 +2884,11 @@ var ArrayField = ({
|
|
2866
2884
|
0,
|
2867
2885
|
existingValue[i]
|
2868
2886
|
);
|
2869
|
-
|
2870
|
-
existingValue
|
2871
|
-
mapArrayStateToUi(
|
2872
|
-
regenerateArrayState(existingValue)
|
2873
|
-
)
|
2887
|
+
const newUi = mapArrayStateToUi(
|
2888
|
+
regenerateArrayState(existingValue)
|
2874
2889
|
);
|
2890
|
+
setUi(newUi, false);
|
2891
|
+
onChange(existingValue);
|
2875
2892
|
},
|
2876
2893
|
title: "Duplicate",
|
2877
2894
|
children: /* @__PURE__ */ jsx7(Copy, { size: 16 })
|
@@ -2890,12 +2907,13 @@ var ArrayField = ({
|
|
2890
2907
|
];
|
2891
2908
|
existingValue.splice(i, 1);
|
2892
2909
|
existingItems.splice(i, 1);
|
2893
|
-
|
2894
|
-
existingValue,
|
2910
|
+
setUi(
|
2895
2911
|
mapArrayStateToUi({
|
2896
2912
|
items: existingItems
|
2897
|
-
})
|
2913
|
+
}),
|
2914
|
+
false
|
2898
2915
|
);
|
2916
|
+
onChange(existingValue);
|
2899
2917
|
},
|
2900
2918
|
title: "Delete",
|
2901
2919
|
children: /* @__PURE__ */ jsx7(Trash, { size: 16 })
|
@@ -2907,58 +2925,49 @@ var ArrayField = ({
|
|
2907
2925
|
]
|
2908
2926
|
}
|
2909
2927
|
),
|
2910
|
-
/* @__PURE__ */ jsx7("div", { className: getClassNameItem("body"), children: /* @__PURE__ */ jsx7(
|
2911
|
-
|
2912
|
-
{
|
2913
|
-
|
2914
|
-
|
2915
|
-
|
2916
|
-
|
2917
|
-
|
2918
|
-
|
2919
|
-
|
2920
|
-
|
2921
|
-
|
2922
|
-
|
2923
|
-
|
2924
|
-
|
2925
|
-
|
2926
|
-
|
2927
|
-
|
2928
|
-
|
2928
|
+
/* @__PURE__ */ jsx7("div", { className: getClassNameItem("body"), children: /* @__PURE__ */ jsx7("fieldset", { className: getClassNameItem("fieldset"), children: Object.keys(field.arrayFields).map((subName) => {
|
2929
|
+
const subField = field.arrayFields[subName];
|
2930
|
+
const indexName = `${name}[${i}]`;
|
2931
|
+
const subPath = `${indexName}.${subName}`;
|
2932
|
+
const localIndexName = `${localName}[${i}]`;
|
2933
|
+
const localWildcardName = `${localName}[*]`;
|
2934
|
+
const localSubPath = `${localIndexName}.${subName}`;
|
2935
|
+
const localWildcardSubPath = `${localWildcardName}.${subName}`;
|
2936
|
+
const subReadOnly = forceReadOnly ? forceReadOnly : typeof readOnlyFields[subPath] !== "undefined" ? readOnlyFields[localSubPath] : readOnlyFields[localWildcardSubPath];
|
2937
|
+
const label2 = subField.label || subName;
|
2938
|
+
return /* @__PURE__ */ jsx7(
|
2939
|
+
NestedFieldProvider,
|
2940
|
+
{
|
2941
|
+
name: localIndexName,
|
2942
|
+
wildcardName: localWildcardName,
|
2943
|
+
subName,
|
2944
|
+
readOnlyFields,
|
2945
|
+
children: /* @__PURE__ */ jsx7(
|
2946
|
+
AutoFieldPrivate,
|
2929
2947
|
{
|
2930
|
-
name:
|
2931
|
-
|
2932
|
-
subName
|
2933
|
-
|
2934
|
-
|
2935
|
-
|
2936
|
-
|
2937
|
-
|
2938
|
-
|
2939
|
-
|
2940
|
-
|
2941
|
-
|
2942
|
-
|
2943
|
-
|
2944
|
-
|
2945
|
-
|
2946
|
-
|
2947
|
-
|
2948
|
-
|
2949
|
-
|
2950
|
-
|
2951
|
-
|
2952
|
-
|
2953
|
-
}
|
2954
|
-
}
|
2955
|
-
)
|
2956
|
-
},
|
2957
|
-
subPath
|
2958
|
-
);
|
2959
|
-
})
|
2960
|
-
}
|
2961
|
-
) })
|
2948
|
+
name: subPath,
|
2949
|
+
label: label2,
|
2950
|
+
id: `${_arrayId}_${subName}`,
|
2951
|
+
readOnly: subReadOnly,
|
2952
|
+
field: __spreadProps(__spreadValues({}, subField), {
|
2953
|
+
label: label2
|
2954
|
+
// May be used by custom fields
|
2955
|
+
}),
|
2956
|
+
value: data[subName],
|
2957
|
+
onChange: (val, ui) => {
|
2958
|
+
onChange(
|
2959
|
+
replace(value, i, __spreadProps(__spreadValues({}, data), {
|
2960
|
+
[subName]: val
|
2961
|
+
})),
|
2962
|
+
ui
|
2963
|
+
);
|
2964
|
+
}
|
2965
|
+
}
|
2966
|
+
)
|
2967
|
+
},
|
2968
|
+
subPath
|
2969
|
+
);
|
2970
|
+
}) }) })
|
2962
2971
|
]
|
2963
2972
|
}
|
2964
2973
|
)
|
@@ -2979,7 +2988,8 @@ var ArrayField = ({
|
|
2979
2988
|
field.defaultItemProps || {}
|
2980
2989
|
];
|
2981
2990
|
const newArrayState = regenerateArrayState(newValue);
|
2982
|
-
|
2991
|
+
setUi(mapArrayStateToUi(newArrayState), false);
|
2992
|
+
onChange(newValue);
|
2983
2993
|
},
|
2984
2994
|
children: /* @__PURE__ */ jsx7(Plus, { size: 21 })
|
2985
2995
|
}
|
@@ -3004,6 +3014,7 @@ var DefaultField = ({
|
|
3004
3014
|
value: _value,
|
3005
3015
|
name,
|
3006
3016
|
label,
|
3017
|
+
labelIcon,
|
3007
3018
|
Label: Label2,
|
3008
3019
|
id
|
3009
3020
|
}) => {
|
@@ -3012,7 +3023,7 @@ var DefaultField = ({
|
|
3012
3023
|
Label2,
|
3013
3024
|
{
|
3014
3025
|
label: label || name,
|
3015
|
-
icon: /* @__PURE__ */ jsxs4(Fragment2, { children: [
|
3026
|
+
icon: labelIcon || /* @__PURE__ */ jsxs4(Fragment2, { children: [
|
3016
3027
|
field.type === "text" && /* @__PURE__ */ jsx8(Type, { size: 16 }),
|
3017
3028
|
field.type === "number" && /* @__PURE__ */ jsx8(Hash, { size: 16 })
|
3018
3029
|
] }),
|
@@ -3062,7 +3073,7 @@ init_react_import();
|
|
3062
3073
|
import {
|
3063
3074
|
useMemo as useMemo2,
|
3064
3075
|
useEffect as useEffect9,
|
3065
|
-
useState as
|
3076
|
+
useState as useState6,
|
3066
3077
|
useCallback as useCallback3,
|
3067
3078
|
isValidElement
|
3068
3079
|
} from "react";
|
@@ -3073,7 +3084,7 @@ var styles_module_default6 = { "ExternalInput-actions": "_ExternalInput-actions_
|
|
3073
3084
|
|
3074
3085
|
// components/Modal/index.tsx
|
3075
3086
|
init_react_import();
|
3076
|
-
import { useEffect as useEffect7, useState as
|
3087
|
+
import { useEffect as useEffect7, useState as useState4 } from "react";
|
3077
3088
|
|
3078
3089
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Modal/styles.module.css#css-module
|
3079
3090
|
init_react_import();
|
@@ -3088,7 +3099,7 @@ var Modal = ({
|
|
3088
3099
|
onClose,
|
3089
3100
|
isOpen
|
3090
3101
|
}) => {
|
3091
|
-
const [rootEl, setRootEl] =
|
3102
|
+
const [rootEl, setRootEl] = useState4(null);
|
3092
3103
|
useEffect7(() => {
|
3093
3104
|
setRootEl(document.getElementById("puck-portal-root"));
|
3094
3105
|
}, []);
|
@@ -3136,7 +3147,7 @@ init_react_import();
|
|
3136
3147
|
|
3137
3148
|
// components/Button/Button.tsx
|
3138
3149
|
init_react_import();
|
3139
|
-
import { useEffect as useEffect8, useState as
|
3150
|
+
import { useEffect as useEffect8, useState as useState5 } from "react";
|
3140
3151
|
|
3141
3152
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Button/Button.module.css#css-module
|
3142
3153
|
init_react_import();
|
@@ -3186,7 +3197,7 @@ var Button = (_a) => {
|
|
3186
3197
|
"size",
|
3187
3198
|
"loading"
|
3188
3199
|
]);
|
3189
|
-
const [loading, setLoading] =
|
3200
|
+
const [loading, setLoading] = useState5(loadingProp);
|
3190
3201
|
useEffect8(() => setLoading(loadingProp), [loadingProp]);
|
3191
3202
|
const ElementType = href ? "a" : type ? "button" : "span";
|
3192
3203
|
const dataAttrs = filterDataAttrs(props);
|
@@ -3242,12 +3253,12 @@ var ExternalInput = ({
|
|
3242
3253
|
mapRow = (val) => val,
|
3243
3254
|
filterFields
|
3244
3255
|
} = field || {};
|
3245
|
-
const [data, setData] =
|
3246
|
-
const [isOpen, setOpen] =
|
3247
|
-
const [isLoading, setIsLoading] =
|
3256
|
+
const [data, setData] = useState6([]);
|
3257
|
+
const [isOpen, setOpen] = useState6(false);
|
3258
|
+
const [isLoading, setIsLoading] = useState6(true);
|
3248
3259
|
const hasFilterFields = !!filterFields;
|
3249
|
-
const [filters, setFilters] =
|
3250
|
-
const [filtersToggled, setFiltersToggled] =
|
3260
|
+
const [filters, setFilters] = useState6(field.initialFilters || {});
|
3261
|
+
const [filtersToggled, setFiltersToggled] = useState6(hasFilterFields);
|
3251
3262
|
const mappedData = useMemo2(() => {
|
3252
3263
|
return data.map(mapRow);
|
3253
3264
|
}, [data]);
|
@@ -3262,7 +3273,7 @@ var ExternalInput = ({
|
|
3262
3273
|
}
|
3263
3274
|
return Array.from(validKeys);
|
3264
3275
|
}, [mappedData]);
|
3265
|
-
const [searchQuery, setSearchQuery] =
|
3276
|
+
const [searchQuery, setSearchQuery] = useState6(field.initialQuery || "");
|
3266
3277
|
const search = useCallback3(
|
3267
3278
|
(query, filters2) => __async(void 0, null, function* () {
|
3268
3279
|
setIsLoading(true);
|
@@ -3448,6 +3459,7 @@ var ExternalField = ({
|
|
3448
3459
|
value,
|
3449
3460
|
name,
|
3450
3461
|
label,
|
3462
|
+
labelIcon,
|
3451
3463
|
Label: Label2,
|
3452
3464
|
id,
|
3453
3465
|
readOnly
|
@@ -3465,27 +3477,35 @@ var ExternalField = ({
|
|
3465
3477
|
if (field.type !== "external") {
|
3466
3478
|
return null;
|
3467
3479
|
}
|
3468
|
-
return /* @__PURE__ */ jsx13(
|
3469
|
-
|
3480
|
+
return /* @__PURE__ */ jsx13(
|
3481
|
+
Label2,
|
3470
3482
|
{
|
3471
|
-
name,
|
3472
|
-
|
3473
|
-
|
3474
|
-
|
3475
|
-
|
3476
|
-
|
3477
|
-
|
3478
|
-
|
3479
|
-
|
3480
|
-
|
3481
|
-
|
3482
|
-
|
3483
|
-
|
3484
|
-
|
3485
|
-
|
3486
|
-
|
3483
|
+
label: label || name,
|
3484
|
+
icon: labelIcon || /* @__PURE__ */ jsx13(Link, { size: 16 }),
|
3485
|
+
el: "div",
|
3486
|
+
children: /* @__PURE__ */ jsx13(
|
3487
|
+
ExternalInput,
|
3488
|
+
{
|
3489
|
+
name,
|
3490
|
+
field: __spreadProps(__spreadValues({}, validField), {
|
3491
|
+
// DEPRECATED
|
3492
|
+
placeholder: ((_a = deprecatedField.adaptor) == null ? void 0 : _a.name) ? `Select from ${deprecatedField.adaptor.name}` : validField.placeholder || "Select data",
|
3493
|
+
mapProp: ((_b = deprecatedField.adaptor) == null ? void 0 : _b.mapProp) || validField.mapProp,
|
3494
|
+
mapRow: validField.mapRow,
|
3495
|
+
fetchList: ((_c = deprecatedField.adaptor) == null ? void 0 : _c.fetchList) ? () => __async(void 0, null, function* () {
|
3496
|
+
return yield deprecatedField.adaptor.fetchList(
|
3497
|
+
deprecatedField.adaptorParams
|
3498
|
+
);
|
3499
|
+
}) : validField.fetchList
|
3500
|
+
}),
|
3501
|
+
onChange,
|
3502
|
+
value,
|
3503
|
+
id,
|
3504
|
+
readOnly
|
3505
|
+
}
|
3506
|
+
)
|
3487
3507
|
}
|
3488
|
-
)
|
3508
|
+
);
|
3489
3509
|
};
|
3490
3510
|
|
3491
3511
|
// components/AutoField/fields/RadioField/index.tsx
|
@@ -3514,6 +3534,7 @@ var RadioField = ({
|
|
3514
3534
|
name,
|
3515
3535
|
id,
|
3516
3536
|
label,
|
3537
|
+
labelIcon,
|
3517
3538
|
Label: Label2
|
3518
3539
|
}) => {
|
3519
3540
|
const flatOptions = useMemo3(
|
@@ -3526,7 +3547,7 @@ var RadioField = ({
|
|
3526
3547
|
return /* @__PURE__ */ jsx14(
|
3527
3548
|
Label2,
|
3528
3549
|
{
|
3529
|
-
icon: /* @__PURE__ */ jsx14(CircleCheckBig, { size: 16 }),
|
3550
|
+
icon: labelIcon || /* @__PURE__ */ jsx14(CircleCheckBig, { size: 16 }),
|
3530
3551
|
label: label || name,
|
3531
3552
|
readOnly,
|
3532
3553
|
el: "div",
|
@@ -3573,6 +3594,7 @@ var SelectField = ({
|
|
3573
3594
|
field,
|
3574
3595
|
onChange,
|
3575
3596
|
label,
|
3597
|
+
labelIcon,
|
3576
3598
|
Label: Label2,
|
3577
3599
|
value,
|
3578
3600
|
name,
|
@@ -3590,7 +3612,7 @@ var SelectField = ({
|
|
3590
3612
|
Label2,
|
3591
3613
|
{
|
3592
3614
|
label: label || name,
|
3593
|
-
icon: /* @__PURE__ */ jsx15(ChevronDown, { size: 16 }),
|
3615
|
+
icon: labelIcon || /* @__PURE__ */ jsx15(ChevronDown, { size: 16 }),
|
3594
3616
|
readOnly,
|
3595
3617
|
children: /* @__PURE__ */ jsx15(
|
3596
3618
|
"select",
|
@@ -3634,24 +3656,33 @@ var TextareaField = ({
|
|
3634
3656
|
value,
|
3635
3657
|
name,
|
3636
3658
|
label,
|
3659
|
+
labelIcon,
|
3637
3660
|
Label: Label2,
|
3638
3661
|
id
|
3639
3662
|
}) => {
|
3640
|
-
return /* @__PURE__ */ jsx16(
|
3641
|
-
|
3663
|
+
return /* @__PURE__ */ jsx16(
|
3664
|
+
Label2,
|
3642
3665
|
{
|
3643
|
-
|
3644
|
-
|
3645
|
-
autoComplete: "off",
|
3646
|
-
name,
|
3647
|
-
value: typeof value === "undefined" ? "" : value,
|
3648
|
-
onChange: (e) => onChange(e.currentTarget.value),
|
3666
|
+
label: label || name,
|
3667
|
+
icon: labelIcon || /* @__PURE__ */ jsx16(Type, { size: 16 }),
|
3649
3668
|
readOnly,
|
3650
|
-
|
3651
|
-
|
3652
|
-
|
3669
|
+
children: /* @__PURE__ */ jsx16(
|
3670
|
+
"textarea",
|
3671
|
+
{
|
3672
|
+
id,
|
3673
|
+
className: getClassName13("input"),
|
3674
|
+
autoComplete: "off",
|
3675
|
+
name,
|
3676
|
+
value: typeof value === "undefined" ? "" : value,
|
3677
|
+
onChange: (e) => onChange(e.currentTarget.value),
|
3678
|
+
readOnly,
|
3679
|
+
tabIndex: readOnly ? -1 : void 0,
|
3680
|
+
rows: 5,
|
3681
|
+
placeholder: field.type === "textarea" ? field.placeholder : void 0
|
3682
|
+
}
|
3683
|
+
)
|
3653
3684
|
}
|
3654
|
-
)
|
3685
|
+
);
|
3655
3686
|
};
|
3656
3687
|
|
3657
3688
|
// components/AutoField/fields/ObjectField/index.tsx
|
@@ -3670,6 +3701,7 @@ var ObjectField = ({
|
|
3670
3701
|
value,
|
3671
3702
|
name,
|
3672
3703
|
label,
|
3704
|
+
labelIcon,
|
3673
3705
|
Label: Label2,
|
3674
3706
|
readOnly,
|
3675
3707
|
id
|
@@ -3683,7 +3715,7 @@ var ObjectField = ({
|
|
3683
3715
|
Label2,
|
3684
3716
|
{
|
3685
3717
|
label: label || name,
|
3686
|
-
icon: /* @__PURE__ */ jsx17(EllipsisVertical, { size: 16 }),
|
3718
|
+
icon: labelIcon || /* @__PURE__ */ jsx17(EllipsisVertical, { size: 16 }),
|
3687
3719
|
el: "div",
|
3688
3720
|
readOnly,
|
3689
3721
|
children: /* @__PURE__ */ jsx17("div", { className: getClassName14(), children: /* @__PURE__ */ jsx17("fieldset", { className: getClassName14("fieldset"), children: Object.keys(field.objectFields).map((subName) => {
|
@@ -3730,12 +3762,12 @@ var ObjectField = ({
|
|
3730
3762
|
|
3731
3763
|
// lib/use-safe-id.ts
|
3732
3764
|
init_react_import();
|
3733
|
-
import React2, { useState as
|
3765
|
+
import React2, { useState as useState7 } from "react";
|
3734
3766
|
var useSafeId = () => {
|
3735
3767
|
if (typeof React2.useId !== "undefined") {
|
3736
3768
|
return React2.useId();
|
3737
3769
|
}
|
3738
|
-
const [id] =
|
3770
|
+
const [id] = useState7(generateId());
|
3739
3771
|
return id;
|
3740
3772
|
};
|
3741
3773
|
|
@@ -3800,6 +3832,7 @@ function AutoFieldInternal(props) {
|
|
3800
3832
|
const { id, Label: Label2 = FieldLabelInternal } = props;
|
3801
3833
|
const field = props.field;
|
3802
3834
|
const label = field.label;
|
3835
|
+
const labelIcon = field.labelIcon;
|
3803
3836
|
const defaultId = useSafeId();
|
3804
3837
|
const resolvedId = id || defaultId;
|
3805
3838
|
const defaultFields = {
|
@@ -3825,6 +3858,7 @@ function AutoFieldInternal(props) {
|
|
3825
3858
|
const mergedProps = __spreadProps(__spreadValues({}, props), {
|
3826
3859
|
field,
|
3827
3860
|
label,
|
3861
|
+
labelIcon,
|
3828
3862
|
Label: Label2,
|
3829
3863
|
id: resolvedId
|
3830
3864
|
});
|
@@ -3886,11 +3920,14 @@ function AutoFieldInternal(props) {
|
|
3886
3920
|
function AutoFieldPrivate(props) {
|
3887
3921
|
const isFocused = useAppStore((s) => s.state.ui.field.focus === props.name);
|
3888
3922
|
const { value, onChange } = props;
|
3889
|
-
const [localValue, setLocalValue] =
|
3890
|
-
const onChangeLocal = useCallback4(
|
3891
|
-
|
3892
|
-
|
3893
|
-
|
3923
|
+
const [localValue, setLocalValue] = useState8(value);
|
3924
|
+
const onChangeLocal = useCallback4(
|
3925
|
+
(val, ui) => {
|
3926
|
+
setLocalValue(val);
|
3927
|
+
onChange(val, ui);
|
3928
|
+
},
|
3929
|
+
[onChange]
|
3930
|
+
);
|
3894
3931
|
useEffect11(() => {
|
3895
3932
|
if (!isFocused) {
|
3896
3933
|
setLocalValue(value);
|
@@ -3923,7 +3960,7 @@ init_react_import();
|
|
3923
3960
|
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" };
|
3924
3961
|
|
3925
3962
|
// components/Drawer/index.tsx
|
3926
|
-
import {
|
3963
|
+
import { useMemo as useMemo9, useState as useState15 } from "react";
|
3927
3964
|
|
3928
3965
|
// components/DragDropContext/index.tsx
|
3929
3966
|
init_react_import();
|
@@ -3933,9 +3970,8 @@ import {
|
|
3933
3970
|
useCallback as useCallback10,
|
3934
3971
|
useContext as useContext7,
|
3935
3972
|
useEffect as useEffect17,
|
3936
|
-
|
3937
|
-
|
3938
|
-
useState as useState15
|
3973
|
+
useRef as useRef4,
|
3974
|
+
useState as useState14
|
3939
3975
|
} from "react";
|
3940
3976
|
import { AutoScroller, defaultPreset } from "@dnd-kit/dom";
|
3941
3977
|
|
@@ -3947,7 +3983,7 @@ import {
|
|
3947
3983
|
useContext as useContext6,
|
3948
3984
|
useEffect as useEffect16,
|
3949
3985
|
useMemo as useMemo8,
|
3950
|
-
useRef as
|
3986
|
+
useRef as useRef3
|
3951
3987
|
} from "react";
|
3952
3988
|
|
3953
3989
|
// components/DraggableComponent/index.tsx
|
@@ -3957,8 +3993,8 @@ import {
|
|
3957
3993
|
useContext as useContext5,
|
3958
3994
|
useEffect as useEffect12,
|
3959
3995
|
useMemo as useMemo7,
|
3960
|
-
useRef,
|
3961
|
-
useState as
|
3996
|
+
useRef as useRef2,
|
3997
|
+
useState as useState10
|
3962
3998
|
} from "react";
|
3963
3999
|
|
3964
4000
|
// css-module:/home/runner/work/puck/puck/packages/core/components/DraggableComponent/styles.module.css#css-module
|
@@ -3993,7 +4029,7 @@ import {
|
|
3993
4029
|
createContext as createContext3,
|
3994
4030
|
useCallback as useCallback5,
|
3995
4031
|
useMemo as useMemo6,
|
3996
|
-
useState as
|
4032
|
+
useState as useState9
|
3997
4033
|
} from "react";
|
3998
4034
|
import { createStore as createStore2 } from "zustand";
|
3999
4035
|
import { Fragment as Fragment5, jsx as jsx19 } from "react/jsx-runtime";
|
@@ -4018,8 +4054,8 @@ var DropZoneProvider = ({
|
|
4018
4054
|
children,
|
4019
4055
|
value
|
4020
4056
|
}) => {
|
4021
|
-
const [hoveringComponent, setHoveringComponent] =
|
4022
|
-
const [activeZones, setActiveZones] =
|
4057
|
+
const [hoveringComponent, setHoveringComponent] = useState9();
|
4058
|
+
const [activeZones, setActiveZones] = useState9({});
|
4023
4059
|
const dispatch = useAppStore((s) => s.dispatch);
|
4024
4060
|
const registerZone = useCallback5(
|
4025
4061
|
(zoneCompound) => {
|
@@ -4127,7 +4163,7 @@ var DraggableComponent = ({
|
|
4127
4163
|
const dispatch = useAppStore((s) => s.dispatch);
|
4128
4164
|
const iframe = useAppStore((s) => s.iframe);
|
4129
4165
|
const ctx = useContext5(dropZoneContext);
|
4130
|
-
const [localZones, setLocalZones] =
|
4166
|
+
const [localZones, setLocalZones] = useState10({});
|
4131
4167
|
const registerLocalZone = useCallback6(
|
4132
4168
|
(zoneCompound2, active) => {
|
4133
4169
|
var _a;
|
@@ -4168,7 +4204,7 @@ var DraggableComponent = ({
|
|
4168
4204
|
);
|
4169
4205
|
const canCollide = permissions.drag || userIsDragging;
|
4170
4206
|
const disabled = !isEnabled || !canCollide;
|
4171
|
-
const [dragAxis, setDragAxis] =
|
4207
|
+
const [dragAxis, setDragAxis] = useState10(userDragAxis || autoDragAxis);
|
4172
4208
|
const { ref: sortableRef, status } = useSortableSafe({
|
4173
4209
|
id,
|
4174
4210
|
index,
|
@@ -4194,7 +4230,7 @@ var DraggableComponent = ({
|
|
4194
4230
|
}
|
4195
4231
|
});
|
4196
4232
|
const thisIsDragging = status === "dragging";
|
4197
|
-
const ref =
|
4233
|
+
const ref = useRef2(null);
|
4198
4234
|
const refSetter = useCallback6(
|
4199
4235
|
(el) => {
|
4200
4236
|
sortableRef(el);
|
@@ -4204,7 +4240,7 @@ var DraggableComponent = ({
|
|
4204
4240
|
},
|
4205
4241
|
[sortableRef]
|
4206
4242
|
);
|
4207
|
-
const [portalEl, setPortalEl] =
|
4243
|
+
const [portalEl, setPortalEl] = useState10();
|
4208
4244
|
useEffect12(() => {
|
4209
4245
|
var _a, _b, _c;
|
4210
4246
|
setPortalEl(
|
@@ -4231,7 +4267,7 @@ var DraggableComponent = ({
|
|
4231
4267
|
};
|
4232
4268
|
return style2;
|
4233
4269
|
}, [ref.current]);
|
4234
|
-
const [style, setStyle] =
|
4270
|
+
const [style, setStyle] = useState10();
|
4235
4271
|
const sync = useCallback6(() => {
|
4236
4272
|
setStyle(getStyle());
|
4237
4273
|
}, [ref.current, iframe]);
|
@@ -4300,7 +4336,7 @@ var DraggableComponent = ({
|
|
4300
4336
|
zone: zoneCompound
|
4301
4337
|
});
|
4302
4338
|
}, [index, zoneCompound]);
|
4303
|
-
const [hover, setHover] =
|
4339
|
+
const [hover, setHover] = useState10(false);
|
4304
4340
|
const indicativeHover = (ctx == null ? void 0 : ctx.hoveringComponent) === id;
|
4305
4341
|
useEffect12(() => {
|
4306
4342
|
if (!ref.current) {
|
@@ -4361,7 +4397,7 @@ var DraggableComponent = ({
|
|
4361
4397
|
};
|
4362
4398
|
}
|
4363
4399
|
}, [disabled, ref]);
|
4364
|
-
const [isVisible, setIsVisible] =
|
4400
|
+
const [isVisible, setIsVisible] = useState10(false);
|
4365
4401
|
useEffect12(() => {
|
4366
4402
|
sync();
|
4367
4403
|
if ((isSelected || hover || indicativeHover) && !userIsDragging) {
|
@@ -4378,10 +4414,18 @@ var DraggableComponent = ({
|
|
4378
4414
|
const rect = el.getBoundingClientRect();
|
4379
4415
|
const diffLeft = rect.x;
|
4380
4416
|
const exceedsBoundsLeft = diffLeft < 0;
|
4417
|
+
const diffTop = rect.y;
|
4418
|
+
const exceedsBoundsTop = diffTop < 0;
|
4381
4419
|
if (exceedsBoundsLeft) {
|
4382
4420
|
el.style.transformOrigin = "left top";
|
4383
4421
|
el.style.left = "0px";
|
4384
4422
|
}
|
4423
|
+
if (exceedsBoundsTop) {
|
4424
|
+
el.style.top = "12px";
|
4425
|
+
if (!exceedsBoundsLeft) {
|
4426
|
+
el.style.transformOrigin = "right top";
|
4427
|
+
}
|
4428
|
+
}
|
4385
4429
|
}
|
4386
4430
|
}
|
4387
4431
|
},
|
@@ -4480,15 +4524,15 @@ var styles_module_default12 = { "DropZone": "_DropZone_kmkdc_1", "DropZone--isAc
|
|
4480
4524
|
|
4481
4525
|
// components/DropZone/lib/use-min-empty-height.ts
|
4482
4526
|
init_react_import();
|
4483
|
-
import { useEffect as useEffect13, useState as
|
4527
|
+
import { useEffect as useEffect13, useState as useState11 } from "react";
|
4484
4528
|
var useMinEmptyHeight = ({
|
4485
4529
|
zoneCompound,
|
4486
4530
|
userMinEmptyHeight,
|
4487
4531
|
ref
|
4488
4532
|
}) => {
|
4489
4533
|
const appStore = useAppStoreApi();
|
4490
|
-
const [prevHeight, setPrevHeight] =
|
4491
|
-
const [isAnimating, setIsAnimating] =
|
4534
|
+
const [prevHeight, setPrevHeight] = useState11(0);
|
4535
|
+
const [isAnimating, setIsAnimating] = useState11(false);
|
4492
4536
|
const { draggedItem, isZone } = useContextStore(ZoneStoreContext, (s) => {
|
4493
4537
|
var _a, _b;
|
4494
4538
|
return {
|
@@ -4534,7 +4578,7 @@ function assignRefs(refs, node) {
|
|
4534
4578
|
|
4535
4579
|
// components/DropZone/lib/use-content-with-preview.ts
|
4536
4580
|
init_react_import();
|
4537
|
-
import { useEffect as useEffect14, useState as
|
4581
|
+
import { useEffect as useEffect14, useState as useState12 } from "react";
|
4538
4582
|
|
4539
4583
|
// lib/dnd/use-rendered-callback.ts
|
4540
4584
|
init_react_import();
|
@@ -4565,8 +4609,8 @@ var useContentIdsWithPreview = (contentIds, zoneCompound) => {
|
|
4565
4609
|
}
|
4566
4610
|
);
|
4567
4611
|
const isDragging = useAppStore((s) => s.state.ui.isDragging);
|
4568
|
-
const [contentIdsWithPreview, setContentIdsWithPreview] =
|
4569
|
-
const [localPreview, setLocalPreview] =
|
4612
|
+
const [contentIdsWithPreview, setContentIdsWithPreview] = useState12(contentIds);
|
4613
|
+
const [localPreview, setLocalPreview] = useState12(
|
4570
4614
|
preview
|
4571
4615
|
);
|
4572
4616
|
const updateContent = useRenderedCallback(
|
@@ -4609,13 +4653,13 @@ var useContentIdsWithPreview = (contentIds, zoneCompound) => {
|
|
4609
4653
|
|
4610
4654
|
// components/DropZone/lib/use-drag-axis.ts
|
4611
4655
|
init_react_import();
|
4612
|
-
import { useCallback as useCallback8, useEffect as useEffect15, useState as
|
4656
|
+
import { useCallback as useCallback8, useEffect as useEffect15, useState as useState13 } from "react";
|
4613
4657
|
var GRID_DRAG_AXIS = "dynamic";
|
4614
4658
|
var FLEX_ROW_DRAG_AXIS = "x";
|
4615
4659
|
var DEFAULT_DRAG_AXIS = "y";
|
4616
4660
|
var useDragAxis = (ref, collisionAxis) => {
|
4617
4661
|
const status = useAppStore((s) => s.status);
|
4618
|
-
const [dragAxis, setDragAxis] =
|
4662
|
+
const [dragAxis, setDragAxis] = useState13(
|
4619
4663
|
collisionAxis || DEFAULT_DRAG_AXIS
|
4620
4664
|
);
|
4621
4665
|
const calculateDragAxis = useCallback8(() => {
|
@@ -4871,7 +4915,7 @@ var DropZoneEdit = forwardRef3(
|
|
4871
4915
|
return content.map(({ props }) => props.id);
|
4872
4916
|
})
|
4873
4917
|
);
|
4874
|
-
const ref =
|
4918
|
+
const ref = useRef3(null);
|
4875
4919
|
const acceptsTarget = useCallback9(
|
4876
4920
|
(componentType) => {
|
4877
4921
|
if (!componentType) {
|
@@ -5373,7 +5417,7 @@ function useDragListener(type, fn, deps = []) {
|
|
5373
5417
|
}
|
5374
5418
|
var AREA_CHANGE_DEBOUNCE_MS = 100;
|
5375
5419
|
var useTempDisableFallback = (timeout3) => {
|
5376
|
-
const lastFallbackDisable =
|
5420
|
+
const lastFallbackDisable = useRef4(null);
|
5377
5421
|
return useCallback10((manager) => {
|
5378
5422
|
collisionStore.setState({ fallbackEnabled: false });
|
5379
5423
|
const fallbackId = generateId();
|
@@ -5395,10 +5439,10 @@ var DragDropContextClient = ({
|
|
5395
5439
|
const resolveData2 = useAppStore((s) => s.resolveData);
|
5396
5440
|
const metadata = useAppStore((s) => s.metadata);
|
5397
5441
|
const appStore = useAppStoreApi();
|
5398
|
-
const id =
|
5399
|
-
const debouncedParamsRef =
|
5442
|
+
const id = useSafeId();
|
5443
|
+
const debouncedParamsRef = useRef4(null);
|
5400
5444
|
const tempDisableFallback = useTempDisableFallback(100);
|
5401
|
-
const [zoneStore] =
|
5445
|
+
const [zoneStore] = useState14(
|
5402
5446
|
() => createStore3(() => ({
|
5403
5447
|
zoneDepthIndex: {},
|
5404
5448
|
nextZoneDepthIndex: {},
|
@@ -5467,7 +5511,7 @@ var DragDropContextClient = ({
|
|
5467
5511
|
);
|
5468
5512
|
}
|
5469
5513
|
}, []);
|
5470
|
-
const [plugins] =
|
5514
|
+
const [plugins] = useState14(() => [
|
5471
5515
|
...disableAutoScroll ? defaultPreset.plugins.filter((plugin) => plugin !== AutoScroller) : defaultPreset.plugins,
|
5472
5516
|
createNestedDroppablePlugin(
|
5473
5517
|
{
|
@@ -5515,9 +5559,9 @@ var DragDropContextClient = ({
|
|
5515
5559
|
)
|
5516
5560
|
]);
|
5517
5561
|
const sensors = useSensors();
|
5518
|
-
const [dragListeners, setDragListeners] =
|
5519
|
-
const dragMode =
|
5520
|
-
const initialSelector =
|
5562
|
+
const [dragListeners, setDragListeners] = useState14({});
|
5563
|
+
const dragMode = useRef4(null);
|
5564
|
+
const initialSelector = useRef4(void 0);
|
5521
5565
|
return /* @__PURE__ */ jsx23("div", { id, children: /* @__PURE__ */ jsx23(
|
5522
5566
|
dragListenerContext.Provider,
|
5523
5567
|
{
|
@@ -5810,7 +5854,7 @@ var DrawerItem = ({
|
|
5810
5854
|
isDragDisabled
|
5811
5855
|
}) => {
|
5812
5856
|
const resolvedId = id || name;
|
5813
|
-
const [dynamicId, setDynamicId] =
|
5857
|
+
const [dynamicId, setDynamicId] = useState15(generateId(resolvedId));
|
5814
5858
|
if (typeof index !== "undefined") {
|
5815
5859
|
console.error(
|
5816
5860
|
"Warning: The `index` prop on Drawer.Item is deprecated and no longer required."
|
@@ -5849,7 +5893,7 @@ var Drawer = ({
|
|
5849
5893
|
"Warning: The `direction` prop on Drawer is deprecated and no longer required to achieve multi-directional dragging."
|
5850
5894
|
);
|
5851
5895
|
}
|
5852
|
-
const id =
|
5896
|
+
const id = useSafeId();
|
5853
5897
|
const { ref } = useDroppableSafe({
|
5854
5898
|
id,
|
5855
5899
|
type: "void",
|
@@ -5877,7 +5921,7 @@ import {
|
|
5877
5921
|
useContext as useContext11,
|
5878
5922
|
useEffect as useEffect25,
|
5879
5923
|
useMemo as useMemo18,
|
5880
|
-
useState as
|
5924
|
+
useState as useState22
|
5881
5925
|
} from "react";
|
5882
5926
|
|
5883
5927
|
// components/SidebarSection/index.tsx
|
@@ -6177,7 +6221,7 @@ init_react_import();
|
|
6177
6221
|
|
6178
6222
|
// lib/use-component-list.tsx
|
6179
6223
|
init_react_import();
|
6180
|
-
import { useEffect as useEffect18, useState as
|
6224
|
+
import { useEffect as useEffect18, useState as useState16 } from "react";
|
6181
6225
|
|
6182
6226
|
// components/ComponentList/index.tsx
|
6183
6227
|
init_react_import();
|
@@ -6248,7 +6292,7 @@ ComponentList.Item = ComponentListItem;
|
|
6248
6292
|
// lib/use-component-list.tsx
|
6249
6293
|
import { jsx as jsx29 } from "react/jsx-runtime";
|
6250
6294
|
var useComponentList = () => {
|
6251
|
-
const [componentList, setComponentList] =
|
6295
|
+
const [componentList, setComponentList] = useState16();
|
6252
6296
|
const config = useAppStore((s) => s.config);
|
6253
6297
|
const uiComponentList = useAppStore((s) => s.state.ui.componentList);
|
6254
6298
|
useEffect18(() => {
|
@@ -6331,7 +6375,7 @@ var Components = () => {
|
|
6331
6375
|
|
6332
6376
|
// components/Puck/components/Preview/index.tsx
|
6333
6377
|
init_react_import();
|
6334
|
-
import { useCallback as useCallback12, useEffect as useEffect20, useRef as
|
6378
|
+
import { useCallback as useCallback12, useEffect as useEffect20, useRef as useRef5, useMemo as useMemo13 } from "react";
|
6335
6379
|
|
6336
6380
|
// components/AutoFrame/index.tsx
|
6337
6381
|
init_react_import();
|
@@ -6339,7 +6383,7 @@ import {
|
|
6339
6383
|
createContext as createContext5,
|
6340
6384
|
useContext as useContext8,
|
6341
6385
|
useEffect as useEffect19,
|
6342
|
-
useState as
|
6386
|
+
useState as useState17
|
6343
6387
|
} from "react";
|
6344
6388
|
import hash from "object-hash";
|
6345
6389
|
import { createPortal as createPortal3 } from "react-dom";
|
@@ -6567,10 +6611,10 @@ function AutoFrame(_a) {
|
|
6567
6611
|
"onNotReady",
|
6568
6612
|
"frameRef"
|
6569
6613
|
]);
|
6570
|
-
const [loaded, setLoaded] =
|
6571
|
-
const [ctx, setCtx] =
|
6572
|
-
const [mountTarget, setMountTarget] =
|
6573
|
-
const [stylesLoaded, setStylesLoaded] =
|
6614
|
+
const [loaded, setLoaded] = useState17(false);
|
6615
|
+
const [ctx, setCtx] = useState17({});
|
6616
|
+
const [mountTarget, setMountTarget] = useState17();
|
6617
|
+
const [stylesLoaded, setStylesLoaded] = useState17(false);
|
6574
6618
|
useEffect19(() => {
|
6575
6619
|
var _a2;
|
6576
6620
|
if (frameRef.current) {
|
@@ -6683,7 +6727,7 @@ var Preview3 = ({ id = "puck-preview" }) => {
|
|
6683
6727
|
);
|
6684
6728
|
const Frame = useMemo13(() => overrides.iframe, [overrides]);
|
6685
6729
|
const rootProps = root.props || root;
|
6686
|
-
const ref =
|
6730
|
+
const ref = useRef5(null);
|
6687
6731
|
useBubbleIframeEvents(ref);
|
6688
6732
|
const inner = !renderData ? /* @__PURE__ */ jsx32(
|
6689
6733
|
Page,
|
@@ -7115,13 +7159,13 @@ import {
|
|
7115
7159
|
useCallback as useCallback14,
|
7116
7160
|
useEffect as useEffect22,
|
7117
7161
|
useMemo as useMemo16,
|
7118
|
-
useRef as
|
7119
|
-
useState as
|
7162
|
+
useRef as useRef6,
|
7163
|
+
useState as useState19
|
7120
7164
|
} from "react";
|
7121
7165
|
|
7122
7166
|
// components/ViewportControls/index.tsx
|
7123
7167
|
init_react_import();
|
7124
|
-
import { useEffect as useEffect21, useMemo as useMemo15, useState as
|
7168
|
+
import { useEffect as useEffect21, useMemo as useMemo15, useState as useState18 } from "react";
|
7125
7169
|
|
7126
7170
|
// css-module:/home/runner/work/puck/puck/packages/core/components/ViewportControls/styles.module.css#css-module
|
7127
7171
|
init_react_import();
|
@@ -7144,7 +7188,7 @@ var ViewportButton = ({
|
|
7144
7188
|
onClick
|
7145
7189
|
}) => {
|
7146
7190
|
const viewports = useAppStore((s) => s.state.ui.viewports);
|
7147
|
-
const [isActive, setIsActive] =
|
7191
|
+
const [isActive, setIsActive] = useState18(false);
|
7148
7192
|
useEffect21(() => {
|
7149
7193
|
setIsActive(width === viewports.current.width);
|
7150
7194
|
}, [width, viewports.current.width]);
|
@@ -7328,8 +7372,8 @@ var Canvas = () => {
|
|
7328
7372
|
viewports: s.state.ui.viewports
|
7329
7373
|
}))
|
7330
7374
|
);
|
7331
|
-
const frameRef =
|
7332
|
-
const [showTransition, setShowTransition] =
|
7375
|
+
const frameRef = useRef6(null);
|
7376
|
+
const [showTransition, setShowTransition] = useState19(false);
|
7333
7377
|
const defaultRender = useMemo16(() => {
|
7334
7378
|
const PuckDefault = ({ children }) => /* @__PURE__ */ jsx36(Fragment13, { children });
|
7335
7379
|
return PuckDefault;
|
@@ -7388,7 +7432,7 @@ var Canvas = () => {
|
|
7388
7432
|
window.removeEventListener("resize", cb);
|
7389
7433
|
};
|
7390
7434
|
}, []);
|
7391
|
-
const [showLoader, setShowLoader] =
|
7435
|
+
const [showLoader, setShowLoader] = useState19(false);
|
7392
7436
|
useEffect22(() => {
|
7393
7437
|
setTimeout(() => {
|
7394
7438
|
setShowLoader(true);
|
@@ -7518,10 +7562,10 @@ var DefaultOverride = ({ children }) => /* @__PURE__ */ jsx37(Fragment14, { chil
|
|
7518
7562
|
|
7519
7563
|
// lib/use-inject-css.ts
|
7520
7564
|
init_react_import();
|
7521
|
-
import { useEffect as useEffect23, useState as
|
7565
|
+
import { useEffect as useEffect23, useState as useState20 } from "react";
|
7522
7566
|
var styles = ``;
|
7523
7567
|
var useInjectStyleSheet = (initialStyles, iframeEnabled) => {
|
7524
|
-
const [el, setEl] =
|
7568
|
+
const [el, setEl] = useState20();
|
7525
7569
|
useEffect23(() => {
|
7526
7570
|
setEl(document.createElement("style"));
|
7527
7571
|
}, []);
|
@@ -7563,7 +7607,7 @@ var usePreviewModeHotkeys = () => {
|
|
7563
7607
|
|
7564
7608
|
// lib/use-puck.ts
|
7565
7609
|
init_react_import();
|
7566
|
-
import { createContext as createContext6, useContext as useContext10, useEffect as useEffect24, useState as
|
7610
|
+
import { createContext as createContext6, useContext as useContext10, useEffect as useEffect24, useState as useState21 } from "react";
|
7567
7611
|
import { createStore as createStore4, useStore as useStore3 } from "zustand";
|
7568
7612
|
var generateUsePuck = (store) => {
|
7569
7613
|
const history = {
|
@@ -7592,7 +7636,7 @@ var UsePuckStoreContext = createContext6(
|
|
7592
7636
|
null
|
7593
7637
|
);
|
7594
7638
|
var useRegisterUsePuckStore = (appStore) => {
|
7595
|
-
const [usePuckStore] =
|
7639
|
+
const [usePuckStore] = useState21(
|
7596
7640
|
() => createStore4(() => generateUsePuck(appStore.getState()))
|
7597
7641
|
);
|
7598
7642
|
useEffect24(() => {
|
@@ -7674,7 +7718,7 @@ function PuckProvider({ children }) {
|
|
7674
7718
|
enabled: true,
|
7675
7719
|
waitForStyles: true
|
7676
7720
|
}, _iframe);
|
7677
|
-
const [generatedAppState] =
|
7721
|
+
const [generatedAppState] = useState22(() => {
|
7678
7722
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
7679
7723
|
const initial = __spreadValues(__spreadValues({}, defaultAppState.ui), initialUi);
|
7680
7724
|
let clientUiState = {};
|
@@ -7767,7 +7811,7 @@ function PuckProvider({ children }) {
|
|
7767
7811
|
onAction,
|
7768
7812
|
metadata
|
7769
7813
|
]);
|
7770
|
-
const [appStore] =
|
7814
|
+
const [appStore] = useState22(() => createAppStore(generateAppStore()));
|
7771
7815
|
useEffect25(() => {
|
7772
7816
|
appStore.setState(__spreadValues({}, generateAppStore()));
|
7773
7817
|
}, [
|
@@ -7820,7 +7864,7 @@ function PuckLayout({ children }) {
|
|
7820
7864
|
const rightSideBarVisible = useAppStore(
|
7821
7865
|
(s) => s.state.ui.rightSideBarVisible
|
7822
7866
|
);
|
7823
|
-
const [menuOpen, setMenuOpen] =
|
7867
|
+
const [menuOpen, setMenuOpen] = useState22(false);
|
7824
7868
|
const appStore = useAppStoreApi();
|
7825
7869
|
useEffect25(() => {
|
7826
7870
|
return appStore.subscribe((s) => {
|
@@ -7910,7 +7954,7 @@ function PuckLayout({ children }) {
|
|
7910
7954
|
() => overrides.headerActions || defaultHeaderActionsRender,
|
7911
7955
|
[overrides]
|
7912
7956
|
);
|
7913
|
-
const [mounted, setMounted] =
|
7957
|
+
const [mounted, setMounted] = useState22(false);
|
7914
7958
|
useEffect25(() => {
|
7915
7959
|
setMounted(true);
|
7916
7960
|
}, []);
|
@@ -8075,40 +8119,6 @@ var migrations = [
|
|
8075
8119
|
function migrate(data) {
|
8076
8120
|
return migrations == null ? void 0 : migrations.reduce((acc, migration) => migration(acc), data);
|
8077
8121
|
}
|
8078
|
-
|
8079
|
-
// lib/transform-props.ts
|
8080
|
-
init_react_import();
|
8081
|
-
function transformProps(data, propTransforms) {
|
8082
|
-
const mapItem = (item) => {
|
8083
|
-
if (propTransforms[item.type]) {
|
8084
|
-
return __spreadProps(__spreadValues({}, item), {
|
8085
|
-
props: propTransforms[item.type](item.props)
|
8086
|
-
});
|
8087
|
-
}
|
8088
|
-
return item;
|
8089
|
-
};
|
8090
|
-
const defaultedData = defaultData(data);
|
8091
|
-
const rootProps = defaultedData.root.props || defaultedData.root;
|
8092
|
-
let newRoot = __spreadValues({}, defaultedData.root);
|
8093
|
-
if (propTransforms["root"]) {
|
8094
|
-
if (defaultedData.root.props) {
|
8095
|
-
newRoot.props = propTransforms["root"](rootProps);
|
8096
|
-
} else {
|
8097
|
-
newRoot = propTransforms["root"](rootProps);
|
8098
|
-
}
|
8099
|
-
}
|
8100
|
-
const afterPropTransforms = __spreadProps(__spreadValues({}, defaultedData), {
|
8101
|
-
root: newRoot,
|
8102
|
-
content: defaultedData.content.map(mapItem),
|
8103
|
-
zones: Object.keys(data.zones || {}).reduce(
|
8104
|
-
(acc, zoneKey) => __spreadProps(__spreadValues({}, acc), {
|
8105
|
-
[zoneKey]: data.zones[zoneKey].map(mapItem)
|
8106
|
-
}),
|
8107
|
-
{}
|
8108
|
-
)
|
8109
|
-
});
|
8110
|
-
return afterPropTransforms;
|
8111
|
-
}
|
8112
8122
|
export {
|
8113
8123
|
Action,
|
8114
8124
|
ActionBar,
|