@measured/puck 0.18.3-canary.098fdd1 → 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 +67 -65
- package/dist/index.mjs +67 -65
- package/package.json +1 -1
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
|
]);
|
@@ -1945,7 +1949,9 @@ var SortableProvider = ({
|
|
1945
1949
|
onMove
|
1946
1950
|
}) => {
|
1947
1951
|
const [move, setMove] = (0, import_react11.useState)({ source: -1, target: -1 });
|
1948
|
-
const sensors = useSensors(
|
1952
|
+
const sensors = useSensors({
|
1953
|
+
mouse: { distance: { value: 5 } }
|
1954
|
+
});
|
1949
1955
|
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
1950
1956
|
import_react10.DragDropProvider,
|
1951
1957
|
{
|
@@ -2000,7 +2006,11 @@ var Sortable = ({
|
|
2000
2006
|
children,
|
2001
2007
|
type = "item"
|
2002
2008
|
}) => {
|
2003
|
-
const {
|
2009
|
+
const {
|
2010
|
+
ref: sortableRef,
|
2011
|
+
status,
|
2012
|
+
handleRef
|
2013
|
+
} = useSortableSafe({
|
2004
2014
|
id,
|
2005
2015
|
type,
|
2006
2016
|
index,
|
@@ -2008,7 +2018,7 @@ var Sortable = ({
|
|
2008
2018
|
data: { index },
|
2009
2019
|
collisionDetector: createDynamicCollisionDetector("y")
|
2010
2020
|
});
|
2011
|
-
return children({ status, ref: sortableRef });
|
2021
|
+
return children({ status, ref: sortableRef, handleRef });
|
2012
2022
|
};
|
2013
2023
|
|
2014
2024
|
// components/AutoField/context.tsx
|
@@ -2173,7 +2183,7 @@ var ArrayField = ({
|
|
2173
2183
|
addDisabled
|
2174
2184
|
}),
|
2175
2185
|
children: [
|
2176
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
2186
|
+
localState.arrayState.items.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
2177
2187
|
"div",
|
2178
2188
|
{
|
2179
2189
|
ref: dndContainerRef,
|
@@ -2188,7 +2198,7 @@ var ArrayField = ({
|
|
2188
2198
|
id: _arrayId,
|
2189
2199
|
index: i,
|
2190
2200
|
disabled: readOnly,
|
2191
|
-
children: ({ status, ref }) => /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
2201
|
+
children: ({ status, ref, handleRef }) => /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
2192
2202
|
"div",
|
2193
2203
|
{
|
2194
2204
|
ref,
|
@@ -2201,6 +2211,7 @@ var ArrayField = ({
|
|
2201
2211
|
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
2202
2212
|
"div",
|
2203
2213
|
{
|
2214
|
+
ref: handleRef,
|
2204
2215
|
onClick: (e) => {
|
2205
2216
|
if (isDragging) return;
|
2206
2217
|
e.preventDefault();
|
@@ -2278,58 +2289,49 @@ var ArrayField = ({
|
|
2278
2289
|
]
|
2279
2290
|
}
|
2280
2291
|
),
|
2281
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: getClassNameItem("body"), children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
2282
|
-
|
2283
|
-
{
|
2284
|
-
|
2285
|
-
|
2286
|
-
|
2287
|
-
|
2288
|
-
|
2289
|
-
|
2290
|
-
|
2291
|
-
|
2292
|
-
|
2293
|
-
|
2294
|
-
|
2295
|
-
|
2296
|
-
|
2297
|
-
|
2298
|
-
|
2299
|
-
|
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) => {
|
2293
|
+
const subField = field.arrayFields[subName];
|
2294
|
+
const indexName = `${name}[${i}]`;
|
2295
|
+
const subPath = `${indexName}.${subName}`;
|
2296
|
+
const localIndexName = `${localName}[${i}]`;
|
2297
|
+
const localWildcardName = `${localName}[*]`;
|
2298
|
+
const localSubPath = `${localIndexName}.${subName}`;
|
2299
|
+
const localWildcardSubPath = `${localWildcardName}.${subName}`;
|
2300
|
+
const subReadOnly = forceReadOnly ? forceReadOnly : typeof readOnlyFields[subPath] !== "undefined" ? readOnlyFields[localSubPath] : readOnlyFields[localWildcardSubPath];
|
2301
|
+
const label2 = subField.label || subName;
|
2302
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
2303
|
+
NestedFieldProvider,
|
2304
|
+
{
|
2305
|
+
name: localIndexName,
|
2306
|
+
wildcardName: localWildcardName,
|
2307
|
+
subName,
|
2308
|
+
readOnlyFields,
|
2309
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
2310
|
+
AutoFieldPrivate,
|
2300
2311
|
{
|
2301
|
-
name:
|
2302
|
-
|
2303
|
-
subName
|
2304
|
-
|
2305
|
-
|
2306
|
-
|
2307
|
-
|
2308
|
-
|
2309
|
-
|
2310
|
-
|
2311
|
-
|
2312
|
-
|
2313
|
-
|
2314
|
-
|
2315
|
-
|
2316
|
-
|
2317
|
-
|
2318
|
-
|
2319
|
-
|
2320
|
-
|
2321
|
-
|
2322
|
-
|
2323
|
-
|
2324
|
-
}
|
2325
|
-
}
|
2326
|
-
)
|
2327
|
-
},
|
2328
|
-
subPath
|
2329
|
-
);
|
2330
|
-
})
|
2331
|
-
}
|
2332
|
-
) })
|
2312
|
+
name: subPath,
|
2313
|
+
label: label2,
|
2314
|
+
id: `${_arrayId}_${subName}`,
|
2315
|
+
readOnly: subReadOnly,
|
2316
|
+
field: __spreadProps(__spreadValues({}, subField), {
|
2317
|
+
label: label2
|
2318
|
+
// May be used by custom fields
|
2319
|
+
}),
|
2320
|
+
value: data[subName],
|
2321
|
+
onChange: (val, ui) => {
|
2322
|
+
onChange(
|
2323
|
+
replace(value, i, __spreadProps(__spreadValues({}, data), {
|
2324
|
+
[subName]: val
|
2325
|
+
})),
|
2326
|
+
ui
|
2327
|
+
);
|
2328
|
+
}
|
2329
|
+
}
|
2330
|
+
)
|
2331
|
+
},
|
2332
|
+
subPath
|
2333
|
+
);
|
2334
|
+
}) }) })
|
2333
2335
|
]
|
2334
2336
|
}
|
2335
2337
|
)
|
package/dist/index.mjs
CHANGED
@@ -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
|
]);
|
@@ -1766,7 +1770,9 @@ var SortableProvider = ({
|
|
1766
1770
|
onMove
|
1767
1771
|
}) => {
|
1768
1772
|
const [move, setMove] = useState6({ source: -1, target: -1 });
|
1769
|
-
const sensors = useSensors(
|
1773
|
+
const sensors = useSensors({
|
1774
|
+
mouse: { distance: { value: 5 } }
|
1775
|
+
});
|
1770
1776
|
return /* @__PURE__ */ jsx6(
|
1771
1777
|
DragDropProvider,
|
1772
1778
|
{
|
@@ -1821,7 +1827,11 @@ var Sortable = ({
|
|
1821
1827
|
children,
|
1822
1828
|
type = "item"
|
1823
1829
|
}) => {
|
1824
|
-
const {
|
1830
|
+
const {
|
1831
|
+
ref: sortableRef,
|
1832
|
+
status,
|
1833
|
+
handleRef
|
1834
|
+
} = useSortableSafe({
|
1825
1835
|
id,
|
1826
1836
|
type,
|
1827
1837
|
index,
|
@@ -1829,7 +1839,7 @@ var Sortable = ({
|
|
1829
1839
|
data: { index },
|
1830
1840
|
collisionDetector: createDynamicCollisionDetector("y")
|
1831
1841
|
});
|
1832
|
-
return children({ status, ref: sortableRef });
|
1842
|
+
return children({ status, ref: sortableRef, handleRef });
|
1833
1843
|
};
|
1834
1844
|
|
1835
1845
|
// components/AutoField/context.tsx
|
@@ -1994,7 +2004,7 @@ var ArrayField = ({
|
|
1994
2004
|
addDisabled
|
1995
2005
|
}),
|
1996
2006
|
children: [
|
1997
|
-
/* @__PURE__ */ jsx8(
|
2007
|
+
localState.arrayState.items.length > 0 && /* @__PURE__ */ jsx8(
|
1998
2008
|
"div",
|
1999
2009
|
{
|
2000
2010
|
ref: dndContainerRef,
|
@@ -2009,7 +2019,7 @@ var ArrayField = ({
|
|
2009
2019
|
id: _arrayId,
|
2010
2020
|
index: i,
|
2011
2021
|
disabled: readOnly,
|
2012
|
-
children: ({ status, ref }) => /* @__PURE__ */ jsxs3(
|
2022
|
+
children: ({ status, ref, handleRef }) => /* @__PURE__ */ jsxs3(
|
2013
2023
|
"div",
|
2014
2024
|
{
|
2015
2025
|
ref,
|
@@ -2022,6 +2032,7 @@ var ArrayField = ({
|
|
2022
2032
|
/* @__PURE__ */ jsxs3(
|
2023
2033
|
"div",
|
2024
2034
|
{
|
2035
|
+
ref: handleRef,
|
2025
2036
|
onClick: (e) => {
|
2026
2037
|
if (isDragging) return;
|
2027
2038
|
e.preventDefault();
|
@@ -2099,58 +2110,49 @@ var ArrayField = ({
|
|
2099
2110
|
]
|
2100
2111
|
}
|
2101
2112
|
),
|
2102
|
-
/* @__PURE__ */ jsx8("div", { className: getClassNameItem("body"), children: /* @__PURE__ */ jsx8(
|
2103
|
-
|
2104
|
-
{
|
2105
|
-
|
2106
|
-
|
2107
|
-
|
2108
|
-
|
2109
|
-
|
2110
|
-
|
2111
|
-
|
2112
|
-
|
2113
|
-
|
2114
|
-
|
2115
|
-
|
2116
|
-
|
2117
|
-
|
2118
|
-
|
2119
|
-
|
2120
|
-
|
2113
|
+
/* @__PURE__ */ jsx8("div", { className: getClassNameItem("body"), children: /* @__PURE__ */ jsx8("fieldset", { className: getClassNameItem("fieldset"), children: Object.keys(field.arrayFields).map((subName) => {
|
2114
|
+
const subField = field.arrayFields[subName];
|
2115
|
+
const indexName = `${name}[${i}]`;
|
2116
|
+
const subPath = `${indexName}.${subName}`;
|
2117
|
+
const localIndexName = `${localName}[${i}]`;
|
2118
|
+
const localWildcardName = `${localName}[*]`;
|
2119
|
+
const localSubPath = `${localIndexName}.${subName}`;
|
2120
|
+
const localWildcardSubPath = `${localWildcardName}.${subName}`;
|
2121
|
+
const subReadOnly = forceReadOnly ? forceReadOnly : typeof readOnlyFields[subPath] !== "undefined" ? readOnlyFields[localSubPath] : readOnlyFields[localWildcardSubPath];
|
2122
|
+
const label2 = subField.label || subName;
|
2123
|
+
return /* @__PURE__ */ jsx8(
|
2124
|
+
NestedFieldProvider,
|
2125
|
+
{
|
2126
|
+
name: localIndexName,
|
2127
|
+
wildcardName: localWildcardName,
|
2128
|
+
subName,
|
2129
|
+
readOnlyFields,
|
2130
|
+
children: /* @__PURE__ */ jsx8(
|
2131
|
+
AutoFieldPrivate,
|
2121
2132
|
{
|
2122
|
-
name:
|
2123
|
-
|
2124
|
-
subName
|
2125
|
-
|
2126
|
-
|
2127
|
-
|
2128
|
-
|
2129
|
-
|
2130
|
-
|
2131
|
-
|
2132
|
-
|
2133
|
-
|
2134
|
-
|
2135
|
-
|
2136
|
-
|
2137
|
-
|
2138
|
-
|
2139
|
-
|
2140
|
-
|
2141
|
-
|
2142
|
-
|
2143
|
-
|
2144
|
-
|
2145
|
-
}
|
2146
|
-
}
|
2147
|
-
)
|
2148
|
-
},
|
2149
|
-
subPath
|
2150
|
-
);
|
2151
|
-
})
|
2152
|
-
}
|
2153
|
-
) })
|
2133
|
+
name: subPath,
|
2134
|
+
label: label2,
|
2135
|
+
id: `${_arrayId}_${subName}`,
|
2136
|
+
readOnly: subReadOnly,
|
2137
|
+
field: __spreadProps(__spreadValues({}, subField), {
|
2138
|
+
label: label2
|
2139
|
+
// May be used by custom fields
|
2140
|
+
}),
|
2141
|
+
value: data[subName],
|
2142
|
+
onChange: (val, ui) => {
|
2143
|
+
onChange(
|
2144
|
+
replace(value, i, __spreadProps(__spreadValues({}, data), {
|
2145
|
+
[subName]: val
|
2146
|
+
})),
|
2147
|
+
ui
|
2148
|
+
);
|
2149
|
+
}
|
2150
|
+
}
|
2151
|
+
)
|
2152
|
+
},
|
2153
|
+
subPath
|
2154
|
+
);
|
2155
|
+
}) }) })
|
2154
2156
|
]
|
2155
2157
|
}
|
2156
2158
|
)
|
package/package.json
CHANGED