@contentful/field-editor-reference 4.5.0 → 4.5.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 +6 -0
- package/dist/common/SortableLinkList.d.ts +19 -0
- package/dist/field-editor-reference.cjs.development.js +58 -74
- 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 +59 -76
- package/dist/field-editor-reference.esm.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/package.json +2 -2
- package/dist/assets/SortableElements.d.ts +0 -8
- package/dist/entries/SortableElements.d.ts +0 -10
|
@@ -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';
|
|
@@ -3295,7 +3295,8 @@ var styles$3 = {
|
|
|
3295
3295
|
position: 'relative'
|
|
3296
3296
|
}),
|
|
3297
3297
|
item: /*#__PURE__*/css({
|
|
3298
|
-
marginBottom: tokens.spacingM
|
|
3298
|
+
marginBottom: tokens.spacingM,
|
|
3299
|
+
marginRight: tokens.spacingM
|
|
3299
3300
|
})
|
|
3300
3301
|
};
|
|
3301
3302
|
|
|
@@ -3311,45 +3312,56 @@ var SortableLink = /*#__PURE__*/SortableElement(function (props) {
|
|
|
3311
3312
|
className: styles$3.item
|
|
3312
3313
|
}, props.children);
|
|
3313
3314
|
});
|
|
3314
|
-
var
|
|
3315
|
-
var lastIndex = props.items.length - 1;
|
|
3315
|
+
var SortableLinkListInternal = /*#__PURE__*/SortableContainer(function (props) {
|
|
3316
3316
|
return React__default.createElement("div", {
|
|
3317
|
-
className: styles$3.container
|
|
3317
|
+
className: cx(styles$3.container, props.className)
|
|
3318
3318
|
}, props.items.map(function (item, index) {
|
|
3319
|
+
var _item$sys$id;
|
|
3320
|
+
|
|
3319
3321
|
return React__default.createElement(SortableLink, {
|
|
3320
3322
|
disabled: props.isDisabled,
|
|
3321
|
-
key: item.sys.id + "-" + index,
|
|
3323
|
+
key: ((_item$sys$id = item.sys.id) != null ? _item$sys$id : item.sys.urn) + "-" + index,
|
|
3322
3324
|
index: index
|
|
3323
|
-
},
|
|
3324
|
-
|
|
3325
|
+
}, props.children(_extends({}, props, {
|
|
3326
|
+
item: item,
|
|
3325
3327
|
index: index,
|
|
3326
|
-
|
|
3327
|
-
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
|
|
3328
|
+
DragHandle: props.isDisabled ? undefined : DragHandle
|
|
3341
3329
|
})));
|
|
3342
3330
|
}));
|
|
3343
|
-
});
|
|
3331
|
+
}); // HOC does not support generics, so we mimic it via additional component
|
|
3332
|
+
|
|
3333
|
+
function SortableLinkList(props) {
|
|
3334
|
+
return React__default.createElement(SortableLinkListInternal, Object.assign({}, props, {
|
|
3335
|
+
children: props.children
|
|
3336
|
+
}));
|
|
3337
|
+
}
|
|
3344
3338
|
|
|
3345
3339
|
function MultipleEntryReferenceEditor(props) {
|
|
3346
3340
|
return createElement(MultipleReferenceEditor, Object.assign({}, props, {
|
|
3347
3341
|
entityType: "Entry"
|
|
3348
3342
|
}), function (childrenProps) {
|
|
3349
|
-
return createElement(SortableLinkList, Object.assign({},
|
|
3350
|
-
|
|
3351
|
-
|
|
3352
|
-
|
|
3343
|
+
return createElement(SortableLinkList, Object.assign({}, childrenProps), function (props) {
|
|
3344
|
+
var lastIndex = props.items.length - 1;
|
|
3345
|
+
return createElement(FetchingWrappedEntryCard, Object.assign({}, props, {
|
|
3346
|
+
key: props.item.sys.id + "-" + props.index,
|
|
3347
|
+
index: props.index,
|
|
3348
|
+
allContentTypes: childrenProps.allContentTypes,
|
|
3349
|
+
isDisabled: props.isDisabled,
|
|
3350
|
+
entryId: props.item.sys.id,
|
|
3351
|
+
onRemove: function onRemove() {
|
|
3352
|
+
childrenProps.setValue(props.items.filter(function (_value, i) {
|
|
3353
|
+
return i !== props.index;
|
|
3354
|
+
}));
|
|
3355
|
+
},
|
|
3356
|
+
onMoveTop: props.index !== 0 ? function () {
|
|
3357
|
+
return childrenProps.onMove(props.index, 0);
|
|
3358
|
+
} : undefined,
|
|
3359
|
+
onMoveBottom: props.index !== lastIndex ? function () {
|
|
3360
|
+
return childrenProps.onMove(props.index, lastIndex);
|
|
3361
|
+
} : undefined,
|
|
3362
|
+
renderDragHandle: props.DragHandle
|
|
3363
|
+
}));
|
|
3364
|
+
});
|
|
3353
3365
|
});
|
|
3354
3366
|
}
|
|
3355
3367
|
|
|
@@ -3760,67 +3772,38 @@ SingleMediaEditor.defaultProps = {
|
|
|
3760
3772
|
};
|
|
3761
3773
|
|
|
3762
3774
|
var styles$6 = {
|
|
3763
|
-
|
|
3775
|
+
gridContainer: /*#__PURE__*/css({
|
|
3764
3776
|
position: 'relative',
|
|
3765
3777
|
display: 'flex',
|
|
3766
3778
|
flexWrap: 'wrap'
|
|
3767
|
-
}),
|
|
3768
|
-
container: /*#__PURE__*/css({
|
|
3769
|
-
position: 'relative'
|
|
3770
|
-
}),
|
|
3771
|
-
item: /*#__PURE__*/css({
|
|
3772
|
-
marginBottom: tokens.spacingM,
|
|
3773
|
-
marginRight: tokens.spacingM
|
|
3774
3779
|
})
|
|
3775
3780
|
};
|
|
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
3781
|
function MultipleMediaEditor(props) {
|
|
3812
3782
|
return createElement(MultipleReferenceEditor, Object.assign({}, props, {
|
|
3813
3783
|
entityType: "Asset"
|
|
3814
3784
|
}), function (childrenProps) {
|
|
3815
|
-
|
|
3816
|
-
|
|
3817
|
-
|
|
3818
|
-
|
|
3785
|
+
var _cx;
|
|
3786
|
+
|
|
3787
|
+
return createElement(SortableLinkList, Object.assign({}, childrenProps, {
|
|
3788
|
+
className: cx((_cx = {}, _cx[styles$6.gridContainer] = childrenProps.viewType === 'card', _cx)),
|
|
3789
|
+
axis: childrenProps.viewType === 'card' ? 'xy' : 'y'
|
|
3790
|
+
}), function (props) {
|
|
3791
|
+
return createElement(FetchingWrappedAssetCard, Object.assign({}, props, {
|
|
3792
|
+
key: props.item.sys.id + "-" + props.index,
|
|
3793
|
+
assetId: props.item.sys.id,
|
|
3794
|
+
onRemove: function onRemove() {
|
|
3795
|
+
childrenProps.setValue(props.items.filter(function (_value, i) {
|
|
3796
|
+
return i !== props.index;
|
|
3797
|
+
}));
|
|
3798
|
+
},
|
|
3799
|
+
renderDragHandle: props.DragHandle
|
|
3800
|
+
}));
|
|
3801
|
+
});
|
|
3819
3802
|
});
|
|
3820
3803
|
}
|
|
3821
3804
|
MultipleMediaEditor.defaultProps = {
|
|
3822
3805
|
isInitiallyDisabled: true
|
|
3823
3806
|
};
|
|
3824
3807
|
|
|
3825
|
-
export { AssetThumbnail, CombinedLinkActions, CreateEntryLinkButton, CreateEntryMenuTrigger, EntityProvider, MissingEntityCard, MultipleEntryReferenceEditor, MultipleMediaEditor, ScheduledIconWithTooltip, SingleEntryReferenceEditor, SingleMediaEditor, WrappedAssetCard, WrappedEntryCard, getScheduleTooltipContent, useEntities };
|
|
3808
|
+
export { AssetThumbnail, CombinedLinkActions, CreateEntryLinkButton, CreateEntryMenuTrigger, EntityProvider, MissingEntityCard, MultipleEntryReferenceEditor, MultipleMediaEditor, ScheduledIconWithTooltip, SingleEntryReferenceEditor, SingleMediaEditor, SortableLinkList, WrappedAssetCard, WrappedEntryCard, getScheduleTooltipContent, useEntities };
|
|
3826
3809
|
//# sourceMappingURL=field-editor-reference.esm.js.map
|