@measured/puck 0.18.3-canary.9e8e47b → 0.18.3
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-CHWFBYEM.mjs → chunk-4QIG6FWS.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 +355 -340
- package/dist/index.mjs +211 -230
- package/dist/{resolve-all-data-ppm982Jh.d.mts → resolve-all-data-ChsqfT2w.d.mts} +12 -1
- package/dist/{resolve-all-data-ppm982Jh.d.ts → resolve-all-data-ChsqfT2w.d.ts} +12 -1
- package/dist/rsc.d.mts +2 -2
- package/dist/rsc.d.ts +2 -2
- package/dist/rsc.js +37 -2
- package/dist/rsc.mjs +5 -3
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
@@ -8,15 +8,15 @@ import {
|
|
8
8
|
__spreadProps,
|
9
9
|
__spreadValues,
|
10
10
|
__toESM,
|
11
|
-
defaultData,
|
12
11
|
getChanged,
|
13
12
|
init_react_import,
|
14
13
|
resolveAllData,
|
15
14
|
resolveComponentData,
|
16
15
|
resolveRootData,
|
17
16
|
rootDroppableId,
|
18
|
-
setupZone
|
19
|
-
|
17
|
+
setupZone,
|
18
|
+
transformProps
|
19
|
+
} from "./chunk-4QIG6FWS.mjs";
|
20
20
|
|
21
21
|
// ../../node_modules/classnames/index.js
|
22
22
|
var require_classnames = __commonJS({
|
@@ -213,7 +213,7 @@ import {
|
|
213
213
|
useContext as useContext3,
|
214
214
|
useEffect as useEffect9,
|
215
215
|
useMemo as useMemo5,
|
216
|
-
useState as
|
216
|
+
useState as useState11
|
217
217
|
} from "react";
|
218
218
|
|
219
219
|
// components/AutoField/fields/index.tsx
|
@@ -674,7 +674,7 @@ var IconButton = ({
|
|
674
674
|
};
|
675
675
|
|
676
676
|
// components/AutoField/fields/ArrayField/index.tsx
|
677
|
-
import { useCallback as useCallback3, useEffect as useEffect4, useState as
|
677
|
+
import { useCallback as useCallback3, useEffect as useEffect4, useRef, useState as useState6 } from "react";
|
678
678
|
|
679
679
|
// components/DragIcon/index.tsx
|
680
680
|
init_react_import();
|
@@ -1084,7 +1084,6 @@ function useAppContext() {
|
|
1084
1084
|
// components/Sortable/index.tsx
|
1085
1085
|
init_react_import();
|
1086
1086
|
import { DragDropProvider } from "@dnd-kit/react";
|
1087
|
-
import { useState as useState6 } from "react";
|
1088
1087
|
|
1089
1088
|
// lib/dnd/dnd-kit/safe.ts
|
1090
1089
|
init_react_import();
|
@@ -1110,7 +1109,8 @@ function useDraggableSafe(input) {
|
|
1110
1109
|
function useSortableSafe(input) {
|
1111
1110
|
if (typeof window === "undefined") {
|
1112
1111
|
return { ref: () => {
|
1113
|
-
}, status: "idle"
|
1112
|
+
}, status: "idle", handleRef: () => {
|
1113
|
+
} };
|
1114
1114
|
}
|
1115
1115
|
return useSortable(input);
|
1116
1116
|
}
|
@@ -1394,23 +1394,26 @@ function patchWindow(window2) {
|
|
1394
1394
|
|
1395
1395
|
// lib/dnd/use-sensors.ts
|
1396
1396
|
import { isElement as isElement2 } from "@dnd-kit/dom/utilities";
|
1397
|
-
var useSensors = (
|
1397
|
+
var useSensors = ({
|
1398
|
+
other,
|
1399
|
+
mouse,
|
1400
|
+
touch
|
1401
|
+
} = {
|
1402
|
+
touch: { delay: { value: 200, tolerance: 10 } },
|
1403
|
+
other: { delay: { value: 200, tolerance: 10 }, distance: { value: 5 } }
|
1404
|
+
}) => {
|
1398
1405
|
const [sensors] = useState5(() => [
|
1399
1406
|
PointerSensor.configure({
|
1400
1407
|
activationConstraints(event, source) {
|
1401
1408
|
var _a;
|
1402
1409
|
const { pointerType, target } = event;
|
1403
1410
|
if (pointerType === "mouse" && isElement2(target) && (source.handle === target || ((_a = source.handle) == null ? void 0 : _a.contains(target)))) {
|
1404
|
-
return
|
1411
|
+
return mouse;
|
1405
1412
|
}
|
1406
|
-
const delay = { value: 200, tolerance: 10 };
|
1407
1413
|
if (pointerType === "touch") {
|
1408
|
-
return
|
1414
|
+
return touch;
|
1409
1415
|
}
|
1410
|
-
return
|
1411
|
-
delay,
|
1412
|
-
distance: { value: 5 }
|
1413
|
-
};
|
1416
|
+
return other;
|
1414
1417
|
}
|
1415
1418
|
})
|
1416
1419
|
]);
|
@@ -1756,7 +1759,6 @@ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input
|
|
1756
1759
|
};
|
1757
1760
|
|
1758
1761
|
// components/Sortable/index.tsx
|
1759
|
-
import { RestrictToElement } from "@dnd-kit/dom/modifiers";
|
1760
1762
|
import { jsx as jsx6 } from "react/jsx-runtime";
|
1761
1763
|
var SortableProvider = ({
|
1762
1764
|
children,
|
@@ -1764,22 +1766,20 @@ var SortableProvider = ({
|
|
1764
1766
|
onDragEnd,
|
1765
1767
|
onMove
|
1766
1768
|
}) => {
|
1767
|
-
const
|
1768
|
-
|
1769
|
+
const sensors = useSensors({
|
1770
|
+
mouse: { distance: { value: 5 } }
|
1771
|
+
});
|
1769
1772
|
return /* @__PURE__ */ jsx6(
|
1770
1773
|
DragDropProvider,
|
1771
1774
|
{
|
1772
1775
|
sensors,
|
1773
|
-
|
1774
|
-
|
1775
|
-
|
1776
|
-
|
1777
|
-
}
|
1778
|
-
})
|
1779
|
-
],
|
1780
|
-
onDragStart,
|
1776
|
+
onDragStart: (event) => {
|
1777
|
+
var _a, _b;
|
1778
|
+
return onDragStart((_b = (_a = event.operation.source) == null ? void 0 : _a.id.toString()) != null ? _b : "");
|
1779
|
+
},
|
1781
1780
|
onDragOver: (event, manager) => {
|
1782
1781
|
var _a, _b;
|
1782
|
+
event.preventDefault();
|
1783
1783
|
const { operation } = event;
|
1784
1784
|
const { source, target } = operation;
|
1785
1785
|
if (!source || !target) return;
|
@@ -1787,14 +1787,14 @@ var SortableProvider = ({
|
|
1787
1787
|
let targetIndex = target.data.index;
|
1788
1788
|
const collisionData = (_b = (_a = manager.dragOperation.data) == null ? void 0 : _a.collisionMap) == null ? void 0 : _b[target.id];
|
1789
1789
|
if (sourceIndex !== targetIndex && source.id !== target.id) {
|
1790
|
-
const collisionPosition =
|
1790
|
+
const collisionPosition = collisionData.direction === "up" ? "before" : "after";
|
1791
1791
|
if (targetIndex >= sourceIndex) {
|
1792
1792
|
targetIndex = targetIndex - 1;
|
1793
1793
|
}
|
1794
1794
|
if (collisionPosition === "after") {
|
1795
1795
|
targetIndex = targetIndex + 1;
|
1796
1796
|
}
|
1797
|
-
|
1797
|
+
onMove({
|
1798
1798
|
source: sourceIndex,
|
1799
1799
|
target: targetIndex
|
1800
1800
|
});
|
@@ -1802,12 +1802,8 @@ var SortableProvider = ({
|
|
1802
1802
|
},
|
1803
1803
|
onDragEnd: () => {
|
1804
1804
|
setTimeout(() => {
|
1805
|
-
if (move.source !== -1 && move.target !== -1) {
|
1806
|
-
onMove(move);
|
1807
|
-
}
|
1808
1805
|
onDragEnd();
|
1809
1806
|
}, 250);
|
1810
|
-
setMove({ source: -1, target: -1 });
|
1811
1807
|
},
|
1812
1808
|
children
|
1813
1809
|
}
|
@@ -1820,7 +1816,11 @@ var Sortable = ({
|
|
1820
1816
|
children,
|
1821
1817
|
type = "item"
|
1822
1818
|
}) => {
|
1823
|
-
const {
|
1819
|
+
const {
|
1820
|
+
ref: sortableRef,
|
1821
|
+
status,
|
1822
|
+
handleRef
|
1823
|
+
} = useSortableSafe({
|
1824
1824
|
id,
|
1825
1825
|
type,
|
1826
1826
|
index,
|
@@ -1828,7 +1828,7 @@ var Sortable = ({
|
|
1828
1828
|
data: { index },
|
1829
1829
|
collisionDetector: createDynamicCollisionDetector("y")
|
1830
1830
|
});
|
1831
|
-
return children({ status, ref: sortableRef });
|
1831
|
+
return children({ status, ref: sortableRef, handleRef });
|
1832
1832
|
};
|
1833
1833
|
|
1834
1834
|
// components/AutoField/context.tsx
|
@@ -1902,10 +1902,16 @@ var ArrayField = ({
|
|
1902
1902
|
}),
|
1903
1903
|
openId: ""
|
1904
1904
|
};
|
1905
|
-
const [localState, setLocalState] =
|
1905
|
+
const [localState, setLocalState] = useState6({ arrayState, value });
|
1906
|
+
const updateLocalState = useCallback3(
|
1907
|
+
(value2) => {
|
1908
|
+
setLocalState({ arrayState, value: value2 });
|
1909
|
+
},
|
1910
|
+
[arrayState]
|
1911
|
+
);
|
1906
1912
|
useEffect4(() => {
|
1907
|
-
|
1908
|
-
}, [value
|
1913
|
+
updateLocalState(value);
|
1914
|
+
}, [value]);
|
1909
1915
|
const mapArrayStateToUi = useCallback3(
|
1910
1916
|
(partialArrayState) => {
|
1911
1917
|
return {
|
@@ -1946,8 +1952,10 @@ var ArrayField = ({
|
|
1946
1952
|
setUi(mapArrayStateToUi(arrayState));
|
1947
1953
|
}
|
1948
1954
|
}, []);
|
1949
|
-
const [
|
1955
|
+
const [draggedItem, setDraggedItem] = useState6("");
|
1956
|
+
const isDragging = !!draggedItem;
|
1950
1957
|
const forceReadOnly = getPermissions({ item: selectedItem }).edit === false;
|
1958
|
+
const valueRef = useRef(value);
|
1951
1959
|
if (field.type !== "array" || !field.arrayFields) {
|
1952
1960
|
return null;
|
1953
1961
|
}
|
@@ -1962,10 +1970,17 @@ var ArrayField = ({
|
|
1962
1970
|
children: /* @__PURE__ */ jsx8(
|
1963
1971
|
SortableProvider,
|
1964
1972
|
{
|
1965
|
-
onDragStart: () =>
|
1966
|
-
onDragEnd: () =>
|
1973
|
+
onDragStart: (id2) => setDraggedItem(id2),
|
1974
|
+
onDragEnd: () => {
|
1975
|
+
setDraggedItem("");
|
1976
|
+
onChange(valueRef.current);
|
1977
|
+
},
|
1967
1978
|
onMove: (move) => {
|
1968
|
-
|
1979
|
+
var _a;
|
1980
|
+
if (((_a = arrayState.items[move.source]) == null ? void 0 : _a._arrayId) !== draggedItem) {
|
1981
|
+
return;
|
1982
|
+
}
|
1983
|
+
const newValue = reorder(localState.value, move.source, move.target);
|
1969
1984
|
const newArrayStateItems = reorder(
|
1970
1985
|
arrayState.items,
|
1971
1986
|
move.source,
|
@@ -1977,11 +1992,11 @@ var ArrayField = ({
|
|
1977
1992
|
})
|
1978
1993
|
};
|
1979
1994
|
setUi(newUi, false);
|
1980
|
-
onChange(newValue, newUi);
|
1981
1995
|
setLocalState({
|
1982
1996
|
value: newValue,
|
1983
1997
|
arrayState: __spreadProps(__spreadValues({}, arrayState), { items: newArrayStateItems })
|
1984
1998
|
});
|
1999
|
+
valueRef.current = newValue;
|
1985
2000
|
},
|
1986
2001
|
children: /* @__PURE__ */ jsxs3(
|
1987
2002
|
"div",
|
@@ -1990,11 +2005,8 @@ var ArrayField = ({
|
|
1990
2005
|
hasItems: Array.isArray(value) && value.length > 0,
|
1991
2006
|
addDisabled
|
1992
2007
|
}),
|
1993
|
-
onClick: (e) => {
|
1994
|
-
e.preventDefault();
|
1995
|
-
},
|
1996
2008
|
children: [
|
1997
|
-
/* @__PURE__ */ jsx8("div", { className: getClassName5("inner"), "data-dnd-container": true, children: localState.arrayState.items.map((item, i) => {
|
2009
|
+
localState.arrayState.items.length > 0 && /* @__PURE__ */ jsx8("div", { className: getClassName5("inner"), "data-dnd-container": true, children: localState.arrayState.items.map((item, i) => {
|
1998
2010
|
const { _arrayId = `${id}-${i}`, _originalIndex = i } = item;
|
1999
2011
|
const data = Array.from(localState.value || [])[i] || {};
|
2000
2012
|
return /* @__PURE__ */ jsx8(
|
@@ -2003,7 +2015,7 @@ var ArrayField = ({
|
|
2003
2015
|
id: _arrayId,
|
2004
2016
|
index: i,
|
2005
2017
|
disabled: readOnly,
|
2006
|
-
children: ({ status, ref }) => /* @__PURE__ */ jsxs3(
|
2018
|
+
children: ({ status, ref, handleRef }) => /* @__PURE__ */ jsxs3(
|
2007
2019
|
"div",
|
2008
2020
|
{
|
2009
2021
|
ref,
|
@@ -2016,6 +2028,7 @@ var ArrayField = ({
|
|
2016
2028
|
/* @__PURE__ */ jsxs3(
|
2017
2029
|
"div",
|
2018
2030
|
{
|
2031
|
+
ref: handleRef,
|
2019
2032
|
onClick: (e) => {
|
2020
2033
|
if (isDragging) return;
|
2021
2034
|
e.preventDefault();
|
@@ -2052,12 +2065,11 @@ var ArrayField = ({
|
|
2052
2065
|
0,
|
2053
2066
|
existingValue[i]
|
2054
2067
|
);
|
2055
|
-
|
2056
|
-
existingValue
|
2057
|
-
mapArrayStateToUi(
|
2058
|
-
regenerateArrayState(existingValue)
|
2059
|
-
)
|
2068
|
+
const newUi = mapArrayStateToUi(
|
2069
|
+
regenerateArrayState(existingValue)
|
2060
2070
|
);
|
2071
|
+
setUi(newUi, false);
|
2072
|
+
onChange(existingValue, newUi);
|
2061
2073
|
},
|
2062
2074
|
title: "Duplicate",
|
2063
2075
|
children: /* @__PURE__ */ jsx8(Copy, { size: 16 })
|
@@ -2076,12 +2088,11 @@ var ArrayField = ({
|
|
2076
2088
|
];
|
2077
2089
|
existingValue.splice(i, 1);
|
2078
2090
|
existingItems.splice(i, 1);
|
2079
|
-
|
2080
|
-
|
2081
|
-
|
2082
|
-
|
2083
|
-
|
2084
|
-
);
|
2091
|
+
const newUi = mapArrayStateToUi({
|
2092
|
+
items: existingItems
|
2093
|
+
});
|
2094
|
+
setUi(newUi, false);
|
2095
|
+
onChange(existingValue, newUi);
|
2085
2096
|
},
|
2086
2097
|
title: "Delete",
|
2087
2098
|
children: /* @__PURE__ */ jsx8(Trash, { size: 16 })
|
@@ -2093,58 +2104,49 @@ var ArrayField = ({
|
|
2093
2104
|
]
|
2094
2105
|
}
|
2095
2106
|
),
|
2096
|
-
/* @__PURE__ */ jsx8("div", { className: getClassNameItem("body"), children: /* @__PURE__ */ jsx8(
|
2097
|
-
|
2098
|
-
{
|
2099
|
-
|
2100
|
-
|
2101
|
-
|
2102
|
-
|
2103
|
-
|
2104
|
-
|
2105
|
-
|
2106
|
-
|
2107
|
-
|
2108
|
-
|
2109
|
-
|
2110
|
-
|
2111
|
-
|
2112
|
-
|
2113
|
-
|
2114
|
-
|
2107
|
+
/* @__PURE__ */ jsx8("div", { className: getClassNameItem("body"), children: /* @__PURE__ */ jsx8("fieldset", { className: getClassNameItem("fieldset"), children: Object.keys(field.arrayFields).map((subName) => {
|
2108
|
+
const subField = field.arrayFields[subName];
|
2109
|
+
const indexName = `${name}[${i}]`;
|
2110
|
+
const subPath = `${indexName}.${subName}`;
|
2111
|
+
const localIndexName = `${localName}[${i}]`;
|
2112
|
+
const localWildcardName = `${localName}[*]`;
|
2113
|
+
const localSubPath = `${localIndexName}.${subName}`;
|
2114
|
+
const localWildcardSubPath = `${localWildcardName}.${subName}`;
|
2115
|
+
const subReadOnly = forceReadOnly ? forceReadOnly : typeof readOnlyFields[subPath] !== "undefined" ? readOnlyFields[localSubPath] : readOnlyFields[localWildcardSubPath];
|
2116
|
+
const label2 = subField.label || subName;
|
2117
|
+
return /* @__PURE__ */ jsx8(
|
2118
|
+
NestedFieldProvider,
|
2119
|
+
{
|
2120
|
+
name: localIndexName,
|
2121
|
+
wildcardName: localWildcardName,
|
2122
|
+
subName,
|
2123
|
+
readOnlyFields,
|
2124
|
+
children: /* @__PURE__ */ jsx8(
|
2125
|
+
AutoFieldPrivate,
|
2115
2126
|
{
|
2116
|
-
name:
|
2117
|
-
|
2118
|
-
subName
|
2119
|
-
|
2120
|
-
|
2121
|
-
|
2122
|
-
|
2123
|
-
|
2124
|
-
|
2125
|
-
|
2126
|
-
|
2127
|
-
|
2128
|
-
|
2129
|
-
|
2130
|
-
|
2131
|
-
|
2132
|
-
|
2133
|
-
|
2134
|
-
|
2135
|
-
|
2136
|
-
|
2137
|
-
|
2138
|
-
|
2139
|
-
}
|
2140
|
-
}
|
2141
|
-
)
|
2142
|
-
},
|
2143
|
-
subPath
|
2144
|
-
);
|
2145
|
-
})
|
2146
|
-
}
|
2147
|
-
) })
|
2127
|
+
name: subPath,
|
2128
|
+
label: label2,
|
2129
|
+
id: `${_arrayId}_${subName}`,
|
2130
|
+
readOnly: subReadOnly,
|
2131
|
+
field: __spreadProps(__spreadValues({}, subField), {
|
2132
|
+
label: label2
|
2133
|
+
// May be used by custom fields
|
2134
|
+
}),
|
2135
|
+
value: data[subName],
|
2136
|
+
onChange: (val, ui) => {
|
2137
|
+
onChange(
|
2138
|
+
replace(value, i, __spreadProps(__spreadValues({}, data), {
|
2139
|
+
[subName]: val
|
2140
|
+
})),
|
2141
|
+
ui
|
2142
|
+
);
|
2143
|
+
}
|
2144
|
+
}
|
2145
|
+
)
|
2146
|
+
},
|
2147
|
+
subPath
|
2148
|
+
);
|
2149
|
+
}) }) })
|
2148
2150
|
]
|
2149
2151
|
}
|
2150
2152
|
)
|
@@ -2165,7 +2167,9 @@ var ArrayField = ({
|
|
2165
2167
|
field.defaultItemProps || {}
|
2166
2168
|
];
|
2167
2169
|
const newArrayState = regenerateArrayState(newValue);
|
2168
|
-
|
2170
|
+
const newUi = mapArrayStateToUi(newArrayState);
|
2171
|
+
setUi(newUi, false);
|
2172
|
+
onChange(newValue, newUi);
|
2169
2173
|
},
|
2170
2174
|
children: /* @__PURE__ */ jsx8(Plus, { size: 21 })
|
2171
2175
|
}
|
@@ -2246,7 +2250,7 @@ init_react_import();
|
|
2246
2250
|
import {
|
2247
2251
|
useMemo as useMemo2,
|
2248
2252
|
useEffect as useEffect7,
|
2249
|
-
useState as
|
2253
|
+
useState as useState9,
|
2250
2254
|
useCallback as useCallback4,
|
2251
2255
|
isValidElement
|
2252
2256
|
} from "react";
|
@@ -2257,7 +2261,7 @@ var styles_module_default6 = { "ExternalInput-actions": "_ExternalInput-actions_
|
|
2257
2261
|
|
2258
2262
|
// components/Modal/index.tsx
|
2259
2263
|
init_react_import();
|
2260
|
-
import { useEffect as useEffect5, useState as
|
2264
|
+
import { useEffect as useEffect5, useState as useState7 } from "react";
|
2261
2265
|
|
2262
2266
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Modal/styles.module.css#css-module
|
2263
2267
|
init_react_import();
|
@@ -2272,7 +2276,7 @@ var Modal = ({
|
|
2272
2276
|
onClose,
|
2273
2277
|
isOpen
|
2274
2278
|
}) => {
|
2275
|
-
const [rootEl, setRootEl] =
|
2279
|
+
const [rootEl, setRootEl] = useState7(null);
|
2276
2280
|
useEffect5(() => {
|
2277
2281
|
setRootEl(document.getElementById("puck-portal-root"));
|
2278
2282
|
}, []);
|
@@ -2320,7 +2324,7 @@ init_react_import();
|
|
2320
2324
|
|
2321
2325
|
// components/Button/Button.tsx
|
2322
2326
|
init_react_import();
|
2323
|
-
import { useEffect as useEffect6, useState as
|
2327
|
+
import { useEffect as useEffect6, useState as useState8 } from "react";
|
2324
2328
|
|
2325
2329
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Button/Button.module.css#css-module
|
2326
2330
|
init_react_import();
|
@@ -2370,7 +2374,7 @@ var Button = (_a) => {
|
|
2370
2374
|
"size",
|
2371
2375
|
"loading"
|
2372
2376
|
]);
|
2373
|
-
const [loading, setLoading] =
|
2377
|
+
const [loading, setLoading] = useState8(loadingProp);
|
2374
2378
|
useEffect6(() => setLoading(loadingProp), [loadingProp]);
|
2375
2379
|
const ElementType = href ? "a" : type ? "button" : "span";
|
2376
2380
|
const dataAttrs = filterDataAttrs(props);
|
@@ -2426,12 +2430,12 @@ var ExternalInput = ({
|
|
2426
2430
|
mapRow = (val) => val,
|
2427
2431
|
filterFields
|
2428
2432
|
} = field || {};
|
2429
|
-
const [data, setData] =
|
2430
|
-
const [isOpen, setOpen] =
|
2431
|
-
const [isLoading, setIsLoading] =
|
2433
|
+
const [data, setData] = useState9([]);
|
2434
|
+
const [isOpen, setOpen] = useState9(false);
|
2435
|
+
const [isLoading, setIsLoading] = useState9(true);
|
2432
2436
|
const hasFilterFields = !!filterFields;
|
2433
|
-
const [filters, setFilters] =
|
2434
|
-
const [filtersToggled, setFiltersToggled] =
|
2437
|
+
const [filters, setFilters] = useState9(field.initialFilters || {});
|
2438
|
+
const [filtersToggled, setFiltersToggled] = useState9(hasFilterFields);
|
2435
2439
|
const mappedData = useMemo2(() => {
|
2436
2440
|
return data.map(mapRow);
|
2437
2441
|
}, [data]);
|
@@ -2446,7 +2450,7 @@ var ExternalInput = ({
|
|
2446
2450
|
}
|
2447
2451
|
return Array.from(validKeys);
|
2448
2452
|
}, [mappedData]);
|
2449
|
-
const [searchQuery, setSearchQuery] =
|
2453
|
+
const [searchQuery, setSearchQuery] = useState9(field.initialQuery || "");
|
2450
2454
|
const search = useCallback4(
|
2451
2455
|
(query, filters2) => __async(void 0, null, function* () {
|
2452
2456
|
setIsLoading(true);
|
@@ -2915,7 +2919,7 @@ var ObjectField = ({
|
|
2915
2919
|
|
2916
2920
|
// lib/use-safe-id.ts
|
2917
2921
|
init_react_import();
|
2918
|
-
import React2, { useState as
|
2922
|
+
import React2, { useState as useState10 } from "react";
|
2919
2923
|
|
2920
2924
|
// lib/generate-id.ts
|
2921
2925
|
init_react_import();
|
@@ -2927,7 +2931,7 @@ var useSafeId = () => {
|
|
2927
2931
|
if (typeof React2.useId !== "undefined") {
|
2928
2932
|
return React2.useId();
|
2929
2933
|
}
|
2930
|
-
const [id] =
|
2934
|
+
const [id] = useState10(generateId());
|
2931
2935
|
return id;
|
2932
2936
|
};
|
2933
2937
|
|
@@ -3073,7 +3077,7 @@ function AutoFieldInternal(props) {
|
|
3073
3077
|
function AutoFieldPrivate(props) {
|
3074
3078
|
const { state } = useAppContext();
|
3075
3079
|
const { value, onChange } = props;
|
3076
|
-
const [localValue, setLocalValue] =
|
3080
|
+
const [localValue, setLocalValue] = useState11(value);
|
3077
3081
|
const onChangeDb = useDebouncedCallback(
|
3078
3082
|
(val, ui) => {
|
3079
3083
|
onChange(val, ui);
|
@@ -3081,10 +3085,13 @@ function AutoFieldPrivate(props) {
|
|
3081
3085
|
50,
|
3082
3086
|
{ leading: true }
|
3083
3087
|
);
|
3084
|
-
const onChangeLocal = useCallback5(
|
3085
|
-
|
3086
|
-
|
3087
|
-
|
3088
|
+
const onChangeLocal = useCallback5(
|
3089
|
+
(val, ui) => {
|
3090
|
+
setLocalValue(val);
|
3091
|
+
onChangeDb(val, ui);
|
3092
|
+
},
|
3093
|
+
[onChange]
|
3094
|
+
);
|
3088
3095
|
useEffect9(() => {
|
3089
3096
|
if (state.ui.field.focus !== props.name) {
|
3090
3097
|
setLocalValue(value);
|
@@ -3117,7 +3124,7 @@ init_react_import();
|
|
3117
3124
|
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" };
|
3118
3125
|
|
3119
3126
|
// components/Drawer/index.tsx
|
3120
|
-
import { useId as useId2, useMemo as useMemo9, useState as
|
3127
|
+
import { useId as useId2, useMemo as useMemo9, useState as useState18 } from "react";
|
3121
3128
|
|
3122
3129
|
// components/DragDropContext/index.tsx
|
3123
3130
|
init_react_import();
|
@@ -3128,8 +3135,8 @@ import {
|
|
3128
3135
|
useContext as useContext7,
|
3129
3136
|
useEffect as useEffect15,
|
3130
3137
|
useId,
|
3131
|
-
useRef as
|
3132
|
-
useState as
|
3138
|
+
useRef as useRef4,
|
3139
|
+
useState as useState17
|
3133
3140
|
} from "react";
|
3134
3141
|
import { AutoScroller, defaultPreset } from "@dnd-kit/dom";
|
3135
3142
|
|
@@ -3141,7 +3148,7 @@ import {
|
|
3141
3148
|
useContext as useContext6,
|
3142
3149
|
useEffect as useEffect14,
|
3143
3150
|
useMemo as useMemo8,
|
3144
|
-
useRef as
|
3151
|
+
useRef as useRef3
|
3145
3152
|
} from "react";
|
3146
3153
|
|
3147
3154
|
// components/DraggableComponent/index.tsx
|
@@ -3151,8 +3158,8 @@ import {
|
|
3151
3158
|
useContext as useContext5,
|
3152
3159
|
useEffect as useEffect10,
|
3153
3160
|
useMemo as useMemo7,
|
3154
|
-
useRef,
|
3155
|
-
useState as
|
3161
|
+
useRef as useRef2,
|
3162
|
+
useState as useState13
|
3156
3163
|
} from "react";
|
3157
3164
|
|
3158
3165
|
// css-module:/home/runner/work/puck/puck/packages/core/components/DraggableComponent/styles.module.css#css-module
|
@@ -3187,7 +3194,7 @@ import {
|
|
3187
3194
|
createContext as createContext3,
|
3188
3195
|
useCallback as useCallback6,
|
3189
3196
|
useMemo as useMemo6,
|
3190
|
-
useState as
|
3197
|
+
useState as useState12
|
3191
3198
|
} from "react";
|
3192
3199
|
import { createStore as createStore2 } from "zustand";
|
3193
3200
|
import { Fragment as Fragment5, jsx as jsx20 } from "react/jsx-runtime";
|
@@ -3212,11 +3219,11 @@ var DropZoneProvider = ({
|
|
3212
3219
|
children,
|
3213
3220
|
value
|
3214
3221
|
}) => {
|
3215
|
-
const [hoveringComponent, setHoveringComponent] =
|
3216
|
-
const [areasWithZones, setAreasWithZones] =
|
3222
|
+
const [hoveringComponent, setHoveringComponent] = useState12();
|
3223
|
+
const [areasWithZones, setAreasWithZones] = useState12(
|
3217
3224
|
{}
|
3218
3225
|
);
|
3219
|
-
const [activeZones, setActiveZones] =
|
3226
|
+
const [activeZones, setActiveZones] = useState12({});
|
3220
3227
|
const { dispatch } = useAppContext();
|
3221
3228
|
const registerZoneArea = useCallback6(
|
3222
3229
|
(area) => {
|
@@ -3333,7 +3340,7 @@ var DraggableComponent = ({
|
|
3333
3340
|
state
|
3334
3341
|
} = useAppContext();
|
3335
3342
|
const ctx = useContext5(dropZoneContext);
|
3336
|
-
const [localZones, setLocalZones] =
|
3343
|
+
const [localZones, setLocalZones] = useState13({});
|
3337
3344
|
const registerLocalZone = useCallback7(
|
3338
3345
|
(zoneCompound2, active) => {
|
3339
3346
|
var _a;
|
@@ -3358,7 +3365,7 @@ var DraggableComponent = ({
|
|
3358
3365
|
);
|
3359
3366
|
const containsActiveZone = Object.values(localZones).filter(Boolean).length > 0;
|
3360
3367
|
const { path = [] } = ctx || {};
|
3361
|
-
const [canDrag, setCanDrag] =
|
3368
|
+
const [canDrag, setCanDrag] = useState13(false);
|
3362
3369
|
useEffect10(() => {
|
3363
3370
|
var _a;
|
3364
3371
|
const item = getItem({ index, zone: zoneCompound }, state.data);
|
@@ -3375,7 +3382,7 @@ var DraggableComponent = ({
|
|
3375
3382
|
);
|
3376
3383
|
const canCollide = canDrag || userIsDragging;
|
3377
3384
|
const disabled = !isEnabled || !canCollide;
|
3378
|
-
const [dragAxis, setDragAxis] =
|
3385
|
+
const [dragAxis, setDragAxis] = useState13(userDragAxis || autoDragAxis);
|
3379
3386
|
const { ref: sortableRef, status } = useSortableSafe({
|
3380
3387
|
id,
|
3381
3388
|
index,
|
@@ -3401,7 +3408,7 @@ var DraggableComponent = ({
|
|
3401
3408
|
}
|
3402
3409
|
});
|
3403
3410
|
const thisIsDragging = status === "dragging";
|
3404
|
-
const ref =
|
3411
|
+
const ref = useRef2(null);
|
3405
3412
|
const refSetter = useCallback7(
|
3406
3413
|
(el) => {
|
3407
3414
|
sortableRef(el);
|
@@ -3411,7 +3418,7 @@ var DraggableComponent = ({
|
|
3411
3418
|
},
|
3412
3419
|
[sortableRef]
|
3413
3420
|
);
|
3414
|
-
const [portalEl, setPortalEl] =
|
3421
|
+
const [portalEl, setPortalEl] = useState13();
|
3415
3422
|
useEffect10(() => {
|
3416
3423
|
var _a, _b, _c;
|
3417
3424
|
setPortalEl(
|
@@ -3438,7 +3445,7 @@ var DraggableComponent = ({
|
|
3438
3445
|
};
|
3439
3446
|
return style2;
|
3440
3447
|
}, [ref.current]);
|
3441
|
-
const [style, setStyle] =
|
3448
|
+
const [style, setStyle] = useState13();
|
3442
3449
|
const sync = useCallback7(() => {
|
3443
3450
|
setStyle(getStyle());
|
3444
3451
|
}, [ref.current, iframe]);
|
@@ -3516,7 +3523,7 @@ var DraggableComponent = ({
|
|
3516
3523
|
zone: zoneCompound
|
3517
3524
|
});
|
3518
3525
|
}, [index, zoneCompound]);
|
3519
|
-
const [hover, setHover] =
|
3526
|
+
const [hover, setHover] = useState13(false);
|
3520
3527
|
const indicativeHover = (ctx == null ? void 0 : ctx.hoveringComponent) === id;
|
3521
3528
|
useEffect10(() => {
|
3522
3529
|
if (!ref.current) {
|
@@ -3577,7 +3584,7 @@ var DraggableComponent = ({
|
|
3577
3584
|
};
|
3578
3585
|
}
|
3579
3586
|
}, [disabled, ref]);
|
3580
|
-
const [isVisible, setIsVisible] =
|
3587
|
+
const [isVisible, setIsVisible] = useState13(false);
|
3581
3588
|
useEffect10(() => {
|
3582
3589
|
sync();
|
3583
3590
|
if ((isSelected || hover || indicativeHover) && !userIsDragging) {
|
@@ -3594,10 +3601,18 @@ var DraggableComponent = ({
|
|
3594
3601
|
const rect = el.getBoundingClientRect();
|
3595
3602
|
const diffLeft = rect.x;
|
3596
3603
|
const exceedsBoundsLeft = diffLeft < 0;
|
3604
|
+
const diffTop = rect.y;
|
3605
|
+
const exceedsBoundsTop = diffTop < 0;
|
3597
3606
|
if (exceedsBoundsLeft) {
|
3598
3607
|
el.style.transformOrigin = "left top";
|
3599
3608
|
el.style.left = "0px";
|
3600
3609
|
}
|
3610
|
+
if (exceedsBoundsTop) {
|
3611
|
+
el.style.top = "12px";
|
3612
|
+
if (!exceedsBoundsLeft) {
|
3613
|
+
el.style.transformOrigin = "right top";
|
3614
|
+
}
|
3615
|
+
}
|
3601
3616
|
}
|
3602
3617
|
}
|
3603
3618
|
},
|
@@ -3697,14 +3712,14 @@ var styles_module_default12 = { "DropZone": "_DropZone_kmkdc_1", "DropZone--isAc
|
|
3697
3712
|
|
3698
3713
|
// components/DropZone/lib/use-min-empty-height.ts
|
3699
3714
|
init_react_import();
|
3700
|
-
import { useEffect as useEffect11, useState as
|
3715
|
+
import { useEffect as useEffect11, useState as useState14 } from "react";
|
3701
3716
|
var useMinEmptyHeight = ({
|
3702
3717
|
zoneCompound,
|
3703
3718
|
userMinEmptyHeight,
|
3704
3719
|
ref
|
3705
3720
|
}) => {
|
3706
|
-
const [prevHeight, setPrevHeight] =
|
3707
|
-
const [isAnimating, setIsAnimating] =
|
3721
|
+
const [prevHeight, setPrevHeight] = useState14(0);
|
3722
|
+
const [isAnimating, setIsAnimating] = useState14(false);
|
3708
3723
|
const { draggedItem, isZone } = useContextStore(ZoneStoreContext, (s) => {
|
3709
3724
|
var _a, _b;
|
3710
3725
|
return {
|
@@ -3746,7 +3761,7 @@ function assignRefs(refs, node) {
|
|
3746
3761
|
|
3747
3762
|
// components/DropZone/lib/use-content-with-preview.ts
|
3748
3763
|
init_react_import();
|
3749
|
-
import { useEffect as useEffect12, useState as
|
3764
|
+
import { useEffect as useEffect12, useState as useState15 } from "react";
|
3750
3765
|
|
3751
3766
|
// lib/dnd/use-rendered-callback.ts
|
3752
3767
|
init_react_import();
|
@@ -3789,8 +3804,8 @@ var useContentWithPreview = (content, zoneCompound) => {
|
|
3789
3804
|
ui: { isDragging }
|
3790
3805
|
}
|
3791
3806
|
} = useAppContext();
|
3792
|
-
const [contentWithPreview, setContentWithPreview] =
|
3793
|
-
const [localPreview, setLocalPreview] =
|
3807
|
+
const [contentWithPreview, setContentWithPreview] = useState15(content);
|
3808
|
+
const [localPreview, setLocalPreview] = useState15(
|
3794
3809
|
preview
|
3795
3810
|
);
|
3796
3811
|
const updateContent = useRenderedCallback(
|
@@ -3839,13 +3854,13 @@ var useContentWithPreview = (content, zoneCompound) => {
|
|
3839
3854
|
|
3840
3855
|
// components/DropZone/lib/use-drag-axis.ts
|
3841
3856
|
init_react_import();
|
3842
|
-
import { useCallback as useCallback9, useEffect as useEffect13, useState as
|
3857
|
+
import { useCallback as useCallback9, useEffect as useEffect13, useState as useState16 } from "react";
|
3843
3858
|
var GRID_DRAG_AXIS = "dynamic";
|
3844
3859
|
var FLEX_ROW_DRAG_AXIS = "x";
|
3845
3860
|
var DEFAULT_DRAG_AXIS = "y";
|
3846
3861
|
var useDragAxis = (ref, collisionAxis) => {
|
3847
3862
|
const { status } = useAppContext();
|
3848
|
-
const [dragAxis, setDragAxis] =
|
3863
|
+
const [dragAxis, setDragAxis] = useState16(
|
3849
3864
|
collisionAxis || DEFAULT_DRAG_AXIS
|
3850
3865
|
);
|
3851
3866
|
const calculateDragAxis = useCallback9(() => {
|
@@ -3947,7 +3962,7 @@ var DropZoneEdit = forwardRef3(
|
|
3947
3962
|
}
|
3948
3963
|
return data.content || [];
|
3949
3964
|
}, [data, zoneCompound]);
|
3950
|
-
const ref =
|
3965
|
+
const ref = useRef3(null);
|
3951
3966
|
const acceptsTarget = useCallback10(
|
3952
3967
|
(componentType) => {
|
3953
3968
|
if (!componentType) {
|
@@ -4870,7 +4885,7 @@ function useDragListener(type, fn, deps = []) {
|
|
4870
4885
|
}
|
4871
4886
|
var AREA_CHANGE_DEBOUNCE_MS = 100;
|
4872
4887
|
var useTempDisableFallback = (timeout3) => {
|
4873
|
-
const lastFallbackDisable =
|
4888
|
+
const lastFallbackDisable = useRef4(null);
|
4874
4889
|
return useCallback11((manager) => {
|
4875
4890
|
collisionStore.setState({ fallbackEnabled: false });
|
4876
4891
|
const fallbackId = generateId();
|
@@ -4890,9 +4905,9 @@ var DragDropContextClient = ({
|
|
4890
4905
|
const { state, config, dispatch, resolveData } = useAppContext();
|
4891
4906
|
const id = useId();
|
4892
4907
|
const { data } = state;
|
4893
|
-
const debouncedParamsRef =
|
4908
|
+
const debouncedParamsRef = useRef4(null);
|
4894
4909
|
const tempDisableFallback = useTempDisableFallback(100);
|
4895
|
-
const [zoneStore] =
|
4910
|
+
const [zoneStore] = useState17(
|
4896
4911
|
() => createStore3(() => ({
|
4897
4912
|
zoneDepthIndex: {},
|
4898
4913
|
nextZoneDepthIndex: {},
|
@@ -4961,7 +4976,7 @@ var DragDropContextClient = ({
|
|
4961
4976
|
);
|
4962
4977
|
}
|
4963
4978
|
}, []);
|
4964
|
-
const [plugins] =
|
4979
|
+
const [plugins] = useState17(() => [
|
4965
4980
|
...disableAutoScroll ? defaultPreset.plugins.filter((plugin) => plugin !== AutoScroller) : defaultPreset.plugins,
|
4966
4981
|
createNestedDroppablePlugin(
|
4967
4982
|
{
|
@@ -5009,9 +5024,9 @@ var DragDropContextClient = ({
|
|
5009
5024
|
)
|
5010
5025
|
]);
|
5011
5026
|
const sensors = useSensors();
|
5012
|
-
const [dragListeners, setDragListeners] =
|
5013
|
-
const [pathData, setPathData] =
|
5014
|
-
const dragMode =
|
5027
|
+
const [dragListeners, setDragListeners] = useState17({});
|
5028
|
+
const [pathData, setPathData] = useState17();
|
5029
|
+
const dragMode = useRef4(null);
|
5015
5030
|
const registerPath = useCallback11(
|
5016
5031
|
(id2, selector, label) => {
|
5017
5032
|
const [area] = getZoneId(selector.zone);
|
@@ -5040,7 +5055,7 @@ var DragDropContextClient = ({
|
|
5040
5055
|
},
|
5041
5056
|
[data, setPathData]
|
5042
5057
|
);
|
5043
|
-
const initialSelector =
|
5058
|
+
const initialSelector = useRef4(void 0);
|
5044
5059
|
return /* @__PURE__ */ jsx23("div", { id, children: /* @__PURE__ */ jsx23(
|
5045
5060
|
dragListenerContext.Provider,
|
5046
5061
|
{
|
@@ -5332,7 +5347,7 @@ var DrawerItem = ({
|
|
5332
5347
|
isDragDisabled
|
5333
5348
|
}) => {
|
5334
5349
|
const resolvedId = id || name;
|
5335
|
-
const [dynamicId, setDynamicId] =
|
5350
|
+
const [dynamicId, setDynamicId] = useState18(generateId(resolvedId));
|
5336
5351
|
if (typeof index !== "undefined") {
|
5337
5352
|
console.error(
|
5338
5353
|
"Warning: The `index` prop on Drawer.Item is deprecated and no longer required."
|
@@ -5398,7 +5413,7 @@ import {
|
|
5398
5413
|
useEffect as useEffect24,
|
5399
5414
|
useMemo as useMemo19,
|
5400
5415
|
useReducer,
|
5401
|
-
useState as
|
5416
|
+
useState as useState26
|
5402
5417
|
} from "react";
|
5403
5418
|
|
5404
5419
|
// components/SidebarSection/index.tsx
|
@@ -5599,7 +5614,7 @@ import { useMemo as useMemo12 } from "react";
|
|
5599
5614
|
|
5600
5615
|
// lib/use-resolved-fields.ts
|
5601
5616
|
init_react_import();
|
5602
|
-
import { useCallback as useCallback13, useEffect as useEffect17, useMemo as useMemo11, useRef as
|
5617
|
+
import { useCallback as useCallback13, useEffect as useEffect17, useMemo as useMemo11, useRef as useRef6, useState as useState19 } from "react";
|
5603
5618
|
|
5604
5619
|
// lib/use-parent.ts
|
5605
5620
|
init_react_import();
|
@@ -5627,9 +5642,9 @@ var useParent = () => {
|
|
5627
5642
|
|
5628
5643
|
// lib/use-on-value-change.ts
|
5629
5644
|
init_react_import();
|
5630
|
-
import { useRef as
|
5645
|
+
import { useRef as useRef5, useEffect as useEffect16 } from "react";
|
5631
5646
|
function useOnValueChange(value, onChange, compare = Object.is, deps = []) {
|
5632
|
-
const tracked =
|
5647
|
+
const tracked = useRef5(value);
|
5633
5648
|
useEffect16(() => {
|
5634
5649
|
const oldValue = tracked.current;
|
5635
5650
|
if (!compare(value, oldValue)) {
|
@@ -5662,13 +5677,13 @@ var useResolvedFields = ({
|
|
5662
5677
|
[selectedItem, rootFields, componentConfig == null ? void 0 : componentConfig.fields]
|
5663
5678
|
);
|
5664
5679
|
const rootProps = data.root.props || data.root;
|
5665
|
-
const [lastSelectedData, setLastSelectedData] =
|
5666
|
-
const [resolvedFields, setResolvedFields] =
|
5680
|
+
const [lastSelectedData, setLastSelectedData] = useState19({});
|
5681
|
+
const [resolvedFields, setResolvedFields] = useState19({
|
5667
5682
|
fields: defaultFields,
|
5668
5683
|
id: selectedItem == null ? void 0 : selectedItem.props.id
|
5669
5684
|
});
|
5670
|
-
const [fieldsLoading, setFieldsLoading] =
|
5671
|
-
const lastFields =
|
5685
|
+
const [fieldsLoading, setFieldsLoading] = useState19(false);
|
5686
|
+
const lastFields = useRef6(defaultFields);
|
5672
5687
|
const defaultResolveFields = (_componentData, _params) => defaultFields;
|
5673
5688
|
const componentData = useMemo11(
|
5674
5689
|
() => selectedItem ? selectedItem : { props: rootProps, readOnly: data.root.readOnly || {} },
|
@@ -5911,7 +5926,7 @@ init_react_import();
|
|
5911
5926
|
|
5912
5927
|
// lib/use-component-list.tsx
|
5913
5928
|
init_react_import();
|
5914
|
-
import { useEffect as useEffect18, useState as
|
5929
|
+
import { useEffect as useEffect18, useState as useState20 } from "react";
|
5915
5930
|
|
5916
5931
|
// components/ComponentList/index.tsx
|
5917
5932
|
init_react_import();
|
@@ -5978,7 +5993,7 @@ ComponentList.Item = ComponentListItem;
|
|
5978
5993
|
// lib/use-component-list.tsx
|
5979
5994
|
import { jsx as jsx29 } from "react/jsx-runtime";
|
5980
5995
|
var useComponentList = (config, ui) => {
|
5981
|
-
const [componentList, setComponentList] =
|
5996
|
+
const [componentList, setComponentList] = useState20();
|
5982
5997
|
useEffect18(() => {
|
5983
5998
|
var _a, _b, _c;
|
5984
5999
|
if (Object.keys(ui.componentList).length > 0) {
|
@@ -6059,7 +6074,7 @@ var Components = () => {
|
|
6059
6074
|
|
6060
6075
|
// components/Puck/components/Preview/index.tsx
|
6061
6076
|
init_react_import();
|
6062
|
-
import { useCallback as useCallback14, useEffect as useEffect20, useRef as
|
6077
|
+
import { useCallback as useCallback14, useEffect as useEffect20, useRef as useRef8, useMemo as useMemo14 } from "react";
|
6063
6078
|
|
6064
6079
|
// components/AutoFrame/index.tsx
|
6065
6080
|
init_react_import();
|
@@ -6067,7 +6082,7 @@ import {
|
|
6067
6082
|
createContext as createContext5,
|
6068
6083
|
useContext as useContext10,
|
6069
6084
|
useEffect as useEffect19,
|
6070
|
-
useState as
|
6085
|
+
useState as useState21
|
6071
6086
|
} from "react";
|
6072
6087
|
import hash from "object-hash";
|
6073
6088
|
import { createPortal as createPortal3 } from "react-dom";
|
@@ -6291,9 +6306,9 @@ function AutoFrame(_a) {
|
|
6291
6306
|
"onStylesLoaded",
|
6292
6307
|
"frameRef"
|
6293
6308
|
]);
|
6294
|
-
const [loaded, setLoaded] =
|
6295
|
-
const [ctx, setCtx] =
|
6296
|
-
const [mountTarget, setMountTarget] =
|
6309
|
+
const [loaded, setLoaded] = useState21(false);
|
6310
|
+
const [ctx, setCtx] = useState21({});
|
6311
|
+
const [mountTarget, setMountTarget] = useState21();
|
6297
6312
|
useEffect19(() => {
|
6298
6313
|
var _a2;
|
6299
6314
|
if (frameRef.current) {
|
@@ -6433,7 +6448,7 @@ var Preview2 = ({ id = "puck-preview" }) => {
|
|
6433
6448
|
);
|
6434
6449
|
const Frame = useMemo14(() => overrides.iframe, [overrides]);
|
6435
6450
|
const rootProps = state.data.root.props || state.data.root;
|
6436
|
-
const ref =
|
6451
|
+
const ref = useRef8(null);
|
6437
6452
|
useBubbleIframeEvents(ref);
|
6438
6453
|
const inner = state.ui.previewMode === "edit" ? /* @__PURE__ */ jsx33(
|
6439
6454
|
Page,
|
@@ -6812,19 +6827,19 @@ function usePuckHistory({
|
|
6812
6827
|
|
6813
6828
|
// lib/use-history-store.ts
|
6814
6829
|
init_react_import();
|
6815
|
-
import { useState as
|
6830
|
+
import { useState as useState22 } from "react";
|
6816
6831
|
import { useDebouncedCallback as useDebouncedCallback3 } from "use-debounce";
|
6817
6832
|
var EMPTY_HISTORY_INDEX = 0;
|
6818
6833
|
function useHistoryStore(initialHistory) {
|
6819
6834
|
var _a, _b;
|
6820
|
-
const [histories, setHistories] =
|
6835
|
+
const [histories, setHistories] = useState22(
|
6821
6836
|
(_a = initialHistory == null ? void 0 : initialHistory.histories) != null ? _a : []
|
6822
6837
|
);
|
6823
6838
|
const updateHistories = (histories2) => {
|
6824
6839
|
setHistories(histories2);
|
6825
6840
|
setIndex(histories2.length - 1);
|
6826
6841
|
};
|
6827
|
-
const [index, setIndex] =
|
6842
|
+
const [index, setIndex] = useState22(
|
6828
6843
|
(_b = initialHistory == null ? void 0 : initialHistory.index) != null ? _b : EMPTY_HISTORY_INDEX
|
6829
6844
|
);
|
6830
6845
|
const hasPast = index > EMPTY_HISTORY_INDEX;
|
@@ -6988,13 +7003,13 @@ import {
|
|
6988
7003
|
useCallback as useCallback16,
|
6989
7004
|
useEffect as useEffect22,
|
6990
7005
|
useMemo as useMemo17,
|
6991
|
-
useRef as
|
6992
|
-
useState as
|
7006
|
+
useRef as useRef9,
|
7007
|
+
useState as useState24
|
6993
7008
|
} from "react";
|
6994
7009
|
|
6995
7010
|
// components/ViewportControls/index.tsx
|
6996
7011
|
init_react_import();
|
6997
|
-
import { useEffect as useEffect21, useMemo as useMemo16, useState as
|
7012
|
+
import { useEffect as useEffect21, useMemo as useMemo16, useState as useState23 } from "react";
|
6998
7013
|
|
6999
7014
|
// css-module:/home/runner/work/puck/puck/packages/core/components/ViewportControls/styles.module.css#css-module
|
7000
7015
|
init_react_import();
|
@@ -7017,7 +7032,7 @@ var ViewportButton = ({
|
|
7017
7032
|
onClick
|
7018
7033
|
}) => {
|
7019
7034
|
const { state } = useAppContext();
|
7020
|
-
const [isActive, setIsActive] =
|
7035
|
+
const [isActive, setIsActive] = useState23(false);
|
7021
7036
|
useEffect21(() => {
|
7022
7037
|
setIsActive(width === state.ui.viewports.current.width);
|
7023
7038
|
}, [width, state.ui.viewports.current.width]);
|
@@ -7177,8 +7192,8 @@ var Canvas = () => {
|
|
7177
7192
|
const { status, iframe } = useAppContext();
|
7178
7193
|
const { dispatch, state, overrides, setUi, zoomConfig, setZoomConfig } = useAppContext();
|
7179
7194
|
const { ui } = state;
|
7180
|
-
const frameRef =
|
7181
|
-
const [showTransition, setShowTransition] =
|
7195
|
+
const frameRef = useRef9(null);
|
7196
|
+
const [showTransition, setShowTransition] = useState24(false);
|
7182
7197
|
const defaultRender = useMemo17(() => {
|
7183
7198
|
const PuckDefault = ({ children }) => /* @__PURE__ */ jsx37(Fragment13, { children });
|
7184
7199
|
return PuckDefault;
|
@@ -7233,7 +7248,7 @@ var Canvas = () => {
|
|
7233
7248
|
window.removeEventListener("resize", cb);
|
7234
7249
|
};
|
7235
7250
|
}, []);
|
7236
|
-
const [showLoader, setShowLoader] =
|
7251
|
+
const [showLoader, setShowLoader] = useState24(false);
|
7237
7252
|
useEffect22(() => {
|
7238
7253
|
setTimeout(() => {
|
7239
7254
|
setShowLoader(true);
|
@@ -7363,10 +7378,10 @@ var DefaultOverride = ({ children }) => /* @__PURE__ */ jsx38(Fragment14, { chil
|
|
7363
7378
|
|
7364
7379
|
// lib/use-inject-css.ts
|
7365
7380
|
init_react_import();
|
7366
|
-
import { useEffect as useEffect23, useState as
|
7381
|
+
import { useEffect as useEffect23, useState as useState25 } from "react";
|
7367
7382
|
var styles = ``;
|
7368
7383
|
var useInjectStyleSheet = (initialStyles, iframeEnabled) => {
|
7369
|
-
const [el, setEl] =
|
7384
|
+
const [el, setEl] = useState25();
|
7370
7385
|
useEffect23(() => {
|
7371
7386
|
setEl(document.createElement("style"));
|
7372
7387
|
}, []);
|
@@ -7450,7 +7465,7 @@ function Puck({
|
|
7450
7465
|
waitForStyles: true
|
7451
7466
|
}, _iframe);
|
7452
7467
|
useInjectGlobalCss(iframe.enabled);
|
7453
|
-
const [generatedAppState] =
|
7468
|
+
const [generatedAppState] = useState26(() => {
|
7454
7469
|
var _a2, _b2, _c, _d, _e, _f, _g, _h, _i;
|
7455
7470
|
const initial = __spreadValues(__spreadValues({}, defaultAppState.ui), initialUi);
|
7456
7471
|
let clientUiState = {};
|
@@ -7522,7 +7537,7 @@ function Puck({
|
|
7522
7537
|
histories,
|
7523
7538
|
index: initialHistoryIndex
|
7524
7539
|
});
|
7525
|
-
const [reducer] =
|
7540
|
+
const [reducer] = useState26(
|
7526
7541
|
() => createReducer({
|
7527
7542
|
config,
|
7528
7543
|
record: historyStore.record,
|
@@ -7540,7 +7555,7 @@ function Puck({
|
|
7540
7555
|
historyStore,
|
7541
7556
|
iframeEnabled: (_a = _iframe == null ? void 0 : _iframe.enabled) != null ? _a : true
|
7542
7557
|
});
|
7543
|
-
const [menuOpen, setMenuOpen] =
|
7558
|
+
const [menuOpen, setMenuOpen] = useState26(false);
|
7544
7559
|
const { itemSelector, leftSideBarVisible, rightSideBarVisible } = ui;
|
7545
7560
|
const selectedItem = itemSelector ? getItem(itemSelector, data) : null;
|
7546
7561
|
useEffect24(() => {
|
@@ -7627,7 +7642,7 @@ function Puck({
|
|
7627
7642
|
() => loadedOverrides.headerActions || defaultHeaderActionsRender,
|
7628
7643
|
[loadedOverrides]
|
7629
7644
|
);
|
7630
|
-
const [mounted, setMounted] =
|
7645
|
+
const [mounted, setMounted] = useState26(false);
|
7631
7646
|
useEffect24(() => {
|
7632
7647
|
setMounted(true);
|
7633
7648
|
}, []);
|
@@ -7814,40 +7829,6 @@ function migrate(data) {
|
|
7814
7829
|
return migrations == null ? void 0 : migrations.reduce((acc, migration) => migration(acc), data);
|
7815
7830
|
}
|
7816
7831
|
|
7817
|
-
// lib/transform-props.ts
|
7818
|
-
init_react_import();
|
7819
|
-
function transformProps(data, propTransforms) {
|
7820
|
-
const mapItem = (item) => {
|
7821
|
-
if (propTransforms[item.type]) {
|
7822
|
-
return __spreadProps(__spreadValues({}, item), {
|
7823
|
-
props: propTransforms[item.type](item.props)
|
7824
|
-
});
|
7825
|
-
}
|
7826
|
-
return item;
|
7827
|
-
};
|
7828
|
-
const defaultedData = defaultData(data);
|
7829
|
-
const rootProps = defaultedData.root.props || defaultedData.root;
|
7830
|
-
let newRoot = __spreadValues({}, defaultedData.root);
|
7831
|
-
if (propTransforms["root"]) {
|
7832
|
-
if (defaultedData.root.props) {
|
7833
|
-
newRoot.props = propTransforms["root"](rootProps);
|
7834
|
-
} else {
|
7835
|
-
newRoot = propTransforms["root"](rootProps);
|
7836
|
-
}
|
7837
|
-
}
|
7838
|
-
const afterPropTransforms = __spreadProps(__spreadValues({}, defaultedData), {
|
7839
|
-
root: newRoot,
|
7840
|
-
content: defaultedData.content.map(mapItem),
|
7841
|
-
zones: Object.keys(data.zones || {}).reduce(
|
7842
|
-
(acc, zoneKey) => __spreadProps(__spreadValues({}, acc), {
|
7843
|
-
[zoneKey]: data.zones[zoneKey].map(mapItem)
|
7844
|
-
}),
|
7845
|
-
{}
|
7846
|
-
)
|
7847
|
-
});
|
7848
|
-
return afterPropTransforms;
|
7849
|
-
}
|
7850
|
-
|
7851
7832
|
// lib/use-puck.ts
|
7852
7833
|
init_react_import();
|
7853
7834
|
var usePuck = () => {
|