@contentful/field-editor-reference 4.6.0 → 4.6.1

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 CHANGED
@@ -3,6 +3,12 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [4.6.1](https://github.com/contentful/field-editors/compare/@contentful/field-editor-reference@4.6.0...@contentful/field-editor-reference@4.6.1) (2022-07-18)
7
+
8
+ ### Bug Fixes
9
+
10
+ - correctly pass props to children of SortableLinkList ([#1187](https://github.com/contentful/field-editors/issues/1187)) ([5f574b9](https://github.com/contentful/field-editors/commit/5f574b938670290e8e2bb8c0b9bcb67720a83da9))
11
+
6
12
  # [4.6.0](https://github.com/contentful/field-editors/compare/@contentful/field-editor-reference@4.5.1...@contentful/field-editor-reference@4.6.0) (2022-07-15)
7
13
 
8
14
  ### Features
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import { SortableContainerProps } from 'react-sortable-hoc';
3
3
  import { ReferenceEditorProps } from './ReferenceEditor';
4
- declare type SortableContainerChildProps<IType> = SortableLinkListProps<IType> & {
4
+ declare type SortableContainerChildProps<IType> = Pick<SortableLinkListProps<IType>, 'items' | 'isDisabled'> & {
5
5
  item: IType;
6
6
  index: number;
7
7
  DragHandle?: typeof DragHandle;
@@ -3302,8 +3302,7 @@ var styles$3 = {
3302
3302
  position: 'relative'
3303
3303
  }),
3304
3304
  item: /*#__PURE__*/emotion.css({
3305
- marginBottom: tokens.spacingM,
3306
- marginRight: tokens.spacingM
3305
+ marginBottom: tokens.spacingM
3307
3306
  })
3308
3307
  };
3309
3308
 
@@ -3323,50 +3322,58 @@ var SortableLinkListInternal = /*#__PURE__*/reactSortableHoc.SortableContainer(f
3323
3322
  return React__default.createElement("div", {
3324
3323
  className: emotion.cx(styles$3.container, props.className)
3325
3324
  }, props.items.map(function (item, index) {
3326
- var _item$sys$id;
3325
+ var _item$sys$urn;
3327
3326
 
3328
3327
  return React__default.createElement(SortableLink, {
3329
3328
  disabled: props.isDisabled,
3330
- key: ((_item$sys$id = item.sys.id) != null ? _item$sys$id : item.sys.urn) + "-" + index,
3329
+ key: ((_item$sys$urn = item.sys.urn) != null ? _item$sys$urn : item.sys.id) + "-" + index,
3331
3330
  index: index
3332
- }, props.children(_extends({}, props, {
3331
+ }, props.children({
3332
+ items: props.items,
3333
+ isDisabled: props.isDisabled,
3333
3334
  item: item,
3334
3335
  index: index,
3335
3336
  DragHandle: props.isDisabled ? undefined : DragHandle
3336
- })));
3337
+ }));
3337
3338
  }));
3338
3339
  }); // HOC does not support generics, so we mimic it via additional component
3339
3340
 
3340
3341
  function SortableLinkList(props) {
3341
- return React__default.createElement(SortableLinkListInternal, Object.assign({}, props, {
3342
- children: props.children
3343
- }));
3342
+ return React__default.createElement(SortableLinkListInternal, Object.assign({}, props), props.children);
3344
3343
  }
3345
3344
 
3346
3345
  function MultipleEntryReferenceEditor(props) {
3347
3346
  return React.createElement(MultipleReferenceEditor, Object.assign({}, props, {
3348
3347
  entityType: "Entry"
3349
3348
  }), function (childrenProps) {
3350
- return React.createElement(SortableLinkList, Object.assign({}, childrenProps), function (props) {
3351
- var lastIndex = props.items.length - 1;
3349
+ return React.createElement(SortableLinkList, Object.assign({}, props, childrenProps, {
3350
+ axis: "y",
3351
+ useDragHandle: true
3352
+ }), function (_ref) {
3353
+ var items = _ref.items,
3354
+ item = _ref.item,
3355
+ index = _ref.index,
3356
+ isDisabled = _ref.isDisabled,
3357
+ DragHandle = _ref.DragHandle;
3358
+ var lastIndex = items.length - 1;
3352
3359
  return React.createElement(FetchingWrappedEntryCard, Object.assign({}, props, {
3353
- key: props.item.sys.id + "-" + props.index,
3354
- index: props.index,
3360
+ key: item.sys.id + "-" + index,
3361
+ index: index,
3355
3362
  allContentTypes: childrenProps.allContentTypes,
3356
- isDisabled: props.isDisabled,
3357
- entryId: props.item.sys.id,
3363
+ isDisabled: isDisabled,
3364
+ entryId: item.sys.id,
3358
3365
  onRemove: function onRemove() {
3359
- childrenProps.setValue(props.items.filter(function (_value, i) {
3360
- return i !== props.index;
3366
+ childrenProps.setValue(items.filter(function (_value, i) {
3367
+ return i !== index;
3361
3368
  }));
3362
3369
  },
3363
- onMoveTop: props.index !== 0 ? function () {
3364
- return childrenProps.onMove(props.index, 0);
3370
+ onMoveTop: index !== 0 ? function () {
3371
+ return childrenProps.onMove(index, 0);
3365
3372
  } : undefined,
3366
- onMoveBottom: props.index !== lastIndex ? function () {
3367
- return childrenProps.onMove(props.index, lastIndex);
3373
+ onMoveBottom: index !== lastIndex ? function () {
3374
+ return childrenProps.onMove(index, lastIndex);
3368
3375
  } : undefined,
3369
- renderDragHandle: props.DragHandle
3376
+ renderDragHandle: DragHandle
3370
3377
  }));
3371
3378
  });
3372
3379
  });
@@ -3793,17 +3800,24 @@ function MultipleMediaEditor(props) {
3793
3800
 
3794
3801
  return React.createElement(SortableLinkList, Object.assign({}, childrenProps, {
3795
3802
  className: emotion.cx((_cx = {}, _cx[styles$6.gridContainer] = childrenProps.viewType === 'card', _cx)),
3796
- axis: childrenProps.viewType === 'card' ? 'xy' : 'y'
3797
- }), function (props) {
3803
+ axis: childrenProps.viewType === 'card' ? 'xy' : 'y',
3804
+ useDragHandle: true
3805
+ }), function (_ref) {
3806
+ var items = _ref.items,
3807
+ item = _ref.item,
3808
+ index = _ref.index,
3809
+ isDisabled = _ref.isDisabled,
3810
+ DragHandle = _ref.DragHandle;
3798
3811
  return React.createElement(FetchingWrappedAssetCard, Object.assign({}, props, {
3799
- key: props.item.sys.id + "-" + props.index,
3800
- assetId: props.item.sys.id,
3812
+ isDisabled: isDisabled,
3813
+ key: item.sys.id + "-" + index,
3814
+ assetId: item.sys.id,
3801
3815
  onRemove: function onRemove() {
3802
- childrenProps.setValue(props.items.filter(function (_value, i) {
3803
- return i !== props.index;
3816
+ childrenProps.setValue(items.filter(function (_value, i) {
3817
+ return i !== index;
3804
3818
  }));
3805
3819
  },
3806
- renderDragHandle: props.DragHandle
3820
+ renderDragHandle: DragHandle
3807
3821
  }));
3808
3822
  });
3809
3823
  });