@contentful/field-editor-reference 4.5.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.
@@ -1,5 +1,5 @@
1
1
  import React__default, { useState, useRef, useEffect, createElement, Fragment, useMemo, useCallback, useReducer } from 'react';
2
- import { css } from 'emotion';
2
+ import { css, cx } from 'emotion';
3
3
  import tokens from '@contentful/f36-tokens';
4
4
  import get from 'lodash-es/get';
5
5
  import { Menu, TextInput, Button, Paragraph, Card, SectionHeading, IconButton, Tooltip, Flex, Text, EntryCard, MenuItem, MenuDivider, AssetCard } from '@contentful/f36-components';
@@ -3311,36 +3311,29 @@ var SortableLink = /*#__PURE__*/SortableElement(function (props) {
3311
3311
  className: styles$3.item
3312
3312
  }, props.children);
3313
3313
  });
3314
- var SortableLinkList = /*#__PURE__*/SortableContainer(function (props) {
3315
- var lastIndex = props.items.length - 1;
3314
+ var SortableLinkListInternal = /*#__PURE__*/SortableContainer(function (props) {
3316
3315
  return React__default.createElement("div", {
3317
- className: styles$3.container
3316
+ className: cx(styles$3.container, props.className)
3318
3317
  }, props.items.map(function (item, index) {
3318
+ var _item$sys$urn;
3319
+
3319
3320
  return React__default.createElement(SortableLink, {
3320
3321
  disabled: props.isDisabled,
3321
- key: item.sys.id + "-" + index,
3322
+ key: ((_item$sys$urn = item.sys.urn) != null ? _item$sys$urn : item.sys.id) + "-" + index,
3322
3323
  index: index
3323
- }, React__default.createElement(FetchingWrappedEntryCard, Object.assign({}, props, {
3324
- key: item.sys.id + "-" + index,
3325
- index: index,
3326
- allContentTypes: props.allContentTypes,
3324
+ }, props.children({
3325
+ items: props.items,
3327
3326
  isDisabled: props.isDisabled,
3328
- entryId: item.sys.id,
3329
- onRemove: function onRemove() {
3330
- props.setValue(props.items.filter(function (_value, i) {
3331
- return i !== index;
3332
- }));
3333
- },
3334
- onMoveTop: index !== 0 ? function () {
3335
- return props.onMove(index, 0);
3336
- } : undefined,
3337
- onMoveBottom: index !== lastIndex ? function () {
3338
- return props.onMove(index, lastIndex);
3339
- } : undefined,
3340
- renderDragHandle: props.isDisabled ? undefined : DragHandle
3341
- })));
3327
+ item: item,
3328
+ index: index,
3329
+ DragHandle: props.isDisabled ? undefined : DragHandle
3330
+ }));
3342
3331
  }));
3343
- });
3332
+ }); // HOC does not support generics, so we mimic it via additional component
3333
+
3334
+ function SortableLinkList(props) {
3335
+ return React__default.createElement(SortableLinkListInternal, Object.assign({}, props), props.children);
3336
+ }
3344
3337
 
3345
3338
  function MultipleEntryReferenceEditor(props) {
3346
3339
  return createElement(MultipleReferenceEditor, Object.assign({}, props, {
@@ -3349,7 +3342,33 @@ function MultipleEntryReferenceEditor(props) {
3349
3342
  return createElement(SortableLinkList, Object.assign({}, props, childrenProps, {
3350
3343
  axis: "y",
3351
3344
  useDragHandle: true
3352
- }));
3345
+ }), function (_ref) {
3346
+ var items = _ref.items,
3347
+ item = _ref.item,
3348
+ index = _ref.index,
3349
+ isDisabled = _ref.isDisabled,
3350
+ DragHandle = _ref.DragHandle;
3351
+ var lastIndex = items.length - 1;
3352
+ return createElement(FetchingWrappedEntryCard, Object.assign({}, props, {
3353
+ key: item.sys.id + "-" + index,
3354
+ index: index,
3355
+ allContentTypes: childrenProps.allContentTypes,
3356
+ isDisabled: isDisabled,
3357
+ entryId: item.sys.id,
3358
+ onRemove: function onRemove() {
3359
+ childrenProps.setValue(items.filter(function (_value, i) {
3360
+ return i !== index;
3361
+ }));
3362
+ },
3363
+ onMoveTop: index !== 0 ? function () {
3364
+ return childrenProps.onMove(index, 0);
3365
+ } : undefined,
3366
+ onMoveBottom: index !== lastIndex ? function () {
3367
+ return childrenProps.onMove(index, lastIndex);
3368
+ } : undefined,
3369
+ renderDragHandle: DragHandle
3370
+ }));
3371
+ });
3353
3372
  });
3354
3373
  }
3355
3374
 
@@ -3760,67 +3779,45 @@ SingleMediaEditor.defaultProps = {
3760
3779
  };
