@contentful/field-editor-reference 4.6.9 → 5.1.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/CHANGELOG.md +24 -0
- package/dist/assets/WrappedAssetCard/AssetCardActions.d.ts +1 -1
- package/dist/common/EntityStore.d.ts +55 -5
- package/dist/common/ReferenceEditor.d.ts +1 -1
- package/dist/common/useAccessApi.d.ts +1 -1
- package/dist/components/LinkActions/LinkEntityActions.d.ts +1 -1
- package/dist/components/LinkActions/helpers.d.ts +3 -3
- package/dist/field-editor-reference.cjs.development.js +991 -560
- package/dist/field-editor-reference.cjs.development.js.map +1 -1
- package/dist/field-editor-reference.cjs.production.min.js +1 -1
- package/dist/field-editor-reference.cjs.production.min.js.map +1 -1
- package/dist/field-editor-reference.esm.js +988 -561
- package/dist/field-editor-reference.esm.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/resources/Cards/ContentfulEntryCard.d.ts +21 -0
- package/dist/resources/Cards/ResourceCard.d.ts +12 -0
- package/dist/resources/Cards/UnsupportedEntityCard.d.ts +4 -0
- package/dist/resources/MultipleResourceReferenceEditor.d.ts +7 -0
- package/dist/resources/SingleResourceReferenceEditor.d.ts +7 -0
- package/dist/resources/index.d.ts +2 -0
- package/dist/resources/testHelpers/resourceEditorHelpers.d.ts +50 -0
- package/dist/resources/useResourceLinkActions.d.ts +7 -0
- package/dist/types.d.ts +10 -0
- package/package.json +6 -3
|
@@ -12,14 +12,17 @@ var get = _interopDefault(require('lodash/get'));
|
|
|
12
12
|
var f36Components = require('@contentful/f36-components');
|
|
13
13
|
var f36Icons = require('@contentful/f36-icons');
|
|
14
14
|
var moment = _interopDefault(require('moment'));
|
|
15
|
-
var deepEqual = _interopDefault(require('deep-equal'));
|
|
16
15
|
var fieldEditorShared = require('@contentful/field-editor-shared');
|
|
16
|
+
var deepEqual = _interopDefault(require('deep-equal'));
|
|
17
|
+
var reactQuery = require('@tanstack/react-query');
|
|
17
18
|
var constate = _interopDefault(require('constate'));
|
|
18
19
|
var contentfulManagement = require('contentful-management');
|
|
20
|
+
var PQueue = _interopDefault(require('p-queue'));
|
|
19
21
|
var isNumber = _interopDefault(require('lodash/isNumber'));
|
|
20
22
|
var arrayMove = _interopDefault(require('array-move'));
|
|
21
23
|
var reactSortableHoc = require('react-sortable-hoc');
|
|
22
24
|
var mimetype = _interopDefault(require('@contentful/mimetype'));
|
|
25
|
+
var reactIntersectionObserver = require('react-intersection-observer');
|
|
23
26
|
|
|
24
27
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
25
28
|
try {
|
|
@@ -75,57 +78,110 @@ function _extends() {
|
|
|
75
78
|
return _extends.apply(this, arguments);
|
|
76
79
|
}
|
|
77
80
|
|
|
78
|
-
function
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
var sourceKeys = Object.keys(source);
|
|
82
|
-
var key, i;
|
|
81
|
+
function _inheritsLoose(subClass, superClass) {
|
|
82
|
+
subClass.prototype = Object.create(superClass.prototype);
|
|
83
|
+
subClass.prototype.constructor = subClass;
|
|
83
84
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
85
|
+
_setPrototypeOf(subClass, superClass);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function _getPrototypeOf(o) {
|
|
89
|
+
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
|
|
90
|
+
return o.__proto__ || Object.getPrototypeOf(o);
|
|
91
|
+
};
|
|
92
|
+
return _getPrototypeOf(o);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function _setPrototypeOf(o, p) {
|
|
96
|
+
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
|
|
97
|
+
o.__proto__ = p;
|
|
98
|
+
return o;
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
return _setPrototypeOf(o, p);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function _isNativeReflectConstruct() {
|
|
105
|
+
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
106
|
+
if (Reflect.construct.sham) return false;
|
|
107
|
+
if (typeof Proxy === "function") return true;
|
|
108
|
+
|
|
109
|
+
try {
|
|
110
|
+
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|
111
|
+
return true;
|
|
112
|
+
} catch (e) {
|
|
113
|
+
return false;
|
|
88
114
|
}
|
|
115
|
+
}
|
|
89
116
|
|
|
90
|
-
|
|
117
|
+
function _construct(Parent, args, Class) {
|
|
118
|
+
if (_isNativeReflectConstruct()) {
|
|
119
|
+
_construct = Reflect.construct;
|
|
120
|
+
} else {
|
|
121
|
+
_construct = function _construct(Parent, args, Class) {
|
|
122
|
+
var a = [null];
|
|
123
|
+
a.push.apply(a, args);
|
|
124
|
+
var Constructor = Function.bind.apply(Parent, a);
|
|
125
|
+
var instance = new Constructor();
|
|
126
|
+
if (Class) _setPrototypeOf(instance, Class.prototype);
|
|
127
|
+
return instance;
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
return _construct.apply(null, arguments);
|
|
91
132
|
}
|
|
92
133
|
|
|
93
|
-
function
|
|
94
|
-
|
|
95
|
-
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
96
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
97
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
98
|
-
if (n === "Map" || n === "Set") return Array.from(o);
|
|
99
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
134
|
+
function _isNativeFunction(fn) {
|
|
135
|
+
return Function.toString.call(fn).indexOf("[native code]") !== -1;
|
|
100
136
|
}
|
|
101
137
|
|
|
102
|
-
function
|
|
103
|
-
|
|
138
|
+
function _wrapNativeSuper(Class) {
|
|
139
|
+
var _cache = typeof Map === "function" ? new Map() : undefined;
|
|
140
|
+
|
|
141
|
+
_wrapNativeSuper = function _wrapNativeSuper(Class) {
|
|
142
|
+
if (Class === null || !_isNativeFunction(Class)) return Class;
|
|
143
|
+
|
|
144
|
+
if (typeof Class !== "function") {
|
|
145
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
if (typeof _cache !== "undefined") {
|
|
149
|
+
if (_cache.has(Class)) return _cache.get(Class);
|
|
104
150
|
|
|
105
|
-
|
|
151
|
+
_cache.set(Class, Wrapper);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
function Wrapper() {
|
|
155
|
+
return _construct(Class, arguments, _getPrototypeOf(this).constructor);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
Wrapper.prototype = Object.create(Class.prototype, {
|
|
159
|
+
constructor: {
|
|
160
|
+
value: Wrapper,
|
|
161
|
+
enumerable: false,
|
|
162
|
+
writable: true,
|
|
163
|
+
configurable: true
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
return _setPrototypeOf(Wrapper, Class);
|
|
167
|
+
};
|
|
106
168
|
|
|
107
|
-
return
|
|
169
|
+
return _wrapNativeSuper(Class);
|
|
108
170
|
}
|
|
109
171
|
|
|
110
|
-
function
|
|
111
|
-
|
|
112
|
-
|
|
172
|
+
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
173
|
+
if (source == null) return {};
|
|
174
|
+
var target = {};
|
|
175
|
+
var sourceKeys = Object.keys(source);
|
|
176
|
+
var key, i;
|
|
113
177
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
if (i >= o.length) return {
|
|
119
|
-
done: true
|
|
120
|
-
};
|
|
121
|
-
return {
|
|
122
|
-
done: false,
|
|
123
|
-
value: o[i++]
|
|
124
|
-
};
|
|
125
|
-
};
|
|
178
|
+
for (i = 0; i < sourceKeys.length; i++) {
|
|
179
|
+
key = sourceKeys[i];
|
|
180
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
181
|
+
target[key] = source[key];
|
|
126
182
|
}
|
|
127
183
|
|
|
128
|
-
|
|
184
|
+
return target;
|
|
129
185
|
}
|
|
130
186
|
|
|
131
187
|
var container = /*#__PURE__*/emotion.css({
|
|
@@ -505,7 +561,7 @@ function CombinedLinkActions(props) {
|
|
|
505
561
|
var hideEmptyCard = props.entityType === 'Asset' && !props.isEmpty;
|
|
506
562
|
return React.createElement("div", {
|
|
507
563
|
className: hideEmptyCard ? '' : container
|
|
508
|
-
}, !props.canCreateEntity && !props.canLinkEntity && React.createElement(NoLinkPermissionsInfo, null), props.entityType === 'Entry' && React.createElement(CombinedEntryLinkActions,
|
|
564
|
+
}, !props.canCreateEntity && !props.canLinkEntity && React.createElement(NoLinkPermissionsInfo, null), props.entityType === 'Entry' && React.createElement(CombinedEntryLinkActions, _extends({}, props)), props.entityType === 'Asset' && React.createElement(CombinedAssetLinkActions, _extends({}, props)));
|
|
509
565
|
}
|
|
510
566
|
|
|
511
567
|
function CombinedEntryLinkActions(props) {
|
|
@@ -1635,9 +1691,8 @@ function useLinkActionsProps(props) {
|
|
|
1635
1691
|
return function (_x, _x2) {
|
|
1636
1692
|
return _ref.apply(this, arguments);
|
|
1637
1693
|
};
|
|
1638
|
-
}(), [sdk, entityType, onCreated]);
|
|
1639
|
-
|
|
1640
|
-
var onLinkExisting = /*#__PURE__*/function () {
|
|
1694
|
+
}(), [sdk, entityType, onCreated]);
|
|
1695
|
+
var onLinkExisting = React.useCallback( /*#__PURE__*/function () {
|
|
1641
1696
|
var _ref2 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(index) {
|
|
1642
1697
|
var entity;
|
|
1643
1698
|
return runtime_1.wrap(function _callee2$(_context2) {
|
|
@@ -1672,12 +1727,12 @@ function useLinkActionsProps(props) {
|
|
|
1672
1727
|
}, _callee2);
|
|
1673
1728
|
}));
|
|
1674
1729
|
|
|
1675
|
-
return function
|
|
1730
|
+
return function (_x3) {
|
|
1676
1731
|
return _ref2.apply(this, arguments);
|
|
1677
1732
|
};
|
|
1678
|
-
}()
|
|
1679
|
-
|
|
1680
|
-
var onLinkSeveralExisting = /*#__PURE__*/function () {
|
|
1733
|
+
}(), // eslint-disable-next-line react-hooks/exhaustive-deps -- TODO: Evaluate the dependencies
|
|
1734
|
+
[sdk, entityType, onLinkedExisting]);
|
|
1735
|
+
var onLinkSeveralExisting = React.useCallback( /*#__PURE__*/function () {
|
|
1681
1736
|
var _ref3 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3(index) {
|
|
1682
1737
|
var entities;
|
|
1683
1738
|
return runtime_1.wrap(function _callee3$(_context3) {
|
|
@@ -1712,11 +1767,11 @@ function useLinkActionsProps(props) {
|
|
|
1712
1767
|
}, _callee3);
|
|
1713
1768
|
}));
|
|
1714
1769
|
|
|
1715
|
-
return function
|
|
1770
|
+
return function (_x4) {
|
|
1716
1771
|
return _ref3.apply(this, arguments);
|
|
1717
1772
|
};
|
|
1718
|
-
}()
|
|
1719
|
-
|
|
1773
|
+
}(), // eslint-disable-next-line react-hooks/exhaustive-deps -- TODO: Evaluate the dependencies
|
|
1774
|
+
[sdk, entityType, onLinkedExisting]); // FIXME: The memoization might rerun every time due to the always changing callback identities above
|
|
1720
1775
|
|
|
1721
1776
|
return React.useMemo(function () {
|
|
1722
1777
|
return {
|
|
@@ -1746,7 +1801,7 @@ function LinkEntityActions(_ref4) {
|
|
|
1746
1801
|
props = _objectWithoutPropertiesLoose(_ref4, _excluded);
|
|
1747
1802
|
|
|
1748
1803
|
var renderLinkActions = renderCustomActions ? renderCustomActions : function (props) {
|
|
1749
|
-
return React.createElement(LinkActions,
|
|
1804
|
+
return React.createElement(LinkActions, _extends({}, props));
|
|
1750
1805
|
};
|
|
1751
1806
|
return renderLinkActions(props);
|
|
1752
1807
|
}
|
|
@@ -1807,6 +1862,8 @@ var ScheduleTooltip = function ScheduleTooltip(_ref2) {
|
|
|
1807
1862
|
};
|
|
1808
1863
|
|
|
1809
1864
|
var ScheduledIconWithTooltip = function ScheduledIconWithTooltip(_ref) {
|
|
1865
|
+
var _status$jobs;
|
|
1866
|
+
|
|
1810
1867
|
var entityType = _ref.entityType,
|
|
1811
1868
|
entityId = _ref.entityId,
|
|
1812
1869
|
getEntityScheduledActions = _ref.getEntityScheduledActions,
|
|
@@ -1838,7 +1895,7 @@ var ScheduledIconWithTooltip = function ScheduledIconWithTooltip(_ref) {
|
|
|
1838
1895
|
return null;
|
|
1839
1896
|
}
|
|
1840
1897
|
|
|
1841
|
-
var jobs = status.jobs ?
|
|
1898
|
+
var jobs = (_status$jobs = status.jobs) != null ? _status$jobs : [];
|
|
1842
1899
|
|
|
1843
1900
|
if (jobs.length === 0) {
|
|
1844
1901
|
return null;
|
|
@@ -1864,502 +1921,426 @@ function AssetThumbnail(props) {
|
|
|
1864
1921
|
});
|
|
1865
1922
|
}
|
|
1866
1923
|
|
|
1867
|
-
|
|
1868
|
-
|
|
1924
|
+
var _excluded$1 = ["priority"],
|
|
1925
|
+
_excluded2 = ["children"];
|
|
1869
1926
|
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1927
|
+
var globalQueue = /*#__PURE__*/new PQueue({
|
|
1928
|
+
concurrency: 20
|
|
1929
|
+
});
|
|
1930
|
+
var UnsupportedError = /*#__PURE__*/function (_Error) {
|
|
1931
|
+
_inheritsLoose(UnsupportedError, _Error);
|
|
1875
1932
|
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
entries: _extends({}, state.entries, (_extends3 = {}, _extends3[action.id] = 'failed', _extends3))
|
|
1879
|
-
});
|
|
1933
|
+
function UnsupportedError(message) {
|
|
1934
|
+
var _this;
|
|
1880
1935
|
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1936
|
+
_this = _Error.call(this, message) || this;
|
|
1937
|
+
_this.isUnsupportedError = void 0;
|
|
1938
|
+
_this.isUnsupportedError = true;
|
|
1939
|
+
return _this;
|
|
1940
|
+
}
|
|
1885
1941
|
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1942
|
+
return UnsupportedError;
|
|
1943
|
+
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
1944
|
+
function isUnsupportedError(value) {
|
|
1945
|
+
return typeof value === 'object' && (value == null ? void 0 : value.isUnsupportedError) === true;
|
|
1946
|
+
}
|
|
1890
1947
|
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
});
|
|
1948
|
+
var isEntityQueryKey = function isEntityQueryKey(queryKey) {
|
|
1949
|
+
return Array.isArray(queryKey) && (queryKey[0] === 'Entry' || queryKey[0] === 'Asset') && queryKey.length === 4;
|
|
1950
|
+
};
|
|
1895
1951
|
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
});
|
|
1952
|
+
function fetchContentfulEntry(_x) {
|
|
1953
|
+
return _fetchContentfulEntry.apply(this, arguments);
|
|
1954
|
+
}
|
|
1900
1955
|
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
});
|
|
1956
|
+
function _fetchContentfulEntry() {
|
|
1957
|
+
_fetchContentfulEntry = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3(params) {
|
|
1958
|
+
var urn, fetch, options, resourceId, _resourceId$split, spaceId, entryId, environmentId, _yield$Promise$all, space, entry, contentTypeId, _yield$Promise$all2, contentType, defaultLocaleCode;
|
|
1905
1959
|
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1960
|
+
return runtime_1.wrap(function _callee3$(_context3) {
|
|
1961
|
+
while (1) {
|
|
1962
|
+
switch (_context3.prev = _context3.next) {
|
|
1963
|
+
case 0:
|
|
1964
|
+
urn = params.urn, fetch = params.fetch, options = params.options;
|
|
1965
|
+
resourceId = urn.split(':', 6)[5];
|
|
1966
|
+
_resourceId$split = resourceId.split('/'), spaceId = _resourceId$split[1], entryId = _resourceId$split[3];
|
|
1967
|
+
environmentId = 'master';
|
|
1968
|
+
_context3.next = 6;
|
|
1969
|
+
return Promise.all([fetch(['space', spaceId], function (_ref9) {
|
|
1970
|
+
var cmaClient = _ref9.cmaClient;
|
|
1971
|
+
return cmaClient.space.get({
|
|
1972
|
+
spaceId: spaceId
|
|
1973
|
+
});
|
|
1974
|
+
}, options), fetch(['entry', spaceId, environmentId, entryId], function (_ref10) {
|
|
1975
|
+
var cmaClient = _ref10.cmaClient;
|
|
1976
|
+
return cmaClient.entry.get({
|
|
1977
|
+
spaceId: spaceId,
|
|
1978
|
+
environmentId: environmentId,
|
|
1979
|
+
entryId: entryId
|
|
1980
|
+
});
|
|
1981
|
+
}, options)]);
|
|
1910
1982
|
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1983
|
+
case 6:
|
|
1984
|
+
_yield$Promise$all = _context3.sent;
|
|
1985
|
+
space = _yield$Promise$all[0];
|
|
1986
|
+
entry = _yield$Promise$all[1];
|
|
1987
|
+
contentTypeId = entry.sys.contentType.sys.id;
|
|
1988
|
+
_context3.next = 12;
|
|
1989
|
+
return Promise.all([fetch(['contentType', spaceId, environmentId, contentTypeId], function (_ref11) {
|
|
1990
|
+
var cmaClient = _ref11.cmaClient;
|
|
1991
|
+
return cmaClient.contentType.get({
|
|
1992
|
+
contentTypeId: contentTypeId,
|
|
1993
|
+
spaceId: spaceId,
|
|
1994
|
+
environmentId: environmentId
|
|
1995
|
+
});
|
|
1996
|
+
}, options), fetch(['defaultLocale', spaceId, environmentId], /*#__PURE__*/function () {
|
|
1997
|
+
var _ref13 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(_ref12) {
|
|
1998
|
+
var _locales$items$find;
|
|
1917
1999
|
|
|
1918
|
-
var
|
|
1919
|
-
|
|
1920
|
-
|
|
2000
|
+
var cmaClient, locales, defaultLocaleCode;
|
|
2001
|
+
return runtime_1.wrap(function _callee2$(_context2) {
|
|
2002
|
+
while (1) {
|
|
2003
|
+
switch (_context2.prev = _context2.next) {
|
|
2004
|
+
case 0:
|
|
2005
|
+
cmaClient = _ref12.cmaClient;
|
|
2006
|
+
_context2.next = 3;
|
|
2007
|
+
return cmaClient.locale.getMany({
|
|
2008
|
+
spaceId: spaceId,
|
|
2009
|
+
environmentId: environmentId,
|
|
2010
|
+
query: {
|
|
2011
|
+
limit: 100
|
|
2012
|
+
}
|
|
2013
|
+
});
|
|
2014
|
+
|
|
2015
|
+
case 3:
|
|
2016
|
+
locales = _context2.sent;
|
|
2017
|
+
defaultLocaleCode = (_locales$items$find = locales.items.find(function (locale) {
|
|
2018
|
+
return locale["default"];
|
|
2019
|
+
})) == null ? void 0 : _locales$items$find.code;
|
|
2020
|
+
return _context2.abrupt("return", defaultLocaleCode);
|
|
1921
2021
|
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
};
|
|
2022
|
+
case 6:
|
|
2023
|
+
case "end":
|
|
2024
|
+
return _context2.stop();
|
|
2025
|
+
}
|
|
2026
|
+
}
|
|
2027
|
+
}, _callee2);
|
|
2028
|
+
}));
|
|
2029
|
+
|
|
2030
|
+
return function (_x3) {
|
|
2031
|
+
return _ref13.apply(this, arguments);
|
|
2032
|
+
};
|
|
2033
|
+
}(), options)]);
|
|
2034
|
+
|
|
2035
|
+
case 12:
|
|
2036
|
+
_yield$Promise$all2 = _context3.sent;
|
|
2037
|
+
contentType = _yield$Promise$all2[0];
|
|
2038
|
+
defaultLocaleCode = _yield$Promise$all2[1];
|
|
2039
|
+
return _context3.abrupt("return", {
|
|
2040
|
+
defaultLocaleCode: defaultLocaleCode,
|
|
2041
|
+
resource: entry,
|
|
2042
|
+
space: space,
|
|
2043
|
+
contentType: contentType
|
|
2044
|
+
});
|
|
1928
2045
|
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
2046
|
+
case 16:
|
|
2047
|
+
case "end":
|
|
2048
|
+
return _context3.stop();
|
|
2049
|
+
}
|
|
2050
|
+
}
|
|
2051
|
+
}, _callee3);
|
|
2052
|
+
}));
|
|
2053
|
+
return _fetchContentfulEntry.apply(this, arguments);
|
|
2054
|
+
}
|
|
1932
2055
|
|
|
1933
|
-
|
|
2056
|
+
var _constate = /*#__PURE__*/constate(function useInitServices(props) {
|
|
2057
|
+
var currentSpaceId = props.sdk.ids.space;
|
|
2058
|
+
var currentEnvironmentId = props.sdk.ids.environment;
|
|
2059
|
+
var queryClient = reactQuery.useQueryClient();
|
|
2060
|
+
var queryCache = queryClient.getQueryCache();
|
|
2061
|
+
var entityChangeUnsubscribers = React.useRef({});
|
|
2062
|
+
var cmaClient = React.useMemo(function () {
|
|
1934
2063
|
return contentfulManagement.createClient({
|
|
1935
2064
|
apiAdapter: props.sdk.cmaAdapter
|
|
1936
2065
|
}, {
|
|
1937
2066
|
type: 'plain'
|
|
1938
2067
|
});
|
|
1939
|
-
})
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
var loadEntityScheduledActions = React.useCallback(function (entityType, id) {
|
|
1947
|
-
var key = entityType + ":" + id;
|
|
2068
|
+
}, [props.sdk.cmaAdapter]);
|
|
2069
|
+
var queryQueue = React.useMemo(function () {
|
|
2070
|
+
if (props.queryConcurrency) {
|
|
2071
|
+
return new PQueue({
|
|
2072
|
+
concurrency: props.queryConcurrency
|
|
2073
|
+
});
|
|
2074
|
+
}
|
|
1948
2075
|
|
|
1949
|
-
|
|
1950
|
-
|
|
2076
|
+
return globalQueue;
|
|
2077
|
+
}, [props.queryConcurrency]);
|
|
2078
|
+
var fetch = React.useCallback(function fetch(queryKey, fn, options) {
|
|
2079
|
+
if (options === void 0) {
|
|
2080
|
+
options = {};
|
|
1951
2081
|
}
|
|
1952
2082
|
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
actions: undefined
|
|
2083
|
+
var _options = options,
|
|
2084
|
+
priority = _options.priority,
|
|
2085
|
+
queryOptions = _objectWithoutPropertiesLoose(_options, _excluded$1);
|
|
2086
|
+
|
|
2087
|
+
return queryClient.fetchQuery(queryKey, function () {
|
|
2088
|
+
return queryQueue.add(function () {
|
|
2089
|
+
return fn({
|
|
2090
|
+
cmaClient: cmaClient
|
|
2091
|
+
});
|
|
2092
|
+
}, {
|
|
2093
|
+
priority: priority
|
|
1965
2094
|
});
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
2095
|
+
}, queryOptions);
|
|
2096
|
+
}, [queryClient, queryQueue, cmaClient]);
|
|
2097
|
+
var getEntity = React.useCallback(function getEntity(entityType, entityId, options) {
|
|
2098
|
+
var _options$spaceId, _options$environmentI;
|
|
2099
|
+
|
|
2100
|
+
var spaceId = (_options$spaceId = options == null ? void 0 : options.spaceId) != null ? _options$spaceId : currentSpaceId;
|
|
2101
|
+
var environmentId = (_options$environmentI = options == null ? void 0 : options.environmentId) != null ? _options$environmentI : currentEnvironmentId;
|
|
2102
|
+
var queryKey = [entityType, entityId, spaceId, environmentId];
|
|
2103
|
+
return fetch(queryKey, function (_ref) {
|
|
2104
|
+
var cmaClient = _ref.cmaClient;
|
|
2105
|
+
|
|
2106
|
+
if (entityType === 'Entry') {
|
|
2107
|
+
return cmaClient.entry.get({
|
|
2108
|
+
entryId: entityId,
|
|
2109
|
+
spaceId: spaceId,
|
|
2110
|
+
environmentId: environmentId
|
|
2111
|
+
});
|
|
2112
|
+
}
|
|
1983
2113
|
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
return _context.abrupt("return", entry);
|
|
2114
|
+
if (entityType === 'Asset') {
|
|
2115
|
+
return cmaClient.asset.get({
|
|
2116
|
+
assetId: entityId,
|
|
2117
|
+
spaceId: spaceId,
|
|
2118
|
+
environmentId: environmentId
|
|
2119
|
+
});
|
|
2120
|
+
}
|
|
1992
2121
|
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2122
|
+
throw new UnsupportedError('Unsupported entity type');
|
|
2123
|
+
}, options);
|
|
2124
|
+
}, [fetch, currentSpaceId, currentEnvironmentId]);
|
|
2125
|
+
var getEntityScheduledActions = React.useCallback(function getEntityScheduledActions(entityType, entityId, options) {
|
|
2126
|
+
var _options$spaceId2, _options$environmentI2;
|
|
2127
|
+
|
|
2128
|
+
var spaceId = (_options$spaceId2 = options == null ? void 0 : options.spaceId) != null ? _options$spaceId2 : currentSpaceId;
|
|
2129
|
+
var environmentId = (_options$environmentI2 = options == null ? void 0 : options.environmentId) != null ? _options$environmentI2 : currentEnvironmentId;
|
|
2130
|
+
var queryKey = ['scheduled-actions', entityType, entityId, spaceId, environmentId];
|
|
2131
|
+
return fetch(queryKey, /*#__PURE__*/function () {
|
|
2132
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(_ref2) {
|
|
2133
|
+
var cmaClient, response;
|
|
2134
|
+
return runtime_1.wrap(function _callee$(_context) {
|
|
2135
|
+
while (1) {
|
|
2136
|
+
switch (_context.prev = _context.next) {
|
|
2137
|
+
case 0:
|
|
2138
|
+
cmaClient = _ref2.cmaClient;
|
|
2139
|
+
_context.next = 3;
|
|
2140
|
+
return cmaClient.scheduledActions.getMany({
|
|
2141
|
+
spaceId: spaceId,
|
|
2142
|
+
query: {
|
|
2143
|
+
'environment.sys.id': environmentId,
|
|
2144
|
+
'entity.sys.id': entityId,
|
|
2145
|
+
'sys.status[in]': 'scheduled',
|
|
2146
|
+
order: 'scheduledFor.datetime'
|
|
2147
|
+
}
|
|
2148
|
+
});
|
|
2001
2149
|
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
}
|
|
2006
|
-
}
|
|
2007
|
-
}, _callee, null, [[0, 8]]);
|
|
2008
|
-
}));
|
|
2150
|
+
case 3:
|
|
2151
|
+
response = _context.sent;
|
|
2152
|
+
return _context.abrupt("return", response.items);
|
|
2009
2153
|
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
return runtime_1.wrap(function _callee2$(_context2) {
|
|
2018
|
-
while (1) {
|
|
2019
|
-
switch (_context2.prev = _context2.next) {
|
|
2020
|
-
case 0:
|
|
2021
|
-
cachedEntry = state.entries[entryId];
|
|
2154
|
+
case 5:
|
|
2155
|
+
case "end":
|
|
2156
|
+
return _context.stop();
|
|
2157
|
+
}
|
|
2158
|
+
}
|
|
2159
|
+
}, _callee);
|
|
2160
|
+
}));
|
|
2022
2161
|
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2162
|
+
return function (_x2) {
|
|
2163
|
+
return _ref3.apply(this, arguments);
|
|
2164
|
+
};
|
|
2165
|
+
}(), options);
|
|
2166
|
+
}, [fetch, currentSpaceId, currentEnvironmentId]);
|
|
2167
|
+
var getResource = React.useCallback(function getResource(resourceType, urn, options) {
|
|
2168
|
+
var queryKey = ['Resource', resourceType, urn];
|
|
2169
|
+
return fetch(queryKey, function () {
|
|
2170
|
+
if (resourceType === 'Contentful:Entry') {
|
|
2171
|
+
return fetchContentfulEntry({
|
|
2172
|
+
fetch: fetch,
|
|
2173
|
+
urn: urn,
|
|
2174
|
+
options: options
|
|
2175
|
+
});
|
|
2176
|
+
}
|
|
2027
2177
|
|
|
2028
|
-
|
|
2178
|
+
throw new UnsupportedError('Unsupported resource type');
|
|
2179
|
+
}, options);
|
|
2180
|
+
}, [fetch]);
|
|
2181
|
+
var isSameSpaceEntityQueryKey = React.useCallback(function (queryKey) {
|
|
2182
|
+
var isEntityKey = isEntityQueryKey(queryKey);
|
|
2183
|
+
var isSameSpaceEntityKey = isEntityKey && queryKey[2] === currentSpaceId && queryKey[3] === currentEnvironmentId;
|
|
2184
|
+
return isSameSpaceEntityKey;
|
|
2185
|
+
}, [currentSpaceId, currentEnvironmentId]); // @ts-expect-error ...
|
|
2186
|
+
|
|
2187
|
+
// @ts-expect-error ...
|
|
2188
|
+
var onEntityChanged = props.sdk.space.onEntityChanged;
|
|
2189
|
+
React.useEffect(function () {
|
|
2190
|
+
if (typeof onEntityChanged !== 'function') {
|
|
2191
|
+
return;
|
|
2192
|
+
}
|
|
2029
2193
|
|
|
2030
|
-
|
|
2031
|
-
|
|
2194
|
+
var subscribeQuery = function subscribeQuery(_ref4) {
|
|
2195
|
+
var queryKey = _ref4.queryKey,
|
|
2196
|
+
queryHash = _ref4.queryHash;
|
|
2197
|
+
var entityType = queryKey[0],
|
|
2198
|
+
entityId = queryKey[1];
|
|
2199
|
+
entityChangeUnsubscribers.current[queryHash] = onEntityChanged(entityType, entityId, function (data) {
|
|
2200
|
+
queryClient.setQueryData(queryKey, data);
|
|
2201
|
+
});
|
|
2202
|
+
};
|
|
2032
2203
|
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2204
|
+
var queries = queryCache.findAll({
|
|
2205
|
+
type: 'active',
|
|
2206
|
+
predicate: function predicate(query) {
|
|
2207
|
+
return isSameSpaceEntityQueryKey(query.queryKey);
|
|
2208
|
+
}
|
|
2209
|
+
});
|
|
2210
|
+
queries.forEach(subscribeQuery);
|
|
2211
|
+
var unsubscribe = queryCache.subscribe(function (event) {
|
|
2212
|
+
if (!event) {
|
|
2213
|
+
return;
|
|
2214
|
+
}
|
|
2040
2215
|
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
var loadAsset = React.useCallback( /*#__PURE__*/function () {
|
|
2046
|
-
var _ref4 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3(assetId) {
|
|
2047
|
-
var asset;
|
|
2048
|
-
return runtime_1.wrap(function _callee3$(_context3) {
|
|
2049
|
-
while (1) {
|
|
2050
|
-
switch (_context3.prev = _context3.next) {
|
|
2051
|
-
case 0:
|
|
2052
|
-
_context3.prev = 0;
|
|
2053
|
-
_context3.next = 3;
|
|
2054
|
-
return cmaClient.asset.get({
|
|
2055
|
-
spaceId: spaceId,
|
|
2056
|
-
environmentId: environmentId,
|
|
2057
|
-
assetId: assetId
|
|
2058
|
-
});
|
|
2216
|
+
var type = event.type,
|
|
2217
|
+
query = event.query;
|
|
2218
|
+
var queryKey = query.queryKey,
|
|
2219
|
+
queryHash = query.queryHash;
|
|
2059
2220
|
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
type: 'set_asset',
|
|
2064
|
-
id: assetId,
|
|
2065
|
-
asset: asset
|
|
2066
|
-
});
|
|
2067
|
-
return _context3.abrupt("return", asset);
|
|
2221
|
+
if (!isSameSpaceEntityQueryKey(queryKey)) {
|
|
2222
|
+
return;
|
|
2223
|
+
}
|
|
2068
2224
|
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
dispatch({
|
|
2073
|
-
type: 'set_asset_failed',
|
|
2074
|
-
id: assetId
|
|
2075
|
-
});
|
|
2076
|
-
return _context3.abrupt("return");
|
|
2225
|
+
if (type === 'added') {
|
|
2226
|
+
subscribeQuery(query);
|
|
2227
|
+
}
|
|
2077
2228
|
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
return _context3.stop();
|
|
2081
|
-
}
|
|
2082
|
-
}
|
|
2083
|
-
}, _callee3, null, [[0, 8]]);
|
|
2084
|
-
}));
|
|
2229
|
+
if (type === 'removed') {
|
|
2230
|
+
var _entityChangeUnsubscr, _entityChangeUnsubscr2;
|
|
2085
2231
|
|
|
2086
|
-
|
|
2087
|
-
|
|
2232
|
+
// calling unsubscribe
|
|
2233
|
+
(_entityChangeUnsubscr = (_entityChangeUnsubscr2 = entityChangeUnsubscribers.current)[queryHash]) == null ? void 0 : _entityChangeUnsubscr.call(_entityChangeUnsubscr2);
|
|
2234
|
+
}
|
|
2235
|
+
});
|
|
2236
|
+
return function () {
|
|
2237
|
+
unsubscribe();
|
|
2238
|
+
Object.values(entityChangeUnsubscribers.current).forEach(function (off) {
|
|
2239
|
+
return off();
|
|
2240
|
+
});
|
|
2241
|
+
entityChangeUnsubscribers.current = {};
|
|
2088
2242
|
};
|
|
2089
|
-
}
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2243
|
+
}, [onEntityChanged, queryCache, isSameSpaceEntityQueryKey, queryClient]);
|
|
2244
|
+
return {
|
|
2245
|
+
cmaClient: cmaClient,
|
|
2246
|
+
fetch: fetch,
|
|
2247
|
+
getResource: getResource,
|
|
2248
|
+
getEntity: getEntity,
|
|
2249
|
+
ids: props.sdk.ids,
|
|
2250
|
+
getEntityScheduledActions: getEntityScheduledActions
|
|
2251
|
+
};
|
|
2252
|
+
}, function (_ref5) {
|
|
2253
|
+
var fetch = _ref5.fetch;
|
|
2254
|
+
return fetch;
|
|
2255
|
+
}, function (_ref6) {
|
|
2256
|
+
var getResource = _ref6.getResource,
|
|
2257
|
+
getEntity = _ref6.getEntity,
|
|
2258
|
+
getEntityScheduledActions = _ref6.getEntityScheduledActions;
|
|
2259
|
+
return {
|
|
2260
|
+
getResource: getResource,
|
|
2261
|
+
getEntity: getEntity,
|
|
2262
|
+
getEntityScheduledActions: getEntityScheduledActions
|
|
2263
|
+
};
|
|
2264
|
+
}, function (_ref7) {
|
|
2265
|
+
var ids = _ref7.ids;
|
|
2266
|
+
return ids;
|
|
2267
|
+
}),
|
|
2268
|
+
InternalServiceProvider = _constate[0],
|
|
2269
|
+
useEntityLoader = _constate[2],
|
|
2270
|
+
useCurrentIds = _constate[3];
|
|
2271
|
+
|
|
2272
|
+
function useEntity(entityType, entityId, options) {
|
|
2273
|
+
var _options$spaceId3, _options$environmentI3;
|
|
2274
|
+
|
|
2275
|
+
var _useCurrentIds = useCurrentIds(),
|
|
2276
|
+
space = _useCurrentIds.space,
|
|
2277
|
+
environment = _useCurrentIds.environment;
|
|
2278
|
+
|
|
2279
|
+
var _useEntityLoader = useEntityLoader(),
|
|
2280
|
+
getEntity = _useEntityLoader.getEntity;
|
|
2281
|
+
|
|
2282
|
+
var queryKey = [entityType, entityId, (_options$spaceId3 = options == null ? void 0 : options.spaceId) != null ? _options$spaceId3 : space, (_options$environmentI3 = options == null ? void 0 : options.environmentId) != null ? _options$environmentI3 : environment];
|
|
2283
|
+
|
|
2284
|
+
var _useQuery = reactQuery.useQuery(queryKey, function () {
|
|
2285
|
+
return getEntity(entityType, entityId, options);
|
|
2286
|
+
}, {
|
|
2287
|
+
enabled: options == null ? void 0 : options.enabled
|
|
2288
|
+
}),
|
|
2289
|
+
status = _useQuery.status,
|
|
2290
|
+
data = _useQuery.data;
|
|
2103
2291
|
|
|
2104
|
-
|
|
2292
|
+
return {
|
|
2293
|
+
status: status,
|
|
2294
|
+
data: data
|
|
2295
|
+
};
|
|
2296
|
+
}
|
|
2297
|
+
function useResource(resourceType, urn, options) {
|
|
2298
|
+
var queryKey = ['Resource', resourceType, urn];
|
|
2105
2299
|
|
|
2106
|
-
|
|
2107
|
-
|
|
2300
|
+
var _useEntityLoader2 = useEntityLoader(),
|
|
2301
|
+
getResource = _useEntityLoader2.getResource;
|
|
2108
2302
|
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2303
|
+
var _useQuery2 = reactQuery.useQuery(queryKey, function () {
|
|
2304
|
+
return getResource(resourceType, urn, options);
|
|
2305
|
+
}, {
|
|
2306
|
+
enabled: options == null ? void 0 : options.enabled
|
|
2307
|
+
}),
|
|
2308
|
+
status = _useQuery2.status,
|
|
2309
|
+
data = _useQuery2.data,
|
|
2310
|
+
error = _useQuery2.error;
|
|
2116
2311
|
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
var _locales$items$find;
|
|
2312
|
+
return {
|
|
2313
|
+
status: status,
|
|
2314
|
+
data: data,
|
|
2315
|
+
error: error
|
|
2316
|
+
};
|
|
2317
|
+
}
|
|
2124
2318
|
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
_context5.t2 = _context5.sent;
|
|
2151
|
-
_context5.t3 = [_context5.t1, _context5.t2];
|
|
2152
|
-
_context5.next = 13;
|
|
2153
|
-
return _context5.t0.all.call(_context5.t0, _context5.t3);
|
|
2154
|
-
|
|
2155
|
-
case 13:
|
|
2156
|
-
_yield$Promise$all = _context5.sent;
|
|
2157
|
-
space = _yield$Promise$all[0];
|
|
2158
|
-
entry = _yield$Promise$all[1];
|
|
2159
|
-
contentTypeId = entry.sys.contentType.sys.id;
|
|
2160
|
-
_context5.t4 = Promise;
|
|
2161
|
-
_context5.next = 20;
|
|
2162
|
-
return cmaClient.contentType.get({
|
|
2163
|
-
contentTypeId: contentTypeId,
|
|
2164
|
-
spaceId: spaceId,
|
|
2165
|
-
environmentId: environmentId
|
|
2166
|
-
});
|
|
2167
|
-
|
|
2168
|
-
case 20:
|
|
2169
|
-
_context5.t5 = _context5.sent;
|
|
2170
|
-
_context5.next = 23;
|
|
2171
|
-
return cmaClient.locale.getMany({
|
|
2172
|
-
spaceId: spaceId,
|
|
2173
|
-
environmentId: environmentId,
|
|
2174
|
-
query: {
|
|
2175
|
-
limit: 100
|
|
2176
|
-
}
|
|
2177
|
-
});
|
|
2178
|
-
|
|
2179
|
-
case 23:
|
|
2180
|
-
_context5.t6 = _context5.sent;
|
|
2181
|
-
_context5.t7 = [_context5.t5, _context5.t6];
|
|
2182
|
-
_context5.next = 27;
|
|
2183
|
-
return _context5.t4.all.call(_context5.t4, _context5.t7);
|
|
2184
|
-
|
|
2185
|
-
case 27:
|
|
2186
|
-
_yield$Promise$all2 = _context5.sent;
|
|
2187
|
-
contentType = _yield$Promise$all2[0];
|
|
2188
|
-
locales = _yield$Promise$all2[1];
|
|
2189
|
-
defaultLocaleCode = (_locales$items$find = locales.items.find(function (locale) {
|
|
2190
|
-
return locale["default"];
|
|
2191
|
-
})) == null ? void 0 : _locales$items$find.code;
|
|
2192
|
-
return _context5.abrupt("return", {
|
|
2193
|
-
resource: entry,
|
|
2194
|
-
defaultLocaleCode: defaultLocaleCode,
|
|
2195
|
-
space: space,
|
|
2196
|
-
contentType: contentType
|
|
2197
|
-
});
|
|
2198
|
-
|
|
2199
|
-
case 32:
|
|
2200
|
-
case "end":
|
|
2201
|
-
return _context5.stop();
|
|
2202
|
-
}
|
|
2203
|
-
}
|
|
2204
|
-
}, _callee5);
|
|
2205
|
-
}));
|
|
2206
|
-
|
|
2207
|
-
return function (_x5) {
|
|
2208
|
-
return _ref6.apply(this, arguments);
|
|
2209
|
-
};
|
|
2210
|
-
}(), [cmaClient]);
|
|
2211
|
-
var getResource = React.useCallback( /*#__PURE__*/function () {
|
|
2212
|
-
var _ref7 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee6(resourceType, urn) {
|
|
2213
|
-
var cachedResource, resourceInfo;
|
|
2214
|
-
return runtime_1.wrap(function _callee6$(_context6) {
|
|
2215
|
-
while (1) {
|
|
2216
|
-
switch (_context6.prev = _context6.next) {
|
|
2217
|
-
case 0:
|
|
2218
|
-
cachedResource = state.resources[resourceType + "." + urn];
|
|
2219
|
-
|
|
2220
|
-
if (!isNotNil(cachedResource)) {
|
|
2221
|
-
_context6.next = 3;
|
|
2222
|
-
break;
|
|
2223
|
-
}
|
|
2224
|
-
|
|
2225
|
-
return _context6.abrupt("return", cachedResource);
|
|
2226
|
-
|
|
2227
|
-
case 3:
|
|
2228
|
-
_context6.prev = 3;
|
|
2229
|
-
|
|
2230
|
-
if (!(resourceType === 'Contentful:Entry')) {
|
|
2231
|
-
_context6.next = 8;
|
|
2232
|
-
break;
|
|
2233
|
-
}
|
|
2234
|
-
|
|
2235
|
-
_context6.next = 7;
|
|
2236
|
-
return loadContentfulEntry(urn);
|
|
2237
|
-
|
|
2238
|
-
case 7:
|
|
2239
|
-
resourceInfo = _context6.sent;
|
|
2240
|
-
|
|
2241
|
-
case 8:
|
|
2242
|
-
dispatch({
|
|
2243
|
-
type: 'set_resource',
|
|
2244
|
-
resourceType: resourceType,
|
|
2245
|
-
urn: urn,
|
|
2246
|
-
resourceInfo: resourceInfo
|
|
2247
|
-
});
|
|
2248
|
-
return _context6.abrupt("return", resourceInfo);
|
|
2249
|
-
|
|
2250
|
-
case 12:
|
|
2251
|
-
_context6.prev = 12;
|
|
2252
|
-
_context6.t0 = _context6["catch"](3);
|
|
2253
|
-
dispatch({
|
|
2254
|
-
type: 'set_resource_failed',
|
|
2255
|
-
resourceType: resourceType,
|
|
2256
|
-
urn: urn
|
|
2257
|
-
});
|
|
2258
|
-
return _context6.abrupt("return");
|
|
2259
|
-
|
|
2260
|
-
case 16:
|
|
2261
|
-
case "end":
|
|
2262
|
-
return _context6.stop();
|
|
2263
|
-
}
|
|
2264
|
-
}
|
|
2265
|
-
}, _callee6, null, [[3, 12]]);
|
|
2266
|
-
}));
|
|
2267
|
-
|
|
2268
|
-
return function (_x6, _x7) {
|
|
2269
|
-
return _ref7.apply(this, arguments);
|
|
2270
|
-
};
|
|
2271
|
-
}(), [loadContentfulEntry, state.resources]);
|
|
2272
|
-
React.useEffect(function () {
|
|
2273
|
-
// @ts-expect-error
|
|
2274
|
-
if (typeof props.sdk.space.onEntityChanged !== 'undefined') {
|
|
2275
|
-
// @ts-expect-error
|
|
2276
|
-
var onEntityChanged = props.sdk.space.onEntityChanged;
|
|
2277
|
-
var listeners = [];
|
|
2278
|
-
|
|
2279
|
-
var _loop = function _loop() {
|
|
2280
|
-
var _step$value = _step.value,
|
|
2281
|
-
id = _step$value[0];
|
|
2282
|
-
listeners.push(onEntityChanged('Entry', id, function (entry) {
|
|
2283
|
-
return dispatch({
|
|
2284
|
-
type: 'set_entry',
|
|
2285
|
-
id: id,
|
|
2286
|
-
entry: entry
|
|
2287
|
-
});
|
|
2288
|
-
}));
|
|
2289
|
-
};
|
|
2290
|
-
|
|
2291
|
-
for (var _iterator = _createForOfIteratorHelperLoose(nonNilResources(state.entries)), _step; !(_step = _iterator()).done;) {
|
|
2292
|
-
_loop();
|
|
2293
|
-
}
|
|
2294
|
-
|
|
2295
|
-
var _loop2 = function _loop2() {
|
|
2296
|
-
var _step2$value = _step2.value,
|
|
2297
|
-
id = _step2$value[0];
|
|
2298
|
-
listeners.push(onEntityChanged('Asset', id, function (asset) {
|
|
2299
|
-
return dispatch({
|
|
2300
|
-
type: 'set_asset',
|
|
2301
|
-
id: id,
|
|
2302
|
-
asset: asset
|
|
2303
|
-
});
|
|
2304
|
-
}));
|
|
2305
|
-
};
|
|
2306
|
-
|
|
2307
|
-
for (var _iterator2 = _createForOfIteratorHelperLoose(nonNilResources(state.assets)), _step2; !(_step2 = _iterator2()).done;) {
|
|
2308
|
-
_loop2();
|
|
2309
|
-
}
|
|
2310
|
-
|
|
2311
|
-
return function () {
|
|
2312
|
-
return listeners.forEach(function (off) {
|
|
2313
|
-
return off();
|
|
2314
|
-
});
|
|
2315
|
-
};
|
|
2316
|
-
}
|
|
2317
|
-
|
|
2318
|
-
return props.sdk.navigator.onSlideInNavigation(function (_ref8) {
|
|
2319
|
-
var oldSlideLevel = _ref8.oldSlideLevel,
|
|
2320
|
-
newSlideLevel = _ref8.newSlideLevel;
|
|
2321
|
-
|
|
2322
|
-
if (oldSlideLevel > newSlideLevel) {
|
|
2323
|
-
for (var _iterator3 = _createForOfIteratorHelperLoose(nonNilResources(state.entries)), _step3; !(_step3 = _iterator3()).done;) {
|
|
2324
|
-
var _step3$value = _step3.value,
|
|
2325
|
-
id = _step3$value[0];
|
|
2326
|
-
loadEntry(id);
|
|
2327
|
-
}
|
|
2328
|
-
|
|
2329
|
-
for (var _iterator4 = _createForOfIteratorHelperLoose(nonNilResources(state.assets)), _step4; !(_step4 = _iterator4()).done;) {
|
|
2330
|
-
var _step4$value = _step4.value,
|
|
2331
|
-
_id = _step4$value[0];
|
|
2332
|
-
loadAsset(_id);
|
|
2333
|
-
}
|
|
2334
|
-
}
|
|
2335
|
-
}); // eslint-disable-next-line react-hooks/exhaustive-deps -- TODO: Evaluate the dependencies
|
|
2336
|
-
}, [props.sdk, state.assets, state.entries]);
|
|
2337
|
-
return React.useMemo(function () {
|
|
2338
|
-
return {
|
|
2339
|
-
/**
|
|
2340
|
-
* @deprecated use `getEntry` instead
|
|
2341
|
-
*/
|
|
2342
|
-
getOrLoadEntry: getEntry,
|
|
2343
|
-
|
|
2344
|
-
/**
|
|
2345
|
-
* @deprecated use `getAsset` instead
|
|
2346
|
-
*/
|
|
2347
|
-
getOrLoadAsset: getAsset,
|
|
2348
|
-
getResource: getResource,
|
|
2349
|
-
getEntry: getEntry,
|
|
2350
|
-
getAsset: getAsset,
|
|
2351
|
-
loadEntityScheduledActions: loadEntityScheduledActions,
|
|
2352
|
-
entries: state.entries,
|
|
2353
|
-
assets: state.assets,
|
|
2354
|
-
scheduledActions: state.scheduledActions,
|
|
2355
|
-
resources: state.resources
|
|
2356
|
-
};
|
|
2357
|
-
}, [getResource, getEntry, getAsset, loadEntityScheduledActions, state.entries, state.assets, state.scheduledActions, state.resources]);
|
|
2358
|
-
}
|
|
2359
|
-
|
|
2360
|
-
var _constate = /*#__PURE__*/constate(useEntitiesStore),
|
|
2361
|
-
EntityProvider = _constate[0],
|
|
2362
|
-
useEntities = _constate[1];
|
|
2319
|
+
function EntityProvider(_ref8) {
|
|
2320
|
+
var children = _ref8.children,
|
|
2321
|
+
props = _objectWithoutPropertiesLoose(_ref8, _excluded2);
|
|
2322
|
+
|
|
2323
|
+
var reactQueryClient = React.useMemo(function () {
|
|
2324
|
+
var queryCache = new reactQuery.QueryCache();
|
|
2325
|
+
var queryClient = new reactQuery.QueryClient({
|
|
2326
|
+
queryCache: queryCache,
|
|
2327
|
+
defaultOptions: {
|
|
2328
|
+
queries: {
|
|
2329
|
+
useErrorBoundary: false,
|
|
2330
|
+
refetchOnWindowFocus: false,
|
|
2331
|
+
refetchOnReconnect: true,
|
|
2332
|
+
refetchOnMount: false,
|
|
2333
|
+
staleTime: Infinity,
|
|
2334
|
+
retry: false
|
|
2335
|
+
}
|
|
2336
|
+
}
|
|
2337
|
+
});
|
|
2338
|
+
return queryClient;
|
|
2339
|
+
}, []);
|
|
2340
|
+
return React__default.createElement(reactQuery.QueryClientProvider, {
|
|
2341
|
+
client: reactQueryClient
|
|
2342
|
+
}, React__default.createElement(InternalServiceProvider, _extends({}, props), children));
|
|
2343
|
+
}
|
|
2363
2344
|
|
|
2364
2345
|
function ReferenceEditor(props) {
|
|
2365
2346
|
return React.createElement(EntityProvider, {
|
|
@@ -2581,7 +2562,10 @@ function fromFieldValidations(field) {
|
|
|
2581
2562
|
var result = {
|
|
2582
2563
|
contentTypes: (_linkContentTypeValid = linkContentTypeValidations == null ? void 0 : linkContentTypeValidations.linkContentType) != null ? _linkContentTypeValid : undefined,
|
|
2583
2564
|
mimetypeGroups: (_linkMimetypeGroupVal = linkMimetypeGroupValidations == null ? void 0 : linkMimetypeGroupValidations.linkMimetypeGroup) != null ? _linkMimetypeGroupVal : undefined,
|
|
2584
|
-
numberOfLinks: numberOfLinks
|
|
2565
|
+
numberOfLinks: numberOfLinks // todo: there are multiple BE problems that need to be solved first, for now we don't want to apply size constraints
|
|
2566
|
+
// linkedFileSize: findValidation(field, 'assetFileSize', {}),
|
|
2567
|
+
// linkedImageDimensions: findValidation(field, 'assetImageDimensions', {})
|
|
2568
|
+
|
|
2585
2569
|
};
|
|
2586
2570
|
return result;
|
|
2587
2571
|
}
|
|
@@ -2780,7 +2764,7 @@ function Editor(props) {
|
|
|
2780
2764
|
[linkActionsProps]);
|
|
2781
2765
|
|
|
2782
2766
|
if (!props.entityId) {
|
|
2783
|
-
return React.createElement(LinkEntityActions,
|
|
2767
|
+
return React.createElement(LinkEntityActions, _extends({
|
|
2784
2768
|
renderCustomActions: props.renderCustomActions
|
|
2785
2769
|
}, linkActionsProps));
|
|
2786
2770
|
}
|
|
@@ -2792,12 +2776,12 @@ function Editor(props) {
|
|
|
2792
2776
|
|
|
2793
2777
|
function SingleReferenceEditor(props) {
|
|
2794
2778
|
var allContentTypes = props.sdk.space.getCachedContentTypes();
|
|
2795
|
-
return React.createElement(ReferenceEditor,
|
|
2779
|
+
return React.createElement(ReferenceEditor, _extends({}, props), function (_ref) {
|
|
2796
2780
|
var value = _ref.value,
|
|
2797
2781
|
setValue = _ref.setValue,
|
|
2798
2782
|
disabled = _ref.disabled,
|
|
2799
2783
|
externalReset = _ref.externalReset;
|
|
2800
|
-
return React.createElement(Editor,
|
|
2784
|
+
return React.createElement(Editor, _extends({}, props, {
|
|
2801
2785
|
key: externalReset + "-reference",
|
|
2802
2786
|
entityId: value ? value.sys.id : '',
|
|
2803
2787
|
isDisabled: disabled,
|
|
@@ -3027,18 +3011,24 @@ function _openEntry() {
|
|
|
3027
3011
|
}
|
|
3028
3012
|
|
|
3029
3013
|
function FetchingWrappedEntryCard(props) {
|
|
3030
|
-
var
|
|
3031
|
-
|
|
3032
|
-
|
|
3033
|
-
loadEntityScheduledActions = _useEntities.loadEntityScheduledActions,
|
|
3034
|
-
entries = _useEntities.entries;
|
|
3014
|
+
var _useEntity = useEntity('Entry', props.entryId),
|
|
3015
|
+
entry = _useEntity.data,
|
|
3016
|
+
status = _useEntity.status;
|
|
3035
3017
|
|
|
3036
|
-
|
|
3037
|
-
|
|
3038
|
-
|
|
3018
|
+
var _useEntityLoader = useEntityLoader(),
|
|
3019
|
+
getEntityScheduledActions = _useEntityLoader.getEntityScheduledActions;
|
|
3020
|
+
|
|
3021
|
+
var loadEntityScheduledActions = React.useCallback(function () {
|
|
3022
|
+
return getEntityScheduledActions('Entry', props.entryId);
|
|
3023
|
+
}, [getEntityScheduledActions, props.entryId]);
|
|
3039
3024
|
var size = props.viewType === 'link' ? 'small' : 'default';
|
|
3040
|
-
|
|
3041
|
-
var
|
|
3025
|
+
|
|
3026
|
+
var _useEntityLoader2 = useEntityLoader(),
|
|
3027
|
+
getEntity = _useEntityLoader2.getEntity;
|
|
3028
|
+
|
|
3029
|
+
var getAsset = function getAsset(assetId) {
|
|
3030
|
+
return getEntity('Asset', assetId);
|
|
3031
|
+
};
|
|
3042
3032
|
|
|
3043
3033
|
var onEdit = /*#__PURE__*/function () {
|
|
3044
3034
|
var _ref = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee() {
|
|
@@ -3096,7 +3086,7 @@ function FetchingWrappedEntryCard(props) {
|
|
|
3096
3086
|
|
|
3097
3087
|
}, [entry]);
|
|
3098
3088
|
return React.useMemo(function () {
|
|
3099
|
-
if (
|
|
3089
|
+
if (status === 'error') {
|
|
3100
3090
|
var card = React.createElement(MissingEntityCard, {
|
|
3101
3091
|
entityType: "Entry",
|
|
3102
3092
|
isDisabled: props.isDisabled,
|
|
@@ -3116,7 +3106,7 @@ function FetchingWrappedEntryCard(props) {
|
|
|
3116
3106
|
return card;
|
|
3117
3107
|
}
|
|
3118
3108
|
|
|
3119
|
-
if (
|
|
3109
|
+
if (status === 'loading') {
|
|
3120
3110
|
return React.createElement(f36Components.EntryCard, {
|
|
3121
3111
|
size: size,
|
|
3122
3112
|
isLoading: true
|
|
@@ -3155,7 +3145,7 @@ function FetchingWrappedEntryCard(props) {
|
|
|
3155
3145
|
entryUrl: (props == null ? void 0 : props.entityUrl) || sharedCardProps.entityUrl
|
|
3156
3146
|
});
|
|
3157
3147
|
|
|
3158
|
-
return React.createElement(WrappedEntryCard,
|
|
3148
|
+
return React.createElement(WrappedEntryCard, _extends({}, builtinCardProps));
|
|
3159
3149
|
}
|
|
3160
3150
|
|
|
3161
3151
|
if (props.renderCustomCard) {
|
|
@@ -3168,11 +3158,11 @@ function FetchingWrappedEntryCard(props) {
|
|
|
3168
3158
|
}
|
|
3169
3159
|
|
|
3170
3160
|
return renderDefaultCard(); // eslint-disable-next-line react-hooks/exhaustive-deps -- TODO: Evaluate the dependencies
|
|
3171
|
-
}, [props,
|
|
3161
|
+
}, [props, status, entry]);
|
|
3172
3162
|
}
|
|
3173
3163
|
|
|
3174
3164
|
function SingleEntryReferenceEditor(props) {
|
|
3175
|
-
return React.createElement(SingleReferenceEditor,
|
|
3165
|
+
return React.createElement(SingleReferenceEditor, _extends({}, props, {
|
|
3176
3166
|
entityType: "Entry"
|
|
3177
3167
|
}), function (_ref) {
|
|
3178
3168
|
var allContentTypes = _ref.allContentTypes,
|
|
@@ -3182,7 +3172,7 @@ function SingleEntryReferenceEditor(props) {
|
|
|
3182
3172
|
renderCustomCard = _ref.renderCustomCard,
|
|
3183
3173
|
hasCardRemoveActions = _ref.hasCardRemoveActions,
|
|
3184
3174
|
hasCardEditActions = _ref.hasCardEditActions;
|
|
3185
|
-
return React.createElement(FetchingWrappedEntryCard,
|
|
3175
|
+
return React.createElement(FetchingWrappedEntryCard, _extends({}, props, {
|
|
3186
3176
|
allContentTypes: allContentTypes,
|
|
3187
3177
|
isDisabled: isDisabled,
|
|
3188
3178
|
entryId: entityId,
|
|
@@ -3273,19 +3263,19 @@ function Editor$1(props) {
|
|
|
3273
3263
|
onSortEnd: onSortEnd,
|
|
3274
3264
|
onMove: onMove,
|
|
3275
3265
|
renderCustomCard: props.renderCustomCard && customCardRenderer
|
|
3276
|
-
})), React.createElement(LinkEntityActions,
|
|
3266
|
+
})), React.createElement(LinkEntityActions, _extends({
|
|
3277
3267
|
renderCustomActions: props.renderCustomActions
|
|
3278
3268
|
}, linkActionsProps)));
|
|
3279
3269
|
}
|
|
3280
3270
|
|
|
3281
3271
|
function MultipleReferenceEditor(props) {
|
|
3282
3272
|
var allContentTypes = props.sdk.space.getCachedContentTypes();
|
|
3283
|
-
return React.createElement(ReferenceEditor,
|
|
3273
|
+
return React.createElement(ReferenceEditor, _extends({}, props), function (_ref2) {
|
|
3284
3274
|
var value = _ref2.value,
|
|
3285
3275
|
disabled = _ref2.disabled,
|
|
3286
3276
|
setValue = _ref2.setValue,
|
|
3287
3277
|
externalReset = _ref2.externalReset;
|
|
3288
|
-
return React.createElement(Editor$1,
|
|
3278
|
+
return React.createElement(Editor$1, _extends({}, props, {
|
|
3289
3279
|
items: value || emptyArray,
|
|
3290
3280
|
isDisabled: disabled,
|
|
3291
3281
|
setValue: setValue,
|
|
@@ -3342,16 +3332,16 @@ var SortableLinkListInternal = /*#__PURE__*/reactSortableHoc.SortableContainer(f
|
|
|
3342
3332
|
function SortableLinkList(props) {
|
|
3343
3333
|
// with the default distance of 0 the drag start event is "confused" with the click event,
|
|
3344
3334
|
// so the latter one isn't fired and click handlers on child elements don't work
|
|
3345
|
-
return React__default.createElement(SortableLinkListInternal,
|
|
3335
|
+
return React__default.createElement(SortableLinkListInternal, _extends({
|
|
3346
3336
|
distance: 1
|
|
3347
3337
|
}, props), props.children);
|
|
3348
3338
|
}
|
|
3349
3339
|
|
|
3350
3340
|
function MultipleEntryReferenceEditor(props) {
|
|
3351
|
-
return React.createElement(MultipleReferenceEditor,
|
|
3341
|
+
return React.createElement(MultipleReferenceEditor, _extends({}, props, {
|
|
3352
3342
|
entityType: "Entry"
|
|
3353
3343
|
}), function (childrenProps) {
|
|
3354
|
-
return React.createElement(SortableLinkList,
|
|
3344
|
+
return React.createElement(SortableLinkList, _extends({}, childrenProps, {
|
|
3355
3345
|
axis: "y",
|
|
3356
3346
|
useDragHandle: true
|
|
3357
3347
|
}), function (_ref) {
|
|
@@ -3361,7 +3351,7 @@ function MultipleEntryReferenceEditor(props) {
|
|
|
3361
3351
|
isDisabled = _ref.isDisabled,
|
|
3362
3352
|
DragHandle = _ref.DragHandle;
|
|
3363
3353
|
var lastIndex = items.length - 1;
|
|
3364
|
-
return React.createElement(FetchingWrappedEntryCard,
|
|
3354
|
+
return React.createElement(FetchingWrappedEntryCard, _extends({}, childrenProps, {
|
|
3365
3355
|
key: item.sys.id + "-" + index,
|
|
3366
3356
|
index: index,
|
|
3367
3357
|
allContentTypes: childrenProps.allContentTypes,
|
|
@@ -3616,20 +3606,16 @@ var WrappedAssetLink = function WrappedAssetLink(props) {
|
|
|
3616
3606
|
};
|
|
3617
3607
|
|
|
3618
3608
|
function FetchingWrappedAssetCard(props) {
|
|
3619
|
-
var
|
|
3620
|
-
|
|
3621
|
-
|
|
3622
|
-
assets = _useEntities.assets;
|
|
3609
|
+
var _useEntity = useEntity('Asset', props.assetId),
|
|
3610
|
+
asset = _useEntity.data,
|
|
3611
|
+
status = _useEntity.status;
|
|
3623
3612
|
|
|
3624
|
-
|
|
3625
|
-
|
|
3626
|
-
return;
|
|
3627
|
-
}
|
|
3613
|
+
var _useEntityLoader = useEntityLoader(),
|
|
3614
|
+
getEntityScheduledActions = _useEntityLoader.getEntityScheduledActions;
|
|
3628
3615
|
|
|
3629
|
-
|
|
3630
|
-
|
|
3631
|
-
|
|
3632
|
-
var entityKey = asset === 'failed' ? 'failed' : asset === undefined ? 'undefined' : ":" + asset.sys.id + ":" + asset.sys.version;
|
|
3616
|
+
var loadEntityScheduledActions = React.useCallback(function () {
|
|
3617
|
+
return getEntityScheduledActions('Asset', props.assetId);
|
|
3618
|
+
}, [getEntityScheduledActions, props.assetId]);
|
|
3633
3619
|
React.useEffect(function () {
|
|
3634
3620
|
if (asset) {
|
|
3635
3621
|
props.onAction && props.onAction({
|
|
@@ -3688,7 +3674,7 @@ function FetchingWrappedAssetCard(props) {
|
|
|
3688
3674
|
};
|
|
3689
3675
|
|
|
3690
3676
|
return React.useMemo(function () {
|
|
3691
|
-
if (
|
|
3677
|
+
if (status === 'error') {
|
|
3692
3678
|
var card = React.createElement(MissingEntityCard, {
|
|
3693
3679
|
entityType: "Asset",
|
|
3694
3680
|
asSquare: props.viewType !== 'link',
|
|
@@ -3709,8 +3695,7 @@ function FetchingWrappedAssetCard(props) {
|
|
|
3709
3695
|
return card;
|
|
3710
3696
|
}
|
|
3711
3697
|
|
|
3712
|
-
var getEntityUrl = props.getEntityUrl
|
|
3713
|
-
sdk = props.sdk;
|
|
3698
|
+
var getEntityUrl = props.getEntityUrl;
|
|
3714
3699
|
var size = props.viewType === 'big_card' ? 'default' : 'small';
|
|
3715
3700
|
var commonProps = {
|
|
3716
3701
|
asset: asset,
|
|
@@ -3725,20 +3710,20 @@ function FetchingWrappedAssetCard(props) {
|
|
|
3725
3710
|
};
|
|
3726
3711
|
|
|
3727
3712
|
if (props.viewType === 'link') {
|
|
3728
|
-
if (
|
|
3713
|
+
if (status === 'loading') {
|
|
3729
3714
|
return React.createElement(f36Components.EntryCard, {
|
|
3730
3715
|
size: "small",
|
|
3731
3716
|
isLoading: true
|
|
3732
3717
|
});
|
|
3733
3718
|
}
|
|
3734
3719
|
|
|
3735
|
-
return React.createElement(WrappedAssetLink,
|
|
3720
|
+
return React.createElement(WrappedAssetLink, _extends({}, commonProps, {
|
|
3736
3721
|
href: commonProps.entityUrl,
|
|
3737
|
-
getEntityScheduledActions:
|
|
3722
|
+
getEntityScheduledActions: loadEntityScheduledActions
|
|
3738
3723
|
}));
|
|
3739
3724
|
}
|
|
3740
3725
|
|
|
3741
|
-
if (
|
|
3726
|
+
if (status === 'loading') {
|
|
3742
3727
|
return React.createElement(f36Components.AssetCard, {
|
|
3743
3728
|
size: size,
|
|
3744
3729
|
isLoading: true
|
|
@@ -3753,7 +3738,7 @@ function FetchingWrappedAssetCard(props) {
|
|
|
3753
3738
|
getAssetUrl: getEntityUrl
|
|
3754
3739
|
});
|
|
3755
3740
|
|
|
3756
|
-
return React.createElement(WrappedAssetCard,
|
|
3741
|
+
return React.createElement(WrappedAssetCard, _extends({}, builtinCardProps));
|
|
3757
3742
|
}
|
|
3758
3743
|
|
|
3759
3744
|
if (props.renderCustomCard) {
|
|
@@ -3770,17 +3755,17 @@ function FetchingWrappedAssetCard(props) {
|
|
|
3770
3755
|
}
|
|
3771
3756
|
|
|
3772
3757
|
return renderDefaultCard(); // eslint-disable-next-line react-hooks/exhaustive-deps -- TODO: Evaluate the dependencies
|
|
3773
|
-
}, [props,
|
|
3758
|
+
}, [props, status, asset]);
|
|
3774
3759
|
}
|
|
3775
3760
|
|
|
3776
3761
|
function SingleMediaEditor(props) {
|
|
3777
|
-
return React.createElement(SingleReferenceEditor,
|
|
3762
|
+
return React.createElement(SingleReferenceEditor, _extends({}, props, {
|
|
3778
3763
|
entityType: "Asset"
|
|
3779
3764
|
}), function (_ref) {
|
|
3780
3765
|
var entityId = _ref.entityId,
|
|
3781
3766
|
isDisabled = _ref.isDisabled,
|
|
3782
3767
|
setValue = _ref.setValue;
|
|
3783
|
-
return React.createElement(FetchingWrappedAssetCard,
|
|
3768
|
+
return React.createElement(FetchingWrappedAssetCard, _extends({}, props, {
|
|
3784
3769
|
viewType: "big_card",
|
|
3785
3770
|
assetId: entityId,
|
|
3786
3771
|
isDisabled: isDisabled,
|
|
@@ -3802,12 +3787,12 @@ var styles$6 = {
|
|
|
3802
3787
|
})
|
|
3803
3788
|
};
|
|
3804
3789
|
function MultipleMediaEditor(props) {
|
|
3805
|
-
return React.createElement(MultipleReferenceEditor,
|
|
3790
|
+
return React.createElement(MultipleReferenceEditor, _extends({}, props, {
|
|
3806
3791
|
entityType: "Asset"
|
|
3807
3792
|
}), function (childrenProps) {
|
|
3808
3793
|
var _cx;
|
|
3809
3794
|
|
|
3810
|
-
return React.createElement(SortableLinkList,
|
|
3795
|
+
return React.createElement(SortableLinkList, _extends({}, childrenProps, {
|
|
3811
3796
|
className: emotion.cx((_cx = {}, _cx[styles$6.gridContainer] = childrenProps.viewType === 'card', _cx)),
|
|
3812
3797
|
axis: childrenProps.viewType === 'card' ? 'xy' : 'y',
|
|
3813
3798
|
useDragHandle: true
|
|
@@ -3817,7 +3802,7 @@ function MultipleMediaEditor(props) {
|
|
|
3817
3802
|
index = _ref.index,
|
|
3818
3803
|
isDisabled = _ref.isDisabled,
|
|
3819
3804
|
DragHandle = _ref.DragHandle;
|
|
3820
|
-
return React.createElement(FetchingWrappedAssetCard,
|
|
3805
|
+
return React.createElement(FetchingWrappedAssetCard, _extends({}, childrenProps, {
|
|
3821
3806
|
isDisabled: isDisabled,
|
|
3822
3807
|
key: item.sys.id + "-" + index,
|
|
3823
3808
|
assetId: item.sys.id,
|
|
@@ -3835,6 +3820,448 @@ MultipleMediaEditor.defaultProps = {
|
|
|
3835
3820
|
isInitiallyDisabled: true
|
|
3836
3821
|
};
|
|
3837
3822
|
|
|
3823
|
+
var resolveAsset = function resolveAsset() {
|
|
3824
|
+
return Promise.resolve();
|
|
3825
|
+
}; // we don't want to show scheduled actions for resources
|
|
3826
|
+
|
|
3827
|
+
|
|
3828
|
+
var resolveScheduledActions = function resolveScheduledActions() {
|
|
3829
|
+
return Promise.resolve([]);
|
|
3830
|
+
};
|
|
3831
|
+
|
|
3832
|
+
function ContentfulEntryCard(_ref) {
|
|
3833
|
+
var info = _ref.info,
|
|
3834
|
+
isDisabled = _ref.isDisabled,
|
|
3835
|
+
renderDragHandle = _ref.renderDragHandle,
|
|
3836
|
+
onRemove = _ref.onRemove,
|
|
3837
|
+
onMoveTop = _ref.onMoveTop,
|
|
3838
|
+
onMoveBottom = _ref.onMoveBottom,
|
|
3839
|
+
getEntryRouteHref = _ref.getEntryRouteHref;
|
|
3840
|
+
var resourceSys = info.resource.sys;
|
|
3841
|
+
var spaceId = resourceSys.space.sys.id;
|
|
3842
|
+
var environmentId = resourceSys.environment.sys.id;
|
|
3843
|
+
var entryId = resourceSys.id;
|
|
3844
|
+
var resourceHref = getEntryRouteHref({
|
|
3845
|
+
spaceId: spaceId,
|
|
3846
|
+
environmentId: environmentId,
|
|
3847
|
+
entryId: entryId
|
|
3848
|
+
}); // TODO: move this into `sdk.navigator.openEntry()`, note that it's signature only include the entry id (not a space or environment)
|
|
3849
|
+
|
|
3850
|
+
var openEntryDetail = function openEntryDetail() {
|
|
3851
|
+
window.open(resourceHref, '_blank', 'noopener,noreferrer');
|
|
3852
|
+
};
|
|
3853
|
+
|
|
3854
|
+
return React.createElement(WrappedEntryCard, {
|
|
3855
|
+
entry: info.resource,
|
|
3856
|
+
isDisabled: isDisabled,
|
|
3857
|
+
hasCardEditActions: false,
|
|
3858
|
+
contentType: info.contentType,
|
|
3859
|
+
// we use the default locale from the space the entry belongs to
|
|
3860
|
+
// as we assume this gives a more consistent behaviour.
|
|
3861
|
+
// locales will inevitably differ from space to space, so it's likely
|
|
3862
|
+
// that the current locale does not exist in the "remote" space
|
|
3863
|
+
localeCode: info.defaultLocaleCode,
|
|
3864
|
+
defaultLocaleCode: info.defaultLocaleCode,
|
|
3865
|
+
size: "small",
|
|
3866
|
+
getAsset: resolveAsset,
|
|
3867
|
+
getEntityScheduledActions: resolveScheduledActions,
|
|
3868
|
+
spaceName: info.space.name,
|
|
3869
|
+
renderDragHandle: renderDragHandle,
|
|
3870
|
+
isClickable: true,
|
|
3871
|
+
onEdit: openEntryDetail,
|
|
3872
|
+
hasCardRemoveActions: Boolean(onRemove),
|
|
3873
|
+
onRemove: onRemove,
|
|
3874
|
+
onMoveBottom: onMoveBottom,
|
|
3875
|
+
onMoveTop: onMoveTop,
|
|
3876
|
+
entryUrl: resourceHref
|
|
3877
|
+
});
|
|
3878
|
+
}
|
|
3879
|
+
|
|
3880
|
+
var styles$7 = {
|
|
3881
|
+
card: /*#__PURE__*/emotion.css({
|
|
3882
|
+
position: 'relative'
|
|
3883
|
+
})
|
|
3884
|
+
};
|
|
3885
|
+
function UnsupportedEntityCard(props) {
|
|
3886
|
+
return React__default.createElement(f36Components.Card, {
|
|
3887
|
+
className: styles$7.card
|
|
3888
|
+
}, React__default.createElement(f36Components.SectionHeading, {
|
|
3889
|
+
marginBottom: "none"
|
|
3890
|
+
}, "Resource type ", props.entityType, " is currently not supported"));
|
|
3891
|
+
}
|
|
3892
|
+
|
|
3893
|
+
function ResourceCardSkeleton() {
|
|
3894
|
+
return React.createElement(f36Components.EntryCard, {
|
|
3895
|
+
size: "small",
|
|
3896
|
+
isLoading: true
|
|
3897
|
+
});
|
|
3898
|
+
}
|
|
3899
|
+
|
|
3900
|
+
function ExistingResourceCard(props) {
|
|
3901
|
+
var resourceLink = props.resourceLink,
|
|
3902
|
+
inView = props.inView,
|
|
3903
|
+
_props$index = props.index,
|
|
3904
|
+
index = _props$index === void 0 ? 0 : _props$index;
|
|
3905
|
+
var resourceOptions = {
|
|
3906
|
+
priority: index * -1,
|
|
3907
|
+
enabled: inView
|
|
3908
|
+
};
|
|
3909
|
+
|
|
3910
|
+
var _useResource = useResource(resourceLink.sys.linkType, resourceLink.sys.urn, resourceOptions),
|
|
3911
|
+
data = _useResource.data,
|
|
3912
|
+
error = _useResource.error;
|
|
3913
|
+
|
|
3914
|
+
if (!data && !error) {
|
|
3915
|
+
return React.createElement(ResourceCardSkeleton, null);
|
|
3916
|
+
}
|
|
3917
|
+
|
|
3918
|
+
if (data) {
|
|
3919
|
+
return React.createElement(ContentfulEntryCard, _extends({
|
|
3920
|
+
info: data
|
|
3921
|
+
}, props));
|
|
3922
|
+
}
|
|
3923
|
+
|
|
3924
|
+
if (isUnsupportedError(error)) {
|
|
3925
|
+
return React.createElement(UnsupportedEntityCard, {
|
|
3926
|
+
entityType: resourceLink.sys.linkType
|
|
3927
|
+
});
|
|
3928
|
+
}
|
|
3929
|
+
|
|
3930
|
+
return React.createElement(MissingEntityCard, {
|
|
3931
|
+
entityType: "Entry",
|
|
3932
|
+
isDisabled: props.isDisabled,
|
|
3933
|
+
onRemove: props.onRemove
|
|
3934
|
+
});
|
|
3935
|
+
}
|
|
3936
|
+
|
|
3937
|
+
function ResourceCardWrapper(props) {
|
|
3938
|
+
if (!props.resourceLink) {
|
|
3939
|
+
return null;
|
|
3940
|
+
}
|
|
3941
|
+
|
|
3942
|
+
return React.createElement(ExistingResourceCard, _extends({}, props, {
|
|
3943
|
+
resourceLink: props.resourceLink,
|
|
3944
|
+
getEntryRouteHref: props.getEntryRouteHref
|
|
3945
|
+
}));
|
|
3946
|
+
}
|
|
3947
|
+
|
|
3948
|
+
function ResourceCard(props) {
|
|
3949
|
+
var _useInView = reactIntersectionObserver.useInView({
|
|
3950
|
+
triggerOnce: true,
|
|
3951
|
+
rootMargin: '300px 0px 0px 300px'
|
|
3952
|
+
}),
|
|
3953
|
+
ref = _useInView.ref,
|
|
3954
|
+
inView = _useInView.inView; // Forma does not offer us to pass refs, so we need an additional wrapper here
|
|
3955
|
+
|
|
3956
|
+
|
|
3957
|
+
return React.createElement("div", {
|
|
3958
|
+
ref: ref
|
|
3959
|
+
}, React.createElement(ResourceCardWrapper, _extends({}, props, {
|
|
3960
|
+
inView: inView
|
|
3961
|
+
})));
|
|
3962
|
+
}
|
|
3963
|
+
|
|
3964
|
+
function useResourceLinkActions(_ref) {
|
|
3965
|
+
var apiUrl = _ref.apiUrl,
|
|
3966
|
+
dialogs = _ref.dialogs,
|
|
3967
|
+
field = _ref.field,
|
|
3968
|
+
onAfterLink = _ref.onAfterLink;
|
|
3969
|
+
var handleAfterLink = React.useCallback(function (entries) {
|
|
3970
|
+
if (!onAfterLink) {
|
|
3971
|
+
return;
|
|
3972
|
+
}
|
|
3973
|
+
|
|
3974
|
+
entries.forEach(onAfterLink);
|
|
3975
|
+
}, [onAfterLink]);
|
|
3976
|
+
var multiple = field.type === 'Array';
|
|
3977
|
+
var toLinkItem = React.useMemo(function () {
|
|
3978
|
+
function toUrn(entry) {
|
|
3979
|
+
return "crn:" + apiUrl + ":::content:spaces/" + entry.sys.space.sys.id + "/entries/" + entry.sys.id;
|
|
3980
|
+
}
|
|
3981
|
+
|
|
3982
|
+
return function (entry) {
|
|
3983
|
+
return {
|
|
3984
|
+
sys: {
|
|
3985
|
+
type: 'ResourceLink',
|
|
3986
|
+
linkType: 'Contentful:Entry',
|
|
3987
|
+
urn: toUrn(entry)
|
|
3988
|
+
}
|
|
3989
|
+
};
|
|
3990
|
+
};
|
|
3991
|
+
}, [apiUrl]);
|
|
3992
|
+
var onLinkedExisting = React.useMemo(function () {
|
|
3993
|
+
if (multiple) {
|
|
3994
|
+
return function (entries) {
|
|
3995
|
+
var linkItems = entries.map(toLinkItem);
|
|
3996
|
+
var prevValue = field.getValue() || [];
|
|
3997
|
+
var updatedValue = [].concat(prevValue, linkItems);
|
|
3998
|
+
field.setValue(updatedValue);
|
|
3999
|
+
handleAfterLink(entries);
|
|
4000
|
+
};
|
|
4001
|
+
} else {
|
|
4002
|
+
return function (entries) {
|
|
4003
|
+
var entry = entries[0];
|
|
4004
|
+
field.setValue(toLinkItem(entry));
|
|
4005
|
+
handleAfterLink([entry]);
|
|
4006
|
+
};
|
|
4007
|
+
}
|
|
4008
|
+
}, [field, handleAfterLink, multiple, toLinkItem]);
|
|
4009
|
+
var onLinkExisting = React.useMemo(function () {
|
|
4010
|
+
var promptSelection = multiple ? /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee() {
|
|
4011
|
+
return runtime_1.wrap(function _callee$(_context) {
|
|
4012
|
+
while (1) {
|
|
4013
|
+
switch (_context.prev = _context.next) {
|
|
4014
|
+
case 0:
|
|
4015
|
+
_context.next = 2;
|
|
4016
|
+
return dialogs.selectMultipleResourceEntries({
|
|
4017
|
+
// @ts-expect-error wait for update of app-sdk version
|
|
4018
|
+
allowedResources: field.allowedResources
|
|
4019
|
+
});
|
|
4020
|
+
|
|
4021
|
+
case 2:
|
|
4022
|
+
return _context.abrupt("return", _context.sent);
|
|
4023
|
+
|
|
4024
|
+
case 3:
|
|
4025
|
+
case "end":
|
|
4026
|
+
return _context.stop();
|
|
4027
|
+
}
|
|
4028
|
+
}
|
|
4029
|
+
}, _callee);
|
|
4030
|
+
})) : /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2() {
|
|
4031
|
+
return runtime_1.wrap(function _callee2$(_context2) {
|
|
4032
|
+
while (1) {
|
|
4033
|
+
switch (_context2.prev = _context2.next) {
|
|
4034
|
+
case 0:
|
|
4035
|
+
_context2.next = 2;
|
|
4036
|
+
return dialogs.selectSingleResourceEntry({
|
|
4037
|
+
// @ts-expect-error wait for update of app-sdk version
|
|
4038
|
+
allowedResources: field.allowedResources
|
|
4039
|
+
});
|
|
4040
|
+
|
|
4041
|
+
case 2:
|
|
4042
|
+
_context2.t0 = _context2.sent;
|
|
4043
|
+
return _context2.abrupt("return", [_context2.t0]);
|
|
4044
|
+
|
|
4045
|
+
case 4:
|
|
4046
|
+
case "end":
|
|
4047
|
+
return _context2.stop();
|
|
4048
|
+
}
|
|
4049
|
+
}
|
|
4050
|
+
}, _callee2);
|
|
4051
|
+
}));
|
|
4052
|
+
return /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3() {
|
|
4053
|
+
var res;
|
|
4054
|
+
return runtime_1.wrap(function _callee3$(_context3) {
|
|
4055
|
+
while (1) {
|
|
4056
|
+
switch (_context3.prev = _context3.next) {
|
|
4057
|
+
case 0:
|
|
4058
|
+
_context3.next = 2;
|
|
4059
|
+
return promptSelection();
|
|
4060
|
+
|
|
4061
|
+
case 2:
|
|
4062
|
+
res = _context3.sent;
|
|
4063
|
+
|
|
4064
|
+
if (res) {
|
|
4065
|
+
_context3.next = 5;
|
|
4066
|
+
break;
|
|
4067
|
+
}
|
|
4068
|
+
|
|
4069
|
+
return _context3.abrupt("return");
|
|
4070
|
+
|
|
4071
|
+
case 5:
|
|
4072
|
+
onLinkedExisting(res);
|
|
4073
|
+
|
|
4074
|
+
case 6:
|
|
4075
|
+
case "end":
|
|
4076
|
+
return _context3.stop();
|
|
4077
|
+
}
|
|
4078
|
+
}
|
|
4079
|
+
}, _callee3);
|
|
4080
|
+
})); // @ts-expect-error wait for update of app-sdk version
|
|
4081
|
+
}, [dialogs, field.allowedResources, multiple, onLinkedExisting]);
|
|
4082
|
+
return {
|
|
4083
|
+
onLinkExisting: onLinkExisting,
|
|
4084
|
+
onLinkedExisting: onLinkedExisting,
|
|
4085
|
+
// hardcoded values to match interface for standard reference field actions
|
|
4086
|
+
entityType: 'Entry',
|
|
4087
|
+
contentTypes: [],
|
|
4088
|
+
canCreateEntity: false,
|
|
4089
|
+
canLinkMultiple: multiple,
|
|
4090
|
+
canLinkEntity: true,
|
|
4091
|
+
isDisabled: false,
|
|
4092
|
+
isEmpty: false,
|
|
4093
|
+
isFull: false,
|
|
4094
|
+
// eslint-disable-next-line -- hardcoded values to match interface for standard reference field actions
|
|
4095
|
+
onCreate: function () {
|
|
4096
|
+
var _onCreate = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee4() {
|
|
4097
|
+
return runtime_1.wrap(function _callee4$(_context4) {
|
|
4098
|
+
while (1) {
|
|
4099
|
+
switch (_context4.prev = _context4.next) {
|
|
4100
|
+
case 0:
|
|
4101
|
+
case "end":
|
|
4102
|
+
return _context4.stop();
|
|
4103
|
+
}
|
|
4104
|
+
}
|
|
4105
|
+
}, _callee4);
|
|
4106
|
+
}));
|
|
4107
|
+
|
|
4108
|
+
function onCreate() {
|
|
4109
|
+
return _onCreate.apply(this, arguments);
|
|
4110
|
+
}
|
|
4111
|
+
|
|
4112
|
+
return onCreate;
|
|
4113
|
+
}(),
|
|
4114
|
+
// eslint-disable-next-line -- hardcoded values to match interface for standard reference field actions
|
|
4115
|
+
onCreated: function onCreated() {}
|
|
4116
|
+
};
|
|
4117
|
+
}
|
|
4118
|
+
|
|
4119
|
+
function ResourceEditor(props) {
|
|
4120
|
+
var setValue = props.setValue,
|
|
4121
|
+
items = props.items,
|
|
4122
|
+
apiUrl = props.apiUrl;
|
|
4123
|
+
var onSortStart = React.useCallback(function (_, event) {
|
|
4124
|
+
return event.preventDefault();
|
|
4125
|
+
}, []);
|
|
4126
|
+
var onSortEnd = React.useCallback(function (_ref) {
|
|
4127
|
+
var oldIndex = _ref.oldIndex,
|
|
4128
|
+
newIndex = _ref.newIndex;
|
|
4129
|
+
var newItems = arrayMove(items, oldIndex, newIndex);
|
|
4130
|
+
setValue(newItems);
|
|
4131
|
+
}, [items, setValue]);
|
|
4132
|
+
var onMove = React.useCallback(function (oldIndex, newIndex) {
|
|
4133
|
+
var newItems = arrayMove(items, oldIndex, newIndex);
|
|
4134
|
+
setValue(newItems);
|
|
4135
|
+
}, [items, setValue]);
|
|
4136
|
+
var onRemoteItemAtIndex = React.useCallback(function (index) {
|
|
4137
|
+
setValue(items.filter(function (_v, i) {
|
|
4138
|
+
return i !== index;
|
|
4139
|
+
}));
|
|
4140
|
+
}, [items, setValue]);
|
|
4141
|
+
var _props$sdk = props.sdk,
|
|
4142
|
+
dialogs = _props$sdk.dialogs,
|
|
4143
|
+
field = _props$sdk.field;
|
|
4144
|
+
var linkActionsProps = useResourceLinkActions({
|
|
4145
|
+
dialogs: dialogs,
|
|
4146
|
+
field: field,
|
|
4147
|
+
apiUrl: apiUrl
|
|
4148
|
+
});
|
|
4149
|
+
return React.createElement(React.Fragment, null, props.children(_extends({}, props, {
|
|
4150
|
+
onSortStart: onSortStart,
|
|
4151
|
+
onSortEnd: onSortEnd,
|
|
4152
|
+
onMove: onMove,
|
|
4153
|
+
onRemoteItemAtIndex: onRemoteItemAtIndex
|
|
4154
|
+
})), React.createElement(CombinedLinkActions, _extends({}, linkActionsProps)));
|
|
4155
|
+
} // provides memoized callbacks bound to a given item
|
|
4156
|
+
|
|
4157
|
+
|
|
4158
|
+
function WithPerItemCallbacks(_ref2) {
|
|
4159
|
+
var listLength = _ref2.listLength,
|
|
4160
|
+
index = _ref2.index,
|
|
4161
|
+
onMove = _ref2.onMove,
|
|
4162
|
+
onRemoteItemAtIndex = _ref2.onRemoteItemAtIndex,
|
|
4163
|
+
children = _ref2.children;
|
|
4164
|
+
var handleMoveTop = React.useMemo(function () {
|
|
4165
|
+
return index > 0 ? function () {
|
|
4166
|
+
return onMove(index, 0);
|
|
4167
|
+
} : undefined;
|
|
4168
|
+
}, [index, onMove]);
|
|
4169
|
+
var handleMoveBottom = React.useMemo(function () {
|
|
4170
|
+
return index < listLength - 1 ? function () {
|
|
4171
|
+
return onMove(index, listLength - 1);
|
|
4172
|
+
} : undefined;
|
|
4173
|
+
}, [index, onMove, listLength]);
|
|
4174
|
+
var handleRemove = React.useCallback(function () {
|
|
4175
|
+
return onRemoteItemAtIndex(index);
|
|
4176
|
+
}, [index, onRemoteItemAtIndex]);
|
|
4177
|
+
return React.createElement(React.Fragment, null, children({
|
|
4178
|
+
onMoveBottom: handleMoveBottom,
|
|
4179
|
+
onMoveTop: handleMoveTop,
|
|
4180
|
+
onRemove: handleRemove
|
|
4181
|
+
}));
|
|
4182
|
+
}
|
|
4183
|
+
|
|
4184
|
+
var EMPTY_ARRAY = [];
|
|
4185
|
+
function MultipleResourceReferenceEditor(props) {
|
|
4186
|
+
return React.createElement(EntityProvider, {
|
|
4187
|
+
sdk: props.sdk
|
|
4188
|
+
}, React.createElement(fieldEditorShared.FieldConnector, {
|
|
4189
|
+
throttle: 0,
|
|
4190
|
+
field: props.sdk.field,
|
|
4191
|
+
isInitiallyDisabled: props.isInitiallyDisabled,
|
|
4192
|
+
isEqualValues: deepEqual
|
|
4193
|
+
}, function (_ref3) {
|
|
4194
|
+
var value = _ref3.value,
|
|
4195
|
+
disabled = _ref3.disabled,
|
|
4196
|
+
setValue = _ref3.setValue,
|
|
4197
|
+
externalReset = _ref3.externalReset;
|
|
4198
|
+
return React.createElement(ResourceEditor, _extends({}, props, {
|
|
4199
|
+
items: value || EMPTY_ARRAY,
|
|
4200
|
+
isDisabled: disabled,
|
|
4201
|
+
setValue: setValue,
|
|
4202
|
+
key: externalReset + "-list"
|
|
4203
|
+
}), function (editorProps) {
|
|
4204
|
+
return React.createElement(SortableLinkList, _extends({}, editorProps), function (_ref4) {
|
|
4205
|
+
var item = _ref4.item,
|
|
4206
|
+
isDisabled = _ref4.isDisabled,
|
|
4207
|
+
DragHandle = _ref4.DragHandle,
|
|
4208
|
+
index = _ref4.index;
|
|
4209
|
+
return React.createElement(WithPerItemCallbacks, {
|
|
4210
|
+
index: index,
|
|
4211
|
+
onMove: editorProps.onMove,
|
|
4212
|
+
onRemoteItemAtIndex: editorProps.onRemoteItemAtIndex,
|
|
4213
|
+
listLength: (value == null ? void 0 : value.length) || 0
|
|
4214
|
+
}, function (_ref5) {
|
|
4215
|
+
var onMoveBottom = _ref5.onMoveBottom,
|
|
4216
|
+
onMoveTop = _ref5.onMoveTop,
|
|
4217
|
+
onRemove = _ref5.onRemove;
|
|
4218
|
+
return React.createElement(ResourceCard, {
|
|
4219
|
+
index: index,
|
|
4220
|
+
resourceLink: item,
|
|
4221
|
+
isDisabled: isDisabled,
|
|
4222
|
+
renderDragHandle: DragHandle,
|
|
4223
|
+
onMoveTop: onMoveTop,
|
|
4224
|
+
onMoveBottom: onMoveBottom,
|
|
4225
|
+
onRemove: onRemove,
|
|
4226
|
+
getEntryRouteHref: props.getEntryRouteHref
|
|
4227
|
+
});
|
|
4228
|
+
});
|
|
4229
|
+
});
|
|
4230
|
+
});
|
|
4231
|
+
}));
|
|
4232
|
+
}
|
|
4233
|
+
|
|
4234
|
+
function SingleResourceReferenceEditor(props) {
|
|
4235
|
+
var _props$sdk = props.sdk,
|
|
4236
|
+
dialogs = _props$sdk.dialogs,
|
|
4237
|
+
field = _props$sdk.field;
|
|
4238
|
+
var linkActionsProps = useResourceLinkActions({
|
|
4239
|
+
dialogs: dialogs,
|
|
4240
|
+
field: field,
|
|
4241
|
+
apiUrl: props.apiUrl
|
|
4242
|
+
});
|
|
4243
|
+
return React.createElement(EntityProvider, {
|
|
4244
|
+
sdk: props.sdk
|
|
4245
|
+
}, React.createElement(fieldEditorShared.FieldConnector, {
|
|
4246
|
+
throttle: 0,
|
|
4247
|
+
field: props.sdk.field,
|
|
4248
|
+
isInitiallyDisabled: props.isInitiallyDisabled,
|
|
4249
|
+
isEqualValues: deepEqual
|
|
4250
|
+
}, function (_ref) {
|
|
4251
|
+
var value = _ref.value,
|
|
4252
|
+
disabled = _ref.disabled;
|
|
4253
|
+
return value ? React.createElement(ResourceCard, {
|
|
4254
|
+
onRemove: function onRemove() {
|
|
4255
|
+
return props.sdk.field.removeValue();
|
|
4256
|
+
},
|
|
4257
|
+
resourceLink: value,
|
|
4258
|
+
isDisabled: disabled,
|
|
4259
|
+
getEntryRouteHref: props.getEntryRouteHref
|
|
4260
|
+
}) : // TODO: support custom actions once publicly available
|
|
4261
|
+
React.createElement(CombinedLinkActions, _extends({}, linkActionsProps));
|
|
4262
|
+
}));
|
|
4263
|
+
}
|
|
4264
|
+
|
|
3838
4265
|
exports.AssetThumbnail = AssetThumbnail;
|
|
3839
4266
|
exports.CombinedLinkActions = CombinedLinkActions;
|
|
3840
4267
|
exports.CreateEntryLinkButton = CreateEntryLinkButton;
|
|
@@ -3843,12 +4270,16 @@ exports.EntityProvider = EntityProvider;
|
|
|
3843
4270
|
exports.MissingEntityCard = MissingEntityCard;
|
|
3844
4271
|
exports.MultipleEntryReferenceEditor = MultipleEntryReferenceEditor;
|
|
3845
4272
|
exports.MultipleMediaEditor = MultipleMediaEditor;
|
|
4273
|
+
exports.MultipleResourceReferenceEditor = MultipleResourceReferenceEditor;
|
|
3846
4274
|
exports.ScheduledIconWithTooltip = ScheduledIconWithTooltip;
|
|
3847
4275
|
exports.SingleEntryReferenceEditor = SingleEntryReferenceEditor;
|
|
3848
4276
|
exports.SingleMediaEditor = SingleMediaEditor;
|
|
4277
|
+
exports.SingleResourceReferenceEditor = SingleResourceReferenceEditor;
|
|
3849
4278
|
exports.SortableLinkList = SortableLinkList;
|
|
3850
4279
|
exports.WrappedAssetCard = WrappedAssetCard;
|
|
3851
4280
|
exports.WrappedEntryCard = WrappedEntryCard;
|
|
3852
4281
|
exports.getScheduleTooltipContent = getScheduleTooltipContent;
|
|
3853
|
-
exports.
|
|
4282
|
+
exports.useEntity = useEntity;
|
|
4283
|
+
exports.useEntityLoader = useEntityLoader;
|
|
4284
|
+
exports.useResource = useResource;
|
|
3854
4285
|
//# sourceMappingURL=field-editor-reference.cjs.development.js.map
|