@measured/puck 0.18.3-canary.154e7f7 → 0.18.3-canary.368f37f
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.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();
|
@@ -1301,7 +1300,8 @@ function useDraggableSafe(input) {
|
|
1301
1300
|
function useSortableSafe(input) {
|
1302
1301
|
if (typeof window === "undefined") {
|
1303
1302
|
return { ref: () => {
|
1304
|
-
}, status: "idle"
|
1303
|
+
}, status: "idle", handleRef: () => {
|
1304
|
+
} };
|
1305
1305
|
}
|
1306
1306
|
return (0, import_sortable.useSortable)(input);
|
1307
1307
|
}
|
@@ -1576,23 +1576,26 @@ function patchWindow(window2) {
|
|
1576
1576
|
|
1577
1577
|
// lib/dnd/use-sensors.ts
|
1578
1578
|
var import_utilities2 = require("@dnd-kit/dom/utilities");
|
1579
|
-
var useSensors = (
|
1579
|
+
var useSensors = ({
|
1580
|
+
other,
|
1581
|
+
mouse,
|
1582
|
+
touch
|
1583
|
+
} = {
|
1584
|
+
touch: { delay: { value: 200, tolerance: 10 } },
|
1585
|
+
other: { delay: { value: 200, tolerance: 10 }, distance: { value: 5 } }
|
1586
|
+
}) => {
|
1580
1587
|
const [sensors] = (0, import_react9.useState)(() => [
|
1581
1588
|
PointerSensor.configure({
|
1582
1589
|
activationConstraints(event, source) {
|
1583
1590
|
var _a;
|
1584
1591
|
const { pointerType, target } = event;
|
1585
1592
|
if (pointerType === "mouse" && (0, import_utilities2.isElement)(target) && (source.handle === target || ((_a = source.handle) == null ? void 0 : _a.contains(target)))) {
|
1586
|
-
return
|
1593
|
+
return mouse;
|
1587
1594
|
}
|
1588
|
-
const delay = { value: 200, tolerance: 10 };
|
1589
1595
|
if (pointerType === "touch") {
|
1590
|
-
return
|
1596
|
+
return touch;
|
1591
1597
|
}
|
1592
|
-
return
|
1593
|
-
delay,
|
1594
|
-
distance: { value: 5 }
|
1595
|
-
};
|
1598
|
+
return other;
|
1596
1599
|
}
|
1597
1600
|
})
|
1598
1601
|
]);
|
@@ -1935,7 +1938,6 @@ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input
|
|
1935
1938
|
};
|
1936
1939
|
|
1937
1940
|
// components/Sortable/index.tsx
|
1938
|
-
var import_modifiers = require("@dnd-kit/dom/modifiers");
|
1939
1941
|
var import_jsx_runtime6 = require("react/jsx-runtime");
|
1940
1942
|
var SortableProvider = ({
|
1941
1943
|
children,
|
@@ -1943,22 +1945,20 @@ var SortableProvider = ({
|
|
1943
1945
|
onDragEnd,
|
1944
1946
|
onMove
|
1945
1947
|
}) => {
|
1946
|
-
const
|
1947
|
-
|
1948
|
+
const sensors = useSensors({
|
1949
|
+
mouse: { distance: { value: 5 } }
|
1950
|
+
});
|
1948
1951
|
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
1949
1952
|
import_react10.DragDropProvider,
|
1950
1953
|
{
|
1951
1954
|
sensors,
|
1952
|
-
|
1953
|
-
|
1954
|
-
|
1955
|
-
|
1956
|
-
}
|
1957
|
-
})
|
1958
|
-
],
|
1959
|
-
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
|
+
},
|
1960
1959
|
onDragOver: (event, manager) => {
|
1961
1960
|
var _a, _b;
|
1961
|
+
event.preventDefault();
|
1962
1962
|
const { operation } = event;
|
1963
1963
|
const { source, target } = operation;
|
1964
1964
|
if (!source || !target) return;
|
@@ -1966,14 +1966,14 @@ var SortableProvider = ({
|
|
1966
1966
|
let targetIndex = target.data.index;
|
1967
1967
|
const collisionData = (_b = (_a = manager.dragOperation.data) == null ? void 0 : _a.collisionMap) == null ? void 0 : _b[target.id];
|
1968
1968
|
if (sourceIndex !== targetIndex && source.id !== target.id) {
|
1969
|
-
const collisionPosition =
|
1969
|
+
const collisionPosition = collisionData.direction === "up" ? "before" : "after";
|
1970
1970
|
if (targetIndex >= sourceIndex) {
|
1971
1971
|
targetIndex = targetIndex - 1;
|
1972
1972
|
}
|
1973
1973
|
if (collisionPosition === "after") {
|
1974
1974
|
targetIndex = targetIndex + 1;
|
1975
1975
|
}
|
1976
|
-
|
1976
|
+
onMove({
|
1977
1977
|
source: sourceIndex,
|
1978
1978
|
target: targetIndex
|
1979
1979
|
});
|
@@ -1981,12 +1981,8 @@ var SortableProvider = ({
|
|
1981
1981
|
},
|
1982
1982
|
onDragEnd: () => {
|
1983
1983
|
setTimeout(() => {
|
1984
|
-
if (move.source !== -1 && move.target !== -1) {
|
1985
|
-
onMove(move);
|
1986
|
-
}
|
1987
1984
|
onDragEnd();
|
1988
1985
|
}, 250);
|
1989
|
-
setMove({ source: -1, target: -1 });
|
1990
1986
|
},
|
1991
1987
|
children
|
1992
1988
|
}
|
@@ -1999,7 +1995,11 @@ var Sortable = ({
|
|
1999
1995
|
children,
|
2000
1996
|
type = "item"
|
2001
1997
|
}) => {
|
2002
|
-
const {
|
1998
|
+
const {
|
1999
|
+
ref: sortableRef,
|
2000
|
+
status,
|
2001
|
+
handleRef
|
2002
|
+
} = useSortableSafe({
|
2003
2003
|
id,
|
2004
2004
|
type,
|
2005
2005
|
index,
|
@@ -2007,16 +2007,16 @@ var Sortable = ({
|
|
2007
2007
|
data: { index },
|
2008
2008
|
collisionDetector: createDynamicCollisionDetector("y")
|
2009
2009
|
});
|
2010
|
-
return children({ status, ref: sortableRef });
|
2010
|
+
return children({ status, ref: sortableRef, handleRef });
|
2011
2011
|
};
|
2012
2012
|
|
2013
2013
|
// components/AutoField/context.tsx
|
2014
2014
|
init_react_import();
|
2015
|
-
var
|
2015
|
+
var import_react11 = require("react");
|
2016
2016
|
var import_jsx_runtime7 = require("react/jsx-runtime");
|
2017
|
-
var NestedFieldContext = (0,
|
2017
|
+
var NestedFieldContext = (0, import_react11.createContext)({});
|
2018
2018
|
var useNestedFieldContext = () => {
|
2019
|
-
const context = (0,
|
2019
|
+
const context = (0, import_react11.useContext)(NestedFieldContext);
|
2020
2020
|
return __spreadProps(__spreadValues({}, context), {
|
2021
2021
|
readOnlyFields: context.readOnlyFields || {}
|
2022
2022
|
});
|
@@ -2030,7 +2030,7 @@ var NestedFieldProvider = ({
|
|
2030
2030
|
}) => {
|
2031
2031
|
const subPath = `${name}.${subName}`;
|
2032
2032
|
const wildcardSubPath = `${wildcardName}.${subName}`;
|
2033
|
-
const subReadOnlyFields = (0,
|
2033
|
+
const subReadOnlyFields = (0, import_react11.useMemo)(
|
2034
2034
|
() => Object.keys(readOnlyFields).reduce((acc, readOnlyKey) => {
|
2035
2035
|
const isLocal = readOnlyKey.indexOf(subPath) > -1 || readOnlyKey.indexOf(wildcardSubPath) > -1;
|
2036
2036
|
if (isLocal) {
|
@@ -2081,11 +2081,17 @@ var ArrayField = ({
|
|
2081
2081
|
}),
|
2082
2082
|
openId: ""
|
2083
2083
|
};
|
2084
|
-
const [localState, setLocalState] = (0,
|
2085
|
-
(0,
|
2086
|
-
|
2087
|
-
|
2088
|
-
|
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)(
|
2089
2095
|
(partialArrayState) => {
|
2090
2096
|
return {
|
2091
2097
|
arrayState: __spreadProps(__spreadValues({}, state.ui.arrayState), {
|
@@ -2095,13 +2101,13 @@ var ArrayField = ({
|
|
2095
2101
|
},
|
2096
2102
|
[arrayState]
|
2097
2103
|
);
|
2098
|
-
const getHighestIndex = (0,
|
2104
|
+
const getHighestIndex = (0, import_react12.useCallback)(() => {
|
2099
2105
|
return arrayState.items.reduce(
|
2100
2106
|
(acc, item) => item._originalIndex > acc ? item._originalIndex : acc,
|
2101
2107
|
-1
|
2102
2108
|
);
|
2103
2109
|
}, [arrayState]);
|
2104
|
-
const regenerateArrayState = (0,
|
2110
|
+
const regenerateArrayState = (0, import_react12.useCallback)(
|
2105
2111
|
(value2) => {
|
2106
2112
|
let highestIndex = getHighestIndex();
|
2107
2113
|
const newItems = Array.from(value2 || []).map((item, idx) => {
|
@@ -2120,13 +2126,15 @@ var ArrayField = ({
|
|
2120
2126
|
},
|
2121
2127
|
[arrayState]
|
2122
2128
|
);
|
2123
|
-
(0,
|
2129
|
+
(0, import_react12.useEffect)(() => {
|
2124
2130
|
if (arrayState.items.length > 0) {
|
2125
2131
|
setUi(mapArrayStateToUi(arrayState));
|
2126
2132
|
}
|
2127
2133
|
}, []);
|
2128
|
-
const [
|
2134
|
+
const [draggedItem, setDraggedItem] = (0, import_react12.useState)("");
|
2135
|
+
const isDragging = !!draggedItem;
|
2129
2136
|
const forceReadOnly = getPermissions({ item: selectedItem }).edit === false;
|
2137
|
+
const valueRef = (0, import_react12.useRef)(value);
|
2130
2138
|
if (field.type !== "array" || !field.arrayFields) {
|
2131
2139
|
return null;
|
2132
2140
|
}
|
@@ -2141,10 +2149,17 @@ var ArrayField = ({
|
|
2141
2149
|
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
2142
2150
|
SortableProvider,
|
2143
2151
|
{
|
2144
|
-
onDragStart: () =>
|
2145
|
-
onDragEnd: () =>
|
2152
|
+
onDragStart: (id2) => setDraggedItem(id2),
|
2153
|
+
onDragEnd: () => {
|
2154
|
+
setDraggedItem("");
|
2155
|
+
onChange(valueRef.current);
|
2156
|
+
},
|
2146
2157
|
onMove: (move) => {
|
2147
|
-
|
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);
|
2148
2163
|
const newArrayStateItems = reorder(
|
2149
2164
|
arrayState.items,
|
2150
2165
|
move.source,
|
@@ -2156,11 +2171,11 @@ var ArrayField = ({
|
|
2156
2171
|
})
|
2157
2172
|
};
|
2158
2173
|
setUi(newUi, false);
|
2159
|
-
onChange(newValue, newUi);
|
2160
2174
|
setLocalState({
|
2161
2175
|
value: newValue,
|
2162
2176
|
arrayState: __spreadProps(__spreadValues({}, arrayState), { items: newArrayStateItems })
|
2163
2177
|
});
|
2178
|
+
valueRef.current = newValue;
|
2164
2179
|
},
|
2165
2180
|
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
2166
2181
|
"div",
|
@@ -2169,11 +2184,8 @@ var ArrayField = ({
|
|
2169
2184
|
hasItems: Array.isArray(value) && value.length > 0,
|
2170
2185
|
addDisabled
|
2171
2186
|
}),
|
2172
|
-
onClick: (e) => {
|
2173
|
-
e.preventDefault();
|
2174
|
-
},
|
2175
2187
|
children: [
|
2176
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: getClassName5("inner"), "data-dnd-container": true, children: localState.arrayState.items.map((item, i) => {
|
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) => {
|
2177
2189
|
const { _arrayId = `${id}-${i}`, _originalIndex = i } = item;
|
2178
2190
|
const data = Array.from(localState.value || [])[i] || {};
|
2179
2191
|
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
@@ -2182,7 +2194,7 @@ var ArrayField = ({
|
|
2182
2194
|
id: _arrayId,
|
2183
2195
|
index: i,
|
2184
2196
|
disabled: readOnly,
|
2185
|
-
children: ({ status, ref }) => /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
2197
|
+
children: ({ status, ref, handleRef }) => /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
2186
2198
|
"div",
|
2187
2199
|
{
|
2188
2200
|
ref,
|
@@ -2195,6 +2207,7 @@ var ArrayField = ({
|
|
2195
2207
|
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
2196
2208
|
"div",
|
2197
2209
|
{
|
2210
|
+
ref: handleRef,
|
2198
2211
|
onClick: (e) => {
|
2199
2212
|
if (isDragging) return;
|
2200
2213
|
e.preventDefault();
|
@@ -2231,12 +2244,11 @@ var ArrayField = ({
|
|
2231
2244
|
0,
|
2232
2245
|
existingValue[i]
|
2233
2246
|
);
|
2234
|
-
|
2235
|
-
existingValue
|
2236
|
-
mapArrayStateToUi(
|
2237
|
-
regenerateArrayState(existingValue)
|
2238
|
-
)
|
2247
|
+
const newUi = mapArrayStateToUi(
|
2248
|
+
regenerateArrayState(existingValue)
|
2239
2249
|
);
|
2250
|
+
setUi(newUi, false);
|
2251
|
+
onChange(existingValue, newUi);
|
2240
2252
|
},
|
2241
2253
|
title: "Duplicate",
|
2242
2254
|
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Copy, { size: 16 })
|
@@ -2255,12 +2267,11 @@ var ArrayField = ({
|
|
2255
2267
|
];
|
2256
2268
|
existingValue.splice(i, 1);
|
2257
2269
|
existingItems.splice(i, 1);
|
2258
|
-
|
2259
|
-
|
2260
|
-
|
2261
|
-
|
2262
|
-
|
2263
|
-
);
|
2270
|
+
const newUi = mapArrayStateToUi({
|
2271
|
+
items: existingItems
|
2272
|
+
});
|
2273
|
+
setUi(newUi, false);
|
2274
|
+
onChange(existingValue, newUi);
|
2264
2275
|
},
|
2265
2276
|
title: "Delete",
|
2266
2277
|
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Trash, { size: 16 })
|
@@ -2272,58 +2283,49 @@ var ArrayField = ({
|
|
2272
2283
|
]
|
2273
2284
|
}
|
2274
2285
|
),
|
2275
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: getClassNameItem("body"), children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
2276
|
-
|
2277
|
-
{
|
2278
|
-
|
2279
|
-
|
2280
|
-
|
2281
|
-
|
2282
|
-
|
2283
|
-
|
2284
|
-
|
2285
|
-
|
2286
|
-
|
2287
|
-
|
2288
|
-
|
2289
|
-
|
2290
|
-
|
2291
|
-
|
2292
|
-
|
2293
|
-
|
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,
|
2294
2305
|
{
|
2295
|
-
name:
|
2296
|
-
|
2297
|
-
subName
|
2298
|
-
|
2299
|
-
|
2300
|
-
|
2301
|
-
|
2302
|
-
|
2303
|
-
|
2304
|
-
|
2305
|
-
|
2306
|
-
|
2307
|
-
|
2308
|
-
|
2309
|
-
|
2310
|
-
|
2311
|
-
|
2312
|
-
|
2313
|
-
|
2314
|
-
|
2315
|
-
|
2316
|
-
|
2317
|
-
|
2318
|
-
}
|
2319
|
-
}
|
2320
|
-
)
|
2321
|
-
},
|
2322
|
-
subPath
|
2323
|
-
);
|
2324
|
-
})
|
2325
|
-
}
|
2326
|
-
) })
|
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
|
+
}) }) })
|
2327
2329
|
]
|
2328
2330
|
}
|
2329
2331
|
)
|
@@ -2344,7 +2346,9 @@ var ArrayField = ({
|
|
2344
2346
|
field.defaultItemProps || {}
|
2345
2347
|
];
|
2346
2348
|
const newArrayState = regenerateArrayState(newValue);
|
2347
|
-
|
2349
|
+
const newUi = mapArrayStateToUi(newArrayState);
|
2350
|
+
setUi(newUi, false);
|
2351
|
+
onChange(newValue, newUi);
|
2348
2352
|
},
|
2349
2353
|
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Plus, { size: 21 })
|
2350
2354
|
}
|
@@ -2418,11 +2422,11 @@ var DefaultField = ({
|
|
2418
2422
|
|
2419
2423
|
// components/AutoField/fields/ExternalField/index.tsx
|
2420
2424
|
init_react_import();
|
2421
|
-
var
|
2425
|
+
var import_react16 = require("react");
|
2422
2426
|
|
2423
2427
|
// components/ExternalInput/index.tsx
|
2424
2428
|
init_react_import();
|
2425
|
-
var
|
2429
|
+
var import_react15 = require("react");
|
2426
2430
|
|
2427
2431
|
// css-module:/home/runner/work/puck/puck/packages/core/components/ExternalInput/styles.module.css#css-module
|
2428
2432
|
init_react_import();
|
@@ -2430,7 +2434,7 @@ var styles_module_default6 = { "ExternalInput-actions": "_ExternalInput-actions_
|
|
2430
2434
|
|
2431
2435
|
// components/Modal/index.tsx
|
2432
2436
|
init_react_import();
|
2433
|
-
var
|
2437
|
+
var import_react13 = require("react");
|
2434
2438
|
|
2435
2439
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Modal/styles.module.css#css-module
|
2436
2440
|
init_react_import();
|
@@ -2445,8 +2449,8 @@ var Modal = ({
|
|
2445
2449
|
onClose,
|
2446
2450
|
isOpen
|
2447
2451
|
}) => {
|
2448
|
-
const [rootEl, setRootEl] = (0,
|
2449
|
-
(0,
|
2452
|
+
const [rootEl, setRootEl] = (0, import_react13.useState)(null);
|
2453
|
+
(0, import_react13.useEffect)(() => {
|
2450
2454
|
setRootEl(document.getElementById("puck-portal-root"));
|
2451
2455
|
}, []);
|
2452
2456
|
if (!rootEl) {
|
@@ -2493,7 +2497,7 @@ init_react_import();
|
|
2493
2497
|
|
2494
2498
|
// components/Button/Button.tsx
|
2495
2499
|
init_react_import();
|
2496
|
-
var
|
2500
|
+
var import_react14 = require("react");
|
2497
2501
|
|
2498
2502
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Button/Button.module.css#css-module
|
2499
2503
|
init_react_import();
|
@@ -2543,8 +2547,8 @@ var Button = (_a) => {
|
|
2543
2547
|
"size",
|
2544
2548
|
"loading"
|
2545
2549
|
]);
|
2546
|
-
const [loading, setLoading] = (0,
|
2547
|
-
(0,
|
2550
|
+
const [loading, setLoading] = (0, import_react14.useState)(loadingProp);
|
2551
|
+
(0, import_react14.useEffect)(() => setLoading(loadingProp), [loadingProp]);
|
2548
2552
|
const ElementType = href ? "a" : type ? "button" : "span";
|
2549
2553
|
const dataAttrs = filterDataAttrs(props);
|
2550
2554
|
const el = /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
@@ -2599,28 +2603,28 @@ var ExternalInput = ({
|
|
2599
2603
|
mapRow = (val) => val,
|
2600
2604
|
filterFields
|
2601
2605
|
} = field || {};
|
2602
|
-
const [data, setData] = (0,
|
2603
|
-
const [isOpen, setOpen] = (0,
|
2604
|
-
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);
|
2605
2609
|
const hasFilterFields = !!filterFields;
|
2606
|
-
const [filters, setFilters] = (0,
|
2607
|
-
const [filtersToggled, setFiltersToggled] = (0,
|
2608
|
-
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)(() => {
|
2609
2613
|
return data.map(mapRow);
|
2610
2614
|
}, [data]);
|
2611
|
-
const keys = (0,
|
2615
|
+
const keys = (0, import_react15.useMemo)(() => {
|
2612
2616
|
const validKeys = /* @__PURE__ */ new Set();
|
2613
2617
|
for (const item of mappedData) {
|
2614
2618
|
for (const key of Object.keys(item)) {
|
2615
|
-
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])) {
|
2616
2620
|
validKeys.add(key);
|
2617
2621
|
}
|
2618
2622
|
}
|
2619
2623
|
}
|
2620
2624
|
return Array.from(validKeys);
|
2621
2625
|
}, [mappedData]);
|
2622
|
-
const [searchQuery, setSearchQuery] = (0,
|
2623
|
-
const search = (0,
|
2626
|
+
const [searchQuery, setSearchQuery] = (0, import_react15.useState)(field.initialQuery || "");
|
2627
|
+
const search = (0, import_react15.useCallback)(
|
2624
2628
|
(query, filters2) => __async(void 0, null, function* () {
|
2625
2629
|
setIsLoading(true);
|
2626
2630
|
const cacheKey = `${id}-${query}-${JSON.stringify(filters2)}`;
|
@@ -2633,7 +2637,7 @@ var ExternalInput = ({
|
|
2633
2637
|
}),
|
2634
2638
|
[id, field]
|
2635
2639
|
);
|
2636
|
-
const Footer = (0,
|
2640
|
+
const Footer = (0, import_react15.useCallback)(
|
2637
2641
|
(props) => field.renderFooter ? field.renderFooter(props) : /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("span", { className: getClassNameModal("footer"), children: [
|
2638
2642
|
props.items.length,
|
2639
2643
|
" result",
|
@@ -2641,7 +2645,7 @@ var ExternalInput = ({
|
|
2641
2645
|
] }),
|
2642
2646
|
[field.renderFooter]
|
2643
2647
|
);
|
2644
|
-
(0,
|
2648
|
+
(0, import_react15.useEffect)(() => {
|
2645
2649
|
search(searchQuery, filters);
|
2646
2650
|
}, []);
|
2647
2651
|
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
|
@@ -2812,7 +2816,7 @@ var ExternalField = ({
|
|
2812
2816
|
var _a, _b, _c;
|
2813
2817
|
const validField = field;
|
2814
2818
|
const deprecatedField = field;
|
2815
|
-
(0,
|
2819
|
+
(0, import_react16.useEffect)(() => {
|
2816
2820
|
if (deprecatedField.adaptor) {
|
2817
2821
|
console.error(
|
2818
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."
|
@@ -2847,7 +2851,7 @@ var ExternalField = ({
|
|
2847
2851
|
|
2848
2852
|
// components/AutoField/fields/RadioField/index.tsx
|
2849
2853
|
init_react_import();
|
2850
|
-
var
|
2854
|
+
var import_react17 = require("react");
|
2851
2855
|
|
2852
2856
|
// lib/safe-json-parse.ts
|
2853
2857
|
init_react_import();
|
@@ -2873,7 +2877,7 @@ var RadioField = ({
|
|
2873
2877
|
label,
|
2874
2878
|
Label: Label2
|
2875
2879
|
}) => {
|
2876
|
-
const flatOptions = (0,
|
2880
|
+
const flatOptions = (0, import_react17.useMemo)(
|
2877
2881
|
() => field.type === "radio" ? field.options.map(({ value: value2 }) => value2) : [],
|
2878
2882
|
[field]
|
2879
2883
|
);
|
@@ -2923,7 +2927,7 @@ var RadioField = ({
|
|
2923
2927
|
|
2924
2928
|
// components/AutoField/fields/SelectField/index.tsx
|
2925
2929
|
init_react_import();
|
2926
|
-
var
|
2930
|
+
var import_react18 = require("react");
|
2927
2931
|
var import_jsx_runtime16 = require("react/jsx-runtime");
|
2928
2932
|
var getClassName12 = get_class_name_factory_default("Input", styles_module_default2);
|
2929
2933
|
var SelectField = ({
|
@@ -2936,7 +2940,7 @@ var SelectField = ({
|
|
2936
2940
|
readOnly,
|
2937
2941
|
id
|
2938
2942
|
}) => {
|
2939
|
-
const flatOptions = (0,
|
2943
|
+
const flatOptions = (0, import_react18.useMemo)(
|
2940
2944
|
() => field.type === "select" ? field.options.map(({ value: value2 }) => value2) : [],
|
2941
2945
|
[field]
|
2942
2946
|
);
|
@@ -3088,7 +3092,7 @@ var ObjectField = ({
|
|
3088
3092
|
|
3089
3093
|
// lib/use-safe-id.ts
|
3090
3094
|
init_react_import();
|
3091
|
-
var
|
3095
|
+
var import_react19 = __toESM(require("react"));
|
3092
3096
|
|
3093
3097
|
// lib/generate-id.ts
|
3094
3098
|
init_react_import();
|
@@ -3097,10 +3101,10 @@ var generateId = (type) => type ? `${type}-${(0, import_uuid.v4)()}` : (0, impor
|
|
3097
3101
|
|
3098
3102
|
// lib/use-safe-id.ts
|
3099
3103
|
var useSafeId = () => {
|
3100
|
-
if (typeof
|
3101
|
-
return
|
3104
|
+
if (typeof import_react19.default.useId !== "undefined") {
|
3105
|
+
return import_react19.default.useId();
|
3102
3106
|
}
|
3103
|
-
const [id] = (0,
|
3107
|
+
const [id] = (0, import_react19.useState)(generateId());
|
3104
3108
|
return id;
|
3105
3109
|
};
|
3106
3110
|
|
@@ -3134,7 +3138,7 @@ var FieldLabelInternal = ({
|
|
3134
3138
|
readOnly
|
3135
3139
|
}) => {
|
3136
3140
|
const { overrides } = useAppContext();
|
3137
|
-
const Wrapper = (0,
|
3141
|
+
const Wrapper = (0, import_react20.useMemo)(
|
3138
3142
|
() => overrides.fieldLabel || FieldLabel,
|
3139
3143
|
[overrides]
|
3140
3144
|
);
|
@@ -3156,7 +3160,7 @@ var FieldLabelInternal = ({
|
|
3156
3160
|
function AutoFieldInternal(props) {
|
3157
3161
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
3158
3162
|
const { dispatch, overrides, selectedItem } = useAppContext();
|
3159
|
-
const nestedFieldContext = (0,
|
3163
|
+
const nestedFieldContext = (0, import_react20.useContext)(NestedFieldContext);
|
3160
3164
|
const { id, Label: Label2 = FieldLabelInternal } = props;
|
3161
3165
|
const field = props.field;
|
3162
3166
|
const label = field.label;
|
@@ -3188,7 +3192,7 @@ function AutoFieldInternal(props) {
|
|
3188
3192
|
Label: Label2,
|
3189
3193
|
id: resolvedId
|
3190
3194
|
});
|
3191
|
-
const onFocus = (0,
|
3195
|
+
const onFocus = (0, import_react20.useCallback)(
|
3192
3196
|
(e) => {
|
3193
3197
|
if (mergedProps.name && (e.target.nodeName === "INPUT" || e.target.nodeName === "TEXTAREA")) {
|
3194
3198
|
e.stopPropagation();
|
@@ -3202,7 +3206,7 @@ function AutoFieldInternal(props) {
|
|
3202
3206
|
},
|
3203
3207
|
[mergedProps.name]
|
3204
3208
|
);
|
3205
|
-
const onBlur = (0,
|
3209
|
+
const onBlur = (0, import_react20.useCallback)((e) => {
|
3206
3210
|
if ("name" in e.target) {
|
3207
3211
|
dispatch({
|
3208
3212
|
type: "setUi",
|
@@ -3246,7 +3250,7 @@ function AutoFieldInternal(props) {
|
|
3246
3250
|
function AutoFieldPrivate(props) {
|
3247
3251
|
const { state } = useAppContext();
|
3248
3252
|
const { value, onChange } = props;
|
3249
|
-
const [localValue, setLocalValue] = (0,
|
3253
|
+
const [localValue, setLocalValue] = (0, import_react20.useState)(value);
|
3250
3254
|
const onChangeDb = (0, import_use_debounce.useDebouncedCallback)(
|
3251
3255
|
(val, ui) => {
|
3252
3256
|
onChange(val, ui);
|
@@ -3254,11 +3258,14 @@ function AutoFieldPrivate(props) {
|
|
3254
3258
|
50,
|
3255
3259
|
{ leading: true }
|
3256
3260
|
);
|
3257
|
-
const onChangeLocal = (0,
|
3258
|
-
|
3259
|
-
|
3260
|
-
|
3261
|
-
|
3261
|
+
const onChangeLocal = (0, import_react20.useCallback)(
|
3262
|
+
(val, ui) => {
|
3263
|
+
setLocalValue(val);
|
3264
|
+
onChangeDb(val, ui);
|
3265
|
+
},
|
3266
|
+
[onChange]
|
3267
|
+
);
|
3268
|
+
(0, import_react20.useEffect)(() => {
|
3262
3269
|
if (state.ui.field.focus !== props.name) {
|
3263
3270
|
setLocalValue(value);
|
3264
3271
|
}
|
@@ -3270,7 +3277,7 @@ function AutoFieldPrivate(props) {
|
|
3270
3277
|
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(AutoFieldInternal, __spreadValues(__spreadValues({}, props), localProps));
|
3271
3278
|
}
|
3272
3279
|
function AutoField(props) {
|
3273
|
-
const DefaultLabel = (0,
|
3280
|
+
const DefaultLabel = (0, import_react20.useMemo)(() => {
|
3274
3281
|
const DefaultLabel2 = (labelProps) => /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
3275
3282
|
"div",
|
3276
3283
|
__spreadProps(__spreadValues({}, labelProps), {
|
@@ -3290,21 +3297,21 @@ init_react_import();
|
|
3290
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" };
|
3291
3298
|
|
3292
3299
|
// components/Drawer/index.tsx
|
3293
|
-
var
|
3300
|
+
var import_react32 = require("react");
|
3294
3301
|
|
3295
3302
|
// components/DragDropContext/index.tsx
|
3296
3303
|
init_react_import();
|
3297
|
-
var
|
3298
|
-
var
|
3304
|
+
var import_react30 = require("@dnd-kit/react");
|
3305
|
+
var import_react31 = require("react");
|
3299
3306
|
var import_dom = require("@dnd-kit/dom");
|
3300
3307
|
|
3301
3308
|
// components/DropZone/index.tsx
|
3302
3309
|
init_react_import();
|
3303
|
-
var
|
3310
|
+
var import_react29 = require("react");
|
3304
3311
|
|
3305
3312
|
// components/DraggableComponent/index.tsx
|
3306
3313
|
init_react_import();
|
3307
|
-
var
|
3314
|
+
var import_react23 = require("react");
|
3308
3315
|
|
3309
3316
|
// css-module:/home/runner/work/puck/puck/packages/core/components/DraggableComponent/styles.module.css#css-module
|
3310
3317
|
init_react_import();
|
@@ -3334,11 +3341,11 @@ function getDeepScrollPosition(element) {
|
|
3334
3341
|
|
3335
3342
|
// components/DropZone/context.tsx
|
3336
3343
|
init_react_import();
|
3337
|
-
var
|
3344
|
+
var import_react21 = require("react");
|
3338
3345
|
var import_zustand = require("zustand");
|
3339
3346
|
var import_jsx_runtime20 = require("react/jsx-runtime");
|
3340
|
-
var dropZoneContext = (0,
|
3341
|
-
var ZoneStoreContext = (0,
|
3347
|
+
var dropZoneContext = (0, import_react21.createContext)(null);
|
3348
|
+
var ZoneStoreContext = (0, import_react21.createContext)(
|
3342
3349
|
(0, import_zustand.createStore)(() => ({
|
3343
3350
|
zoneDepthIndex: {},
|
3344
3351
|
nextZoneDepthIndex: {},
|
@@ -3358,19 +3365,19 @@ var DropZoneProvider = ({
|
|
3358
3365
|
children,
|
3359
3366
|
value
|
3360
3367
|
}) => {
|
3361
|
-
const [hoveringComponent, setHoveringComponent] = (0,
|
3362
|
-
const [areasWithZones, setAreasWithZones] = (0,
|
3368
|
+
const [hoveringComponent, setHoveringComponent] = (0, import_react21.useState)();
|
3369
|
+
const [areasWithZones, setAreasWithZones] = (0, import_react21.useState)(
|
3363
3370
|
{}
|
3364
3371
|
);
|
3365
|
-
const [activeZones, setActiveZones] = (0,
|
3372
|
+
const [activeZones, setActiveZones] = (0, import_react21.useState)({});
|
3366
3373
|
const { dispatch } = useAppContext();
|
3367
|
-
const registerZoneArea = (0,
|
3374
|
+
const registerZoneArea = (0, import_react21.useCallback)(
|
3368
3375
|
(area) => {
|
3369
3376
|
setAreasWithZones((latest) => __spreadProps(__spreadValues({}, latest), { [area]: true }));
|
3370
3377
|
},
|
3371
3378
|
[setAreasWithZones]
|
3372
3379
|
);
|
3373
|
-
const registerZone = (0,
|
3380
|
+
const registerZone = (0, import_react21.useCallback)(
|
3374
3381
|
(zoneCompound) => {
|
3375
3382
|
if (!dispatch) {
|
3376
3383
|
return;
|
@@ -3383,7 +3390,7 @@ var DropZoneProvider = ({
|
|
3383
3390
|
},
|
3384
3391
|
[setActiveZones, dispatch]
|
3385
3392
|
);
|
3386
|
-
const unregisterZone = (0,
|
3393
|
+
const unregisterZone = (0, import_react21.useCallback)(
|
3387
3394
|
(zoneCompound) => {
|
3388
3395
|
if (!dispatch) {
|
3389
3396
|
return;
|
@@ -3398,7 +3405,7 @@ var DropZoneProvider = ({
|
|
3398
3405
|
},
|
3399
3406
|
[setActiveZones, dispatch]
|
3400
3407
|
);
|
3401
|
-
const memoValue = (0,
|
3408
|
+
const memoValue = (0, import_react21.useMemo)(
|
3402
3409
|
() => __spreadValues({
|
3403
3410
|
hoveringComponent,
|
3404
3411
|
setHoveringComponent,
|
@@ -3415,11 +3422,11 @@ var DropZoneProvider = ({
|
|
3415
3422
|
|
3416
3423
|
// lib/use-context-store.ts
|
3417
3424
|
init_react_import();
|
3418
|
-
var
|
3425
|
+
var import_react22 = require("react");
|
3419
3426
|
var import_zustand2 = require("zustand");
|
3420
3427
|
var import_shallow = require("zustand/react/shallow");
|
3421
3428
|
function useContextStore(context, selector) {
|
3422
|
-
const store = (0,
|
3429
|
+
const store = (0, import_react22.useContext)(context);
|
3423
3430
|
if (!store) {
|
3424
3431
|
throw new Error("useContextStore must be used inside context");
|
3425
3432
|
}
|
@@ -3478,9 +3485,9 @@ var DraggableComponent = ({
|
|
3478
3485
|
iframe,
|
3479
3486
|
state
|
3480
3487
|
} = useAppContext();
|
3481
|
-
const ctx = (0,
|
3482
|
-
const [localZones, setLocalZones] = (0,
|
3483
|
-
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)(
|
3484
3491
|
(zoneCompound2, active) => {
|
3485
3492
|
var _a;
|
3486
3493
|
(_a = ctx == null ? void 0 : ctx.registerLocalZone) == null ? void 0 : _a.call(ctx, zoneCompound2, active);
|
@@ -3490,7 +3497,7 @@ var DraggableComponent = ({
|
|
3490
3497
|
},
|
3491
3498
|
[setLocalZones]
|
3492
3499
|
);
|
3493
|
-
const unregisterLocalZone = (0,
|
3500
|
+
const unregisterLocalZone = (0, import_react23.useCallback)(
|
3494
3501
|
(zoneCompound2) => {
|
3495
3502
|
var _a;
|
3496
3503
|
(_a = ctx == null ? void 0 : ctx.unregisterLocalZone) == null ? void 0 : _a.call(ctx, zoneCompound2);
|
@@ -3504,8 +3511,8 @@ var DraggableComponent = ({
|
|
3504
3511
|
);
|
3505
3512
|
const containsActiveZone = Object.values(localZones).filter(Boolean).length > 0;
|
3506
3513
|
const { path = [] } = ctx || {};
|
3507
|
-
const [canDrag, setCanDrag] = (0,
|
3508
|
-
(0,
|
3514
|
+
const [canDrag, setCanDrag] = (0, import_react23.useState)(false);
|
3515
|
+
(0, import_react23.useEffect)(() => {
|
3509
3516
|
var _a;
|
3510
3517
|
const item = getItem({ index, zone: zoneCompound }, state.data);
|
3511
3518
|
if (item) {
|
@@ -3521,7 +3528,7 @@ var DraggableComponent = ({
|
|
3521
3528
|
);
|
3522
3529
|
const canCollide = canDrag || userIsDragging;
|
3523
3530
|
const disabled = !isEnabled || !canCollide;
|
3524
|
-
const [dragAxis, setDragAxis] = (0,
|
3531
|
+
const [dragAxis, setDragAxis] = (0, import_react23.useState)(userDragAxis || autoDragAxis);
|
3525
3532
|
const { ref: sortableRef, status } = useSortableSafe({
|
3526
3533
|
id,
|
3527
3534
|
index,
|
@@ -3547,8 +3554,8 @@ var DraggableComponent = ({
|
|
3547
3554
|
}
|
3548
3555
|
});
|
3549
3556
|
const thisIsDragging = status === "dragging";
|
3550
|
-
const ref = (0,
|
3551
|
-
const refSetter = (0,
|
3557
|
+
const ref = (0, import_react23.useRef)(null);
|
3558
|
+
const refSetter = (0, import_react23.useCallback)(
|
3552
3559
|
(el) => {
|
3553
3560
|
sortableRef(el);
|
3554
3561
|
if (el) {
|
@@ -3557,14 +3564,14 @@ var DraggableComponent = ({
|
|
3557
3564
|
},
|
3558
3565
|
[sortableRef]
|
3559
3566
|
);
|
3560
|
-
const [portalEl, setPortalEl] = (0,
|
3561
|
-
(0,
|
3567
|
+
const [portalEl, setPortalEl] = (0, import_react23.useState)();
|
3568
|
+
(0, import_react23.useEffect)(() => {
|
3562
3569
|
var _a, _b, _c;
|
3563
3570
|
setPortalEl(
|
3564
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
|
3565
3572
|
);
|
3566
3573
|
}, [iframe.enabled, ref.current]);
|
3567
|
-
const getStyle = (0,
|
3574
|
+
const getStyle = (0, import_react23.useCallback)(() => {
|
3568
3575
|
var _a, _b, _c;
|
3569
3576
|
if (!ref.current) return;
|
3570
3577
|
const rect = ref.current.getBoundingClientRect();
|
@@ -3584,11 +3591,11 @@ var DraggableComponent = ({
|
|
3584
3591
|
};
|
3585
3592
|
return style2;
|
3586
3593
|
}, [ref.current]);
|
3587
|
-
const [style, setStyle] = (0,
|
3588
|
-
const sync = (0,
|
3594
|
+
const [style, setStyle] = (0, import_react23.useState)();
|
3595
|
+
const sync = (0, import_react23.useCallback)(() => {
|
3589
3596
|
setStyle(getStyle());
|
3590
3597
|
}, [ref.current, iframe]);
|
3591
|
-
(0,
|
3598
|
+
(0, import_react23.useEffect)(() => {
|
3592
3599
|
if (ref.current && !userIsDragging) {
|
3593
3600
|
const observer = new ResizeObserver(sync);
|
3594
3601
|
observer.observe(ref.current);
|
@@ -3597,7 +3604,7 @@ var DraggableComponent = ({
|
|
3597
3604
|
};
|
3598
3605
|
}
|
3599
3606
|
}, [ref.current, userIsDragging]);
|
3600
|
-
(0,
|
3607
|
+
(0, import_react23.useEffect)(() => {
|
3601
3608
|
ctx == null ? void 0 : ctx.registerPath(
|
3602
3609
|
id,
|
3603
3610
|
{
|
@@ -3611,14 +3618,14 @@ var DraggableComponent = ({
|
|
3611
3618
|
(_a = ctx == null ? void 0 : ctx.unregisterPath) == null ? void 0 : _a.call(ctx, id);
|
3612
3619
|
};
|
3613
3620
|
}, [id, zoneCompound, index, componentType]);
|
3614
|
-
const CustomActionBar = (0,
|
3621
|
+
const CustomActionBar = (0, import_react23.useMemo)(
|
3615
3622
|
() => overrides.actionBar || DefaultActionBar,
|
3616
3623
|
[overrides.actionBar]
|
3617
3624
|
);
|
3618
3625
|
const permissions = getPermissions({
|
3619
3626
|
item: selectedItem
|
3620
3627
|
});
|
3621
|
-
const onClick = (0,
|
3628
|
+
const onClick = (0, import_react23.useCallback)(
|
3622
3629
|
(e) => {
|
3623
3630
|
e.stopPropagation();
|
3624
3631
|
dispatch({
|
@@ -3630,7 +3637,7 @@ var DraggableComponent = ({
|
|
3630
3637
|
},
|
3631
3638
|
[index, zoneCompound, id]
|
3632
3639
|
);
|
3633
|
-
const onSelectParent = (0,
|
3640
|
+
const onSelectParent = (0, import_react23.useCallback)(() => {
|
3634
3641
|
if (!(ctx == null ? void 0 : ctx.areaId)) {
|
3635
3642
|
return;
|
3636
3643
|
}
|
@@ -3648,23 +3655,23 @@ var DraggableComponent = ({
|
|
3648
3655
|
}
|
3649
3656
|
});
|
3650
3657
|
}, [ctx, path]);
|
3651
|
-
const onDuplicate = (0,
|
3658
|
+
const onDuplicate = (0, import_react23.useCallback)(() => {
|
3652
3659
|
dispatch({
|
3653
3660
|
type: "duplicate",
|
3654
3661
|
sourceIndex: index,
|
3655
3662
|
sourceZone: zoneCompound
|
3656
3663
|
});
|
3657
3664
|
}, [index, zoneCompound]);
|
3658
|
-
const onDelete = (0,
|
3665
|
+
const onDelete = (0, import_react23.useCallback)(() => {
|
3659
3666
|
dispatch({
|
3660
3667
|
type: "remove",
|
3661
3668
|
index,
|
3662
3669
|
zone: zoneCompound
|
3663
3670
|
});
|
3664
3671
|
}, [index, zoneCompound]);
|
3665
|
-
const [hover, setHover] = (0,
|
3672
|
+
const [hover, setHover] = (0, import_react23.useState)(false);
|
3666
3673
|
const indicativeHover = (ctx == null ? void 0 : ctx.hoveringComponent) === id;
|
3667
|
-
(0,
|
3674
|
+
(0, import_react23.useEffect)(() => {
|
3668
3675
|
if (!ref.current) {
|
3669
3676
|
return;
|
3670
3677
|
}
|
@@ -3714,7 +3721,7 @@ var DraggableComponent = ({
|
|
3714
3721
|
thisIsDragging,
|
3715
3722
|
inDroppableZone
|
3716
3723
|
]);
|
3717
|
-
(0,
|
3724
|
+
(0, import_react23.useEffect)(() => {
|
3718
3725
|
if (ref.current && disabled) {
|
3719
3726
|
ref.current.setAttribute("data-puck-disabled", "");
|
3720
3727
|
return () => {
|
@@ -3723,8 +3730,8 @@ var DraggableComponent = ({
|
|
3723
3730
|
};
|
3724
3731
|
}
|
3725
3732
|
}, [disabled, ref]);
|
3726
|
-
const [isVisible, setIsVisible] = (0,
|
3727
|
-
(0,
|
3733
|
+
const [isVisible, setIsVisible] = (0, import_react23.useState)(false);
|
3734
|
+
(0, import_react23.useEffect)(() => {
|
3728
3735
|
sync();
|
3729
3736
|
if ((isSelected || hover || indicativeHover) && !userIsDragging) {
|
3730
3737
|
setIsVisible(true);
|
@@ -3732,7 +3739,7 @@ var DraggableComponent = ({
|
|
3732
3739
|
setIsVisible(false);
|
3733
3740
|
}
|
3734
3741
|
}, [isSelected, hover, indicativeHover, iframe, state.data, userIsDragging]);
|
3735
|
-
const syncActionsPosition = (0,
|
3742
|
+
const syncActionsPosition = (0, import_react23.useCallback)(
|
3736
3743
|
(el) => {
|
3737
3744
|
if (el) {
|
3738
3745
|
const view = el.ownerDocument.defaultView;
|
@@ -3740,16 +3747,24 @@ var DraggableComponent = ({
|
|
3740
3747
|
const rect = el.getBoundingClientRect();
|
3741
3748
|
const diffLeft = rect.x;
|
3742
3749
|
const exceedsBoundsLeft = diffLeft < 0;
|
3750
|
+
const diffTop = rect.y;
|
3751
|
+
const exceedsBoundsTop = diffTop < 0;
|
3743
3752
|
if (exceedsBoundsLeft) {
|
3744
3753
|
el.style.transformOrigin = "left top";
|
3745
3754
|
el.style.left = "0px";
|
3746
3755
|
}
|
3756
|
+
if (exceedsBoundsTop) {
|
3757
|
+
el.style.top = "12px";
|
3758
|
+
if (!exceedsBoundsLeft) {
|
3759
|
+
el.style.transformOrigin = "right top";
|
3760
|
+
}
|
3761
|
+
}
|
3747
3762
|
}
|
3748
3763
|
}
|
3749
3764
|
},
|
3750
3765
|
[zoomConfig]
|
3751
3766
|
);
|
3752
|
-
(0,
|
3767
|
+
(0, import_react23.useEffect)(() => {
|
3753
3768
|
if (userDragAxis) {
|
3754
3769
|
setDragAxis(userDragAxis);
|
3755
3770
|
return;
|
@@ -3843,14 +3858,14 @@ var styles_module_default12 = { "DropZone": "_DropZone_kmkdc_1", "DropZone--isAc
|
|
3843
3858
|
|
3844
3859
|
// components/DropZone/lib/use-min-empty-height.ts
|
3845
3860
|
init_react_import();
|
3846
|
-
var
|
3861
|
+
var import_react24 = require("react");
|
3847
3862
|
var useMinEmptyHeight = ({
|
3848
3863
|
zoneCompound,
|
3849
3864
|
userMinEmptyHeight,
|
3850
3865
|
ref
|
3851
3866
|
}) => {
|
3852
|
-
const [prevHeight, setPrevHeight] = (0,
|
3853
|
-
const [isAnimating, setIsAnimating] = (0,
|
3867
|
+
const [prevHeight, setPrevHeight] = (0, import_react24.useState)(0);
|
3868
|
+
const [isAnimating, setIsAnimating] = (0, import_react24.useState)(false);
|
3854
3869
|
const { draggedItem, isZone } = useContextStore(ZoneStoreContext, (s) => {
|
3855
3870
|
var _a, _b;
|
3856
3871
|
return {
|
@@ -3858,7 +3873,7 @@ var useMinEmptyHeight = ({
|
|
3858
3873
|
isZone: ((_b = s.draggedItem) == null ? void 0 : _b.data.zone) === zoneCompound
|
3859
3874
|
};
|
3860
3875
|
});
|
3861
|
-
(0,
|
3876
|
+
(0, import_react24.useEffect)(() => {
|
3862
3877
|
if (draggedItem && ref.current) {
|
3863
3878
|
if (isZone) {
|
3864
3879
|
const rect = ref.current.getBoundingClientRect();
|
@@ -3892,15 +3907,15 @@ function assignRefs(refs, node) {
|
|
3892
3907
|
|
3893
3908
|
// components/DropZone/lib/use-content-with-preview.ts
|
3894
3909
|
init_react_import();
|
3895
|
-
var
|
3910
|
+
var import_react27 = require("react");
|
3896
3911
|
|
3897
3912
|
// lib/dnd/use-rendered-callback.ts
|
3898
3913
|
init_react_import();
|
3899
|
-
var
|
3900
|
-
var
|
3914
|
+
var import_react25 = require("@dnd-kit/react");
|
3915
|
+
var import_react26 = require("react");
|
3901
3916
|
function useRenderedCallback(callback, deps) {
|
3902
|
-
const manager = (0,
|
3903
|
-
return (0,
|
3917
|
+
const manager = (0, import_react25.useDragDropManager)();
|
3918
|
+
return (0, import_react26.useCallback)(
|
3904
3919
|
(...args) => __async(this, null, function* () {
|
3905
3920
|
yield manager == null ? void 0 : manager.renderer.rendering;
|
3906
3921
|
return callback(...args);
|
@@ -3935,8 +3950,8 @@ var useContentWithPreview = (content, zoneCompound) => {
|
|
3935
3950
|
ui: { isDragging }
|
3936
3951
|
}
|
3937
3952
|
} = useAppContext();
|
3938
|
-
const [contentWithPreview, setContentWithPreview] = (0,
|
3939
|
-
const [localPreview, setLocalPreview] = (0,
|
3953
|
+
const [contentWithPreview, setContentWithPreview] = (0, import_react27.useState)(content);
|
3954
|
+
const [localPreview, setLocalPreview] = (0, import_react27.useState)(
|
3940
3955
|
preview
|
3941
3956
|
);
|
3942
3957
|
const updateContent = useRenderedCallback(
|
@@ -3977,7 +3992,7 @@ var useContentWithPreview = (content, zoneCompound) => {
|
|
3977
3992
|
},
|
3978
3993
|
[draggedItemId, previewExists]
|
3979
3994
|
);
|
3980
|
-
(0,
|
3995
|
+
(0, import_react27.useEffect)(() => {
|
3981
3996
|
updateContent(content, preview, isDragging);
|
3982
3997
|
}, [content, preview, isDragging]);
|
3983
3998
|
return [contentWithPreview, localPreview];
|
@@ -3985,16 +4000,16 @@ var useContentWithPreview = (content, zoneCompound) => {
|
|
3985
4000
|
|
3986
4001
|
// components/DropZone/lib/use-drag-axis.ts
|
3987
4002
|
init_react_import();
|
3988
|
-
var
|
4003
|
+
var import_react28 = require("react");
|
3989
4004
|
var GRID_DRAG_AXIS = "dynamic";
|
3990
4005
|
var FLEX_ROW_DRAG_AXIS = "x";
|
3991
4006
|
var DEFAULT_DRAG_AXIS = "y";
|
3992
4007
|
var useDragAxis = (ref, collisionAxis) => {
|
3993
4008
|
const { status } = useAppContext();
|
3994
|
-
const [dragAxis, setDragAxis] = (0,
|
4009
|
+
const [dragAxis, setDragAxis] = (0, import_react28.useState)(
|
3995
4010
|
collisionAxis || DEFAULT_DRAG_AXIS
|
3996
4011
|
);
|
3997
|
-
const calculateDragAxis = (0,
|
4012
|
+
const calculateDragAxis = (0, import_react28.useCallback)(() => {
|
3998
4013
|
if (ref.current) {
|
3999
4014
|
const computedStyle = window.getComputedStyle(ref.current);
|
4000
4015
|
if (computedStyle.display === "grid") {
|
@@ -4006,7 +4021,7 @@ var useDragAxis = (ref, collisionAxis) => {
|
|
4006
4021
|
}
|
4007
4022
|
}
|
4008
4023
|
}, [ref.current]);
|
4009
|
-
(0,
|
4024
|
+
(0, import_react28.useEffect)(() => {
|
4010
4025
|
const onViewportChange = () => {
|
4011
4026
|
calculateDragAxis();
|
4012
4027
|
};
|
@@ -4015,7 +4030,7 @@ var useDragAxis = (ref, collisionAxis) => {
|
|
4015
4030
|
window.removeEventListener("viewportchange", onViewportChange);
|
4016
4031
|
};
|
4017
4032
|
}, []);
|
4018
|
-
(0,
|
4033
|
+
(0, import_react28.useEffect)(calculateDragAxis, [status, collisionAxis]);
|
4019
4034
|
return [dragAxis, calculateDragAxis];
|
4020
4035
|
};
|
4021
4036
|
|
@@ -4025,7 +4040,7 @@ var getClassName17 = get_class_name_factory_default("DropZone", styles_module_de
|
|
4025
4040
|
var getRandomColor = () => `#${Math.floor(Math.random() * 16777215).toString(16)}`;
|
4026
4041
|
var RENDER_DEBUG = false;
|
4027
4042
|
var DropZoneEditPure = (props) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(DropZoneEdit, __spreadValues({}, props));
|
4028
|
-
var DropZoneEdit = (0,
|
4043
|
+
var DropZoneEdit = (0, import_react29.forwardRef)(
|
4029
4044
|
function DropZoneEditInternal({
|
4030
4045
|
zone,
|
4031
4046
|
allow,
|
@@ -4036,7 +4051,7 @@ var DropZoneEdit = (0, import_react30.forwardRef)(
|
|
4036
4051
|
collisionAxis
|
4037
4052
|
}, userRef) {
|
4038
4053
|
const appContext2 = useAppContext();
|
4039
|
-
const ctx = (0,
|
4054
|
+
const ctx = (0, import_react29.useContext)(dropZoneContext);
|
4040
4055
|
const {
|
4041
4056
|
// These all need setting via context
|
4042
4057
|
data,
|
@@ -4072,12 +4087,12 @@ var DropZoneEdit = (0, import_react30.forwardRef)(
|
|
4072
4087
|
};
|
4073
4088
|
});
|
4074
4089
|
const { itemSelector } = appContext2.state.ui;
|
4075
|
-
(0,
|
4090
|
+
(0, import_react29.useEffect)(() => {
|
4076
4091
|
if (areaId && registerZoneArea) {
|
4077
4092
|
registerZoneArea(areaId);
|
4078
4093
|
}
|
4079
4094
|
}, [areaId]);
|
4080
|
-
(0,
|
4095
|
+
(0, import_react29.useEffect)(() => {
|
4081
4096
|
if (ctx == null ? void 0 : ctx.registerZone) {
|
4082
4097
|
ctx == null ? void 0 : ctx.registerZone(zoneCompound);
|
4083
4098
|
}
|
@@ -4087,14 +4102,14 @@ var DropZoneEdit = (0, import_react30.forwardRef)(
|
|
4087
4102
|
}
|
4088
4103
|
};
|
4089
4104
|
}, []);
|
4090
|
-
const content = (0,
|
4105
|
+
const content = (0, import_react29.useMemo)(() => {
|
4091
4106
|
if (areaId && zone !== rootDroppableId) {
|
4092
4107
|
return setupZone(data, zoneCompound).zones[zoneCompound];
|
4093
4108
|
}
|
4094
4109
|
return data.content || [];
|
4095
4110
|
}, [data, zoneCompound]);
|
4096
|
-
const ref = (0,
|
4097
|
-
const acceptsTarget = (0,
|
4111
|
+
const ref = (0, import_react29.useRef)(null);
|
4112
|
+
const acceptsTarget = (0, import_react29.useCallback)(
|
4098
4113
|
(componentType) => {
|
4099
4114
|
if (!componentType) {
|
4100
4115
|
return true;
|
@@ -4116,7 +4131,7 @@ var DropZoneEdit = (0, import_react30.forwardRef)(
|
|
4116
4131
|
},
|
4117
4132
|
[allow, disallow]
|
4118
4133
|
);
|
4119
|
-
(0,
|
4134
|
+
(0, import_react29.useEffect)(() => {
|
4120
4135
|
if (registerLocalZone) {
|
4121
4136
|
registerLocalZone(zoneCompound, acceptsTarget(draggedComponentType));
|
4122
4137
|
}
|
@@ -4251,13 +4266,13 @@ var DropZoneEdit = (0, import_react30.forwardRef)(
|
|
4251
4266
|
}
|
4252
4267
|
);
|
4253
4268
|
var DropZoneRenderPure = (props) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(DropZoneRender, __spreadValues({}, props));
|
4254
|
-
var DropZoneRender = (0,
|
4269
|
+
var DropZoneRender = (0, import_react29.forwardRef)(
|
4255
4270
|
function DropZoneRenderInternal({ className, style, zone }, ref) {
|
4256
|
-
const ctx = (0,
|
4271
|
+
const ctx = (0, import_react29.useContext)(dropZoneContext);
|
4257
4272
|
const { data, areaId = "root", config } = ctx || {};
|
4258
4273
|
let zoneCompound = rootDroppableId;
|
4259
4274
|
let content = (data == null ? void 0 : data.content) || [];
|
4260
|
-
(0,
|
4275
|
+
(0, import_react29.useEffect)(() => {
|
4261
4276
|
if (ctx == null ? void 0 : ctx.registerZone) {
|
4262
4277
|
ctx == null ? void 0 : ctx.registerZone(zoneCompound);
|
4263
4278
|
}
|
@@ -4304,9 +4319,9 @@ var DropZoneRender = (0, import_react30.forwardRef)(
|
|
4304
4319
|
}
|
4305
4320
|
);
|
4306
4321
|
var DropZonePure = (props) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(DropZone, __spreadValues({}, props));
|
4307
|
-
var DropZone = (0,
|
4322
|
+
var DropZone = (0, import_react29.forwardRef)(
|
4308
4323
|
function DropZone2(props, ref) {
|
4309
|
-
const ctx = (0,
|
4324
|
+
const ctx = (0, import_react29.useContext)(dropZoneContext);
|
4310
4325
|
if ((ctx == null ? void 0 : ctx.mode) === "edit") {
|
4311
4326
|
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_jsx_runtime22.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(DropZoneEdit, __spreadProps(__spreadValues({}, props), { ref })) });
|
4312
4327
|
}
|
@@ -5001,12 +5016,12 @@ function getDeepDir(el) {
|
|
5001
5016
|
// components/DragDropContext/index.tsx
|
5002
5017
|
var import_jsx_runtime23 = require("react/jsx-runtime");
|
5003
5018
|
var DEBUG3 = false;
|
5004
|
-
var dragListenerContext = (0,
|
5019
|
+
var dragListenerContext = (0, import_react31.createContext)({
|
5005
5020
|
dragListeners: {}
|
5006
5021
|
});
|
5007
5022
|
function useDragListener(type, fn, deps = []) {
|
5008
|
-
const { setDragListeners } = (0,
|
5009
|
-
(0,
|
5023
|
+
const { setDragListeners } = (0, import_react31.useContext)(dragListenerContext);
|
5024
|
+
(0, import_react31.useEffect)(() => {
|
5010
5025
|
if (setDragListeners) {
|
5011
5026
|
setDragListeners((old) => __spreadProps(__spreadValues({}, old), {
|
5012
5027
|
[type]: [...old[type] || [], fn]
|
@@ -5016,8 +5031,8 @@ function useDragListener(type, fn, deps = []) {
|
|
5016
5031
|
}
|
5017
5032
|
var AREA_CHANGE_DEBOUNCE_MS = 100;
|
5018
5033
|
var useTempDisableFallback = (timeout3) => {
|
5019
|
-
const lastFallbackDisable = (0,
|
5020
|
-
return (0,
|
5034
|
+
const lastFallbackDisable = (0, import_react31.useRef)(null);
|
5035
|
+
return (0, import_react31.useCallback)((manager) => {
|
5021
5036
|
collisionStore.setState({ fallbackEnabled: false });
|
5022
5037
|
const fallbackId = generateId();
|
5023
5038
|
lastFallbackDisable.current = fallbackId;
|
@@ -5034,11 +5049,11 @@ var DragDropContextClient = ({
|
|
5034
5049
|
disableAutoScroll
|
5035
5050
|
}) => {
|
5036
5051
|
const { state, config, dispatch, resolveData } = useAppContext();
|
5037
|
-
const id = (0,
|
5052
|
+
const id = (0, import_react31.useId)();
|
5038
5053
|
const { data } = state;
|
5039
|
-
const debouncedParamsRef = (0,
|
5054
|
+
const debouncedParamsRef = (0, import_react31.useRef)(null);
|
5040
5055
|
const tempDisableFallback = useTempDisableFallback(100);
|
5041
|
-
const [zoneStore] = (0,
|
5056
|
+
const [zoneStore] = (0, import_react31.useState)(
|
5042
5057
|
() => (0, import_zustand3.createStore)(() => ({
|
5043
5058
|
zoneDepthIndex: {},
|
5044
5059
|
nextZoneDepthIndex: {},
|
@@ -5048,7 +5063,7 @@ var DragDropContextClient = ({
|
|
5048
5063
|
previewIndex: {}
|
5049
5064
|
}))
|
5050
5065
|
);
|
5051
|
-
const getChanged2 = (0,
|
5066
|
+
const getChanged2 = (0, import_react31.useCallback)(
|
5052
5067
|
(params, id2) => {
|
5053
5068
|
const { zoneDepthIndex = {}, areaDepthIndex = {} } = zoneStore.getState() || {};
|
5054
5069
|
const stateHasZone = Object.keys(zoneDepthIndex).length > 0;
|
@@ -5069,7 +5084,7 @@ var DragDropContextClient = ({
|
|
5069
5084
|
},
|
5070
5085
|
[zoneStore]
|
5071
5086
|
);
|
5072
|
-
const setDeepestAndCollide = (0,
|
5087
|
+
const setDeepestAndCollide = (0, import_react31.useCallback)(
|
5073
5088
|
(params, manager) => {
|
5074
5089
|
const { zoneChanged, areaChanged } = getChanged2(params, id);
|
5075
5090
|
if (!zoneChanged && !areaChanged) return;
|
@@ -5093,7 +5108,7 @@ var DragDropContextClient = ({
|
|
5093
5108
|
setDeepestDb.cancel();
|
5094
5109
|
debouncedParamsRef.current = null;
|
5095
5110
|
};
|
5096
|
-
(0,
|
5111
|
+
(0, import_react31.useEffect)(() => {
|
5097
5112
|
if (DEBUG3) {
|
5098
5113
|
zoneStore.subscribe(
|
5099
5114
|
(s) => {
|
@@ -5107,7 +5122,7 @@ var DragDropContextClient = ({
|
|
5107
5122
|
);
|
5108
5123
|
}
|
5109
5124
|
}, []);
|
5110
|
-
const [plugins] = (0,
|
5125
|
+
const [plugins] = (0, import_react31.useState)(() => [
|
5111
5126
|
...disableAutoScroll ? import_dom.defaultPreset.plugins.filter((plugin) => plugin !== import_dom.AutoScroller) : import_dom.defaultPreset.plugins,
|
5112
5127
|
createNestedDroppablePlugin(
|
5113
5128
|
{
|
@@ -5155,10 +5170,10 @@ var DragDropContextClient = ({
|
|
5155
5170
|
)
|
5156
5171
|
]);
|
5157
5172
|
const sensors = useSensors();
|
5158
|
-
const [dragListeners, setDragListeners] = (0,
|
5159
|
-
const [pathData, setPathData] = (0,
|
5160
|
-
const dragMode = (0,
|
5161
|
-
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)(
|
5162
5177
|
(id2, selector, label) => {
|
5163
5178
|
const [area] = getZoneId(selector.zone);
|
5164
5179
|
setPathData((latestPathData = {}) => {
|
@@ -5176,7 +5191,7 @@ var DragDropContextClient = ({
|
|
5176
5191
|
},
|
5177
5192
|
[data, setPathData]
|
5178
5193
|
);
|
5179
|
-
const unregisterPath = (0,
|
5194
|
+
const unregisterPath = (0, import_react31.useCallback)(
|
5180
5195
|
(id2) => {
|
5181
5196
|
setPathData((latestPathData = {}) => {
|
5182
5197
|
const newPathData = __spreadValues({}, latestPathData);
|
@@ -5186,7 +5201,7 @@ var DragDropContextClient = ({
|
|
5186
5201
|
},
|
5187
5202
|
[data, setPathData]
|
5188
5203
|
);
|
5189
|
-
const initialSelector = (0,
|
5204
|
+
const initialSelector = (0, import_react31.useRef)(void 0);
|
5190
5205
|
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { id, children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
5191
5206
|
dragListenerContext.Provider,
|
5192
5207
|
{
|
@@ -5195,7 +5210,7 @@ var DragDropContextClient = ({
|
|
5195
5210
|
setDragListeners
|
5196
5211
|
},
|
5197
5212
|
children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
5198
|
-
|
5213
|
+
import_react30.DragDropProvider,
|
5199
5214
|
{
|
5200
5215
|
plugins,
|
5201
5216
|
sensors,
|
@@ -5424,7 +5439,7 @@ var DrawerItemInner = ({
|
|
5424
5439
|
dragRef,
|
5425
5440
|
isDragDisabled
|
5426
5441
|
}) => {
|
5427
|
-
const CustomInner = (0,
|
5442
|
+
const CustomInner = (0, import_react32.useMemo)(
|
5428
5443
|
() => children || (({ children: children2 }) => /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: getClassNameItem2("default"), children: children2 })),
|
5429
5444
|
[children]
|
5430
5445
|
);
|
@@ -5478,7 +5493,7 @@ var DrawerItem = ({
|
|
5478
5493
|
isDragDisabled
|
5479
5494
|
}) => {
|
5480
5495
|
const resolvedId = id || name;
|
5481
|
-
const [dynamicId, setDynamicId] = (0,
|
5496
|
+
const [dynamicId, setDynamicId] = (0, import_react32.useState)(generateId(resolvedId));
|
5482
5497
|
if (typeof index !== "undefined") {
|
5483
5498
|
console.error(
|
5484
5499
|
"Warning: The `index` prop on Drawer.Item is deprecated and no longer required."
|
@@ -5517,7 +5532,7 @@ var Drawer = ({
|
|
5517
5532
|
"Warning: The `direction` prop on Drawer is deprecated and no longer required to achieve multi-directional dragging."
|
5518
5533
|
);
|
5519
5534
|
}
|
5520
|
-
const id = (0,
|
5535
|
+
const id = (0, import_react32.useId)();
|
5521
5536
|
const { ref } = useDroppableSafe({
|
5522
5537
|
id,
|
5523
5538
|
type: "void",
|
@@ -5539,7 +5554,7 @@ Drawer.Item = DrawerItem;
|
|
5539
5554
|
|
5540
5555
|
// components/Puck/index.tsx
|
5541
5556
|
init_react_import();
|
5542
|
-
var
|
5557
|
+
var import_react50 = require("react");
|
5543
5558
|
|
5544
5559
|
// components/SidebarSection/index.tsx
|
5545
5560
|
init_react_import();
|
@@ -5550,7 +5565,7 @@ var styles_module_default13 = { "SidebarSection": "_SidebarSection_8boj8_1", "Si
|
|
5550
5565
|
|
5551
5566
|
// lib/use-breadcrumbs.ts
|
5552
5567
|
init_react_import();
|
5553
|
-
var
|
5568
|
+
var import_react33 = require("react");
|
5554
5569
|
var convertPathDataToBreadcrumbs = (selectedItem, pathData, data) => {
|
5555
5570
|
const id = selectedItem ? selectedItem == null ? void 0 : selectedItem.props.id : "";
|
5556
5571
|
const currentPathData = pathData && id && pathData[id] ? __spreadValues({}, pathData[id]) : { label: "Page", path: [] };
|
@@ -5600,8 +5615,8 @@ var useBreadcrumbs = (renderCount) => {
|
|
5600
5615
|
state: { data },
|
5601
5616
|
selectedItem
|
5602
5617
|
} = useAppContext();
|
5603
|
-
const dzContext = (0,
|
5604
|
-
return (0,
|
5618
|
+
const dzContext = (0, import_react33.useContext)(dropZoneContext);
|
5619
|
+
return (0, import_react33.useMemo)(() => {
|
5605
5620
|
const breadcrumbs = convertPathDataToBreadcrumbs(
|
5606
5621
|
selectedItem,
|
5607
5622
|
dzContext == null ? void 0 : dzContext.pathData,
|
@@ -5735,15 +5750,15 @@ init_react_import();
|
|
5735
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" };
|
5736
5751
|
|
5737
5752
|
// components/Puck/components/Fields/index.tsx
|
5738
|
-
var
|
5753
|
+
var import_react37 = require("react");
|
5739
5754
|
|
5740
5755
|
// lib/use-resolved-fields.ts
|
5741
5756
|
init_react_import();
|
5742
|
-
var
|
5757
|
+
var import_react36 = require("react");
|
5743
5758
|
|
5744
5759
|
// lib/use-parent.ts
|
5745
5760
|
init_react_import();
|
5746
|
-
var
|
5761
|
+
var import_react34 = require("react");
|
5747
5762
|
var getParent = (itemSelector, pathData, data) => {
|
5748
5763
|
var _a;
|
5749
5764
|
if (!itemSelector) return null;
|
@@ -5755,8 +5770,8 @@ var getParent = (itemSelector, pathData, data) => {
|
|
5755
5770
|
};
|
5756
5771
|
var useGetParent = () => {
|
5757
5772
|
const { state } = useAppContext();
|
5758
|
-
const { pathData } = (0,
|
5759
|
-
return (0,
|
5773
|
+
const { pathData } = (0, import_react34.useContext)(dropZoneContext) || {};
|
5774
|
+
return (0, import_react34.useCallback)(
|
5760
5775
|
() => getParent(state.ui.itemSelector, pathData, state.data),
|
5761
5776
|
[state.ui.itemSelector, pathData, state.data]
|
5762
5777
|
);
|
@@ -5767,10 +5782,10 @@ var useParent = () => {
|
|
5767
5782
|
|
5768
5783
|
// lib/use-on-value-change.ts
|
5769
5784
|
init_react_import();
|
5770
|
-
var
|
5785
|
+
var import_react35 = require("react");
|
5771
5786
|
function useOnValueChange(value, onChange, compare = Object.is, deps = []) {
|
5772
|
-
const tracked = (0,
|
5773
|
-
(0,
|
5787
|
+
const tracked = (0, import_react35.useRef)(value);
|
5788
|
+
(0, import_react35.useEffect)(() => {
|
5774
5789
|
const oldValue = tracked.current;
|
5775
5790
|
if (!compare(value, oldValue)) {
|
5776
5791
|
tracked.current = value;
|
@@ -5797,27 +5812,27 @@ var useResolvedFields = ({
|
|
5797
5812
|
const { data } = state;
|
5798
5813
|
const rootFields = ((_a = config.root) == null ? void 0 : _a.fields) || defaultPageFields;
|
5799
5814
|
const componentConfig = selectedItem ? config.components[selectedItem.type] : null;
|
5800
|
-
const defaultFields = (0,
|
5815
|
+
const defaultFields = (0, import_react36.useMemo)(
|
5801
5816
|
() => (selectedItem ? componentConfig == null ? void 0 : componentConfig.fields : rootFields) || {},
|
5802
5817
|
[selectedItem, rootFields, componentConfig == null ? void 0 : componentConfig.fields]
|
5803
5818
|
);
|
5804
5819
|
const rootProps = data.root.props || data.root;
|
5805
|
-
const [lastSelectedData, setLastSelectedData] = (0,
|
5806
|
-
const [resolvedFields, setResolvedFields] = (0,
|
5820
|
+
const [lastSelectedData, setLastSelectedData] = (0, import_react36.useState)({});
|
5821
|
+
const [resolvedFields, setResolvedFields] = (0, import_react36.useState)({
|
5807
5822
|
fields: defaultFields,
|
5808
5823
|
id: selectedItem == null ? void 0 : selectedItem.props.id
|
5809
5824
|
});
|
5810
|
-
const [fieldsLoading, setFieldsLoading] = (0,
|
5811
|
-
const lastFields = (0,
|
5825
|
+
const [fieldsLoading, setFieldsLoading] = (0, import_react36.useState)(false);
|
5826
|
+
const lastFields = (0, import_react36.useRef)(defaultFields);
|
5812
5827
|
const defaultResolveFields = (_componentData, _params) => defaultFields;
|
5813
|
-
const componentData = (0,
|
5828
|
+
const componentData = (0, import_react36.useMemo)(
|
5814
5829
|
() => selectedItem ? selectedItem : { props: rootProps, readOnly: data.root.readOnly || {} },
|
5815
5830
|
[selectedItem, rootProps, data.root.readOnly]
|
5816
5831
|
);
|
5817
5832
|
const hasComponentResolver = selectedItem && (componentConfig == null ? void 0 : componentConfig.resolveFields);
|
5818
5833
|
const hasRootResolver = !selectedItem && ((_b = config.root) == null ? void 0 : _b.resolveFields);
|
5819
5834
|
const hasResolver = hasComponentResolver || hasRootResolver;
|
5820
|
-
const resolveFields = (0,
|
5835
|
+
const resolveFields = (0, import_react36.useCallback)(
|
5821
5836
|
(..._0) => __async(void 0, [..._0], function* (fields = {}) {
|
5822
5837
|
var _a2;
|
5823
5838
|
const lastData = ((_a2 = lastSelectedData.props) == null ? void 0 : _a2.id) === componentData.props.id ? lastSelectedData : null;
|
@@ -5855,7 +5870,7 @@ var useResolvedFields = ({
|
|
5855
5870
|
}),
|
5856
5871
|
[data, config, componentData, selectedItem, state, parent]
|
5857
5872
|
);
|
5858
|
-
const triggerResolver = (0,
|
5873
|
+
const triggerResolver = (0, import_react36.useCallback)(() => {
|
5859
5874
|
var _a2, _b2;
|
5860
5875
|
if (!((_a2 = state.ui.itemSelector) == null ? void 0 : _a2.zone) || ((_b2 = state.ui.itemSelector) == null ? void 0 : _b2.zone) === "default-zone" || parent) {
|
5861
5876
|
if (hasResolver) {
|
@@ -5895,7 +5910,7 @@ var useResolvedFields = ({
|
|
5895
5910
|
},
|
5896
5911
|
(a, b) => JSON.stringify(a) === JSON.stringify(b)
|
5897
5912
|
);
|
5898
|
-
(0,
|
5913
|
+
(0, import_react36.useEffect)(() => {
|
5899
5914
|
triggerResolver();
|
5900
5915
|
}, []);
|
5901
5916
|
if (resolvedFields.id !== (selectedItem == null ? void 0 : selectedItem.props.id) && !_skipIdCheck) {
|
@@ -5930,7 +5945,7 @@ var Fields = ({ wrapFields = true }) => {
|
|
5930
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;
|
5931
5946
|
const isLoading = fieldsResolving || componentResolving;
|
5932
5947
|
const rootProps = data.root.props || data.root;
|
5933
|
-
const Wrapper = (0,
|
5948
|
+
const Wrapper = (0, import_react37.useMemo)(() => overrides.fields || DefaultFields, [overrides]);
|
5934
5949
|
return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
|
5935
5950
|
"form",
|
5936
5951
|
{
|
@@ -6051,7 +6066,7 @@ init_react_import();
|
|
6051
6066
|
|
6052
6067
|
// lib/use-component-list.tsx
|
6053
6068
|
init_react_import();
|
6054
|
-
var
|
6069
|
+
var import_react38 = require("react");
|
6055
6070
|
|
6056
6071
|
// components/ComponentList/index.tsx
|
6057
6072
|
init_react_import();
|
@@ -6118,8 +6133,8 @@ ComponentList.Item = ComponentListItem;
|
|
6118
6133
|
// lib/use-component-list.tsx
|
6119
6134
|
var import_jsx_runtime29 = require("react/jsx-runtime");
|
6120
6135
|
var useComponentList = (config, ui) => {
|
6121
|
-
const [componentList, setComponentList] = (0,
|
6122
|
-
(0,
|
6136
|
+
const [componentList, setComponentList] = (0, import_react38.useState)();
|
6137
|
+
(0, import_react38.useEffect)(() => {
|
6123
6138
|
var _a, _b, _c;
|
6124
6139
|
if (Object.keys(ui.componentList).length > 0) {
|
6125
6140
|
const matchedComponents = [];
|
@@ -6188,22 +6203,22 @@ var useComponentList = (config, ui) => {
|
|
6188
6203
|
};
|
6189
6204
|
|
6190
6205
|
// components/Puck/components/Components/index.tsx
|
6191
|
-
var
|
6206
|
+
var import_react39 = require("react");
|
6192
6207
|
var import_jsx_runtime30 = require("react/jsx-runtime");
|
6193
6208
|
var Components = () => {
|
6194
6209
|
const { config, state, overrides } = useAppContext();
|
6195
6210
|
const componentList = useComponentList(config, state.ui);
|
6196
|
-
const Wrapper = (0,
|
6211
|
+
const Wrapper = (0, import_react39.useMemo)(() => overrides.components || "div", [overrides]);
|
6197
6212
|
return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Wrapper, { children: componentList ? componentList : /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(ComponentList, { id: "all" }) });
|
6198
6213
|
};
|
6199
6214
|
|
6200
6215
|
// components/Puck/components/Preview/index.tsx
|
6201
6216
|
init_react_import();
|
6202
|
-
var
|
6217
|
+
var import_react41 = require("react");
|
6203
6218
|
|
6204
6219
|
// components/AutoFrame/index.tsx
|
6205
6220
|
init_react_import();
|
6206
|
-
var
|
6221
|
+
var import_react40 = require("react");
|
6207
6222
|
var import_object_hash = __toESM(require("object-hash"));
|
6208
6223
|
var import_react_dom3 = require("react-dom");
|
6209
6224
|
var import_jsx_runtime31 = require("react/jsx-runtime");
|
@@ -6249,7 +6264,7 @@ var CopyHostStyles = ({
|
|
6249
6264
|
onStylesLoaded = () => null
|
6250
6265
|
}) => {
|
6251
6266
|
const { document: doc, window: win } = useFrame();
|
6252
|
-
(0,
|
6267
|
+
(0, import_react40.useEffect)(() => {
|
6253
6268
|
if (!win || !doc) {
|
6254
6269
|
return () => {
|
6255
6270
|
};
|
@@ -6408,8 +6423,8 @@ var CopyHostStyles = ({
|
|
6408
6423
|
}, []);
|
6409
6424
|
return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_jsx_runtime31.Fragment, { children });
|
6410
6425
|
};
|
6411
|
-
var autoFrameContext = (0,
|
6412
|
-
var useFrame = () => (0,
|
6426
|
+
var autoFrameContext = (0, import_react40.createContext)({});
|
6427
|
+
var useFrame = () => (0, import_react40.useContext)(autoFrameContext);
|
6413
6428
|
function AutoFrame(_a) {
|
6414
6429
|
var _b = _a, {
|
6415
6430
|
children,
|
@@ -6426,10 +6441,10 @@ function AutoFrame(_a) {
|
|
6426
6441
|
"onStylesLoaded",
|
6427
6442
|
"frameRef"
|
6428
6443
|
]);
|
6429
|
-
const [loaded, setLoaded] = (0,
|
6430
|
-
const [ctx, setCtx] = (0,
|
6431
|
-
const [mountTarget, setMountTarget] = (0,
|
6432
|
-
(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)(() => {
|
6433
6448
|
var _a2;
|
6434
6449
|
if (frameRef.current) {
|
6435
6450
|
setCtx({
|
@@ -6524,7 +6539,7 @@ var import_jsx_runtime33 = require("react/jsx-runtime");
|
|
6524
6539
|
var getClassName23 = get_class_name_factory_default("PuckPreview", styles_module_default18);
|
6525
6540
|
var useBubbleIframeEvents = (ref) => {
|
6526
6541
|
const { status } = useAppContext();
|
6527
|
-
(0,
|
6542
|
+
(0, import_react41.useEffect)(() => {
|
6528
6543
|
var _a;
|
6529
6544
|
if (ref.current && status === "READY") {
|
6530
6545
|
const iframe = ref.current;
|
@@ -6557,7 +6572,7 @@ var useBubbleIframeEvents = (ref) => {
|
|
6557
6572
|
};
|
6558
6573
|
var Preview2 = ({ id = "puck-preview" }) => {
|
6559
6574
|
const { config, dispatch, state, setStatus, iframe, overrides } = useAppContext();
|
6560
|
-
const Page = (0,
|
6575
|
+
const Page = (0, import_react41.useCallback)(
|
6561
6576
|
(pageProps) => {
|
6562
6577
|
var _a, _b;
|
6563
6578
|
return ((_a = config.root) == null ? void 0 : _a.render) ? (_b = config.root) == null ? void 0 : _b.render(__spreadValues({
|
@@ -6566,9 +6581,9 @@ var Preview2 = ({ id = "puck-preview" }) => {
|
|
6566
6581
|
},
|
6567
6582
|
[config.root]
|
6568
6583
|
);
|
6569
|
-
const Frame = (0,
|
6584
|
+
const Frame = (0, import_react41.useMemo)(() => overrides.iframe, [overrides]);
|
6570
6585
|
const rootProps = state.data.root.props || state.data.root;
|
6571
|
-
const ref = (0,
|
6586
|
+
const ref = (0, import_react41.useRef)(null);
|
6572
6587
|
useBubbleIframeEvents(ref);
|
6573
6588
|
const inner = state.ui.previewMode === "edit" ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
6574
6589
|
Page,
|
@@ -6665,7 +6680,7 @@ var scrollIntoView = (el) => {
|
|
6665
6680
|
};
|
6666
6681
|
|
6667
6682
|
// components/LayerTree/index.tsx
|
6668
|
-
var
|
6683
|
+
var import_react42 = require("react");
|
6669
6684
|
|
6670
6685
|
// lib/is-child-of-zone.ts
|
6671
6686
|
init_react_import();
|
@@ -6711,7 +6726,7 @@ var LayerTree = ({
|
|
6711
6726
|
label
|
6712
6727
|
}) => {
|
6713
6728
|
const zones = data.zones || {};
|
6714
|
-
const ctx = (0,
|
6729
|
+
const ctx = (0, import_react42.useContext)(dropZoneContext);
|
6715
6730
|
return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(import_jsx_runtime34.Fragment, { children: [
|
6716
6731
|
label && /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("div", { className: getClassName24("zoneTitle"), children: [
|
6717
6732
|
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: getClassName24("zoneIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Layers, { size: "16" }) }),
|
@@ -6818,13 +6833,13 @@ var LayerTree = ({
|
|
6818
6833
|
};
|
6819
6834
|
|
6820
6835
|
// components/Puck/components/Outline/index.tsx
|
6821
|
-
var
|
6836
|
+
var import_react43 = require("react");
|
6822
6837
|
var import_jsx_runtime35 = require("react/jsx-runtime");
|
6823
6838
|
var Outline = () => {
|
6824
6839
|
const { dispatch, state, overrides, config } = useAppContext();
|
6825
6840
|
const { data, ui } = state;
|
6826
6841
|
const { itemSelector } = ui;
|
6827
|
-
const setItemSelector = (0,
|
6842
|
+
const setItemSelector = (0, import_react43.useCallback)(
|
6828
6843
|
(newItemSelector) => {
|
6829
6844
|
dispatch({
|
6830
6845
|
type: "setUi",
|
@@ -6833,7 +6848,7 @@ var Outline = () => {
|
|
6833
6848
|
},
|
6834
6849
|
[]
|
6835
6850
|
);
|
6836
|
-
const Wrapper = (0,
|
6851
|
+
const Wrapper = (0, import_react43.useMemo)(() => overrides.outline || "div", [overrides]);
|
6837
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: [
|
6838
6853
|
(ctx == null ? void 0 : ctx.activeZones) && (ctx == null ? void 0 : ctx.activeZones[rootDroppableId]) && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
6839
6854
|
LayerTree,
|
@@ -6947,19 +6962,19 @@ function usePuckHistory({
|
|
6947
6962
|
|
6948
6963
|
// lib/use-history-store.ts
|
6949
6964
|
init_react_import();
|
6950
|
-
var
|
6965
|
+
var import_react44 = require("react");
|
6951
6966
|
var import_use_debounce3 = require("use-debounce");
|
6952
6967
|
var EMPTY_HISTORY_INDEX = 0;
|
6953
6968
|
function useHistoryStore(initialHistory) {
|
6954
6969
|
var _a, _b;
|
6955
|
-
const [histories, setHistories] = (0,
|
6970
|
+
const [histories, setHistories] = (0, import_react44.useState)(
|
6956
6971
|
(_a = initialHistory == null ? void 0 : initialHistory.histories) != null ? _a : []
|
6957
6972
|
);
|
6958
6973
|
const updateHistories = (histories2) => {
|
6959
6974
|
setHistories(histories2);
|
6960
6975
|
setIndex(histories2.length - 1);
|
6961
6976
|
};
|
6962
|
-
const [index, setIndex] = (0,
|
6977
|
+
const [index, setIndex] = (0, import_react44.useState)(
|
6963
6978
|
(_b = initialHistory == null ? void 0 : initialHistory.index) != null ? _b : EMPTY_HISTORY_INDEX
|
6964
6979
|
);
|
6965
6980
|
const hasPast = index > EMPTY_HISTORY_INDEX;
|
@@ -7119,11 +7134,11 @@ var getBox = function getBox2(el) {
|
|
7119
7134
|
};
|
7120
7135
|
|
7121
7136
|
// components/Puck/components/Canvas/index.tsx
|
7122
|
-
var
|
7137
|
+
var import_react46 = require("react");
|
7123
7138
|
|
7124
7139
|
// components/ViewportControls/index.tsx
|
7125
7140
|
init_react_import();
|
7126
|
-
var
|
7141
|
+
var import_react45 = require("react");
|
7127
7142
|
|
7128
7143
|
// css-module:/home/runner/work/puck/puck/packages/core/components/ViewportControls/styles.module.css#css-module
|
7129
7144
|
init_react_import();
|
@@ -7146,8 +7161,8 @@ var ViewportButton = ({
|
|
7146
7161
|
onClick
|
7147
7162
|
}) => {
|
7148
7163
|
const { state } = useAppContext();
|
7149
|
-
const [isActive, setIsActive] = (0,
|
7150
|
-
(0,
|
7164
|
+
const [isActive, setIsActive] = (0, import_react45.useState)(false);
|
7165
|
+
(0, import_react45.useEffect)(() => {
|
7151
7166
|
setIsActive(width === state.ui.viewports.current.width);
|
7152
7167
|
}, [width, state.ui.viewports.current.width]);
|
7153
7168
|
return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("span", { className: getClassNameButton({ isActive }), children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
@@ -7183,7 +7198,7 @@ var ViewportControls = ({
|
|
7183
7198
|
const defaultsContainAutoZoom = defaultZoomOptions.find(
|
7184
7199
|
(option) => option.value === autoZoom
|
7185
7200
|
);
|
7186
|
-
const zoomOptions = (0,
|
7201
|
+
const zoomOptions = (0, import_react45.useMemo)(
|
7187
7202
|
() => [
|
7188
7203
|
...defaultZoomOptions,
|
7189
7204
|
...defaultsContainAutoZoom ? [] : [
|
@@ -7306,17 +7321,17 @@ var Canvas = () => {
|
|
7306
7321
|
const { status, iframe } = useAppContext();
|
7307
7322
|
const { dispatch, state, overrides, setUi, zoomConfig, setZoomConfig } = useAppContext();
|
7308
7323
|
const { ui } = state;
|
7309
|
-
const frameRef = (0,
|
7310
|
-
const [showTransition, setShowTransition] = (0,
|
7311
|
-
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)(() => {
|
7312
7327
|
const PuckDefault = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(import_jsx_runtime37.Fragment, { children });
|
7313
7328
|
return PuckDefault;
|
7314
7329
|
}, []);
|
7315
|
-
const CustomPreview = (0,
|
7330
|
+
const CustomPreview = (0, import_react46.useMemo)(
|
7316
7331
|
() => overrides.preview || defaultRender,
|
7317
7332
|
[overrides]
|
7318
7333
|
);
|
7319
|
-
const getFrameDimensions = (0,
|
7334
|
+
const getFrameDimensions = (0, import_react46.useCallback)(() => {
|
7320
7335
|
if (frameRef.current) {
|
7321
7336
|
const frame = frameRef.current;
|
7322
7337
|
const box = getBox(frame);
|
@@ -7324,7 +7339,7 @@ var Canvas = () => {
|
|
7324
7339
|
}
|
7325
7340
|
return { width: 0, height: 0 };
|
7326
7341
|
}, [frameRef]);
|
7327
|
-
const resetAutoZoom = (0,
|
7342
|
+
const resetAutoZoom = (0, import_react46.useCallback)(
|
7328
7343
|
(ui2 = state.ui) => {
|
7329
7344
|
if (frameRef.current) {
|
7330
7345
|
setZoomConfig(
|
@@ -7334,11 +7349,11 @@ var Canvas = () => {
|
|
7334
7349
|
},
|
7335
7350
|
[frameRef, zoomConfig, state.ui]
|
7336
7351
|
);
|
7337
|
-
(0,
|
7352
|
+
(0, import_react46.useEffect)(() => {
|
7338
7353
|
setShowTransition(false);
|
7339
7354
|
resetAutoZoom();
|
7340
7355
|
}, [frameRef, ui.leftSideBarVisible, ui.rightSideBarVisible]);
|
7341
|
-
(0,
|
7356
|
+
(0, import_react46.useEffect)(() => {
|
7342
7357
|
const { height: frameHeight } = getFrameDimensions();
|
7343
7358
|
if (ui.viewports.current.height === "auto") {
|
7344
7359
|
setZoomConfig(__spreadProps(__spreadValues({}, zoomConfig), {
|
@@ -7346,13 +7361,13 @@ var Canvas = () => {
|
|
7346
7361
|
}));
|
7347
7362
|
}
|
7348
7363
|
}, [zoomConfig.zoom]);
|
7349
|
-
(0,
|
7364
|
+
(0, import_react46.useEffect)(() => {
|
7350
7365
|
if (ZOOM_ON_CHANGE) {
|
7351
7366
|
setShowTransition(true);
|
7352
7367
|
resetAutoZoom(ui);
|
7353
7368
|
}
|
7354
7369
|
}, [ui.viewports.current.width]);
|
7355
|
-
(0,
|
7370
|
+
(0, import_react46.useEffect)(() => {
|
7356
7371
|
const cb = () => {
|
7357
7372
|
setShowTransition(false);
|
7358
7373
|
resetAutoZoom();
|
@@ -7362,8 +7377,8 @@ var Canvas = () => {
|
|
7362
7377
|
window.removeEventListener("resize", cb);
|
7363
7378
|
};
|
7364
7379
|
}, []);
|
7365
|
-
const [showLoader, setShowLoader] = (0,
|
7366
|
-
(0,
|
7380
|
+
const [showLoader, setShowLoader] = (0, import_react46.useState)(false);
|
7381
|
+
(0, import_react46.useEffect)(() => {
|
7367
7382
|
setTimeout(() => {
|
7368
7383
|
setShowLoader(true);
|
7369
7384
|
}, 500);
|
@@ -7441,7 +7456,7 @@ var Canvas = () => {
|
|
7441
7456
|
|
7442
7457
|
// lib/use-loaded-overrides.ts
|
7443
7458
|
init_react_import();
|
7444
|
-
var
|
7459
|
+
var import_react47 = require("react");
|
7445
7460
|
|
7446
7461
|
// lib/load-overrides.ts
|
7447
7462
|
init_react_import();
|
@@ -7480,7 +7495,7 @@ var useLoadedOverrides = ({
|
|
7480
7495
|
overrides,
|
7481
7496
|
plugins
|
7482
7497
|
}) => {
|
7483
|
-
return (0,
|
7498
|
+
return (0, import_react47.useMemo)(() => {
|
7484
7499
|
return loadOverrides({ overrides, plugins });
|
7485
7500
|
}, [plugins, overrides]);
|
7486
7501
|
};
|
@@ -7492,14 +7507,14 @@ var DefaultOverride = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime38
|
|
7492
7507
|
|
7493
7508
|
// lib/use-inject-css.ts
|
7494
7509
|
init_react_import();
|
7495
|
-
var
|
7510
|
+
var import_react48 = require("react");
|
7496
7511
|
var styles = ``;
|
7497
7512
|
var useInjectStyleSheet = (initialStyles, iframeEnabled) => {
|
7498
|
-
const [el, setEl] = (0,
|
7499
|
-
(0,
|
7513
|
+
const [el, setEl] = (0, import_react48.useState)();
|
7514
|
+
(0, import_react48.useEffect)(() => {
|
7500
7515
|
setEl(document.createElement("style"));
|
7501
7516
|
}, []);
|
7502
|
-
(0,
|
7517
|
+
(0, import_react48.useEffect)(() => {
|
7503
7518
|
var _a;
|
7504
7519
|
if (!el || typeof window === "undefined") {
|
7505
7520
|
return;
|
@@ -7519,10 +7534,10 @@ var useInjectGlobalCss = (iframeEnabled) => {
|
|
7519
7534
|
|
7520
7535
|
// lib/use-preview-mode-hotkeys.ts
|
7521
7536
|
init_react_import();
|
7522
|
-
var
|
7537
|
+
var import_react49 = require("react");
|
7523
7538
|
var import_react_hotkeys_hook2 = require("react-hotkeys-hook");
|
7524
7539
|
var usePreviewModeHotkeys = (dispatch, iframeEnabled) => {
|
7525
|
-
const toggleInteractive = (0,
|
7540
|
+
const toggleInteractive = (0, import_react49.useCallback)(() => {
|
7526
7541
|
dispatch({
|
7527
7542
|
type: "setUi",
|
7528
7543
|
ui: (ui) => ({
|
@@ -7579,7 +7594,7 @@ function Puck({
|
|
7579
7594
|
waitForStyles: true
|
7580
7595
|
}, _iframe);
|
7581
7596
|
useInjectGlobalCss(iframe.enabled);
|
7582
|
-
const [generatedAppState] = (0,
|
7597
|
+
const [generatedAppState] = (0, import_react50.useState)(() => {
|
7583
7598
|
var _a2, _b2, _c, _d, _e, _f, _g, _h, _i;
|
7584
7599
|
const initial = __spreadValues(__spreadValues({}, defaultAppState.ui), initialUi);
|
7585
7600
|
let clientUiState = {};
|
@@ -7651,14 +7666,14 @@ function Puck({
|
|
7651
7666
|
histories,
|
7652
7667
|
index: initialHistoryIndex
|
7653
7668
|
});
|
7654
|
-
const [reducer] = (0,
|
7669
|
+
const [reducer] = (0, import_react50.useState)(
|
7655
7670
|
() => createReducer({
|
7656
7671
|
config,
|
7657
7672
|
record: historyStore.record,
|
7658
7673
|
onAction
|
7659
7674
|
})
|
7660
7675
|
);
|
7661
|
-
const [appState, dispatch] = (0,
|
7676
|
+
const [appState, dispatch] = (0, import_react50.useReducer)(
|
7662
7677
|
reducer,
|
7663
7678
|
flushZones(initialAppState)
|
7664
7679
|
);
|
@@ -7669,14 +7684,14 @@ function Puck({
|
|
7669
7684
|
historyStore,
|
7670
7685
|
iframeEnabled: (_a = _iframe == null ? void 0 : _iframe.enabled) != null ? _a : true
|
7671
7686
|
});
|
7672
|
-
const [menuOpen, setMenuOpen] = (0,
|
7687
|
+
const [menuOpen, setMenuOpen] = (0, import_react50.useState)(false);
|
7673
7688
|
const { itemSelector, leftSideBarVisible, rightSideBarVisible } = ui;
|
7674
7689
|
const selectedItem = itemSelector ? getItem(itemSelector, data) : null;
|
7675
|
-
(0,
|
7690
|
+
(0, import_react50.useEffect)(() => {
|
7676
7691
|
if (onChange) onChange(data);
|
7677
7692
|
}, [data]);
|
7678
7693
|
const rootProps = data.root.props || data.root;
|
7679
|
-
const toggleSidebars = (0,
|
7694
|
+
const toggleSidebars = (0, import_react50.useCallback)(
|
7680
7695
|
(sidebar) => {
|
7681
7696
|
const widerViewport = window.matchMedia("(min-width: 638px)").matches;
|
7682
7697
|
const sideBarVisible = sidebar === "left" ? leftSideBarVisible : rightSideBarVisible;
|
@@ -7690,7 +7705,7 @@ function Puck({
|
|
7690
7705
|
},
|
7691
7706
|
[dispatch, leftSideBarVisible, rightSideBarVisible]
|
7692
7707
|
);
|
7693
|
-
(0,
|
7708
|
+
(0, import_react50.useEffect)(() => {
|
7694
7709
|
if (!window.matchMedia("(min-width: 638px)").matches) {
|
7695
7710
|
dispatch({
|
7696
7711
|
type: "setUi",
|
@@ -7713,7 +7728,7 @@ function Puck({
|
|
7713
7728
|
window.removeEventListener("resize", handleResize);
|
7714
7729
|
};
|
7715
7730
|
}, []);
|
7716
|
-
const defaultHeaderRender = (0,
|
7731
|
+
const defaultHeaderRender = (0, import_react50.useMemo)(() => {
|
7717
7732
|
if (renderHeader) {
|
7718
7733
|
console.warn(
|
7719
7734
|
"`renderHeader` is deprecated. Please use `overrides.header` and the `usePuck` hook instead"
|
@@ -7727,7 +7742,7 @@ function Puck({
|
|
7727
7742
|
}
|
7728
7743
|
return DefaultOverride;
|
7729
7744
|
}, [renderHeader]);
|
7730
|
-
const defaultHeaderActionsRender = (0,
|
7745
|
+
const defaultHeaderActionsRender = (0, import_react50.useMemo)(() => {
|
7731
7746
|
if (renderHeaderActions) {
|
7732
7747
|
console.warn(
|
7733
7748
|
"`renderHeaderActions` is deprecated. Please use `overrides.headerActions` and the `usePuck` hook instead."
|
@@ -7744,20 +7759,20 @@ function Puck({
|
|
7744
7759
|
overrides,
|
7745
7760
|
plugins
|
7746
7761
|
});
|
7747
|
-
const CustomPuck = (0,
|
7762
|
+
const CustomPuck = (0, import_react50.useMemo)(
|
7748
7763
|
() => loadedOverrides.puck || DefaultOverride,
|
7749
7764
|
[loadedOverrides]
|
7750
7765
|
);
|
7751
|
-
const CustomHeader = (0,
|
7766
|
+
const CustomHeader = (0, import_react50.useMemo)(
|
7752
7767
|
() => loadedOverrides.header || defaultHeaderRender,
|
7753
7768
|
[loadedOverrides]
|
7754
7769
|
);
|
7755
|
-
const CustomHeaderActions = (0,
|
7770
|
+
const CustomHeaderActions = (0, import_react50.useMemo)(
|
7756
7771
|
() => loadedOverrides.headerActions || defaultHeaderActionsRender,
|
7757
7772
|
[loadedOverrides]
|
7758
7773
|
);
|
7759
|
-
const [mounted, setMounted] = (0,
|
7760
|
-
(0,
|
7774
|
+
const [mounted, setMounted] = (0, import_react50.useState)(false);
|
7775
|
+
(0, import_react50.useEffect)(() => {
|
7761
7776
|
setMounted(true);
|
7762
7777
|
}, []);
|
7763
7778
|
const selectedComponentConfig = selectedItem && config.components[selectedItem.type];
|