@contentful/field-editor-reference 5.21.4 → 5.21.5
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/dist/cjs/__fixtures__/FakeSdk.js +3 -3
- package/dist/cjs/__fixtures__/asset/index.js +5 -5
- package/dist/cjs/__fixtures__/entry/index.js +3 -3
- package/dist/cjs/__fixtures__/fixtures.js +3 -1
- package/dist/cjs/assets/MultipleMediaEditor.js +4 -2
- package/dist/cjs/assets/SingleMediaEditor.js +4 -2
- package/dist/cjs/assets/WrappedAssetCard/AssetCardActions.js +8 -6
- package/dist/cjs/assets/WrappedAssetCard/FetchingWrappedAssetCard.js +8 -6
- package/dist/cjs/assets/WrappedAssetCard/WrappedAssetCard.js +4 -2
- package/dist/cjs/assets/WrappedAssetCard/WrappedAssetLink.js +4 -2
- package/dist/cjs/assets/index.js +3 -3
- package/dist/cjs/common/EntityStore.js +29 -27
- package/dist/cjs/common/MultipleReferenceEditor.js +7 -5
- package/dist/cjs/common/ReferenceEditor.js +3 -1
- package/dist/cjs/common/SingleReferenceEditor.js +5 -3
- package/dist/cjs/common/SortableLinkList.js +5 -5
- package/dist/cjs/common/customCardTypes.js +3 -1
- package/dist/cjs/common/queryClient.js +8 -6
- package/dist/cjs/common/useContentTypePermissions.js +1 -1
- package/dist/cjs/common/useEditorPermissions.js +3 -3
- package/dist/cjs/common/useEditorPermissions.spec.js +11 -11
- package/dist/cjs/components/AssetThumbnail/AssetThumbnail.js +3 -1
- package/dist/cjs/components/CreateEntryLinkButton/CreateEntryLinkButton.js +5 -3
- package/dist/cjs/components/CreateEntryLinkButton/CreateEntryLinkButton.spec.js +15 -13
- package/dist/cjs/components/CreateEntryLinkButton/CreateEntryMenuTrigger.js +5 -3
- package/dist/cjs/components/CreateEntryLinkButton/CreateEntryMenuTrigger.spec.js +8 -6
- package/dist/cjs/components/LinkActions/CombinedLinkActions.js +3 -1
- package/dist/cjs/components/LinkActions/LinkActions.js +6 -4
- package/dist/cjs/components/LinkActions/LinkEntityActions.js +11 -9
- package/dist/cjs/components/LinkActions/NoLinkPermissionsInfo.js +3 -1
- package/dist/cjs/components/LinkActions/helpers.js +5 -5
- package/dist/cjs/components/LinkActions/redesignStyles.js +3 -3
- package/dist/cjs/components/MissingEntityCard/MissingEntityCard.js +3 -1
- package/dist/cjs/components/ResourceEntityErrorCard/ResourceEntityErrorCard.js +3 -1
- package/dist/cjs/components/ResourceEntityErrorCard/UnsupportedEntityCard.js +3 -1
- package/dist/cjs/components/ScheduledIconWithTooltip/ScheduleTooltip.js +8 -6
- package/dist/cjs/components/ScheduledIconWithTooltip/ScheduledIconWithTooltip.js +4 -2
- package/dist/cjs/components/ScheduledIconWithTooltip/formatDateAndTime.js +3 -3
- package/dist/cjs/components/SpaceName/SpaceName.js +3 -1
- package/dist/cjs/components/index.js +12 -12
- package/dist/cjs/entries/MultipleEntryReferenceEditor.js +5 -3
- package/dist/cjs/entries/SingleEntryReferenceEditor.js +4 -2
- package/dist/cjs/entries/WrappedEntryCard/FetchingWrappedEntryCard.js +8 -6
- package/dist/cjs/entries/WrappedEntryCard/WrappedEntryCard.js +5 -3
- package/dist/cjs/entries/index.js +3 -3
- package/dist/cjs/index.js +37 -37
- package/dist/cjs/resources/Cards/ContentfulEntryCard.js +4 -2
- package/dist/cjs/resources/Cards/ResourceCard.js +6 -4
- package/dist/cjs/resources/Cards/ResourceCard.spec.js +12 -10
- package/dist/cjs/resources/MultipleResourceReferenceEditor.js +10 -8
- package/dist/cjs/resources/MultipleResourceReferenceEditor.spec.js +7 -5
- package/dist/cjs/resources/SingleResourceReferenceEditor.js +5 -3
- package/dist/cjs/resources/SingleResourceReferenceEditor.spec.js +3 -1
- package/dist/cjs/resources/testHelpers/resourceEditorHelpers.js +5 -5
- package/dist/cjs/resources/useResourceLinkActions.js +1 -1
- package/dist/cjs/types.js +3 -3
- package/dist/cjs/utils/useSortIDs.js +5 -3
- package/dist/esm/__fixtures__/FakeSdk.js +3 -3
- package/dist/esm/assets/MultipleMediaEditor.js +1 -1
- package/dist/esm/assets/SingleMediaEditor.js +1 -1
- package/dist/esm/assets/WrappedAssetCard/AssetCardActions.js +2 -2
- package/dist/esm/assets/WrappedAssetCard/FetchingWrappedAssetCard.js +5 -5
- package/dist/esm/assets/WrappedAssetCard/WrappedAssetCard.js +1 -1
- package/dist/esm/assets/WrappedAssetCard/WrappedAssetLink.js +1 -1
- package/dist/esm/common/EntityStore.js +20 -20
- package/dist/esm/common/MultipleReferenceEditor.js +4 -4
- package/dist/esm/common/SingleReferenceEditor.js +2 -2
- package/dist/esm/common/SortableLinkList.js +5 -5
- package/dist/esm/common/queryClient.js +1 -1
- package/dist/esm/common/useContentTypePermissions.js +1 -1
- package/dist/esm/common/useEditorPermissions.js +3 -3
- package/dist/esm/common/useEditorPermissions.spec.js +11 -11
- package/dist/esm/components/CreateEntryLinkButton/CreateEntryLinkButton.js +2 -2
- package/dist/esm/components/CreateEntryLinkButton/CreateEntryLinkButton.spec.js +12 -12
- package/dist/esm/components/CreateEntryLinkButton/CreateEntryMenuTrigger.js +2 -2
- package/dist/esm/components/CreateEntryLinkButton/CreateEntryMenuTrigger.spec.js +5 -5
- package/dist/esm/components/LinkActions/LinkEntityActions.js +4 -4
- package/dist/esm/components/LinkActions/helpers.js +2 -2
- package/dist/esm/components/ScheduledIconWithTooltip/ScheduleTooltip.js +2 -2
- package/dist/esm/components/ScheduledIconWithTooltip/ScheduledIconWithTooltip.js +1 -1
- package/dist/esm/entries/MultipleEntryReferenceEditor.js +2 -2
- package/dist/esm/entries/SingleEntryReferenceEditor.js +1 -1
- package/dist/esm/entries/WrappedEntryCard/FetchingWrappedEntryCard.js +5 -5
- package/dist/esm/entries/WrappedEntryCard/WrappedEntryCard.js +2 -2
- package/dist/esm/resources/Cards/ContentfulEntryCard.js +1 -1
- package/dist/esm/resources/Cards/ResourceCard.js +3 -3
- package/dist/esm/resources/Cards/ResourceCard.spec.js +9 -9
- package/dist/esm/resources/MultipleResourceReferenceEditor.js +7 -7
- package/dist/esm/resources/MultipleResourceReferenceEditor.spec.js +4 -4
- package/dist/esm/resources/SingleResourceReferenceEditor.js +2 -2
- package/dist/esm/resources/testHelpers/resourceEditorHelpers.js +2 -2
- package/dist/esm/resources/useResourceLinkActions.js +1 -1
- package/dist/esm/utils/useSortIDs.js +2 -2
- package/package.json +3 -3
|
@@ -9,32 +9,32 @@ function _export(target, all) {
|
|
|
9
9
|
});
|
|
10
10
|
}
|
|
11
11
|
_export(exports, {
|
|
12
|
+
AssetThumbnail: function() {
|
|
13
|
+
return _AssetThumbnail.AssetThumbnail;
|
|
14
|
+
},
|
|
12
15
|
CombinedLinkActions: function() {
|
|
13
16
|
return _CombinedLinkActions.CombinedLinkActions;
|
|
14
17
|
},
|
|
15
|
-
MissingEntityCard: function() {
|
|
16
|
-
return _MissingEntityCard.MissingEntityCard;
|
|
17
|
-
},
|
|
18
|
-
LinkEntityActions: function() {
|
|
19
|
-
return _LinkEntityActions.LinkEntityActions;
|
|
20
|
-
},
|
|
21
18
|
CreateEntryLinkButton: function() {
|
|
22
19
|
return _CreateEntryLinkButton.CreateEntryLinkButton;
|
|
23
20
|
},
|
|
24
21
|
CreateEntryMenuTrigger: function() {
|
|
25
22
|
return _CreateEntryMenuTrigger.CreateEntryMenuTrigger;
|
|
26
23
|
},
|
|
24
|
+
LinkEntityActions: function() {
|
|
25
|
+
return _LinkEntityActions.LinkEntityActions;
|
|
26
|
+
},
|
|
27
|
+
MissingEntityCard: function() {
|
|
28
|
+
return _MissingEntityCard.MissingEntityCard;
|
|
29
|
+
},
|
|
30
|
+
ResourceEntityErrorCard: function() {
|
|
31
|
+
return _ResourceEntityErrorCard.ResourceEntityErrorCard;
|
|
32
|
+
},
|
|
27
33
|
ScheduledIconWithTooltip: function() {
|
|
28
34
|
return _ScheduledIconWithTooltip.ScheduledIconWithTooltip;
|
|
29
35
|
},
|
|
30
36
|
getScheduleTooltipContent: function() {
|
|
31
37
|
return _ScheduleTooltip.getScheduleTooltipContent;
|
|
32
|
-
},
|
|
33
|
-
AssetThumbnail: function() {
|
|
34
|
-
return _AssetThumbnail.AssetThumbnail;
|
|
35
|
-
},
|
|
36
|
-
ResourceEntityErrorCard: function() {
|
|
37
|
-
return _ResourceEntityErrorCard.ResourceEntityErrorCard;
|
|
38
38
|
}
|
|
39
39
|
});
|
|
40
40
|
const _CombinedLinkActions = require("./LinkActions/CombinedLinkActions");
|
|
@@ -34,7 +34,9 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
|
34
34
|
if (cache && cache.has(obj)) {
|
|
35
35
|
return cache.get(obj);
|
|
36
36
|
}
|
|
37
|
-
var newObj = {
|
|
37
|
+
var newObj = {
|
|
38
|
+
__proto__: null
|
|
39
|
+
};
|
|
38
40
|
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
39
41
|
for(var key in obj){
|
|
40
42
|
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
@@ -54,7 +56,7 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
|
54
56
|
}
|
|
55
57
|
function MultipleEntryReferenceEditor(props) {
|
|
56
58
|
const [indexToUpdate, setIndexToUpdate] = _react.useState(undefined);
|
|
57
|
-
const updateBeforeSortStart = ({ index
|
|
59
|
+
const updateBeforeSortStart = ({ index })=>{
|
|
58
60
|
setIndexToUpdate(index);
|
|
59
61
|
};
|
|
60
62
|
return _react.createElement(_MultipleReferenceEditor.MultipleReferenceEditor, {
|
|
@@ -65,7 +67,7 @@ function MultipleEntryReferenceEditor(props) {
|
|
|
65
67
|
...childrenProps,
|
|
66
68
|
sortingStrategy: _sortable.verticalListSortingStrategy,
|
|
67
69
|
updateBeforeSortStart: updateBeforeSortStart
|
|
68
|
-
}, ({ items
|
|
70
|
+
}, ({ items, item, index, isDisabled, DragHandle })=>{
|
|
69
71
|
const lastIndex = items.length - 1;
|
|
70
72
|
return _react.createElement(_FetchingWrappedEntryCard.FetchingWrappedEntryCard, {
|
|
71
73
|
...childrenProps,
|
|
@@ -32,7 +32,9 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
|
32
32
|
if (cache && cache.has(obj)) {
|
|
33
33
|
return cache.get(obj);
|
|
34
34
|
}
|
|
35
|
-
var newObj = {
|
|
35
|
+
var newObj = {
|
|
36
|
+
__proto__: null
|
|
37
|
+
};
|
|
36
38
|
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
37
39
|
for(var key in obj){
|
|
38
40
|
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
@@ -54,7 +56,7 @@ function SingleEntryReferenceEditor(props) {
|
|
|
54
56
|
return _react.createElement(_SingleReferenceEditor.SingleReferenceEditor, {
|
|
55
57
|
...props,
|
|
56
58
|
entityType: "Entry"
|
|
57
|
-
}, ({ allContentTypes
|
|
59
|
+
}, ({ allContentTypes, isDisabled, entityId, setValue, renderCustomCard, hasCardRemoveActions, hasCardEditActions })=>{
|
|
58
60
|
return _react.createElement(_FetchingWrappedEntryCard.FetchingWrappedEntryCard, {
|
|
59
61
|
...props,
|
|
60
62
|
allContentTypes: allContentTypes,
|
|
@@ -40,7 +40,9 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
|
40
40
|
if (cache && cache.has(obj)) {
|
|
41
41
|
return cache.get(obj);
|
|
42
42
|
}
|
|
43
|
-
var newObj = {
|
|
43
|
+
var newObj = {
|
|
44
|
+
__proto__: null
|
|
45
|
+
};
|
|
44
46
|
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
45
47
|
for(var key in obj){
|
|
46
48
|
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
@@ -78,14 +80,14 @@ async function openEntry(sdk, entryId, options) {
|
|
|
78
80
|
return slide;
|
|
79
81
|
}
|
|
80
82
|
function FetchingWrappedEntryCard(props) {
|
|
81
|
-
const { data: entry
|
|
82
|
-
const { getEntityScheduledActions
|
|
83
|
+
const { data: entry, status } = (0, _EntityStore.useEntity)('Entry', props.entryId);
|
|
84
|
+
const { getEntityScheduledActions } = (0, _EntityStore.useEntityLoader)();
|
|
83
85
|
const loadEntityScheduledActions = _react.useCallback(()=>getEntityScheduledActions('Entry', props.entryId), [
|
|
84
86
|
getEntityScheduledActions,
|
|
85
87
|
props.entryId
|
|
86
88
|
]);
|
|
87
89
|
const size = props.viewType === 'link' ? 'small' : 'default';
|
|
88
|
-
const { getEntity
|
|
90
|
+
const { getEntity } = (0, _EntityStore.useEntityLoader)();
|
|
89
91
|
const getAsset = (assetId)=>getEntity('Asset', assetId);
|
|
90
92
|
const onEdit = async ()=>{
|
|
91
93
|
const slide = await openEntry(props.sdk, props.entryId, {
|
|
@@ -159,7 +161,7 @@ function FetchingWrappedEntryCard(props) {
|
|
|
159
161
|
onMoveBottom: props.onMoveBottom,
|
|
160
162
|
isBeingDragged: props.isBeingDragged
|
|
161
163
|
};
|
|
162
|
-
const { hasCardEditActions
|
|
164
|
+
const { hasCardEditActions, hasCardMoveActions, hasCardRemoveActions } = props;
|
|
163
165
|
function renderDefaultCard(props) {
|
|
164
166
|
const builtinCardProps = {
|
|
165
167
|
...sharedCardProps,
|
|
@@ -169,7 +171,7 @@ function FetchingWrappedEntryCard(props) {
|
|
|
169
171
|
hasCardRemoveActions,
|
|
170
172
|
getAsset,
|
|
171
173
|
getEntityScheduledActions: loadEntityScheduledActions,
|
|
172
|
-
entry:
|
|
174
|
+
entry: props?.entity || sharedCardProps.entity,
|
|
173
175
|
entryUrl: props?.entityUrl || sharedCardProps.entityUrl
|
|
174
176
|
};
|
|
175
177
|
return _react.createElement(_WrappedEntryCard.WrappedEntryCard, builtinCardProps);
|
|
@@ -42,7 +42,9 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
|
42
42
|
if (cache && cache.has(obj)) {
|
|
43
43
|
return cache.get(obj);
|
|
44
44
|
}
|
|
45
|
-
var newObj = {
|
|
45
|
+
var newObj = {
|
|
46
|
+
__proto__: null
|
|
47
|
+
};
|
|
46
48
|
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
47
49
|
for(var key in obj){
|
|
48
50
|
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
@@ -60,7 +62,7 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
|
60
62
|
}
|
|
61
63
|
return newObj;
|
|
62
64
|
}
|
|
63
|
-
const { getEntryTitle
|
|
65
|
+
const { getEntryTitle, getEntityDescription, getEntryStatus, getEntryImage } = _fieldeditorshared.entityHelpers;
|
|
64
66
|
const styles = {
|
|
65
67
|
scheduleIcon: (0, _emotion.css)({
|
|
66
68
|
marginRight: _f36tokens.default.spacing2Xs
|
|
@@ -74,7 +76,7 @@ const defaultProps = {
|
|
|
74
76
|
};
|
|
75
77
|
function WrappedEntryCard(props) {
|
|
76
78
|
const [file, setFile] = _react.useState(null);
|
|
77
|
-
const { contentType
|
|
79
|
+
const { contentType } = props;
|
|
78
80
|
_react.useEffect(()=>{
|
|
79
81
|
if (props.entry) {
|
|
80
82
|
getEntryImage({
|
|
@@ -9,12 +9,12 @@ function _export(target, all) {
|
|
|
9
9
|
});
|
|
10
10
|
}
|
|
11
11
|
_export(exports, {
|
|
12
|
-
SingleEntryReferenceEditor: function() {
|
|
13
|
-
return _SingleEntryReferenceEditor.SingleEntryReferenceEditor;
|
|
14
|
-
},
|
|
15
12
|
MultipleEntryReferenceEditor: function() {
|
|
16
13
|
return _MultipleEntryReferenceEditor.MultipleEntryReferenceEditor;
|
|
17
14
|
},
|
|
15
|
+
SingleEntryReferenceEditor: function() {
|
|
16
|
+
return _SingleEntryReferenceEditor.SingleEntryReferenceEditor;
|
|
17
|
+
},
|
|
18
18
|
WrappedEntryCard: function() {
|
|
19
19
|
return _WrappedEntryCard.WrappedEntryCard;
|
|
20
20
|
}
|
package/dist/cjs/index.js
CHANGED
|
@@ -9,71 +9,71 @@ function _export(target, all) {
|
|
|
9
9
|
});
|
|
10
10
|
}
|
|
11
11
|
_export(exports, {
|
|
12
|
-
|
|
13
|
-
return _components.
|
|
12
|
+
AssetThumbnail: function() {
|
|
13
|
+
return _components.AssetThumbnail;
|
|
14
|
+
},
|
|
15
|
+
CombinedLinkActions: function() {
|
|
16
|
+
return _components.CombinedLinkActions;
|
|
14
17
|
},
|
|
15
18
|
CreateEntryLinkButton: function() {
|
|
16
19
|
return _components.CreateEntryLinkButton;
|
|
17
20
|
},
|
|
18
|
-
|
|
19
|
-
return _components.
|
|
20
|
-
},
|
|
21
|
-
ScheduledIconWithTooltip: function() {
|
|
22
|
-
return _components.ScheduledIconWithTooltip;
|
|
21
|
+
CreateEntryMenuTrigger: function() {
|
|
22
|
+
return _components.CreateEntryMenuTrigger;
|
|
23
23
|
},
|
|
24
|
-
|
|
25
|
-
return
|
|
24
|
+
EntityCacheProvider: function() {
|
|
25
|
+
return _queryClient.SharedQueryClientProvider;
|
|
26
26
|
},
|
|
27
|
-
|
|
28
|
-
return
|
|
27
|
+
EntityProvider: function() {
|
|
28
|
+
return _EntityStore.EntityProvider;
|
|
29
29
|
},
|
|
30
30
|
MissingEntityCard: function() {
|
|
31
31
|
return _components.MissingEntityCard;
|
|
32
32
|
},
|
|
33
|
-
CombinedLinkActions: function() {
|
|
34
|
-
return _components.CombinedLinkActions;
|
|
35
|
-
},
|
|
36
|
-
SingleEntryReferenceEditor: function() {
|
|
37
|
-
return _entries.SingleEntryReferenceEditor;
|
|
38
|
-
},
|
|
39
33
|
MultipleEntryReferenceEditor: function() {
|
|
40
34
|
return _entries.MultipleEntryReferenceEditor;
|
|
41
35
|
},
|
|
42
|
-
|
|
43
|
-
return
|
|
36
|
+
MultipleMediaEditor: function() {
|
|
37
|
+
return _assets.MultipleMediaEditor;
|
|
38
|
+
},
|
|
39
|
+
MultipleResourceReferenceEditor: function() {
|
|
40
|
+
return _resources.MultipleResourceReferenceEditor;
|
|
41
|
+
},
|
|
42
|
+
ResourceEntityErrorCard: function() {
|
|
43
|
+
return _components.ResourceEntityErrorCard;
|
|
44
|
+
},
|
|
45
|
+
ScheduledIconWithTooltip: function() {
|
|
46
|
+
return _components.ScheduledIconWithTooltip;
|
|
47
|
+
},
|
|
48
|
+
SingleEntryReferenceEditor: function() {
|
|
49
|
+
return _entries.SingleEntryReferenceEditor;
|
|
44
50
|
},
|
|
45
51
|
SingleMediaEditor: function() {
|
|
46
52
|
return _assets.SingleMediaEditor;
|
|
47
53
|
},
|
|
48
|
-
|
|
49
|
-
return
|
|
50
|
-
},
|
|
51
|
-
WrappedAssetCard: function() {
|
|
52
|
-
return _assets.WrappedAssetCard;
|
|
54
|
+
SingleResourceReferenceEditor: function() {
|
|
55
|
+
return _resources.SingleResourceReferenceEditor;
|
|
53
56
|
},
|
|
54
57
|
SortableLinkList: function() {
|
|
55
58
|
return _SortableLinkList.SortableLinkList;
|
|
56
59
|
},
|
|
57
|
-
|
|
58
|
-
return
|
|
60
|
+
WrappedAssetCard: function() {
|
|
61
|
+
return _assets.WrappedAssetCard;
|
|
59
62
|
},
|
|
60
|
-
|
|
61
|
-
return
|
|
63
|
+
WrappedEntryCard: function() {
|
|
64
|
+
return _entries.WrappedEntryCard;
|
|
65
|
+
},
|
|
66
|
+
getScheduleTooltipContent: function() {
|
|
67
|
+
return _components.getScheduleTooltipContent;
|
|
62
68
|
},
|
|
63
69
|
useEntity: function() {
|
|
64
70
|
return _EntityStore.useEntity;
|
|
65
71
|
},
|
|
72
|
+
useEntityLoader: function() {
|
|
73
|
+
return _EntityStore.useEntityLoader;
|
|
74
|
+
},
|
|
66
75
|
useResource: function() {
|
|
67
76
|
return _EntityStore.useResource;
|
|
68
|
-
},
|
|
69
|
-
EntityCacheProvider: function() {
|
|
70
|
-
return _queryClient.SharedQueryClientProvider;
|
|
71
|
-
},
|
|
72
|
-
SingleResourceReferenceEditor: function() {
|
|
73
|
-
return _resources.SingleResourceReferenceEditor;
|
|
74
|
-
},
|
|
75
|
-
MultipleResourceReferenceEditor: function() {
|
|
76
|
-
return _resources.MultipleResourceReferenceEditor;
|
|
77
77
|
}
|
|
78
78
|
});
|
|
79
79
|
const _components = require("./components");
|
|
@@ -31,7 +31,9 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
|
31
31
|
if (cache && cache.has(obj)) {
|
|
32
32
|
return cache.get(obj);
|
|
33
33
|
}
|
|
34
|
-
var newObj = {
|
|
34
|
+
var newObj = {
|
|
35
|
+
__proto__: null
|
|
36
|
+
};
|
|
35
37
|
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
36
38
|
for(var key in obj){
|
|
37
39
|
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
@@ -51,7 +53,7 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
|
51
53
|
}
|
|
52
54
|
const resolveAsset = ()=>Promise.resolve();
|
|
53
55
|
const resolveScheduledActions = ()=>Promise.resolve([]);
|
|
54
|
-
function ContentfulEntryCard({ info
|
|
56
|
+
function ContentfulEntryCard({ info, isDisabled, renderDragHandle, onRemove, onMoveTop, onMoveBottom, getEntryRouteHref }) {
|
|
55
57
|
const resourceSys = info.resource.sys;
|
|
56
58
|
const spaceId = resourceSys.space.sys.id;
|
|
57
59
|
const environmentId = resourceSys.environment.sys.id;
|
|
@@ -35,7 +35,9 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
|
35
35
|
if (cache && cache.has(obj)) {
|
|
36
36
|
return cache.get(obj);
|
|
37
37
|
}
|
|
38
|
-
var newObj = {
|
|
38
|
+
var newObj = {
|
|
39
|
+
__proto__: null
|
|
40
|
+
};
|
|
39
41
|
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
40
42
|
for(var key in obj){
|
|
41
43
|
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
@@ -60,12 +62,12 @@ function ResourceCardSkeleton() {
|
|
|
60
62
|
});
|
|
61
63
|
}
|
|
62
64
|
function ExistingResourceCard(props) {
|
|
63
|
-
const { resourceLink
|
|
65
|
+
const { resourceLink, inView, index = 0 } = props;
|
|
64
66
|
const resourceOptions = {
|
|
65
67
|
priority: index * -1,
|
|
66
68
|
enabled: inView
|
|
67
69
|
};
|
|
68
|
-
const { data
|
|
70
|
+
const { data, error } = (0, _EntityStore.useResource)(resourceLink.sys.linkType, resourceLink.sys.urn, resourceOptions);
|
|
69
71
|
if (!data && !error) {
|
|
70
72
|
return _react.createElement(ResourceCardSkeleton, null);
|
|
71
73
|
}
|
|
@@ -93,7 +95,7 @@ function ResourceCardWrapper(props) {
|
|
|
93
95
|
});
|
|
94
96
|
}
|
|
95
97
|
function ResourceCard(props) {
|
|
96
|
-
const { ref
|
|
98
|
+
const { ref, inView } = (0, _reactintersectionobserver.useInView)({
|
|
97
99
|
triggerOnce: true,
|
|
98
100
|
rootMargin: '300px 0px 0px 300px'
|
|
99
101
|
});
|
|
@@ -38,7 +38,9 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
|
38
38
|
if (cache && cache.has(obj)) {
|
|
39
39
|
return cache.get(obj);
|
|
40
40
|
}
|
|
41
|
-
var newObj = {
|
|
41
|
+
var newObj = {
|
|
42
|
+
__proto__: null
|
|
43
|
+
};
|
|
42
44
|
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
43
45
|
for(var key in obj){
|
|
44
46
|
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
@@ -75,7 +77,7 @@ const sdk = {
|
|
|
75
77
|
get: jest.fn().mockReturnValue(_published_content_typejson.default)
|
|
76
78
|
},
|
|
77
79
|
Entry: {
|
|
78
|
-
get: jest.fn().mockImplementation(({ spaceId
|
|
80
|
+
get: jest.fn().mockImplementation(({ spaceId, environmentId, entryId })=>{
|
|
79
81
|
if (spaceId === 'space-id' && environmentId === 'master' && entryId === 'linked-entry-urn') {
|
|
80
82
|
return Promise.resolve(_published_entryjson.default);
|
|
81
83
|
}
|
|
@@ -114,7 +116,7 @@ const sdk = {
|
|
|
114
116
|
environment: 'environment-id'
|
|
115
117
|
}
|
|
116
118
|
};
|
|
117
|
-
function renderResourceCard({ linkType ='Contentful:Entry'
|
|
119
|
+
function renderResourceCard({ linkType = 'Contentful:Entry', entryUrn = resolvableEntryUrn } = {}) {
|
|
118
120
|
return (0, _react1.render)(_react.createElement(_EntityStore.EntityProvider, {
|
|
119
121
|
sdk: sdk
|
|
120
122
|
}, _react.createElement(_ResourceCard.ResourceCard, {
|
|
@@ -131,7 +133,7 @@ function renderResourceCard({ linkType ='Contentful:Entry' , entryUrn =resolvabl
|
|
|
131
133
|
}
|
|
132
134
|
describe('ResourceCard', ()=>{
|
|
133
135
|
it('renders entry card with implicit master crn', async ()=>{
|
|
134
|
-
const { getByTestId
|
|
136
|
+
const { getByTestId, getByText } = renderResourceCard();
|
|
135
137
|
const tooltipContent = `Space: ${_indifferent_spacejson.default.name} (Env.: ${_published_entryjson.default.sys.environment.sys.id})`;
|
|
136
138
|
await (0, _react1.waitFor)(()=>expect(getByTestId('cf-ui-entry-card')).toBeDefined());
|
|
137
139
|
expect(getByText(_published_entryjson.default.fields.exField['en-US'])).toBeDefined();
|
|
@@ -140,7 +142,7 @@ describe('ResourceCard', ()=>{
|
|
|
140
142
|
await (0, _react1.waitFor)(()=>expect(getByText(tooltipContent)).toBeDefined());
|
|
141
143
|
});
|
|
142
144
|
it('renders entry card with explicit master crn', async ()=>{
|
|
143
|
-
const { getByTestId
|
|
145
|
+
const { getByTestId, getByText } = renderResourceCard({
|
|
144
146
|
entryUrn: resolvableEntryUrnWithExplicitMaster
|
|
145
147
|
});
|
|
146
148
|
const tooltipContent = `Space: ${_indifferent_spacejson.default.name} (Env.: ${_published_entryjson.default.sys.environment.sys.id})`;
|
|
@@ -151,7 +153,7 @@ describe('ResourceCard', ()=>{
|
|
|
151
153
|
await (0, _react1.waitFor)(()=>expect(getByText(tooltipContent)).toBeDefined());
|
|
152
154
|
});
|
|
153
155
|
it('renders entry card with a non master environment', async ()=>{
|
|
154
|
-
const { getByTestId
|
|
156
|
+
const { getByTestId, getByText } = renderResourceCard({
|
|
155
157
|
entryUrn: resolvableEntryUrnWithAnotherEnvironment
|
|
156
158
|
});
|
|
157
159
|
await (0, _react1.waitFor)(()=>expect(getByTestId('cf-ui-entry-card')).toBeDefined());
|
|
@@ -162,23 +164,23 @@ describe('ResourceCard', ()=>{
|
|
|
162
164
|
await (0, _react1.waitFor)(()=>expect(getByText(tooltipContent)).toBeDefined());
|
|
163
165
|
});
|
|
164
166
|
it('renders skeleton when no data is provided', ()=>{
|
|
165
|
-
const { getByTestId
|
|
167
|
+
const { getByTestId } = renderResourceCard();
|
|
166
168
|
expect(getByTestId('cf-ui-skeleton-form')).toBeDefined();
|
|
167
169
|
});
|
|
168
170
|
it('renders unsupported entity card when unsupported link is passed', async ()=>{
|
|
169
|
-
const { getByText
|
|
171
|
+
const { getByText } = renderResourceCard({
|
|
170
172
|
linkType: 'Contentful:UnsupportedLink'
|
|
171
173
|
});
|
|
172
174
|
await (0, _react1.waitFor)(()=>expect(getByText('Resource type Contentful:UnsupportedLink is currently not supported')).toBeDefined());
|
|
173
175
|
});
|
|
174
176
|
it('renders missing entity card when unknown error is returned', async ()=>{
|
|
175
|
-
const { getByTestId
|
|
177
|
+
const { getByTestId } = renderResourceCard({
|
|
176
178
|
entryUrn: unknownEntryUrn
|
|
177
179
|
});
|
|
178
180
|
await (0, _react1.waitFor)(()=>expect(getByTestId('cf-ui-missing-entry-card')).toBeDefined());
|
|
179
181
|
});
|
|
180
182
|
it('renders missing entity card when crn is invalid', async ()=>{
|
|
181
|
-
const { getByTestId
|
|
183
|
+
const { getByTestId } = renderResourceCard({
|
|
182
184
|
entryUrn: ''
|
|
183
185
|
});
|
|
184
186
|
await (0, _react1.waitFor)(()=>expect(getByTestId('cf-ui-missing-entry-card')).toBeDefined());
|
|
@@ -44,7 +44,9 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
|
44
44
|
if (cache && cache.has(obj)) {
|
|
45
45
|
return cache.get(obj);
|
|
46
46
|
}
|
|
47
|
-
var newObj = {
|
|
47
|
+
var newObj = {
|
|
48
|
+
__proto__: null
|
|
49
|
+
};
|
|
48
50
|
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
49
51
|
for(var key in obj){
|
|
50
52
|
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
@@ -63,9 +65,9 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
|
63
65
|
return newObj;
|
|
64
66
|
}
|
|
65
67
|
function ResourceEditor(props) {
|
|
66
|
-
const { setValue
|
|
68
|
+
const { setValue, items, apiUrl } = props;
|
|
67
69
|
const onSortStart = ()=>(0, _noop.default)();
|
|
68
|
-
const onSortEnd = (0, _react.useCallback)(({ oldIndex
|
|
70
|
+
const onSortEnd = (0, _react.useCallback)(({ oldIndex, newIndex })=>{
|
|
69
71
|
const newItems = (0, _sortable.arrayMove)(items, oldIndex, newIndex);
|
|
70
72
|
setValue(newItems);
|
|
71
73
|
}, [
|
|
@@ -85,7 +87,7 @@ function ResourceEditor(props) {
|
|
|
85
87
|
items,
|
|
86
88
|
setValue
|
|
87
89
|
]);
|
|
88
|
-
const { dialogs
|
|
90
|
+
const { dialogs, field } = props.sdk;
|
|
89
91
|
const linkActionsProps = (0, _useResourceLinkActions.useResourceLinkActions)({
|
|
90
92
|
dialogs,
|
|
91
93
|
field,
|
|
@@ -102,7 +104,7 @@ function ResourceEditor(props) {
|
|
|
102
104
|
renderCustomActions: props.renderCustomActions
|
|
103
105
|
}));
|
|
104
106
|
}
|
|
105
|
-
function WithPerItemCallbacks({ listLength
|
|
107
|
+
function WithPerItemCallbacks({ listLength, index, onMove, onRemoteItemAtIndex, children }) {
|
|
106
108
|
const handleMoveTop = _react.useMemo(()=>index > 0 ? ()=>onMove(index, 0) : undefined, [
|
|
107
109
|
index,
|
|
108
110
|
onMove
|
|
@@ -131,7 +133,7 @@ function MultipleResourceReferenceEditor(props) {
|
|
|
131
133
|
field: props.sdk.field,
|
|
132
134
|
isInitiallyDisabled: props.isInitiallyDisabled,
|
|
133
135
|
isEqualValues: _deepequal.default
|
|
134
|
-
}, ({ value
|
|
136
|
+
}, ({ value, disabled, setValue, externalReset })=>{
|
|
135
137
|
return _react.createElement(ResourceEditor, {
|
|
136
138
|
...props,
|
|
137
139
|
items: value || EMPTY_ARRAY,
|
|
@@ -139,13 +141,13 @@ function MultipleResourceReferenceEditor(props) {
|
|
|
139
141
|
setValue: setValue,
|
|
140
142
|
renderCustomActions: props.renderCustomActions,
|
|
141
143
|
key: `${externalReset}-list`
|
|
142
|
-
}, (editorProps)=>_react.createElement(_SortableLinkList.SortableLinkList, editorProps, ({ item
|
|
144
|
+
}, (editorProps)=>_react.createElement(_SortableLinkList.SortableLinkList, editorProps, ({ item, isDisabled, DragHandle, index })=>_react.createElement(WithPerItemCallbacks, {
|
|
143
145
|
key: index,
|
|
144
146
|
index: index,
|
|
145
147
|
onMove: editorProps.onMove,
|
|
146
148
|
onRemoteItemAtIndex: editorProps.onRemoteItemAtIndex,
|
|
147
149
|
listLength: value?.length || 0
|
|
148
|
-
}, ({ onMoveBottom
|
|
150
|
+
}, ({ onMoveBottom, onMoveTop, onRemove })=>_react.createElement(_ResourceCard.ResourceCard, {
|
|
149
151
|
key: index,
|
|
150
152
|
index: index,
|
|
151
153
|
resourceLink: item,
|
|
@@ -29,7 +29,9 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
|
29
29
|
if (cache && cache.has(obj)) {
|
|
30
30
|
return cache.get(obj);
|
|
31
31
|
}
|
|
32
|
-
var newObj = {
|
|
32
|
+
var newObj = {
|
|
33
|
+
__proto__: null
|
|
34
|
+
};
|
|
33
35
|
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
34
36
|
for(var key in obj){
|
|
35
37
|
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
@@ -123,7 +125,7 @@ describe('Multiple resource editor', ()=>{
|
|
|
123
125
|
});
|
|
124
126
|
describe('with value', ()=>{
|
|
125
127
|
it('renders the cards', async ()=>{
|
|
126
|
-
const { entryLinks
|
|
128
|
+
const { entryLinks, entryInfos } = generateMultipleTestResources();
|
|
127
129
|
mockedResources = {};
|
|
128
130
|
for (const [spaceId, link] of Object.entries(entryLinks)){
|
|
129
131
|
mockedResources[`${link.sys.linkType}.${link.sys.urn}`] = entryInfos[spaceId];
|
|
@@ -150,7 +152,7 @@ describe('Multiple resource editor', ()=>{
|
|
|
150
152
|
});
|
|
151
153
|
describe('card actions', ()=>{
|
|
152
154
|
it('should have a move to top button', async ()=>{
|
|
153
|
-
const { entryLinks
|
|
155
|
+
const { entryLinks, entryInfos } = generateMultipleTestResources();
|
|
154
156
|
mockedResources = {};
|
|
155
157
|
for (const [spaceId, link] of Object.entries(entryLinks)){
|
|
156
158
|
mockedResources[`${link.sys.linkType}.${link.sys.urn}`] = entryInfos[spaceId];
|
|
@@ -176,7 +178,7 @@ describe('Multiple resource editor', ()=>{
|
|
|
176
178
|
}
|
|
177
179
|
});
|
|
178
180
|
it('should have a move to bottom button', async ()=>{
|
|
179
|
-
const { entryLinks
|
|
181
|
+
const { entryLinks, entryInfos } = generateMultipleTestResources();
|
|
180
182
|
mockedResources = {};
|
|
181
183
|
for (const [spaceId, link] of Object.entries(entryLinks)){
|
|
182
184
|
mockedResources[`${link.sys.linkType}.${link.sys.urn}`] = entryInfos[spaceId];
|
|
@@ -202,7 +204,7 @@ describe('Multiple resource editor', ()=>{
|
|
|
202
204
|
}
|
|
203
205
|
});
|
|
204
206
|
it('works when using remove action', async ()=>{
|
|
205
|
-
const { entryLinks
|
|
207
|
+
const { entryLinks, entryInfos } = generateMultipleTestResources();
|
|
206
208
|
mockedResources = {};
|
|
207
209
|
for (const [spaceId, link] of Object.entries(entryLinks)){
|
|
208
210
|
mockedResources[`${link.sys.linkType}.${link.sys.urn}`] = entryInfos[spaceId];
|
|
@@ -41,7 +41,9 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
|
41
41
|
if (cache && cache.has(obj)) {
|
|
42
42
|
return cache.get(obj);
|
|
43
43
|
}
|
|
44
|
-
var newObj = {
|
|
44
|
+
var newObj = {
|
|
45
|
+
__proto__: null
|
|
46
|
+
};
|
|
45
47
|
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
46
48
|
for(var key in obj){
|
|
47
49
|
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
@@ -60,7 +62,7 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
|
60
62
|
return newObj;
|
|
61
63
|
}
|
|
62
64
|
function SingleResourceReferenceEditor(props) {
|
|
63
|
-
const { dialogs
|
|
65
|
+
const { dialogs, field } = props.sdk;
|
|
64
66
|
const linkActionsProps = (0, _useResourceLinkActions.useResourceLinkActions)({
|
|
65
67
|
dialogs,
|
|
66
68
|
field,
|
|
@@ -73,7 +75,7 @@ function SingleResourceReferenceEditor(props) {
|
|
|
73
75
|
field: props.sdk.field,
|
|
74
76
|
isInitiallyDisabled: props.isInitiallyDisabled,
|
|
75
77
|
isEqualValues: _deepequal.default
|
|
76
|
-
}, ({ value
|
|
78
|
+
}, ({ value, disabled })=>{
|
|
77
79
|
return value ? _react.createElement(_ResourceCard.ResourceCard, {
|
|
78
80
|
onRemove: ()=>props.sdk.field.removeValue(),
|
|
79
81
|
resourceLink: value,
|
|
@@ -29,7 +29,9 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
|
29
29
|
if (cache && cache.has(obj)) {
|
|
30
30
|
return cache.get(obj);
|
|
31
31
|
}
|
|
32
|
-
var newObj = {
|
|
32
|
+
var newObj = {
|
|
33
|
+
__proto__: null
|
|
34
|
+
};
|
|
33
35
|
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
34
36
|
for(var key in obj){
|
|
35
37
|
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
@@ -9,11 +9,11 @@ function _export(target, all) {
|
|
|
9
9
|
});
|
|
10
10
|
}
|
|
11
11
|
_export(exports, {
|
|
12
|
-
mockSdkForField: function() {
|
|
13
|
-
return mockSdkForField;
|
|
14
|
-
},
|
|
15
12
|
createFakeEntryResource: function() {
|
|
16
13
|
return createFakeEntryResource;
|
|
14
|
+
},
|
|
15
|
+
mockSdkForField: function() {
|
|
16
|
+
return mockSdkForField;
|
|
17
17
|
}
|
|
18
18
|
});
|
|
19
19
|
function mockSdkForField(fieldDefinition, fieldValue) {
|
|
@@ -75,8 +75,8 @@ function mockSdkForField(fieldDefinition, fieldValue) {
|
|
|
75
75
|
}
|
|
76
76
|
};
|
|
77
77
|
}
|
|
78
|
-
const createFakeEntryResource = ({ title
|
|
79
|
-
const { id: spaceId
|
|
78
|
+
const createFakeEntryResource = ({ title, id, space })=>{
|
|
79
|
+
const { id: spaceId, name: spaceName } = space;
|
|
80
80
|
return {
|
|
81
81
|
resource: {
|
|
82
82
|
sys: {
|
|
@@ -29,7 +29,7 @@ const getUpdatedValue = (field, entries, apiUrl)=>{
|
|
|
29
29
|
return toLinkItem(entries[0], apiUrl);
|
|
30
30
|
}
|
|
31
31
|
};
|
|
32
|
-
function useResourceLinkActions({ dialogs
|
|
32
|
+
function useResourceLinkActions({ dialogs, field, onAfterLink, apiUrl }) {
|
|
33
33
|
const handleAfterLink = (0, _react.useCallback)((entries)=>{
|
|
34
34
|
if (!onAfterLink) {
|
|
35
35
|
return;
|
package/dist/cjs/types.js
CHANGED
|
@@ -9,14 +9,14 @@ function _export(target, all) {
|
|
|
9
9
|
});
|
|
10
10
|
}
|
|
11
11
|
_export(exports, {
|
|
12
|
+
Asset: function() {
|
|
13
|
+
return _fieldeditorshared.Asset;
|
|
14
|
+
},
|
|
12
15
|
Entry: function() {
|
|
13
16
|
return _fieldeditorshared.Entry;
|
|
14
17
|
},
|
|
15
18
|
File: function() {
|
|
16
19
|
return _fieldeditorshared.File;
|
|
17
|
-
},
|
|
18
|
-
Asset: function() {
|
|
19
|
-
return _fieldeditorshared.Asset;
|
|
20
20
|
}
|
|
21
21
|
});
|
|
22
22
|
const _fieldeditorshared = require("@contentful/field-editor-shared");
|