@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
|
@@ -59,7 +59,7 @@ function newReferenceEditorFakeSdk(props) {
|
|
|
59
59
|
locales,
|
|
60
60
|
cmaAdapter: (0, _fieldeditortestutils.createFakeCMAAdapter)({
|
|
61
61
|
Entry: {
|
|
62
|
-
get: async ({ entryId
|
|
62
|
+
get: async ({ entryId })=>{
|
|
63
63
|
if (props?.fetchDelay) {
|
|
64
64
|
await delay(props.fetchDelay);
|
|
65
65
|
}
|
|
@@ -76,7 +76,7 @@ function newReferenceEditorFakeSdk(props) {
|
|
|
76
76
|
}
|
|
77
77
|
},
|
|
78
78
|
Asset: {
|
|
79
|
-
get: async ({ assetId
|
|
79
|
+
get: async ({ assetId })=>{
|
|
80
80
|
if (props?.fetchDelay) {
|
|
81
81
|
await delay(props.fetchDelay);
|
|
82
82
|
}
|
|
@@ -101,7 +101,7 @@ function newReferenceEditorFakeSdk(props) {
|
|
|
101
101
|
}
|
|
102
102
|
},
|
|
103
103
|
ContentType: {
|
|
104
|
-
get: async ({ contentTypeId
|
|
104
|
+
get: async ({ contentTypeId })=>{
|
|
105
105
|
if (contentTypeId === _fixtures.contentTypes.published.sys.id) {
|
|
106
106
|
return _fixtures.contentTypes.published;
|
|
107
107
|
}
|
|
@@ -12,17 +12,17 @@ _export(exports, {
|
|
|
12
12
|
changed: function() {
|
|
13
13
|
return _changed_assetjson.default;
|
|
14
14
|
},
|
|
15
|
+
created: function() {
|
|
16
|
+
return _created_assetjson.default;
|
|
17
|
+
},
|
|
15
18
|
empty: function() {
|
|
16
19
|
return _empty_assetjson.default;
|
|
17
20
|
},
|
|
18
|
-
published: function() {
|
|
19
|
-
return _published_assetjson.default;
|
|
20
|
-
},
|
|
21
21
|
invalid: function() {
|
|
22
22
|
return _invalid_assetjson.default;
|
|
23
23
|
},
|
|
24
|
-
|
|
25
|
-
return
|
|
24
|
+
published: function() {
|
|
25
|
+
return _published_assetjson.default;
|
|
26
26
|
}
|
|
27
27
|
});
|
|
28
28
|
const _changed_assetjson = _interop_require_default(require("./changed_asset.json"));
|
|
@@ -15,11 +15,11 @@ _export(exports, {
|
|
|
15
15
|
empty: function() {
|
|
16
16
|
return _empty_entryjson.default;
|
|
17
17
|
},
|
|
18
|
-
published: function() {
|
|
19
|
-
return _published_entryjson.default;
|
|
20
|
-
},
|
|
21
18
|
invalid: function() {
|
|
22
19
|
return _invalid_entryjson.default;
|
|
20
|
+
},
|
|
21
|
+
published: function() {
|
|
22
|
+
return _published_entryjson.default;
|
|
23
23
|
}
|
|
24
24
|
});
|
|
25
25
|
const _changed_entryjson = _interop_require_default(require("./changed_entry.json"));
|
|
@@ -51,7 +51,9 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
|
51
51
|
if (cache && cache.has(obj)) {
|
|
52
52
|
return cache.get(obj);
|
|
53
53
|
}
|
|
54
|
-
var newObj = {
|
|
54
|
+
var newObj = {
|
|
55
|
+
__proto__: null
|
|
56
|
+
};
|
|
55
57
|
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
56
58
|
for(var key in obj){
|
|
57
59
|
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
@@ -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)) {
|
|
@@ -70,7 +72,7 @@ function MultipleMediaEditor(props) {
|
|
|
70
72
|
className: (0, _emotion.cx)({
|
|
71
73
|
[styles.gridContainer]: childrenProps.viewType === 'card'
|
|
72
74
|
})
|
|
73
|
-
}, ({ items
|
|
75
|
+
}, ({ items, item, index, isDisabled, DragHandle })=>_react.createElement(_FetchingWrappedAssetCard.FetchingWrappedAssetCard, {
|
|
74
76
|
...childrenProps,
|
|
75
77
|
isDisabled: isDisabled,
|
|
76
78
|
key: `${item.sys.id}-${index}`,
|
|
@@ -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 SingleMediaEditor(props) {
|
|
|
54
56
|
return _react.createElement(_SingleReferenceEditor.SingleReferenceEditor, {
|
|
55
57
|
...props,
|
|
56
58
|
entityType: "Asset"
|
|
57
|
-
}, ({ entityId
|
|
59
|
+
}, ({ entityId, isDisabled, setValue })=>_react.createElement(_FetchingWrappedAssetCard.FetchingWrappedAssetCard, {
|
|
58
60
|
...props,
|
|
59
61
|
viewType: "big_card",
|
|
60
62
|
assetId: entityId,
|
|
@@ -9,11 +9,11 @@ function _export(target, all) {
|
|
|
9
9
|
});
|
|
10
10
|
}
|
|
11
11
|
_export(exports, {
|
|
12
|
-
renderAssetInfo: function() {
|
|
13
|
-
return renderAssetInfo;
|
|
14
|
-
},
|
|
15
12
|
renderActions: function() {
|
|
16
13
|
return renderActions;
|
|
14
|
+
},
|
|
15
|
+
renderAssetInfo: function() {
|
|
16
|
+
return renderAssetInfo;
|
|
17
17
|
}
|
|
18
18
|
});
|
|
19
19
|
const _react = _interop_require_wildcard(require("react"));
|
|
@@ -48,7 +48,9 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
|
48
48
|
if (cache && cache.has(obj)) {
|
|
49
49
|
return cache.get(obj);
|
|
50
50
|
}
|
|
51
|
-
var newObj = {
|
|
51
|
+
var newObj = {
|
|
52
|
+
__proto__: null
|
|
53
|
+
};
|
|
52
54
|
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
53
55
|
for(var key in obj){
|
|
54
56
|
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
@@ -104,7 +106,7 @@ function downloadAsset(url) {
|
|
|
104
106
|
window.open(url, '_blank', 'noopener,noreferrer');
|
|
105
107
|
}
|
|
106
108
|
function renderAssetInfo(props) {
|
|
107
|
-
const { entityFile
|
|
109
|
+
const { entityFile } = props;
|
|
108
110
|
const fileName = (0, _get.default)(entityFile, 'fileName');
|
|
109
111
|
const mimeType = (0, _get.default)(entityFile, 'contentType');
|
|
110
112
|
const fileSize = (0, _get.default)(entityFile, 'details.size');
|
|
@@ -129,7 +131,7 @@ function renderAssetInfo(props) {
|
|
|
129
131
|
];
|
|
130
132
|
}
|
|
131
133
|
function renderActions(props) {
|
|
132
|
-
const { entityFile
|
|
134
|
+
const { entityFile, isDisabled, onEdit, onRemove } = props;
|
|
133
135
|
return [
|
|
134
136
|
_react.createElement(_f36components.Menu.SectionTitle, {
|
|
135
137
|
key: "section-title"
|
|
@@ -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)) {
|
|
@@ -54,8 +56,8 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
|
54
56
|
return newObj;
|
|
55
57
|
}
|
|
56
58
|
function FetchingWrappedAssetCard(props) {
|
|
57
|
-
const { data: asset
|
|
58
|
-
const { getEntityScheduledActions
|
|
59
|
+
const { data: asset, status } = (0, _EntityStore.useEntity)('Asset', props.assetId);
|
|
60
|
+
const { getEntityScheduledActions } = (0, _EntityStore.useEntityLoader)();
|
|
59
61
|
const loadEntityScheduledActions = _react.useCallback(()=>getEntityScheduledActions('Asset', props.assetId), [
|
|
60
62
|
getEntityScheduledActions,
|
|
61
63
|
props.assetId
|
|
@@ -71,7 +73,7 @@ function FetchingWrappedAssetCard(props) {
|
|
|
71
73
|
asset
|
|
72
74
|
]);
|
|
73
75
|
const onEdit = async ()=>{
|
|
74
|
-
const { slide
|
|
76
|
+
const { slide } = await props.sdk.navigator.openAsset(props.assetId, {
|
|
75
77
|
slideIn: true
|
|
76
78
|
});
|
|
77
79
|
props.onAction && props.onAction({
|
|
@@ -110,7 +112,7 @@ function FetchingWrappedAssetCard(props) {
|
|
|
110
112
|
}
|
|
111
113
|
return card;
|
|
112
114
|
}
|
|
113
|
-
const { getEntityUrl
|
|
115
|
+
const { getEntityUrl } = props;
|
|
114
116
|
const size = props.viewType === 'big_card' ? 'default' : 'small';
|
|
115
117
|
const commonProps = {
|
|
116
118
|
asset,
|
|
@@ -147,7 +149,7 @@ function FetchingWrappedAssetCard(props) {
|
|
|
147
149
|
...commonProps,
|
|
148
150
|
...props,
|
|
149
151
|
getEntityScheduledActions: loadEntityScheduledActions,
|
|
150
|
-
asset:
|
|
152
|
+
asset: props?.entity || commonProps.asset,
|
|
151
153
|
getAssetUrl: getEntityUrl
|
|
152
154
|
};
|
|
153
155
|
return _react.createElement(_WrappedAssetCard.WrappedAssetCard, builtinCardProps);
|
|
@@ -43,7 +43,9 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
|
43
43
|
if (cache && cache.has(obj)) {
|
|
44
44
|
return cache.get(obj);
|
|
45
45
|
}
|
|
46
|
-
var newObj = {
|
|
46
|
+
var newObj = {
|
|
47
|
+
__proto__: null
|
|
48
|
+
};
|
|
47
49
|
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
48
50
|
for(var key in obj){
|
|
49
51
|
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
@@ -93,7 +95,7 @@ function getFileType(file) {
|
|
|
93
95
|
return groupToIconMap[groupName] || 'archive';
|
|
94
96
|
}
|
|
95
97
|
const WrappedAssetCard = (props)=>{
|
|
96
|
-
const { className
|
|
98
|
+
const { className, onEdit, getAssetUrl, onRemove, size, isDisabled, isSelected, isClickable } = props;
|
|
97
99
|
const status = _fieldeditorshared.entityHelpers.getEntryStatus(props.asset.sys);
|
|
98
100
|
if (status === 'deleted') {
|
|
99
101
|
return _react.createElement(_components.MissingEntityCard, {
|
|
@@ -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)) {
|
|
@@ -66,7 +68,7 @@ const styles = {
|
|
|
66
68
|
})
|
|
67
69
|
};
|
|
68
70
|
const WrappedAssetLink = (props)=>{
|
|
69
|
-
const { className
|
|
71
|
+
const { className, href, onEdit, onRemove, isDisabled } = props;
|
|
70
72
|
const status = _fieldeditorshared.entityHelpers.getEntryStatus(props.asset.sys);
|
|
71
73
|
if (status === 'deleted') {
|
|
72
74
|
return _react.createElement(_components.MissingEntityCard, {
|
package/dist/cjs/assets/index.js
CHANGED
|
@@ -9,12 +9,12 @@ function _export(target, all) {
|
|
|
9
9
|
});
|
|
10
10
|
}
|
|
11
11
|
_export(exports, {
|
|
12
|
-
SingleMediaEditor: function() {
|
|
13
|
-
return _SingleMediaEditor.SingleMediaEditor;
|
|
14
|
-
},
|
|
15
12
|
MultipleMediaEditor: function() {
|
|
16
13
|
return _MultipleMediaEditor.MultipleMediaEditor;
|
|
17
14
|
},
|
|
15
|
+
SingleMediaEditor: function() {
|
|
16
|
+
return _SingleMediaEditor.SingleMediaEditor;
|
|
17
|
+
},
|
|
18
18
|
WrappedAssetCard: function() {
|
|
19
19
|
return _WrappedAssetCard.WrappedAssetCard;
|
|
20
20
|
}
|
|
@@ -9,6 +9,9 @@ function _export(target, all) {
|
|
|
9
9
|
});
|
|
10
10
|
}
|
|
11
11
|
_export(exports, {
|
|
12
|
+
EntityProvider: function() {
|
|
13
|
+
return EntityProvider;
|
|
14
|
+
},
|
|
12
15
|
UnsupportedError: function() {
|
|
13
16
|
return UnsupportedError;
|
|
14
17
|
},
|
|
@@ -18,14 +21,11 @@ _export(exports, {
|
|
|
18
21
|
useEntity: function() {
|
|
19
22
|
return useEntity;
|
|
20
23
|
},
|
|
21
|
-
useResource: function() {
|
|
22
|
-
return useResource;
|
|
23
|
-
},
|
|
24
|
-
EntityProvider: function() {
|
|
25
|
-
return EntityProvider;
|
|
26
|
-
},
|
|
27
24
|
useEntityLoader: function() {
|
|
28
25
|
return useEntityLoader;
|
|
26
|
+
},
|
|
27
|
+
useResource: function() {
|
|
28
|
+
return useResource;
|
|
29
29
|
}
|
|
30
30
|
});
|
|
31
31
|
const _react = _interop_require_wildcard(require("react"));
|
|
@@ -72,7 +72,9 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
|
72
72
|
if (cache && cache.has(obj)) {
|
|
73
73
|
return cache.get(obj);
|
|
74
74
|
}
|
|
75
|
-
var newObj = {
|
|
75
|
+
var newObj = {
|
|
76
|
+
__proto__: null
|
|
77
|
+
};
|
|
76
78
|
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
77
79
|
for(var key in obj){
|
|
78
80
|
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
@@ -107,7 +109,7 @@ const isEntityQueryKey = (queryKey)=>{
|
|
|
107
109
|
return Array.isArray(queryKey) && (queryKey[0] === 'Entry' || queryKey[0] === 'Asset') && queryKey.length === 4;
|
|
108
110
|
};
|
|
109
111
|
async function fetchContentfulEntry(params) {
|
|
110
|
-
const { urn
|
|
112
|
+
const { urn, fetch, options } = params;
|
|
111
113
|
const resourceId = urn.split(':', 6)[5];
|
|
112
114
|
const ENTITY_RESOURCE_ID_REGEX = RegExp("^spaces\\/(?<spaceId>[^/]+)(?:\\/environments\\/(?<environmentId>[^/]+))?\\/entries\\/(?<entityId>[^/]+)$");
|
|
113
115
|
const resourceIdMatch = resourceId.match(ENTITY_RESOURCE_ID_REGEX);
|
|
@@ -121,7 +123,7 @@ async function fetchContentfulEntry(params) {
|
|
|
121
123
|
fetch([
|
|
122
124
|
'space',
|
|
123
125
|
spaceId
|
|
124
|
-
], ({ cmaClient
|
|
126
|
+
], ({ cmaClient })=>cmaClient.space.get({
|
|
125
127
|
spaceId
|
|
126
128
|
}), options),
|
|
127
129
|
fetch([
|
|
@@ -129,7 +131,7 @@ async function fetchContentfulEntry(params) {
|
|
|
129
131
|
spaceId,
|
|
130
132
|
environmentId,
|
|
131
133
|
entryId
|
|
132
|
-
], ({ cmaClient
|
|
134
|
+
], ({ cmaClient })=>cmaClient.entry.get({
|
|
133
135
|
spaceId,
|
|
134
136
|
environmentId,
|
|
135
137
|
entryId
|
|
@@ -142,7 +144,7 @@ async function fetchContentfulEntry(params) {
|
|
|
142
144
|
spaceId,
|
|
143
145
|
environmentId,
|
|
144
146
|
contentTypeId
|
|
145
|
-
], ({ cmaClient
|
|
147
|
+
], ({ cmaClient })=>cmaClient.contentType.get({
|
|
146
148
|
contentTypeId,
|
|
147
149
|
spaceId,
|
|
148
150
|
environmentId
|
|
@@ -151,7 +153,7 @@ async function fetchContentfulEntry(params) {
|
|
|
151
153
|
'defaultLocale',
|
|
152
154
|
spaceId,
|
|
153
155
|
environmentId
|
|
154
|
-
], async ({ cmaClient
|
|
156
|
+
], async ({ cmaClient })=>{
|
|
155
157
|
const locales = await cmaClient.locale.getMany({
|
|
156
158
|
spaceId,
|
|
157
159
|
environmentId,
|
|
@@ -201,7 +203,7 @@ const [InternalServiceProvider, useFetch, useEntityLoader, useCurrentIds] = (0,
|
|
|
201
203
|
props.queryConcurrency
|
|
202
204
|
]);
|
|
203
205
|
const fetch = (0, _react.useCallback)(function fetch(queryKey, fn, options = {}) {
|
|
204
|
-
const { priority
|
|
206
|
+
const { priority, ...queryOptions } = options;
|
|
205
207
|
return queryClient.fetchQuery(queryKey, ()=>queryQueue.add(()=>fn({
|
|
206
208
|
cmaClient
|
|
207
209
|
}), {
|
|
@@ -221,7 +223,7 @@ const [InternalServiceProvider, useFetch, useEntityLoader, useCurrentIds] = (0,
|
|
|
221
223
|
spaceId,
|
|
222
224
|
environmentId
|
|
223
225
|
];
|
|
224
|
-
return fetch(queryKey, ({ cmaClient
|
|
226
|
+
return fetch(queryKey, ({ cmaClient })=>{
|
|
225
227
|
if (entityType === 'Entry') {
|
|
226
228
|
return cmaClient.entry.get({
|
|
227
229
|
entryId: entityId,
|
|
@@ -255,7 +257,7 @@ const [InternalServiceProvider, useFetch, useEntityLoader, useCurrentIds] = (0,
|
|
|
255
257
|
spaceId,
|
|
256
258
|
environmentId
|
|
257
259
|
];
|
|
258
|
-
return fetch(queryKey, async ({ cmaClient
|
|
260
|
+
return fetch(queryKey, async ({ cmaClient })=>{
|
|
259
261
|
const response = await cmaClient.scheduledActions.getMany({
|
|
260
262
|
spaceId,
|
|
261
263
|
query: {
|
|
@@ -309,7 +311,7 @@ const [InternalServiceProvider, useFetch, useEntityLoader, useCurrentIds] = (0,
|
|
|
309
311
|
});
|
|
310
312
|
}
|
|
311
313
|
if (typeof onEntityChanged !== 'function') {
|
|
312
|
-
return onSlideInNavigation(({ oldSlideLevel
|
|
314
|
+
return onSlideInNavigation(({ oldSlideLevel, newSlideLevel })=>{
|
|
313
315
|
if (oldSlideLevel > newSlideLevel) {
|
|
314
316
|
findSameSpaceQueries().forEach((query)=>{
|
|
315
317
|
void queryClient.invalidateQueries(query.queryKey);
|
|
@@ -317,7 +319,7 @@ const [InternalServiceProvider, useFetch, useEntityLoader, useCurrentIds] = (0,
|
|
|
317
319
|
}
|
|
318
320
|
});
|
|
319
321
|
}
|
|
320
|
-
const subscribeQuery = ({ queryKey
|
|
322
|
+
const subscribeQuery = ({ queryKey, queryHash })=>{
|
|
321
323
|
const [entityType, entityId] = queryKey;
|
|
322
324
|
entityChangeUnsubscribers.current[queryHash] = onEntityChanged(entityType, entityId, (data)=>{
|
|
323
325
|
queryClient.setQueryData(queryKey, data);
|
|
@@ -328,8 +330,8 @@ const [InternalServiceProvider, useFetch, useEntityLoader, useCurrentIds] = (0,
|
|
|
328
330
|
if (!event) {
|
|
329
331
|
return;
|
|
330
332
|
}
|
|
331
|
-
const { type
|
|
332
|
-
const { queryKey
|
|
333
|
+
const { type, query } = event;
|
|
334
|
+
const { queryKey, queryHash } = query;
|
|
333
335
|
if (!isSameSpaceEntityQueryKey(queryKey)) {
|
|
334
336
|
return;
|
|
335
337
|
}
|
|
@@ -361,24 +363,24 @@ const [InternalServiceProvider, useFetch, useEntityLoader, useCurrentIds] = (0,
|
|
|
361
363
|
getEntity,
|
|
362
364
|
getEntityScheduledActions
|
|
363
365
|
};
|
|
364
|
-
}, ({ fetch
|
|
366
|
+
}, ({ fetch })=>fetch, ({ getResource, getEntity, getEntityScheduledActions })=>({
|
|
365
367
|
getResource,
|
|
366
368
|
getEntity,
|
|
367
369
|
getEntityScheduledActions
|
|
368
|
-
}), ({ ids
|
|
370
|
+
}), ({ ids })=>({
|
|
369
371
|
environment: ids.environmentAlias ?? ids.environment,
|
|
370
372
|
space: ids.space
|
|
371
373
|
}));
|
|
372
374
|
function useEntity(entityType, entityId, options) {
|
|
373
|
-
const { space
|
|
374
|
-
const { getEntity
|
|
375
|
+
const { space, environment } = useCurrentIds();
|
|
376
|
+
const { getEntity } = useEntityLoader();
|
|
375
377
|
const queryKey = [
|
|
376
378
|
entityType,
|
|
377
379
|
entityId,
|
|
378
380
|
options?.spaceId ?? space,
|
|
379
381
|
options?.environmentId ?? environment
|
|
380
382
|
];
|
|
381
|
-
const { status
|
|
383
|
+
const { status, data } = (0, _queryClient.useQuery)(queryKey, ()=>getEntity(entityType, entityId, options), {
|
|
382
384
|
enabled: options?.enabled
|
|
383
385
|
});
|
|
384
386
|
return {
|
|
@@ -392,8 +394,8 @@ function useResource(resourceType, urn, options) {
|
|
|
392
394
|
resourceType,
|
|
393
395
|
urn
|
|
394
396
|
];
|
|
395
|
-
const { getResource
|
|
396
|
-
const { status
|
|
397
|
+
const { getResource } = useEntityLoader();
|
|
398
|
+
const { status, data, error } = (0, _queryClient.useQuery)(queryKey, ()=>getResource(resourceType, urn, options), {
|
|
397
399
|
enabled: options?.enabled
|
|
398
400
|
});
|
|
399
401
|
return {
|
|
@@ -402,6 +404,6 @@ function useResource(resourceType, urn, options) {
|
|
|
402
404
|
error
|
|
403
405
|
};
|
|
404
406
|
}
|
|
405
|
-
function EntityProvider({ children
|
|
407
|
+
function EntityProvider({ children, ...props }) {
|
|
406
408
|
return _react.default.createElement(_queryClient.SharedQueryClientProvider, null, _react.default.createElement(InternalServiceProvider, props, children));
|
|
407
409
|
}
|
|
@@ -36,7 +36,9 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
|
36
36
|
if (cache && cache.has(obj)) {
|
|
37
37
|
return cache.get(obj);
|
|
38
38
|
}
|
|
39
|
-
var newObj = {
|
|
39
|
+
var newObj = {
|
|
40
|
+
__proto__: null
|
|
41
|
+
};
|
|
40
42
|
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
41
43
|
for(var key in obj){
|
|
42
44
|
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
@@ -73,18 +75,18 @@ const nullableValue = {
|
|
|
73
75
|
}
|
|
74
76
|
};
|
|
75
77
|
function Editor(props) {
|
|
76
|
-
const { setValue
|
|
78
|
+
const { setValue, entityType, onSortingEnd, setIndexToUpdate } = props;
|
|
77
79
|
const editorPermissions = (0, _useEditorPermissions.useEditorPermissions)(props);
|
|
78
80
|
const items = _react.useMemo(()=>{
|
|
79
81
|
return (props.items || []).map((link)=>link || nullableValue);
|
|
80
82
|
}, [
|
|
81
83
|
props.items
|
|
82
84
|
]);
|
|
83
|
-
const { rearrangeSortIDs
|
|
85
|
+
const { rearrangeSortIDs } = (0, _useSortIDs.useSortIDs)(items);
|
|
84
86
|
const onSortStart = (0, _react.useCallback)(()=>{
|
|
85
87
|
document.body.classList.add('grabbing');
|
|
86
88
|
}, []);
|
|
87
|
-
const onSortEnd = (0, _react.useCallback)(({ oldIndex
|
|
89
|
+
const onSortEnd = (0, _react.useCallback)(({ oldIndex, newIndex })=>{
|
|
88
90
|
onSortingEnd && onSortingEnd({
|
|
89
91
|
oldIndex,
|
|
90
92
|
newIndex
|
|
@@ -144,7 +146,7 @@ function Editor(props) {
|
|
|
144
146
|
}
|
|
145
147
|
function MultipleReferenceEditor(props) {
|
|
146
148
|
const allContentTypes = props.sdk.space.getCachedContentTypes();
|
|
147
|
-
return _react.createElement(_ReferenceEditor.ReferenceEditor, props, ({ value
|
|
149
|
+
return _react.createElement(_ReferenceEditor.ReferenceEditor, props, ({ value, disabled, setValue, externalReset })=>{
|
|
148
150
|
return _react.createElement(Editor, {
|
|
149
151
|
...props,
|
|
150
152
|
items: value || emptyArray,
|
|
@@ -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)) {
|
|
@@ -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)) {
|
|
@@ -53,7 +55,7 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
|
53
55
|
return newObj;
|
|
54
56
|
}
|
|
55
57
|
function Editor(props) {
|
|
56
|
-
const { setValue
|
|
58
|
+
const { setValue, entityType } = props;
|
|
57
59
|
const editorPermissions = (0, _useEditorPermissions.useEditorPermissions)(props);
|
|
58
60
|
const onCreate = (0, _react.useCallback)((id)=>void setValue({
|
|
59
61
|
sys: {
|
|
@@ -101,7 +103,7 @@ function Editor(props) {
|
|
|
101
103
|
}
|
|
102
104
|
function SingleReferenceEditor(props) {
|
|
103
105
|
const allContentTypes = props.sdk.space.getCachedContentTypes();
|
|
104
|
-
return _react.createElement(_ReferenceEditor.ReferenceEditor, props, ({ value
|
|
106
|
+
return _react.createElement(_ReferenceEditor.ReferenceEditor, props, ({ value, setValue, disabled, externalReset })=>{
|
|
105
107
|
return _react.createElement(Editor, {
|
|
106
108
|
...props,
|
|
107
109
|
key: `${externalReset}-reference`,
|
|
@@ -35,8 +35,8 @@ const styles = {
|
|
|
35
35
|
display: 'flex'
|
|
36
36
|
})
|
|
37
37
|
};
|
|
38
|
-
const SortableLink = ({ id
|
|
39
|
-
const { listeners
|
|
38
|
+
const SortableLink = ({ id, items, item, isDisabled = false, index, children })=>{
|
|
39
|
+
const { listeners, setNodeRef, setActivatorNodeRef, transform, transition, isDragging } = (0, _sortable.useSortable)({
|
|
40
40
|
id
|
|
41
41
|
});
|
|
42
42
|
const style = {
|
|
@@ -72,8 +72,8 @@ const SortableLink = ({ id , items , item , isDisabled =false , index , children
|
|
|
72
72
|
DragHandle: isDisabled ? undefined : DragHandle
|
|
73
73
|
}));
|
|
74
74
|
};
|
|
75
|
-
const SortableLinkList = ({ items
|
|
76
|
-
const { sortIDs
|
|
75
|
+
const SortableLinkList = ({ items, isDisabled, className, children, onSortStart, onSortEnd, updateBeforeSortStart, sortingStrategy })=>{
|
|
76
|
+
const { sortIDs, rearrangeSortIDs } = (0, _useSortIDs.useSortIDs)(items);
|
|
77
77
|
const onSortStartHandler = _react.default.useCallback((event)=>{
|
|
78
78
|
const index = sortIDs.findIndex((item)=>item.id === event.active.id);
|
|
79
79
|
updateBeforeSortStart?.({
|
|
@@ -86,7 +86,7 @@ const SortableLinkList = ({ items , isDisabled , className , children , onSortSt
|
|
|
86
86
|
sortIDs
|
|
87
87
|
]);
|
|
88
88
|
const onSortEndHandler = _react.default.useCallback((event)=>{
|
|
89
|
-
const { active
|
|
89
|
+
const { active, over } = event;
|
|
90
90
|
if (active && over && active.id !== over.id) {
|
|
91
91
|
const oldIndex = sortIDs.findIndex((item)=>item.id === active.id);
|
|
92
92
|
const newIndex = sortIDs.findIndex((item)=>item.id === over.id);
|
|
@@ -24,7 +24,9 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
|
24
24
|
if (cache && cache.has(obj)) {
|
|
25
25
|
return cache.get(obj);
|
|
26
26
|
}
|
|
27
|
-
var newObj = {
|
|
27
|
+
var newObj = {
|
|
28
|
+
__proto__: null
|
|
29
|
+
};
|
|
28
30
|
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
29
31
|
for(var key in obj){
|
|
30
32
|
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
@@ -9,14 +9,14 @@ function _export(target, all) {
|
|
|
9
9
|
});
|
|
10
10
|
}
|
|
11
11
|
_export(exports, {
|
|
12
|
-
|
|
13
|
-
return
|
|
12
|
+
SharedQueryClientProvider: function() {
|
|
13
|
+
return SharedQueryClientProvider;
|
|
14
14
|
},
|
|
15
15
|
useQuery: function() {
|
|
16
16
|
return useQuery;
|
|
17
17
|
},
|
|
18
|
-
|
|
19
|
-
return
|
|
18
|
+
useQueryClient: function() {
|
|
19
|
+
return useQueryClient;
|
|
20
20
|
}
|
|
21
21
|
});
|
|
22
22
|
const _react = _interop_require_wildcard(require("react"));
|
|
@@ -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)) {
|
|
@@ -89,7 +91,7 @@ const useQuery = (key, fn, opt)=>{
|
|
|
89
91
|
context: clientContext
|
|
90
92
|
});
|
|
91
93
|
};
|
|
92
|
-
function SharedQueryClientProvider({ children
|
|
94
|
+
function SharedQueryClientProvider({ children }) {
|
|
93
95
|
const client = useQueryClient();
|
|
94
96
|
return _react.createElement(clientContext.Provider, {
|
|
95
97
|
value: client
|
|
@@ -30,7 +30,7 @@ function useContentTypePermissions(props) {
|
|
|
30
30
|
props.entityType
|
|
31
31
|
]);
|
|
32
32
|
const [creatableContentTypes, setCreatableContentTypes] = (0, _react.useState)(availableContentTypes);
|
|
33
|
-
const { canPerformActionOnEntryOfType
|
|
33
|
+
const { canPerformActionOnEntryOfType } = (0, _useAccessApi.useAccessApi)(props.sdk.access);
|
|
34
34
|
(0, _react.useEffect)(()=>{
|
|
35
35
|
function getContentTypes(action) {
|
|
36
36
|
return filter(availableContentTypes, (ct)=>canPerformActionOnEntryOfType(action, ct.sys.id));
|
|
@@ -13,17 +13,17 @@ const _fromFieldValidations = require("../utils/fromFieldValidations");
|
|
|
13
13
|
const _useAccessApi = require("./useAccessApi");
|
|
14
14
|
const _useContentTypePermissions = require("./useContentTypePermissions");
|
|
15
15
|
function useEditorPermissions(props) {
|
|
16
|
-
const { sdk
|
|
16
|
+
const { sdk, entityType, parameters } = props;
|
|
17
17
|
const validations = (0, _react.useMemo)(()=>(0, _fromFieldValidations.fromFieldValidations)(props.sdk.field), [
|
|
18
18
|
props.sdk.field
|
|
19
19
|
]);
|
|
20
20
|
const [canCreateEntity, setCanCreateEntity] = (0, _react.useState)(true);
|
|
21
21
|
const [canLinkEntity, setCanLinkEntity] = (0, _react.useState)(true);
|
|
22
|
-
const { creatableContentTypes
|
|
22
|
+
const { creatableContentTypes, availableContentTypes } = (0, _useContentTypePermissions.useContentTypePermissions)({
|
|
23
23
|
...props,
|
|
24
24
|
validations
|
|
25
25
|
});
|
|
26
|
-
const { canPerformAction
|
|
26
|
+
const { canPerformAction } = (0, _useAccessApi.useAccessApi)(sdk.access);
|
|
27
27
|
(0, _react.useEffect)(()=>{
|
|
28
28
|
if (parameters.instance.showCreateEntityAction === false) {
|
|
29
29
|
setCanCreateEntity(false);
|