@contentful/field-editor-reference 4.6.0 → 4.6.3

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,24 @@
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.3](https://github.com/contentful/field-editors/compare/@contentful/field-editor-reference@4.6.2...@contentful/field-editor-reference@4.6.3) (2022-07-19)
7
+
8
+ ### Bug Fixes
9
+
10
+ - drill props correctly ([#1190](https://github.com/contentful/field-editors/issues/1190)) ([f17742a](https://github.com/contentful/field-editors/commit/f17742a80f1d41f15a494fd84436deb745e4431d))
11
+
12
+ ## [4.6.2](https://github.com/contentful/field-editors/compare/@contentful/field-editor-reference@4.6.1...@contentful/field-editor-reference@4.6.2) (2022-07-18)
13
+
14
+ ### Bug Fixes
15
+
16
+ - click handler on children of sortable list ([#1188](https://github.com/contentful/field-editors/issues/1188)) ([7ebab54](https://github.com/contentful/field-editors/commit/7ebab54b2ecd301b3cf066615b124da72b46856a))
17
+
18
+ ## [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)
19
+
20
+ ### Bug Fixes
21
+
22
+ - 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))
23
+
6
24
  # [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
25
 
8
26
  ### 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,62 @@ 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
+ // with the default distance of 0 the drag start event is "confused" with the click event,
3343
+ // so the latter one isn't fired and click handlers on child elements don't work
3344
+ return React__default.createElement(SortableLinkListInternal, Object.assign({
3345
+ distance: 1
3346
+ }, props), props.children);
3344
3347
  }
3345
3348
 
3346
3349
  function MultipleEntryReferenceEditor(props) {
3347
3350
  return React.createElement(MultipleReferenceEditor, Object.assign({}, props, {
3348
3351
  entityType: "Entry"
3349
3352
  }), function (childrenProps) {
3350
- return React.createElement(SortableLinkList, Object.assign({}, childrenProps), function (props) {
3351
- var lastIndex = props.items.length - 1;
3352
- return React.createElement(FetchingWrappedEntryCard, Object.assign({}, props, {
3353
- key: props.item.sys.id + "-" + props.index,
3354
- index: props.index,
3353
+ return React.createElement(SortableLinkList, Object.assign({}, childrenProps, {
3354
+ axis: "y",
3355
+ useDragHandle: true
3356
+ }), function (_ref) {
3357
+ var items = _ref.items,
3358
+ item = _ref.item,
3359
+ index = _ref.index,
3360
+ isDisabled = _ref.isDisabled,
3361
+ DragHandle = _ref.DragHandle;
3362
+ var lastIndex = items.length - 1;
3363
+ return React.createElement(FetchingWrappedEntryCard, Object.assign({}, childrenProps, {
3364
+ key: item.sys.id + "-" + index,
3365
+ index: index,
3355
3366
  allContentTypes: childrenProps.allContentTypes,
3356
- isDisabled: props.isDisabled,
3357
- entryId: props.item.sys.id,
3367
+ isDisabled: isDisabled,
3368
+ entryId: item.sys.id,
3358
3369
  onRemove: function onRemove() {
3359
- childrenProps.setValue(props.items.filter(function (_value, i) {
3360
- return i !== props.index;
3370
+ childrenProps.setValue(items.filter(function (_value, i) {
3371
+ return i !== index;
3361
3372
  }));
3362
3373
  },
3363
- onMoveTop: props.index !== 0 ? function () {
3364
- return childrenProps.onMove(props.index, 0);
3374
+ onMoveTop: index !== 0 ? function () {
3375
+ return childrenProps.onMove(index, 0);
3365
3376
  } : undefined,
3366
- onMoveBottom: props.index !== lastIndex ? function () {
3367
- return childrenProps.onMove(props.index, lastIndex);
3377
+ onMoveBottom: index !== lastIndex ? function () {
3378
+ return childrenProps.onMove(index, lastIndex);
3368
3379
  } : undefined,
3369
- renderDragHandle: props.DragHandle
3380
+ renderDragHandle: DragHandle
3370
3381
  }));
3371
3382
  });
3372
3383
  });
@@ -3793,17 +3804,24 @@ function MultipleMediaEditor(props) {
3793
3804
 
3794
3805
  return React.createElement(SortableLinkList, Object.assign({}, childrenProps, {
3795
3806
  className: emotion.cx((_cx = {}, _cx[styles$6.gridContainer] = childrenProps.viewType === 'card', _cx)),
3796
- axis: childrenProps.viewType === 'card' ? 'xy' : 'y'
3797
- }), function (props) {
3798
- return React.createElement(FetchingWrappedAssetCard, Object.assign({}, props, {
3799
- key: props.item.sys.id + "-" + props.index,
3800
- assetId: props.item.sys.id,
3807
+ axis: childrenProps.viewType === 'card' ? 'xy' : 'y',
3808
+ useDragHandle: true
3809
+ }), function (_ref) {
3810
+ var items = _ref.items,
3811
+ item = _ref.item,
3812
+ index = _ref.index,
3813
+ isDisabled = _ref.isDisabled,
3814
+ DragHandle = _ref.DragHandle;
3815
+ return React.createElement(FetchingWrappedAssetCard, Object.assign({}, childrenProps, {
3816
+ isDisabled: isDisabled,
3817
+ key: item.sys.id + "-" + index,
3818
+ assetId: item.sys.id,
3801
3819
  onRemove: function onRemove() {
3802
- childrenProps.setValue(props.items.filter(function (_value, i) {
3803
- return i !== props.index;
3820
+ childrenProps.setValue(items.filter(function (_value, i) {
3821
+ return i !== index;
3804
3822
  }));
3805
3823
  },
3806
- renderDragHandle: props.DragHandle
3824
+ renderDragHandle: DragHandle
3807
3825
  }));
3808
3826
  });
3809
3827
  });