@contentful/field-editor-reference 5.3.3 → 5.4.0
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/CHANGELOG.md +6 -0
- package/dist/common/MultipleReferenceEditor.d.ts +2 -1
- package/dist/common/ReferenceEditor.d.ts +3 -0
- package/dist/common/customCardTypes.d.ts +2 -1
- package/dist/entries/WrappedEntryCard/FetchingWrappedEntryCard.d.ts +1 -0
- package/dist/field-editor-reference.cjs.development.js +33 -13
- package/dist/field-editor-reference.cjs.development.js.map +1 -1
- package/dist/field-editor-reference.cjs.production.min.js +1 -1
- package/dist/field-editor-reference.cjs.production.min.js.map +1 -1
- package/dist/field-editor-reference.esm.js +33 -13
- package/dist/field-editor-reference.esm.js.map +1 -1
- package/package.json +2 -2
|
@@ -3178,7 +3178,8 @@ function FetchingWrappedEntryCard(props) {
|
|
|
3178
3178
|
onEdit: onEdit,
|
|
3179
3179
|
onRemove: onRemoveEntry,
|
|
3180
3180
|
onMoveTop: props.onMoveTop,
|
|
3181
|
-
onMoveBottom: props.onMoveBottom
|
|
3181
|
+
onMoveBottom: props.onMoveBottom,
|
|
3182
|
+
isBeingDragged: props.isBeingDragged
|
|
3182
3183
|
};
|
|
3183
3184
|
var hasCardEditActions = props.hasCardEditActions,
|
|
3184
3185
|
hasCardMoveActions = props.hasCardMoveActions,
|
|
@@ -3267,7 +3268,8 @@ var nullableValue = {
|
|
|
3267
3268
|
|
|
3268
3269
|
function Editor$1(props) {
|
|
3269
3270
|
var setValue = props.setValue,
|
|
3270
|
-
entityType = props.entityType
|
|
3271
|
+
entityType = props.entityType,
|
|
3272
|
+
setIndexToUpdate = props.setIndexToUpdate;
|
|
3271
3273
|
var editorPermissions = useEditorPermissions(props);
|
|
3272
3274
|
var items = useMemo(function () {
|
|
3273
3275
|
return (props.items || []). // If null values have found their way into the persisted
|
|
@@ -3279,14 +3281,20 @@ function Editor$1(props) {
|
|
|
3279
3281
|
});
|
|
3280
3282
|
}, [props.items]);
|
|
3281
3283
|
var onSortStart = useCallback(function (_, event) {
|
|
3282
|
-
|
|
3284
|
+
if (event instanceof MouseEvent) {
|
|
3285
|
+
document.body.classList.add('grabbing');
|
|
3286
|
+
}
|
|
3287
|
+
|
|
3288
|
+
event.preventDefault();
|
|
3283
3289
|
}, []);
|
|
3284
3290
|
var onSortEnd = useCallback(function (_ref) {
|
|
3285
3291
|
var oldIndex = _ref.oldIndex,
|
|
3286
3292
|
newIndex = _ref.newIndex;
|
|
3287
3293
|
var newItems = arrayMove(items, oldIndex, newIndex);
|
|
3288
3294
|
setValue(newItems);
|
|
3289
|
-
|
|
3295
|
+
setIndexToUpdate && setIndexToUpdate(undefined);
|
|
3296
|
+
document.body.classList.remove('grabbing');
|
|
3297
|
+
}, [items, setIndexToUpdate, setValue]);
|
|
3290
3298
|
var onMove = useCallback(function (oldIndex, newIndex) {
|
|
3291
3299
|
var newItems = arrayMove(items, oldIndex, newIndex);
|
|
3292
3300
|
setValue(newItems);
|
|
@@ -3388,18 +3396,29 @@ function SortableLinkList(props) {
|
|
|
3388
3396
|
}
|
|
3389
3397
|
|
|
3390
3398
|
function MultipleEntryReferenceEditor(props) {
|
|
3399
|
+
var _React$useState = useState(undefined),
|
|
3400
|
+
indexToUpdate = _React$useState[0],
|
|
3401
|
+
setIndexToUpdate = _React$useState[1];
|
|
3402
|
+
|
|
3403
|
+
var updateBeforeSortStart = function updateBeforeSortStart(_ref) {
|
|
3404
|
+
var index = _ref.index;
|
|
3405
|
+
setIndexToUpdate(index);
|
|
3406
|
+
};
|
|
3407
|
+
|
|
3391
3408
|
return createElement(MultipleReferenceEditor, _extends({}, props, {
|
|
3392
|
-
entityType: "Entry"
|
|
3409
|
+
entityType: "Entry",
|
|
3410
|
+
setIndexToUpdate: setIndexToUpdate
|
|
3393
3411
|
}), function (childrenProps) {
|
|
3394
3412
|
return createElement(SortableLinkList, _extends({}, childrenProps, {
|
|
3395
3413
|
axis: "y",
|
|
3396
|
-
useDragHandle: true
|
|
3397
|
-
|
|
3398
|
-
|
|
3399
|
-
|
|
3400
|
-
|
|
3401
|
-
|
|
3402
|
-
|
|
3414
|
+
useDragHandle: true,
|
|
3415
|
+
updateBeforeSortStart: updateBeforeSortStart
|
|
3416
|
+
}), function (_ref2) {
|
|
3417
|
+
var items = _ref2.items,
|
|
3418
|
+
item = _ref2.item,
|
|
3419
|
+
index = _ref2.index,
|
|
3420
|
+
isDisabled = _ref2.isDisabled,
|
|
3421
|
+
DragHandle = _ref2.DragHandle;
|
|
3403
3422
|
var lastIndex = items.length - 1;
|
|
3404
3423
|
return createElement(FetchingWrappedEntryCard, _extends({}, childrenProps, {
|
|
3405
3424
|
key: item.sys.id + "-" + index,
|
|
@@ -3418,7 +3437,8 @@ function MultipleEntryReferenceEditor(props) {
|
|
|
3418
3437
|
onMoveBottom: index !== lastIndex ? function () {
|
|
3419
3438
|
return childrenProps.onMove(index, lastIndex);
|
|
3420
3439
|
} : undefined,
|
|
3421
|
-
renderDragHandle: DragHandle
|
|
3440
|
+
renderDragHandle: DragHandle,
|
|
3441
|
+
isBeingDragged: index === indexToUpdate
|
|
3422
3442
|
}));
|
|
3423
3443
|
});
|
|
3424
3444
|
});
|