@contentful/field-editor-reference 5.9.0 → 5.10.0
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 +183 -0
- package/dist/cjs/__fixtures__/asset/index.js +37 -0
- package/dist/cjs/__fixtures__/content-type/index.js +16 -0
- package/dist/cjs/__fixtures__/entry/index.js +33 -0
- package/dist/cjs/__fixtures__/fixtures.js +71 -0
- package/dist/cjs/__fixtures__/locale/index.js +40 -0
- package/dist/cjs/__fixtures__/space/index.js +16 -0
- package/dist/cjs/assets/MultipleMediaEditor.js +86 -0
- package/dist/cjs/assets/SingleMediaEditor.js +69 -0
- package/dist/cjs/assets/WrappedAssetCard/AssetCardActions.js +125 -0
- package/dist/cjs/assets/WrappedAssetCard/FetchingWrappedAssetCard.js +171 -0
- package/dist/cjs/assets/WrappedAssetCard/WrappedAssetCard.js +159 -0
- package/dist/cjs/assets/WrappedAssetCard/WrappedAssetLink.js +130 -0
- package/dist/cjs/assets/index.js +24 -0
- package/dist/cjs/common/EntityStore.js +420 -0
- package/dist/cjs/common/MultipleReferenceEditor.js +164 -0
- package/dist/cjs/common/ReferenceEditor.js +74 -0
- package/dist/cjs/common/SingleReferenceEditor.js +118 -0
- package/dist/cjs/common/SortableLinkList.js +95 -0
- package/dist/cjs/common/customCardTypes.js +44 -0
- package/dist/cjs/common/useAccessApi.js +19 -0
- package/dist/cjs/common/useContentTypePermissions.js +54 -0
- package/dist/cjs/common/useEditorPermissions.js +77 -0
- package/dist/cjs/common/useEditorPermissions.spec.js +205 -0
- package/dist/cjs/components/AssetThumbnail/AssetThumbnail.js +62 -0
- package/dist/cjs/components/CreateEntryLinkButton/CreateEntryLinkButton.js +102 -0
- package/dist/cjs/components/CreateEntryLinkButton/CreateEntryLinkButton.spec.js +254 -0
- package/dist/cjs/components/CreateEntryLinkButton/CreateEntryMenuTrigger.js +199 -0
- package/dist/cjs/components/CreateEntryLinkButton/CreateEntryMenuTrigger.spec.js +190 -0
- package/dist/cjs/components/CreateEntryLinkButton/useGlobalMouseUp.js +19 -0
- package/dist/cjs/components/LinkActions/CombinedLinkActions.js +167 -0
- package/dist/cjs/components/LinkActions/LinkActions.js +123 -0
- package/dist/cjs/components/LinkActions/LinkEntityActions.js +186 -0
- package/dist/cjs/components/LinkActions/NoLinkPermissionsInfo.js +54 -0
- package/dist/cjs/components/LinkActions/helpers.js +78 -0
- package/dist/cjs/components/LinkActions/redesignStyles.js +44 -0
- package/dist/cjs/components/LinkActions/styles.js +33 -0
- package/dist/cjs/components/MissingEntityCard/MissingEntityCard.js +75 -0
- package/dist/cjs/components/MissingEntityCard/styles.js +29 -0
- package/dist/cjs/components/ScheduledIconWithTooltip/ScheduleTooltip.js +75 -0
- package/dist/cjs/components/ScheduledIconWithTooltip/ScheduledIconWithTooltip.js +81 -0
- package/dist/cjs/components/ScheduledIconWithTooltip/formatDateAndTime.js +45 -0
- package/dist/cjs/components/SpaceName/SpaceName.js +91 -0
- package/dist/cjs/components/index.js +44 -0
- package/dist/cjs/entries/MultipleEntryReferenceEditor.js +86 -0
- package/dist/cjs/entries/SingleEntryReferenceEditor.js +74 -0
- package/dist/cjs/entries/WrappedEntryCard/FetchingWrappedEntryCard.js +189 -0
- package/dist/cjs/entries/WrappedEntryCard/WrappedEntryCard.js +181 -0
- package/dist/cjs/entries/index.js +24 -0
- package/dist/cjs/index.js +92 -0
- package/dist/cjs/resources/Cards/ContentfulEntryCard.js +87 -0
- package/dist/cjs/resources/Cards/ResourceCard.js +111 -0
- package/dist/cjs/resources/Cards/UnsupportedEntityCard.js +64 -0
- package/dist/cjs/resources/MultipleResourceReferenceEditor.js +157 -0
- package/dist/cjs/resources/MultipleResourceReferenceEditor.spec.js +297 -0
- package/dist/cjs/resources/SingleResourceReferenceEditor.js +87 -0
- package/dist/cjs/resources/SingleResourceReferenceEditor.spec.js +161 -0
- package/dist/cjs/resources/index.js +19 -0
- package/dist/cjs/resources/testHelpers/resourceEditorHelpers.js +121 -0
- package/dist/cjs/resources/useResourceLinkActions.js +88 -0
- package/dist/cjs/types.js +22 -0
- package/dist/cjs/utils/fromFieldValidations.js +54 -0
- package/dist/esm/__fixtures__/FakeSdk.js +173 -0
- package/dist/esm/__fixtures__/asset/index.js +6 -0
- package/dist/esm/__fixtures__/content-type/index.js +2 -0
- package/dist/esm/__fixtures__/entry/index.js +5 -0
- package/dist/esm/__fixtures__/fixtures.js +6 -0
- package/dist/esm/__fixtures__/locale/index.js +15 -0
- package/dist/esm/__fixtures__/space/index.js +2 -0
- package/dist/esm/assets/MultipleMediaEditor.js +37 -0
- package/dist/esm/assets/SingleMediaEditor.js +20 -0
- package/dist/esm/assets/WrappedAssetCard/AssetCardActions.js +63 -0
- package/dist/esm/assets/WrappedAssetCard/FetchingWrappedAssetCard.js +122 -0
- package/dist/esm/assets/WrappedAssetCard/WrappedAssetCard.js +105 -0
- package/dist/esm/assets/WrappedAssetCard/WrappedAssetLink.js +76 -0
- package/dist/esm/assets/index.js +3 -0
- package/dist/esm/common/EntityStore.js +347 -0
- package/dist/esm/common/MultipleReferenceEditor.js +111 -0
- package/dist/esm/common/ReferenceEditor.js +20 -0
- package/dist/esm/common/SingleReferenceEditor.js +70 -0
- package/dist/esm/common/SortableLinkList.js +41 -0
- package/dist/esm/common/customCardTypes.js +1 -0
- package/dist/esm/common/useAccessApi.js +9 -0
- package/dist/esm/common/useContentTypePermissions.js +44 -0
- package/dist/esm/common/useEditorPermissions.js +67 -0
- package/dist/esm/common/useEditorPermissions.spec.js +201 -0
- package/dist/esm/components/AssetThumbnail/AssetThumbnail.js +13 -0
- package/dist/esm/components/CreateEntryLinkButton/CreateEntryLinkButton.js +48 -0
- package/dist/esm/components/CreateEntryLinkButton/CreateEntryLinkButton.spec.js +206 -0
- package/dist/esm/components/CreateEntryLinkButton/CreateEntryMenuTrigger.js +145 -0
- package/dist/esm/components/CreateEntryLinkButton/CreateEntryMenuTrigger.spec.js +142 -0
- package/dist/esm/components/CreateEntryLinkButton/useGlobalMouseUp.js +9 -0
- package/dist/esm/components/LinkActions/CombinedLinkActions.js +118 -0
- package/dist/esm/components/LinkActions/LinkActions.js +66 -0
- package/dist/esm/components/LinkActions/LinkEntityActions.js +127 -0
- package/dist/esm/components/LinkActions/NoLinkPermissionsInfo.js +5 -0
- package/dist/esm/components/LinkActions/helpers.js +57 -0
- package/dist/esm/components/LinkActions/redesignStyles.js +18 -0
- package/dist/esm/components/LinkActions/styles.js +10 -0
- package/dist/esm/components/MissingEntityCard/MissingEntityCard.js +26 -0
- package/dist/esm/components/MissingEntityCard/styles.js +11 -0
- package/dist/esm/components/ScheduledIconWithTooltip/ScheduleTooltip.js +18 -0
- package/dist/esm/components/ScheduledIconWithTooltip/ScheduledIconWithTooltip.js +32 -0
- package/dist/esm/components/ScheduledIconWithTooltip/formatDateAndTime.js +19 -0
- package/dist/esm/components/SpaceName/SpaceName.js +37 -0
- package/dist/esm/components/index.js +8 -0
- package/dist/esm/entries/MultipleEntryReferenceEditor.js +37 -0
- package/dist/esm/entries/SingleEntryReferenceEditor.js +25 -0
- package/dist/esm/entries/WrappedEntryCard/FetchingWrappedEntryCard.js +135 -0
- package/dist/esm/entries/WrappedEntryCard/WrappedEntryCard.js +127 -0
- package/dist/esm/entries/index.js +3 -0
- package/dist/esm/index.js +7 -0
- package/dist/esm/resources/Cards/ContentfulEntryCard.js +38 -0
- package/dist/esm/resources/Cards/ResourceCard.js +62 -0
- package/dist/esm/resources/Cards/UnsupportedEntityCard.js +15 -0
- package/dist/esm/resources/MultipleResourceReferenceEditor.js +104 -0
- package/dist/esm/resources/MultipleResourceReferenceEditor.spec.js +254 -0
- package/dist/esm/resources/SingleResourceReferenceEditor.js +33 -0
- package/dist/esm/resources/SingleResourceReferenceEditor.spec.js +118 -0
- package/dist/esm/resources/index.js +2 -0
- package/dist/esm/resources/testHelpers/resourceEditorHelpers.js +103 -0
- package/dist/esm/resources/useResourceLinkActions.js +78 -0
- package/dist/esm/types.js +1 -0
- package/dist/esm/utils/fromFieldValidations.js +39 -0
- package/dist/{__fixtures__ → types/__fixtures__}/FakeSdk.d.ts +8 -8
- package/dist/{__fixtures__ → types/__fixtures__}/asset/index.d.ts +6 -6
- package/dist/{__fixtures__ → types/__fixtures__}/content-type/index.d.ts +2 -2
- package/dist/{__fixtures__ → types/__fixtures__}/entry/index.d.ts +5 -5
- package/dist/{__fixtures__ → types/__fixtures__}/fixtures.d.ts +6 -6
- package/dist/{__fixtures__ → types/__fixtures__}/locale/index.d.ts +42 -42
- package/dist/{__fixtures__ → types/__fixtures__}/space/index.d.ts +2 -2
- package/dist/{assets → types/assets}/MultipleMediaEditor.d.ts +10 -10
- package/dist/types/assets/SingleMediaEditor.d.ts +10 -0
- package/dist/{assets → types/assets}/WrappedAssetCard/AssetCardActions.d.ts +11 -11
- package/dist/{assets → types/assets}/WrappedAssetCard/FetchingWrappedAssetCard.d.ts +17 -17
- package/dist/{assets → types/assets}/WrappedAssetCard/WrappedAssetCard.d.ts +24 -24
- package/dist/{assets → types/assets}/WrappedAssetCard/WrappedAssetLink.d.ts +16 -16
- package/dist/{assets → types/assets}/index.d.ts +3 -3
- package/dist/{common → types/common}/EntityStore.d.ts +62 -62
- package/dist/{common → types/common}/MultipleReferenceEditor.d.ts +25 -25
- package/dist/{common → types/common}/ReferenceEditor.d.ts +46 -46
- package/dist/{common → types/common}/SingleReferenceEditor.d.ts +24 -24
- package/dist/{common → types/common}/SortableLinkList.d.ts +19 -19
- package/dist/{common → types/common}/customCardTypes.d.ts +29 -29
- package/dist/types/common/useAccessApi.d.ts +16 -0
- package/dist/{common → types/common}/useContentTypePermissions.d.ts +17 -17
- package/dist/{common → types/common}/useEditorPermissions.d.ts +17 -17
- package/dist/types/common/useEditorPermissions.spec.d.ts +1 -0
- package/dist/{components → types/components}/AssetThumbnail/AssetThumbnail.d.ts +7 -7
- package/dist/{components → types/components}/CreateEntryLinkButton/CreateEntryLinkButton.d.ts +19 -19
- package/dist/types/components/CreateEntryLinkButton/CreateEntryLinkButton.spec.d.ts +1 -0
- package/dist/{components → types/components}/CreateEntryLinkButton/CreateEntryMenuTrigger.d.ts +31 -31
- package/dist/types/components/CreateEntryLinkButton/CreateEntryMenuTrigger.spec.d.ts +1 -0
- package/dist/{components → types/components}/CreateEntryLinkButton/useGlobalMouseUp.d.ts +1 -1
- package/dist/{components → types/components}/LinkActions/CombinedLinkActions.d.ts +10 -10
- package/dist/{components → types/components}/LinkActions/LinkActions.d.ts +26 -26
- package/dist/{components → types/components}/LinkActions/LinkEntityActions.d.ts +24 -24
- package/dist/types/components/LinkActions/NoLinkPermissionsInfo.d.ts +2 -0
- package/dist/{components → types/components}/LinkActions/helpers.d.ts +26 -26
- package/dist/{components → types/components}/LinkActions/redesignStyles.d.ts +3 -3
- package/dist/{components → types/components}/LinkActions/styles.d.ts +2 -2
- package/dist/{components → types/components}/MissingEntityCard/MissingEntityCard.d.ts +8 -8
- package/dist/{components → types/components}/MissingEntityCard/styles.d.ts +2 -2
- package/dist/{components → types/components}/ScheduledIconWithTooltip/ScheduleTooltip.d.ts +11 -11
- package/dist/{components → types/components}/ScheduledIconWithTooltip/ScheduledIconWithTooltip.d.ts +10 -10
- package/dist/{components → types/components}/ScheduledIconWithTooltip/formatDateAndTime.d.ts +15 -15
- package/dist/types/components/SpaceName/SpaceName.d.ts +6 -0
- package/dist/{components → types/components}/index.d.ts +9 -9
- package/dist/{entries → types/entries}/MultipleEntryReferenceEditor.d.ts +3 -3
- package/dist/{entries → types/entries}/SingleEntryReferenceEditor.d.ts +8 -8
- package/dist/{entries → types/entries}/WrappedEntryCard/FetchingWrappedEntryCard.d.ts +18 -18
- package/dist/{entries → types/entries}/WrappedEntryCard/WrappedEntryCard.d.ts +35 -35
- package/dist/{entries → types/entries}/index.d.ts +3 -3
- package/dist/{index.d.ts → types/index.d.ts} +9 -8
- package/dist/{resources → types/resources}/Cards/ContentfulEntryCard.d.ts +21 -21
- package/dist/{resources → types/resources}/Cards/ResourceCard.d.ts +12 -12
- package/dist/{resources → types/resources}/Cards/UnsupportedEntityCard.d.ts +4 -4
- package/dist/{resources → types/resources}/MultipleResourceReferenceEditor.d.ts +7 -7
- package/dist/types/resources/MultipleResourceReferenceEditor.spec.d.ts +1 -0
- package/dist/{resources → types/resources}/SingleResourceReferenceEditor.d.ts +7 -7
- package/dist/types/resources/SingleResourceReferenceEditor.spec.d.ts +1 -0
- package/dist/{resources → types/resources}/index.d.ts +2 -2
- package/dist/{resources → types/resources}/testHelpers/resourceEditorHelpers.d.ts +50 -50
- package/dist/{resources → types/resources}/useResourceLinkActions.d.ts +7 -7
- package/dist/{types.d.ts → types/types.d.ts} +104 -104
- package/dist/{utils → types/utils}/fromFieldValidations.d.ts +21 -21
- package/package.json +25 -11
- package/CHANGELOG.md +0 -860
- package/dist/assets/SingleMediaEditor.d.ts +0 -10
- package/dist/common/useAccessApi.d.ts +0 -16
- package/dist/components/LinkActions/NoLinkPermissionsInfo.d.ts +0 -2
- package/dist/components/SpaceName/SpaceName.d.ts +0 -6
- package/dist/field-editor-reference.cjs.development.js +0 -2753
- package/dist/field-editor-reference.cjs.development.js.map +0 -1
- package/dist/field-editor-reference.cjs.production.min.js +0 -2
- package/dist/field-editor-reference.cjs.production.min.js.map +0 -1
- package/dist/field-editor-reference.esm.js +0 -2727
- package/dist/field-editor-reference.esm.js.map +0 -1
- package/dist/index.js +0 -8
|
@@ -0,0 +1,420 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: all[name]
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
UnsupportedError: function() {
|
|
13
|
+
return UnsupportedError;
|
|
14
|
+
},
|
|
15
|
+
isUnsupportedError: function() {
|
|
16
|
+
return isUnsupportedError;
|
|
17
|
+
},
|
|
18
|
+
useEntity: function() {
|
|
19
|
+
return useEntity;
|
|
20
|
+
},
|
|
21
|
+
useResource: function() {
|
|
22
|
+
return useResource;
|
|
23
|
+
},
|
|
24
|
+
EntityProvider: function() {
|
|
25
|
+
return EntityProvider;
|
|
26
|
+
},
|
|
27
|
+
useEntityLoader: function() {
|
|
28
|
+
return useEntityLoader;
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
const _react = _interop_require_wildcard(require("react"));
|
|
32
|
+
const _reactquery = require("@tanstack/react-query");
|
|
33
|
+
const _constate = _interop_require_default(require("constate"));
|
|
34
|
+
const _contentfulmanagement = require("contentful-management");
|
|
35
|
+
const _pqueue = _interop_require_default(require("p-queue"));
|
|
36
|
+
function _define_property(obj, key, value) {
|
|
37
|
+
if (key in obj) {
|
|
38
|
+
Object.defineProperty(obj, key, {
|
|
39
|
+
value: value,
|
|
40
|
+
enumerable: true,
|
|
41
|
+
configurable: true,
|
|
42
|
+
writable: true
|
|
43
|
+
});
|
|
44
|
+
} else {
|
|
45
|
+
obj[key] = value;
|
|
46
|
+
}
|
|
47
|
+
return obj;
|
|
48
|
+
}
|
|
49
|
+
function _interop_require_default(obj) {
|
|
50
|
+
return obj && obj.__esModule ? obj : {
|
|
51
|
+
default: obj
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
function _getRequireWildcardCache(nodeInterop) {
|
|
55
|
+
if (typeof WeakMap !== "function") return null;
|
|
56
|
+
var cacheBabelInterop = new WeakMap();
|
|
57
|
+
var cacheNodeInterop = new WeakMap();
|
|
58
|
+
return (_getRequireWildcardCache = function(nodeInterop) {
|
|
59
|
+
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
60
|
+
})(nodeInterop);
|
|
61
|
+
}
|
|
62
|
+
function _interop_require_wildcard(obj, nodeInterop) {
|
|
63
|
+
if (!nodeInterop && obj && obj.__esModule) {
|
|
64
|
+
return obj;
|
|
65
|
+
}
|
|
66
|
+
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
67
|
+
return {
|
|
68
|
+
default: obj
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
var cache = _getRequireWildcardCache(nodeInterop);
|
|
72
|
+
if (cache && cache.has(obj)) {
|
|
73
|
+
return cache.get(obj);
|
|
74
|
+
}
|
|
75
|
+
var newObj = {};
|
|
76
|
+
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
77
|
+
for(var key in obj){
|
|
78
|
+
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
79
|
+
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
80
|
+
if (desc && (desc.get || desc.set)) {
|
|
81
|
+
Object.defineProperty(newObj, key, desc);
|
|
82
|
+
} else {
|
|
83
|
+
newObj[key] = obj[key];
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
newObj.default = obj;
|
|
88
|
+
if (cache) {
|
|
89
|
+
cache.set(obj, newObj);
|
|
90
|
+
}
|
|
91
|
+
return newObj;
|
|
92
|
+
}
|
|
93
|
+
const globalQueue = new _pqueue.default({
|
|
94
|
+
concurrency: 50
|
|
95
|
+
});
|
|
96
|
+
class UnsupportedError extends Error {
|
|
97
|
+
constructor(message){
|
|
98
|
+
super(message);
|
|
99
|
+
_define_property(this, "isUnsupportedError", void 0);
|
|
100
|
+
this.isUnsupportedError = true;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
function isUnsupportedError(value) {
|
|
104
|
+
return typeof value === 'object' && value?.isUnsupportedError === true;
|
|
105
|
+
}
|
|
106
|
+
const isEntityQueryKey = (queryKey)=>{
|
|
107
|
+
return Array.isArray(queryKey) && (queryKey[0] === 'Entry' || queryKey[0] === 'Asset') && queryKey.length === 4;
|
|
108
|
+
};
|
|
109
|
+
async function fetchContentfulEntry(params) {
|
|
110
|
+
const { urn , fetch , options } = params;
|
|
111
|
+
const resourceId = urn.split(':', 6)[5];
|
|
112
|
+
const [, spaceId, , entryId] = resourceId.split('/');
|
|
113
|
+
const environmentId = 'master';
|
|
114
|
+
const [space, entry] = await Promise.all([
|
|
115
|
+
fetch([
|
|
116
|
+
'space',
|
|
117
|
+
spaceId
|
|
118
|
+
], ({ cmaClient })=>cmaClient.space.get({
|
|
119
|
+
spaceId
|
|
120
|
+
}), options),
|
|
121
|
+
fetch([
|
|
122
|
+
'entry',
|
|
123
|
+
spaceId,
|
|
124
|
+
environmentId,
|
|
125
|
+
entryId
|
|
126
|
+
], ({ cmaClient })=>cmaClient.entry.get({
|
|
127
|
+
spaceId,
|
|
128
|
+
environmentId,
|
|
129
|
+
entryId
|
|
130
|
+
}), options)
|
|
131
|
+
]);
|
|
132
|
+
const contentTypeId = entry.sys.contentType.sys.id;
|
|
133
|
+
const [contentType, defaultLocaleCode] = await Promise.all([
|
|
134
|
+
fetch([
|
|
135
|
+
'contentType',
|
|
136
|
+
spaceId,
|
|
137
|
+
environmentId,
|
|
138
|
+
contentTypeId
|
|
139
|
+
], ({ cmaClient })=>cmaClient.contentType.get({
|
|
140
|
+
contentTypeId,
|
|
141
|
+
spaceId,
|
|
142
|
+
environmentId
|
|
143
|
+
}), options),
|
|
144
|
+
fetch([
|
|
145
|
+
'defaultLocale',
|
|
146
|
+
spaceId,
|
|
147
|
+
environmentId
|
|
148
|
+
], async ({ cmaClient })=>{
|
|
149
|
+
const locales = await cmaClient.locale.getMany({
|
|
150
|
+
spaceId,
|
|
151
|
+
environmentId,
|
|
152
|
+
query: {
|
|
153
|
+
limit: 100
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
const defaultLocaleCode = locales.items.find((locale)=>locale.default)?.code;
|
|
157
|
+
return defaultLocaleCode;
|
|
158
|
+
}, options)
|
|
159
|
+
]);
|
|
160
|
+
return {
|
|
161
|
+
defaultLocaleCode,
|
|
162
|
+
resource: entry,
|
|
163
|
+
space: space,
|
|
164
|
+
contentType: contentType
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
const [InternalServiceProvider, useFetch, useEntityLoader, useCurrentIds] = (0, _constate.default)(function useInitServices(props) {
|
|
168
|
+
const currentSpaceId = props.sdk.ids.space;
|
|
169
|
+
const currentEnvironmentId = props.sdk.ids.environmentAlias ?? props.sdk.ids.environment;
|
|
170
|
+
const environmentIds = (0, _react.useMemo)(()=>[
|
|
171
|
+
props.sdk.ids.environmentAlias,
|
|
172
|
+
props.sdk.ids.environment
|
|
173
|
+
], [
|
|
174
|
+
props.sdk.ids.environmentAlias,
|
|
175
|
+
props.sdk.ids.environment
|
|
176
|
+
]);
|
|
177
|
+
const queryClient = (0, _reactquery.useQueryClient)();
|
|
178
|
+
const queryCache = queryClient.getQueryCache();
|
|
179
|
+
const entityChangeUnsubscribers = (0, _react.useRef)({});
|
|
180
|
+
const cmaClient = (0, _react.useMemo)(()=>(0, _contentfulmanagement.createClient)({
|
|
181
|
+
apiAdapter: props.sdk.cmaAdapter
|
|
182
|
+
}, {
|
|
183
|
+
type: 'plain'
|
|
184
|
+
}), [
|
|
185
|
+
props.sdk.cmaAdapter
|
|
186
|
+
]);
|
|
187
|
+
const queryQueue = (0, _react.useMemo)(()=>{
|
|
188
|
+
if (props.queryConcurrency) {
|
|
189
|
+
return new _pqueue.default({
|
|
190
|
+
concurrency: props.queryConcurrency
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
return globalQueue;
|
|
194
|
+
}, [
|
|
195
|
+
props.queryConcurrency
|
|
196
|
+
]);
|
|
197
|
+
const fetch = (0, _react.useCallback)(function fetch(queryKey, fn, options = {}) {
|
|
198
|
+
const { priority , ...queryOptions } = options;
|
|
199
|
+
return queryClient.fetchQuery(queryKey, ()=>queryQueue.add(()=>fn({
|
|
200
|
+
cmaClient
|
|
201
|
+
}), {
|
|
202
|
+
priority
|
|
203
|
+
}), queryOptions);
|
|
204
|
+
}, [
|
|
205
|
+
queryClient,
|
|
206
|
+
queryQueue,
|
|
207
|
+
cmaClient
|
|
208
|
+
]);
|
|
209
|
+
const getEntity = (0, _react.useCallback)(function getEntity(entityType, entityId, options) {
|
|
210
|
+
const spaceId = options?.spaceId ?? currentSpaceId;
|
|
211
|
+
const environmentId = options?.environmentId ?? currentEnvironmentId;
|
|
212
|
+
const queryKey = [
|
|
213
|
+
entityType,
|
|
214
|
+
entityId,
|
|
215
|
+
spaceId,
|
|
216
|
+
environmentId
|
|
217
|
+
];
|
|
218
|
+
return fetch(queryKey, ({ cmaClient })=>{
|
|
219
|
+
if (entityType === 'Entry') {
|
|
220
|
+
return cmaClient.entry.get({
|
|
221
|
+
entryId: entityId,
|
|
222
|
+
spaceId,
|
|
223
|
+
environmentId
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
if (entityType === 'Asset') {
|
|
227
|
+
return cmaClient.asset.get({
|
|
228
|
+
assetId: entityId,
|
|
229
|
+
spaceId,
|
|
230
|
+
environmentId
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
throw new UnsupportedError('Unsupported entity type');
|
|
234
|
+
}, options);
|
|
235
|
+
}, [
|
|
236
|
+
fetch,
|
|
237
|
+
currentSpaceId,
|
|
238
|
+
currentEnvironmentId
|
|
239
|
+
]);
|
|
240
|
+
const getEntityScheduledActions = (0, _react.useCallback)(function getEntityScheduledActions(entityType, entityId, options) {
|
|
241
|
+
const fixedEntityCacheId = 'scheduledActionEntityId';
|
|
242
|
+
const maxScheduledActions = 500;
|
|
243
|
+
const spaceId = options?.spaceId ?? currentSpaceId;
|
|
244
|
+
const environmentId = options?.environmentId ?? currentEnvironmentId;
|
|
245
|
+
const queryKey = [
|
|
246
|
+
'scheduled-actions',
|
|
247
|
+
entityType,
|
|
248
|
+
fixedEntityCacheId,
|
|
249
|
+
spaceId,
|
|
250
|
+
environmentId
|
|
251
|
+
];
|
|
252
|
+
return fetch(queryKey, async ({ cmaClient })=>{
|
|
253
|
+
const response = await cmaClient.scheduledActions.getMany({
|
|
254
|
+
spaceId,
|
|
255
|
+
query: {
|
|
256
|
+
'environment.sys.id': environmentId,
|
|
257
|
+
'sys.status[in]': 'scheduled',
|
|
258
|
+
order: 'scheduledFor.datetime',
|
|
259
|
+
limit: maxScheduledActions
|
|
260
|
+
}
|
|
261
|
+
});
|
|
262
|
+
return response.items;
|
|
263
|
+
}, options).then((items)=>items.filter((action)=>action.entity.sys.id === entityId));
|
|
264
|
+
}, [
|
|
265
|
+
fetch,
|
|
266
|
+
currentSpaceId,
|
|
267
|
+
currentEnvironmentId
|
|
268
|
+
]);
|
|
269
|
+
const getResource = (0, _react.useCallback)(function getResource(resourceType, urn, options) {
|
|
270
|
+
const queryKey = [
|
|
271
|
+
'Resource',
|
|
272
|
+
resourceType,
|
|
273
|
+
urn
|
|
274
|
+
];
|
|
275
|
+
return fetch(queryKey, ()=>{
|
|
276
|
+
if (resourceType === 'Contentful:Entry') {
|
|
277
|
+
return fetchContentfulEntry({
|
|
278
|
+
fetch,
|
|
279
|
+
urn,
|
|
280
|
+
options
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
throw new UnsupportedError('Unsupported resource type');
|
|
284
|
+
}, options);
|
|
285
|
+
}, [
|
|
286
|
+
fetch
|
|
287
|
+
]);
|
|
288
|
+
const isSameSpaceEntityQueryKey = (0, _react.useCallback)((queryKey)=>{
|
|
289
|
+
const isEntityKey = isEntityQueryKey(queryKey);
|
|
290
|
+
const isSameSpaceEntityKey = isEntityKey && queryKey[2] === currentSpaceId && environmentIds.includes(queryKey[3]);
|
|
291
|
+
return isSameSpaceEntityKey;
|
|
292
|
+
}, [
|
|
293
|
+
currentSpaceId,
|
|
294
|
+
environmentIds
|
|
295
|
+
]);
|
|
296
|
+
const onEntityChanged = props.sdk.space.onEntityChanged;
|
|
297
|
+
const onSlideInNavigation = props.sdk.navigator.onSlideInNavigation;
|
|
298
|
+
(0, _react.useEffect)(()=>{
|
|
299
|
+
function findSameSpaceQueries() {
|
|
300
|
+
return queryCache.findAll({
|
|
301
|
+
type: 'active',
|
|
302
|
+
predicate: (query)=>isSameSpaceEntityQueryKey(query.queryKey)
|
|
303
|
+
});
|
|
304
|
+
}
|
|
305
|
+
if (typeof onEntityChanged !== 'function') {
|
|
306
|
+
return onSlideInNavigation(({ oldSlideLevel , newSlideLevel })=>{
|
|
307
|
+
if (oldSlideLevel > newSlideLevel) {
|
|
308
|
+
findSameSpaceQueries().forEach((query)=>{
|
|
309
|
+
void queryClient.invalidateQueries(query.queryKey);
|
|
310
|
+
});
|
|
311
|
+
}
|
|
312
|
+
});
|
|
313
|
+
}
|
|
314
|
+
const subscribeQuery = ({ queryKey , queryHash })=>{
|
|
315
|
+
const [entityType, entityId] = queryKey;
|
|
316
|
+
entityChangeUnsubscribers.current[queryHash] = onEntityChanged(entityType, entityId, (data)=>{
|
|
317
|
+
queryClient.setQueryData(queryKey, data);
|
|
318
|
+
});
|
|
319
|
+
};
|
|
320
|
+
findSameSpaceQueries().forEach(subscribeQuery);
|
|
321
|
+
const unsubscribe = queryCache.subscribe((event)=>{
|
|
322
|
+
if (!event) {
|
|
323
|
+
return;
|
|
324
|
+
}
|
|
325
|
+
const { type , query } = event;
|
|
326
|
+
const { queryKey , queryHash } = query;
|
|
327
|
+
if (!isSameSpaceEntityQueryKey(queryKey)) {
|
|
328
|
+
return;
|
|
329
|
+
}
|
|
330
|
+
if (type === 'added') {
|
|
331
|
+
subscribeQuery(query);
|
|
332
|
+
}
|
|
333
|
+
if (type === 'removed') {
|
|
334
|
+
entityChangeUnsubscribers.current[queryHash]?.();
|
|
335
|
+
}
|
|
336
|
+
});
|
|
337
|
+
return ()=>{
|
|
338
|
+
unsubscribe();
|
|
339
|
+
Object.values(entityChangeUnsubscribers.current).forEach((off)=>off());
|
|
340
|
+
entityChangeUnsubscribers.current = {};
|
|
341
|
+
};
|
|
342
|
+
}, [
|
|
343
|
+
onEntityChanged,
|
|
344
|
+
queryCache,
|
|
345
|
+
isSameSpaceEntityQueryKey,
|
|
346
|
+
queryClient,
|
|
347
|
+
getEntity,
|
|
348
|
+
onSlideInNavigation
|
|
349
|
+
]);
|
|
350
|
+
return {
|
|
351
|
+
ids: props.sdk.ids,
|
|
352
|
+
cmaClient,
|
|
353
|
+
fetch,
|
|
354
|
+
getResource,
|
|
355
|
+
getEntity,
|
|
356
|
+
getEntityScheduledActions
|
|
357
|
+
};
|
|
358
|
+
}, ({ fetch })=>fetch, ({ getResource , getEntity , getEntityScheduledActions })=>({
|
|
359
|
+
getResource,
|
|
360
|
+
getEntity,
|
|
361
|
+
getEntityScheduledActions
|
|
362
|
+
}), ({ ids })=>({
|
|
363
|
+
environment: ids.environmentAlias ?? ids.environment,
|
|
364
|
+
space: ids.space
|
|
365
|
+
}));
|
|
366
|
+
function useEntity(entityType, entityId, options) {
|
|
367
|
+
const { space , environment } = useCurrentIds();
|
|
368
|
+
const { getEntity } = useEntityLoader();
|
|
369
|
+
const queryKey = [
|
|
370
|
+
entityType,
|
|
371
|
+
entityId,
|
|
372
|
+
options?.spaceId ?? space,
|
|
373
|
+
options?.environmentId ?? environment
|
|
374
|
+
];
|
|
375
|
+
const { status , data } = (0, _reactquery.useQuery)(queryKey, ()=>getEntity(entityType, entityId, options), {
|
|
376
|
+
enabled: options?.enabled
|
|
377
|
+
});
|
|
378
|
+
return {
|
|
379
|
+
status,
|
|
380
|
+
data
|
|
381
|
+
};
|
|
382
|
+
}
|
|
383
|
+
function useResource(resourceType, urn, options) {
|
|
384
|
+
const queryKey = [
|
|
385
|
+
'Resource',
|
|
386
|
+
resourceType,
|
|
387
|
+
urn
|
|
388
|
+
];
|
|
389
|
+
const { getResource } = useEntityLoader();
|
|
390
|
+
const { status , data , error } = (0, _reactquery.useQuery)(queryKey, ()=>getResource(resourceType, urn, options), {
|
|
391
|
+
enabled: options?.enabled
|
|
392
|
+
});
|
|
393
|
+
return {
|
|
394
|
+
status,
|
|
395
|
+
data,
|
|
396
|
+
error
|
|
397
|
+
};
|
|
398
|
+
}
|
|
399
|
+
function EntityProvider({ children , ...props }) {
|
|
400
|
+
const reactQueryClient = (0, _react.useMemo)(()=>{
|
|
401
|
+
const queryCache = new _reactquery.QueryCache();
|
|
402
|
+
const queryClient = new _reactquery.QueryClient({
|
|
403
|
+
queryCache,
|
|
404
|
+
defaultOptions: {
|
|
405
|
+
queries: {
|
|
406
|
+
useErrorBoundary: false,
|
|
407
|
+
refetchOnWindowFocus: false,
|
|
408
|
+
refetchOnReconnect: true,
|
|
409
|
+
refetchOnMount: false,
|
|
410
|
+
staleTime: Infinity,
|
|
411
|
+
retry: false
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
});
|
|
415
|
+
return queryClient;
|
|
416
|
+
}, []);
|
|
417
|
+
return _react.default.createElement(_reactquery.QueryClientProvider, {
|
|
418
|
+
client: reactQueryClient
|
|
419
|
+
}, _react.default.createElement(InternalServiceProvider, props, children));
|
|
420
|
+
}
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "MultipleReferenceEditor", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return MultipleReferenceEditor;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _react = _interop_require_wildcard(require("react"));
|
|
12
|
+
const _arraymove = _interop_require_default(require("array-move"));
|
|
13
|
+
const _components = require("../components");
|
|
14
|
+
const _LinkEntityActions = require("../components/LinkActions/LinkEntityActions");
|
|
15
|
+
const _ReferenceEditor = require("./ReferenceEditor");
|
|
16
|
+
const _useEditorPermissions = require("./useEditorPermissions");
|
|
17
|
+
function _interop_require_default(obj) {
|
|
18
|
+
return obj && obj.__esModule ? obj : {
|
|
19
|
+
default: obj
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
function _getRequireWildcardCache(nodeInterop) {
|
|
23
|
+
if (typeof WeakMap !== "function") return null;
|
|
24
|
+
var cacheBabelInterop = new WeakMap();
|
|
25
|
+
var cacheNodeInterop = new WeakMap();
|
|
26
|
+
return (_getRequireWildcardCache = function(nodeInterop) {
|
|
27
|
+
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
28
|
+
})(nodeInterop);
|
|
29
|
+
}
|
|
30
|
+
function _interop_require_wildcard(obj, nodeInterop) {
|
|
31
|
+
if (!nodeInterop && obj && obj.__esModule) {
|
|
32
|
+
return obj;
|
|
33
|
+
}
|
|
34
|
+
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
35
|
+
return {
|
|
36
|
+
default: obj
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
var cache = _getRequireWildcardCache(nodeInterop);
|
|
40
|
+
if (cache && cache.has(obj)) {
|
|
41
|
+
return cache.get(obj);
|
|
42
|
+
}
|
|
43
|
+
var newObj = {};
|
|
44
|
+
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
45
|
+
for(var key in obj){
|
|
46
|
+
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
47
|
+
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
48
|
+
if (desc && (desc.get || desc.set)) {
|
|
49
|
+
Object.defineProperty(newObj, key, desc);
|
|
50
|
+
} else {
|
|
51
|
+
newObj[key] = obj[key];
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
newObj.default = obj;
|
|
56
|
+
if (cache) {
|
|
57
|
+
cache.set(obj, newObj);
|
|
58
|
+
}
|
|
59
|
+
return newObj;
|
|
60
|
+
}
|
|
61
|
+
function onLinkOrCreate(setValue, entityType, items, ids, index = items.length) {
|
|
62
|
+
const links = ids.map((id)=>({
|
|
63
|
+
sys: {
|
|
64
|
+
type: 'Link',
|
|
65
|
+
linkType: entityType,
|
|
66
|
+
id
|
|
67
|
+
}
|
|
68
|
+
}));
|
|
69
|
+
const newItems = Array.from(items);
|
|
70
|
+
newItems.splice(index, 0, ...links);
|
|
71
|
+
setValue(newItems);
|
|
72
|
+
}
|
|
73
|
+
const emptyArray = [];
|
|
74
|
+
const nullableValue = {
|
|
75
|
+
sys: {
|
|
76
|
+
id: 'null-value'
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
function Editor(props) {
|
|
80
|
+
const { setValue , entityType , setIndexToUpdate } = props;
|
|
81
|
+
const editorPermissions = (0, _useEditorPermissions.useEditorPermissions)(props);
|
|
82
|
+
const items = _react.useMemo(()=>{
|
|
83
|
+
return (props.items || []).map((link)=>link || nullableValue);
|
|
84
|
+
}, [
|
|
85
|
+
props.items
|
|
86
|
+
]);
|
|
87
|
+
const onSortStart = (0, _react.useCallback)((_, event)=>{
|
|
88
|
+
if (event instanceof MouseEvent) {
|
|
89
|
+
document.body.classList.add('grabbing');
|
|
90
|
+
}
|
|
91
|
+
event.preventDefault();
|
|
92
|
+
}, []);
|
|
93
|
+
const onSortEnd = (0, _react.useCallback)(({ oldIndex , newIndex })=>{
|
|
94
|
+
props.onSortingEnd && props.onSortingEnd({
|
|
95
|
+
oldIndex,
|
|
96
|
+
newIndex
|
|
97
|
+
});
|
|
98
|
+
const newItems = (0, _arraymove.default)(items, oldIndex, newIndex);
|
|
99
|
+
setValue(newItems);
|
|
100
|
+
setIndexToUpdate && setIndexToUpdate(undefined);
|
|
101
|
+
document.body.classList.remove('grabbing');
|
|
102
|
+
}, [
|
|
103
|
+
items,
|
|
104
|
+
props,
|
|
105
|
+
setIndexToUpdate,
|
|
106
|
+
setValue
|
|
107
|
+
]);
|
|
108
|
+
const onMove = (0, _react.useCallback)((oldIndex, newIndex)=>{
|
|
109
|
+
const newItems = (0, _arraymove.default)(items, oldIndex, newIndex);
|
|
110
|
+
setValue(newItems);
|
|
111
|
+
}, [
|
|
112
|
+
items,
|
|
113
|
+
setValue
|
|
114
|
+
]);
|
|
115
|
+
const onCreate = (0, _react.useCallback)((id, index)=>onLinkOrCreate(setValue, entityType, items, [
|
|
116
|
+
id
|
|
117
|
+
], index), [
|
|
118
|
+
setValue,
|
|
119
|
+
items,
|
|
120
|
+
entityType
|
|
121
|
+
]);
|
|
122
|
+
const onLink = (0, _react.useCallback)((ids, index)=>onLinkOrCreate(setValue, entityType, items, ids, index), [
|
|
123
|
+
setValue,
|
|
124
|
+
items,
|
|
125
|
+
entityType
|
|
126
|
+
]);
|
|
127
|
+
const linkActionsProps = (0, _LinkEntityActions.useLinkActionsProps)({
|
|
128
|
+
...props,
|
|
129
|
+
canLinkMultiple: true,
|
|
130
|
+
editorPermissions,
|
|
131
|
+
onCreate,
|
|
132
|
+
onLink,
|
|
133
|
+
itemsLength: items.length
|
|
134
|
+
});
|
|
135
|
+
const customCardRenderer = (0, _react.useCallback)((cardProps, _, renderDefaultCard)=>props.renderCustomCard ? props.renderCustomCard(cardProps, linkActionsProps, renderDefaultCard) : false, [
|
|
136
|
+
linkActionsProps
|
|
137
|
+
]);
|
|
138
|
+
return _react.createElement(_react.Fragment, null, props.children({
|
|
139
|
+
...props,
|
|
140
|
+
onSortStart: onSortStart,
|
|
141
|
+
onSortEnd: onSortEnd,
|
|
142
|
+
onMove,
|
|
143
|
+
renderCustomCard: props.renderCustomCard && customCardRenderer
|
|
144
|
+
}), _react.createElement(_components.LinkEntityActions, {
|
|
145
|
+
renderCustomActions: props.renderCustomActions,
|
|
146
|
+
...linkActionsProps
|
|
147
|
+
}));
|
|
148
|
+
}
|
|
149
|
+
function MultipleReferenceEditor(props) {
|
|
150
|
+
const allContentTypes = props.sdk.space.getCachedContentTypes();
|
|
151
|
+
return _react.createElement(_ReferenceEditor.ReferenceEditor, props, ({ value , disabled , setValue , externalReset })=>{
|
|
152
|
+
return _react.createElement(Editor, {
|
|
153
|
+
...props,
|
|
154
|
+
items: value || emptyArray,
|
|
155
|
+
isDisabled: disabled,
|
|
156
|
+
setValue: setValue,
|
|
157
|
+
key: `${externalReset}-list`,
|
|
158
|
+
allContentTypes: allContentTypes
|
|
159
|
+
});
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
MultipleReferenceEditor.defaultProps = {
|
|
163
|
+
hasCardEditActions: true
|
|
164
|
+
};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "ReferenceEditor", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return ReferenceEditor;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _react = _interop_require_wildcard(require("react"));
|
|
12
|
+
const _fieldeditorshared = require("@contentful/field-editor-shared");
|
|
13
|
+
const _deepequal = _interop_require_default(require("deep-equal"));
|
|
14
|
+
const _EntityStore = require("./EntityStore");
|
|
15
|
+
function _interop_require_default(obj) {
|
|
16
|
+
return obj && obj.__esModule ? obj : {
|
|
17
|
+
default: obj
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
function _getRequireWildcardCache(nodeInterop) {
|
|
21
|
+
if (typeof WeakMap !== "function") return null;
|
|
22
|
+
var cacheBabelInterop = new WeakMap();
|
|
23
|
+
var cacheNodeInterop = new WeakMap();
|
|
24
|
+
return (_getRequireWildcardCache = function(nodeInterop) {
|
|
25
|
+
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
26
|
+
})(nodeInterop);
|
|
27
|
+
}
|
|
28
|
+
function _interop_require_wildcard(obj, nodeInterop) {
|
|
29
|
+
if (!nodeInterop && obj && obj.__esModule) {
|
|
30
|
+
return obj;
|
|
31
|
+
}
|
|
32
|
+
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
33
|
+
return {
|
|
34
|
+
default: obj
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
var cache = _getRequireWildcardCache(nodeInterop);
|
|
38
|
+
if (cache && cache.has(obj)) {
|
|
39
|
+
return cache.get(obj);
|
|
40
|
+
}
|
|
41
|
+
var newObj = {};
|
|
42
|
+
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
43
|
+
for(var key in obj){
|
|
44
|
+
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
45
|
+
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
46
|
+
if (desc && (desc.get || desc.set)) {
|
|
47
|
+
Object.defineProperty(newObj, key, desc);
|
|
48
|
+
} else {
|
|
49
|
+
newObj[key] = obj[key];
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
newObj.default = obj;
|
|
54
|
+
if (cache) {
|
|
55
|
+
cache.set(obj, newObj);
|
|
56
|
+
}
|
|
57
|
+
return newObj;
|
|
58
|
+
}
|
|
59
|
+
function ReferenceEditor(props) {
|
|
60
|
+
return _react.createElement(_EntityStore.EntityProvider, {
|
|
61
|
+
sdk: props.sdk
|
|
62
|
+
}, _react.createElement(_fieldeditorshared.FieldConnector, {
|
|
63
|
+
throttle: 0,
|
|
64
|
+
field: props.sdk.field,
|
|
65
|
+
isInitiallyDisabled: props.isInitiallyDisabled,
|
|
66
|
+
isEqualValues: (value1, value2)=>{
|
|
67
|
+
return (0, _deepequal.default)(value1, value2);
|
|
68
|
+
}
|
|
69
|
+
}, props.children));
|
|
70
|
+
}
|
|
71
|
+
ReferenceEditor.defaultProps = {
|
|
72
|
+
isInitiallyDisabled: true,
|
|
73
|
+
hasCardEditActions: true
|
|
74
|
+
};
|