@measured/puck 0.18.3-canary.1d484ee → 0.18.3-canary.368f37f
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +19 -16
- package/dist/index.mjs +22 -18
- package/package.json +3 -3
package/dist/index.js
CHANGED
@@ -2134,6 +2134,7 @@ var ArrayField = ({
|
|
2134
2134
|
const [draggedItem, setDraggedItem] = (0, import_react12.useState)("");
|
2135
2135
|
const isDragging = !!draggedItem;
|
2136
2136
|
const forceReadOnly = getPermissions({ item: selectedItem }).edit === false;
|
2137
|
+
const valueRef = (0, import_react12.useRef)(value);
|
2137
2138
|
if (field.type !== "array" || !field.arrayFields) {
|
2138
2139
|
return null;
|
2139
2140
|
}
|
@@ -2151,10 +2152,11 @@ var ArrayField = ({
|
|
2151
2152
|
onDragStart: (id2) => setDraggedItem(id2),
|
2152
2153
|
onDragEnd: () => {
|
2153
2154
|
setDraggedItem("");
|
2154
|
-
onChange(
|
2155
|
+
onChange(valueRef.current);
|
2155
2156
|
},
|
2156
2157
|
onMove: (move) => {
|
2157
|
-
|
2158
|
+
var _a;
|
2159
|
+
if (((_a = arrayState.items[move.source]) == null ? void 0 : _a._arrayId) !== draggedItem) {
|
2158
2160
|
return;
|
2159
2161
|
}
|
2160
2162
|
const newValue = reorder(localState.value, move.source, move.target);
|
@@ -2173,6 +2175,7 @@ var ArrayField = ({
|
|
2173
2175
|
value: newValue,
|
2174
2176
|
arrayState: __spreadProps(__spreadValues({}, arrayState), { items: newArrayStateItems })
|
2175
2177
|
});
|
2178
|
+
valueRef.current = newValue;
|
2176
2179
|
},
|
2177
2180
|
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
2178
2181
|
"div",
|
@@ -2241,12 +2244,11 @@ var ArrayField = ({
|
|
2241
2244
|
0,
|
2242
2245
|
existingValue[i]
|
2243
2246
|
);
|
2244
|
-
|
2245
|
-
existingValue
|
2246
|
-
mapArrayStateToUi(
|
2247
|
-
regenerateArrayState(existingValue)
|
2248
|
-
)
|
2247
|
+
const newUi = mapArrayStateToUi(
|
2248
|
+
regenerateArrayState(existingValue)
|
2249
2249
|
);
|
2250
|
+
setUi(newUi, false);
|
2251
|
+
onChange(existingValue, newUi);
|
2250
2252
|
},
|
2251
2253
|
title: "Duplicate",
|
2252
2254
|
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Copy, { size: 16 })
|
@@ -2265,12 +2267,11 @@ var ArrayField = ({
|
|
2265
2267
|
];
|
2266
2268
|
existingValue.splice(i, 1);
|
2267
2269
|
existingItems.splice(i, 1);
|
2268
|
-
|
2269
|
-
|
2270
|
-
|
2271
|
-
|
2272
|
-
|
2273
|
-
);
|
2270
|
+
const newUi = mapArrayStateToUi({
|
2271
|
+
items: existingItems
|
2272
|
+
});
|
2273
|
+
setUi(newUi, false);
|
2274
|
+
onChange(existingValue, newUi);
|
2274
2275
|
},
|
2275
2276
|
title: "Delete",
|
2276
2277
|
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Trash, { size: 16 })
|
@@ -2345,7 +2346,9 @@ var ArrayField = ({
|
|
2345
2346
|
field.defaultItemProps || {}
|
2346
2347
|
];
|
2347
2348
|
const newArrayState = regenerateArrayState(newValue);
|
2348
|
-
|
2349
|
+
const newUi = mapArrayStateToUi(newArrayState);
|
2350
|
+
setUi(newUi, false);
|
2351
|
+
onChange(newValue, newUi);
|
2349
2352
|
},
|
2350
2353
|
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Plus, { size: 21 })
|
2351
2354
|
}
|
@@ -5046,7 +5049,7 @@ var DragDropContextClient = ({
|
|
5046
5049
|
disableAutoScroll
|
5047
5050
|
}) => {
|
5048
5051
|
const { state, config, dispatch, resolveData } = useAppContext();
|
5049
|
-
const id =
|
5052
|
+
const id = (0, import_react31.useId)();
|
5050
5053
|
const { data } = state;
|
5051
5054
|
const debouncedParamsRef = (0, import_react31.useRef)(null);
|
5052
5055
|
const tempDisableFallback = useTempDisableFallback(100);
|
@@ -5529,7 +5532,7 @@ var Drawer = ({
|
|
5529
5532
|
"Warning: The `direction` prop on Drawer is deprecated and no longer required to achieve multi-directional dragging."
|
5530
5533
|
);
|
5531
5534
|
}
|
5532
|
-
const id =
|
5535
|
+
const id = (0, import_react32.useId)();
|
5533
5536
|
const { ref } = useDroppableSafe({
|
5534
5537
|
id,
|
5535
5538
|
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 useState6 } from "react";
|
677
|
+
import { useCallback as useCallback3, useEffect as useEffect4, useRef, useState as useState6 } from "react";
|
678
678
|
|
679
679
|
// components/DragIcon/index.tsx
|
680
680
|
init_react_import();
|
@@ -1955,6 +1955,7 @@ var ArrayField = ({
|
|
1955
1955
|
const [draggedItem, setDraggedItem] = useState6("");
|
1956
1956
|
const isDragging = !!draggedItem;
|
1957
1957
|
const forceReadOnly = getPermissions({ item: selectedItem }).edit === false;
|
1958
|
+
const valueRef = useRef(value);
|
1958
1959
|
if (field.type !== "array" || !field.arrayFields) {
|
1959
1960
|
return null;
|
1960
1961
|
}
|
@@ -1972,10 +1973,11 @@ var ArrayField = ({
|
|
1972
1973
|
onDragStart: (id2) => setDraggedItem(id2),
|
1973
1974
|
onDragEnd: () => {
|
1974
1975
|
setDraggedItem("");
|
1975
|
-
onChange(
|
1976
|
+
onChange(valueRef.current);
|
1976
1977
|
},
|
1977
1978
|
onMove: (move) => {
|
1978
|
-
|
1979
|
+
var _a;
|
1980
|
+
if (((_a = arrayState.items[move.source]) == null ? void 0 : _a._arrayId) !== draggedItem) {
|
1979
1981
|
return;
|
1980
1982
|
}
|
1981
1983
|
const newValue = reorder(localState.value, move.source, move.target);
|
@@ -1994,6 +1996,7 @@ var ArrayField = ({
|
|
1994
1996
|
value: newValue,
|
1995
1997
|
arrayState: __spreadProps(__spreadValues({}, arrayState), { items: newArrayStateItems })
|
1996
1998
|
});
|
1999
|
+
valueRef.current = newValue;
|
1997
2000
|
},
|
1998
2001
|
children: /* @__PURE__ */ jsxs3(
|
1999
2002
|
"div",
|
@@ -2062,12 +2065,11 @@ var ArrayField = ({
|
|
2062
2065
|
0,
|
2063
2066
|
existingValue[i]
|
2064
2067
|
);
|
2065
|
-
|
2066
|
-
existingValue
|
2067
|
-
mapArrayStateToUi(
|
2068
|
-
regenerateArrayState(existingValue)
|
2069
|
-
)
|
2068
|
+
const newUi = mapArrayStateToUi(
|
2069
|
+
regenerateArrayState(existingValue)
|
2070
2070
|
);
|
2071
|
+
setUi(newUi, false);
|
2072
|
+
onChange(existingValue, newUi);
|
2071
2073
|
},
|
2072
2074
|
title: "Duplicate",
|
2073
2075
|
children: /* @__PURE__ */ jsx8(Copy, { size: 16 })
|
@@ -2086,12 +2088,11 @@ var ArrayField = ({
|
|
2086
2088
|
];
|
2087
2089
|
existingValue.splice(i, 1);
|
2088
2090
|
existingItems.splice(i, 1);
|
2089
|
-
|
2090
|
-
|
2091
|
-
|
2092
|
-
|
2093
|
-
|
2094
|
-
);
|
2091
|
+
const newUi = mapArrayStateToUi({
|
2092
|
+
items: existingItems
|
2093
|
+
});
|
2094
|
+
setUi(newUi, false);
|
2095
|
+
onChange(existingValue, newUi);
|
2095
2096
|
},
|
2096
2097
|
title: "Delete",
|
2097
2098
|
children: /* @__PURE__ */ jsx8(Trash, { size: 16 })
|
@@ -2166,7 +2167,9 @@ var ArrayField = ({
|
|
2166
2167
|
field.defaultItemProps || {}
|
2167
2168
|
];
|
2168
2169
|
const newArrayState = regenerateArrayState(newValue);
|
2169
|
-
|
2170
|
+
const newUi = mapArrayStateToUi(newArrayState);
|
2171
|
+
setUi(newUi, false);
|
2172
|
+
onChange(newValue, newUi);
|
2170
2173
|
},
|
2171
2174
|
children: /* @__PURE__ */ jsx8(Plus, { size: 21 })
|
2172
2175
|
}
|
@@ -3121,7 +3124,7 @@ init_react_import();
|
|
3121
3124
|
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" };
|
3122
3125
|
|
3123
3126
|
// components/Drawer/index.tsx
|
3124
|
-
import { useMemo as useMemo9, useState as useState18 } from "react";
|
3127
|
+
import { useId as useId2, useMemo as useMemo9, useState as useState18 } from "react";
|
3125
3128
|
|
3126
3129
|
// components/DragDropContext/index.tsx
|
3127
3130
|
init_react_import();
|
@@ -3131,6 +3134,7 @@ import {
|
|
3131
3134
|
useCallback as useCallback11,
|
3132
3135
|
useContext as useContext7,
|
3133
3136
|
useEffect as useEffect15,
|
3137
|
+
useId,
|
3134
3138
|
useRef as useRef4,
|
3135
3139
|
useState as useState17
|
3136
3140
|
} from "react";
|
@@ -4899,7 +4903,7 @@ var DragDropContextClient = ({
|
|
4899
4903
|
disableAutoScroll
|
4900
4904
|
}) => {
|
4901
4905
|
const { state, config, dispatch, resolveData } = useAppContext();
|
4902
|
-
const id =
|
4906
|
+
const id = useId();
|
4903
4907
|
const { data } = state;
|
4904
4908
|
const debouncedParamsRef = useRef4(null);
|
4905
4909
|
const tempDisableFallback = useTempDisableFallback(100);
|
@@ -5382,7 +5386,7 @@ var Drawer = ({
|
|
5382
5386
|
"Warning: The `direction` prop on Drawer is deprecated and no longer required to achieve multi-directional dragging."
|
5383
5387
|
);
|
5384
5388
|
}
|
5385
|
-
const id =
|
5389
|
+
const id = useId2();
|
5386
5390
|
const { ref } = useDroppableSafe({
|
5387
5391
|
id,
|
5388
5392
|
type: "void",
|
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.368f37f",
|
4
4
|
"author": "Measured Corporation Ltd <hello@measured.co>",
|
5
5
|
"repository": "measuredco/puck",
|
6
6
|
"bugs": "https://github.com/measuredco/puck/issues",
|
@@ -75,9 +75,9 @@
|
|
75
75
|
"react-hotkeys-hook": "^4.6.1",
|
76
76
|
"use-debounce": "^9.0.4",
|
77
77
|
"uuid": "^9.0.1",
|
78
|
-
"zustand": "^
|
78
|
+
"zustand": "^5.0.2"
|
79
79
|
},
|
80
80
|
"peerDependencies": {
|
81
|
-
"react": "^
|
81
|
+
"react": "^18.0.0 || ^19.0.0"
|
82
82
|
}
|
83
83
|
}
|