@measured/puck 0.18.3-canary.b44056f → 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 +408 -414
- package/dist/index.mjs +250 -289
- 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 +3 -3
package/dist/index.js
CHANGED
@@ -309,7 +309,7 @@ init_react_import();
|
|
309
309
|
var styles_module_default2 = { "InputWrapper": "_InputWrapper_g5w3n_1", "Input-label": "_Input-label_g5w3n_5", "Input-labelIcon": "_Input-labelIcon_g5w3n_14", "Input-disabledIcon": "_Input-disabledIcon_g5w3n_21", "Input-input": "_Input-input_g5w3n_26", "Input": "_Input_g5w3n_1", "Input--readOnly": "_Input--readOnly_g5w3n_74", "Input-radioGroupItems": "_Input-radioGroupItems_g5w3n_85", "Input-radio": "_Input-radio_g5w3n_85", "Input-radioInner": "_Input-radioInner_g5w3n_102", "Input-radioInput": "_Input-radioInput_g5w3n_147" };
|
310
310
|
|
311
311
|
// components/AutoField/index.tsx
|
312
|
-
var
|
312
|
+
var import_react20 = require("react");
|
313
313
|
|
314
314
|
// components/AutoField/fields/index.tsx
|
315
315
|
init_react_import();
|
@@ -769,7 +769,7 @@ var IconButton = ({
|
|
769
769
|
};
|
770
770
|
|
771
771
|
// components/AutoField/fields/ArrayField/index.tsx
|
772
|
-
var
|
772
|
+
var import_react12 = require("react");
|
773
773
|
|
774
774
|
// components/DragIcon/index.tsx
|
775
775
|
init_react_import();
|
@@ -1278,7 +1278,6 @@ function useAppContext() {
|
|
1278
1278
|
// components/Sortable/index.tsx
|
1279
1279
|
init_react_import();
|
1280
1280
|
var import_react10 = require("@dnd-kit/react");
|
1281
|
-
var import_react11 = require("react");
|
1282
1281
|
|
1283
1282
|
// lib/dnd/dnd-kit/safe.ts
|
1284
1283
|
init_react_import();
|
@@ -1939,16 +1938,13 @@ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input
|
|
1939
1938
|
};
|
1940
1939
|
|
1941
1940
|
// components/Sortable/index.tsx
|
1942
|
-
var import_modifiers = require("@dnd-kit/dom/modifiers");
|
1943
1941
|
var import_jsx_runtime6 = require("react/jsx-runtime");
|
1944
1942
|
var SortableProvider = ({
|
1945
|
-
container,
|
1946
1943
|
children,
|
1947
1944
|
onDragStart,
|
1948
1945
|
onDragEnd,
|
1949
1946
|
onMove
|
1950
1947
|
}) => {
|
1951
|
-
const [move, setMove] = (0, import_react11.useState)({ source: -1, target: -1 });
|
1952
1948
|
const sensors = useSensors({
|
1953
1949
|
mouse: { distance: { value: 5 } }
|
1954
1950
|
});
|
@@ -1956,16 +1952,13 @@ var SortableProvider = ({
|
|
1956
1952
|
import_react10.DragDropProvider,
|
1957
1953
|
{
|
1958
1954
|
sensors,
|
1959
|
-
|
1960
|
-
|
1961
|
-
|
1962
|
-
|
1963
|
-
}
|
1964
|
-
})
|
1965
|
-
],
|
1966
|
-
onDragStart,
|
1955
|
+
onDragStart: (event) => {
|
1956
|
+
var _a, _b;
|
1957
|
+
return onDragStart((_b = (_a = event.operation.source) == null ? void 0 : _a.id.toString()) != null ? _b : "");
|
1958
|
+
},
|
1967
1959
|
onDragOver: (event, manager) => {
|
1968
1960
|
var _a, _b;
|
1961
|
+
event.preventDefault();
|
1969
1962
|
const { operation } = event;
|
1970
1963
|
const { source, target } = operation;
|
1971
1964
|
if (!source || !target) return;
|
@@ -1973,14 +1966,14 @@ var SortableProvider = ({
|
|
1973
1966
|
let targetIndex = target.data.index;
|
1974
1967
|
const collisionData = (_b = (_a = manager.dragOperation.data) == null ? void 0 : _a.collisionMap) == null ? void 0 : _b[target.id];
|
1975
1968
|
if (sourceIndex !== targetIndex && source.id !== target.id) {
|
1976
|
-
const collisionPosition =
|
1969
|
+
const collisionPosition = collisionData.direction === "up" ? "before" : "after";
|
1977
1970
|
if (targetIndex >= sourceIndex) {
|
1978
1971
|
targetIndex = targetIndex - 1;
|
1979
1972
|
}
|
1980
1973
|
if (collisionPosition === "after") {
|
1981
1974
|
targetIndex = targetIndex + 1;
|
1982
1975
|
}
|
1983
|
-
|
1976
|
+
onMove({
|
1984
1977
|
source: sourceIndex,
|
1985
1978
|
target: targetIndex
|
1986
1979
|
});
|
@@ -1988,12 +1981,8 @@ var SortableProvider = ({
|
|
1988
1981
|
},
|
1989
1982
|
onDragEnd: () => {
|
1990
1983
|
setTimeout(() => {
|
1991
|
-
if (move.source !== -1 && move.target !== -1) {
|
1992
|
-
onMove(move);
|
1993
|
-
}
|
1994
1984
|
onDragEnd();
|
1995
1985
|
}, 250);
|
1996
|
-
setMove({ source: -1, target: -1 });
|
1997
1986
|
},
|
1998
1987
|
children
|
1999
1988
|
}
|
@@ -2023,11 +2012,11 @@ var Sortable = ({
|
|
2023
2012
|
|
2024
2013
|
// components/AutoField/context.tsx
|
2025
2014
|
init_react_import();
|
2026
|
-
var
|
2015
|
+
var import_react11 = require("react");
|
2027
2016
|
var import_jsx_runtime7 = require("react/jsx-runtime");
|
2028
|
-
var NestedFieldContext = (0,
|
2017
|
+
var NestedFieldContext = (0, import_react11.createContext)({});
|
2029
2018
|
var useNestedFieldContext = () => {
|
2030
|
-
const context = (0,
|
2019
|
+
const context = (0, import_react11.useContext)(NestedFieldContext);
|
2031
2020
|
return __spreadProps(__spreadValues({}, context), {
|
2032
2021
|
readOnlyFields: context.readOnlyFields || {}
|
2033
2022
|
});
|
@@ -2041,7 +2030,7 @@ var NestedFieldProvider = ({
|
|
2041
2030
|
}) => {
|
2042
2031
|
const subPath = `${name}.${subName}`;
|
2043
2032
|
const wildcardSubPath = `${wildcardName}.${subName}`;
|
2044
|
-
const subReadOnlyFields = (0,
|
2033
|
+
const subReadOnlyFields = (0, import_react11.useMemo)(
|
2045
2034
|
() => Object.keys(readOnlyFields).reduce((acc, readOnlyKey) => {
|
2046
2035
|
const isLocal = readOnlyKey.indexOf(subPath) > -1 || readOnlyKey.indexOf(wildcardSubPath) > -1;
|
2047
2036
|
if (isLocal) {
|
@@ -2092,11 +2081,17 @@ var ArrayField = ({
|
|
2092
2081
|
}),
|
2093
2082
|
openId: ""
|
2094
2083
|
};
|
2095
|
-
const [localState, setLocalState] = (0,
|
2096
|
-
(0,
|
2097
|
-
|
2098
|
-
|
2099
|
-
|
2084
|
+
const [localState, setLocalState] = (0, import_react12.useState)({ arrayState, value });
|
2085
|
+
const updateLocalState = (0, import_react12.useCallback)(
|
2086
|
+
(value2) => {
|
2087
|
+
setLocalState({ arrayState, value: value2 });
|
2088
|
+
},
|
2089
|
+
[arrayState]
|
2090
|
+
);
|
2091
|
+
(0, import_react12.useEffect)(() => {
|
2092
|
+
updateLocalState(value);
|
2093
|
+
}, [value]);
|
2094
|
+
const mapArrayStateToUi = (0, import_react12.useCallback)(
|
2100
2095
|
(partialArrayState) => {
|
2101
2096
|
return {
|
2102
2097
|
arrayState: __spreadProps(__spreadValues({}, state.ui.arrayState), {
|
@@ -2106,13 +2101,13 @@ var ArrayField = ({
|
|
2106
2101
|
},
|
2107
2102
|
[arrayState]
|
2108
2103
|
);
|
2109
|
-
const getHighestIndex = (0,
|
2104
|
+
const getHighestIndex = (0, import_react12.useCallback)(() => {
|
2110
2105
|
return arrayState.items.reduce(
|
2111
2106
|
(acc, item) => item._originalIndex > acc ? item._originalIndex : acc,
|
2112
2107
|
-1
|
2113
2108
|
);
|
2114
2109
|
}, [arrayState]);
|
2115
|
-
const regenerateArrayState = (0,
|
2110
|
+
const regenerateArrayState = (0, import_react12.useCallback)(
|
2116
2111
|
(value2) => {
|
2117
2112
|
let highestIndex = getHighestIndex();
|
2118
2113
|
const newItems = Array.from(value2 || []).map((item, idx) => {
|
@@ -2131,14 +2126,15 @@ var ArrayField = ({
|
|
2131
2126
|
},
|
2132
2127
|
[arrayState]
|
2133
2128
|
);
|
2134
|
-
(0,
|
2129
|
+
(0, import_react12.useEffect)(() => {
|
2135
2130
|
if (arrayState.items.length > 0) {
|
2136
2131
|
setUi(mapArrayStateToUi(arrayState));
|
2137
2132
|
}
|
2138
2133
|
}, []);
|
2139
|
-
const [
|
2140
|
-
const
|
2134
|
+
const [draggedItem, setDraggedItem] = (0, import_react12.useState)("");
|
2135
|
+
const isDragging = !!draggedItem;
|
2141
2136
|
const forceReadOnly = getPermissions({ item: selectedItem }).edit === false;
|
2137
|
+
const valueRef = (0, import_react12.useRef)(value);
|
2142
2138
|
if (field.type !== "array" || !field.arrayFields) {
|
2143
2139
|
return null;
|
2144
2140
|
}
|
@@ -2153,11 +2149,17 @@ var ArrayField = ({
|
|
2153
2149
|
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
2154
2150
|
SortableProvider,
|
2155
2151
|
{
|
2156
|
-
|
2157
|
-
|
2158
|
-
|
2152
|
+
onDragStart: (id2) => setDraggedItem(id2),
|
2153
|
+
onDragEnd: () => {
|
2154
|
+
setDraggedItem("");
|
2155
|
+
onChange(valueRef.current);
|
2156
|
+
},
|
2159
2157
|
onMove: (move) => {
|
2160
|
-
|
2158
|
+
var _a;
|
2159
|
+
if (((_a = arrayState.items[move.source]) == null ? void 0 : _a._arrayId) !== draggedItem) {
|
2160
|
+
return;
|
2161
|
+
}
|
2162
|
+
const newValue = reorder(localState.value, move.source, move.target);
|
2161
2163
|
const newArrayStateItems = reorder(
|
2162
2164
|
arrayState.items,
|
2163
2165
|
move.source,
|
@@ -2169,11 +2171,11 @@ var ArrayField = ({
|
|
2169
2171
|
})
|
2170
2172
|
};
|
2171
2173
|
setUi(newUi, false);
|
2172
|
-
onChange(newValue, newUi);
|
2173
2174
|
setLocalState({
|
2174
2175
|
value: newValue,
|
2175
2176
|
arrayState: __spreadProps(__spreadValues({}, arrayState), { items: newArrayStateItems })
|
2176
2177
|
});
|
2178
|
+
valueRef.current = newValue;
|
2177
2179
|
},
|
2178
2180
|
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
2179
2181
|
"div",
|
@@ -2183,164 +2185,154 @@ var ArrayField = ({
|
|
2183
2185
|
addDisabled
|
2184
2186
|
}),
|
2185
2187
|
children: [
|
2186
|
-
localState.arrayState.items.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
2187
|
-
|
2188
|
-
{
|
2189
|
-
|
2190
|
-
|
2191
|
-
|
2192
|
-
|
2193
|
-
|
2194
|
-
|
2195
|
-
|
2196
|
-
|
2188
|
+
localState.arrayState.items.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: getClassName5("inner"), "data-dnd-container": true, children: localState.arrayState.items.map((item, i) => {
|
2189
|
+
const { _arrayId = `${id}-${i}`, _originalIndex = i } = item;
|
2190
|
+
const data = Array.from(localState.value || [])[i] || {};
|
2191
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
2192
|
+
Sortable,
|
2193
|
+
{
|
2194
|
+
id: _arrayId,
|
2195
|
+
index: i,
|
2196
|
+
disabled: readOnly,
|
2197
|
+
children: ({ status, ref, handleRef }) => /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
2198
|
+
"div",
|
2197
2199
|
{
|
2198
|
-
|
2199
|
-
|
2200
|
-
|
2201
|
-
|
2202
|
-
|
2203
|
-
|
2204
|
-
|
2205
|
-
|
2206
|
-
|
2207
|
-
|
2208
|
-
|
2209
|
-
|
2210
|
-
|
2211
|
-
|
2212
|
-
|
2213
|
-
{
|
2214
|
-
|
2215
|
-
|
2216
|
-
|
2217
|
-
|
2218
|
-
|
2219
|
-
|
2220
|
-
|
2221
|
-
|
2222
|
-
|
2223
|
-
|
2224
|
-
|
2225
|
-
} else {
|
2226
|
-
setUi(
|
2227
|
-
mapArrayStateToUi({
|
2228
|
-
openId: _arrayId
|
2229
|
-
})
|
2230
|
-
);
|
2231
|
-
}
|
2232
|
-
},
|
2233
|
-
className: getClassNameItem("summary"),
|
2234
|
-
children: [
|
2235
|
-
field.getItemSummary ? field.getItemSummary(data, i) : `Item #${_originalIndex}`,
|
2236
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: getClassNameItem("rhs"), children: [
|
2237
|
-
!readOnly && /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: getClassNameItem("actions"), children: [
|
2238
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: getClassNameItem("action"), children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
2239
|
-
IconButton,
|
2240
|
-
{
|
2241
|
-
type: "button",
|
2242
|
-
disabled: !!addDisabled,
|
2243
|
-
onClick: (e) => {
|
2244
|
-
e.stopPropagation();
|
2245
|
-
const existingValue = [...value || []];
|
2246
|
-
existingValue.splice(
|
2247
|
-
i,
|
2248
|
-
0,
|
2249
|
-
existingValue[i]
|
2250
|
-
);
|
2251
|
-
onChange(
|
2252
|
-
existingValue,
|
2253
|
-
mapArrayStateToUi(
|
2254
|
-
regenerateArrayState(existingValue)
|
2255
|
-
)
|
2256
|
-
);
|
2257
|
-
},
|
2258
|
-
title: "Duplicate",
|
2259
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Copy, { size: 16 })
|
2260
|
-
}
|
2261
|
-
) }),
|
2262
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: getClassNameItem("action"), children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
2263
|
-
IconButton,
|
2264
|
-
{
|
2265
|
-
type: "button",
|
2266
|
-
disabled: field.min !== void 0 && field.min >= localState.arrayState.items.length,
|
2267
|
-
onClick: (e) => {
|
2268
|
-
e.stopPropagation();
|
2269
|
-
const existingValue = [...value || []];
|
2270
|
-
const existingItems = [
|
2271
|
-
...arrayState.items || []
|
2272
|
-
];
|
2273
|
-
existingValue.splice(i, 1);
|
2274
|
-
existingItems.splice(i, 1);
|
2275
|
-
onChange(
|
2276
|
-
existingValue,
|
2277
|
-
mapArrayStateToUi({
|
2278
|
-
items: existingItems
|
2279
|
-
})
|
2280
|
-
);
|
2281
|
-
},
|
2282
|
-
title: "Delete",
|
2283
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Trash, { size: 16 })
|
2284
|
-
}
|
2285
|
-
) })
|
2286
|
-
] }),
|
2287
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(DragIcon, {}) })
|
2288
|
-
] })
|
2289
|
-
]
|
2200
|
+
ref,
|
2201
|
+
className: getClassNameItem({
|
2202
|
+
isExpanded: arrayState.openId === _arrayId,
|
2203
|
+
isDragging: status === "dragging",
|
2204
|
+
readOnly
|
2205
|
+
}),
|
2206
|
+
children: [
|
2207
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
2208
|
+
"div",
|
2209
|
+
{
|
2210
|
+
ref: handleRef,
|
2211
|
+
onClick: (e) => {
|
2212
|
+
if (isDragging) return;
|
2213
|
+
e.preventDefault();
|
2214
|
+
e.stopPropagation();
|
2215
|
+
if (arrayState.openId === _arrayId) {
|
2216
|
+
setUi(
|
2217
|
+
mapArrayStateToUi({
|
2218
|
+
openId: ""
|
2219
|
+
})
|
2220
|
+
);
|
2221
|
+
} else {
|
2222
|
+
setUi(
|
2223
|
+
mapArrayStateToUi({
|
2224
|
+
openId: _arrayId
|
2225
|
+
})
|
2226
|
+
);
|
2290
2227
|
}
|
2291
|
-
|
2292
|
-
|
2293
|
-
|
2294
|
-
|
2295
|
-
|
2296
|
-
|
2297
|
-
|
2298
|
-
|
2299
|
-
const localWildcardSubPath = `${localWildcardName}.${subName}`;
|
2300
|
-
const subReadOnly = forceReadOnly ? forceReadOnly : typeof readOnlyFields[subPath] !== "undefined" ? readOnlyFields[localSubPath] : readOnlyFields[localWildcardSubPath];
|
2301
|
-
const label2 = subField.label || subName;
|
2302
|
-
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
2303
|
-
NestedFieldProvider,
|
2304
|
-
{
|
2305
|
-
name: localIndexName,
|
2306
|
-
wildcardName: localWildcardName,
|
2307
|
-
subName,
|
2308
|
-
readOnlyFields,
|
2309
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
2310
|
-
AutoFieldPrivate,
|
2228
|
+
},
|
2229
|
+
className: getClassNameItem("summary"),
|
2230
|
+
children: [
|
2231
|
+
field.getItemSummary ? field.getItemSummary(data, i) : `Item #${_originalIndex}`,
|
2232
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: getClassNameItem("rhs"), children: [
|
2233
|
+
!readOnly && /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: getClassNameItem("actions"), children: [
|
2234
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: getClassNameItem("action"), children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
2235
|
+
IconButton,
|
2311
2236
|
{
|
2312
|
-
|
2313
|
-
|
2314
|
-
|
2315
|
-
|
2316
|
-
|
2317
|
-
|
2318
|
-
|
2319
|
-
|
2320
|
-
|
2321
|
-
onChange: (val, ui) => {
|
2322
|
-
onChange(
|
2323
|
-
replace(value, i, __spreadProps(__spreadValues({}, data), {
|
2324
|
-
[subName]: val
|
2325
|
-
})),
|
2326
|
-
ui
|
2237
|
+
type: "button",
|
2238
|
+
disabled: !!addDisabled,
|
2239
|
+
onClick: (e) => {
|
2240
|
+
e.stopPropagation();
|
2241
|
+
const existingValue = [...value || []];
|
2242
|
+
existingValue.splice(
|
2243
|
+
i,
|
2244
|
+
0,
|
2245
|
+
existingValue[i]
|
2327
2246
|
);
|
2328
|
-
|
2247
|
+
const newUi = mapArrayStateToUi(
|
2248
|
+
regenerateArrayState(existingValue)
|
2249
|
+
);
|
2250
|
+
setUi(newUi, false);
|
2251
|
+
onChange(existingValue, newUi);
|
2252
|
+
},
|
2253
|
+
title: "Duplicate",
|
2254
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Copy, { size: 16 })
|
2329
2255
|
}
|
2330
|
-
)
|
2331
|
-
|
2332
|
-
|
2333
|
-
|
2334
|
-
|
2335
|
-
|
2336
|
-
|
2337
|
-
|
2338
|
-
|
2339
|
-
|
2340
|
-
|
2341
|
-
|
2342
|
-
|
2343
|
-
|
2256
|
+
) }),
|
2257
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: getClassNameItem("action"), children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
2258
|
+
IconButton,
|
2259
|
+
{
|
2260
|
+
type: "button",
|
2261
|
+
disabled: field.min !== void 0 && field.min >= localState.arrayState.items.length,
|
2262
|
+
onClick: (e) => {
|
2263
|
+
e.stopPropagation();
|
2264
|
+
const existingValue = [...value || []];
|
2265
|
+
const existingItems = [
|
2266
|
+
...arrayState.items || []
|
2267
|
+
];
|
2268
|
+
existingValue.splice(i, 1);
|
2269
|
+
existingItems.splice(i, 1);
|
2270
|
+
const newUi = mapArrayStateToUi({
|
2271
|
+
items: existingItems
|
2272
|
+
});
|
2273
|
+
setUi(newUi, false);
|
2274
|
+
onChange(existingValue, newUi);
|
2275
|
+
},
|
2276
|
+
title: "Delete",
|
2277
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Trash, { size: 16 })
|
2278
|
+
}
|
2279
|
+
) })
|
2280
|
+
] }),
|
2281
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(DragIcon, {}) })
|
2282
|
+
] })
|
2283
|
+
]
|
2284
|
+
}
|
2285
|
+
),
|
2286
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: getClassNameItem("body"), children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("fieldset", { className: getClassNameItem("fieldset"), children: Object.keys(field.arrayFields).map((subName) => {
|
2287
|
+
const subField = field.arrayFields[subName];
|
2288
|
+
const indexName = `${name}[${i}]`;
|
2289
|
+
const subPath = `${indexName}.${subName}`;
|
2290
|
+
const localIndexName = `${localName}[${i}]`;
|
2291
|
+
const localWildcardName = `${localName}[*]`;
|
2292
|
+
const localSubPath = `${localIndexName}.${subName}`;
|
2293
|
+
const localWildcardSubPath = `${localWildcardName}.${subName}`;
|
2294
|
+
const subReadOnly = forceReadOnly ? forceReadOnly : typeof readOnlyFields[subPath] !== "undefined" ? readOnlyFields[localSubPath] : readOnlyFields[localWildcardSubPath];
|
2295
|
+
const label2 = subField.label || subName;
|
2296
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
2297
|
+
NestedFieldProvider,
|
2298
|
+
{
|
2299
|
+
name: localIndexName,
|
2300
|
+
wildcardName: localWildcardName,
|
2301
|
+
subName,
|
2302
|
+
readOnlyFields,
|
2303
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
2304
|
+
AutoFieldPrivate,
|
2305
|
+
{
|
2306
|
+
name: subPath,
|
2307
|
+
label: label2,
|
2308
|
+
id: `${_arrayId}_${subName}`,
|
2309
|
+
readOnly: subReadOnly,
|
2310
|
+
field: __spreadProps(__spreadValues({}, subField), {
|
2311
|
+
label: label2
|
2312
|
+
// May be used by custom fields
|
2313
|
+
}),
|
2314
|
+
value: data[subName],
|
2315
|
+
onChange: (val, ui) => {
|
2316
|
+
onChange(
|
2317
|
+
replace(value, i, __spreadProps(__spreadValues({}, data), {
|
2318
|
+
[subName]: val
|
2319
|
+
})),
|
2320
|
+
ui
|
2321
|
+
);
|
2322
|
+
}
|
2323
|
+
}
|
2324
|
+
)
|
2325
|
+
},
|
2326
|
+
subPath
|
2327
|
+
);
|
2328
|
+
}) }) })
|
2329
|
+
]
|
2330
|
+
}
|
2331
|
+
)
|
2332
|
+
},
|
2333
|
+
_arrayId
|
2334
|
+
);
|
2335
|
+
}) }),
|
2344
2336
|
!addDisabled && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
2345
2337
|
"button",
|
2346
2338
|
{
|
@@ -2354,7 +2346,9 @@ var ArrayField = ({
|
|
2354
2346
|
field.defaultItemProps || {}
|
2355
2347
|
];
|
2356
2348
|
const newArrayState = regenerateArrayState(newValue);
|
2357
|
-
|
2349
|
+
const newUi = mapArrayStateToUi(newArrayState);
|
2350
|
+
setUi(newUi, false);
|
2351
|
+
onChange(newValue, newUi);
|
2358
2352
|
},
|
2359
2353
|
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Plus, { size: 21 })
|
2360
2354
|
}
|
@@ -2428,11 +2422,11 @@ var DefaultField = ({
|
|
2428
2422
|
|
2429
2423
|
// components/AutoField/fields/ExternalField/index.tsx
|
2430
2424
|
init_react_import();
|
2431
|
-
var
|
2425
|
+
var import_react16 = require("react");
|
2432
2426
|
|
2433
2427
|
// components/ExternalInput/index.tsx
|
2434
2428
|
init_react_import();
|
2435
|
-
var
|
2429
|
+
var import_react15 = require("react");
|
2436
2430
|
|
2437
2431
|
// css-module:/home/runner/work/puck/puck/packages/core/components/ExternalInput/styles.module.css#css-module
|
2438
2432
|
init_react_import();
|
@@ -2440,7 +2434,7 @@ var styles_module_default6 = { "ExternalInput-actions": "_ExternalInput-actions_
|
|
2440
2434
|
|
2441
2435
|
// components/Modal/index.tsx
|
2442
2436
|
init_react_import();
|
2443
|
-
var
|
2437
|
+
var import_react13 = require("react");
|
2444
2438
|
|
2445
2439
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Modal/styles.module.css#css-module
|
2446
2440
|
init_react_import();
|
@@ -2455,8 +2449,8 @@ var Modal = ({
|
|
2455
2449
|
onClose,
|
2456
2450
|
isOpen
|
2457
2451
|
}) => {
|
2458
|
-
const [rootEl, setRootEl] = (0,
|
2459
|
-
(0,
|
2452
|
+
const [rootEl, setRootEl] = (0, import_react13.useState)(null);
|
2453
|
+
(0, import_react13.useEffect)(() => {
|
2460
2454
|
setRootEl(document.getElementById("puck-portal-root"));
|
2461
2455
|
}, []);
|
2462
2456
|
if (!rootEl) {
|
@@ -2503,7 +2497,7 @@ init_react_import();
|
|
2503
2497
|
|
2504
2498
|
// components/Button/Button.tsx
|
2505
2499
|
init_react_import();
|
2506
|
-
var
|
2500
|
+
var import_react14 = require("react");
|
2507
2501
|
|
2508
2502
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Button/Button.module.css#css-module
|
2509
2503
|
init_react_import();
|
@@ -2553,8 +2547,8 @@ var Button = (_a) => {
|
|
2553
2547
|
"size",
|
2554
2548
|
"loading"
|
2555
2549
|
]);
|
2556
|
-
const [loading, setLoading] = (0,
|
2557
|
-
(0,
|
2550
|
+
const [loading, setLoading] = (0, import_react14.useState)(loadingProp);
|
2551
|
+
(0, import_react14.useEffect)(() => setLoading(loadingProp), [loadingProp]);
|
2558
2552
|
const ElementType = href ? "a" : type ? "button" : "span";
|
2559
2553
|
const dataAttrs = filterDataAttrs(props);
|
2560
2554
|
const el = /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
@@ -2609,28 +2603,28 @@ var ExternalInput = ({
|
|
2609
2603
|
mapRow = (val) => val,
|
2610
2604
|
filterFields
|
2611
2605
|
} = field || {};
|
2612
|
-
const [data, setData] = (0,
|
2613
|
-
const [isOpen, setOpen] = (0,
|
2614
|
-
const [isLoading, setIsLoading] = (0,
|
2606
|
+
const [data, setData] = (0, import_react15.useState)([]);
|
2607
|
+
const [isOpen, setOpen] = (0, import_react15.useState)(false);
|
2608
|
+
const [isLoading, setIsLoading] = (0, import_react15.useState)(true);
|
2615
2609
|
const hasFilterFields = !!filterFields;
|
2616
|
-
const [filters, setFilters] = (0,
|
2617
|
-
const [filtersToggled, setFiltersToggled] = (0,
|
2618
|
-
const mappedData = (0,
|
2610
|
+
const [filters, setFilters] = (0, import_react15.useState)(field.initialFilters || {});
|
2611
|
+
const [filtersToggled, setFiltersToggled] = (0, import_react15.useState)(hasFilterFields);
|
2612
|
+
const mappedData = (0, import_react15.useMemo)(() => {
|
2619
2613
|
return data.map(mapRow);
|
2620
2614
|
}, [data]);
|
2621
|
-
const keys = (0,
|
2615
|
+
const keys = (0, import_react15.useMemo)(() => {
|
2622
2616
|
const validKeys = /* @__PURE__ */ new Set();
|
2623
2617
|
for (const item of mappedData) {
|
2624
2618
|
for (const key of Object.keys(item)) {
|
2625
|
-
if (typeof item[key] === "string" || typeof item[key] === "number" || (0,
|
2619
|
+
if (typeof item[key] === "string" || typeof item[key] === "number" || (0, import_react15.isValidElement)(item[key])) {
|
2626
2620
|
validKeys.add(key);
|
2627
2621
|
}
|
2628
2622
|
}
|
2629
2623
|
}
|
2630
2624
|
return Array.from(validKeys);
|
2631
2625
|
}, [mappedData]);
|
2632
|
-
const [searchQuery, setSearchQuery] = (0,
|
2633
|
-
const search = (0,
|
2626
|
+
const [searchQuery, setSearchQuery] = (0, import_react15.useState)(field.initialQuery || "");
|
2627
|
+
const search = (0, import_react15.useCallback)(
|
2634
2628
|
(query, filters2) => __async(void 0, null, function* () {
|
2635
2629
|
setIsLoading(true);
|
2636
2630
|
const cacheKey = `${id}-${query}-${JSON.stringify(filters2)}`;
|
@@ -2643,7 +2637,7 @@ var ExternalInput = ({
|
|
2643
2637
|
}),
|
2644
2638
|
[id, field]
|
2645
2639
|
);
|
2646
|
-
const Footer = (0,
|
2640
|
+
const Footer = (0, import_react15.useCallback)(
|
2647
2641
|
(props) => field.renderFooter ? field.renderFooter(props) : /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("span", { className: getClassNameModal("footer"), children: [
|
2648
2642
|
props.items.length,
|
2649
2643
|
" result",
|
@@ -2651,7 +2645,7 @@ var ExternalInput = ({
|
|
2651
2645
|
] }),
|
2652
2646
|
[field.renderFooter]
|
2653
2647
|
);
|
2654
|
-
(0,
|
2648
|
+
(0, import_react15.useEffect)(() => {
|
2655
2649
|
search(searchQuery, filters);
|
2656
2650
|
}, []);
|
2657
2651
|
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
|
@@ -2822,7 +2816,7 @@ var ExternalField = ({
|
|
2822
2816
|
var _a, _b, _c;
|
2823
2817
|
const validField = field;
|
2824
2818
|
const deprecatedField = field;
|
2825
|
-
(0,
|
2819
|
+
(0, import_react16.useEffect)(() => {
|
2826
2820
|
if (deprecatedField.adaptor) {
|
2827
2821
|
console.error(
|
2828
2822
|
"Warning: The `adaptor` API is deprecated. Please use updated APIs on the `external` field instead. This will be a breaking change in a future release."
|
@@ -2857,7 +2851,7 @@ var ExternalField = ({
|
|
2857
2851
|
|
2858
2852
|
// components/AutoField/fields/RadioField/index.tsx
|
2859
2853
|
init_react_import();
|
2860
|
-
var
|
2854
|
+
var import_react17 = require("react");
|
2861
2855
|
|
2862
2856
|
// lib/safe-json-parse.ts
|
2863
2857
|
init_react_import();
|
@@ -2883,7 +2877,7 @@ var RadioField = ({
|
|
2883
2877
|
label,
|
2884
2878
|
Label: Label2
|
2885
2879
|
}) => {
|
2886
|
-
const flatOptions = (0,
|
2880
|
+
const flatOptions = (0, import_react17.useMemo)(
|
2887
2881
|
() => field.type === "radio" ? field.options.map(({ value: value2 }) => value2) : [],
|
2888
2882
|
[field]
|
2889
2883
|
);
|
@@ -2933,7 +2927,7 @@ var RadioField = ({
|
|
2933
2927
|
|
2934
2928
|
// components/AutoField/fields/SelectField/index.tsx
|
2935
2929
|
init_react_import();
|
2936
|
-
var
|
2930
|
+
var import_react18 = require("react");
|
2937
2931
|
var import_jsx_runtime16 = require("react/jsx-runtime");
|
2938
2932
|
var getClassName12 = get_class_name_factory_default("Input", styles_module_default2);
|
2939
2933
|
var SelectField = ({
|
@@ -2946,7 +2940,7 @@ var SelectField = ({
|
|
2946
2940
|
readOnly,
|
2947
2941
|
id
|
2948
2942
|
}) => {
|
2949
|
-
const flatOptions = (0,
|
2943
|
+
const flatOptions = (0, import_react18.useMemo)(
|
2950
2944
|
() => field.type === "select" ? field.options.map(({ value: value2 }) => value2) : [],
|
2951
2945
|
[field]
|
2952
2946
|
);
|
@@ -3098,7 +3092,7 @@ var ObjectField = ({
|
|
3098
3092
|
|
3099
3093
|
// lib/use-safe-id.ts
|
3100
3094
|
init_react_import();
|
3101
|
-
var
|
3095
|
+
var import_react19 = __toESM(require("react"));
|
3102
3096
|
|
3103
3097
|
// lib/generate-id.ts
|
3104
3098
|
init_react_import();
|
@@ -3107,10 +3101,10 @@ var generateId = (type) => type ? `${type}-${(0, import_uuid.v4)()}` : (0, impor
|
|
3107
3101
|
|
3108
3102
|
// lib/use-safe-id.ts
|
3109
3103
|
var useSafeId = () => {
|
3110
|
-
if (typeof
|
3111
|
-
return
|
3104
|
+
if (typeof import_react19.default.useId !== "undefined") {
|
3105
|
+
return import_react19.default.useId();
|
3112
3106
|
}
|
3113
|
-
const [id] = (0,
|
3107
|
+
const [id] = (0, import_react19.useState)(generateId());
|
3114
3108
|
return id;
|
3115
3109
|
};
|
3116
3110
|
|
@@ -3144,7 +3138,7 @@ var FieldLabelInternal = ({
|
|
3144
3138
|
readOnly
|
3145
3139
|
}) => {
|
3146
3140
|
const { overrides } = useAppContext();
|
3147
|
-
const Wrapper = (0,
|
3141
|
+
const Wrapper = (0, import_react20.useMemo)(
|
3148
3142
|
() => overrides.fieldLabel || FieldLabel,
|
3149
3143
|
[overrides]
|
3150
3144
|
);
|
@@ -3166,7 +3160,7 @@ var FieldLabelInternal = ({
|
|
3166
3160
|
function AutoFieldInternal(props) {
|
3167
3161
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
3168
3162
|
const { dispatch, overrides, selectedItem } = useAppContext();
|
3169
|
-
const nestedFieldContext = (0,
|
3163
|
+
const nestedFieldContext = (0, import_react20.useContext)(NestedFieldContext);
|
3170
3164
|
const { id, Label: Label2 = FieldLabelInternal } = props;
|
3171
3165
|
const field = props.field;
|
3172
3166
|
const label = field.label;
|
@@ -3198,7 +3192,7 @@ function AutoFieldInternal(props) {
|
|
3198
3192
|
Label: Label2,
|
3199
3193
|
id: resolvedId
|
3200
3194
|
});
|
3201
|
-
const onFocus = (0,
|
3195
|
+
const onFocus = (0, import_react20.useCallback)(
|
3202
3196
|
(e) => {
|
3203
3197
|
if (mergedProps.name && (e.target.nodeName === "INPUT" || e.target.nodeName === "TEXTAREA")) {
|
3204
3198
|
e.stopPropagation();
|
@@ -3212,7 +3206,7 @@ function AutoFieldInternal(props) {
|
|
3212
3206
|
},
|
3213
3207
|
[mergedProps.name]
|
3214
3208
|
);
|
3215
|
-
const onBlur = (0,
|
3209
|
+
const onBlur = (0, import_react20.useCallback)((e) => {
|
3216
3210
|
if ("name" in e.target) {
|
3217
3211
|
dispatch({
|
3218
3212
|
type: "setUi",
|
@@ -3256,7 +3250,7 @@ function AutoFieldInternal(props) {
|
|
3256
3250
|
function AutoFieldPrivate(props) {
|
3257
3251
|
const { state } = useAppContext();
|
3258
3252
|
const { value, onChange } = props;
|
3259
|
-
const [localValue, setLocalValue] = (0,
|
3253
|
+
const [localValue, setLocalValue] = (0, import_react20.useState)(value);
|
3260
3254
|
const onChangeDb = (0, import_use_debounce.useDebouncedCallback)(
|
3261
3255
|
(val, ui) => {
|
3262
3256
|
onChange(val, ui);
|
@@ -3264,14 +3258,14 @@ function AutoFieldPrivate(props) {
|
|
3264
3258
|
50,
|
3265
3259
|
{ leading: true }
|
3266
3260
|
);
|
3267
|
-
const onChangeLocal = (0,
|
3261
|
+
const onChangeLocal = (0, import_react20.useCallback)(
|
3268
3262
|
(val, ui) => {
|
3269
3263
|
setLocalValue(val);
|
3270
3264
|
onChangeDb(val, ui);
|
3271
3265
|
},
|
3272
3266
|
[onChange]
|
3273
3267
|
);
|
3274
|
-
(0,
|
3268
|
+
(0, import_react20.useEffect)(() => {
|
3275
3269
|
if (state.ui.field.focus !== props.name) {
|
3276
3270
|
setLocalValue(value);
|
3277
3271
|
}
|
@@ -3283,7 +3277,7 @@ function AutoFieldPrivate(props) {
|
|
3283
3277
|
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(AutoFieldInternal, __spreadValues(__spreadValues({}, props), localProps));
|
3284
3278
|
}
|
3285
3279
|
function AutoField(props) {
|
3286
|
-
const DefaultLabel = (0,
|
3280
|
+
const DefaultLabel = (0, import_react20.useMemo)(() => {
|
3287
3281
|
const DefaultLabel2 = (labelProps) => /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
3288
3282
|
"div",
|
3289
3283
|
__spreadProps(__spreadValues({}, labelProps), {
|
@@ -3303,21 +3297,21 @@ init_react_import();
|
|
3303
3297
|
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" };
|
3304
3298
|
|
3305
3299
|
// components/Drawer/index.tsx
|
3306
|
-
var
|
3300
|
+
var import_react32 = require("react");
|
3307
3301
|
|
3308
3302
|
// components/DragDropContext/index.tsx
|
3309
3303
|
init_react_import();
|
3310
|
-
var
|
3311
|
-
var
|
3304
|
+
var import_react30 = require("@dnd-kit/react");
|
3305
|
+
var import_react31 = require("react");
|
3312
3306
|
var import_dom = require("@dnd-kit/dom");
|
3313
3307
|
|
3314
3308
|
// components/DropZone/index.tsx
|
3315
3309
|
init_react_import();
|
3316
|
-
var
|
3310
|
+
var import_react29 = require("react");
|
3317
3311
|
|
3318
3312
|
// components/DraggableComponent/index.tsx
|
3319
3313
|
init_react_import();
|
3320
|
-
var
|
3314
|
+
var import_react23 = require("react");
|
3321
3315
|
|
3322
3316
|
// css-module:/home/runner/work/puck/puck/packages/core/components/DraggableComponent/styles.module.css#css-module
|
3323
3317
|
init_react_import();
|
@@ -3347,11 +3341,11 @@ function getDeepScrollPosition(element) {
|
|
3347
3341
|
|
3348
3342
|
// components/DropZone/context.tsx
|
3349
3343
|
init_react_import();
|
3350
|
-
var
|
3344
|
+
var import_react21 = require("react");
|
3351
3345
|
var import_zustand = require("zustand");
|
3352
3346
|
var import_jsx_runtime20 = require("react/jsx-runtime");
|
3353
|
-
var dropZoneContext = (0,
|
3354
|
-
var ZoneStoreContext = (0,
|
3347
|
+
var dropZoneContext = (0, import_react21.createContext)(null);
|
3348
|
+
var ZoneStoreContext = (0, import_react21.createContext)(
|
3355
3349
|
(0, import_zustand.createStore)(() => ({
|
3356
3350
|
zoneDepthIndex: {},
|
3357
3351
|
nextZoneDepthIndex: {},
|
@@ -3371,19 +3365,19 @@ var DropZoneProvider = ({
|
|
3371
3365
|
children,
|
3372
3366
|
value
|
3373
3367
|
}) => {
|
3374
|
-
const [hoveringComponent, setHoveringComponent] = (0,
|
3375
|
-
const [areasWithZones, setAreasWithZones] = (0,
|
3368
|
+
const [hoveringComponent, setHoveringComponent] = (0, import_react21.useState)();
|
3369
|
+
const [areasWithZones, setAreasWithZones] = (0, import_react21.useState)(
|
3376
3370
|
{}
|
3377
3371
|
);
|
3378
|
-
const [activeZones, setActiveZones] = (0,
|
3372
|
+
const [activeZones, setActiveZones] = (0, import_react21.useState)({});
|
3379
3373
|
const { dispatch } = useAppContext();
|
3380
|
-
const registerZoneArea = (0,
|
3374
|
+
const registerZoneArea = (0, import_react21.useCallback)(
|
3381
3375
|
(area) => {
|
3382
3376
|
setAreasWithZones((latest) => __spreadProps(__spreadValues({}, latest), { [area]: true }));
|
3383
3377
|
},
|
3384
3378
|
[setAreasWithZones]
|
3385
3379
|
);
|
3386
|
-
const registerZone = (0,
|
3380
|
+
const registerZone = (0, import_react21.useCallback)(
|
3387
3381
|
(zoneCompound) => {
|
3388
3382
|
if (!dispatch) {
|
3389
3383
|
return;
|
@@ -3396,7 +3390,7 @@ var DropZoneProvider = ({
|
|
3396
3390
|
},
|
3397
3391
|
[setActiveZones, dispatch]
|
3398
3392
|
);
|
3399
|
-
const unregisterZone = (0,
|
3393
|
+
const unregisterZone = (0, import_react21.useCallback)(
|
3400
3394
|
(zoneCompound) => {
|
3401
3395
|
if (!dispatch) {
|
3402
3396
|
return;
|
@@ -3411,7 +3405,7 @@ var DropZoneProvider = ({
|
|
3411
3405
|
},
|
3412
3406
|
[setActiveZones, dispatch]
|
3413
3407
|
);
|
3414
|
-
const memoValue = (0,
|
3408
|
+
const memoValue = (0, import_react21.useMemo)(
|
3415
3409
|
() => __spreadValues({
|
3416
3410
|
hoveringComponent,
|
3417
3411
|
setHoveringComponent,
|
@@ -3428,11 +3422,11 @@ var DropZoneProvider = ({
|
|
3428
3422
|
|
3429
3423
|
// lib/use-context-store.ts
|
3430
3424
|
init_react_import();
|
3431
|
-
var
|
3425
|
+
var import_react22 = require("react");
|
3432
3426
|
var import_zustand2 = require("zustand");
|
3433
3427
|
var import_shallow = require("zustand/react/shallow");
|
3434
3428
|
function useContextStore(context, selector) {
|
3435
|
-
const store = (0,
|
3429
|
+
const store = (0, import_react22.useContext)(context);
|
3436
3430
|
if (!store) {
|
3437
3431
|
throw new Error("useContextStore must be used inside context");
|
3438
3432
|
}
|
@@ -3491,9 +3485,9 @@ var DraggableComponent = ({
|
|
3491
3485
|
iframe,
|
3492
3486
|
state
|
3493
3487
|
} = useAppContext();
|
3494
|
-
const ctx = (0,
|
3495
|
-
const [localZones, setLocalZones] = (0,
|
3496
|
-
const registerLocalZone = (0,
|
3488
|
+
const ctx = (0, import_react23.useContext)(dropZoneContext);
|
3489
|
+
const [localZones, setLocalZones] = (0, import_react23.useState)({});
|
3490
|
+
const registerLocalZone = (0, import_react23.useCallback)(
|
3497
3491
|
(zoneCompound2, active) => {
|
3498
3492
|
var _a;
|
3499
3493
|
(_a = ctx == null ? void 0 : ctx.registerLocalZone) == null ? void 0 : _a.call(ctx, zoneCompound2, active);
|
@@ -3503,7 +3497,7 @@ var DraggableComponent = ({
|
|
3503
3497
|
},
|
3504
3498
|
[setLocalZones]
|
3505
3499
|
);
|
3506
|
-
const unregisterLocalZone = (0,
|
3500
|
+
const unregisterLocalZone = (0, import_react23.useCallback)(
|
3507
3501
|
(zoneCompound2) => {
|
3508
3502
|
var _a;
|
3509
3503
|
(_a = ctx == null ? void 0 : ctx.unregisterLocalZone) == null ? void 0 : _a.call(ctx, zoneCompound2);
|
@@ -3517,8 +3511,8 @@ var DraggableComponent = ({
|
|
3517
3511
|
);
|
3518
3512
|
const containsActiveZone = Object.values(localZones).filter(Boolean).length > 0;
|
3519
3513
|
const { path = [] } = ctx || {};
|
3520
|
-
const [canDrag, setCanDrag] = (0,
|
3521
|
-
(0,
|
3514
|
+
const [canDrag, setCanDrag] = (0, import_react23.useState)(false);
|
3515
|
+
(0, import_react23.useEffect)(() => {
|
3522
3516
|
var _a;
|
3523
3517
|
const item = getItem({ index, zone: zoneCompound }, state.data);
|
3524
3518
|
if (item) {
|
@@ -3534,7 +3528,7 @@ var DraggableComponent = ({
|
|
3534
3528
|
);
|
3535
3529
|
const canCollide = canDrag || userIsDragging;
|
3536
3530
|
const disabled = !isEnabled || !canCollide;
|
3537
|
-
const [dragAxis, setDragAxis] = (0,
|
3531
|
+
const [dragAxis, setDragAxis] = (0, import_react23.useState)(userDragAxis || autoDragAxis);
|
3538
3532
|
const { ref: sortableRef, status } = useSortableSafe({
|
3539
3533
|
id,
|
3540
3534
|
index,
|
@@ -3560,8 +3554,8 @@ var DraggableComponent = ({
|
|
3560
3554
|
}
|
3561
3555
|
});
|
3562
3556
|
const thisIsDragging = status === "dragging";
|
3563
|
-
const ref = (0,
|
3564
|
-
const refSetter = (0,
|
3557
|
+
const ref = (0, import_react23.useRef)(null);
|
3558
|
+
const refSetter = (0, import_react23.useCallback)(
|
3565
3559
|
(el) => {
|
3566
3560
|
sortableRef(el);
|
3567
3561
|
if (el) {
|
@@ -3570,14 +3564,14 @@ var DraggableComponent = ({
|
|
3570
3564
|
},
|
3571
3565
|
[sortableRef]
|
3572
3566
|
);
|
3573
|
-
const [portalEl, setPortalEl] = (0,
|
3574
|
-
(0,
|
3567
|
+
const [portalEl, setPortalEl] = (0, import_react23.useState)();
|
3568
|
+
(0, import_react23.useEffect)(() => {
|
3575
3569
|
var _a, _b, _c;
|
3576
3570
|
setPortalEl(
|
3577
3571
|
iframe.enabled ? (_a = ref.current) == null ? void 0 : _a.ownerDocument.body : (_c = (_b = ref.current) == null ? void 0 : _b.closest("[data-puck-preview]")) != null ? _c : document.body
|
3578
3572
|
);
|
3579
3573
|
}, [iframe.enabled, ref.current]);
|
3580
|
-
const getStyle = (0,
|
3574
|
+
const getStyle = (0, import_react23.useCallback)(() => {
|
3581
3575
|
var _a, _b, _c;
|
3582
3576
|
if (!ref.current) return;
|
3583
3577
|
const rect = ref.current.getBoundingClientRect();
|
@@ -3597,11 +3591,11 @@ var DraggableComponent = ({
|
|
3597
3591
|
};
|
3598
3592
|
return style2;
|
3599
3593
|
}, [ref.current]);
|
3600
|
-
const [style, setStyle] = (0,
|
3601
|
-
const sync = (0,
|
3594
|
+
const [style, setStyle] = (0, import_react23.useState)();
|
3595
|
+
const sync = (0, import_react23.useCallback)(() => {
|
3602
3596
|
setStyle(getStyle());
|
3603
3597
|
}, [ref.current, iframe]);
|
3604
|
-
(0,
|
3598
|
+
(0, import_react23.useEffect)(() => {
|
3605
3599
|
if (ref.current && !userIsDragging) {
|
3606
3600
|
const observer = new ResizeObserver(sync);
|
3607
3601
|
observer.observe(ref.current);
|
@@ -3610,7 +3604,7 @@ var DraggableComponent = ({
|
|
3610
3604
|
};
|
3611
3605
|
}
|
3612
3606
|
}, [ref.current, userIsDragging]);
|
3613
|
-
(0,
|
3607
|
+
(0, import_react23.useEffect)(() => {
|
3614
3608
|
ctx == null ? void 0 : ctx.registerPath(
|
3615
3609
|
id,
|
3616
3610
|
{
|
@@ -3624,14 +3618,14 @@ var DraggableComponent = ({
|
|
3624
3618
|
(_a = ctx == null ? void 0 : ctx.unregisterPath) == null ? void 0 : _a.call(ctx, id);
|
3625
3619
|
};
|
3626
3620
|
}, [id, zoneCompound, index, componentType]);
|
3627
|
-
const CustomActionBar = (0,
|
3621
|
+
const CustomActionBar = (0, import_react23.useMemo)(
|
3628
3622
|
() => overrides.actionBar || DefaultActionBar,
|
3629
3623
|
[overrides.actionBar]
|
3630
3624
|
);
|
3631
3625
|
const permissions = getPermissions({
|
3632
3626
|
item: selectedItem
|
3633
3627
|
});
|
3634
|
-
const onClick = (0,
|
3628
|
+
const onClick = (0, import_react23.useCallback)(
|
3635
3629
|
(e) => {
|
3636
3630
|
e.stopPropagation();
|
3637
3631
|
dispatch({
|
@@ -3643,7 +3637,7 @@ var DraggableComponent = ({
|
|
3643
3637
|
},
|
3644
3638
|
[index, zoneCompound, id]
|
3645
3639
|
);
|
3646
|
-
const onSelectParent = (0,
|
3640
|
+
const onSelectParent = (0, import_react23.useCallback)(() => {
|
3647
3641
|
if (!(ctx == null ? void 0 : ctx.areaId)) {
|
3648
3642
|
return;
|
3649
3643
|
}
|
@@ -3661,23 +3655,23 @@ var DraggableComponent = ({
|
|
3661
3655
|
}
|
3662
3656
|
});
|
3663
3657
|
}, [ctx, path]);
|
3664
|
-
const onDuplicate = (0,
|
3658
|
+
const onDuplicate = (0, import_react23.useCallback)(() => {
|
3665
3659
|
dispatch({
|
3666
3660
|
type: "duplicate",
|
3667
3661
|
sourceIndex: index,
|
3668
3662
|
sourceZone: zoneCompound
|
3669
3663
|
});
|
3670
3664
|
}, [index, zoneCompound]);
|
3671
|
-
const onDelete = (0,
|
3665
|
+
const onDelete = (0, import_react23.useCallback)(() => {
|
3672
3666
|
dispatch({
|
3673
3667
|
type: "remove",
|
3674
3668
|
index,
|
3675
3669
|
zone: zoneCompound
|
3676
3670
|
});
|
3677
3671
|
}, [index, zoneCompound]);
|
3678
|
-
const [hover, setHover] = (0,
|
3672
|
+
const [hover, setHover] = (0, import_react23.useState)(false);
|
3679
3673
|
const indicativeHover = (ctx == null ? void 0 : ctx.hoveringComponent) === id;
|
3680
|
-
(0,
|
3674
|
+
(0, import_react23.useEffect)(() => {
|
3681
3675
|
if (!ref.current) {
|
3682
3676
|
return;
|
3683
3677
|
}
|
@@ -3727,7 +3721,7 @@ var DraggableComponent = ({
|
|
3727
3721
|
thisIsDragging,
|
3728
3722
|
inDroppableZone
|
3729
3723
|
]);
|
3730
|
-
(0,
|
3724
|
+
(0, import_react23.useEffect)(() => {
|
3731
3725
|
if (ref.current && disabled) {
|
3732
3726
|
ref.current.setAttribute("data-puck-disabled", "");
|
3733
3727
|
return () => {
|
@@ -3736,8 +3730,8 @@ var DraggableComponent = ({
|
|
3736
3730
|
};
|
3737
3731
|
}
|
3738
3732
|
}, [disabled, ref]);
|
3739
|
-
const [isVisible, setIsVisible] = (0,
|
3740
|
-
(0,
|
3733
|
+
const [isVisible, setIsVisible] = (0, import_react23.useState)(false);
|
3734
|
+
(0, import_react23.useEffect)(() => {
|
3741
3735
|
sync();
|
3742
3736
|
if ((isSelected || hover || indicativeHover) && !userIsDragging) {
|
3743
3737
|
setIsVisible(true);
|
@@ -3745,7 +3739,7 @@ var DraggableComponent = ({
|
|
3745
3739
|
setIsVisible(false);
|
3746
3740
|
}
|
3747
3741
|
}, [isSelected, hover, indicativeHover, iframe, state.data, userIsDragging]);
|
3748
|
-
const syncActionsPosition = (0,
|
3742
|
+
const syncActionsPosition = (0, import_react23.useCallback)(
|
3749
3743
|
(el) => {
|
3750
3744
|
if (el) {
|
3751
3745
|
const view = el.ownerDocument.defaultView;
|
@@ -3770,7 +3764,7 @@ var DraggableComponent = ({
|
|
3770
3764
|
},
|
3771
3765
|
[zoomConfig]
|
3772
3766
|
);
|
3773
|
-
(0,
|
3767
|
+
(0, import_react23.useEffect)(() => {
|
3774
3768
|
if (userDragAxis) {
|
3775
3769
|
setDragAxis(userDragAxis);
|
3776
3770
|
return;
|
@@ -3864,14 +3858,14 @@ var styles_module_default12 = { "DropZone": "_DropZone_kmkdc_1", "DropZone--isAc
|
|
3864
3858
|
|
3865
3859
|
// components/DropZone/lib/use-min-empty-height.ts
|
3866
3860
|
init_react_import();
|
3867
|
-
var
|
3861
|
+
var import_react24 = require("react");
|
3868
3862
|
var useMinEmptyHeight = ({
|
3869
3863
|
zoneCompound,
|
3870
3864
|
userMinEmptyHeight,
|
3871
3865
|
ref
|
3872
3866
|
}) => {
|
3873
|
-
const [prevHeight, setPrevHeight] = (0,
|
3874
|
-
const [isAnimating, setIsAnimating] = (0,
|
3867
|
+
const [prevHeight, setPrevHeight] = (0, import_react24.useState)(0);
|
3868
|
+
const [isAnimating, setIsAnimating] = (0, import_react24.useState)(false);
|
3875
3869
|
const { draggedItem, isZone } = useContextStore(ZoneStoreContext, (s) => {
|
3876
3870
|
var _a, _b;
|
3877
3871
|
return {
|
@@ -3879,7 +3873,7 @@ var useMinEmptyHeight = ({
|
|
3879
3873
|
isZone: ((_b = s.draggedItem) == null ? void 0 : _b.data.zone) === zoneCompound
|
3880
3874
|
};
|
3881
3875
|
});
|
3882
|
-
(0,
|
3876
|
+
(0, import_react24.useEffect)(() => {
|
3883
3877
|
if (draggedItem && ref.current) {
|
3884
3878
|
if (isZone) {
|
3885
3879
|
const rect = ref.current.getBoundingClientRect();
|
@@ -3913,15 +3907,15 @@ function assignRefs(refs, node) {
|
|
3913
3907
|
|
3914
3908
|
// components/DropZone/lib/use-content-with-preview.ts
|
3915
3909
|
init_react_import();
|
3916
|
-
var
|
3910
|
+
var import_react27 = require("react");
|
3917
3911
|
|
3918
3912
|
// lib/dnd/use-rendered-callback.ts
|
3919
3913
|
init_react_import();
|
3920
|
-
var
|
3921
|
-
var
|
3914
|
+
var import_react25 = require("@dnd-kit/react");
|
3915
|
+
var import_react26 = require("react");
|
3922
3916
|
function useRenderedCallback(callback, deps) {
|
3923
|
-
const manager = (0,
|
3924
|
-
return (0,
|
3917
|
+
const manager = (0, import_react25.useDragDropManager)();
|
3918
|
+
return (0, import_react26.useCallback)(
|
3925
3919
|
(...args) => __async(this, null, function* () {
|
3926
3920
|
yield manager == null ? void 0 : manager.renderer.rendering;
|
3927
3921
|
return callback(...args);
|
@@ -3956,8 +3950,8 @@ var useContentWithPreview = (content, zoneCompound) => {
|
|
3956
3950
|
ui: { isDragging }
|
3957
3951
|
}
|
3958
3952
|
} = useAppContext();
|
3959
|
-
const [contentWithPreview, setContentWithPreview] = (0,
|
3960
|
-
const [localPreview, setLocalPreview] = (0,
|
3953
|
+
const [contentWithPreview, setContentWithPreview] = (0, import_react27.useState)(content);
|
3954
|
+
const [localPreview, setLocalPreview] = (0, import_react27.useState)(
|
3961
3955
|
preview
|
3962
3956
|
);
|
3963
3957
|
const updateContent = useRenderedCallback(
|
@@ -3998,7 +3992,7 @@ var useContentWithPreview = (content, zoneCompound) => {
|
|
3998
3992
|
},
|
3999
3993
|
[draggedItemId, previewExists]
|
4000
3994
|
);
|
4001
|
-
(0,
|
3995
|
+
(0, import_react27.useEffect)(() => {
|
4002
3996
|
updateContent(content, preview, isDragging);
|
4003
3997
|
}, [content, preview, isDragging]);
|
4004
3998
|
return [contentWithPreview, localPreview];
|
@@ -4006,16 +4000,16 @@ var useContentWithPreview = (content, zoneCompound) => {
|
|
4006
4000
|
|
4007
4001
|
// components/DropZone/lib/use-drag-axis.ts
|
4008
4002
|
init_react_import();
|
4009
|
-
var
|
4003
|
+
var import_react28 = require("react");
|
4010
4004
|
var GRID_DRAG_AXIS = "dynamic";
|
4011
4005
|
var FLEX_ROW_DRAG_AXIS = "x";
|
4012
4006
|
var DEFAULT_DRAG_AXIS = "y";
|
4013
4007
|
var useDragAxis = (ref, collisionAxis) => {
|
4014
4008
|
const { status } = useAppContext();
|
4015
|
-
const [dragAxis, setDragAxis] = (0,
|
4009
|
+
const [dragAxis, setDragAxis] = (0, import_react28.useState)(
|
4016
4010
|
collisionAxis || DEFAULT_DRAG_AXIS
|
4017
4011
|
);
|
4018
|
-
const calculateDragAxis = (0,
|
4012
|
+
const calculateDragAxis = (0, import_react28.useCallback)(() => {
|
4019
4013
|
if (ref.current) {
|
4020
4014
|
const computedStyle = window.getComputedStyle(ref.current);
|
4021
4015
|
if (computedStyle.display === "grid") {
|
@@ -4027,7 +4021,7 @@ var useDragAxis = (ref, collisionAxis) => {
|
|
4027
4021
|
}
|
4028
4022
|
}
|
4029
4023
|
}, [ref.current]);
|
4030
|
-
(0,
|
4024
|
+
(0, import_react28.useEffect)(() => {
|
4031
4025
|
const onViewportChange = () => {
|
4032
4026
|
calculateDragAxis();
|
4033
4027
|
};
|
@@ -4036,7 +4030,7 @@ var useDragAxis = (ref, collisionAxis) => {
|
|
4036
4030
|
window.removeEventListener("viewportchange", onViewportChange);
|
4037
4031
|
};
|
4038
4032
|
}, []);
|
4039
|
-
(0,
|
4033
|
+
(0, import_react28.useEffect)(calculateDragAxis, [status, collisionAxis]);
|
4040
4034
|
return [dragAxis, calculateDragAxis];
|
4041
4035
|
};
|
4042
4036
|
|
@@ -4046,7 +4040,7 @@ var getClassName17 = get_class_name_factory_default("DropZone", styles_module_de
|
|
4046
4040
|
var getRandomColor = () => `#${Math.floor(Math.random() * 16777215).toString(16)}`;
|
4047
4041
|
var RENDER_DEBUG = false;
|
4048
4042
|
var DropZoneEditPure = (props) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(DropZoneEdit, __spreadValues({}, props));
|
4049
|
-
var DropZoneEdit = (0,
|
4043
|
+
var DropZoneEdit = (0, import_react29.forwardRef)(
|
4050
4044
|
function DropZoneEditInternal({
|
4051
4045
|
zone,
|
4052
4046
|
allow,
|
@@ -4057,7 +4051,7 @@ var DropZoneEdit = (0, import_react30.forwardRef)(
|
|
4057
4051
|
collisionAxis
|
4058
4052
|
}, userRef) {
|
4059
4053
|
const appContext2 = useAppContext();
|
4060
|
-
const ctx = (0,
|
4054
|
+
const ctx = (0, import_react29.useContext)(dropZoneContext);
|
4061
4055
|
const {
|
4062
4056
|
// These all need setting via context
|
4063
4057
|
data,
|
@@ -4093,12 +4087,12 @@ var DropZoneEdit = (0, import_react30.forwardRef)(
|
|
4093
4087
|
};
|
4094
4088
|
});
|
4095
4089
|
const { itemSelector } = appContext2.state.ui;
|
4096
|
-
(0,
|
4090
|
+
(0, import_react29.useEffect)(() => {
|
4097
4091
|
if (areaId && registerZoneArea) {
|
4098
4092
|
registerZoneArea(areaId);
|
4099
4093
|
}
|
4100
4094
|
}, [areaId]);
|
4101
|
-
(0,
|
4095
|
+
(0, import_react29.useEffect)(() => {
|
4102
4096
|
if (ctx == null ? void 0 : ctx.registerZone) {
|
4103
4097
|
ctx == null ? void 0 : ctx.registerZone(zoneCompound);
|
4104
4098
|
}
|
@@ -4108,14 +4102,14 @@ var DropZoneEdit = (0, import_react30.forwardRef)(
|
|
4108
4102
|
}
|
4109
4103
|
};
|
4110
4104
|
}, []);
|
4111
|
-
const content = (0,
|
4105
|
+
const content = (0, import_react29.useMemo)(() => {
|
4112
4106
|
if (areaId && zone !== rootDroppableId) {
|
4113
4107
|
return setupZone(data, zoneCompound).zones[zoneCompound];
|
4114
4108
|
}
|
4115
4109
|
return data.content || [];
|
4116
4110
|
}, [data, zoneCompound]);
|
4117
|
-
const ref = (0,
|
4118
|
-
const acceptsTarget = (0,
|
4111
|
+
const ref = (0, import_react29.useRef)(null);
|
4112
|
+
const acceptsTarget = (0, import_react29.useCallback)(
|
4119
4113
|
(componentType) => {
|
4120
4114
|
if (!componentType) {
|
4121
4115
|
return true;
|
@@ -4137,7 +4131,7 @@ var DropZoneEdit = (0, import_react30.forwardRef)(
|
|
4137
4131
|
},
|
4138
4132
|
[allow, disallow]
|
4139
4133
|
);
|
4140
|
-
(0,
|
4134
|
+
(0, import_react29.useEffect)(() => {
|
4141
4135
|
if (registerLocalZone) {
|
4142
4136
|
registerLocalZone(zoneCompound, acceptsTarget(draggedComponentType));
|
4143
4137
|
}
|
@@ -4272,13 +4266,13 @@ var DropZoneEdit = (0, import_react30.forwardRef)(
|
|
4272
4266
|
}
|
4273
4267
|
);
|
4274
4268
|
var DropZoneRenderPure = (props) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(DropZoneRender, __spreadValues({}, props));
|
4275
|
-
var DropZoneRender = (0,
|
4269
|
+
var DropZoneRender = (0, import_react29.forwardRef)(
|
4276
4270
|
function DropZoneRenderInternal({ className, style, zone }, ref) {
|
4277
|
-
const ctx = (0,
|
4271
|
+
const ctx = (0, import_react29.useContext)(dropZoneContext);
|
4278
4272
|
const { data, areaId = "root", config } = ctx || {};
|
4279
4273
|
let zoneCompound = rootDroppableId;
|
4280
4274
|
let content = (data == null ? void 0 : data.content) || [];
|
4281
|
-
(0,
|
4275
|
+
(0, import_react29.useEffect)(() => {
|
4282
4276
|
if (ctx == null ? void 0 : ctx.registerZone) {
|
4283
4277
|
ctx == null ? void 0 : ctx.registerZone(zoneCompound);
|
4284
4278
|
}
|
@@ -4325,9 +4319,9 @@ var DropZoneRender = (0, import_react30.forwardRef)(
|
|
4325
4319
|
}
|
4326
4320
|
);
|
4327
4321
|
var DropZonePure = (props) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(DropZone, __spreadValues({}, props));
|
4328
|
-
var DropZone = (0,
|
4322
|
+
var DropZone = (0, import_react29.forwardRef)(
|
4329
4323
|
function DropZone2(props, ref) {
|
4330
|
-
const ctx = (0,
|
4324
|
+
const ctx = (0, import_react29.useContext)(dropZoneContext);
|
4331
4325
|
if ((ctx == null ? void 0 : ctx.mode) === "edit") {
|
4332
4326
|
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_jsx_runtime22.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(DropZoneEdit, __spreadProps(__spreadValues({}, props), { ref })) });
|
4333
4327
|
}
|
@@ -5022,12 +5016,12 @@ function getDeepDir(el) {
|
|
5022
5016
|
// components/DragDropContext/index.tsx
|
5023
5017
|
var import_jsx_runtime23 = require("react/jsx-runtime");
|
5024
5018
|
var DEBUG3 = false;
|
5025
|
-
var dragListenerContext = (0,
|
5019
|
+
var dragListenerContext = (0, import_react31.createContext)({
|
5026
5020
|
dragListeners: {}
|
5027
5021
|
});
|
5028
5022
|
function useDragListener(type, fn, deps = []) {
|
5029
|
-
const { setDragListeners } = (0,
|
5030
|
-
(0,
|
5023
|
+
const { setDragListeners } = (0, import_react31.useContext)(dragListenerContext);
|
5024
|
+
(0, import_react31.useEffect)(() => {
|
5031
5025
|
if (setDragListeners) {
|
5032
5026
|
setDragListeners((old) => __spreadProps(__spreadValues({}, old), {
|
5033
5027
|
[type]: [...old[type] || [], fn]
|
@@ -5037,8 +5031,8 @@ function useDragListener(type, fn, deps = []) {
|
|
5037
5031
|
}
|
5038
5032
|
var AREA_CHANGE_DEBOUNCE_MS = 100;
|
5039
5033
|
var useTempDisableFallback = (timeout3) => {
|
5040
|
-
const lastFallbackDisable = (0,
|
5041
|
-
return (0,
|
5034
|
+
const lastFallbackDisable = (0, import_react31.useRef)(null);
|
5035
|
+
return (0, import_react31.useCallback)((manager) => {
|
5042
5036
|
collisionStore.setState({ fallbackEnabled: false });
|
5043
5037
|
const fallbackId = generateId();
|
5044
5038
|
lastFallbackDisable.current = fallbackId;
|
@@ -5055,11 +5049,11 @@ var DragDropContextClient = ({
|
|
5055
5049
|
disableAutoScroll
|
5056
5050
|
}) => {
|
5057
5051
|
const { state, config, dispatch, resolveData } = useAppContext();
|
5058
|
-
const id =
|
5052
|
+
const id = (0, import_react31.useId)();
|
5059
5053
|
const { data } = state;
|
5060
|
-
const debouncedParamsRef = (0,
|
5054
|
+
const debouncedParamsRef = (0, import_react31.useRef)(null);
|
5061
5055
|
const tempDisableFallback = useTempDisableFallback(100);
|
5062
|
-
const [zoneStore] = (0,
|
5056
|
+
const [zoneStore] = (0, import_react31.useState)(
|
5063
5057
|
() => (0, import_zustand3.createStore)(() => ({
|
5064
5058
|
zoneDepthIndex: {},
|
5065
5059
|
nextZoneDepthIndex: {},
|
@@ -5069,7 +5063,7 @@ var DragDropContextClient = ({
|
|
5069
5063
|
previewIndex: {}
|
5070
5064
|
}))
|
5071
5065
|
);
|
5072
|
-
const getChanged2 = (0,
|
5066
|
+
const getChanged2 = (0, import_react31.useCallback)(
|
5073
5067
|
(params, id2) => {
|
5074
5068
|
const { zoneDepthIndex = {}, areaDepthIndex = {} } = zoneStore.getState() || {};
|
5075
5069
|
const stateHasZone = Object.keys(zoneDepthIndex).length > 0;
|
@@ -5090,7 +5084,7 @@ var DragDropContextClient = ({
|
|
5090
5084
|
},
|
5091
5085
|
[zoneStore]
|
5092
5086
|
);
|
5093
|
-
const setDeepestAndCollide = (0,
|
5087
|
+
const setDeepestAndCollide = (0, import_react31.useCallback)(
|
5094
5088
|
(params, manager) => {
|
5095
5089
|
const { zoneChanged, areaChanged } = getChanged2(params, id);
|
5096
5090
|
if (!zoneChanged && !areaChanged) return;
|
@@ -5114,7 +5108,7 @@ var DragDropContextClient = ({
|
|
5114
5108
|
setDeepestDb.cancel();
|
5115
5109
|
debouncedParamsRef.current = null;
|
5116
5110
|
};
|
5117
|
-
(0,
|
5111
|
+
(0, import_react31.useEffect)(() => {
|
5118
5112
|
if (DEBUG3) {
|
5119
5113
|
zoneStore.subscribe(
|
5120
5114
|
(s) => {
|
@@ -5128,7 +5122,7 @@ var DragDropContextClient = ({
|
|
5128
5122
|
);
|
5129
5123
|
}
|
5130
5124
|
}, []);
|
5131
|
-
const [plugins] = (0,
|
5125
|
+
const [plugins] = (0, import_react31.useState)(() => [
|
5132
5126
|
...disableAutoScroll ? import_dom.defaultPreset.plugins.filter((plugin) => plugin !== import_dom.AutoScroller) : import_dom.defaultPreset.plugins,
|
5133
5127
|
createNestedDroppablePlugin(
|
5134
5128
|
{
|
@@ -5176,10 +5170,10 @@ var DragDropContextClient = ({
|
|
5176
5170
|
)
|
5177
5171
|
]);
|
5178
5172
|
const sensors = useSensors();
|
5179
|
-
const [dragListeners, setDragListeners] = (0,
|
5180
|
-
const [pathData, setPathData] = (0,
|
5181
|
-
const dragMode = (0,
|
5182
|
-
const registerPath = (0,
|
5173
|
+
const [dragListeners, setDragListeners] = (0, import_react31.useState)({});
|
5174
|
+
const [pathData, setPathData] = (0, import_react31.useState)();
|
5175
|
+
const dragMode = (0, import_react31.useRef)(null);
|
5176
|
+
const registerPath = (0, import_react31.useCallback)(
|
5183
5177
|
(id2, selector, label) => {
|
5184
5178
|
const [area] = getZoneId(selector.zone);
|
5185
5179
|
setPathData((latestPathData = {}) => {
|
@@ -5197,7 +5191,7 @@ var DragDropContextClient = ({
|
|
5197
5191
|
},
|
5198
5192
|
[data, setPathData]
|
5199
5193
|
);
|
5200
|
-
const unregisterPath = (0,
|
5194
|
+
const unregisterPath = (0, import_react31.useCallback)(
|
5201
5195
|
(id2) => {
|
5202
5196
|
setPathData((latestPathData = {}) => {
|
5203
5197
|
const newPathData = __spreadValues({}, latestPathData);
|
@@ -5207,7 +5201,7 @@ var DragDropContextClient = ({
|
|
5207
5201
|
},
|
5208
5202
|
[data, setPathData]
|
5209
5203
|
);
|
5210
|
-
const initialSelector = (0,
|
5204
|
+
const initialSelector = (0, import_react31.useRef)(void 0);
|
5211
5205
|
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { id, children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
5212
5206
|
dragListenerContext.Provider,
|
5213
5207
|
{
|
@@ -5216,7 +5210,7 @@ var DragDropContextClient = ({
|
|
5216
5210
|
setDragListeners
|
5217
5211
|
},
|
5218
5212
|
children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
5219
|
-
|
5213
|
+
import_react30.DragDropProvider,
|
5220
5214
|
{
|
5221
5215
|
plugins,
|
5222
5216
|
sensors,
|
@@ -5445,7 +5439,7 @@ var DrawerItemInner = ({
|
|
5445
5439
|
dragRef,
|
5446
5440
|
isDragDisabled
|
5447
5441
|
}) => {
|
5448
|
-
const CustomInner = (0,
|
5442
|
+
const CustomInner = (0, import_react32.useMemo)(
|
5449
5443
|
() => children || (({ children: children2 }) => /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: getClassNameItem2("default"), children: children2 })),
|
5450
5444
|
[children]
|
5451
5445
|
);
|
@@ -5499,7 +5493,7 @@ var DrawerItem = ({
|
|
5499
5493
|
isDragDisabled
|
5500
5494
|
}) => {
|
5501
5495
|
const resolvedId = id || name;
|
5502
|
-
const [dynamicId, setDynamicId] = (0,
|
5496
|
+
const [dynamicId, setDynamicId] = (0, import_react32.useState)(generateId(resolvedId));
|
5503
5497
|
if (typeof index !== "undefined") {
|
5504
5498
|
console.error(
|
5505
5499
|
"Warning: The `index` prop on Drawer.Item is deprecated and no longer required."
|
@@ -5538,7 +5532,7 @@ var Drawer = ({
|
|
5538
5532
|
"Warning: The `direction` prop on Drawer is deprecated and no longer required to achieve multi-directional dragging."
|
5539
5533
|
);
|
5540
5534
|
}
|
5541
|
-
const id =
|
5535
|
+
const id = (0, import_react32.useId)();
|
5542
5536
|
const { ref } = useDroppableSafe({
|
5543
5537
|
id,
|
5544
5538
|
type: "void",
|
@@ -5560,7 +5554,7 @@ Drawer.Item = DrawerItem;
|
|
5560
5554
|
|
5561
5555
|
// components/Puck/index.tsx
|
5562
5556
|
init_react_import();
|
5563
|
-
var
|
5557
|
+
var import_react50 = require("react");
|
5564
5558
|
|
5565
5559
|
// components/SidebarSection/index.tsx
|
5566
5560
|
init_react_import();
|
@@ -5571,7 +5565,7 @@ var styles_module_default13 = { "SidebarSection": "_SidebarSection_8boj8_1", "Si
|
|
5571
5565
|
|
5572
5566
|
// lib/use-breadcrumbs.ts
|
5573
5567
|
init_react_import();
|
5574
|
-
var
|
5568
|
+
var import_react33 = require("react");
|
5575
5569
|
var convertPathDataToBreadcrumbs = (selectedItem, pathData, data) => {
|
5576
5570
|
const id = selectedItem ? selectedItem == null ? void 0 : selectedItem.props.id : "";
|
5577
5571
|
const currentPathData = pathData && id && pathData[id] ? __spreadValues({}, pathData[id]) : { label: "Page", path: [] };
|
@@ -5621,8 +5615,8 @@ var useBreadcrumbs = (renderCount) => {
|
|
5621
5615
|
state: { data },
|
5622
5616
|
selectedItem
|
5623
5617
|
} = useAppContext();
|
5624
|
-
const dzContext = (0,
|
5625
|
-
return (0,
|
5618
|
+
const dzContext = (0, import_react33.useContext)(dropZoneContext);
|
5619
|
+
return (0, import_react33.useMemo)(() => {
|
5626
5620
|
const breadcrumbs = convertPathDataToBreadcrumbs(
|
5627
5621
|
selectedItem,
|
5628
5622
|
dzContext == null ? void 0 : dzContext.pathData,
|
@@ -5756,15 +5750,15 @@ init_react_import();
|
|
5756
5750
|
var styles_module_default16 = { "PuckFields": "_PuckFields_10bh7_1", "PuckFields--isLoading": "_PuckFields--isLoading_10bh7_6", "PuckFields-loadingOverlay": "_PuckFields-loadingOverlay_10bh7_10", "PuckFields-loadingOverlayInner": "_PuckFields-loadingOverlayInner_10bh7_25", "PuckFields-field": "_PuckFields-field_10bh7_32", "PuckFields--wrapFields": "_PuckFields--wrapFields_10bh7_36" };
|
5757
5751
|
|
5758
5752
|
// components/Puck/components/Fields/index.tsx
|
5759
|
-
var
|
5753
|
+
var import_react37 = require("react");
|
5760
5754
|
|
5761
5755
|
// lib/use-resolved-fields.ts
|
5762
5756
|
init_react_import();
|
5763
|
-
var
|
5757
|
+
var import_react36 = require("react");
|
5764
5758
|
|
5765
5759
|
// lib/use-parent.ts
|
5766
5760
|
init_react_import();
|
5767
|
-
var
|
5761
|
+
var import_react34 = require("react");
|
5768
5762
|
var getParent = (itemSelector, pathData, data) => {
|
5769
5763
|
var _a;
|
5770
5764
|
if (!itemSelector) return null;
|
@@ -5776,8 +5770,8 @@ var getParent = (itemSelector, pathData, data) => {
|
|
5776
5770
|
};
|
5777
5771
|
var useGetParent = () => {
|
5778
5772
|
const { state } = useAppContext();
|
5779
|
-
const { pathData } = (0,
|
5780
|
-
return (0,
|
5773
|
+
const { pathData } = (0, import_react34.useContext)(dropZoneContext) || {};
|
5774
|
+
return (0, import_react34.useCallback)(
|
5781
5775
|
() => getParent(state.ui.itemSelector, pathData, state.data),
|
5782
5776
|
[state.ui.itemSelector, pathData, state.data]
|
5783
5777
|
);
|
@@ -5788,10 +5782,10 @@ var useParent = () => {
|
|
5788
5782
|
|
5789
5783
|
// lib/use-on-value-change.ts
|
5790
5784
|
init_react_import();
|
5791
|
-
var
|
5785
|
+
var import_react35 = require("react");
|
5792
5786
|
function useOnValueChange(value, onChange, compare = Object.is, deps = []) {
|
5793
|
-
const tracked = (0,
|
5794
|
-
(0,
|
5787
|
+
const tracked = (0, import_react35.useRef)(value);
|
5788
|
+
(0, import_react35.useEffect)(() => {
|
5795
5789
|
const oldValue = tracked.current;
|
5796
5790
|
if (!compare(value, oldValue)) {
|
5797
5791
|
tracked.current = value;
|
@@ -5818,27 +5812,27 @@ var useResolvedFields = ({
|
|
5818
5812
|
const { data } = state;
|
5819
5813
|
const rootFields = ((_a = config.root) == null ? void 0 : _a.fields) || defaultPageFields;
|
5820
5814
|
const componentConfig = selectedItem ? config.components[selectedItem.type] : null;
|
5821
|
-
const defaultFields = (0,
|
5815
|
+
const defaultFields = (0, import_react36.useMemo)(
|
5822
5816
|
() => (selectedItem ? componentConfig == null ? void 0 : componentConfig.fields : rootFields) || {},
|
5823
5817
|
[selectedItem, rootFields, componentConfig == null ? void 0 : componentConfig.fields]
|
5824
5818
|
);
|
5825
5819
|
const rootProps = data.root.props || data.root;
|
5826
|
-
const [lastSelectedData, setLastSelectedData] = (0,
|
5827
|
-
const [resolvedFields, setResolvedFields] = (0,
|
5820
|
+
const [lastSelectedData, setLastSelectedData] = (0, import_react36.useState)({});
|
5821
|
+
const [resolvedFields, setResolvedFields] = (0, import_react36.useState)({
|
5828
5822
|
fields: defaultFields,
|
5829
5823
|
id: selectedItem == null ? void 0 : selectedItem.props.id
|
5830
5824
|
});
|
5831
|
-
const [fieldsLoading, setFieldsLoading] = (0,
|
5832
|
-
const lastFields = (0,
|
5825
|
+
const [fieldsLoading, setFieldsLoading] = (0, import_react36.useState)(false);
|
5826
|
+
const lastFields = (0, import_react36.useRef)(defaultFields);
|
5833
5827
|
const defaultResolveFields = (_componentData, _params) => defaultFields;
|
5834
|
-
const componentData = (0,
|
5828
|
+
const componentData = (0, import_react36.useMemo)(
|
5835
5829
|
() => selectedItem ? selectedItem : { props: rootProps, readOnly: data.root.readOnly || {} },
|
5836
5830
|
[selectedItem, rootProps, data.root.readOnly]
|
5837
5831
|
);
|
5838
5832
|
const hasComponentResolver = selectedItem && (componentConfig == null ? void 0 : componentConfig.resolveFields);
|
5839
5833
|
const hasRootResolver = !selectedItem && ((_b = config.root) == null ? void 0 : _b.resolveFields);
|
5840
5834
|
const hasResolver = hasComponentResolver || hasRootResolver;
|
5841
|
-
const resolveFields = (0,
|
5835
|
+
const resolveFields = (0, import_react36.useCallback)(
|
5842
5836
|
(..._0) => __async(void 0, [..._0], function* (fields = {}) {
|
5843
5837
|
var _a2;
|
5844
5838
|
const lastData = ((_a2 = lastSelectedData.props) == null ? void 0 : _a2.id) === componentData.props.id ? lastSelectedData : null;
|
@@ -5876,7 +5870,7 @@ var useResolvedFields = ({
|
|
5876
5870
|
}),
|
5877
5871
|
[data, config, componentData, selectedItem, state, parent]
|
5878
5872
|
);
|
5879
|
-
const triggerResolver = (0,
|
5873
|
+
const triggerResolver = (0, import_react36.useCallback)(() => {
|
5880
5874
|
var _a2, _b2;
|
5881
5875
|
if (!((_a2 = state.ui.itemSelector) == null ? void 0 : _a2.zone) || ((_b2 = state.ui.itemSelector) == null ? void 0 : _b2.zone) === "default-zone" || parent) {
|
5882
5876
|
if (hasResolver) {
|
@@ -5916,7 +5910,7 @@ var useResolvedFields = ({
|
|
5916
5910
|
},
|
5917
5911
|
(a, b) => JSON.stringify(a) === JSON.stringify(b)
|
5918
5912
|
);
|
5919
|
-
(0,
|
5913
|
+
(0, import_react36.useEffect)(() => {
|
5920
5914
|
triggerResolver();
|
5921
5915
|
}, []);
|
5922
5916
|
if (resolvedFields.id !== (selectedItem == null ? void 0 : selectedItem.props.id) && !_skipIdCheck) {
|
@@ -5951,7 +5945,7 @@ var Fields = ({ wrapFields = true }) => {
|
|
5951
5945
|
const componentResolving = selectedItem ? ((_a = componentState[selectedItem == null ? void 0 : selectedItem.props.id]) == null ? void 0 : _a.loadingCount) > 0 : ((_b = componentState["puck-root"]) == null ? void 0 : _b.loadingCount) > 0;
|
5952
5946
|
const isLoading = fieldsResolving || componentResolving;
|
5953
5947
|
const rootProps = data.root.props || data.root;
|
5954
|
-
const Wrapper = (0,
|
5948
|
+
const Wrapper = (0, import_react37.useMemo)(() => overrides.fields || DefaultFields, [overrides]);
|
5955
5949
|
return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
|
5956
5950
|
"form",
|
5957
5951
|
{
|
@@ -6072,7 +6066,7 @@ init_react_import();
|
|
6072
6066
|
|
6073
6067
|
// lib/use-component-list.tsx
|
6074
6068
|
init_react_import();
|
6075
|
-
var
|
6069
|
+
var import_react38 = require("react");
|
6076
6070
|
|
6077
6071
|
// components/ComponentList/index.tsx
|
6078
6072
|
init_react_import();
|
@@ -6139,8 +6133,8 @@ ComponentList.Item = ComponentListItem;
|
|
6139
6133
|
// lib/use-component-list.tsx
|
6140
6134
|
var import_jsx_runtime29 = require("react/jsx-runtime");
|
6141
6135
|
var useComponentList = (config, ui) => {
|
6142
|
-
const [componentList, setComponentList] = (0,
|
6143
|
-
(0,
|
6136
|
+
const [componentList, setComponentList] = (0, import_react38.useState)();
|
6137
|
+
(0, import_react38.useEffect)(() => {
|
6144
6138
|
var _a, _b, _c;
|
6145
6139
|
if (Object.keys(ui.componentList).length > 0) {
|
6146
6140
|
const matchedComponents = [];
|
@@ -6209,22 +6203,22 @@ var useComponentList = (config, ui) => {
|
|
6209
6203
|
};
|
6210
6204
|
|
6211
6205
|
// components/Puck/components/Components/index.tsx
|
6212
|
-
var
|
6206
|
+
var import_react39 = require("react");
|
6213
6207
|
var import_jsx_runtime30 = require("react/jsx-runtime");
|
6214
6208
|
var Components = () => {
|
6215
6209
|
const { config, state, overrides } = useAppContext();
|
6216
6210
|
const componentList = useComponentList(config, state.ui);
|
6217
|
-
const Wrapper = (0,
|
6211
|
+
const Wrapper = (0, import_react39.useMemo)(() => overrides.components || "div", [overrides]);
|
6218
6212
|
return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Wrapper, { children: componentList ? componentList : /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(ComponentList, { id: "all" }) });
|
6219
6213
|
};
|
6220
6214
|
|
6221
6215
|
// components/Puck/components/Preview/index.tsx
|
6222
6216
|
init_react_import();
|
6223
|
-
var
|
6217
|
+
var import_react41 = require("react");
|
6224
6218
|
|
6225
6219
|
// components/AutoFrame/index.tsx
|
6226
6220
|
init_react_import();
|
6227
|
-
var
|
6221
|
+
var import_react40 = require("react");
|
6228
6222
|
var import_object_hash = __toESM(require("object-hash"));
|
6229
6223
|
var import_react_dom3 = require("react-dom");
|
6230
6224
|
var import_jsx_runtime31 = require("react/jsx-runtime");
|
@@ -6270,7 +6264,7 @@ var CopyHostStyles = ({
|
|
6270
6264
|
onStylesLoaded = () => null
|
6271
6265
|
}) => {
|
6272
6266
|
const { document: doc, window: win } = useFrame();
|
6273
|
-
(0,
|
6267
|
+
(0, import_react40.useEffect)(() => {
|
6274
6268
|
if (!win || !doc) {
|
6275
6269
|
return () => {
|
6276
6270
|
};
|
@@ -6429,8 +6423,8 @@ var CopyHostStyles = ({
|
|
6429
6423
|
}, []);
|
6430
6424
|
return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_jsx_runtime31.Fragment, { children });
|
6431
6425
|
};
|
6432
|
-
var autoFrameContext = (0,
|
6433
|
-
var useFrame = () => (0,
|
6426
|
+
var autoFrameContext = (0, import_react40.createContext)({});
|
6427
|
+
var useFrame = () => (0, import_react40.useContext)(autoFrameContext);
|
6434
6428
|
function AutoFrame(_a) {
|
6435
6429
|
var _b = _a, {
|
6436
6430
|
children,
|
@@ -6447,10 +6441,10 @@ function AutoFrame(_a) {
|
|
6447
6441
|
"onStylesLoaded",
|
6448
6442
|
"frameRef"
|
6449
6443
|
]);
|
6450
|
-
const [loaded, setLoaded] = (0,
|
6451
|
-
const [ctx, setCtx] = (0,
|
6452
|
-
const [mountTarget, setMountTarget] = (0,
|
6453
|
-
(0,
|
6444
|
+
const [loaded, setLoaded] = (0, import_react40.useState)(false);
|
6445
|
+
const [ctx, setCtx] = (0, import_react40.useState)({});
|
6446
|
+
const [mountTarget, setMountTarget] = (0, import_react40.useState)();
|
6447
|
+
(0, import_react40.useEffect)(() => {
|
6454
6448
|
var _a2;
|
6455
6449
|
if (frameRef.current) {
|
6456
6450
|
setCtx({
|
@@ -6545,7 +6539,7 @@ var import_jsx_runtime33 = require("react/jsx-runtime");
|
|
6545
6539
|
var getClassName23 = get_class_name_factory_default("PuckPreview", styles_module_default18);
|
6546
6540
|
var useBubbleIframeEvents = (ref) => {
|
6547
6541
|
const { status } = useAppContext();
|
6548
|
-
(0,
|
6542
|
+
(0, import_react41.useEffect)(() => {
|
6549
6543
|
var _a;
|
6550
6544
|
if (ref.current && status === "READY") {
|
6551
6545
|
const iframe = ref.current;
|
@@ -6578,7 +6572,7 @@ var useBubbleIframeEvents = (ref) => {
|
|
6578
6572
|
};
|
6579
6573
|
var Preview2 = ({ id = "puck-preview" }) => {
|
6580
6574
|
const { config, dispatch, state, setStatus, iframe, overrides } = useAppContext();
|
6581
|
-
const Page = (0,
|
6575
|
+
const Page = (0, import_react41.useCallback)(
|
6582
6576
|
(pageProps) => {
|
6583
6577
|
var _a, _b;
|
6584
6578
|
return ((_a = config.root) == null ? void 0 : _a.render) ? (_b = config.root) == null ? void 0 : _b.render(__spreadValues({
|
@@ -6587,9 +6581,9 @@ var Preview2 = ({ id = "puck-preview" }) => {
|
|
6587
6581
|
},
|
6588
6582
|
[config.root]
|
6589
6583
|
);
|
6590
|
-
const Frame = (0,
|
6584
|
+
const Frame = (0, import_react41.useMemo)(() => overrides.iframe, [overrides]);
|
6591
6585
|
const rootProps = state.data.root.props || state.data.root;
|
6592
|
-
const ref = (0,
|
6586
|
+
const ref = (0, import_react41.useRef)(null);
|
6593
6587
|
useBubbleIframeEvents(ref);
|
6594
6588
|
const inner = state.ui.previewMode === "edit" ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
6595
6589
|
Page,
|
@@ -6686,7 +6680,7 @@ var scrollIntoView = (el) => {
|
|
6686
6680
|
};
|
6687
6681
|
|
6688
6682
|
// components/LayerTree/index.tsx
|
6689
|
-
var
|
6683
|
+
var import_react42 = require("react");
|
6690
6684
|
|
6691
6685
|
// lib/is-child-of-zone.ts
|
6692
6686
|
init_react_import();
|
@@ -6732,7 +6726,7 @@ var LayerTree = ({
|
|
6732
6726
|
label
|
6733
6727
|
}) => {
|
6734
6728
|
const zones = data.zones || {};
|
6735
|
-
const ctx = (0,
|
6729
|
+
const ctx = (0, import_react42.useContext)(dropZoneContext);
|
6736
6730
|
return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(import_jsx_runtime34.Fragment, { children: [
|
6737
6731
|
label && /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("div", { className: getClassName24("zoneTitle"), children: [
|
6738
6732
|
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: getClassName24("zoneIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Layers, { size: "16" }) }),
|
@@ -6839,13 +6833,13 @@ var LayerTree = ({
|
|
6839
6833
|
};
|
6840
6834
|
|
6841
6835
|
// components/Puck/components/Outline/index.tsx
|
6842
|
-
var
|
6836
|
+
var import_react43 = require("react");
|
6843
6837
|
var import_jsx_runtime35 = require("react/jsx-runtime");
|
6844
6838
|
var Outline = () => {
|
6845
6839
|
const { dispatch, state, overrides, config } = useAppContext();
|
6846
6840
|
const { data, ui } = state;
|
6847
6841
|
const { itemSelector } = ui;
|
6848
|
-
const setItemSelector = (0,
|
6842
|
+
const setItemSelector = (0, import_react43.useCallback)(
|
6849
6843
|
(newItemSelector) => {
|
6850
6844
|
dispatch({
|
6851
6845
|
type: "setUi",
|
@@ -6854,7 +6848,7 @@ var Outline = () => {
|
|
6854
6848
|
},
|
6855
6849
|
[]
|
6856
6850
|
);
|
6857
|
-
const Wrapper = (0,
|
6851
|
+
const Wrapper = (0, import_react43.useMemo)(() => overrides.outline || "div", [overrides]);
|
6858
6852
|
return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Wrapper, { children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(dropZoneContext.Consumer, { children: (ctx) => /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(import_jsx_runtime35.Fragment, { children: [
|
6859
6853
|
(ctx == null ? void 0 : ctx.activeZones) && (ctx == null ? void 0 : ctx.activeZones[rootDroppableId]) && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
6860
6854
|
LayerTree,
|
@@ -6968,19 +6962,19 @@ function usePuckHistory({
|
|
6968
6962
|
|
6969
6963
|
// lib/use-history-store.ts
|
6970
6964
|
init_react_import();
|
6971
|
-
var
|
6965
|
+
var import_react44 = require("react");
|
6972
6966
|
var import_use_debounce3 = require("use-debounce");
|
6973
6967
|
var EMPTY_HISTORY_INDEX = 0;
|
6974
6968
|
function useHistoryStore(initialHistory) {
|
6975
6969
|
var _a, _b;
|
6976
|
-
const [histories, setHistories] = (0,
|
6970
|
+
const [histories, setHistories] = (0, import_react44.useState)(
|
6977
6971
|
(_a = initialHistory == null ? void 0 : initialHistory.histories) != null ? _a : []
|
6978
6972
|
);
|
6979
6973
|
const updateHistories = (histories2) => {
|
6980
6974
|
setHistories(histories2);
|
6981
6975
|
setIndex(histories2.length - 1);
|
6982
6976
|
};
|
6983
|
-
const [index, setIndex] = (0,
|
6977
|
+
const [index, setIndex] = (0, import_react44.useState)(
|
6984
6978
|
(_b = initialHistory == null ? void 0 : initialHistory.index) != null ? _b : EMPTY_HISTORY_INDEX
|
6985
6979
|
);
|
6986
6980
|
const hasPast = index > EMPTY_HISTORY_INDEX;
|
@@ -7140,11 +7134,11 @@ var getBox = function getBox2(el) {
|
|
7140
7134
|
};
|
7141
7135
|
|
7142
7136
|
// components/Puck/components/Canvas/index.tsx
|
7143
|
-
var
|
7137
|
+
var import_react46 = require("react");
|
7144
7138
|
|
7145
7139
|
// components/ViewportControls/index.tsx
|
7146
7140
|
init_react_import();
|
7147
|
-
var
|
7141
|
+
var import_react45 = require("react");
|
7148
7142
|
|
7149
7143
|
// css-module:/home/runner/work/puck/puck/packages/core/components/ViewportControls/styles.module.css#css-module
|
7150
7144
|
init_react_import();
|
@@ -7167,8 +7161,8 @@ var ViewportButton = ({
|
|
7167
7161
|
onClick
|
7168
7162
|
}) => {
|
7169
7163
|
const { state } = useAppContext();
|
7170
|
-
const [isActive, setIsActive] = (0,
|
7171
|
-
(0,
|
7164
|
+
const [isActive, setIsActive] = (0, import_react45.useState)(false);
|
7165
|
+
(0, import_react45.useEffect)(() => {
|
7172
7166
|
setIsActive(width === state.ui.viewports.current.width);
|
7173
7167
|
}, [width, state.ui.viewports.current.width]);
|
7174
7168
|
return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("span", { className: getClassNameButton({ isActive }), children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
@@ -7204,7 +7198,7 @@ var ViewportControls = ({
|
|
7204
7198
|
const defaultsContainAutoZoom = defaultZoomOptions.find(
|
7205
7199
|
(option) => option.value === autoZoom
|
7206
7200
|
);
|
7207
|
-
const zoomOptions = (0,
|
7201
|
+
const zoomOptions = (0, import_react45.useMemo)(
|
7208
7202
|
() => [
|
7209
7203
|
...defaultZoomOptions,
|
7210
7204
|
...defaultsContainAutoZoom ? [] : [
|
@@ -7327,17 +7321,17 @@ var Canvas = () => {
|
|
7327
7321
|
const { status, iframe } = useAppContext();
|
7328
7322
|
const { dispatch, state, overrides, setUi, zoomConfig, setZoomConfig } = useAppContext();
|
7329
7323
|
const { ui } = state;
|
7330
|
-
const frameRef = (0,
|
7331
|
-
const [showTransition, setShowTransition] = (0,
|
7332
|
-
const defaultRender = (0,
|
7324
|
+
const frameRef = (0, import_react46.useRef)(null);
|
7325
|
+
const [showTransition, setShowTransition] = (0, import_react46.useState)(false);
|
7326
|
+
const defaultRender = (0, import_react46.useMemo)(() => {
|
7333
7327
|
const PuckDefault = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(import_jsx_runtime37.Fragment, { children });
|
7334
7328
|
return PuckDefault;
|
7335
7329
|
}, []);
|
7336
|
-
const CustomPreview = (0,
|
7330
|
+
const CustomPreview = (0, import_react46.useMemo)(
|
7337
7331
|
() => overrides.preview || defaultRender,
|
7338
7332
|
[overrides]
|
7339
7333
|
);
|
7340
|
-
const getFrameDimensions = (0,
|
7334
|
+
const getFrameDimensions = (0, import_react46.useCallback)(() => {
|
7341
7335
|
if (frameRef.current) {
|
7342
7336
|
const frame = frameRef.current;
|
7343
7337
|
const box = getBox(frame);
|
@@ -7345,7 +7339,7 @@ var Canvas = () => {
|
|
7345
7339
|
}
|
7346
7340
|
return { width: 0, height: 0 };
|
7347
7341
|
}, [frameRef]);
|
7348
|
-
const resetAutoZoom = (0,
|
7342
|
+
const resetAutoZoom = (0, import_react46.useCallback)(
|
7349
7343
|
(ui2 = state.ui) => {
|
7350
7344
|
if (frameRef.current) {
|
7351
7345
|
setZoomConfig(
|
@@ -7355,11 +7349,11 @@ var Canvas = () => {
|
|
7355
7349
|
},
|
7356
7350
|
[frameRef, zoomConfig, state.ui]
|
7357
7351
|
);
|
7358
|
-
(0,
|
7352
|
+
(0, import_react46.useEffect)(() => {
|
7359
7353
|
setShowTransition(false);
|
7360
7354
|
resetAutoZoom();
|
7361
7355
|
}, [frameRef, ui.leftSideBarVisible, ui.rightSideBarVisible]);
|
7362
|
-
(0,
|
7356
|
+
(0, import_react46.useEffect)(() => {
|
7363
7357
|
const { height: frameHeight } = getFrameDimensions();
|
7364
7358
|
if (ui.viewports.current.height === "auto") {
|
7365
7359
|
setZoomConfig(__spreadProps(__spreadValues({}, zoomConfig), {
|
@@ -7367,13 +7361,13 @@ var Canvas = () => {
|
|
7367
7361
|
}));
|
7368
7362
|
}
|
7369
7363
|
}, [zoomConfig.zoom]);
|
7370
|
-
(0,
|
7364
|
+
(0, import_react46.useEffect)(() => {
|
7371
7365
|
if (ZOOM_ON_CHANGE) {
|
7372
7366
|
setShowTransition(true);
|
7373
7367
|
resetAutoZoom(ui);
|
7374
7368
|
}
|
7375
7369
|
}, [ui.viewports.current.width]);
|
7376
|
-
(0,
|
7370
|
+
(0, import_react46.useEffect)(() => {
|
7377
7371
|
const cb = () => {
|
7378
7372
|
setShowTransition(false);
|
7379
7373
|
resetAutoZoom();
|
@@ -7383,8 +7377,8 @@ var Canvas = () => {
|
|
7383
7377
|
window.removeEventListener("resize", cb);
|
7384
7378
|
};
|
7385
7379
|
}, []);
|
7386
|
-
const [showLoader, setShowLoader] = (0,
|
7387
|
-
(0,
|
7380
|
+
const [showLoader, setShowLoader] = (0, import_react46.useState)(false);
|
7381
|
+
(0, import_react46.useEffect)(() => {
|
7388
7382
|
setTimeout(() => {
|
7389
7383
|
setShowLoader(true);
|
7390
7384
|
}, 500);
|
@@ -7462,7 +7456,7 @@ var Canvas = () => {
|
|
7462
7456
|
|
7463
7457
|
// lib/use-loaded-overrides.ts
|
7464
7458
|
init_react_import();
|
7465
|
-
var
|
7459
|
+
var import_react47 = require("react");
|
7466
7460
|
|
7467
7461
|
// lib/load-overrides.ts
|
7468
7462
|
init_react_import();
|
@@ -7501,7 +7495,7 @@ var useLoadedOverrides = ({
|
|
7501
7495
|
overrides,
|
7502
7496
|
plugins
|
7503
7497
|
}) => {
|
7504
|
-
return (0,
|
7498
|
+
return (0, import_react47.useMemo)(() => {
|
7505
7499
|
return loadOverrides({ overrides, plugins });
|
7506
7500
|
}, [plugins, overrides]);
|
7507
7501
|
};
|
@@ -7513,14 +7507,14 @@ var DefaultOverride = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime38
|
|
7513
7507
|
|
7514
7508
|
// lib/use-inject-css.ts
|
7515
7509
|
init_react_import();
|
7516
|
-
var
|
7510
|
+
var import_react48 = require("react");
|
7517
7511
|
var styles = ``;
|
7518
7512
|
var useInjectStyleSheet = (initialStyles, iframeEnabled) => {
|
7519
|
-
const [el, setEl] = (0,
|
7520
|
-
(0,
|
7513
|
+
const [el, setEl] = (0, import_react48.useState)();
|
7514
|
+
(0, import_react48.useEffect)(() => {
|
7521
7515
|
setEl(document.createElement("style"));
|
7522
7516
|
}, []);
|
7523
|
-
(0,
|
7517
|
+
(0, import_react48.useEffect)(() => {
|
7524
7518
|
var _a;
|
7525
7519
|
if (!el || typeof window === "undefined") {
|
7526
7520
|
return;
|
@@ -7540,10 +7534,10 @@ var useInjectGlobalCss = (iframeEnabled) => {
|
|
7540
7534
|
|
7541
7535
|
// lib/use-preview-mode-hotkeys.ts
|
7542
7536
|
init_react_import();
|
7543
|
-
var
|
7537
|
+
var import_react49 = require("react");
|
7544
7538
|
var import_react_hotkeys_hook2 = require("react-hotkeys-hook");
|
7545
7539
|
var usePreviewModeHotkeys = (dispatch, iframeEnabled) => {
|
7546
|
-
const toggleInteractive = (0,
|
7540
|
+
const toggleInteractive = (0, import_react49.useCallback)(() => {
|
7547
7541
|
dispatch({
|
7548
7542
|
type: "setUi",
|
7549
7543
|
ui: (ui) => ({
|
@@ -7600,7 +7594,7 @@ function Puck({
|
|
7600
7594
|
waitForStyles: true
|
7601
7595
|
}, _iframe);
|
7602
7596
|
useInjectGlobalCss(iframe.enabled);
|
7603
|
-
const [generatedAppState] = (0,
|
7597
|
+
const [generatedAppState] = (0, import_react50.useState)(() => {
|
7604
7598
|
var _a2, _b2, _c, _d, _e, _f, _g, _h, _i;
|
7605
7599
|
const initial = __spreadValues(__spreadValues({}, defaultAppState.ui), initialUi);
|
7606
7600
|
let clientUiState = {};
|
@@ -7672,14 +7666,14 @@ function Puck({
|
|
7672
7666
|
histories,
|
7673
7667
|
index: initialHistoryIndex
|
7674
7668
|
});
|
7675
|
-
const [reducer] = (0,
|
7669
|
+
const [reducer] = (0, import_react50.useState)(
|
7676
7670
|
() => createReducer({
|
7677
7671
|
config,
|
7678
7672
|
record: historyStore.record,
|
7679
7673
|
onAction
|
7680
7674
|
})
|
7681
7675
|
);
|
7682
|
-
const [appState, dispatch] = (0,
|
7676
|
+
const [appState, dispatch] = (0, import_react50.useReducer)(
|
7683
7677
|
reducer,
|
7684
7678
|
flushZones(initialAppState)
|
7685
7679
|
);
|
@@ -7690,14 +7684,14 @@ function Puck({
|
|
7690
7684
|
historyStore,
|
7691
7685
|
iframeEnabled: (_a = _iframe == null ? void 0 : _iframe.enabled) != null ? _a : true
|
7692
7686
|
});
|
7693
|
-
const [menuOpen, setMenuOpen] = (0,
|
7687
|
+
const [menuOpen, setMenuOpen] = (0, import_react50.useState)(false);
|
7694
7688
|
const { itemSelector, leftSideBarVisible, rightSideBarVisible } = ui;
|
7695
7689
|
const selectedItem = itemSelector ? getItem(itemSelector, data) : null;
|
7696
|
-
(0,
|
7690
|
+
(0, import_react50.useEffect)(() => {
|
7697
7691
|
if (onChange) onChange(data);
|
7698
7692
|
}, [data]);
|
7699
7693
|
const rootProps = data.root.props || data.root;
|
7700
|
-
const toggleSidebars = (0,
|
7694
|
+
const toggleSidebars = (0, import_react50.useCallback)(
|
7701
7695
|
(sidebar) => {
|
7702
7696
|
const widerViewport = window.matchMedia("(min-width: 638px)").matches;
|
7703
7697
|
const sideBarVisible = sidebar === "left" ? leftSideBarVisible : rightSideBarVisible;
|
@@ -7711,7 +7705,7 @@ function Puck({
|
|
7711
7705
|
},
|
7712
7706
|
[dispatch, leftSideBarVisible, rightSideBarVisible]
|
7713
7707
|
);
|
7714
|
-
(0,
|
7708
|
+
(0, import_react50.useEffect)(() => {
|
7715
7709
|
if (!window.matchMedia("(min-width: 638px)").matches) {
|
7716
7710
|
dispatch({
|
7717
7711
|
type: "setUi",
|
@@ -7734,7 +7728,7 @@ function Puck({
|
|
7734
7728
|
window.removeEventListener("resize", handleResize);
|
7735
7729
|
};
|
7736
7730
|
}, []);
|
7737
|
-
const defaultHeaderRender = (0,
|
7731
|
+
const defaultHeaderRender = (0, import_react50.useMemo)(() => {
|
7738
7732
|
if (renderHeader) {
|
7739
7733
|
console.warn(
|
7740
7734
|
"`renderHeader` is deprecated. Please use `overrides.header` and the `usePuck` hook instead"
|
@@ -7748,7 +7742,7 @@ function Puck({
|
|
7748
7742
|
}
|
7749
7743
|
return DefaultOverride;
|
7750
7744
|
}, [renderHeader]);
|
7751
|
-
const defaultHeaderActionsRender = (0,
|
7745
|
+
const defaultHeaderActionsRender = (0, import_react50.useMemo)(() => {
|
7752
7746
|
if (renderHeaderActions) {
|
7753
7747
|
console.warn(
|
7754
7748
|
"`renderHeaderActions` is deprecated. Please use `overrides.headerActions` and the `usePuck` hook instead."
|
@@ -7765,20 +7759,20 @@ function Puck({
|
|
7765
7759
|
overrides,
|
7766
7760
|
plugins
|
7767
7761
|
});
|
7768
|
-
const CustomPuck = (0,
|
7762
|
+
const CustomPuck = (0, import_react50.useMemo)(
|
7769
7763
|
() => loadedOverrides.puck || DefaultOverride,
|
7770
7764
|
[loadedOverrides]
|
7771
7765
|
);
|
7772
|
-
const CustomHeader = (0,
|
7766
|
+
const CustomHeader = (0, import_react50.useMemo)(
|
7773
7767
|
() => loadedOverrides.header || defaultHeaderRender,
|
7774
7768
|
[loadedOverrides]
|
7775
7769
|
);
|
7776
|
-
const CustomHeaderActions = (0,
|
7770
|
+
const CustomHeaderActions = (0, import_react50.useMemo)(
|
7777
7771
|
() => loadedOverrides.headerActions || defaultHeaderActionsRender,
|
7778
7772
|
[loadedOverrides]
|
7779
7773
|
);
|
7780
|
-
const [mounted, setMounted] = (0,
|
7781
|
-
(0,
|
7774
|
+
const [mounted, setMounted] = (0, import_react50.useState)(false);
|
7775
|
+
(0, import_react50.useEffect)(() => {
|
7782
7776
|
setMounted(true);
|
7783
7777
|
}, []);
|
7784
7778
|
const selectedComponentConfig = selectedItem && config.components[selectedItem.type];
|