@contentful/field-editor-reference 5.3.2 → 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.
@@ -2946,9 +2946,6 @@ function WrappedEntryCard(props) {
2946
2946
  size: props.size,
2947
2947
  isSelected: props.isSelected,
2948
2948
  status: status,
2949
- style: props.spaceName ? {
2950
- backgroundColor: tokens.gray100
2951
- } : undefined,
2952
2949
  icon: props.spaceName ? createElement(SpaceName, {
2953
2950
  spaceName: props.spaceName
2954
2951
  }) : createElement(ScheduledIconWithTooltip, {
@@ -3181,7 +3178,8 @@ function FetchingWrappedEntryCard(props) {
3181
3178
  onEdit: onEdit,
3182
3179
  onRemove: onRemoveEntry,
3183
3180
  onMoveTop: props.onMoveTop,
3184
- onMoveBottom: props.onMoveBottom
3181
+ onMoveBottom: props.onMoveBottom,
3182
+ isBeingDragged: props.isBeingDragged
3185
3183
  };
3186
3184
  var hasCardEditActions = props.hasCardEditActions,
3187
3185
  hasCardMoveActions = props.hasCardMoveActions,
@@ -3270,7 +3268,8 @@ var nullableValue = {
3270
3268
 
3271
3269
  function Editor$1(props) {
3272
3270
  var setValue = props.setValue,
3273
- entityType = props.entityType;
3271
+ entityType = props.entityType,
3272
+ setIndexToUpdate = props.setIndexToUpdate;
3274
3273
  var editorPermissions = useEditorPermissions(props);
3275
3274
  var items = useMemo(function () {
3276
3275
  return (props.items || []). // If null values have found their way into the persisted
@@ -3282,14 +3281,20 @@ function Editor$1(props) {
3282
3281
  });
3283
3282
  }, [props.items]);
3284
3283
  var onSortStart = useCallback(function (_, event) {
3285
- return event.preventDefault();
3284
+ if (event instanceof MouseEvent) {
3285
+ document.body.classList.add('grabbing');
3286
+ }
3287
+
3288
+ event.preventDefault();
3286
3289
  }, []);
3287
3290
  var onSortEnd = useCallback(function (_ref) {
3288
3291
  var oldIndex = _ref.oldIndex,
3289
3292
  newIndex = _ref.newIndex;
3290
3293
  var newItems = arrayMove(items, oldIndex, newIndex);
3291
3294
  setValue(newItems);
3292
- }, [items, setValue]);
3295
+ setIndexToUpdate && setIndexToUpdate(undefined);
3296
+ document.body.classList.remove('grabbing');
3297
+ }, [items, setIndexToUpdate, setValue]);
3293
3298
  var onMove = useCallback(function (oldIndex, newIndex) {
3294
3299
  var newItems = arrayMove(items, oldIndex, newIndex);
3295
3300
  setValue(newItems);
@@ -3391,18 +3396,29 @@ function SortableLinkList(props) {
3391
3396
  }
3392
3397
 
3393
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
+
3394
3408
  return createElement(MultipleReferenceEditor, _extends({}, props, {
3395
- entityType: "Entry"
3409
+ entityType: "Entry",
3410
+ setIndexToUpdate: setIndexToUpdate
3396
3411
  }), function (childrenProps) {
3397
3412
  return createElement(SortableLinkList, _extends({}, childrenProps, {
3398
3413
  axis: "y",
3399
- useDragHandle: true
3400
- }), function (_ref) {
3401
- var items = _ref.items,
3402
- item = _ref.item,
3403
- index = _ref.index,
3404
- isDisabled = _ref.isDisabled,
3405
- DragHandle = _ref.DragHandle;
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;
3406
3422
  var lastIndex = items.length - 1;
3407
3423
  return createElement(FetchingWrappedEntryCard, _extends({}, childrenProps, {
3408
3424
  key: item.sys.id + "-" + index,
@@ -3421,7 +3437,8 @@ function MultipleEntryReferenceEditor(props) {
3421
3437
  onMoveBottom: index !== lastIndex ? function () {
3422
3438
  return childrenProps.onMove(index, lastIndex);
3423
3439
  } : undefined,
3424
- renderDragHandle: DragHandle
3440
+ renderDragHandle: DragHandle,
3441
+ isBeingDragged: index === indexToUpdate
3425
3442
  }));
3426
3443
  });
3427
3444
  });