@measured/puck 0.18.3-canary.154e7f7 → 0.18.3-canary.78bb71d
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/index.js +150 -137
- package/dist/index.mjs +169 -157
- package/package.json +2 -2
package/dist/index.js
CHANGED
@@ -1301,7 +1301,8 @@ function useDraggableSafe(input) {
|
|
1301
1301
|
function useSortableSafe(input) {
|
1302
1302
|
if (typeof window === "undefined") {
|
1303
1303
|
return { ref: () => {
|
1304
|
-
}, status: "idle"
|
1304
|
+
}, status: "idle", handleRef: () => {
|
1305
|
+
} };
|
1305
1306
|
}
|
1306
1307
|
return (0, import_sortable.useSortable)(input);
|
1307
1308
|
}
|
@@ -1576,23 +1577,26 @@ function patchWindow(window2) {
|
|
1576
1577
|
|
1577
1578
|
// lib/dnd/use-sensors.ts
|
1578
1579
|
var import_utilities2 = require("@dnd-kit/dom/utilities");
|
1579
|
-
var useSensors = (
|
1580
|
+
var useSensors = ({
|
1581
|
+
other,
|
1582
|
+
mouse,
|
1583
|
+
touch
|
1584
|
+
} = {
|
1585
|
+
touch: { delay: { value: 200, tolerance: 10 } },
|
1586
|
+
other: { delay: { value: 200, tolerance: 10 }, distance: { value: 5 } }
|
1587
|
+
}) => {
|
1580
1588
|
const [sensors] = (0, import_react9.useState)(() => [
|
1581
1589
|
PointerSensor.configure({
|
1582
1590
|
activationConstraints(event, source) {
|
1583
1591
|
var _a;
|
1584
1592
|
const { pointerType, target } = event;
|
1585
1593
|
if (pointerType === "mouse" && (0, import_utilities2.isElement)(target) && (source.handle === target || ((_a = source.handle) == null ? void 0 : _a.contains(target)))) {
|
1586
|
-
return
|
1594
|
+
return mouse;
|
1587
1595
|
}
|
1588
|
-
const delay = { value: 200, tolerance: 10 };
|
1589
1596
|
if (pointerType === "touch") {
|
1590
|
-
return
|
1597
|
+
return touch;
|
1591
1598
|
}
|
1592
|
-
return
|
1593
|
-
delay,
|
1594
|
-
distance: { value: 5 }
|
1595
|
-
};
|
1599
|
+
return other;
|
1596
1600
|
}
|
1597
1601
|
})
|
1598
1602
|
]);
|
@@ -1938,13 +1942,16 @@ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input
|
|
1938
1942
|
var import_modifiers = require("@dnd-kit/dom/modifiers");
|
1939
1943
|
var import_jsx_runtime6 = require("react/jsx-runtime");
|
1940
1944
|
var SortableProvider = ({
|
1945
|
+
container,
|
1941
1946
|
children,
|
1942
1947
|
onDragStart,
|
1943
1948
|
onDragEnd,
|
1944
1949
|
onMove
|
1945
1950
|
}) => {
|
1946
1951
|
const [move, setMove] = (0, import_react11.useState)({ source: -1, target: -1 });
|
1947
|
-
const sensors = useSensors(
|
1952
|
+
const sensors = useSensors({
|
1953
|
+
mouse: { distance: { value: 5 } }
|
1954
|
+
});
|
1948
1955
|
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
1949
1956
|
import_react10.DragDropProvider,
|
1950
1957
|
{
|
@@ -1952,7 +1959,7 @@ var SortableProvider = ({
|
|
1952
1959
|
modifiers: [
|
1953
1960
|
import_modifiers.RestrictToElement.configure({
|
1954
1961
|
element() {
|
1955
|
-
return
|
1962
|
+
return container.current;
|
1956
1963
|
}
|
1957
1964
|
})
|
1958
1965
|
],
|
@@ -1999,7 +2006,11 @@ var Sortable = ({
|
|
1999
2006
|
children,
|
2000
2007
|
type = "item"
|
2001
2008
|
}) => {
|
2002
|
-
const {
|
2009
|
+
const {
|
2010
|
+
ref: sortableRef,
|
2011
|
+
status,
|
2012
|
+
handleRef
|
2013
|
+
} = useSortableSafe({
|
2003
2014
|
id,
|
2004
2015
|
type,
|
2005
2016
|
index,
|
@@ -2007,7 +2018,7 @@ var Sortable = ({
|
|
2007
2018
|
data: { index },
|
2008
2019
|
collisionDetector: createDynamicCollisionDetector("y")
|
2009
2020
|
});
|
2010
|
-
return children({ status, ref: sortableRef });
|
2021
|
+
return children({ status, ref: sortableRef, handleRef });
|
2011
2022
|
};
|
2012
2023
|
|
2013
2024
|
// components/AutoField/context.tsx
|
@@ -2126,6 +2137,7 @@ var ArrayField = ({
|
|
2126
2137
|
}
|
2127
2138
|
}, []);
|
2128
2139
|
const [isDragging, setIsDragging] = (0, import_react13.useState)(false);
|
2140
|
+
const dndContainerRef = (0, import_react13.useRef)(null);
|
2129
2141
|
const forceReadOnly = getPermissions({ item: selectedItem }).edit === false;
|
2130
2142
|
if (field.type !== "array" || !field.arrayFields) {
|
2131
2143
|
return null;
|
@@ -2141,6 +2153,7 @@ var ArrayField = ({
|
|
2141
2153
|
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
2142
2154
|
SortableProvider,
|
2143
2155
|
{
|
2156
|
+
container: dndContainerRef,
|
2144
2157
|
onDragStart: () => setIsDragging(true),
|
2145
2158
|
onDragEnd: () => setIsDragging(false),
|
2146
2159
|
onMove: (move) => {
|
@@ -2169,117 +2182,114 @@ var ArrayField = ({
|
|
2169
2182
|
hasItems: Array.isArray(value) && value.length > 0,
|
2170
2183
|
addDisabled
|
2171
2184
|
}),
|
2172
|
-
onClick: (e) => {
|
2173
|
-
e.preventDefault();
|
2174
|
-
},
|
2175
2185
|
children: [
|
2176
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
2177
|
-
|
2178
|
-
|
2179
|
-
|
2180
|
-
|
2181
|
-
|
2182
|
-
|
2183
|
-
|
2184
|
-
|
2185
|
-
|
2186
|
-
|
2186
|
+
localState.arrayState.items.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
2187
|
+
"div",
|
2188
|
+
{
|
2189
|
+
ref: dndContainerRef,
|
2190
|
+
className: getClassName5("inner"),
|
2191
|
+
"data-dnd-container": true,
|
2192
|
+
children: localState.arrayState.items.map((item, i) => {
|
2193
|
+
const { _arrayId = `${id}-${i}`, _originalIndex = i } = item;
|
2194
|
+
const data = Array.from(localState.value || [])[i] || {};
|
2195
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
2196
|
+
Sortable,
|
2187
2197
|
{
|
2188
|
-
|
2189
|
-
|
2190
|
-
|
2191
|
-
|
2192
|
-
|
2193
|
-
|
2194
|
-
|
2195
|
-
|
2196
|
-
|
2197
|
-
|
2198
|
-
|
2199
|
-
|
2200
|
-
|
2201
|
-
|
2202
|
-
|
2203
|
-
|
2204
|
-
|
2205
|
-
|
2206
|
-
|
2207
|
-
|
2208
|
-
|
2209
|
-
|
2210
|
-
|
2211
|
-
|
2212
|
-
|
2213
|
-
|
2198
|
+
id: _arrayId,
|
2199
|
+
index: i,
|
2200
|
+
disabled: readOnly,
|
2201
|
+
children: ({ status, ref, handleRef }) => /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
2202
|
+
"div",
|
2203
|
+
{
|
2204
|
+
ref,
|
2205
|
+
className: getClassNameItem({
|
2206
|
+
isExpanded: arrayState.openId === _arrayId,
|
2207
|
+
isDragging: status === "dragging",
|
2208
|
+
readOnly
|
2209
|
+
}),
|
2210
|
+
children: [
|
2211
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
2212
|
+
"div",
|
2213
|
+
{
|
2214
|
+
ref: handleRef,
|
2215
|
+
onClick: (e) => {
|
2216
|
+
if (isDragging) return;
|
2217
|
+
e.preventDefault();
|
2218
|
+
e.stopPropagation();
|
2219
|
+
if (arrayState.openId === _arrayId) {
|
2220
|
+
setUi(
|
2221
|
+
mapArrayStateToUi({
|
2222
|
+
openId: ""
|
2223
|
+
})
|
2224
|
+
);
|
2225
|
+
} else {
|
2226
|
+
setUi(
|
2227
|
+
mapArrayStateToUi({
|
2228
|
+
openId: _arrayId
|
2229
|
+
})
|
2230
|
+
);
|
2231
|
+
}
|
2232
|
+
},
|
2233
|
+
className: getClassNameItem("summary"),
|
2234
|
+
children: [
|
2235
|
+
field.getItemSummary ? field.getItemSummary(data, i) : `Item #${_originalIndex}`,
|
2236
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: getClassNameItem("rhs"), children: [
|
2237
|
+
!readOnly && /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: getClassNameItem("actions"), children: [
|
2238
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: getClassNameItem("action"), children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
2239
|
+
IconButton,
|
2240
|
+
{
|
2241
|
+
type: "button",
|
2242
|
+
disabled: !!addDisabled,
|
2243
|
+
onClick: (e) => {
|
2244
|
+
e.stopPropagation();
|
2245
|
+
const existingValue = [...value || []];
|
2246
|
+
existingValue.splice(
|
2247
|
+
i,
|
2248
|
+
0,
|
2249
|
+
existingValue[i]
|
2250
|
+
);
|
2251
|
+
onChange(
|
2252
|
+
existingValue,
|
2253
|
+
mapArrayStateToUi(
|
2254
|
+
regenerateArrayState(existingValue)
|
2255
|
+
)
|
2256
|
+
);
|
2257
|
+
},
|
2258
|
+
title: "Duplicate",
|
2259
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Copy, { size: 16 })
|
2260
|
+
}
|
2261
|
+
) }),
|
2262
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: getClassNameItem("action"), children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
2263
|
+
IconButton,
|
2264
|
+
{
|
2265
|
+
type: "button",
|
2266
|
+
disabled: field.min !== void 0 && field.min >= localState.arrayState.items.length,
|
2267
|
+
onClick: (e) => {
|
2268
|
+
e.stopPropagation();
|
2269
|
+
const existingValue = [...value || []];
|
2270
|
+
const existingItems = [
|
2271
|
+
...arrayState.items || []
|
2272
|
+
];
|
2273
|
+
existingValue.splice(i, 1);
|
2274
|
+
existingItems.splice(i, 1);
|
2275
|
+
onChange(
|
2276
|
+
existingValue,
|
2277
|
+
mapArrayStateToUi({
|
2278
|
+
items: existingItems
|
2279
|
+
})
|
2280
|
+
);
|
2281
|
+
},
|
2282
|
+
title: "Delete",
|
2283
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Trash, { size: 16 })
|
2284
|
+
}
|
2285
|
+
) })
|
2286
|
+
] }),
|
2287
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(DragIcon, {}) })
|
2288
|
+
] })
|
2289
|
+
]
|
2214
2290
|
}
|
2215
|
-
|
2216
|
-
className: getClassNameItem("
|
2217
|
-
children: [
|
2218
|
-
field.getItemSummary ? field.getItemSummary(data, i) : `Item #${_originalIndex}`,
|
2219
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: getClassNameItem("rhs"), children: [
|
2220
|
-
!readOnly && /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: getClassNameItem("actions"), children: [
|
2221
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: getClassNameItem("action"), children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
2222
|
-
IconButton,
|
2223
|
-
{
|
2224
|
-
type: "button",
|
2225
|
-
disabled: !!addDisabled,
|
2226
|
-
onClick: (e) => {
|
2227
|
-
e.stopPropagation();
|
2228
|
-
const existingValue = [...value || []];
|
2229
|
-
existingValue.splice(
|
2230
|
-
i,
|
2231
|
-
0,
|
2232
|
-
existingValue[i]
|
2233
|
-
);
|
2234
|
-
onChange(
|
2235
|
-
existingValue,
|
2236
|
-
mapArrayStateToUi(
|
2237
|
-
regenerateArrayState(existingValue)
|
2238
|
-
)
|
2239
|
-
);
|
2240
|
-
},
|
2241
|
-
title: "Duplicate",
|
2242
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Copy, { size: 16 })
|
2243
|
-
}
|
2244
|
-
) }),
|
2245
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: getClassNameItem("action"), children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
2246
|
-
IconButton,
|
2247
|
-
{
|
2248
|
-
type: "button",
|
2249
|
-
disabled: field.min !== void 0 && field.min >= localState.arrayState.items.length,
|
2250
|
-
onClick: (e) => {
|
2251
|
-
e.stopPropagation();
|
2252
|
-
const existingValue = [...value || []];
|
2253
|
-
const existingItems = [
|
2254
|
-
...arrayState.items || []
|
2255
|
-
];
|
2256
|
-
existingValue.splice(i, 1);
|
2257
|
-
existingItems.splice(i, 1);
|
2258
|
-
onChange(
|
2259
|
-
existingValue,
|
2260
|
-
mapArrayStateToUi({
|
2261
|
-
items: existingItems
|
2262
|
-
})
|
2263
|
-
);
|
2264
|
-
},
|
2265
|
-
title: "Delete",
|
2266
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Trash, { size: 16 })
|
2267
|
-
}
|
2268
|
-
) })
|
2269
|
-
] }),
|
2270
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(DragIcon, {}) })
|
2271
|
-
] })
|
2272
|
-
]
|
2273
|
-
}
|
2274
|
-
),
|
2275
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: getClassNameItem("body"), children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
2276
|
-
"fieldset",
|
2277
|
-
{
|
2278
|
-
className: getClassNameItem("fieldset"),
|
2279
|
-
onPointerDownCapture: (e) => {
|
2280
|
-
e.stopPropagation();
|
2281
|
-
},
|
2282
|
-
children: Object.keys(field.arrayFields).map((subName) => {
|
2291
|
+
),
|
2292
|
+
/* @__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) => {
|
2283
2293
|
const subField = field.arrayFields[subName];
|
2284
2294
|
const indexName = `${name}[${i}]`;
|
2285
2295
|
const subPath = `${indexName}.${subName}`;
|
@@ -2321,16 +2331,16 @@ var ArrayField = ({
|
|
2321
2331
|
},
|
2322
2332
|
subPath
|
2323
2333
|
);
|
2324
|
-
})
|
2325
|
-
|
2326
|
-
|
2327
|
-
|
2328
|
-
}
|
2329
|
-
|
2330
|
-
|
2331
|
-
|
2332
|
-
|
2333
|
-
|
2334
|
+
}) }) })
|
2335
|
+
]
|
2336
|
+
}
|
2337
|
+
)
|
2338
|
+
},
|
2339
|
+
_arrayId
|
2340
|
+
);
|
2341
|
+
})
|
2342
|
+
}
|
2343
|
+
),
|
2334
2344
|
!addDisabled && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
2335
2345
|
"button",
|
2336
2346
|
{
|
@@ -3254,10 +3264,13 @@ function AutoFieldPrivate(props) {
|
|
3254
3264
|
50,
|
3255
3265
|
{ leading: true }
|
3256
3266
|
);
|
3257
|
-
const onChangeLocal = (0, import_react21.useCallback)(
|
3258
|
-
|
3259
|
-
|
3260
|
-
|
3267
|
+
const onChangeLocal = (0, import_react21.useCallback)(
|
3268
|
+
(val, ui) => {
|
3269
|
+
setLocalValue(val);
|
3270
|
+
onChangeDb(val, ui);
|
3271
|
+
},
|
3272
|
+
[onChange]
|
3273
|
+
);
|
3261
3274
|
(0, import_react21.useEffect)(() => {
|
3262
3275
|
if (state.ui.field.focus !== props.name) {
|
3263
3276
|
setLocalValue(value);
|
@@ -5034,7 +5047,7 @@ var DragDropContextClient = ({
|
|
5034
5047
|
disableAutoScroll
|
5035
5048
|
}) => {
|
5036
5049
|
const { state, config, dispatch, resolveData } = useAppContext();
|
5037
|
-
const id = (
|
5050
|
+
const id = useSafeId();
|
5038
5051
|
const { data } = state;
|
5039
5052
|
const debouncedParamsRef = (0, import_react32.useRef)(null);
|
5040
5053
|
const tempDisableFallback = useTempDisableFallback(100);
|
@@ -5517,7 +5530,7 @@ var Drawer = ({
|
|
5517
5530
|
"Warning: The `direction` prop on Drawer is deprecated and no longer required to achieve multi-directional dragging."
|
5518
5531
|
);
|
5519
5532
|
}
|
5520
|
-
const id = (
|
5533
|
+
const id = useSafeId();
|
5521
5534
|
const { ref } = useDroppableSafe({
|
5522
5535
|
id,
|
5523
5536
|
type: "void",
|
package/dist/index.mjs
CHANGED
@@ -674,7 +674,7 @@ var IconButton = ({
|
|
674
674
|
};
|
675
675
|
|
676
676
|
// components/AutoField/fields/ArrayField/index.tsx
|
677
|
-
import { useCallback as useCallback3, useEffect as useEffect4, useState as useState7 } from "react";
|
677
|
+
import { useCallback as useCallback3, useEffect as useEffect4, useRef, useState as useState7 } from "react";
|
678
678
|
|
679
679
|
// components/DragIcon/index.tsx
|
680
680
|
init_react_import();
|
@@ -1110,7 +1110,8 @@ function useDraggableSafe(input) {
|
|
1110
1110
|
function useSortableSafe(input) {
|
1111
1111
|
if (typeof window === "undefined") {
|
1112
1112
|
return { ref: () => {
|
1113
|
-
}, status: "idle"
|
1113
|
+
}, status: "idle", handleRef: () => {
|
1114
|
+
} };
|
1114
1115
|
}
|
1115
1116
|
return useSortable(input);
|
1116
1117
|
}
|
@@ -1394,23 +1395,26 @@ function patchWindow(window2) {
|
|
1394
1395
|
|
1395
1396
|
// lib/dnd/use-sensors.ts
|
1396
1397
|
import { isElement as isElement2 } from "@dnd-kit/dom/utilities";
|
1397
|
-
var useSensors = (
|
1398
|
+
var useSensors = ({
|
1399
|
+
other,
|
1400
|
+
mouse,
|
1401
|
+
touch
|
1402
|
+
} = {
|
1403
|
+
touch: { delay: { value: 200, tolerance: 10 } },
|
1404
|
+
other: { delay: { value: 200, tolerance: 10 }, distance: { value: 5 } }
|
1405
|
+
}) => {
|
1398
1406
|
const [sensors] = useState5(() => [
|
1399
1407
|
PointerSensor.configure({
|
1400
1408
|
activationConstraints(event, source) {
|
1401
1409
|
var _a;
|
1402
1410
|
const { pointerType, target } = event;
|
1403
1411
|
if (pointerType === "mouse" && isElement2(target) && (source.handle === target || ((_a = source.handle) == null ? void 0 : _a.contains(target)))) {
|
1404
|
-
return
|
1412
|
+
return mouse;
|
1405
1413
|
}
|
1406
|
-
const delay = { value: 200, tolerance: 10 };
|
1407
1414
|
if (pointerType === "touch") {
|
1408
|
-
return
|
1415
|
+
return touch;
|
1409
1416
|
}
|
1410
|
-
return
|
1411
|
-
delay,
|
1412
|
-
distance: { value: 5 }
|
1413
|
-
};
|
1417
|
+
return other;
|
1414
1418
|
}
|
1415
1419
|
})
|
1416
1420
|
]);
|
@@ -1759,13 +1763,16 @@ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input
|
|
1759
1763
|
import { RestrictToElement } from "@dnd-kit/dom/modifiers";
|
1760
1764
|
import { jsx as jsx6 } from "react/jsx-runtime";
|
1761
1765
|
var SortableProvider = ({
|
1766
|
+
container,
|
1762
1767
|
children,
|
1763
1768
|
onDragStart,
|
1764
1769
|
onDragEnd,
|
1765
1770
|
onMove
|
1766
1771
|
}) => {
|
1767
1772
|
const [move, setMove] = useState6({ source: -1, target: -1 });
|
1768
|
-
const sensors = useSensors(
|
1773
|
+
const sensors = useSensors({
|
1774
|
+
mouse: { distance: { value: 5 } }
|
1775
|
+
});
|
1769
1776
|
return /* @__PURE__ */ jsx6(
|
1770
1777
|
DragDropProvider,
|
1771
1778
|
{
|
@@ -1773,7 +1780,7 @@ var SortableProvider = ({
|
|
1773
1780
|
modifiers: [
|
1774
1781
|
RestrictToElement.configure({
|
1775
1782
|
element() {
|
1776
|
-
return
|
1783
|
+
return container.current;
|
1777
1784
|
}
|
1778
1785
|
})
|
1779
1786
|
],
|
@@ -1820,7 +1827,11 @@ var Sortable = ({
|
|
1820
1827
|
children,
|
1821
1828
|
type = "item"
|
1822
1829
|
}) => {
|
1823
|
-
const {
|
1830
|
+
const {
|
1831
|
+
ref: sortableRef,
|
1832
|
+
status,
|
1833
|
+
handleRef
|
1834
|
+
} = useSortableSafe({
|
1824
1835
|
id,
|
1825
1836
|
type,
|
1826
1837
|
index,
|
@@ -1828,7 +1839,7 @@ var Sortable = ({
|
|
1828
1839
|
data: { index },
|
1829
1840
|
collisionDetector: createDynamicCollisionDetector("y")
|
1830
1841
|
});
|
1831
|
-
return children({ status, ref: sortableRef });
|
1842
|
+
return children({ status, ref: sortableRef, handleRef });
|
1832
1843
|
};
|
1833
1844
|
|
1834
1845
|
// components/AutoField/context.tsx
|
@@ -1947,6 +1958,7 @@ var ArrayField = ({
|
|
1947
1958
|
}
|
1948
1959
|
}, []);
|
1949
1960
|
const [isDragging, setIsDragging] = useState7(false);
|
1961
|
+
const dndContainerRef = useRef(null);
|
1950
1962
|
const forceReadOnly = getPermissions({ item: selectedItem }).edit === false;
|
1951
1963
|
if (field.type !== "array" || !field.arrayFields) {
|
1952
1964
|
return null;
|
@@ -1962,6 +1974,7 @@ var ArrayField = ({
|
|
1962
1974
|
children: /* @__PURE__ */ jsx8(
|
1963
1975
|
SortableProvider,
|
1964
1976
|
{
|
1977
|
+
container: dndContainerRef,
|
1965
1978
|
onDragStart: () => setIsDragging(true),
|
1966
1979
|
onDragEnd: () => setIsDragging(false),
|
1967
1980
|
onMove: (move) => {
|
@@ -1990,117 +2003,114 @@ var ArrayField = ({
|
|
1990
2003
|
hasItems: Array.isArray(value) && value.length > 0,
|
1991
2004
|
addDisabled
|
1992
2005
|
}),
|
1993
|
-
onClick: (e) => {
|
1994
|
-
e.preventDefault();
|
1995
|
-
},
|
1996
2006
|
children: [
|
1997
|
-
/* @__PURE__ */ jsx8(
|
1998
|
-
|
1999
|
-
|
2000
|
-
|
2001
|
-
|
2002
|
-
|
2003
|
-
|
2004
|
-
|
2005
|
-
|
2006
|
-
|
2007
|
-
|
2007
|
+
localState.arrayState.items.length > 0 && /* @__PURE__ */ jsx8(
|
2008
|
+
"div",
|
2009
|
+
{
|
2010
|
+
ref: dndContainerRef,
|
2011
|
+
className: getClassName5("inner"),
|
2012
|
+
"data-dnd-container": true,
|
2013
|
+
children: localState.arrayState.items.map((item, i) => {
|
2014
|
+
const { _arrayId = `${id}-${i}`, _originalIndex = i } = item;
|
2015
|
+
const data = Array.from(localState.value || [])[i] || {};
|
2016
|
+
return /* @__PURE__ */ jsx8(
|
2017
|
+
Sortable,
|
2008
2018
|
{
|
2009
|
-
|
2010
|
-
|
2011
|
-
|
2012
|
-
|
2013
|
-
|
2014
|
-
|
2015
|
-
|
2016
|
-
|
2017
|
-
|
2018
|
-
|
2019
|
-
|
2020
|
-
|
2021
|
-
|
2022
|
-
|
2023
|
-
|
2024
|
-
|
2025
|
-
|
2026
|
-
|
2027
|
-
|
2028
|
-
|
2029
|
-
|
2030
|
-
|
2031
|
-
|
2032
|
-
|
2033
|
-
|
2034
|
-
|
2019
|
+
id: _arrayId,
|
2020
|
+
index: i,
|
2021
|
+
disabled: readOnly,
|
2022
|
+
children: ({ status, ref, handleRef }) => /* @__PURE__ */ jsxs3(
|
2023
|
+
"div",
|
2024
|
+
{
|
2025
|
+
ref,
|
2026
|
+
className: getClassNameItem({
|
2027
|
+
isExpanded: arrayState.openId === _arrayId,
|
2028
|
+
isDragging: status === "dragging",
|
2029
|
+
readOnly
|
2030
|
+
}),
|
2031
|
+
children: [
|
2032
|
+
/* @__PURE__ */ jsxs3(
|
2033
|
+
"div",
|
2034
|
+
{
|
2035
|
+
ref: handleRef,
|
2036
|
+
onClick: (e) => {
|
2037
|
+
if (isDragging) return;
|
2038
|
+
e.preventDefault();
|
2039
|
+
e.stopPropagation();
|
2040
|
+
if (arrayState.openId === _arrayId) {
|
2041
|
+
setUi(
|
2042
|
+
mapArrayStateToUi({
|
2043
|
+
openId: ""
|
2044
|
+
})
|
2045
|
+
);
|
2046
|
+
} else {
|
2047
|
+
setUi(
|
2048
|
+
mapArrayStateToUi({
|
2049
|
+
openId: _arrayId
|
2050
|
+
})
|
2051
|
+
);
|
2052
|
+
}
|
2053
|
+
},
|
2054
|
+
className: getClassNameItem("summary"),
|
2055
|
+
children: [
|
2056
|
+
field.getItemSummary ? field.getItemSummary(data, i) : `Item #${_originalIndex}`,
|
2057
|
+
/* @__PURE__ */ jsxs3("div", { className: getClassNameItem("rhs"), children: [
|
2058
|
+
!readOnly && /* @__PURE__ */ jsxs3("div", { className: getClassNameItem("actions"), children: [
|
2059
|
+
/* @__PURE__ */ jsx8("div", { className: getClassNameItem("action"), children: /* @__PURE__ */ jsx8(
|
2060
|
+
IconButton,
|
2061
|
+
{
|
2062
|
+
type: "button",
|
2063
|
+
disabled: !!addDisabled,
|
2064
|
+
onClick: (e) => {
|
2065
|
+
e.stopPropagation();
|
2066
|
+
const existingValue = [...value || []];
|
2067
|
+
existingValue.splice(
|
2068
|
+
i,
|
2069
|
+
0,
|
2070
|
+
existingValue[i]
|
2071
|
+
);
|
2072
|
+
onChange(
|
2073
|
+
existingValue,
|
2074
|
+
mapArrayStateToUi(
|
2075
|
+
regenerateArrayState(existingValue)
|
2076
|
+
)
|
2077
|
+
);
|
2078
|
+
},
|
2079
|
+
title: "Duplicate",
|
2080
|
+
children: /* @__PURE__ */ jsx8(Copy, { size: 16 })
|
2081
|
+
}
|
2082
|
+
) }),
|
2083
|
+
/* @__PURE__ */ jsx8("div", { className: getClassNameItem("action"), children: /* @__PURE__ */ jsx8(
|
2084
|
+
IconButton,
|
2085
|
+
{
|
2086
|
+
type: "button",
|
2087
|
+
disabled: field.min !== void 0 && field.min >= localState.arrayState.items.length,
|
2088
|
+
onClick: (e) => {
|
2089
|
+
e.stopPropagation();
|
2090
|
+
const existingValue = [...value || []];
|
2091
|
+
const existingItems = [
|
2092
|
+
...arrayState.items || []
|
2093
|
+
];
|
2094
|
+
existingValue.splice(i, 1);
|
2095
|
+
existingItems.splice(i, 1);
|
2096
|
+
onChange(
|
2097
|
+
existingValue,
|
2098
|
+
mapArrayStateToUi({
|
2099
|
+
items: existingItems
|
2100
|
+
})
|
2101
|
+
);
|
2102
|
+
},
|
2103
|
+
title: "Delete",
|
2104
|
+
children: /* @__PURE__ */ jsx8(Trash, { size: 16 })
|
2105
|
+
}
|
2106
|
+
) })
|
2107
|
+
] }),
|
2108
|
+
/* @__PURE__ */ jsx8("div", { children: /* @__PURE__ */ jsx8(DragIcon, {}) })
|
2109
|
+
] })
|
2110
|
+
]
|
2035
2111
|
}
|
2036
|
-
|
2037
|
-
className: getClassNameItem("
|
2038
|
-
children: [
|
2039
|
-
field.getItemSummary ? field.getItemSummary(data, i) : `Item #${_originalIndex}`,
|
2040
|
-
/* @__PURE__ */ jsxs3("div", { className: getClassNameItem("rhs"), children: [
|
2041
|
-
!readOnly && /* @__PURE__ */ jsxs3("div", { className: getClassNameItem("actions"), children: [
|
2042
|
-
/* @__PURE__ */ jsx8("div", { className: getClassNameItem("action"), children: /* @__PURE__ */ jsx8(
|
2043
|
-
IconButton,
|
2044
|
-
{
|
2045
|
-
type: "button",
|
2046
|
-
disabled: !!addDisabled,
|
2047
|
-
onClick: (e) => {
|
2048
|
-
e.stopPropagation();
|
2049
|
-
const existingValue = [...value || []];
|
2050
|
-
existingValue.splice(
|
2051
|
-
i,
|
2052
|
-
0,
|
2053
|
-
existingValue[i]
|
2054
|
-
);
|
2055
|
-
onChange(
|
2056
|
-
existingValue,
|
2057
|
-
mapArrayStateToUi(
|
2058
|
-
regenerateArrayState(existingValue)
|
2059
|
-
)
|
2060
|
-
);
|
2061
|
-
},
|
2062
|
-
title: "Duplicate",
|
2063
|
-
children: /* @__PURE__ */ jsx8(Copy, { size: 16 })
|
2064
|
-
}
|
2065
|
-
) }),
|
2066
|
-
/* @__PURE__ */ jsx8("div", { className: getClassNameItem("action"), children: /* @__PURE__ */ jsx8(
|
2067
|
-
IconButton,
|
2068
|
-
{
|
2069
|
-
type: "button",
|
2070
|
-
disabled: field.min !== void 0 && field.min >= localState.arrayState.items.length,
|
2071
|
-
onClick: (e) => {
|
2072
|
-
e.stopPropagation();
|
2073
|
-
const existingValue = [...value || []];
|
2074
|
-
const existingItems = [
|
2075
|
-
...arrayState.items || []
|
2076
|
-
];
|
2077
|
-
existingValue.splice(i, 1);
|
2078
|
-
existingItems.splice(i, 1);
|
2079
|
-
onChange(
|
2080
|
-
existingValue,
|
2081
|
-
mapArrayStateToUi({
|
2082
|
-
items: existingItems
|
2083
|
-
})
|
2084
|
-
);
|
2085
|
-
},
|
2086
|
-
title: "Delete",
|
2087
|
-
children: /* @__PURE__ */ jsx8(Trash, { size: 16 })
|
2088
|
-
}
|
2089
|
-
) })
|
2090
|
-
] }),
|
2091
|
-
/* @__PURE__ */ jsx8("div", { children: /* @__PURE__ */ jsx8(DragIcon, {}) })
|
2092
|
-
] })
|
2093
|
-
]
|
2094
|
-
}
|
2095
|
-
),
|
2096
|
-
/* @__PURE__ */ jsx8("div", { className: getClassNameItem("body"), children: /* @__PURE__ */ jsx8(
|
2097
|
-
"fieldset",
|
2098
|
-
{
|
2099
|
-
className: getClassNameItem("fieldset"),
|
2100
|
-
onPointerDownCapture: (e) => {
|
2101
|
-
e.stopPropagation();
|
2102
|
-
},
|
2103
|
-
children: Object.keys(field.arrayFields).map((subName) => {
|
2112
|
+
),
|
2113
|
+
/* @__PURE__ */ jsx8("div", { className: getClassNameItem("body"), children: /* @__PURE__ */ jsx8("fieldset", { className: getClassNameItem("fieldset"), children: Object.keys(field.arrayFields).map((subName) => {
|
2104
2114
|
const subField = field.arrayFields[subName];
|
2105
2115
|
const indexName = `${name}[${i}]`;
|
2106
2116
|
const subPath = `${indexName}.${subName}`;
|
@@ -2142,16 +2152,16 @@ var ArrayField = ({
|
|
2142
2152
|
},
|
2143
2153
|
subPath
|
2144
2154
|
);
|
2145
|
-
})
|
2146
|
-
|
2147
|
-
|
2148
|
-
|
2149
|
-
}
|
2150
|
-
|
2151
|
-
|
2152
|
-
|
2153
|
-
|
2154
|
-
|
2155
|
+
}) }) })
|
2156
|
+
]
|
2157
|
+
}
|
2158
|
+
)
|
2159
|
+
},
|
2160
|
+
_arrayId
|
2161
|
+
);
|
2162
|
+
})
|
2163
|
+
}
|
2164
|
+
),
|
2155
2165
|
!addDisabled && /* @__PURE__ */ jsx8(
|
2156
2166
|
"button",
|
2157
2167
|
{
|
@@ -3081,10 +3091,13 @@ function AutoFieldPrivate(props) {
|
|
3081
3091
|
50,
|
3082
3092
|
{ leading: true }
|
3083
3093
|
);
|
3084
|
-
const onChangeLocal = useCallback5(
|
3085
|
-
|
3086
|
-
|
3087
|
-
|
3094
|
+
const onChangeLocal = useCallback5(
|
3095
|
+
(val, ui) => {
|
3096
|
+
setLocalValue(val);
|
3097
|
+
onChangeDb(val, ui);
|
3098
|
+
},
|
3099
|
+
[onChange]
|
3100
|
+
);
|
3088
3101
|
useEffect9(() => {
|
3089
3102
|
if (state.ui.field.focus !== props.name) {
|
3090
3103
|
setLocalValue(value);
|
@@ -3117,7 +3130,7 @@ init_react_import();
|
|
3117
3130
|
var styles_module_default10 = { "Drawer": "_Drawer_fkqfo_1", "Drawer-draggable": "_Drawer-draggable_fkqfo_8", "Drawer-draggableBg": "_Drawer-draggableBg_fkqfo_12", "Drawer-draggableFg": "_Drawer-draggableFg_fkqfo_21", "DrawerItem-draggable": "_DrawerItem-draggable_fkqfo_25", "DrawerItem--disabled": "_DrawerItem--disabled_fkqfo_38", "DrawerItem": "_DrawerItem_fkqfo_25", "Drawer--isDraggingFrom": "_Drawer--isDraggingFrom_fkqfo_48", "DrawerItem-name": "_DrawerItem-name_fkqfo_66" };
|
3118
3131
|
|
3119
3132
|
// components/Drawer/index.tsx
|
3120
|
-
import {
|
3133
|
+
import { useMemo as useMemo9, useState as useState19 } from "react";
|
3121
3134
|
|
3122
3135
|
// components/DragDropContext/index.tsx
|
3123
3136
|
init_react_import();
|
@@ -3127,8 +3140,7 @@ import {
|
|
3127
3140
|
useCallback as useCallback11,
|
3128
3141
|
useContext as useContext7,
|
3129
3142
|
useEffect as useEffect15,
|
3130
|
-
|
3131
|
-
useRef as useRef3,
|
3143
|
+
useRef as useRef4,
|
3132
3144
|
useState as useState18
|
3133
3145
|
} from "react";
|
3134
3146
|
import { AutoScroller, defaultPreset } from "@dnd-kit/dom";
|
@@ -3141,7 +3153,7 @@ import {
|
|
3141
3153
|
useContext as useContext6,
|
3142
3154
|
useEffect as useEffect14,
|
3143
3155
|
useMemo as useMemo8,
|
3144
|
-
useRef as
|
3156
|
+
useRef as useRef3
|
3145
3157
|
} from "react";
|
3146
3158
|
|
3147
3159
|
// components/DraggableComponent/index.tsx
|
@@ -3151,7 +3163,7 @@ import {
|
|
3151
3163
|
useContext as useContext5,
|
3152
3164
|
useEffect as useEffect10,
|
3153
3165
|
useMemo as useMemo7,
|
3154
|
-
useRef,
|
3166
|
+
useRef as useRef2,
|
3155
3167
|
useState as useState14
|
3156
3168
|
} from "react";
|
3157
3169
|
|
@@ -3401,7 +3413,7 @@ var DraggableComponent = ({
|
|
3401
3413
|
}
|
3402
3414
|
});
|
3403
3415
|
const thisIsDragging = status === "dragging";
|
3404
|
-
const ref =
|
3416
|
+
const ref = useRef2(null);
|
3405
3417
|
const refSetter = useCallback7(
|
3406
3418
|
(el) => {
|
3407
3419
|
sortableRef(el);
|
@@ -3947,7 +3959,7 @@ var DropZoneEdit = forwardRef3(
|
|
3947
3959
|
}
|
3948
3960
|
return data.content || [];
|
3949
3961
|
}, [data, zoneCompound]);
|
3950
|
-
const ref =
|
3962
|
+
const ref = useRef3(null);
|
3951
3963
|
const acceptsTarget = useCallback10(
|
3952
3964
|
(componentType) => {
|
3953
3965
|
if (!componentType) {
|
@@ -4870,7 +4882,7 @@ function useDragListener(type, fn, deps = []) {
|
|
4870
4882
|
}
|
4871
4883
|
var AREA_CHANGE_DEBOUNCE_MS = 100;
|
4872
4884
|
var useTempDisableFallback = (timeout3) => {
|
4873
|
-
const lastFallbackDisable =
|
4885
|
+
const lastFallbackDisable = useRef4(null);
|
4874
4886
|
return useCallback11((manager) => {
|
4875
4887
|
collisionStore.setState({ fallbackEnabled: false });
|
4876
4888
|
const fallbackId = generateId();
|
@@ -4888,9 +4900,9 @@ var DragDropContextClient = ({
|
|
4888
4900
|
disableAutoScroll
|
4889
4901
|
}) => {
|
4890
4902
|
const { state, config, dispatch, resolveData } = useAppContext();
|
4891
|
-
const id =
|
4903
|
+
const id = useSafeId();
|
4892
4904
|
const { data } = state;
|
4893
|
-
const debouncedParamsRef =
|
4905
|
+
const debouncedParamsRef = useRef4(null);
|
4894
4906
|
const tempDisableFallback = useTempDisableFallback(100);
|
4895
4907
|
const [zoneStore] = useState18(
|
4896
4908
|
() => createStore3(() => ({
|
@@ -5011,7 +5023,7 @@ var DragDropContextClient = ({
|
|
5011
5023
|
const sensors = useSensors();
|
5012
5024
|
const [dragListeners, setDragListeners] = useState18({});
|
5013
5025
|
const [pathData, setPathData] = useState18();
|
5014
|
-
const dragMode =
|
5026
|
+
const dragMode = useRef4(null);
|
5015
5027
|
const registerPath = useCallback11(
|
5016
5028
|
(id2, selector, label) => {
|
5017
5029
|
const [area] = getZoneId(selector.zone);
|
@@ -5040,7 +5052,7 @@ var DragDropContextClient = ({
|
|
5040
5052
|
},
|
5041
5053
|
[data, setPathData]
|
5042
5054
|
);
|
5043
|
-
const initialSelector =
|
5055
|
+
const initialSelector = useRef4(void 0);
|
5044
5056
|
return /* @__PURE__ */ jsx23("div", { id, children: /* @__PURE__ */ jsx23(
|
5045
5057
|
dragListenerContext.Provider,
|
5046
5058
|
{
|
@@ -5371,7 +5383,7 @@ var Drawer = ({
|
|
5371
5383
|
"Warning: The `direction` prop on Drawer is deprecated and no longer required to achieve multi-directional dragging."
|
5372
5384
|
);
|
5373
5385
|
}
|
5374
|
-
const id =
|
5386
|
+
const id = useSafeId();
|
5375
5387
|
const { ref } = useDroppableSafe({
|
5376
5388
|
id,
|
5377
5389
|
type: "void",
|
@@ -5599,7 +5611,7 @@ import { useMemo as useMemo12 } from "react";
|
|
5599
5611
|
|
5600
5612
|
// lib/use-resolved-fields.ts
|
5601
5613
|
init_react_import();
|
5602
|
-
import { useCallback as useCallback13, useEffect as useEffect17, useMemo as useMemo11, useRef as
|
5614
|
+
import { useCallback as useCallback13, useEffect as useEffect17, useMemo as useMemo11, useRef as useRef6, useState as useState20 } from "react";
|
5603
5615
|
|
5604
5616
|
// lib/use-parent.ts
|
5605
5617
|
init_react_import();
|
@@ -5627,9 +5639,9 @@ var useParent = () => {
|
|
5627
5639
|
|
5628
5640
|
// lib/use-on-value-change.ts
|
5629
5641
|
init_react_import();
|
5630
|
-
import { useRef as
|
5642
|
+
import { useRef as useRef5, useEffect as useEffect16 } from "react";
|
5631
5643
|
function useOnValueChange(value, onChange, compare = Object.is, deps = []) {
|
5632
|
-
const tracked =
|
5644
|
+
const tracked = useRef5(value);
|
5633
5645
|
useEffect16(() => {
|
5634
5646
|
const oldValue = tracked.current;
|
5635
5647
|
if (!compare(value, oldValue)) {
|
@@ -5668,7 +5680,7 @@ var useResolvedFields = ({
|
|
5668
5680
|
id: selectedItem == null ? void 0 : selectedItem.props.id
|
5669
5681
|
});
|
5670
5682
|
const [fieldsLoading, setFieldsLoading] = useState20(false);
|
5671
|
-
const lastFields =
|
5683
|
+
const lastFields = useRef6(defaultFields);
|
5672
5684
|
const defaultResolveFields = (_componentData, _params) => defaultFields;
|
5673
5685
|
const componentData = useMemo11(
|
5674
5686
|
() => selectedItem ? selectedItem : { props: rootProps, readOnly: data.root.readOnly || {} },
|
@@ -6059,7 +6071,7 @@ var Components = () => {
|
|
6059
6071
|
|
6060
6072
|
// components/Puck/components/Preview/index.tsx
|
6061
6073
|
init_react_import();
|
6062
|
-
import { useCallback as useCallback14, useEffect as useEffect20, useRef as
|
6074
|
+
import { useCallback as useCallback14, useEffect as useEffect20, useRef as useRef8, useMemo as useMemo14 } from "react";
|
6063
6075
|
|
6064
6076
|
// components/AutoFrame/index.tsx
|
6065
6077
|
init_react_import();
|
@@ -6433,7 +6445,7 @@ var Preview2 = ({ id = "puck-preview" }) => {
|
|
6433
6445
|
);
|
6434
6446
|
const Frame = useMemo14(() => overrides.iframe, [overrides]);
|
6435
6447
|
const rootProps = state.data.root.props || state.data.root;
|
6436
|
-
const ref =
|
6448
|
+
const ref = useRef8(null);
|
6437
6449
|
useBubbleIframeEvents(ref);
|
6438
6450
|
const inner = state.ui.previewMode === "edit" ? /* @__PURE__ */ jsx33(
|
6439
6451
|
Page,
|
@@ -6988,7 +7000,7 @@ import {
|
|
6988
7000
|
useCallback as useCallback16,
|
6989
7001
|
useEffect as useEffect22,
|
6990
7002
|
useMemo as useMemo17,
|
6991
|
-
useRef as
|
7003
|
+
useRef as useRef9,
|
6992
7004
|
useState as useState25
|
6993
7005
|
} from "react";
|
6994
7006
|
|
@@ -7177,7 +7189,7 @@ var Canvas = () => {
|
|
7177
7189
|
const { status, iframe } = useAppContext();
|
7178
7190
|
const { dispatch, state, overrides, setUi, zoomConfig, setZoomConfig } = useAppContext();
|
7179
7191
|
const { ui } = state;
|
7180
|
-
const frameRef =
|
7192
|
+
const frameRef = useRef9(null);
|
7181
7193
|
const [showTransition, setShowTransition] = useState25(false);
|
7182
7194
|
const defaultRender = useMemo17(() => {
|
7183
7195
|
const PuckDefault = ({ children }) => /* @__PURE__ */ jsx37(Fragment13, { children });
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@measured/puck",
|
3
|
-
"version": "0.18.3-canary.
|
3
|
+
"version": "0.18.3-canary.78bb71d",
|
4
4
|
"author": "Measured Corporation Ltd <hello@measured.co>",
|
5
5
|
"repository": "measuredco/puck",
|
6
6
|
"bugs": "https://github.com/measuredco/puck/issues",
|
@@ -75,7 +75,7 @@
|
|
75
75
|
"react-hotkeys-hook": "^4.6.1",
|
76
76
|
"use-debounce": "^9.0.4",
|
77
77
|
"uuid": "^9.0.1",
|
78
|
-
"zustand": "^5.
|
78
|
+
"zustand": "^4.5.6"
|
79
79
|
},
|
80
80
|
"peerDependencies": {
|
81
81
|
"react": "^17.0.0 || ^18.0.0 || ^19.0.0"
|