3761
3780
 
3762
3781
  var styles$6 = {
3763
- gridContainter: /*#__PURE__*/css({
3782
+ gridContainer: /*#__PURE__*/css({
3764
3783
  position: 'relative',
3765
3784
  display: 'flex',
3766
3785
  flexWrap: 'wrap'
3767
- }),
3768
- container: /*#__PURE__*/css({
3769
- position: 'relative'
3770
- }),
3771
- item: /*#__PURE__*/css({
3772
- marginBottom: tokens.spacingM,
3773
- marginRight: tokens.spacingM
3774
3786
  })
3775
3787
  };
3776
-
3777
- var DragHandle$1 = function DragHandle(props) {
3778
- var SortableDragHandle = SortableHandle(function () {
3779
- return props.drag;
3780
- });
3781
- return React__default.createElement(SortableDragHandle, null);
3782
- };
3783
-
3784
- var SortableLink$1 = /*#__PURE__*/SortableElement(function (props) {
3785
- return React__default.createElement("div", {
3786
- className: styles$6.item
3787
- }, props.children);
3788
- });
3789
- var SortableLinkList$1 = /*#__PURE__*/SortableContainer(function (props) {
3790
- return React__default.createElement("div", {
3791
- className: props.viewType === 'card' ? styles$6.gridContainter : styles$6.container
3792
- }, props.items.map(function (item, index) {
3793
- return React__default.createElement(SortableLink$1, {
3794
- disabled: props.isDisabled,
3795
- key: item.sys.id + "-" + index,
3796
- index: index
3797
- }, React__default.createElement(FetchingWrappedAssetCard, Object.assign({}, props, {
3798
- sdk: props.sdk,
3799
- key: item.sys.id + "-" + index,
3800
- assetId: item.sys.id,
3801
- onRemove: function onRemove() {
3802
- props.setValue(props.items.filter(function (_value, i) {
3803
- return i !== index;
3804
- }));
3805
- },
3806
- renderDragHandle: props.isDisabled ? undefined : DragHandle$1
3807
- })));
3808
- }));
3809
- });
3810
-
3811
3788
  function MultipleMediaEditor(props) {
3812
3789
  return createElement(MultipleReferenceEditor, Object.assign({}, props, {
3813
3790
  entityType: "Asset"
3814
3791
  }), function (childrenProps) {
3815
- return createElement(SortableLinkList$1, Object.assign({}, props, childrenProps, {
3816
- axis: props.viewType === 'card' ? 'xy' : 'y',
3792
+ var _cx;
3793
+
3794
+ return createElement(SortableLinkList, Object.assign({}, childrenProps, {
3795
+ className: cx((_cx = {}, _cx[styles$6.gridContainer] = childrenProps.viewType === 'card', _cx)),
3796
+ axis: childrenProps.viewType === 'card' ? 'xy' : 'y',
3817
3797
  useDragHandle: true
3818
- }));
3798
+ }), function (_ref) {
3799
+ var items = _ref.items,
3800
+ item = _ref.item,
3801
+ index = _ref.index,
3802
+ isDisabled = _ref.isDisabled,
3803
+ DragHandle = _ref.DragHandle;
3804
+ return createElement(FetchingWrappedAssetCard, Object.assign({}, props, {
3805
+ isDisabled: isDisabled,
3806
+ key: item.sys.id + "-" + index,
3807
+ assetId: item.sys.id,
3808
+ onRemove: function onRemove() {
3809
+ childrenProps.setValue(items.filter(function (_value, i) {
3810
+ return i !== index;
3811
+ }));
3812
+ },
3813
+ renderDragHandle: DragHandle
3814
+ }));
3815
+ });
3819
3816
  });
3820
3817
  }
3821
3818
  MultipleMediaEditor.defaultProps = {
3822
3819
  isInitiallyDisabled: true
3823
3820
  };
3824
3821
 
3825
- export { AssetThumbnail, CombinedLinkActions, CreateEntryLinkButton, CreateEntryMenuTrigger, EntityProvider, MissingEntityCard, MultipleEntryReferenceEditor, MultipleMediaEditor, ScheduledIconWithTooltip, SingleEntryReferenceEditor, SingleMediaEditor, WrappedAssetCard, WrappedEntryCard, getScheduleTooltipContent, useEntities };
3822
+ export { AssetThumbnail, CombinedLinkActions, CreateEntryLinkButton, CreateEntryMenuTrigger, EntityProvider, MissingEntityCard, MultipleEntryReferenceEditor, MultipleMediaEditor, ScheduledIconWithTooltip, SingleEntryReferenceEditor, SingleMediaEditor, SortableLinkList, WrappedAssetCard, WrappedEntryCard, getScheduleTooltipContent, useEntities };
3826
3823
  //# sourceMappingURL=field-editor-reference.esm.js.map