@measured/puck 0.18.3-canary.154e7f7 → 0.18.3-canary.551c689
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 +340 -328
- package/dist/index.mjs +196 -218
- 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,12 +2126,13 @@ 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;
|
2130
2137
|
if (field.type !== "array" || !field.arrayFields) {
|
2131
2138
|
return null;
|
@@ -2141,10 +2148,16 @@ var ArrayField = ({
|
|
2141
2148
|
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
2142
2149
|
SortableProvider,
|
2143
2150
|
{
|
2144
|
-
onDragStart: () =>
|
2145
|
-
onDragEnd: () =>
|
2151
|
+
onDragStart: (id2) => setDraggedItem(id2),
|
2152
|
+
onDragEnd: () => {
|
2153
|
+
setDraggedItem("");
|
2154
|
+
onChange(localState.value);
|
2155
|
+
},
|
2146
2156
|
onMove: (move) => {
|
2147
|
-
|
2157
|
+
if (arrayState.items[move.source]._arrayId !== draggedItem) {
|
2158
|
+
return;
|
2159
|
+
}
|
2160
|
+
const newValue = reorder(localState.value, move.source, move.target);
|
2148
2161
|
const newArrayStateItems = reorder(
|
2149
2162
|
arrayState.items,
|
2150
2163
|
move.source,
|
@@ -2156,7 +2169,6 @@ var ArrayField = ({
|
|
2156
2169
|
})
|
2157
2170
|
};
|
2158
2171
|
setUi(newUi, false);
|
2159
|
-
onChange(newValue, newUi);
|
2160
2172
|
setLocalState({
|
2161
2173
|
value: newValue,
|
2162
2174
|
arrayState: __spreadProps(__spreadValues({}, arrayState), { items: newArrayStateItems })
|
@@ -2169,11 +2181,8 @@ var ArrayField = ({
|
|
2169
2181
|
hasItems: Array.isArray(value) && value.length > 0,
|
2170
2182
|
addDisabled
|
2171
2183
|
}),
|
2172
|
-
onClick: (e) => {
|
2173
|
-
e.preventDefault();
|
2174
|
-
},
|
2175
2184
|
children: [
|
2176
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: getClassName5("inner"), "data-dnd-container": true, children: localState.arrayState.items.map((item, i) => {
|
2185
|
+
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
2186
|
const { _arrayId = `${id}-${i}`, _originalIndex = i } = item;
|
2178
2187
|
const data = Array.from(localState.value || [])[i] || {};
|
2179
2188
|
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
@@ -2182,7 +2191,7 @@ var ArrayField = ({
|
|
2182
2191
|
id: _arrayId,
|
2183
2192
|
index: i,
|
2184
2193
|
disabled: readOnly,
|
2185
|
-
children: ({ status, ref }) => /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
2194
|
+
children: ({ status, ref, handleRef }) => /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
2186
2195
|
"div",
|
2187
2196
|
{
|
2188
2197
|
ref,
|
@@ -2195,6 +2204,7 @@ var ArrayField = ({
|
|
2195
2204
|
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
2196
2205
|
"div",
|
2197
2206
|
{
|
2207
|
+
ref: handleRef,
|
2198
2208
|
onClick: (e) => {
|
2199
2209
|
if (isDragging) return;
|
2200
2210
|
e.preventDefault();
|
@@ -2272,58 +2282,49 @@ var ArrayField = ({
|
|
2272
2282
|
]
|
2273
2283
|
}
|
2274
2284
|
),
|
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
|
-
|
2285
|
+
/* @__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) => {
|
2286
|
+
const subField = field.arrayFields[subName];
|
2287
|
+
const indexName = `${name}[${i}]`;
|
2288
|
+
const subPath = `${indexName}.${subName}`;
|
2289
|
+
const localIndexName = `${localName}[${i}]`;
|
2290
|
+
const localWildcardName = `${localName}[*]`;
|
2291
|
+
const localSubPath = `${localIndexName}.${subName}`;
|
2292
|
+
const localWildcardSubPath = `${localWildcardName}.${subName}`;
|
2293
|
+
const subReadOnly = forceReadOnly ? forceReadOnly : typeof readOnlyFields[subPath] !== "undefined" ? readOnlyFields[localSubPath] : readOnlyFields[localWildcardSubPath];
|
2294
|
+
const label2 = subField.label || subName;
|
2295
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
2296
|
+
NestedFieldProvider,
|
2297
|
+
{
|
2298
|
+
name: localIndexName,
|
2299
|
+
wildcardName: localWildcardName,
|
2300
|
+
subName,
|
2301
|
+
readOnlyFields,
|
2302
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
2303
|
+
AutoFieldPrivate,
|
2294
2304
|
{
|
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
|
-
) })
|
2305
|
+
name: subPath,
|
2306
|
+
label: label2,
|
2307
|
+
id: `${_arrayId}_${subName}`,
|
2308
|
+
readOnly: subReadOnly,
|
2309
|
+
field: __spreadProps(__spreadValues({}, subField), {
|
2310
|
+
label: label2
|
2311
|
+
// May be used by custom fields
|
2312
|
+
}),
|
2313
|
+
value: data[subName],
|
2314
|
+
onChange: (val, ui) => {
|
2315
|
+
onChange(
|
2316
|
+
replace(value, i, __spreadProps(__spreadValues({}, data), {
|
2317
|
+
[subName]: val
|
2318
|
+
})),
|
2319
|
+
ui
|
2320
|
+
);
|
2321
|
+
}
|
2322
|
+
}
|
2323
|
+
)
|
2324
|
+
},
|
2325
|
+
subPath
|
2326
|
+
);
|
2327
|
+
}) }) })
|
2327
2328
|
]
|
2328
2329
|
}
|
2329
2330
|
)
|
@@ -2418,11 +2419,11 @@ var DefaultField = ({
|
|
2418
2419
|
|
2419
2420
|
// components/AutoField/fields/ExternalField/index.tsx
|
2420
2421
|
init_react_import();
|
2421
|
-
var
|
2422
|
+
var import_react16 = require("react");
|
2422
2423
|
|
2423
2424
|
// components/ExternalInput/index.tsx
|
2424
2425
|
init_react_import();
|
2425
|
-
var
|
2426
|
+
var import_react15 = require("react");
|
2426
2427
|
|
2427
2428
|
// css-module:/home/runner/work/puck/puck/packages/core/components/ExternalInput/styles.module.css#css-module
|
2428
2429
|
init_react_import();
|
@@ -2430,7 +2431,7 @@ var styles_module_default6 = { "ExternalInput-actions": "_ExternalInput-actions_
|
|
2430
2431
|
|
2431
2432
|
// components/Modal/index.tsx
|
2432
2433
|
init_react_import();
|
2433
|
-
var
|
2434
|
+
var import_react13 = require("react");
|
2434
2435
|
|
2435
2436
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Modal/styles.module.css#css-module
|
2436
2437
|
init_react_import();
|
@@ -2445,8 +2446,8 @@ var Modal = ({
|
|
2445
2446
|
onClose,
|
2446
2447
|
isOpen
|
2447
2448
|
}) => {
|
2448
|
-
const [rootEl, setRootEl] = (0,
|
2449
|
-
(0,
|
2449
|
+
const [rootEl, setRootEl] = (0, import_react13.useState)(null);
|
2450
|
+
(0, import_react13.useEffect)(() => {
|
2450
2451
|
setRootEl(document.getElementById("puck-portal-root"));
|
2451
2452
|
}, []);
|
2452
2453
|
if (!rootEl) {
|
@@ -2493,7 +2494,7 @@ init_react_import();
|
|
2493
2494
|
|
2494
2495
|
// components/Button/Button.tsx
|
2495
2496
|
init_react_import();
|
2496
|
-
var
|
2497
|
+
var import_react14 = require("react");
|
2497
2498
|
|
2498
2499
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Button/Button.module.css#css-module
|
2499
2500
|
init_react_import();
|
@@ -2543,8 +2544,8 @@ var Button = (_a) => {
|
|
2543
2544
|
"size",
|
2544
2545
|
"loading"
|
2545
2546
|
]);
|
2546
|
-
const [loading, setLoading] = (0,
|
2547
|
-
(0,
|
2547
|
+
const [loading, setLoading] = (0, import_react14.useState)(loadingProp);
|
2548
|
+
(0, import_react14.useEffect)(() => setLoading(loadingProp), [loadingProp]);
|
2548
2549
|
const ElementType = href ? "a" : type ? "button" : "span";
|
2549
2550
|
const dataAttrs = filterDataAttrs(props);
|
2550
2551
|
const el = /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
@@ -2599,28 +2600,28 @@ var ExternalInput = ({
|
|
2599
2600
|
mapRow = (val) => val,
|
2600
2601
|
filterFields
|
2601
2602
|
} = field || {};
|
2602
|
-
const [data, setData] = (0,
|
2603
|
-
const [isOpen, setOpen] = (0,
|
2604
|
-
const [isLoading, setIsLoading] = (0,
|
2603
|
+
const [data, setData] = (0, import_react15.useState)([]);
|
2604
|
+
const [isOpen, setOpen] = (0, import_react15.useState)(false);
|
2605
|
+
const [isLoading, setIsLoading] = (0, import_react15.useState)(true);
|
2605
2606
|
const hasFilterFields = !!filterFields;
|
2606
|
-
const [filters, setFilters] = (0,
|
2607
|
-
const [filtersToggled, setFiltersToggled] = (0,
|
2608
|
-
const mappedData = (0,
|
2607
|
+
const [filters, setFilters] = (0, import_react15.useState)(field.initialFilters || {});
|
2608
|
+
const [filtersToggled, setFiltersToggled] = (0, import_react15.useState)(hasFilterFields);
|
2609
|
+
const mappedData = (0, import_react15.useMemo)(() => {
|
2609
2610
|
return data.map(mapRow);
|
2610
2611
|
}, [data]);
|
2611
|
-
const keys = (0,
|
2612
|
+
const keys = (0, import_react15.useMemo)(() => {
|
2612
2613
|
const validKeys = /* @__PURE__ */ new Set();
|
2613
2614
|
for (const item of mappedData) {
|
2614
2615
|
for (const key of Object.keys(item)) {
|
2615
|
-
if (typeof item[key] === "string" || typeof item[key] === "number" || (0,
|
2616
|
+
if (typeof item[key] === "string" || typeof item[key] === "number" || (0, import_react15.isValidElement)(item[key])) {
|
2616
2617
|
validKeys.add(key);
|
2617
2618
|
}
|
2618
2619
|
}
|
2619
2620
|
}
|
2620
2621
|
return Array.from(validKeys);
|
2621
2622
|
}, [mappedData]);
|
2622
|
-
const [searchQuery, setSearchQuery] = (0,
|
2623
|
-
const search = (0,
|
2623
|
+
const [searchQuery, setSearchQuery] = (0, import_react15.useState)(field.initialQuery || "");
|
2624
|
+
const search = (0, import_react15.useCallback)(
|
2624
2625
|
(query, filters2) => __async(void 0, null, function* () {
|
2625
2626
|
setIsLoading(true);
|
2626
2627
|
const cacheKey = `${id}-${query}-${JSON.stringify(filters2)}`;
|
@@ -2633,7 +2634,7 @@ var ExternalInput = ({
|
|
2633
2634
|
}),
|
2634
2635
|
[id, field]
|
2635
2636
|
);
|
2636
|
-
const Footer = (0,
|
2637
|
+
const Footer = (0, import_react15.useCallback)(
|
2637
2638
|
(props) => field.renderFooter ? field.renderFooter(props) : /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("span", { className: getClassNameModal("footer"), children: [
|
2638
2639
|
props.items.length,
|
2639
2640
|
" result",
|
@@ -2641,7 +2642,7 @@ var ExternalInput = ({
|
|
2641
2642
|
] }),
|
2642
2643
|
[field.renderFooter]
|
2643
2644
|
);
|
2644
|
-
(0,
|
2645
|
+
(0, import_react15.useEffect)(() => {
|
2645
2646
|
search(searchQuery, filters);
|
2646
2647
|
}, []);
|
2647
2648
|
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
|
@@ -2812,7 +2813,7 @@ var ExternalField = ({
|
|
2812
2813
|
var _a, _b, _c;
|
2813
2814
|
const validField = field;
|
2814
2815
|
const deprecatedField = field;
|
2815
|
-
(0,
|
2816
|
+
(0, import_react16.useEffect)(() => {
|
2816
2817
|
if (deprecatedField.adaptor) {
|
2817
2818
|
console.error(
|
2818
2819
|
"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 +2848,7 @@ var ExternalField = ({
|
|
2847
2848
|
|
2848
2849
|
// components/AutoField/fields/RadioField/index.tsx
|
2849
2850
|
init_react_import();
|
2850
|
-
var
|
2851
|
+
var import_react17 = require("react");
|
2851
2852
|
|
2852
2853
|
// lib/safe-json-parse.ts
|
2853
2854
|
init_react_import();
|
@@ -2873,7 +2874,7 @@ var RadioField = ({
|
|
2873
2874
|
label,
|
2874
2875
|
Label: Label2
|
2875
2876
|
}) => {
|
2876
|
-
const flatOptions = (0,
|
2877
|
+
const flatOptions = (0, import_react17.useMemo)(
|
2877
2878
|
() => field.type === "radio" ? field.options.map(({ value: value2 }) => value2) : [],
|
2878
2879
|
[field]
|
2879
2880
|
);
|
@@ -2923,7 +2924,7 @@ var RadioField = ({
|
|
2923
2924
|
|
2924
2925
|
// components/AutoField/fields/SelectField/index.tsx
|
2925
2926
|
init_react_import();
|
2926
|
-
var
|
2927
|
+
var import_react18 = require("react");
|
2927
2928
|
var import_jsx_runtime16 = require("react/jsx-runtime");
|
2928
2929
|
var getClassName12 = get_class_name_factory_default("Input", styles_module_default2);
|
2929
2930
|
var SelectField = ({
|
@@ -2936,7 +2937,7 @@ var SelectField = ({
|
|
2936
2937
|
readOnly,
|
2937
2938
|
id
|
2938
2939
|
}) => {
|
2939
|
-
const flatOptions = (0,
|
2940
|
+
const flatOptions = (0, import_react18.useMemo)(
|
2940
2941
|
() => field.type === "select" ? field.options.map(({ value: value2 }) => value2) : [],
|
2941
2942
|
[field]
|
2942
2943
|
);
|
@@ -3088,7 +3089,7 @@ var ObjectField = ({
|
|
3088
3089
|
|
3089
3090
|
// lib/use-safe-id.ts
|
3090
3091
|
init_react_import();
|
3091
|
-
var
|
3092
|
+
var import_react19 = __toESM(require("react"));
|
3092
3093
|
|
3093
3094
|
// lib/generate-id.ts
|
3094
3095
|
init_react_import();
|
@@ -3097,10 +3098,10 @@ var generateId = (type) => type ? `${type}-${(0, import_uuid.v4)()}` : (0, impor
|
|
3097
3098
|
|
3098
3099
|
// lib/use-safe-id.ts
|
3099
3100
|
var useSafeId = () => {
|
3100
|
-
if (typeof
|
3101
|
-
return
|
3101
|
+
if (typeof import_react19.default.useId !== "undefined") {
|
3102
|
+
return import_react19.default.useId();
|
3102
3103
|
}
|
3103
|
-
const [id] = (0,
|
3104
|
+
const [id] = (0, import_react19.useState)(generateId());
|
3104
3105
|
return id;
|
3105
3106
|
};
|
3106
3107
|
|
@@ -3134,7 +3135,7 @@ var FieldLabelInternal = ({
|
|
3134
3135
|
readOnly
|
3135
3136
|
}) => {
|
3136
3137
|
const { overrides } = useAppContext();
|
3137
|
-
const Wrapper = (0,
|
3138
|
+
const Wrapper = (0, import_react20.useMemo)(
|
3138
3139
|
() => overrides.fieldLabel || FieldLabel,
|
3139
3140
|
[overrides]
|
3140
3141
|
);
|
@@ -3156,7 +3157,7 @@ var FieldLabelInternal = ({
|
|
3156
3157
|
function AutoFieldInternal(props) {
|
3157
3158
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
3158
3159
|
const { dispatch, overrides, selectedItem } = useAppContext();
|
3159
|
-
const nestedFieldContext = (0,
|
3160
|
+
const nestedFieldContext = (0, import_react20.useContext)(NestedFieldContext);
|
3160
3161
|
const { id, Label: Label2 = FieldLabelInternal } = props;
|
3161
3162
|
const field = props.field;
|
3162
3163
|
const label = field.label;
|
@@ -3188,7 +3189,7 @@ function AutoFieldInternal(props) {
|
|
3188
3189
|
Label: Label2,
|
3189
3190
|
id: resolvedId
|
3190
3191
|
});
|
3191
|
-
const onFocus = (0,
|
3192
|
+
const onFocus = (0, import_react20.useCallback)(
|
3192
3193
|
(e) => {
|
3193
3194
|
if (mergedProps.name && (e.target.nodeName === "INPUT" || e.target.nodeName === "TEXTAREA")) {
|
3194
3195
|
e.stopPropagation();
|
@@ -3202,7 +3203,7 @@ function AutoFieldInternal(props) {
|
|
3202
3203
|
},
|
3203
3204
|
[mergedProps.name]
|
3204
3205
|
);
|
3205
|
-
const onBlur = (0,
|
3206
|
+
const onBlur = (0, import_react20.useCallback)((e) => {
|
3206
3207
|
if ("name" in e.target) {
|
3207
3208
|
dispatch({
|
3208
3209
|
type: "setUi",
|
@@ -3246,7 +3247,7 @@ function AutoFieldInternal(props) {
|
|
3246
3247
|
function AutoFieldPrivate(props) {
|
3247
3248
|
const { state } = useAppContext();
|
3248
3249
|
const { value, onChange } = props;
|
3249
|
-
const [localValue, setLocalValue] = (0,
|
3250
|
+
const [localValue, setLocalValue] = (0, import_react20.useState)(value);
|
3250
3251
|
const onChangeDb = (0, import_use_debounce.useDebouncedCallback)(
|
3251
3252
|
(val, ui) => {
|
3252
3253
|
onChange(val, ui);
|
@@ -3254,11 +3255,14 @@ function AutoFieldPrivate(props) {
|
|
3254
3255
|
50,
|
3255
3256
|
{ leading: true }
|
3256
3257
|
);
|
3257
|
-
const onChangeLocal = (0,
|
3258
|
-
|
3259
|
-
|
3260
|
-
|
3261
|
-
|
3258
|
+
const onChangeLocal = (0, import_react20.useCallback)(
|
3259
|
+
(val, ui) => {
|
3260
|
+
setLocalValue(val);
|
3261
|
+
onChangeDb(val, ui);
|
3262
|
+
},
|
3263
|
+
[onChange]
|
3264
|
+
);
|
3265
|
+
(0, import_react20.useEffect)(() => {
|
3262
3266
|
if (state.ui.field.focus !== props.name) {
|
3263
3267
|
setLocalValue(value);
|
3264
3268
|
}
|
@@ -3270,7 +3274,7 @@ function AutoFieldPrivate(props) {
|
|
3270
3274
|
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(AutoFieldInternal, __spreadValues(__spreadValues({}, props), localProps));
|
3271
3275
|
}
|
3272
3276
|
function AutoField(props) {
|
3273
|
-
const DefaultLabel = (0,
|
3277
|
+
const DefaultLabel = (0, import_react20.useMemo)(() => {
|
3274
3278
|
const DefaultLabel2 = (labelProps) => /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
3275
3279
|
"div",
|
3276
3280
|
__spreadProps(__spreadValues({}, labelProps), {
|
@@ -3290,21 +3294,21 @@ init_react_import();
|
|
3290
3294
|
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
3295
|
|
3292
3296
|
// components/Drawer/index.tsx
|
3293
|
-
var
|
3297
|
+
var import_react32 = require("react");
|
3294
3298
|
|
3295
3299
|
// components/DragDropContext/index.tsx
|
3296
3300
|
init_react_import();
|
3297
|
-
var
|
3298
|
-
var
|
3301
|
+
var import_react30 = require("@dnd-kit/react");
|
3302
|
+
var import_react31 = require("react");
|
3299
3303
|
var import_dom = require("@dnd-kit/dom");
|
3300
3304
|
|
3301
3305
|
// components/DropZone/index.tsx
|
3302
3306
|
init_react_import();
|
3303
|
-
var
|
3307
|
+
var import_react29 = require("react");
|
3304
3308
|
|
3305
3309
|
// components/DraggableComponent/index.tsx
|
3306
3310
|
init_react_import();
|
3307
|
-
var
|
3311
|
+
var import_react23 = require("react");
|
3308
3312
|
|
3309
3313
|
// css-module:/home/runner/work/puck/puck/packages/core/components/DraggableComponent/styles.module.css#css-module
|
3310
3314
|
init_react_import();
|
@@ -3334,11 +3338,11 @@ function getDeepScrollPosition(element) {
|
|
3334
3338
|
|
3335
3339
|
// components/DropZone/context.tsx
|
3336
3340
|
init_react_import();
|
3337
|
-
var
|
3341
|
+
var import_react21 = require("react");
|
3338
3342
|
var import_zustand = require("zustand");
|
3339
3343
|
var import_jsx_runtime20 = require("react/jsx-runtime");
|
3340
|
-
var dropZoneContext = (0,
|
3341
|
-
var ZoneStoreContext = (0,
|
3344
|
+
var dropZoneContext = (0, import_react21.createContext)(null);
|
3345
|
+
var ZoneStoreContext = (0, import_react21.createContext)(
|
3342
3346
|
(0, import_zustand.createStore)(() => ({
|
3343
3347
|
zoneDepthIndex: {},
|
3344
3348
|
nextZoneDepthIndex: {},
|
@@ -3358,19 +3362,19 @@ var DropZoneProvider = ({
|
|
3358
3362
|
children,
|
3359
3363
|
value
|
3360
3364
|
}) => {
|
3361
|
-
const [hoveringComponent, setHoveringComponent] = (0,
|
3362
|
-
const [areasWithZones, setAreasWithZones] = (0,
|
3365
|
+
const [hoveringComponent, setHoveringComponent] = (0, import_react21.useState)();
|
3366
|
+
const [areasWithZones, setAreasWithZones] = (0, import_react21.useState)(
|
3363
3367
|
{}
|
3364
3368
|
);
|
3365
|
-
const [activeZones, setActiveZones] = (0,
|
3369
|
+
const [activeZones, setActiveZones] = (0, import_react21.useState)({});
|
3366
3370
|
const { dispatch } = useAppContext();
|
3367
|
-
const registerZoneArea = (0,
|
3371
|
+
const registerZoneArea = (0, import_react21.useCallback)(
|
3368
3372
|
(area) => {
|
3369
3373
|
setAreasWithZones((latest) => __spreadProps(__spreadValues({}, latest), { [area]: true }));
|
3370
3374
|
},
|
3371
3375
|
[setAreasWithZones]
|
3372
3376
|
);
|
3373
|
-
const registerZone = (0,
|
3377
|
+
const registerZone = (0, import_react21.useCallback)(
|
3374
3378
|
(zoneCompound) => {
|
3375
3379
|
if (!dispatch) {
|
3376
3380
|
return;
|
@@ -3383,7 +3387,7 @@ var DropZoneProvider = ({
|
|
3383
3387
|
},
|
3384
3388
|
[setActiveZones, dispatch]
|
3385
3389
|
);
|
3386
|
-
const unregisterZone = (0,
|
3390
|
+
const unregisterZone = (0, import_react21.useCallback)(
|
3387
3391
|
(zoneCompound) => {
|
3388
3392
|
if (!dispatch) {
|
3389
3393
|
return;
|
@@ -3398,7 +3402,7 @@ var DropZoneProvider = ({
|
|
3398
3402
|
},
|
3399
3403
|
[setActiveZones, dispatch]
|
3400
3404
|
);
|
3401
|
-
const memoValue = (0,
|
3405
|
+
const memoValue = (0, import_react21.useMemo)(
|
3402
3406
|
() => __spreadValues({
|
3403
3407
|
hoveringComponent,
|
3404
3408
|
setHoveringComponent,
|
@@ -3415,11 +3419,11 @@ var DropZoneProvider = ({
|
|
3415
3419
|
|
3416
3420
|
// lib/use-context-store.ts
|
3417
3421
|
init_react_import();
|
3418
|
-
var
|
3422
|
+
var import_react22 = require("react");
|
3419
3423
|
var import_zustand2 = require("zustand");
|
3420
3424
|
var import_shallow = require("zustand/react/shallow");
|
3421
3425
|
function useContextStore(context, selector) {
|
3422
|
-
const store = (0,
|
3426
|
+
const store = (0, import_react22.useContext)(context);
|
3423
3427
|
if (!store) {
|
3424
3428
|
throw new Error("useContextStore must be used inside context");
|
3425
3429
|
}
|
@@ -3478,9 +3482,9 @@ var DraggableComponent = ({
|
|
3478
3482
|
iframe,
|
3479
3483
|
state
|
3480
3484
|
} = useAppContext();
|
3481
|
-
const ctx = (0,
|
3482
|
-
const [localZones, setLocalZones] = (0,
|
3483
|
-
const registerLocalZone = (0,
|
3485
|
+
const ctx = (0, import_react23.useContext)(dropZoneContext);
|
3486
|
+
const [localZones, setLocalZones] = (0, import_react23.useState)({});
|
3487
|
+
const registerLocalZone = (0, import_react23.useCallback)(
|
3484
3488
|
(zoneCompound2, active) => {
|
3485
3489
|
var _a;
|
3486
3490
|
(_a = ctx == null ? void 0 : ctx.registerLocalZone) == null ? void 0 : _a.call(ctx, zoneCompound2, active);
|
@@ -3490,7 +3494,7 @@ var DraggableComponent = ({
|
|
3490
3494
|
},
|
3491
3495
|
[setLocalZones]
|
3492
3496
|
);
|
3493
|
-
const unregisterLocalZone = (0,
|
3497
|
+
const unregisterLocalZone = (0, import_react23.useCallback)(
|
3494
3498
|
(zoneCompound2) => {
|
3495
3499
|
var _a;
|
3496
3500
|
(_a = ctx == null ? void 0 : ctx.unregisterLocalZone) == null ? void 0 : _a.call(ctx, zoneCompound2);
|
@@ -3504,8 +3508,8 @@ var DraggableComponent = ({
|
|
3504
3508
|
);
|
3505
3509
|
const containsActiveZone = Object.values(localZones).filter(Boolean).length > 0;
|
3506
3510
|
const { path = [] } = ctx || {};
|
3507
|
-
const [canDrag, setCanDrag] = (0,
|
3508
|
-
(0,
|
3511
|
+
const [canDrag, setCanDrag] = (0, import_react23.useState)(false);
|
3512
|
+
(0, import_react23.useEffect)(() => {
|
3509
3513
|
var _a;
|
3510
3514
|
const item = getItem({ index, zone: zoneCompound }, state.data);
|
3511
3515
|
if (item) {
|
@@ -3521,7 +3525,7 @@ var DraggableComponent = ({
|
|
3521
3525
|
);
|
3522
3526
|
const canCollide = canDrag || userIsDragging;
|
3523
3527
|
const disabled = !isEnabled || !canCollide;
|
3524
|
-
const [dragAxis, setDragAxis] = (0,
|
3528
|
+
const [dragAxis, setDragAxis] = (0, import_react23.useState)(userDragAxis || autoDragAxis);
|
3525
3529
|
const { ref: sortableRef, status } = useSortableSafe({
|
3526
3530
|
id,
|
3527
3531
|
index,
|
@@ -3547,8 +3551,8 @@ var DraggableComponent = ({
|
|
3547
3551
|
}
|
3548
3552
|
});
|
3549
3553
|
const thisIsDragging = status === "dragging";
|
3550
|
-
const ref = (0,
|
3551
|
-
const refSetter = (0,
|
3554
|
+
const ref = (0, import_react23.useRef)(null);
|
3555
|
+
const refSetter = (0, import_react23.useCallback)(
|
3552
3556
|
(el) => {
|
3553
3557
|
sortableRef(el);
|
3554
3558
|
if (el) {
|
@@ -3557,14 +3561,14 @@ var DraggableComponent = ({
|
|
3557
3561
|
},
|
3558
3562
|
[sortableRef]
|
3559
3563
|
);
|
3560
|
-
const [portalEl, setPortalEl] = (0,
|
3561
|
-
(0,
|
3564
|
+
const [portalEl, setPortalEl] = (0, import_react23.useState)();
|
3565
|
+
(0, import_react23.useEffect)(() => {
|
3562
3566
|
var _a, _b, _c;
|
3563
3567
|
setPortalEl(
|
3564
3568
|
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
3569
|
);
|
3566
3570
|
}, [iframe.enabled, ref.current]);
|
3567
|
-
const getStyle = (0,
|
3571
|
+
const getStyle = (0, import_react23.useCallback)(() => {
|
3568
3572
|
var _a, _b, _c;
|
3569
3573
|
if (!ref.current) return;
|
3570
3574
|
const rect = ref.current.getBoundingClientRect();
|
@@ -3584,11 +3588,11 @@ var DraggableComponent = ({
|
|
3584
3588
|
};
|
3585
3589
|
return style2;
|
3586
3590
|
}, [ref.current]);
|
3587
|
-
const [style, setStyle] = (0,
|
3588
|
-
const sync = (0,
|
3591
|
+
const [style, setStyle] = (0, import_react23.useState)();
|
3592
|
+
const sync = (0, import_react23.useCallback)(() => {
|
3589
3593
|
setStyle(getStyle());
|
3590
3594
|
}, [ref.current, iframe]);
|
3591
|
-
(0,
|
3595
|
+
(0, import_react23.useEffect)(() => {
|
3592
3596
|
if (ref.current && !userIsDragging) {
|
3593
3597
|
const observer = new ResizeObserver(sync);
|
3594
3598
|
observer.observe(ref.current);
|
@@ -3597,7 +3601,7 @@ var DraggableComponent = ({
|
|
3597
3601
|
};
|
3598
3602
|
}
|
3599
3603
|
}, [ref.current, userIsDragging]);
|
3600
|
-
(0,
|
3604
|
+
(0, import_react23.useEffect)(() => {
|
3601
3605
|
ctx == null ? void 0 : ctx.registerPath(
|
3602
3606
|
id,
|
3603
3607
|
{
|
@@ -3611,14 +3615,14 @@ var DraggableComponent = ({
|
|
3611
3615
|
(_a = ctx == null ? void 0 : ctx.unregisterPath) == null ? void 0 : _a.call(ctx, id);
|
3612
3616
|
};
|
3613
3617
|
}, [id, zoneCompound, index, componentType]);
|
3614
|
-
const CustomActionBar = (0,
|
3618
|
+
const CustomActionBar = (0, import_react23.useMemo)(
|
3615
3619
|
() => overrides.actionBar || DefaultActionBar,
|
3616
3620
|
[overrides.actionBar]
|
3617
3621
|
);
|
3618
3622
|
const permissions = getPermissions({
|
3619
3623
|
item: selectedItem
|
3620
3624
|
});
|
3621
|
-
const onClick = (0,
|
3625
|
+
const onClick = (0, import_react23.useCallback)(
|
3622
3626
|
(e) => {
|
3623
3627
|
e.stopPropagation();
|
3624
3628
|
dispatch({
|
@@ -3630,7 +3634,7 @@ var DraggableComponent = ({
|
|
3630
3634
|
},
|
3631
3635
|
[index, zoneCompound, id]
|
3632
3636
|
);
|
3633
|
-
const onSelectParent = (0,
|
3637
|
+
const onSelectParent = (0, import_react23.useCallback)(() => {
|
3634
3638
|
if (!(ctx == null ? void 0 : ctx.areaId)) {
|
3635
3639
|
return;
|
3636
3640
|
}
|
@@ -3648,23 +3652,23 @@ var DraggableComponent = ({
|
|
3648
3652
|
}
|
3649
3653
|
});
|
3650
3654
|
}, [ctx, path]);
|
3651
|
-
const onDuplicate = (0,
|
3655
|
+
const onDuplicate = (0, import_react23.useCallback)(() => {
|
3652
3656
|
dispatch({
|
3653
3657
|
type: "duplicate",
|
3654
3658
|
sourceIndex: index,
|
3655
3659
|
sourceZone: zoneCompound
|
3656
3660
|
});
|
3657
3661
|
}, [index, zoneCompound]);
|
3658
|
-
const onDelete = (0,
|
3662
|
+
const onDelete = (0, import_react23.useCallback)(() => {
|
3659
3663
|
dispatch({
|
3660
3664
|
type: "remove",
|
3661
3665
|
index,
|
3662
3666
|
zone: zoneCompound
|
3663
3667
|
});
|
3664
3668
|
}, [index, zoneCompound]);
|
3665
|
-
const [hover, setHover] = (0,
|
3669
|
+
const [hover, setHover] = (0, import_react23.useState)(false);
|
3666
3670
|
const indicativeHover = (ctx == null ? void 0 : ctx.hoveringComponent) === id;
|
3667
|
-
(0,
|
3671
|
+
(0, import_react23.useEffect)(() => {
|
3668
3672
|
if (!ref.current) {
|
3669
3673
|
return;
|
3670
3674
|
}
|
@@ -3714,7 +3718,7 @@ var DraggableComponent = ({
|
|
3714
3718
|
thisIsDragging,
|
3715
3719
|
inDroppableZone
|
3716
3720
|
]);
|
3717
|
-
(0,
|
3721
|
+
(0, import_react23.useEffect)(() => {
|
3718
3722
|
if (ref.current && disabled) {
|
3719
3723
|
ref.current.setAttribute("data-puck-disabled", "");
|
3720
3724
|
return () => {
|
@@ -3723,8 +3727,8 @@ var DraggableComponent = ({
|
|
3723
3727
|
};
|
3724
3728
|
}
|
3725
3729
|
}, [disabled, ref]);
|
3726
|
-
const [isVisible, setIsVisible] = (0,
|
3727
|
-
(0,
|
3730
|
+
const [isVisible, setIsVisible] = (0, import_react23.useState)(false);
|
3731
|
+
(0, import_react23.useEffect)(() => {
|
3728
3732
|
sync();
|
3729
3733
|
if ((isSelected || hover || indicativeHover) && !userIsDragging) {
|
3730
3734
|
setIsVisible(true);
|
@@ -3732,7 +3736,7 @@ var DraggableComponent = ({
|
|
3732
3736
|
setIsVisible(false);
|
3733
3737
|
}
|
3734
3738
|
}, [isSelected, hover, indicativeHover, iframe, state.data, userIsDragging]);
|
3735
|
-
const syncActionsPosition = (0,
|
3739
|
+
const syncActionsPosition = (0, import_react23.useCallback)(
|
3736
3740
|
(el) => {
|
3737
3741
|
if (el) {
|
3738
3742
|
const view = el.ownerDocument.defaultView;
|
@@ -3740,16 +3744,24 @@ var DraggableComponent = ({
|
|
3740
3744
|
const rect = el.getBoundingClientRect();
|
3741
3745
|
const diffLeft = rect.x;
|
3742
3746
|
const exceedsBoundsLeft = diffLeft < 0;
|
3747
|
+
const diffTop = rect.y;
|
3748
|
+
const exceedsBoundsTop = diffTop < 0;
|
3743
3749
|
if (exceedsBoundsLeft) {
|
3744
3750
|
el.style.transformOrigin = "left top";
|
3745
3751
|
el.style.left = "0px";
|
3746
3752
|
}
|
3753
|
+
if (exceedsBoundsTop) {
|
3754
|
+
el.style.top = "12px";
|
3755
|
+
if (!exceedsBoundsLeft) {
|
3756
|
+
el.style.transformOrigin = "right top";
|
3757
|
+
}
|
3758
|
+
}
|
3747
3759
|
}
|
3748
3760
|
}
|
3749
3761
|
},
|
3750
3762
|
[zoomConfig]
|
3751
3763
|
);
|
3752
|
-
(0,
|
3764
|
+
(0, import_react23.useEffect)(() => {
|
3753
3765
|
if (userDragAxis) {
|
3754
3766
|
setDragAxis(userDragAxis);
|
3755
3767
|
return;
|
@@ -3843,14 +3855,14 @@ var styles_module_default12 = { "DropZone": "_DropZone_kmkdc_1", "DropZone--isAc
|
|
3843
3855
|
|
3844
3856
|
// components/DropZone/lib/use-min-empty-height.ts
|
3845
3857
|
init_react_import();
|
3846
|
-
var
|
3858
|
+
var import_react24 = require("react");
|
3847
3859
|
var useMinEmptyHeight = ({
|
3848
3860
|
zoneCompound,
|
3849
3861
|
userMinEmptyHeight,
|
3850
3862
|
ref
|
3851
3863
|
}) => {
|
3852
|
-
const [prevHeight, setPrevHeight] = (0,
|
3853
|
-
const [isAnimating, setIsAnimating] = (0,
|
3864
|
+
const [prevHeight, setPrevHeight] = (0, import_react24.useState)(0);
|
3865
|
+
const [isAnimating, setIsAnimating] = (0, import_react24.useState)(false);
|
3854
3866
|
const { draggedItem, isZone } = useContextStore(ZoneStoreContext, (s) => {
|
3855
3867
|
var _a, _b;
|
3856
3868
|
return {
|
@@ -3858,7 +3870,7 @@ var useMinEmptyHeight = ({
|
|
3858
3870
|
isZone: ((_b = s.draggedItem) == null ? void 0 : _b.data.zone) === zoneCompound
|
3859
3871
|
};
|
3860
3872
|
});
|
3861
|
-
(0,
|
3873
|
+
(0, import_react24.useEffect)(() => {
|
3862
3874
|
if (draggedItem && ref.current) {
|
3863
3875
|
if (isZone) {
|
3864
3876
|
const rect = ref.current.getBoundingClientRect();
|
@@ -3892,15 +3904,15 @@ function assignRefs(refs, node) {
|
|
3892
3904
|
|
3893
3905
|
// components/DropZone/lib/use-content-with-preview.ts
|
3894
3906
|
init_react_import();
|
3895
|
-
var
|
3907
|
+
var import_react27 = require("react");
|
3896
3908
|
|
3897
3909
|
// lib/dnd/use-rendered-callback.ts
|
3898
3910
|
init_react_import();
|
3899
|
-
var
|
3900
|
-
var
|
3911
|
+
var import_react25 = require("@dnd-kit/react");
|
3912
|
+
var import_react26 = require("react");
|
3901
3913
|
function useRenderedCallback(callback, deps) {
|
3902
|
-
const manager = (0,
|
3903
|
-
return (0,
|
3914
|
+
const manager = (0, import_react25.useDragDropManager)();
|
3915
|
+
return (0, import_react26.useCallback)(
|
3904
3916
|
(...args) => __async(this, null, function* () {
|
3905
3917
|
yield manager == null ? void 0 : manager.renderer.rendering;
|
3906
3918
|
return callback(...args);
|
@@ -3935,8 +3947,8 @@ var useContentWithPreview = (content, zoneCompound) => {
|
|
3935
3947
|
ui: { isDragging }
|
3936
3948
|
}
|
3937
3949
|
} = useAppContext();
|
3938
|
-
const [contentWithPreview, setContentWithPreview] = (0,
|
3939
|
-
const [localPreview, setLocalPreview] = (0,
|
3950
|
+
const [contentWithPreview, setContentWithPreview] = (0, import_react27.useState)(content);
|
3951
|
+
const [localPreview, setLocalPreview] = (0, import_react27.useState)(
|
3940
3952
|
preview
|
3941
3953
|
);
|
3942
3954
|
const updateContent = useRenderedCallback(
|
@@ -3977,7 +3989,7 @@ var useContentWithPreview = (content, zoneCompound) => {
|
|
3977
3989
|
},
|
3978
3990
|
[draggedItemId, previewExists]
|
3979
3991
|
);
|
3980
|
-
(0,
|
3992
|
+
(0, import_react27.useEffect)(() => {
|
3981
3993
|
updateContent(content, preview, isDragging);
|
3982
3994
|
}, [content, preview, isDragging]);
|
3983
3995
|
return [contentWithPreview, localPreview];
|
@@ -3985,16 +3997,16 @@ var useContentWithPreview = (content, zoneCompound) => {
|
|
3985
3997
|
|
3986
3998
|
// components/DropZone/lib/use-drag-axis.ts
|
3987
3999
|
init_react_import();
|
3988
|
-
var
|
4000
|
+
var import_react28 = require("react");
|
3989
4001
|
var GRID_DRAG_AXIS = "dynamic";
|
3990
4002
|
var FLEX_ROW_DRAG_AXIS = "x";
|
3991
4003
|
var DEFAULT_DRAG_AXIS = "y";
|
3992
4004
|
var useDragAxis = (ref, collisionAxis) => {
|
3993
4005
|
const { status } = useAppContext();
|
3994
|
-
const [dragAxis, setDragAxis] = (0,
|
4006
|
+
const [dragAxis, setDragAxis] = (0, import_react28.useState)(
|
3995
4007
|
collisionAxis || DEFAULT_DRAG_AXIS
|
3996
4008
|
);
|
3997
|
-
const calculateDragAxis = (0,
|
4009
|
+
const calculateDragAxis = (0, import_react28.useCallback)(() => {
|
3998
4010
|
if (ref.current) {
|
3999
4011
|
const computedStyle = window.getComputedStyle(ref.current);
|
4000
4012
|
if (computedStyle.display === "grid") {
|
@@ -4006,7 +4018,7 @@ var useDragAxis = (ref, collisionAxis) => {
|
|
4006
4018
|
}
|
4007
4019
|
}
|
4008
4020
|
}, [ref.current]);
|
4009
|
-
(0,
|
4021
|
+
(0, import_react28.useEffect)(() => {
|
4010
4022
|
const onViewportChange = () => {
|
4011
4023
|
calculateDragAxis();
|
4012
4024
|
};
|
@@ -4015,7 +4027,7 @@ var useDragAxis = (ref, collisionAxis) => {
|
|
4015
4027
|
window.removeEventListener("viewportchange", onViewportChange);
|
4016
4028
|
};
|
4017
4029
|
}, []);
|
4018
|
-
(0,
|
4030
|
+
(0, import_react28.useEffect)(calculateDragAxis, [status, collisionAxis]);
|
4019
4031
|
return [dragAxis, calculateDragAxis];
|
4020
4032
|
};
|
4021
4033
|
|
@@ -4025,7 +4037,7 @@ var getClassName17 = get_class_name_factory_default("DropZone", styles_module_de
|
|
4025
4037
|
var getRandomColor = () => `#${Math.floor(Math.random() * 16777215).toString(16)}`;
|
4026
4038
|
var RENDER_DEBUG = false;
|
4027
4039
|
var DropZoneEditPure = (props) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(DropZoneEdit, __spreadValues({}, props));
|
4028
|
-
var DropZoneEdit = (0,
|
4040
|
+
var DropZoneEdit = (0, import_react29.forwardRef)(
|
4029
4041
|
function DropZoneEditInternal({
|
4030
4042
|
zone,
|
4031
4043
|
allow,
|
@@ -4036,7 +4048,7 @@ var DropZoneEdit = (0, import_react30.forwardRef)(
|
|
4036
4048
|
collisionAxis
|
4037
4049
|
}, userRef) {
|
4038
4050
|
const appContext2 = useAppContext();
|
4039
|
-
const ctx = (0,
|
4051
|
+
const ctx = (0, import_react29.useContext)(dropZoneContext);
|
4040
4052
|
const {
|
4041
4053
|
// These all need setting via context
|
4042
4054
|
data,
|
@@ -4072,12 +4084,12 @@ var DropZoneEdit = (0, import_react30.forwardRef)(
|
|
4072
4084
|
};
|
4073
4085
|
});
|
4074
4086
|
const { itemSelector } = appContext2.state.ui;
|
4075
|
-
(0,
|
4087
|
+
(0, import_react29.useEffect)(() => {
|
4076
4088
|
if (areaId && registerZoneArea) {
|
4077
4089
|
registerZoneArea(areaId);
|
4078
4090
|
}
|
4079
4091
|
}, [areaId]);
|
4080
|
-
(0,
|
4092
|
+
(0, import_react29.useEffect)(() => {
|
4081
4093
|
if (ctx == null ? void 0 : ctx.registerZone) {
|
4082
4094
|
ctx == null ? void 0 : ctx.registerZone(zoneCompound);
|
4083
4095
|
}
|
@@ -4087,14 +4099,14 @@ var DropZoneEdit = (0, import_react30.forwardRef)(
|
|
4087
4099
|
}
|
4088
4100
|
};
|
4089
4101
|
}, []);
|
4090
|
-
const content = (0,
|
4102
|
+
const content = (0, import_react29.useMemo)(() => {
|
4091
4103
|
if (areaId && zone !== rootDroppableId) {
|
4092
4104
|
return setupZone(data, zoneCompound).zones[zoneCompound];
|
4093
4105
|
}
|
4094
4106
|
return data.content || [];
|
4095
4107
|
}, [data, zoneCompound]);
|
4096
|
-
const ref = (0,
|
4097
|
-
const acceptsTarget = (0,
|
4108
|
+
const ref = (0, import_react29.useRef)(null);
|
4109
|
+
const acceptsTarget = (0, import_react29.useCallback)(
|
4098
4110
|
(componentType) => {
|
4099
4111
|
if (!componentType) {
|
4100
4112
|
return true;
|
@@ -4116,7 +4128,7 @@ var DropZoneEdit = (0, import_react30.forwardRef)(
|
|
4116
4128
|
},
|
4117
4129
|
[allow, disallow]
|
4118
4130
|
);
|
4119
|
-
(0,
|
4131
|
+
(0, import_react29.useEffect)(() => {
|
4120
4132
|
if (registerLocalZone) {
|
4121
4133
|
registerLocalZone(zoneCompound, acceptsTarget(draggedComponentType));
|
4122
4134
|
}
|
@@ -4251,13 +4263,13 @@ var DropZoneEdit = (0, import_react30.forwardRef)(
|
|
4251
4263
|
}
|
4252
4264
|
);
|
4253
4265
|
var DropZoneRenderPure = (props) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(DropZoneRender, __spreadValues({}, props));
|
4254
|
-
var DropZoneRender = (0,
|
4266
|
+
var DropZoneRender = (0, import_react29.forwardRef)(
|
4255
4267
|
function DropZoneRenderInternal({ className, style, zone }, ref) {
|
4256
|
-
const ctx = (0,
|
4268
|
+
const ctx = (0, import_react29.useContext)(dropZoneContext);
|
4257
4269
|
const { data, areaId = "root", config } = ctx || {};
|
4258
4270
|
let zoneCompound = rootDroppableId;
|
4259
4271
|
let content = (data == null ? void 0 : data.content) || [];
|
4260
|
-
(0,
|
4272
|
+
(0, import_react29.useEffect)(() => {
|
4261
4273
|
if (ctx == null ? void 0 : ctx.registerZone) {
|
4262
4274
|
ctx == null ? void 0 : ctx.registerZone(zoneCompound);
|
4263
4275
|
}
|
@@ -4304,9 +4316,9 @@ var DropZoneRender = (0, import_react30.forwardRef)(
|
|
4304
4316
|
}
|
4305
4317
|
);
|
4306
4318
|
var DropZonePure = (props) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(DropZone, __spreadValues({}, props));
|
4307
|
-
var DropZone = (0,
|
4319
|
+
var DropZone = (0, import_react29.forwardRef)(
|
4308
4320
|
function DropZone2(props, ref) {
|
4309
|
-
const ctx = (0,
|
4321
|
+
const ctx = (0, import_react29.useContext)(dropZoneContext);
|
4310
4322
|
if ((ctx == null ? void 0 : ctx.mode) === "edit") {
|
4311
4323
|
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_jsx_runtime22.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(DropZoneEdit, __spreadProps(__spreadValues({}, props), { ref })) });
|
4312
4324
|
}
|
@@ -5001,12 +5013,12 @@ function getDeepDir(el) {
|
|
5001
5013
|
// components/DragDropContext/index.tsx
|
5002
5014
|
var import_jsx_runtime23 = require("react/jsx-runtime");
|
5003
5015
|
var DEBUG3 = false;
|
5004
|
-
var dragListenerContext = (0,
|
5016
|
+
var dragListenerContext = (0, import_react31.createContext)({
|
5005
5017
|
dragListeners: {}
|
5006
5018
|
});
|
5007
5019
|
function useDragListener(type, fn, deps = []) {
|
5008
|
-
const { setDragListeners } = (0,
|
5009
|
-
(0,
|
5020
|
+
const { setDragListeners } = (0, import_react31.useContext)(dragListenerContext);
|
5021
|
+
(0, import_react31.useEffect)(() => {
|
5010
5022
|
if (setDragListeners) {
|
5011
5023
|
setDragListeners((old) => __spreadProps(__spreadValues({}, old), {
|
5012
5024
|
[type]: [...old[type] || [], fn]
|
@@ -5016,8 +5028,8 @@ function useDragListener(type, fn, deps = []) {
|
|
5016
5028
|
}
|
5017
5029
|
var AREA_CHANGE_DEBOUNCE_MS = 100;
|
5018
5030
|
var useTempDisableFallback = (timeout3) => {
|
5019
|
-
const lastFallbackDisable = (0,
|
5020
|
-
return (0,
|
5031
|
+
const lastFallbackDisable = (0, import_react31.useRef)(null);
|
5032
|
+
return (0, import_react31.useCallback)((manager) => {
|
5021
5033
|
collisionStore.setState({ fallbackEnabled: false });
|
5022
5034
|
const fallbackId = generateId();
|
5023
5035
|
lastFallbackDisable.current = fallbackId;
|
@@ -5034,11 +5046,11 @@ var DragDropContextClient = ({
|
|
5034
5046
|
disableAutoScroll
|
5035
5047
|
}) => {
|
5036
5048
|
const { state, config, dispatch, resolveData } = useAppContext();
|
5037
|
-
const id = (0,
|
5049
|
+
const id = (0, import_react31.useId)();
|
5038
5050
|
const { data } = state;
|
5039
|
-
const debouncedParamsRef = (0,
|
5051
|
+
const debouncedParamsRef = (0, import_react31.useRef)(null);
|
5040
5052
|
const tempDisableFallback = useTempDisableFallback(100);
|
5041
|
-
const [zoneStore] = (0,
|
5053
|
+
const [zoneStore] = (0, import_react31.useState)(
|
5042
5054
|
() => (0, import_zustand3.createStore)(() => ({
|
5043
5055
|
zoneDepthIndex: {},
|
5044
5056
|
nextZoneDepthIndex: {},
|
@@ -5048,7 +5060,7 @@ var DragDropContextClient = ({
|
|
5048
5060
|
previewIndex: {}
|
5049
5061
|
}))
|
5050
5062
|
);
|
5051
|
-
const getChanged2 = (0,
|
5063
|
+
const getChanged2 = (0, import_react31.useCallback)(
|
5052
5064
|
(params, id2) => {
|
5053
5065
|
const { zoneDepthIndex = {}, areaDepthIndex = {} } = zoneStore.getState() || {};
|
5054
5066
|
const stateHasZone = Object.keys(zoneDepthIndex).length > 0;
|
@@ -5069,7 +5081,7 @@ var DragDropContextClient = ({
|
|
5069
5081
|
},
|
5070
5082
|
[zoneStore]
|
5071
5083
|
);
|
5072
|
-
const setDeepestAndCollide = (0,
|
5084
|
+
const setDeepestAndCollide = (0, import_react31.useCallback)(
|
5073
5085
|
(params, manager) => {
|
5074
5086
|
const { zoneChanged, areaChanged } = getChanged2(params, id);
|
5075
5087
|
if (!zoneChanged && !areaChanged) return;
|
@@ -5093,7 +5105,7 @@ var DragDropContextClient = ({
|
|
5093
5105
|
setDeepestDb.cancel();
|
5094
5106
|
debouncedParamsRef.current = null;
|
5095
5107
|
};
|
5096
|
-
(0,
|
5108
|
+
(0, import_react31.useEffect)(() => {
|
5097
5109
|
if (DEBUG3) {
|
5098
5110
|
zoneStore.subscribe(
|
5099
5111
|
(s) => {
|
@@ -5107,7 +5119,7 @@ var DragDropContextClient = ({
|
|
5107
5119
|
);
|
5108
5120
|
}
|
5109
5121
|
}, []);
|
5110
|
-
const [plugins] = (0,
|
5122
|
+
const [plugins] = (0, import_react31.useState)(() => [
|
5111
5123
|
...disableAutoScroll ? import_dom.defaultPreset.plugins.filter((plugin) => plugin !== import_dom.AutoScroller) : import_dom.defaultPreset.plugins,
|
5112
5124
|
createNestedDroppablePlugin(
|
5113
5125
|
{
|
@@ -5155,10 +5167,10 @@ var DragDropContextClient = ({
|
|
5155
5167
|
)
|
5156
5168
|
]);
|
5157
5169
|
const sensors = useSensors();
|
5158
|
-
const [dragListeners, setDragListeners] = (0,
|
5159
|
-
const [pathData, setPathData] = (0,
|
5160
|
-
const dragMode = (0,
|
5161
|
-
const registerPath = (0,
|
5170
|
+
const [dragListeners, setDragListeners] = (0, import_react31.useState)({});
|
5171
|
+
const [pathData, setPathData] = (0, import_react31.useState)();
|
5172
|
+
const dragMode = (0, import_react31.useRef)(null);
|
5173
|
+
const registerPath = (0, import_react31.useCallback)(
|
5162
5174
|
(id2, selector, label) => {
|
5163
5175
|
const [area] = getZoneId(selector.zone);
|
5164
5176
|
setPathData((latestPathData = {}) => {
|
@@ -5176,7 +5188,7 @@ var DragDropContextClient = ({
|
|
5176
5188
|
},
|
5177
5189
|
[data, setPathData]
|
5178
5190
|
);
|
5179
|
-
const unregisterPath = (0,
|
5191
|
+
const unregisterPath = (0, import_react31.useCallback)(
|
5180
5192
|
(id2) => {
|
5181
5193
|
setPathData((latestPathData = {}) => {
|
5182
5194
|
const newPathData = __spreadValues({}, latestPathData);
|
@@ -5186,7 +5198,7 @@ var DragDropContextClient = ({
|
|
5186
5198
|
},
|
5187
5199
|
[data, setPathData]
|
5188
5200
|
);
|
5189
|
-
const initialSelector = (0,
|
5201
|
+
const initialSelector = (0, import_react31.useRef)(void 0);
|
5190
5202
|
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { id, children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
5191
5203
|
dragListenerContext.Provider,
|
5192
5204
|
{
|
@@ -5195,7 +5207,7 @@ var DragDropContextClient = ({
|
|
5195
5207
|
setDragListeners
|
5196
5208
|
},
|
5197
5209
|
children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
5198
|
-
|
5210
|
+
import_react30.DragDropProvider,
|
5199
5211
|
{
|
5200
5212
|
plugins,
|
5201
5213
|
sensors,
|
@@ -5424,7 +5436,7 @@ var DrawerItemInner = ({
|
|
5424
5436
|
dragRef,
|
5425
5437
|
isDragDisabled
|
5426
5438
|
}) => {
|
5427
|
-
const CustomInner = (0,
|
5439
|
+
const CustomInner = (0, import_react32.useMemo)(
|
5428
5440
|
() => children || (({ children: children2 }) => /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: getClassNameItem2("default"), children: children2 })),
|
5429
5441
|
[children]
|
5430
5442
|
);
|
@@ -5478,7 +5490,7 @@ var DrawerItem = ({
|
|
5478
5490
|
isDragDisabled
|
5479
5491
|
}) => {
|
5480
5492
|
const resolvedId = id || name;
|
5481
|
-
const [dynamicId, setDynamicId] = (0,
|
5493
|
+
const [dynamicId, setDynamicId] = (0, import_react32.useState)(generateId(resolvedId));
|
5482
5494
|
if (typeof index !== "undefined") {
|
5483
5495
|
console.error(
|
5484
5496
|
"Warning: The `index` prop on Drawer.Item is deprecated and no longer required."
|
@@ -5517,7 +5529,7 @@ var Drawer = ({
|
|
5517
5529
|
"Warning: The `direction` prop on Drawer is deprecated and no longer required to achieve multi-directional dragging."
|
5518
5530
|
);
|
5519
5531
|
}
|
5520
|
-
const id = (0,
|
5532
|
+
const id = (0, import_react32.useId)();
|
5521
5533
|
const { ref } = useDroppableSafe({
|
5522
5534
|
id,
|
5523
5535
|
type: "void",
|
@@ -5539,7 +5551,7 @@ Drawer.Item = DrawerItem;
|
|
5539
5551
|
|
5540
5552
|
// components/Puck/index.tsx
|
5541
5553
|
init_react_import();
|
5542
|
-
var
|
5554
|
+
var import_react50 = require("react");
|
5543
5555
|
|
5544
5556
|
// components/SidebarSection/index.tsx
|
5545
5557
|
init_react_import();
|
@@ -5550,7 +5562,7 @@ var styles_module_default13 = { "SidebarSection": "_SidebarSection_8boj8_1", "Si
|
|
5550
5562
|
|
5551
5563
|
// lib/use-breadcrumbs.ts
|
5552
5564
|
init_react_import();
|
5553
|
-
var
|
5565
|
+
var import_react33 = require("react");
|
5554
5566
|
var convertPathDataToBreadcrumbs = (selectedItem, pathData, data) => {
|
5555
5567
|
const id = selectedItem ? selectedItem == null ? void 0 : selectedItem.props.id : "";
|
5556
5568
|
const currentPathData = pathData && id && pathData[id] ? __spreadValues({}, pathData[id]) : { label: "Page", path: [] };
|
@@ -5600,8 +5612,8 @@ var useBreadcrumbs = (renderCount) => {
|
|
5600
5612
|
state: { data },
|
5601
5613
|
selectedItem
|
5602
5614
|
} = useAppContext();
|
5603
|
-
const dzContext = (0,
|
5604
|
-
return (0,
|
5615
|
+
const dzContext = (0, import_react33.useContext)(dropZoneContext);
|
5616
|
+
return (0, import_react33.useMemo)(() => {
|
5605
5617
|
const breadcrumbs = convertPathDataToBreadcrumbs(
|
5606
5618
|
selectedItem,
|
5607
5619
|
dzContext == null ? void 0 : dzContext.pathData,
|
@@ -5735,15 +5747,15 @@ init_react_import();
|
|
5735
5747
|
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
5748
|
|
5737
5749
|
// components/Puck/components/Fields/index.tsx
|
5738
|
-
var
|
5750
|
+
var import_react37 = require("react");
|
5739
5751
|
|
5740
5752
|
// lib/use-resolved-fields.ts
|
5741
5753
|
init_react_import();
|
5742
|
-
var
|
5754
|
+
var import_react36 = require("react");
|
5743
5755
|
|
5744
5756
|
// lib/use-parent.ts
|
5745
5757
|
init_react_import();
|
5746
|
-
var
|
5758
|
+
var import_react34 = require("react");
|
5747
5759
|
var getParent = (itemSelector, pathData, data) => {
|
5748
5760
|
var _a;
|
5749
5761
|
if (!itemSelector) return null;
|
@@ -5755,8 +5767,8 @@ var getParent = (itemSelector, pathData, data) => {
|
|
5755
5767
|
};
|
5756
5768
|
var useGetParent = () => {
|
5757
5769
|
const { state } = useAppContext();
|
5758
|
-
const { pathData } = (0,
|
5759
|
-
return (0,
|
5770
|
+
const { pathData } = (0, import_react34.useContext)(dropZoneContext) || {};
|
5771
|
+
return (0, import_react34.useCallback)(
|
5760
5772
|
() => getParent(state.ui.itemSelector, pathData, state.data),
|
5761
5773
|
[state.ui.itemSelector, pathData, state.data]
|
5762
5774
|
);
|
@@ -5767,10 +5779,10 @@ var useParent = () => {
|
|
5767
5779
|
|
5768
5780
|
// lib/use-on-value-change.ts
|
5769
5781
|
init_react_import();
|
5770
|
-
var
|
5782
|
+
var import_react35 = require("react");
|
5771
5783
|
function useOnValueChange(value, onChange, compare = Object.is, deps = []) {
|
5772
|
-
const tracked = (0,
|
5773
|
-
(0,
|
5784
|
+
const tracked = (0, import_react35.useRef)(value);
|
5785
|
+
(0, import_react35.useEffect)(() => {
|
5774
5786
|
const oldValue = tracked.current;
|
5775
5787
|
if (!compare(value, oldValue)) {
|
5776
5788
|
tracked.current = value;
|
@@ -5797,27 +5809,27 @@ var useResolvedFields = ({
|
|
5797
5809
|
const { data } = state;
|
5798
5810
|
const rootFields = ((_a = config.root) == null ? void 0 : _a.fields) || defaultPageFields;
|
5799
5811
|
const componentConfig = selectedItem ? config.components[selectedItem.type] : null;
|
5800
|
-
const defaultFields = (0,
|
5812
|
+
const defaultFields = (0, import_react36.useMemo)(
|
5801
5813
|
() => (selectedItem ? componentConfig == null ? void 0 : componentConfig.fields : rootFields) || {},
|
5802
5814
|
[selectedItem, rootFields, componentConfig == null ? void 0 : componentConfig.fields]
|
5803
5815
|
);
|
5804
5816
|
const rootProps = data.root.props || data.root;
|
5805
|
-
const [lastSelectedData, setLastSelectedData] = (0,
|
5806
|
-
const [resolvedFields, setResolvedFields] = (0,
|
5817
|
+
const [lastSelectedData, setLastSelectedData] = (0, import_react36.useState)({});
|
5818
|
+
const [resolvedFields, setResolvedFields] = (0, import_react36.useState)({
|
5807
5819
|
fields: defaultFields,
|
5808
5820
|
id: selectedItem == null ? void 0 : selectedItem.props.id
|
5809
5821
|
});
|
5810
|
-
const [fieldsLoading, setFieldsLoading] = (0,
|
5811
|
-
const lastFields = (0,
|
5822
|
+
const [fieldsLoading, setFieldsLoading] = (0, import_react36.useState)(false);
|
5823
|
+
const lastFields = (0, import_react36.useRef)(defaultFields);
|
5812
5824
|
const defaultResolveFields = (_componentData, _params) => defaultFields;
|
5813
|
-
const componentData = (0,
|
5825
|
+
const componentData = (0, import_react36.useMemo)(
|
5814
5826
|
() => selectedItem ? selectedItem : { props: rootProps, readOnly: data.root.readOnly || {} },
|
5815
5827
|
[selectedItem, rootProps, data.root.readOnly]
|
5816
5828
|
);
|
5817
5829
|
const hasComponentResolver = selectedItem && (componentConfig == null ? void 0 : componentConfig.resolveFields);
|
5818
5830
|
const hasRootResolver = !selectedItem && ((_b = config.root) == null ? void 0 : _b.resolveFields);
|
5819
5831
|
const hasResolver = hasComponentResolver || hasRootResolver;
|
5820
|
-
const resolveFields = (0,
|
5832
|
+
const resolveFields = (0, import_react36.useCallback)(
|
5821
5833
|
(..._0) => __async(void 0, [..._0], function* (fields = {}) {
|
5822
5834
|
var _a2;
|
5823
5835
|
const lastData = ((_a2 = lastSelectedData.props) == null ? void 0 : _a2.id) === componentData.props.id ? lastSelectedData : null;
|
@@ -5855,7 +5867,7 @@ var useResolvedFields = ({
|
|
5855
5867
|
}),
|
5856
5868
|
[data, config, componentData, selectedItem, state, parent]
|
5857
5869
|
);
|
5858
|
-
const triggerResolver = (0,
|
5870
|
+
const triggerResolver = (0, import_react36.useCallback)(() => {
|
5859
5871
|
var _a2, _b2;
|
5860
5872
|
if (!((_a2 = state.ui.itemSelector) == null ? void 0 : _a2.zone) || ((_b2 = state.ui.itemSelector) == null ? void 0 : _b2.zone) === "default-zone" || parent) {
|
5861
5873
|
if (hasResolver) {
|
@@ -5895,7 +5907,7 @@ var useResolvedFields = ({
|
|
5895
5907
|
},
|
5896
5908
|
(a, b) => JSON.stringify(a) === JSON.stringify(b)
|
5897
5909
|
);
|
5898
|
-
(0,
|
5910
|
+
(0, import_react36.useEffect)(() => {
|
5899
5911
|
triggerResolver();
|
5900
5912
|
}, []);
|
5901
5913
|
if (resolvedFields.id !== (selectedItem == null ? void 0 : selectedItem.props.id) && !_skipIdCheck) {
|
@@ -5930,7 +5942,7 @@ var Fields = ({ wrapFields = true }) => {
|
|
5930
5942
|
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
5943
|
const isLoading = fieldsResolving || componentResolving;
|
5932
5944
|
const rootProps = data.root.props || data.root;
|
5933
|
-
const Wrapper = (0,
|
5945
|
+
const Wrapper = (0, import_react37.useMemo)(() => overrides.fields || DefaultFields, [overrides]);
|
5934
5946
|
return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
|
5935
5947
|
"form",
|
5936
5948
|
{
|
@@ -6051,7 +6063,7 @@ init_react_import();
|
|
6051
6063
|
|
6052
6064
|
// lib/use-component-list.tsx
|
6053
6065
|
init_react_import();
|
6054
|
-
var
|
6066
|
+
var import_react38 = require("react");
|
6055
6067
|
|
6056
6068
|
// components/ComponentList/index.tsx
|
6057
6069
|
init_react_import();
|
@@ -6118,8 +6130,8 @@ ComponentList.Item = ComponentListItem;
|
|
6118
6130
|
// lib/use-component-list.tsx
|
6119
6131
|
var import_jsx_runtime29 = require("react/jsx-runtime");
|
6120
6132
|
var useComponentList = (config, ui) => {
|
6121
|
-
const [componentList, setComponentList] = (0,
|
6122
|
-
(0,
|
6133
|
+
const [componentList, setComponentList] = (0, import_react38.useState)();
|
6134
|
+
(0, import_react38.useEffect)(() => {
|
6123
6135
|
var _a, _b, _c;
|
6124
6136
|
if (Object.keys(ui.componentList).length > 0) {
|
6125
6137
|
const matchedComponents = [];
|
@@ -6188,22 +6200,22 @@ var useComponentList = (config, ui) => {
|
|
6188
6200
|
};
|
6189
6201
|
|
6190
6202
|
// components/Puck/components/Components/index.tsx
|
6191
|
-
var
|
6203
|
+
var import_react39 = require("react");
|
6192
6204
|
var import_jsx_runtime30 = require("react/jsx-runtime");
|
6193
6205
|
var Components = () => {
|
6194
6206
|
const { config, state, overrides } = useAppContext();
|
6195
6207
|
const componentList = useComponentList(config, state.ui);
|
6196
|
-
const Wrapper = (0,
|
6208
|
+
const Wrapper = (0, import_react39.useMemo)(() => overrides.components || "div", [overrides]);
|
6197
6209
|
return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Wrapper, { children: componentList ? componentList : /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(ComponentList, { id: "all" }) });
|
6198
6210
|
};
|
6199
6211
|
|
6200
6212
|
// components/Puck/components/Preview/index.tsx
|
6201
6213
|
init_react_import();
|
6202
|
-
var
|
6214
|
+
var import_react41 = require("react");
|
6203
6215
|
|
6204
6216
|
// components/AutoFrame/index.tsx
|
6205
6217
|
init_react_import();
|
6206
|
-
var
|
6218
|
+
var import_react40 = require("react");
|
6207
6219
|
var import_object_hash = __toESM(require("object-hash"));
|
6208
6220
|
var import_react_dom3 = require("react-dom");
|
6209
6221
|
var import_jsx_runtime31 = require("react/jsx-runtime");
|
@@ -6249,7 +6261,7 @@ var CopyHostStyles = ({
|
|
6249
6261
|
onStylesLoaded = () => null
|
6250
6262
|
}) => {
|
6251
6263
|
const { document: doc, window: win } = useFrame();
|
6252
|
-
(0,
|
6264
|
+
(0, import_react40.useEffect)(() => {
|
6253
6265
|
if (!win || !doc) {
|
6254
6266
|
return () => {
|
6255
6267
|
};
|
@@ -6408,8 +6420,8 @@ var CopyHostStyles = ({
|
|
6408
6420
|
}, []);
|
6409
6421
|
return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_jsx_runtime31.Fragment, { children });
|
6410
6422
|
};
|
6411
|
-
var autoFrameContext = (0,
|
6412
|
-
var useFrame = () => (0,
|
6423
|
+
var autoFrameContext = (0, import_react40.createContext)({});
|
6424
|
+
var useFrame = () => (0, import_react40.useContext)(autoFrameContext);
|
6413
6425
|
function AutoFrame(_a) {
|
6414
6426
|
var _b = _a, {
|
6415
6427
|
children,
|
@@ -6426,10 +6438,10 @@ function AutoFrame(_a) {
|
|
6426
6438
|
"onStylesLoaded",
|
6427
6439
|
"frameRef"
|
6428
6440
|
]);
|
6429
|
-
const [loaded, setLoaded] = (0,
|
6430
|
-
const [ctx, setCtx] = (0,
|
6431
|
-
const [mountTarget, setMountTarget] = (0,
|
6432
|
-
(0,
|
6441
|
+
const [loaded, setLoaded] = (0, import_react40.useState)(false);
|
6442
|
+
const [ctx, setCtx] = (0, import_react40.useState)({});
|
6443
|
+
const [mountTarget, setMountTarget] = (0, import_react40.useState)();
|
6444
|
+
(0, import_react40.useEffect)(() => {
|
6433
6445
|
var _a2;
|
6434
6446
|
if (frameRef.current) {
|
6435
6447
|
setCtx({
|
@@ -6524,7 +6536,7 @@ var import_jsx_runtime33 = require("react/jsx-runtime");
|
|
6524
6536
|
var getClassName23 = get_class_name_factory_default("PuckPreview", styles_module_default18);
|
6525
6537
|
var useBubbleIframeEvents = (ref) => {
|
6526
6538
|
const { status } = useAppContext();
|
6527
|
-
(0,
|
6539
|
+
(0, import_react41.useEffect)(() => {
|
6528
6540
|
var _a;
|
6529
6541
|
if (ref.current && status === "READY") {
|
6530
6542
|
const iframe = ref.current;
|
@@ -6557,7 +6569,7 @@ var useBubbleIframeEvents = (ref) => {
|
|
6557
6569
|
};
|
6558
6570
|
var Preview2 = ({ id = "puck-preview" }) => {
|
6559
6571
|
const { config, dispatch, state, setStatus, iframe, overrides } = useAppContext();
|
6560
|
-
const Page = (0,
|
6572
|
+
const Page = (0, import_react41.useCallback)(
|
6561
6573
|
(pageProps) => {
|
6562
6574
|
var _a, _b;
|
6563
6575
|
return ((_a = config.root) == null ? void 0 : _a.render) ? (_b = config.root) == null ? void 0 : _b.render(__spreadValues({
|
@@ -6566,9 +6578,9 @@ var Preview2 = ({ id = "puck-preview" }) => {
|
|
6566
6578
|
},
|
6567
6579
|
[config.root]
|
6568
6580
|
);
|
6569
|
-
const Frame = (0,
|
6581
|
+
const Frame = (0, import_react41.useMemo)(() => overrides.iframe, [overrides]);
|
6570
6582
|
const rootProps = state.data.root.props || state.data.root;
|
6571
|
-
const ref = (0,
|
6583
|
+
const ref = (0, import_react41.useRef)(null);
|
6572
6584
|
useBubbleIframeEvents(ref);
|
6573
6585
|
const inner = state.ui.previewMode === "edit" ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
6574
6586
|
Page,
|
@@ -6665,7 +6677,7 @@ var scrollIntoView = (el) => {
|
|
6665
6677
|
};
|
6666
6678
|
|
6667
6679
|
// components/LayerTree/index.tsx
|
6668
|
-
var
|
6680
|
+
var import_react42 = require("react");
|
6669
6681
|
|
6670
6682
|
// lib/is-child-of-zone.ts
|
6671
6683
|
init_react_import();
|
@@ -6711,7 +6723,7 @@ var LayerTree = ({
|
|
6711
6723
|
label
|
6712
6724
|
}) => {
|
6713
6725
|
const zones = data.zones || {};
|
6714
|
-
const ctx = (0,
|
6726
|
+
const ctx = (0, import_react42.useContext)(dropZoneContext);
|
6715
6727
|
return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(import_jsx_runtime34.Fragment, { children: [
|
6716
6728
|
label && /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("div", { className: getClassName24("zoneTitle"), children: [
|
6717
6729
|
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: getClassName24("zoneIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Layers, { size: "16" }) }),
|
@@ -6818,13 +6830,13 @@ var LayerTree = ({
|
|
6818
6830
|
};
|
6819
6831
|
|
6820
6832
|
// components/Puck/components/Outline/index.tsx
|
6821
|
-
var
|
6833
|
+
var import_react43 = require("react");
|
6822
6834
|
var import_jsx_runtime35 = require("react/jsx-runtime");
|
6823
6835
|
var Outline = () => {
|
6824
6836
|
const { dispatch, state, overrides, config } = useAppContext();
|
6825
6837
|
const { data, ui } = state;
|
6826
6838
|
const { itemSelector } = ui;
|
6827
|
-
const setItemSelector = (0,
|
6839
|
+
const setItemSelector = (0, import_react43.useCallback)(
|
6828
6840
|
(newItemSelector) => {
|
6829
6841
|
dispatch({
|
6830
6842
|
type: "setUi",
|
@@ -6833,7 +6845,7 @@ var Outline = () => {
|
|
6833
6845
|
},
|
6834
6846
|
[]
|
6835
6847
|
);
|
6836
|
-
const Wrapper = (0,
|
6848
|
+
const Wrapper = (0, import_react43.useMemo)(() => overrides.outline || "div", [overrides]);
|
6837
6849
|
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
6850
|
(ctx == null ? void 0 : ctx.activeZones) && (ctx == null ? void 0 : ctx.activeZones[rootDroppableId]) && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
6839
6851
|
LayerTree,
|
@@ -6947,19 +6959,19 @@ function usePuckHistory({
|
|
6947
6959
|
|
6948
6960
|
// lib/use-history-store.ts
|
6949
6961
|
init_react_import();
|
6950
|
-
var
|
6962
|
+
var import_react44 = require("react");
|
6951
6963
|
var import_use_debounce3 = require("use-debounce");
|
6952
6964
|
var EMPTY_HISTORY_INDEX = 0;
|
6953
6965
|
function useHistoryStore(initialHistory) {
|
6954
6966
|
var _a, _b;
|
6955
|
-
const [histories, setHistories] = (0,
|
6967
|
+
const [histories, setHistories] = (0, import_react44.useState)(
|
6956
6968
|
(_a = initialHistory == null ? void 0 : initialHistory.histories) != null ? _a : []
|
6957
6969
|
);
|
6958
6970
|
const updateHistories = (histories2) => {
|
6959
6971
|
setHistories(histories2);
|
6960
6972
|
setIndex(histories2.length - 1);
|
6961
6973
|
};
|
6962
|
-
const [index, setIndex] = (0,
|
6974
|
+
const [index, setIndex] = (0, import_react44.useState)(
|
6963
6975
|
(_b = initialHistory == null ? void 0 : initialHistory.index) != null ? _b : EMPTY_HISTORY_INDEX
|
6964
6976
|
);
|
6965
6977
|
const hasPast = index > EMPTY_HISTORY_INDEX;
|
@@ -7119,11 +7131,11 @@ var getBox = function getBox2(el) {
|
|
7119
7131
|
};
|
7120
7132
|
|
7121
7133
|
// components/Puck/components/Canvas/index.tsx
|
7122
|
-
var
|
7134
|
+
var import_react46 = require("react");
|
7123
7135
|
|
7124
7136
|
// components/ViewportControls/index.tsx
|
7125
7137
|
init_react_import();
|
7126
|
-
var
|
7138
|
+
var import_react45 = require("react");
|
7127
7139
|
|
7128
7140
|
// css-module:/home/runner/work/puck/puck/packages/core/components/ViewportControls/styles.module.css#css-module
|
7129
7141
|
init_react_import();
|
@@ -7146,8 +7158,8 @@ var ViewportButton = ({
|
|
7146
7158
|
onClick
|
7147
7159
|
}) => {
|
7148
7160
|
const { state } = useAppContext();
|
7149
|
-
const [isActive, setIsActive] = (0,
|
7150
|
-
(0,
|
7161
|
+
const [isActive, setIsActive] = (0, import_react45.useState)(false);
|
7162
|
+
(0, import_react45.useEffect)(() => {
|
7151
7163
|
setIsActive(width === state.ui.viewports.current.width);
|
7152
7164
|
}, [width, state.ui.viewports.current.width]);
|
7153
7165
|
return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("span", { className: getClassNameButton({ isActive }), children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
@@ -7183,7 +7195,7 @@ var ViewportControls = ({
|
|
7183
7195
|
const defaultsContainAutoZoom = defaultZoomOptions.find(
|
7184
7196
|
(option) => option.value === autoZoom
|
7185
7197
|
);
|
7186
|
-
const zoomOptions = (0,
|
7198
|
+
const zoomOptions = (0, import_react45.useMemo)(
|
7187
7199
|
() => [
|
7188
7200
|
...defaultZoomOptions,
|
7189
7201
|
...defaultsContainAutoZoom ? [] : [
|
@@ -7306,17 +7318,17 @@ var Canvas = () => {
|
|
7306
7318
|
const { status, iframe } = useAppContext();
|
7307
7319
|
const { dispatch, state, overrides, setUi, zoomConfig, setZoomConfig } = useAppContext();
|
7308
7320
|
const { ui } = state;
|
7309
|
-
const frameRef = (0,
|
7310
|
-
const [showTransition, setShowTransition] = (0,
|
7311
|
-
const defaultRender = (0,
|
7321
|
+
const frameRef = (0, import_react46.useRef)(null);
|
7322
|
+
const [showTransition, setShowTransition] = (0, import_react46.useState)(false);
|
7323
|
+
const defaultRender = (0, import_react46.useMemo)(() => {
|
7312
7324
|
const PuckDefault = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(import_jsx_runtime37.Fragment, { children });
|
7313
7325
|
return PuckDefault;
|
7314
7326
|
}, []);
|
7315
|
-
const CustomPreview = (0,
|
7327
|
+
const CustomPreview = (0, import_react46.useMemo)(
|
7316
7328
|
() => overrides.preview || defaultRender,
|
7317
7329
|
[overrides]
|
7318
7330
|
);
|
7319
|
-
const getFrameDimensions = (0,
|
7331
|
+
const getFrameDimensions = (0, import_react46.useCallback)(() => {
|
7320
7332
|
if (frameRef.current) {
|
7321
7333
|
const frame = frameRef.current;
|
7322
7334
|
const box = getBox(frame);
|
@@ -7324,7 +7336,7 @@ var Canvas = () => {
|
|
7324
7336
|
}
|
7325
7337
|
return { width: 0, height: 0 };
|
7326
7338
|
}, [frameRef]);
|
7327
|
-
const resetAutoZoom = (0,
|
7339
|
+
const resetAutoZoom = (0, import_react46.useCallback)(
|
7328
7340
|
(ui2 = state.ui) => {
|
7329
7341
|
if (frameRef.current) {
|
7330
7342
|
setZoomConfig(
|
@@ -7334,11 +7346,11 @@ var Canvas = () => {
|
|
7334
7346
|
},
|
7335
7347
|
[frameRef, zoomConfig, state.ui]
|
7336
7348
|
);
|
7337
|
-
(0,
|
7349
|
+
(0, import_react46.useEffect)(() => {
|
7338
7350
|
setShowTransition(false);
|
7339
7351
|
resetAutoZoom();
|
7340
7352
|
}, [frameRef, ui.leftSideBarVisible, ui.rightSideBarVisible]);
|
7341
|
-
(0,
|
7353
|
+
(0, import_react46.useEffect)(() => {
|
7342
7354
|
const { height: frameHeight } = getFrameDimensions();
|
7343
7355
|
if (ui.viewports.current.height === "auto") {
|
7344
7356
|
setZoomConfig(__spreadProps(__spreadValues({}, zoomConfig), {
|
@@ -7346,13 +7358,13 @@ var Canvas = () => {
|
|
7346
7358
|
}));
|
7347
7359
|
}
|
7348
7360
|
}, [zoomConfig.zoom]);
|
7349
|
-
(0,
|
7361
|
+
(0, import_react46.useEffect)(() => {
|
7350
7362
|
if (ZOOM_ON_CHANGE) {
|
7351
7363
|
setShowTransition(true);
|
7352
7364
|
resetAutoZoom(ui);
|
7353
7365
|
}
|
7354
7366
|
}, [ui.viewports.current.width]);
|
7355
|
-
(0,
|
7367
|
+
(0, import_react46.useEffect)(() => {
|
7356
7368
|
const cb = () => {
|
7357
7369
|
setShowTransition(false);
|
7358
7370
|
resetAutoZoom();
|
@@ -7362,8 +7374,8 @@ var Canvas = () => {
|
|
7362
7374
|
window.removeEventListener("resize", cb);
|
7363
7375
|
};
|
7364
7376
|
}, []);
|
7365
|
-
const [showLoader, setShowLoader] = (0,
|
7366
|
-
(0,
|
7377
|
+
const [showLoader, setShowLoader] = (0, import_react46.useState)(false);
|
7378
|
+
(0, import_react46.useEffect)(() => {
|
7367
7379
|
setTimeout(() => {
|
7368
7380
|
setShowLoader(true);
|
7369
7381
|
}, 500);
|
@@ -7441,7 +7453,7 @@ var Canvas = () => {
|
|
7441
7453
|
|
7442
7454
|
// lib/use-loaded-overrides.ts
|
7443
7455
|
init_react_import();
|
7444
|
-
var
|
7456
|
+
var import_react47 = require("react");
|
7445
7457
|
|
7446
7458
|
// lib/load-overrides.ts
|
7447
7459
|
init_react_import();
|
@@ -7480,7 +7492,7 @@ var useLoadedOverrides = ({
|
|
7480
7492
|
overrides,
|
7481
7493
|
plugins
|
7482
7494
|
}) => {
|
7483
|
-
return (0,
|
7495
|
+
return (0, import_react47.useMemo)(() => {
|
7484
7496
|
return loadOverrides({ overrides, plugins });
|
7485
7497
|
}, [plugins, overrides]);
|
7486
7498
|
};
|
@@ -7492,14 +7504,14 @@ var DefaultOverride = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime38
|
|
7492
7504
|
|
7493
7505
|
// lib/use-inject-css.ts
|
7494
7506
|
init_react_import();
|
7495
|
-
var
|
7507
|
+
var import_react48 = require("react");
|
7496
7508
|
var styles = ``;
|
7497
7509
|
var useInjectStyleSheet = (initialStyles, iframeEnabled) => {
|
7498
|
-
const [el, setEl] = (0,
|
7499
|
-
(0,
|
7510
|
+
const [el, setEl] = (0, import_react48.useState)();
|
7511
|
+
(0, import_react48.useEffect)(() => {
|
7500
7512
|
setEl(document.createElement("style"));
|
7501
7513
|
}, []);
|
7502
|
-
(0,
|
7514
|
+
(0, import_react48.useEffect)(() => {
|
7503
7515
|
var _a;
|
7504
7516
|
if (!el || typeof window === "undefined") {
|
7505
7517
|
return;
|
@@ -7519,10 +7531,10 @@ var useInjectGlobalCss = (iframeEnabled) => {
|
|
7519
7531
|
|
7520
7532
|
// lib/use-preview-mode-hotkeys.ts
|
7521
7533
|
init_react_import();
|
7522
|
-
var
|
7534
|
+
var import_react49 = require("react");
|
7523
7535
|
var import_react_hotkeys_hook2 = require("react-hotkeys-hook");
|
7524
7536
|
var usePreviewModeHotkeys = (dispatch, iframeEnabled) => {
|
7525
|
-
const toggleInteractive = (0,
|
7537
|
+
const toggleInteractive = (0, import_react49.useCallback)(() => {
|
7526
7538
|
dispatch({
|
7527
7539
|
type: "setUi",
|
7528
7540
|
ui: (ui) => ({
|
@@ -7579,7 +7591,7 @@ function Puck({
|
|
7579
7591
|
waitForStyles: true
|
7580
7592
|
}, _iframe);
|
7581
7593
|
useInjectGlobalCss(iframe.enabled);
|
7582
|
-
const [generatedAppState] = (0,
|
7594
|
+
const [generatedAppState] = (0, import_react50.useState)(() => {
|
7583
7595
|
var _a2, _b2, _c, _d, _e, _f, _g, _h, _i;
|
7584
7596
|
const initial = __spreadValues(__spreadValues({}, defaultAppState.ui), initialUi);
|
7585
7597
|
let clientUiState = {};
|
@@ -7651,14 +7663,14 @@ function Puck({
|
|
7651
7663
|
histories,
|
7652
7664
|
index: initialHistoryIndex
|
7653
7665
|
});
|
7654
|
-
const [reducer] = (0,
|
7666
|
+
const [reducer] = (0, import_react50.useState)(
|
7655
7667
|
() => createReducer({
|
7656
7668
|
config,
|
7657
7669
|
record: historyStore.record,
|
7658
7670
|
onAction
|
7659
7671
|
})
|
7660
7672
|
);
|
7661
|
-
const [appState, dispatch] = (0,
|
7673
|
+
const [appState, dispatch] = (0, import_react50.useReducer)(
|
7662
7674
|
reducer,
|
7663
7675
|
flushZones(initialAppState)
|
7664
7676
|
);
|
@@ -7669,14 +7681,14 @@ function Puck({
|
|
7669
7681
|
historyStore,
|
7670
7682
|
iframeEnabled: (_a = _iframe == null ? void 0 : _iframe.enabled) != null ? _a : true
|
7671
7683
|
});
|
7672
|
-
const [menuOpen, setMenuOpen] = (0,
|
7684
|
+
const [menuOpen, setMenuOpen] = (0, import_react50.useState)(false);
|
7673
7685
|
const { itemSelector, leftSideBarVisible, rightSideBarVisible } = ui;
|
7674
7686
|
const selectedItem = itemSelector ? getItem(itemSelector, data) : null;
|
7675
|
-
(0,
|
7687
|
+
(0, import_react50.useEffect)(() => {
|
7676
7688
|
if (onChange) onChange(data);
|
7677
7689
|
}, [data]);
|
7678
7690
|
const rootProps = data.root.props || data.root;
|
7679
|
-
const toggleSidebars = (0,
|
7691
|
+
const toggleSidebars = (0, import_react50.useCallback)(
|
7680
7692
|
(sidebar) => {
|
7681
7693
|
const widerViewport = window.matchMedia("(min-width: 638px)").matches;
|
7682
7694
|
const sideBarVisible = sidebar === "left" ? leftSideBarVisible : rightSideBarVisible;
|
@@ -7690,7 +7702,7 @@ function Puck({
|
|
7690
7702
|
},
|
7691
7703
|
[dispatch, leftSideBarVisible, rightSideBarVisible]
|
7692
7704
|
);
|
7693
|
-
(0,
|
7705
|
+
(0, import_react50.useEffect)(() => {
|
7694
7706
|
if (!window.matchMedia("(min-width: 638px)").matches) {
|
7695
7707
|
dispatch({
|
7696
7708
|
type: "setUi",
|
@@ -7713,7 +7725,7 @@ function Puck({
|
|
7713
7725
|
window.removeEventListener("resize", handleResize);
|
7714
7726
|
};
|
7715
7727
|
}, []);
|
7716
|
-
const defaultHeaderRender = (0,
|
7728
|
+
const defaultHeaderRender = (0, import_react50.useMemo)(() => {
|
7717
7729
|
if (renderHeader) {
|
7718
7730
|
console.warn(
|
7719
7731
|
"`renderHeader` is deprecated. Please use `overrides.header` and the `usePuck` hook instead"
|
@@ -7727,7 +7739,7 @@ function Puck({
|
|
7727
7739
|
}
|
7728
7740
|
return DefaultOverride;
|
7729
7741
|
}, [renderHeader]);
|
7730
|
-
const defaultHeaderActionsRender = (0,
|
7742
|
+
const defaultHeaderActionsRender = (0, import_react50.useMemo)(() => {
|
7731
7743
|
if (renderHeaderActions) {
|
7732
7744
|
console.warn(
|
7733
7745
|
"`renderHeaderActions` is deprecated. Please use `overrides.headerActions` and the `usePuck` hook instead."
|
@@ -7744,20 +7756,20 @@ function Puck({
|
|
7744
7756
|
overrides,
|
7745
7757
|
plugins
|
7746
7758
|
});
|
7747
|
-
const CustomPuck = (0,
|
7759
|
+
const CustomPuck = (0, import_react50.useMemo)(
|
7748
7760
|
() => loadedOverrides.puck || DefaultOverride,
|
7749
7761
|
[loadedOverrides]
|
7750
7762
|
);
|
7751
|
-
const CustomHeader = (0,
|
7763
|
+
const CustomHeader = (0, import_react50.useMemo)(
|
7752
7764
|
() => loadedOverrides.header || defaultHeaderRender,
|
7753
7765
|
[loadedOverrides]
|
7754
7766
|
);
|
7755
|
-
const CustomHeaderActions = (0,
|
7767
|
+
const CustomHeaderActions = (0, import_react50.useMemo)(
|
7756
7768
|
() => loadedOverrides.headerActions || defaultHeaderActionsRender,
|
7757
7769
|
[loadedOverrides]
|
7758
7770
|
);
|
7759
|
-
const [mounted, setMounted] = (0,
|
7760
|
-
(0,
|
7771
|
+
const [mounted, setMounted] = (0, import_react50.useState)(false);
|
7772
|
+
(0, import_react50.useEffect)(() => {
|
7761
7773
|
setMounted(true);
|
7762
7774
|
}, []);
|
7763
7775
|
const selectedComponentConfig = selectedItem && config.components[selectedItem.type];
|