@measured/puck 0.19.0-canary.61c8658 → 0.19.0-canary.706ea0c1
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/README.md +1 -0
- 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 +437 -426
- package/dist/index.mjs +280 -303
- package/dist/{resolve-all-data-DleIzc4N.d.mts → resolve-all-data-3XjIPfNh.d.mts} +12 -1
- package/dist/{resolve-all-data-DleIzc4N.d.ts → resolve-all-data-3XjIPfNh.d.ts} +12 -1
- package/dist/rsc.d.mts +2 -2
- package/dist/rsc.d.ts +2 -2
- package/dist/rsc.js +37 -2
- package/dist/rsc.mjs +5 -3
- package/package.json +3 -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, useRef, useState as
|
679
|
+
import { useCallback as useCallback2, useEffect as useEffect6, useRef, 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,31 +2577,27 @@ 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
|
-
container,
|
2570
2582
|
children,
|
2571
2583
|
onDragStart,
|
2572
2584
|
onDragEnd,
|
2573
2585
|
onMove
|
2574
2586
|
}) => {
|
2575
|
-
const
|
2576
|
-
|
2587
|
+
const sensors = useSensors({
|
2588
|
+
mouse: { distance: { value: 5 } }
|
2589
|
+
});
|
2577
2590
|
return /* @__PURE__ */ jsx5(
|
2578
2591
|
DragDropProvider,
|
2579
2592
|
{
|
2580
2593
|
sensors,
|
2581
|
-
|
2582
|
-
|
2583
|
-
|
2584
|
-
|
2585
|
-
}
|
2586
|
-
})
|
2587
|
-
],
|
2588
|
-
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
|
+
},
|
2589
2598
|
onDragOver: (event, manager) => {
|
2590
2599
|
var _a, _b;
|
2600
|
+
event.preventDefault();
|
2591
2601
|
const { operation } = event;
|
2592
2602
|
const { source, target } = operation;
|
2593
2603
|
if (!source || !target) return;
|
@@ -2595,14 +2605,14 @@ var SortableProvider = ({
|
|
2595
2605
|
let targetIndex = target.data.index;
|
2596
2606
|
const collisionData = (_b = (_a = manager.dragOperation.data) == null ? void 0 : _a.collisionMap) == null ? void 0 : _b[target.id];
|
2597
2607
|
if (sourceIndex !== targetIndex && source.id !== target.id) {
|
2598
|
-
const collisionPosition =
|
2608
|
+
const collisionPosition = collisionData.direction === "up" ? "before" : "after";
|
2599
2609
|
if (targetIndex >= sourceIndex) {
|
2600
2610
|
targetIndex = targetIndex - 1;
|
2601
2611
|
}
|
2602
2612
|
if (collisionPosition === "after") {
|
2603
2613
|
targetIndex = targetIndex + 1;
|
2604
2614
|
}
|
2605
|
-
|
2615
|
+
onMove({
|
2606
2616
|
source: sourceIndex,
|
2607
2617
|
target: targetIndex
|
2608
2618
|
});
|
@@ -2610,12 +2620,8 @@ var SortableProvider = ({
|
|
2610
2620
|
},
|
2611
2621
|
onDragEnd: () => {
|
2612
2622
|
setTimeout(() => {
|
2613
|
-
if (move.source !== -1 && move.target !== -1) {
|
2614
|
-
onMove(move);
|
2615
|
-
}
|
2616
2623
|
onDragEnd();
|
2617
2624
|
}, 250);
|
2618
|
-
setMove({ source: -1, target: -1 });
|
2619
2625
|
},
|
2620
2626
|
children
|
2621
2627
|
}
|
@@ -2628,7 +2634,11 @@ var Sortable = ({
|
|
2628
2634
|
children,
|
2629
2635
|
type = "item"
|
2630
2636
|
}) => {
|
2631
|
-
const {
|
2637
|
+
const {
|
2638
|
+
ref: sortableRef,
|
2639
|
+
status,
|
2640
|
+
handleRef
|
2641
|
+
} = useSortableSafe({
|
2632
2642
|
id,
|
2633
2643
|
type,
|
2634
2644
|
index,
|
@@ -2636,7 +2646,7 @@ var Sortable = ({
|
|
2636
2646
|
data: { index },
|
2637
2647
|
collisionDetector: createDynamicCollisionDetector("y")
|
2638
2648
|
});
|
2639
|
-
return children({ status, ref: sortableRef });
|
2649
|
+
return children({ status, ref: sortableRef, handleRef });
|
2640
2650
|
};
|
2641
2651
|
|
2642
2652
|
// components/AutoField/context.tsx
|
@@ -2712,10 +2722,12 @@ var ArrayField = ({
|
|
2712
2722
|
}),
|
2713
2723
|
openId: ""
|
2714
2724
|
};
|
2715
|
-
const [localState, setLocalState] =
|
2725
|
+
const [localState, setLocalState] = useState3({ arrayState, value });
|
2716
2726
|
useEffect6(() => {
|
2717
|
-
|
2718
|
-
|
2727
|
+
var _a;
|
2728
|
+
const _arrayState = (_a = appStore.getState().state.ui.arrayState[id]) != null ? _a : arrayState;
|
2729
|
+
setLocalState({ arrayState: _arrayState, value });
|
2730
|
+
}, [value]);
|
2719
2731
|
const appStore = useAppStoreApi();
|
2720
2732
|
const mapArrayStateToUi = useCallback2(
|
2721
2733
|
(partialArrayState) => {
|
@@ -2758,12 +2770,13 @@ var ArrayField = ({
|
|
2758
2770
|
setUi(mapArrayStateToUi(arrayState));
|
2759
2771
|
}
|
2760
2772
|
}, []);
|
2761
|
-
const [
|
2762
|
-
const
|
2773
|
+
const [draggedItem, setDraggedItem] = useState3("");
|
2774
|
+
const isDragging = !!draggedItem;
|
2763
2775
|
const canEdit = useAppStore(
|
2764
2776
|
(s) => s.permissions.getPermissions({ item: s.selectedItem }).edit
|
2765
2777
|
);
|
2766
2778
|
const forceReadOnly = !canEdit;
|
2779
|
+
const valueRef = useRef(value);
|
2767
2780
|
if (field.type !== "array" || !field.arrayFields) {
|
2768
2781
|
return null;
|
2769
2782
|
}
|
@@ -2778,11 +2791,16 @@ var ArrayField = ({
|
|
2778
2791
|
children: /* @__PURE__ */ jsx7(
|
2779
2792
|
SortableProvider,
|
2780
2793
|
{
|
2781
|
-
|
2782
|
-
|
2783
|
-
|
2794
|
+
onDragStart: (id2) => setDraggedItem(id2),
|
2795
|
+
onDragEnd: () => {
|
2796
|
+
setDraggedItem("");
|
2797
|
+
onChange(valueRef.current);
|
2798
|
+
},
|
2784
2799
|
onMove: (move) => {
|
2785
|
-
|
2800
|
+
if (arrayState.items[move.source]._arrayId !== draggedItem) {
|
2801
|
+
return;
|
2802
|
+
}
|
2803
|
+
const newValue = reorder(localState.value, move.source, move.target);
|
2786
2804
|
const newArrayStateItems = reorder(
|
2787
2805
|
arrayState.items,
|
2788
2806
|
move.source,
|
@@ -2795,11 +2813,11 @@ var ArrayField = ({
|
|
2795
2813
|
})
|
2796
2814
|
};
|
2797
2815
|
setUi(newUi, false);
|
2798
|
-
onChange(newValue, newUi);
|
2799
2816
|
setLocalState({
|
2800
2817
|
value: newValue,
|
2801
2818
|
arrayState: __spreadProps(__spreadValues({}, arrayState), { items: newArrayStateItems })
|
2802
2819
|
});
|
2820
|
+
valueRef.current = newValue;
|
2803
2821
|
},
|
2804
2822
|
children: /* @__PURE__ */ jsxs3(
|
2805
2823
|
"div",
|
@@ -2809,172 +2827,156 @@ var ArrayField = ({
|
|
2809
2827
|
addDisabled
|
2810
2828
|
}),
|
2811
2829
|
children: [
|
2812
|
-
/* @__PURE__ */ jsx7(
|
2813
|
-
|
2814
|
-
{
|
2815
|
-
|
2816
|
-
|
2817
|
-
|
2818
|
-
|
2819
|
-
|
2820
|
-
|
2821
|
-
|
2822
|
-
|
2830
|
+
localState.arrayState.items.length > 0 && /* @__PURE__ */ jsx7("div", { className: getClassName5("inner"), "data-dnd-container": true, children: localState.arrayState.items.map((item, i) => {
|
2831
|
+
const { _arrayId = `${id}-${i}`, _originalIndex = i } = item;
|
2832
|
+
const data = Array.from(localState.value || [])[i] || {};
|
2833
|
+
return /* @__PURE__ */ jsx7(
|
2834
|
+
Sortable,
|
2835
|
+
{
|
2836
|
+
id: _arrayId,
|
2837
|
+
index: i,
|
2838
|
+
disabled: readOnly,
|
2839
|
+
children: ({ status, ref, handleRef }) => /* @__PURE__ */ jsxs3(
|
2840
|
+
"div",
|
2823
2841
|
{
|
2824
|
-
|
2825
|
-
|
2826
|
-
|
2827
|
-
|
2828
|
-
|
2829
|
-
|
2830
|
-
|
2831
|
-
|
2832
|
-
|
2833
|
-
|
2834
|
-
|
2835
|
-
|
2836
|
-
|
2837
|
-
|
2838
|
-
|
2839
|
-
{
|
2840
|
-
|
2841
|
-
|
2842
|
-
|
2843
|
-
|
2844
|
-
|
2845
|
-
|
2846
|
-
|
2847
|
-
|
2848
|
-
|
2849
|
-
|
2850
|
-
|
2851
|
-
setUi(
|
2852
|
-
mapArrayStateToUi({
|
2853
|
-
openId: _arrayId
|
2854
|
-
})
|
2855
|
-
);
|
2856
|
-
}
|
2857
|
-
},
|
2858
|
-
className: getClassNameItem("summary"),
|
2859
|
-
children: [
|
2860
|
-
field.getItemSummary ? field.getItemSummary(data, i) : `Item #${_originalIndex}`,
|
2861
|
-
/* @__PURE__ */ jsxs3("div", { className: getClassNameItem("rhs"), children: [
|
2862
|
-
!readOnly && /* @__PURE__ */ jsxs3("div", { className: getClassNameItem("actions"), children: [
|
2863
|
-
/* @__PURE__ */ jsx7("div", { className: getClassNameItem("action"), children: /* @__PURE__ */ jsx7(
|
2864
|
-
IconButton,
|
2865
|
-
{
|
2866
|
-
type: "button",
|
2867
|
-
disabled: !!addDisabled,
|
2868
|
-
onClick: (e) => {
|
2869
|
-
e.stopPropagation();
|
2870
|
-
const existingValue = [...value || []];
|
2871
|
-
existingValue.splice(
|
2872
|
-
i,
|
2873
|
-
0,
|
2874
|
-
existingValue[i]
|
2875
|
-
);
|
2876
|
-
onChange(
|
2877
|
-
existingValue,
|
2878
|
-
mapArrayStateToUi(
|
2879
|
-
regenerateArrayState(existingValue)
|
2880
|
-
)
|
2881
|
-
);
|
2882
|
-
},
|
2883
|
-
title: "Duplicate",
|
2884
|
-
children: /* @__PURE__ */ jsx7(Copy, { size: 16 })
|
2885
|
-
}
|
2886
|
-
) }),
|
2887
|
-
/* @__PURE__ */ jsx7("div", { className: getClassNameItem("action"), children: /* @__PURE__ */ jsx7(
|
2888
|
-
IconButton,
|
2889
|
-
{
|
2890
|
-
type: "button",
|
2891
|
-
disabled: field.min !== void 0 && field.min >= localState.arrayState.items.length,
|
2892
|
-
onClick: (e) => {
|
2893
|
-
e.stopPropagation();
|
2894
|
-
const existingValue = [...value || []];
|
2895
|
-
const existingItems = [
|
2896
|
-
...arrayState.items || []
|
2897
|
-
];
|
2898
|
-
existingValue.splice(i, 1);
|
2899
|
-
existingItems.splice(i, 1);
|
2900
|
-
onChange(
|
2901
|
-
existingValue,
|
2902
|
-
mapArrayStateToUi({
|
2903
|
-
items: existingItems
|
2904
|
-
})
|
2905
|
-
);
|
2906
|
-
},
|
2907
|
-
title: "Delete",
|
2908
|
-
children: /* @__PURE__ */ jsx7(Trash, { size: 16 })
|
2909
|
-
}
|
2910
|
-
) })
|
2911
|
-
] }),
|
2912
|
-
/* @__PURE__ */ jsx7("div", { children: /* @__PURE__ */ jsx7(DragIcon, {}) })
|
2913
|
-
] })
|
2914
|
-
]
|
2842
|
+
ref,
|
2843
|
+
className: getClassNameItem({
|
2844
|
+
isExpanded: arrayState.openId === _arrayId,
|
2845
|
+
isDragging: status === "dragging",
|
2846
|
+
readOnly
|
2847
|
+
}),
|
2848
|
+
children: [
|
2849
|
+
/* @__PURE__ */ jsxs3(
|
2850
|
+
"div",
|
2851
|
+
{
|
2852
|
+
ref: handleRef,
|
2853
|
+
onClick: (e) => {
|
2854
|
+
if (isDragging) return;
|
2855
|
+
e.preventDefault();
|
2856
|
+
e.stopPropagation();
|
2857
|
+
if (arrayState.openId === _arrayId) {
|
2858
|
+
setUi(
|
2859
|
+
mapArrayStateToUi({
|
2860
|
+
openId: ""
|
2861
|
+
})
|
2862
|
+
);
|
2863
|
+
} else {
|
2864
|
+
setUi(
|
2865
|
+
mapArrayStateToUi({
|
2866
|
+
openId: _arrayId
|
2867
|
+
})
|
2868
|
+
);
|
2915
2869
|
}
|
2916
|
-
|
2917
|
-
|
2918
|
-
|
2919
|
-
{
|
2920
|
-
|
2921
|
-
|
2922
|
-
|
2923
|
-
|
2924
|
-
|
2925
|
-
|
2926
|
-
|
2927
|
-
|
2928
|
-
|
2929
|
-
|
2930
|
-
|
2931
|
-
|
2932
|
-
|
2933
|
-
|
2934
|
-
|
2935
|
-
|
2870
|
+
},
|
2871
|
+
className: getClassNameItem("summary"),
|
2872
|
+
children: [
|
2873
|
+
field.getItemSummary ? field.getItemSummary(data, i) : `Item #${_originalIndex}`,
|
2874
|
+
/* @__PURE__ */ jsxs3("div", { className: getClassNameItem("rhs"), children: [
|
2875
|
+
!readOnly && /* @__PURE__ */ jsxs3("div", { className: getClassNameItem("actions"), children: [
|
2876
|
+
/* @__PURE__ */ jsx7("div", { className: getClassNameItem("action"), children: /* @__PURE__ */ jsx7(
|
2877
|
+
IconButton,
|
2878
|
+
{
|
2879
|
+
type: "button",
|
2880
|
+
disabled: !!addDisabled,
|
2881
|
+
onClick: (e) => {
|
2882
|
+
e.stopPropagation();
|
2883
|
+
const existingValue = [...value || []];
|
2884
|
+
existingValue.splice(
|
2885
|
+
i,
|
2886
|
+
0,
|
2887
|
+
existingValue[i]
|
2888
|
+
);
|
2889
|
+
const newUi = mapArrayStateToUi(
|
2890
|
+
regenerateArrayState(existingValue)
|
2891
|
+
);
|
2892
|
+
setUi(newUi, false);
|
2893
|
+
onChange(existingValue);
|
2894
|
+
},
|
2895
|
+
title: "Duplicate",
|
2896
|
+
children: /* @__PURE__ */ jsx7(Copy, { size: 16 })
|
2897
|
+
}
|
2898
|
+
) }),
|
2899
|
+
/* @__PURE__ */ jsx7("div", { className: getClassNameItem("action"), children: /* @__PURE__ */ jsx7(
|
2900
|
+
IconButton,
|
2936
2901
|
{
|
2937
|
-
|
2938
|
-
|
2939
|
-
|
2940
|
-
|
2941
|
-
|
2942
|
-
|
2943
|
-
|
2944
|
-
|
2945
|
-
|
2946
|
-
|
2947
|
-
|
2948
|
-
|
2949
|
-
|
2950
|
-
// May be used by custom fields
|
2902
|
+
type: "button",
|
2903
|
+
disabled: field.min !== void 0 && field.min >= localState.arrayState.items.length,
|
2904
|
+
onClick: (e) => {
|
2905
|
+
e.stopPropagation();
|
2906
|
+
const existingValue = [...value || []];
|
2907
|
+
const existingItems = [
|
2908
|
+
...arrayState.items || []
|
2909
|
+
];
|
2910
|
+
existingValue.splice(i, 1);
|
2911
|
+
existingItems.splice(i, 1);
|
2912
|
+
setUi(
|
2913
|
+
mapArrayStateToUi({
|
2914
|
+
items: existingItems
|
2951
2915
|
}),
|
2952
|
-
|
2953
|
-
|
2954
|
-
|
2955
|
-
|
2956
|
-
|
2957
|
-
|
2958
|
-
|
2959
|
-
|
2960
|
-
|
2961
|
-
|
2962
|
-
|
2963
|
-
|
2964
|
-
|
2965
|
-
|
2966
|
-
|
2967
|
-
|
2968
|
-
|
2969
|
-
|
2970
|
-
|
2971
|
-
|
2972
|
-
|
2973
|
-
|
2974
|
-
|
2975
|
-
|
2976
|
-
|
2977
|
-
|
2916
|
+
false
|
2917
|
+
);
|
2918
|
+
onChange(existingValue);
|
2919
|
+
},
|
2920
|
+
title: "Delete",
|
2921
|
+
children: /* @__PURE__ */ jsx7(Trash, { size: 16 })
|
2922
|
+
}
|
2923
|
+
) })
|
2924
|
+
] }),
|
2925
|
+
/* @__PURE__ */ jsx7("div", { children: /* @__PURE__ */ jsx7(DragIcon, {}) })
|
2926
|
+
] })
|
2927
|
+
]
|
2928
|
+
}
|
2929
|
+
),
|
2930
|
+
/* @__PURE__ */ jsx7("div", { className: getClassNameItem("body"), children: /* @__PURE__ */ jsx7("fieldset", { className: getClassNameItem("fieldset"), children: Object.keys(field.arrayFields).map((subName) => {
|
2931
|
+
const subField = field.arrayFields[subName];
|
2932
|
+
const indexName = `${name}[${i}]`;
|
2933
|
+
const subPath = `${indexName}.${subName}`;
|
2934
|
+
const localIndexName = `${localName}[${i}]`;
|
2935
|
+
const localWildcardName = `${localName}[*]`;
|
2936
|
+
const localSubPath = `${localIndexName}.${subName}`;
|
2937
|
+
const localWildcardSubPath = `${localWildcardName}.${subName}`;
|
2938
|
+
const subReadOnly = forceReadOnly ? forceReadOnly : typeof readOnlyFields[subPath] !== "undefined" ? readOnlyFields[localSubPath] : readOnlyFields[localWildcardSubPath];
|
2939
|
+
const label2 = subField.label || subName;
|
2940
|
+
return /* @__PURE__ */ jsx7(
|
2941
|
+
NestedFieldProvider,
|
2942
|
+
{
|
2943
|
+
name: localIndexName,
|
2944
|
+
wildcardName: localWildcardName,
|
2945
|
+
subName,
|
2946
|
+
readOnlyFields,
|
2947
|
+
children: /* @__PURE__ */ jsx7(
|
2948
|
+
AutoFieldPrivate,
|
2949
|
+
{
|
2950
|
+
name: subPath,
|
2951
|
+
label: label2,
|
2952
|
+
id: `${_arrayId}_${subName}`,
|
2953
|
+
readOnly: subReadOnly,
|
2954
|
+
field: __spreadProps(__spreadValues({}, subField), {
|
2955
|
+
label: label2
|
2956
|
+
// May be used by custom fields
|
2957
|
+
}),
|
2958
|
+
value: data[subName],
|
2959
|
+
onChange: (val, ui) => {
|
2960
|
+
onChange(
|
2961
|
+
replace(value, i, __spreadProps(__spreadValues({}, data), {
|
2962
|
+
[subName]: val
|
2963
|
+
})),
|
2964
|
+
ui
|
2965
|
+
);
|
2966
|
+
}
|
2967
|
+
}
|
2968
|
+
)
|
2969
|
+
},
|
2970
|
+
subPath
|
2971
|
+
);
|
2972
|
+
}) }) })
|
2973
|
+
]
|
2974
|
+
}
|
2975
|
+
)
|
2976
|
+
},
|
2977
|
+
_arrayId
|
2978
|
+
);
|
2979
|
+
}) }),
|
2978
2980
|
!addDisabled && /* @__PURE__ */ jsx7(
|
2979
2981
|
"button",
|
2980
2982
|
{
|
@@ -2988,7 +2990,8 @@ var ArrayField = ({
|
|
2988
2990
|
field.defaultItemProps || {}
|
2989
2991
|
];
|
2990
2992
|
const newArrayState = regenerateArrayState(newValue);
|
2991
|
-
|
2993
|
+
setUi(mapArrayStateToUi(newArrayState), false);
|
2994
|
+
onChange(newValue);
|
2992
2995
|
},
|
2993
2996
|
children: /* @__PURE__ */ jsx7(Plus, { size: 21 })
|
2994
2997
|
}
|
@@ -3072,7 +3075,7 @@ init_react_import();
|
|
3072
3075
|
import {
|
3073
3076
|
useMemo as useMemo2,
|
3074
3077
|
useEffect as useEffect9,
|
3075
|
-
useState as
|
3078
|
+
useState as useState6,
|
3076
3079
|
useCallback as useCallback3,
|
3077
3080
|
isValidElement
|
3078
3081
|
} from "react";
|
@@ -3083,7 +3086,7 @@ var styles_module_default6 = { "ExternalInput-actions": "_ExternalInput-actions_
|
|
3083
3086
|
|
3084
3087
|
// components/Modal/index.tsx
|
3085
3088
|
init_react_import();
|
3086
|
-
import { useEffect as useEffect7, useState as
|
3089
|
+
import { useEffect as useEffect7, useState as useState4 } from "react";
|
3087
3090
|
|
3088
3091
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Modal/styles.module.css#css-module
|
3089
3092
|
init_react_import();
|
@@ -3098,7 +3101,7 @@ var Modal = ({
|
|
3098
3101
|
onClose,
|
3099
3102
|
isOpen
|
3100
3103
|
}) => {
|
3101
|
-
const [rootEl, setRootEl] =
|
3104
|
+
const [rootEl, setRootEl] = useState4(null);
|
3102
3105
|
useEffect7(() => {
|
3103
3106
|
setRootEl(document.getElementById("puck-portal-root"));
|
3104
3107
|
}, []);
|
@@ -3146,7 +3149,7 @@ init_react_import();
|
|
3146
3149
|
|
3147
3150
|
// components/Button/Button.tsx
|
3148
3151
|
init_react_import();
|
3149
|
-
import { useEffect as useEffect8, useState as
|
3152
|
+
import { useEffect as useEffect8, useState as useState5 } from "react";
|
3150
3153
|
|
3151
3154
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Button/Button.module.css#css-module
|
3152
3155
|
init_react_import();
|
@@ -3196,7 +3199,7 @@ var Button = (_a) => {
|
|
3196
3199
|
"size",
|
3197
3200
|
"loading"
|
3198
3201
|
]);
|
3199
|
-
const [loading, setLoading] =
|
3202
|
+
const [loading, setLoading] = useState5(loadingProp);
|
3200
3203
|
useEffect8(() => setLoading(loadingProp), [loadingProp]);
|
3201
3204
|
const ElementType = href ? "a" : type ? "button" : "span";
|
3202
3205
|
const dataAttrs = filterDataAttrs(props);
|
@@ -3252,12 +3255,12 @@ var ExternalInput = ({
|
|
3252
3255
|
mapRow = (val) => val,
|
3253
3256
|
filterFields
|
3254
3257
|
} = field || {};
|
3255
|
-
const [data, setData] =
|
3256
|
-
const [isOpen, setOpen] =
|
3257
|
-
const [isLoading, setIsLoading] =
|
3258
|
+
const [data, setData] = useState6([]);
|
3259
|
+
const [isOpen, setOpen] = useState6(false);
|
3260
|
+
const [isLoading, setIsLoading] = useState6(true);
|
3258
3261
|
const hasFilterFields = !!filterFields;
|
3259
|
-
const [filters, setFilters] =
|
3260
|
-
const [filtersToggled, setFiltersToggled] =
|
3262
|
+
const [filters, setFilters] = useState6(field.initialFilters || {});
|
3263
|
+
const [filtersToggled, setFiltersToggled] = useState6(hasFilterFields);
|
3261
3264
|
const mappedData = useMemo2(() => {
|
3262
3265
|
return data.map(mapRow);
|
3263
3266
|
}, [data]);
|
@@ -3272,7 +3275,7 @@ var ExternalInput = ({
|
|
3272
3275
|
}
|
3273
3276
|
return Array.from(validKeys);
|
3274
3277
|
}, [mappedData]);
|
3275
|
-
const [searchQuery, setSearchQuery] =
|
3278
|
+
const [searchQuery, setSearchQuery] = useState6(field.initialQuery || "");
|
3276
3279
|
const search = useCallback3(
|
3277
3280
|
(query, filters2) => __async(void 0, null, function* () {
|
3278
3281
|
setIsLoading(true);
|
@@ -3761,12 +3764,12 @@ var ObjectField = ({
|
|
3761
3764
|
|
3762
3765
|
// lib/use-safe-id.ts
|
3763
3766
|
init_react_import();
|
3764
|
-
import React2, { useState as
|
3767
|
+
import React2, { useState as useState7 } from "react";
|
3765
3768
|
var useSafeId = () => {
|
3766
3769
|
if (typeof React2.useId !== "undefined") {
|
3767
3770
|
return React2.useId();
|
3768
3771
|
}
|
3769
|
-
const [id] =
|
3772
|
+
const [id] = useState7(generateId());
|
3770
3773
|
return id;
|
3771
3774
|
};
|
3772
3775
|
|
@@ -3919,7 +3922,7 @@ function AutoFieldInternal(props) {
|
|
3919
3922
|
function AutoFieldPrivate(props) {
|
3920
3923
|
const isFocused = useAppStore((s) => s.state.ui.field.focus === props.name);
|
3921
3924
|
const { value, onChange } = props;
|
3922
|
-
const [localValue, setLocalValue] =
|
3925
|
+
const [localValue, setLocalValue] = useState8(value);
|
3923
3926
|
const onChangeLocal = useCallback4(
|
3924
3927
|
(val, ui) => {
|
3925
3928
|
setLocalValue(val);
|
@@ -3959,7 +3962,7 @@ init_react_import();
|
|
3959
3962
|
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" };
|
3960
3963
|
|
3961
3964
|
// components/Drawer/index.tsx
|
3962
|
-
import { useMemo as useMemo9, useState as
|
3965
|
+
import { useMemo as useMemo9, useState as useState15 } from "react";
|
3963
3966
|
|
3964
3967
|
// components/DragDropContext/index.tsx
|
3965
3968
|
init_react_import();
|
@@ -3970,7 +3973,7 @@ import {
|
|
3970
3973
|
useContext as useContext7,
|
3971
3974
|
useEffect as useEffect17,
|
3972
3975
|
useRef as useRef4,
|
3973
|
-
useState as
|
3976
|
+
useState as useState14
|
3974
3977
|
} from "react";
|
3975
3978
|
import { AutoScroller, defaultPreset } from "@dnd-kit/dom";
|
3976
3979
|
|
@@ -3993,7 +3996,7 @@ import {
|
|
3993
3996
|
useEffect as useEffect12,
|
3994
3997
|
useMemo as useMemo7,
|
3995
3998
|
useRef as useRef2,
|
3996
|
-
useState as
|
3999
|
+
useState as useState10
|
3997
4000
|
} from "react";
|
3998
4001
|
|
3999
4002
|
// css-module:/home/runner/work/puck/puck/packages/core/components/DraggableComponent/styles.module.css#css-module
|
@@ -4028,7 +4031,7 @@ import {
|
|
4028
4031
|
createContext as createContext3,
|
4029
4032
|
useCallback as useCallback5,
|
4030
4033
|
useMemo as useMemo6,
|
4031
|
-
useState as
|
4034
|
+
useState as useState9
|
4032
4035
|
} from "react";
|
4033
4036
|
import { createStore as createStore2 } from "zustand";
|
4034
4037
|
import { Fragment as Fragment5, jsx as jsx19 } from "react/jsx-runtime";
|
@@ -4053,8 +4056,8 @@ var DropZoneProvider = ({
|
|
4053
4056
|
children,
|
4054
4057
|
value
|
4055
4058
|
}) => {
|
4056
|
-
const [hoveringComponent, setHoveringComponent] =
|
4057
|
-
const [activeZones, setActiveZones] =
|
4059
|
+
const [hoveringComponent, setHoveringComponent] = useState9();
|
4060
|
+
const [activeZones, setActiveZones] = useState9({});
|
4058
4061
|
const dispatch = useAppStore((s) => s.dispatch);
|
4059
4062
|
const registerZone = useCallback5(
|
4060
4063
|
(zoneCompound) => {
|
@@ -4162,7 +4165,7 @@ var DraggableComponent = ({
|
|
4162
4165
|
const dispatch = useAppStore((s) => s.dispatch);
|
4163
4166
|
const iframe = useAppStore((s) => s.iframe);
|
4164
4167
|
const ctx = useContext5(dropZoneContext);
|
4165
|
-
const [localZones, setLocalZones] =
|
4168
|
+
const [localZones, setLocalZones] = useState10({});
|
4166
4169
|
const registerLocalZone = useCallback6(
|
4167
4170
|
(zoneCompound2, active) => {
|
4168
4171
|
var _a;
|
@@ -4203,7 +4206,7 @@ var DraggableComponent = ({
|
|
4203
4206
|
);
|
4204
4207
|
const canCollide = permissions.drag || userIsDragging;
|
4205
4208
|
const disabled = !isEnabled || !canCollide;
|
4206
|
-
const [dragAxis, setDragAxis] =
|
4209
|
+
const [dragAxis, setDragAxis] = useState10(userDragAxis || autoDragAxis);
|
4207
4210
|
const { ref: sortableRef, status } = useSortableSafe({
|
4208
4211
|
id,
|
4209
4212
|
index,
|
@@ -4239,7 +4242,7 @@ var DraggableComponent = ({
|
|
4239
4242
|
},
|
4240
4243
|
[sortableRef]
|
4241
4244
|
);
|
4242
|
-
const [portalEl, setPortalEl] =
|
4245
|
+
const [portalEl, setPortalEl] = useState10();
|
4243
4246
|
useEffect12(() => {
|
4244
4247
|
var _a, _b, _c;
|
4245
4248
|
setPortalEl(
|
@@ -4266,7 +4269,7 @@ var DraggableComponent = ({
|
|
4266
4269
|
};
|
4267
4270
|
return style2;
|
4268
4271
|
}, [ref.current]);
|
4269
|
-
const [style, setStyle] =
|
4272
|
+
const [style, setStyle] = useState10();
|
4270
4273
|
const sync = useCallback6(() => {
|
4271
4274
|
setStyle(getStyle());
|
4272
4275
|
}, [ref.current, iframe]);
|
@@ -4335,7 +4338,7 @@ var DraggableComponent = ({
|
|
4335
4338
|
zone: zoneCompound
|
4336
4339
|
});
|
4337
4340
|
}, [index, zoneCompound]);
|
4338
|
-
const [hover, setHover] =
|
4341
|
+
const [hover, setHover] = useState10(false);
|
4339
4342
|
const indicativeHover = (ctx == null ? void 0 : ctx.hoveringComponent) === id;
|
4340
4343
|
useEffect12(() => {
|
4341
4344
|
if (!ref.current) {
|
@@ -4396,7 +4399,7 @@ var DraggableComponent = ({
|
|
4396
4399
|
};
|
4397
4400
|
}
|
4398
4401
|
}, [disabled, ref]);
|
4399
|
-
const [isVisible, setIsVisible] =
|
4402
|
+
const [isVisible, setIsVisible] = useState10(false);
|
4400
4403
|
useEffect12(() => {
|
4401
4404
|
sync();
|
4402
4405
|
if ((isSelected || hover || indicativeHover) && !userIsDragging) {
|
@@ -4413,10 +4416,18 @@ var DraggableComponent = ({
|
|
4413
4416
|
const rect = el.getBoundingClientRect();
|
4414
4417
|
const diffLeft = rect.x;
|
4415
4418
|
const exceedsBoundsLeft = diffLeft < 0;
|
4419
|
+
const diffTop = rect.y;
|
4420
|
+
const exceedsBoundsTop = diffTop < 0;
|
4416
4421
|
if (exceedsBoundsLeft) {
|
4417
4422
|
el.style.transformOrigin = "left top";
|
4418
4423
|
el.style.left = "0px";
|
4419
4424
|
}
|
4425
|
+
if (exceedsBoundsTop) {
|
4426
|
+
el.style.top = "12px";
|
4427
|
+
if (!exceedsBoundsLeft) {
|
4428
|
+
el.style.transformOrigin = "right top";
|
4429
|
+
}
|
4430
|
+
}
|
4420
4431
|
}
|
4421
4432
|
}
|
4422
4433
|
},
|
@@ -4515,15 +4526,15 @@ var styles_module_default12 = { "DropZone": "_DropZone_kmkdc_1", "DropZone--isAc
|
|
4515
4526
|
|
4516
4527
|
// components/DropZone/lib/use-min-empty-height.ts
|
4517
4528
|
init_react_import();
|
4518
|
-
import { useEffect as useEffect13, useState as
|
4529
|
+
import { useEffect as useEffect13, useState as useState11 } from "react";
|
4519
4530
|
var useMinEmptyHeight = ({
|
4520
4531
|
zoneCompound,
|
4521
4532
|
userMinEmptyHeight,
|
4522
4533
|
ref
|
4523
4534
|
}) => {
|
4524
4535
|
const appStore = useAppStoreApi();
|
4525
|
-
const [prevHeight, setPrevHeight] =
|
4526
|
-
const [isAnimating, setIsAnimating] =
|
4536
|
+
const [prevHeight, setPrevHeight] = useState11(0);
|
4537
|
+
const [isAnimating, setIsAnimating] = useState11(false);
|
4527
4538
|
const { draggedItem, isZone } = useContextStore(ZoneStoreContext, (s) => {
|
4528
4539
|
var _a, _b;
|
4529
4540
|
return {
|
@@ -4569,7 +4580,7 @@ function assignRefs(refs, node) {
|
|
4569
4580
|
|
4570
4581
|
// components/DropZone/lib/use-content-with-preview.ts
|
4571
4582
|
init_react_import();
|
4572
|
-
import { useEffect as useEffect14, useState as
|
4583
|
+
import { useEffect as useEffect14, useState as useState12 } from "react";
|
4573
4584
|
|
4574
4585
|
// lib/dnd/use-rendered-callback.ts
|
4575
4586
|
init_react_import();
|
@@ -4600,8 +4611,8 @@ var useContentIdsWithPreview = (contentIds, zoneCompound) => {
|
|
4600
4611
|
}
|
4601
4612
|
);
|
4602
4613
|
const isDragging = useAppStore((s) => s.state.ui.isDragging);
|
4603
|
-
const [contentIdsWithPreview, setContentIdsWithPreview] =
|
4604
|
-
const [localPreview, setLocalPreview] =
|
4614
|
+
const [contentIdsWithPreview, setContentIdsWithPreview] = useState12(contentIds);
|
4615
|
+
const [localPreview, setLocalPreview] = useState12(
|
4605
4616
|
preview
|
4606
4617
|
);
|
4607
4618
|
const updateContent = useRenderedCallback(
|
@@ -4644,13 +4655,13 @@ var useContentIdsWithPreview = (contentIds, zoneCompound) => {
|
|
4644
4655
|
|
4645
4656
|
// components/DropZone/lib/use-drag-axis.ts
|
4646
4657
|
init_react_import();
|
4647
|
-
import { useCallback as useCallback8, useEffect as useEffect15, useState as
|
4658
|
+
import { useCallback as useCallback8, useEffect as useEffect15, useState as useState13 } from "react";
|
4648
4659
|
var GRID_DRAG_AXIS = "dynamic";
|
4649
4660
|
var FLEX_ROW_DRAG_AXIS = "x";
|
4650
4661
|
var DEFAULT_DRAG_AXIS = "y";
|
4651
4662
|
var useDragAxis = (ref, collisionAxis) => {
|
4652
4663
|
const status = useAppStore((s) => s.status);
|
4653
|
-
const [dragAxis, setDragAxis] =
|
4664
|
+
const [dragAxis, setDragAxis] = useState13(
|
4654
4665
|
collisionAxis || DEFAULT_DRAG_AXIS
|
4655
4666
|
);
|
4656
4667
|
const calculateDragAxis = useCallback8(() => {
|
@@ -5433,7 +5444,7 @@ var DragDropContextClient = ({
|
|
5433
5444
|
const id = useSafeId();
|
5434
5445
|
const debouncedParamsRef = useRef4(null);
|
5435
5446
|
const tempDisableFallback = useTempDisableFallback(100);
|
5436
|
-
const [zoneStore] =
|
5447
|
+
const [zoneStore] = useState14(
|
5437
5448
|
() => createStore3(() => ({
|
5438
5449
|
zoneDepthIndex: {},
|
5439
5450
|
nextZoneDepthIndex: {},
|
@@ -5502,7 +5513,7 @@ var DragDropContextClient = ({
|
|
5502
5513
|
);
|
5503
5514
|
}
|
5504
5515
|
}, []);
|
5505
|
-
const [plugins] =
|
5516
|
+
const [plugins] = useState14(() => [
|
5506
5517
|
...disableAutoScroll ? defaultPreset.plugins.filter((plugin) => plugin !== AutoScroller) : defaultPreset.plugins,
|
5507
5518
|
createNestedDroppablePlugin(
|
5508
5519
|
{
|
@@ -5550,7 +5561,7 @@ var DragDropContextClient = ({
|
|
5550
5561
|
)
|
5551
5562
|
]);
|
5552
5563
|
const sensors = useSensors();
|
5553
|
-
const [dragListeners, setDragListeners] =
|
5564
|
+
const [dragListeners, setDragListeners] = useState14({});
|
5554
5565
|
const dragMode = useRef4(null);
|
5555
5566
|
const initialSelector = useRef4(void 0);
|
5556
5567
|
return /* @__PURE__ */ jsx23("div", { id, children: /* @__PURE__ */ jsx23(
|
@@ -5845,7 +5856,7 @@ var DrawerItem = ({
|
|
5845
5856
|
isDragDisabled
|
5846
5857
|
}) => {
|
5847
5858
|
const resolvedId = id || name;
|
5848
|
-
const [dynamicId, setDynamicId] =
|
5859
|
+
const [dynamicId, setDynamicId] = useState15(generateId(resolvedId));
|
5849
5860
|
if (typeof index !== "undefined") {
|
5850
5861
|
console.error(
|
5851
5862
|
"Warning: The `index` prop on Drawer.Item is deprecated and no longer required."
|
@@ -5912,7 +5923,7 @@ import {
|
|
5912
5923
|
useContext as useContext11,
|
5913
5924
|
useEffect as useEffect25,
|
5914
5925
|
useMemo as useMemo18,
|
5915
|
-
useState as
|
5926
|
+
useState as useState22
|
5916
5927
|
} from "react";
|
5917
5928
|
|
5918
5929
|
// components/SidebarSection/index.tsx
|
@@ -6212,7 +6223,7 @@ init_react_import();
|
|
6212
6223
|
|
6213
6224
|
// lib/use-component-list.tsx
|
6214
6225
|
init_react_import();
|
6215
|
-
import { useEffect as useEffect18, useState as
|
6226
|
+
import { useEffect as useEffect18, useState as useState16 } from "react";
|
6216
6227
|
|
6217
6228
|
// components/ComponentList/index.tsx
|
6218
6229
|
init_react_import();
|
@@ -6283,7 +6294,7 @@ ComponentList.Item = ComponentListItem;
|
|
6283
6294
|
// lib/use-component-list.tsx
|
6284
6295
|
import { jsx as jsx29 } from "react/jsx-runtime";
|
6285
6296
|
var useComponentList = () => {
|
6286
|
-
const [componentList, setComponentList] =
|
6297
|
+
const [componentList, setComponentList] = useState16();
|
6287
6298
|
const config = useAppStore((s) => s.config);
|
6288
6299
|
const uiComponentList = useAppStore((s) => s.state.ui.componentList);
|
6289
6300
|
useEffect18(() => {
|
@@ -6374,7 +6385,7 @@ import {
|
|
6374
6385
|
createContext as createContext5,
|
6375
6386
|
useContext as useContext8,
|
6376
6387
|
useEffect as useEffect19,
|
6377
|
-
useState as
|
6388
|
+
useState as useState17
|
6378
6389
|
} from "react";
|
6379
6390
|
import hash from "object-hash";
|
6380
6391
|
import { createPortal as createPortal3 } from "react-dom";
|
@@ -6602,10 +6613,10 @@ function AutoFrame(_a) {
|
|
6602
6613
|
"onNotReady",
|
6603
6614
|
"frameRef"
|
6604
6615
|
]);
|
6605
|
-
const [loaded, setLoaded] =
|
6606
|
-
const [ctx, setCtx] =
|
6607
|
-
const [mountTarget, setMountTarget] =
|
6608
|
-
const [stylesLoaded, setStylesLoaded] =
|
6616
|
+
const [loaded, setLoaded] = useState17(false);
|
6617
|
+
const [ctx, setCtx] = useState17({});
|
6618
|
+
const [mountTarget, setMountTarget] = useState17();
|
6619
|
+
const [stylesLoaded, setStylesLoaded] = useState17(false);
|
6609
6620
|
useEffect19(() => {
|
6610
6621
|
var _a2;
|
6611
6622
|
if (frameRef.current) {
|
@@ -7151,12 +7162,12 @@ import {
|
|
7151
7162
|
useEffect as useEffect22,
|
7152
7163
|
useMemo as useMemo16,
|
7153
7164
|
useRef as useRef6,
|
7154
|
-
useState as
|
7165
|
+
useState as useState19
|
7155
7166
|
} from "react";
|
7156
7167
|
|
7157
7168
|
// components/ViewportControls/index.tsx
|
7158
7169
|
init_react_import();
|
7159
|
-
import { useEffect as useEffect21, useMemo as useMemo15, useState as
|
7170
|
+
import { useEffect as useEffect21, useMemo as useMemo15, useState as useState18 } from "react";
|
7160
7171
|
|
7161
7172
|
// css-module:/home/runner/work/puck/puck/packages/core/components/ViewportControls/styles.module.css#css-module
|
7162
7173
|
init_react_import();
|
@@ -7179,7 +7190,7 @@ var ViewportButton = ({
|
|
7179
7190
|
onClick
|
7180
7191
|
}) => {
|
7181
7192
|
const viewports = useAppStore((s) => s.state.ui.viewports);
|
7182
|
-
const [isActive, setIsActive] =
|
7193
|
+
const [isActive, setIsActive] = useState18(false);
|
7183
7194
|
useEffect21(() => {
|
7184
7195
|
setIsActive(width === viewports.current.width);
|
7185
7196
|
}, [width, viewports.current.width]);
|
@@ -7364,7 +7375,7 @@ var Canvas = () => {
|
|
7364
7375
|
}))
|
7365
7376
|
);
|
7366
7377
|
const frameRef = useRef6(null);
|
7367
|
-
const [showTransition, setShowTransition] =
|
7378
|
+
const [showTransition, setShowTransition] = useState19(false);
|
7368
7379
|
const defaultRender = useMemo16(() => {
|
7369
7380
|
const PuckDefault = ({ children }) => /* @__PURE__ */ jsx36(Fragment13, { children });
|
7370
7381
|
return PuckDefault;
|
@@ -7423,7 +7434,7 @@ var Canvas = () => {
|
|
7423
7434
|
window.removeEventListener("resize", cb);
|
7424
7435
|
};
|
7425
7436
|
}, []);
|
7426
|
-
const [showLoader, setShowLoader] =
|
7437
|
+
const [showLoader, setShowLoader] = useState19(false);
|
7427
7438
|
useEffect22(() => {
|
7428
7439
|
setTimeout(() => {
|
7429
7440
|
setShowLoader(true);
|
@@ -7553,10 +7564,10 @@ var DefaultOverride = ({ children }) => /* @__PURE__ */ jsx37(Fragment14, { chil
|
|
7553
7564
|
|
7554
7565
|
// lib/use-inject-css.ts
|
7555
7566
|
init_react_import();
|
7556
|
-
import { useEffect as useEffect23, useState as
|
7567
|
+
import { useEffect as useEffect23, useState as useState20 } from "react";
|
7557
7568
|
var styles = ``;
|
7558
7569
|
var useInjectStyleSheet = (initialStyles, iframeEnabled) => {
|
7559
|
-
const [el, setEl] =
|
7570
|
+
const [el, setEl] = useState20();
|
7560
7571
|
useEffect23(() => {
|
7561
7572
|
setEl(document.createElement("style"));
|
7562
7573
|
}, []);
|
@@ -7598,7 +7609,7 @@ var usePreviewModeHotkeys = () => {
|
|
7598
7609
|
|
7599
7610
|
// lib/use-puck.ts
|
7600
7611
|
init_react_import();
|
7601
|
-
import { createContext as createContext6, useContext as useContext10, useEffect as useEffect24, useState as
|
7612
|
+
import { createContext as createContext6, useContext as useContext10, useEffect as useEffect24, useState as useState21 } from "react";
|
7602
7613
|
import { createStore as createStore4, useStore as useStore3 } from "zustand";
|
7603
7614
|
var generateUsePuck = (store) => {
|
7604
7615
|
const history = {
|
@@ -7627,7 +7638,7 @@ var UsePuckStoreContext = createContext6(
|
|
7627
7638
|
null
|
7628
7639
|
);
|
7629
7640
|
var useRegisterUsePuckStore = (appStore) => {
|
7630
|
-
const [usePuckStore] =
|
7641
|
+
const [usePuckStore] = useState21(
|
7631
7642
|
() => createStore4(() => generateUsePuck(appStore.getState()))
|
7632
7643
|
);
|
7633
7644
|
useEffect24(() => {
|
@@ -7709,7 +7720,7 @@ function PuckProvider({ children }) {
|
|
7709
7720
|
enabled: true,
|
7710
7721
|
waitForStyles: true
|
7711
7722
|
}, _iframe);
|
7712
|
-
const [generatedAppState] =
|
7723
|
+
const [generatedAppState] = useState22(() => {
|
7713
7724
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
7714
7725
|
const initial = __spreadValues(__spreadValues({}, defaultAppState.ui), initialUi);
|
7715
7726
|
let clientUiState = {};
|
@@ -7802,7 +7813,7 @@ function PuckProvider({ children }) {
|
|
7802
7813
|
onAction,
|
7803
7814
|
metadata
|
7804
7815
|
]);
|
7805
|
-
const [appStore] =
|
7816
|
+
const [appStore] = useState22(() => createAppStore(generateAppStore()));
|
7806
7817
|
useEffect25(() => {
|
7807
7818
|
appStore.setState(__spreadValues({}, generateAppStore()));
|
7808
7819
|
}, [
|
@@ -7832,7 +7843,7 @@ function PuckProvider({ children }) {
|
|
7832
7843
|
const { state, resolveData: resolveData2 } = appStore.getState();
|
7833
7844
|
resolveData2(state);
|
7834
7845
|
}, []);
|
7835
|
-
return /* @__PURE__ */ jsx38(appStoreContext.Provider, { value: appStore, children: /* @__PURE__ */ jsx38(UsePuckStoreContext, { value: uPuckStore, children }) });
|
7846
|
+
return /* @__PURE__ */ jsx38(appStoreContext.Provider, { value: appStore, children: /* @__PURE__ */ jsx38(UsePuckStoreContext.Provider, { value: uPuckStore, children }) });
|
7836
7847
|
}
|
7837
7848
|
function PuckLayout({ children }) {
|
7838
7849
|
const {
|
@@ -7855,7 +7866,7 @@ function PuckLayout({ children }) {
|
|
7855
7866
|
const rightSideBarVisible = useAppStore(
|
7856
7867
|
(s) => s.state.ui.rightSideBarVisible
|
7857
7868
|
);
|
7858
|
-
const [menuOpen, setMenuOpen] =
|
7869
|
+
const [menuOpen, setMenuOpen] = useState22(false);
|
7859
7870
|
const appStore = useAppStoreApi();
|
7860
7871
|
useEffect25(() => {
|
7861
7872
|
return appStore.subscribe((s) => {
|
@@ -7945,7 +7956,7 @@ function PuckLayout({ children }) {
|
|
7945
7956
|
() => overrides.headerActions || defaultHeaderActionsRender,
|
7946
7957
|
[overrides]
|
7947
7958
|
);
|
7948
|
-
const [mounted, setMounted] =
|
7959
|
+
const [mounted, setMounted] = useState22(false);
|
7949
7960
|
useEffect25(() => {
|
7950
7961
|
setMounted(true);
|
7951
7962
|
}, []);
|
@@ -8110,40 +8121,6 @@ var migrations = [
|
|
8110
8121
|
function migrate(data) {
|
8111
8122
|
return migrations == null ? void 0 : migrations.reduce((acc, migration) => migration(acc), data);
|
8112
8123
|
}
|
8113
|
-
|
8114
|
-
// lib/transform-props.ts
|
8115
|
-
init_react_import();
|
8116
|
-
function transformProps(data, propTransforms) {
|
8117
|
-
const mapItem = (item) => {
|
8118
|
-
if (propTransforms[item.type]) {
|
8119
|
-
return __spreadProps(__spreadValues({}, item), {
|
8120
|
-
props: propTransforms[item.type](item.props)
|
8121
|
-
});
|
8122
|
-
}
|
8123
|
-
return item;
|
8124
|
-
};
|
8125
|
-
const defaultedData = defaultData(data);
|
8126
|
-
const rootProps = defaultedData.root.props || defaultedData.root;
|
8127
|
-
let newRoot = __spreadValues({}, defaultedData.root);
|
8128
|
-
if (propTransforms["root"]) {
|
8129
|
-
if (defaultedData.root.props) {
|
8130
|
-
newRoot.props = propTransforms["root"](rootProps);
|
8131
|
-
} else {
|
8132
|
-
newRoot = propTransforms["root"](rootProps);
|
8133
|
-
}
|
8134
|
-
}
|
8135
|
-
const afterPropTransforms = __spreadProps(__spreadValues({}, defaultedData), {
|
8136
|
-
root: newRoot,
|
8137
|
-
content: defaultedData.content.map(mapItem),
|
8138
|
-
zones: Object.keys(data.zones || {}).reduce(
|
8139
|
-
(acc, zoneKey) => __spreadProps(__spreadValues({}, acc), {
|
8140
|
-
[zoneKey]: data.zones[zoneKey].map(mapItem)
|
8141
|
-
}),
|
8142
|
-
{}
|
8143
|
-
)
|
8144
|
-
});
|
8145
|
-
return afterPropTransforms;
|
8146
|
-
}
|
8147
8124
|
export {
|
8148
8125
|
Action,
|
8149
8126
|
ActionBar,
|