@contentful/field-editor-reference 4.4.0 → 4.6.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 +18 -0
- package/dist/__fixtures__/FakeSdk.d.ts +20 -151
- package/dist/assets/WrappedAssetCard/FetchingWrappedAssetCard.d.ts +1 -1
- package/dist/common/EntityStore.d.ts +7 -1
- package/dist/common/SortableLinkList.d.ts +19 -0
- package/dist/entries/WrappedEntryCard/FetchingWrappedEntryCard.d.ts +2 -2
- package/dist/field-editor-reference.cjs.development.js +509 -165
- 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 +510 -167
- package/dist/field-editor-reference.esm.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/types.d.ts +30 -1
- package/package.json +4 -3
- package/dist/assets/SortableElements.d.ts +0 -8
- package/dist/entries/SortableElements.d.ts +0 -10
|
@@ -15,6 +15,7 @@ var moment = _interopDefault(require('moment'));
|
|
|
15
15
|
var deepEqual = _interopDefault(require('deep-equal'));
|
|
16
16
|
var fieldEditorShared = require('@contentful/field-editor-shared');
|
|
17
17
|
var constate = _interopDefault(require('constate'));
|
|
18
|
+
var contentfulManagement = require('contentful-management');
|
|
18
19
|
var isNumber = _interopDefault(require('lodash/isNumber'));
|
|
19
20
|
var arrayMove = _interopDefault(require('array-move'));
|
|
20
21
|
var reactSortableHoc = require('react-sortable-hoc');
|
|
@@ -89,6 +90,44 @@ function _objectWithoutPropertiesLoose(source, excluded) {
|
|
|
89
90
|
return target;
|
|
90
91
|
}
|
|
91
92
|
|
|
93
|
+
function _unsupportedIterableToArray(o, minLen) {
|
|
94
|
+
if (!o) return;
|
|
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);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
function _arrayLikeToArray(arr, len) {
|
|
103
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
104
|
+
|
|
105
|
+
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
106
|
+
|
|
107
|
+
return arr2;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function _createForOfIteratorHelperLoose(o, allowArrayLike) {
|
|
111
|
+
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
|
|
112
|
+
if (it) return (it = it.call(o)).next.bind(it);
|
|
113
|
+
|
|
114
|
+
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
|
|
115
|
+
if (it) o = it;
|
|
116
|
+
var i = 0;
|
|
117
|
+
return function () {
|
|
118
|
+
if (i >= o.length) return {
|
|
119
|
+
done: true
|
|
120
|
+
};
|
|
121
|
+
return {
|
|
122
|
+
done: false,
|
|
123
|
+
value: o[i++]
|
|
124
|
+
};
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
129
|
+
}
|
|
130
|
+
|
|
92
131
|
var container = /*#__PURE__*/emotion.css({
|
|
93
132
|
display: 'flex',
|
|
94
133
|
border: "1px dashed " + tokens.gray500,
|
|
@@ -1829,7 +1868,7 @@ function AssetThumbnail(props) {
|
|
|
1829
1868
|
}
|
|
1830
1869
|
|
|
1831
1870
|
function reducer(state, action) {
|
|
1832
|
-
var _extends2, _extends3, _extends4, _extends5, _extends6;
|
|
1871
|
+
var _extends2, _extends3, _extends4, _extends5, _extends6, _extends7, _extends8;
|
|
1833
1872
|
|
|
1834
1873
|
switch (action.type) {
|
|
1835
1874
|
case 'set_entry':
|
|
@@ -1857,6 +1896,16 @@ function reducer(state, action) {
|
|
|
1857
1896
|
scheduledActions: _extends({}, state.scheduledActions, (_extends6 = {}, _extends6[action.key] = action.actions, _extends6))
|
|
1858
1897
|
});
|
|
1859
1898
|
|
|
1899
|
+
case 'set_resource':
|
|
1900
|
+
return _extends({}, state, {
|
|
1901
|
+
resources: _extends({}, state.resources, (_extends7 = {}, _extends7[action.resourceType + "." + action.urn] = action.resourceInfo, _extends7))
|
|
1902
|
+
});
|
|
1903
|
+
|
|
1904
|
+
case 'set_resource_failed':
|
|
1905
|
+
return _extends({}, state, {
|
|
1906
|
+
resources: _extends({}, state.resources, (_extends8 = {}, _extends8[action.resourceType + "." + action.urn] = 'failed', _extends8))
|
|
1907
|
+
});
|
|
1908
|
+
|
|
1860
1909
|
default:
|
|
1861
1910
|
return state;
|
|
1862
1911
|
}
|
|
@@ -1865,10 +1914,34 @@ function reducer(state, action) {
|
|
|
1865
1914
|
var initialState = {
|
|
1866
1915
|
entries: {},
|
|
1867
1916
|
assets: {},
|
|
1868
|
-
scheduledActions: {}
|
|
1917
|
+
scheduledActions: {},
|
|
1918
|
+
resources: {}
|
|
1919
|
+
};
|
|
1920
|
+
|
|
1921
|
+
var isNotNil = function isNotNil(entity) {
|
|
1922
|
+
return Boolean(entity && entity !== 'failed');
|
|
1923
|
+
};
|
|
1924
|
+
|
|
1925
|
+
var nonNilResources = function nonNilResources(map) {
|
|
1926
|
+
return Object.entries(map).filter(function (_ref) {
|
|
1927
|
+
var value = _ref[1];
|
|
1928
|
+
return isNotNil(value);
|
|
1929
|
+
});
|
|
1869
1930
|
};
|
|
1870
1931
|
|
|
1871
1932
|
function useEntitiesStore(props) {
|
|
1933
|
+
var spaceId = props.sdk.ids.space;
|
|
1934
|
+
var environmentId = props.sdk.ids.environment;
|
|
1935
|
+
|
|
1936
|
+
var _React$useState = React.useState(function () {
|
|
1937
|
+
return contentfulManagement.createClient({
|
|
1938
|
+
apiAdapter: props.sdk.cmaAdapter
|
|
1939
|
+
}, {
|
|
1940
|
+
type: 'plain'
|
|
1941
|
+
});
|
|
1942
|
+
}),
|
|
1943
|
+
cmaClient = _React$useState[0];
|
|
1944
|
+
|
|
1872
1945
|
var _React$useReducer = React.useReducer(reducer, initialState),
|
|
1873
1946
|
state = _React$useReducer[0],
|
|
1874
1947
|
dispatch = _React$useReducer[1];
|
|
@@ -1896,78 +1969,348 @@ function useEntitiesStore(props) {
|
|
|
1896
1969
|
return [];
|
|
1897
1970
|
});
|
|
1898
1971
|
}, [props.sdk.space, state.scheduledActions]);
|
|
1899
|
-
var loadEntry = React.useCallback(function (
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
}, [props.sdk.space]);
|
|
1914
|
-
var loadAsset = React.useCallback(function (id) {
|
|
1915
|
-
return props.sdk.space.getAsset(id).then(function (asset) {
|
|
1916
|
-
dispatch({
|
|
1917
|
-
type: 'set_asset',
|
|
1918
|
-
id: id,
|
|
1919
|
-
asset: asset
|
|
1920
|
-
});
|
|
1921
|
-
return asset;
|
|
1922
|
-
})["catch"](function () {
|
|
1923
|
-
dispatch({
|
|
1924
|
-
type: 'set_asset_failed',
|
|
1925
|
-
id: id
|
|
1926
|
-
});
|
|
1927
|
-
});
|
|
1928
|
-
}, [props.sdk.space]);
|
|
1929
|
-
var getOrLoadAsset = React.useCallback(function (id) {
|
|
1930
|
-
if (state.assets[id] && state.assets[id] !== 'failed') {
|
|
1931
|
-
return Promise.resolve(state.assets[id]);
|
|
1932
|
-
}
|
|
1972
|
+
var loadEntry = React.useCallback( /*#__PURE__*/function () {
|
|
1973
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(entryId) {
|
|
1974
|
+
var entry;
|
|
1975
|
+
return runtime_1.wrap(function _callee$(_context) {
|
|
1976
|
+
while (1) {
|
|
1977
|
+
switch (_context.prev = _context.next) {
|
|
1978
|
+
case 0:
|
|
1979
|
+
_context.prev = 0;
|
|
1980
|
+
_context.next = 3;
|
|
1981
|
+
return cmaClient.entry.get({
|
|
1982
|
+
spaceId: spaceId,
|
|
1983
|
+
environmentId: environmentId,
|
|
1984
|
+
entryId: entryId
|
|
1985
|
+
});
|
|
1933
1986
|
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1987
|
+
case 3:
|
|
1988
|
+
entry = _context.sent;
|
|
1989
|
+
dispatch({
|
|
1990
|
+
type: 'set_entry',
|
|
1991
|
+
id: entryId,
|
|
1992
|
+
entry: entry
|
|
1993
|
+
});
|
|
1994
|
+
return _context.abrupt("return", entry);
|
|
1995
|
+
|
|
1996
|
+
case 8:
|
|
1997
|
+
_context.prev = 8;
|
|
1998
|
+
_context.t0 = _context["catch"](0);
|
|
1999
|
+
dispatch({
|
|
2000
|
+
type: 'set_entry_failed',
|
|
2001
|
+
id: entryId
|
|
2002
|
+
});
|
|
2003
|
+
return _context.abrupt("return");
|
|
2004
|
+
|
|
2005
|
+
case 12:
|
|
2006
|
+
case "end":
|
|
2007
|
+
return _context.stop();
|
|
2008
|
+
}
|
|
2009
|
+
}
|
|
2010
|
+
}, _callee, null, [[0, 8]]);
|
|
2011
|
+
}));
|
|
2012
|
+
|
|
2013
|
+
return function (_x) {
|
|
2014
|
+
return _ref2.apply(this, arguments);
|
|
2015
|
+
};
|
|
2016
|
+
}(), [cmaClient, spaceId, environmentId]);
|
|
2017
|
+
var getEntry = React.useCallback( /*#__PURE__*/function () {
|
|
2018
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(entryId) {
|
|
2019
|
+
var cachedEntry;
|
|
2020
|
+
return runtime_1.wrap(function _callee2$(_context2) {
|
|
2021
|
+
while (1) {
|
|
2022
|
+
switch (_context2.prev = _context2.next) {
|
|
2023
|
+
case 0:
|
|
2024
|
+
cachedEntry = state.entries[entryId];
|
|
2025
|
+
|
|
2026
|
+
if (!isNotNil(cachedEntry)) {
|
|
2027
|
+
_context2.next = 3;
|
|
2028
|
+
break;
|
|
2029
|
+
}
|
|
2030
|
+
|
|
2031
|
+
return _context2.abrupt("return", cachedEntry);
|
|
2032
|
+
|
|
2033
|
+
case 3:
|
|
2034
|
+
return _context2.abrupt("return", loadEntry(entryId));
|
|
2035
|
+
|
|
2036
|
+
case 4:
|
|
2037
|
+
case "end":
|
|
2038
|
+
return _context2.stop();
|
|
2039
|
+
}
|
|
2040
|
+
}
|
|
2041
|
+
}, _callee2);
|
|
2042
|
+
}));
|
|
2043
|
+
|
|
2044
|
+
return function (_x2) {
|
|
2045
|
+
return _ref3.apply(this, arguments);
|
|
2046
|
+
};
|
|
2047
|
+
}(), [loadEntry, state.entries]);
|
|
2048
|
+
var loadAsset = React.useCallback( /*#__PURE__*/function () {
|
|
2049
|
+
var _ref4 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3(assetId) {
|
|
2050
|
+
var asset;
|
|
2051
|
+
return runtime_1.wrap(function _callee3$(_context3) {
|
|
2052
|
+
while (1) {
|
|
2053
|
+
switch (_context3.prev = _context3.next) {
|
|
2054
|
+
case 0:
|
|
2055
|
+
_context3.prev = 0;
|
|
2056
|
+
_context3.next = 3;
|
|
2057
|
+
return cmaClient.asset.get({
|
|
2058
|
+
spaceId: spaceId,
|
|
2059
|
+
environmentId: environmentId,
|
|
2060
|
+
assetId: assetId
|
|
2061
|
+
});
|
|
2062
|
+
|
|
2063
|
+
case 3:
|
|
2064
|
+
asset = _context3.sent;
|
|
2065
|
+
dispatch({
|
|
2066
|
+
type: 'set_asset',
|
|
2067
|
+
id: assetId,
|
|
2068
|
+
asset: asset
|
|
2069
|
+
});
|
|
2070
|
+
return _context3.abrupt("return", asset);
|
|
2071
|
+
|
|
2072
|
+
case 8:
|
|
2073
|
+
_context3.prev = 8;
|
|
2074
|
+
_context3.t0 = _context3["catch"](0);
|
|
2075
|
+
dispatch({
|
|
2076
|
+
type: 'set_asset_failed',
|
|
2077
|
+
id: assetId
|
|
2078
|
+
});
|
|
2079
|
+
return _context3.abrupt("return");
|
|
2080
|
+
|
|
2081
|
+
case 12:
|
|
2082
|
+
case "end":
|
|
2083
|
+
return _context3.stop();
|
|
2084
|
+
}
|
|
2085
|
+
}
|
|
2086
|
+
}, _callee3, null, [[0, 8]]);
|
|
2087
|
+
}));
|
|
2088
|
+
|
|
2089
|
+
return function (_x3) {
|
|
2090
|
+
return _ref4.apply(this, arguments);
|
|
2091
|
+
};
|
|
2092
|
+
}(), [cmaClient, spaceId, environmentId]);
|
|
2093
|
+
var getAsset = React.useCallback( /*#__PURE__*/function () {
|
|
2094
|
+
var _ref5 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee4(assetId) {
|
|
2095
|
+
var cachedAsset;
|
|
2096
|
+
return runtime_1.wrap(function _callee4$(_context4) {
|
|
2097
|
+
while (1) {
|
|
2098
|
+
switch (_context4.prev = _context4.next) {
|
|
2099
|
+
case 0:
|
|
2100
|
+
cachedAsset = state.assets[assetId];
|
|
2101
|
+
|
|
2102
|
+
if (!isNotNil(cachedAsset)) {
|
|
2103
|
+
_context4.next = 3;
|
|
2104
|
+
break;
|
|
2105
|
+
}
|
|
2106
|
+
|
|
2107
|
+
return _context4.abrupt("return", cachedAsset);
|
|
2108
|
+
|
|
2109
|
+
case 3:
|
|
2110
|
+
return _context4.abrupt("return", loadAsset(assetId));
|
|
2111
|
+
|
|
2112
|
+
case 4:
|
|
2113
|
+
case "end":
|
|
2114
|
+
return _context4.stop();
|
|
2115
|
+
}
|
|
2116
|
+
}
|
|
2117
|
+
}, _callee4);
|
|
2118
|
+
}));
|
|
2119
|
+
|
|
2120
|
+
return function (_x4) {
|
|
2121
|
+
return _ref5.apply(this, arguments);
|
|
2122
|
+
};
|
|
2123
|
+
}(), [loadAsset, state.assets]);
|
|
2124
|
+
var loadContentfulEntry = React.useCallback( /*#__PURE__*/function () {
|
|
2125
|
+
var _ref6 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee5(urn) {
|
|
2126
|
+
var _locales$items$find;
|
|
2127
|
+
|
|
2128
|
+
var resourceId, _resourceId$split, spaceId, entryId, environmentId, _yield$Promise$all, space, entry, contentTypeId, _yield$Promise$all2, contentType, locales, defaultLocaleCode;
|
|
2129
|
+
|
|
2130
|
+
return runtime_1.wrap(function _callee5$(_context5) {
|
|
2131
|
+
while (1) {
|
|
2132
|
+
switch (_context5.prev = _context5.next) {
|
|
2133
|
+
case 0:
|
|
2134
|
+
resourceId = urn.split(':', 6)[5];
|
|
2135
|
+
_resourceId$split = resourceId.split('/'), spaceId = _resourceId$split[1], entryId = _resourceId$split[3];
|
|
2136
|
+
environmentId = 'master';
|
|
2137
|
+
_context5.t0 = Promise;
|
|
2138
|
+
_context5.next = 6;
|
|
2139
|
+
return cmaClient.space.get({
|
|
2140
|
+
spaceId: spaceId
|
|
2141
|
+
});
|
|
2142
|
+
|
|
2143
|
+
case 6:
|
|
2144
|
+
_context5.t1 = _context5.sent;
|
|
2145
|
+
_context5.next = 9;
|
|
2146
|
+
return cmaClient.entry.get({
|
|
2147
|
+
spaceId: spaceId,
|
|
2148
|
+
environmentId: environmentId,
|
|
2149
|
+
entryId: entryId
|
|
2150
|
+
});
|
|
2151
|
+
|
|
2152
|
+
case 9:
|
|
2153
|
+
_context5.t2 = _context5.sent;
|
|
2154
|
+
_context5.t3 = [_context5.t1, _context5.t2];
|
|
2155
|
+
_context5.next = 13;
|
|
2156
|
+
return _context5.t0.all.call(_context5.t0, _context5.t3);
|
|
2157
|
+
|
|
2158
|
+
case 13:
|
|
2159
|
+
_yield$Promise$all = _context5.sent;
|
|
2160
|
+
space = _yield$Promise$all[0];
|
|
2161
|
+
entry = _yield$Promise$all[1];
|
|
2162
|
+
contentTypeId = entry.sys.contentType.sys.id;
|
|
2163
|
+
_context5.t4 = Promise;
|
|
2164
|
+
_context5.next = 20;
|
|
2165
|
+
return cmaClient.contentType.get({
|
|
2166
|
+
contentTypeId: contentTypeId,
|
|
2167
|
+
spaceId: spaceId,
|
|
2168
|
+
environmentId: environmentId
|
|
2169
|
+
});
|
|
2170
|
+
|
|
2171
|
+
case 20:
|
|
2172
|
+
_context5.t5 = _context5.sent;
|
|
2173
|
+
_context5.next = 23;
|
|
2174
|
+
return cmaClient.locale.getMany({
|
|
2175
|
+
spaceId: spaceId,
|
|
2176
|
+
environmentId: environmentId,
|
|
2177
|
+
query: {
|
|
2178
|
+
limit: 100
|
|
2179
|
+
}
|
|
2180
|
+
});
|
|
2181
|
+
|
|
2182
|
+
case 23:
|
|
2183
|
+
_context5.t6 = _context5.sent;
|
|
2184
|
+
_context5.t7 = [_context5.t5, _context5.t6];
|
|
2185
|
+
_context5.next = 27;
|
|
2186
|
+
return _context5.t4.all.call(_context5.t4, _context5.t7);
|
|
2187
|
+
|
|
2188
|
+
case 27:
|
|
2189
|
+
_yield$Promise$all2 = _context5.sent;
|
|
2190
|
+
contentType = _yield$Promise$all2[0];
|
|
2191
|
+
locales = _yield$Promise$all2[1];
|
|
2192
|
+
defaultLocaleCode = (_locales$items$find = locales.items.find(function (locale) {
|
|
2193
|
+
return locale["default"];
|
|
2194
|
+
})) == null ? void 0 : _locales$items$find.code;
|
|
2195
|
+
return _context5.abrupt("return", {
|
|
2196
|
+
resource: entry,
|
|
2197
|
+
defaultLocaleCode: defaultLocaleCode,
|
|
2198
|
+
space: space,
|
|
2199
|
+
contentType: contentType
|
|
2200
|
+
});
|
|
2201
|
+
|
|
2202
|
+
case 32:
|
|
2203
|
+
case "end":
|
|
2204
|
+
return _context5.stop();
|
|
2205
|
+
}
|
|
2206
|
+
}
|
|
2207
|
+
}, _callee5);
|
|
2208
|
+
}));
|
|
2209
|
+
|
|
2210
|
+
return function (_x5) {
|
|
2211
|
+
return _ref6.apply(this, arguments);
|
|
2212
|
+
};
|
|
2213
|
+
}(), [cmaClient]);
|
|
2214
|
+
var getResource = React.useCallback( /*#__PURE__*/function () {
|
|
2215
|
+
var _ref7 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee6(resourceType, urn) {
|
|
2216
|
+
var cachedResource, resourceInfo;
|
|
2217
|
+
return runtime_1.wrap(function _callee6$(_context6) {
|
|
2218
|
+
while (1) {
|
|
2219
|
+
switch (_context6.prev = _context6.next) {
|
|
2220
|
+
case 0:
|
|
2221
|
+
cachedResource = state.resources[resourceType + "." + urn];
|
|
2222
|
+
|
|
2223
|
+
if (!isNotNil(cachedResource)) {
|
|
2224
|
+
_context6.next = 3;
|
|
2225
|
+
break;
|
|
2226
|
+
}
|
|
2227
|
+
|
|
2228
|
+
return _context6.abrupt("return", cachedResource);
|
|
2229
|
+
|
|
2230
|
+
case 3:
|
|
2231
|
+
_context6.prev = 3;
|
|
2232
|
+
|
|
2233
|
+
if (!(resourceType === 'Contentful:Entry')) {
|
|
2234
|
+
_context6.next = 8;
|
|
2235
|
+
break;
|
|
2236
|
+
}
|
|
2237
|
+
|
|
2238
|
+
_context6.next = 7;
|
|
2239
|
+
return loadContentfulEntry(urn);
|
|
2240
|
+
|
|
2241
|
+
case 7:
|
|
2242
|
+
resourceInfo = _context6.sent;
|
|
2243
|
+
|
|
2244
|
+
case 8:
|
|
2245
|
+
dispatch({
|
|
2246
|
+
type: 'set_resource',
|
|
2247
|
+
resourceType: resourceType,
|
|
2248
|
+
urn: urn,
|
|
2249
|
+
resourceInfo: resourceInfo
|
|
2250
|
+
});
|
|
2251
|
+
return _context6.abrupt("return", resourceInfo);
|
|
2252
|
+
|
|
2253
|
+
case 12:
|
|
2254
|
+
_context6.prev = 12;
|
|
2255
|
+
_context6.t0 = _context6["catch"](3);
|
|
2256
|
+
dispatch({
|
|
2257
|
+
type: 'set_resource_failed',
|
|
2258
|
+
resourceType: resourceType,
|
|
2259
|
+
urn: urn
|
|
2260
|
+
});
|
|
2261
|
+
return _context6.abrupt("return");
|
|
2262
|
+
|
|
2263
|
+
case 16:
|
|
2264
|
+
case "end":
|
|
2265
|
+
return _context6.stop();
|
|
2266
|
+
}
|
|
2267
|
+
}
|
|
2268
|
+
}, _callee6, null, [[3, 12]]);
|
|
2269
|
+
}));
|
|
1940
2270
|
|
|
1941
|
-
return
|
|
1942
|
-
|
|
2271
|
+
return function (_x6, _x7) {
|
|
2272
|
+
return _ref7.apply(this, arguments);
|
|
2273
|
+
};
|
|
2274
|
+
}(), [loadContentfulEntry, state.resources]);
|
|
1943
2275
|
React.useEffect(function () {
|
|
1944
2276
|
// @ts-expect-error
|
|
1945
2277
|
if (typeof props.sdk.space.onEntityChanged !== 'undefined') {
|
|
1946
2278
|
// @ts-expect-error
|
|
1947
2279
|
var onEntityChanged = props.sdk.space.onEntityChanged;
|
|
1948
2280
|
var listeners = [];
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
2281
|
+
|
|
2282
|
+
var _loop = function _loop() {
|
|
2283
|
+
var _step$value = _step.value,
|
|
2284
|
+
id = _step$value[0];
|
|
2285
|
+
listeners.push(onEntityChanged('Entry', id, function (entry) {
|
|
2286
|
+
return dispatch({
|
|
2287
|
+
type: 'set_entry',
|
|
2288
|
+
id: id,
|
|
2289
|
+
entry: entry
|
|
2290
|
+
});
|
|
2291
|
+
}));
|
|
2292
|
+
};
|
|
2293
|
+
|
|
2294
|
+
for (var _iterator = _createForOfIteratorHelperLoose(nonNilResources(state.entries)), _step; !(_step = _iterator()).done;) {
|
|
2295
|
+
_loop();
|
|
2296
|
+
}
|
|
2297
|
+
|
|
2298
|
+
var _loop2 = function _loop2() {
|
|
2299
|
+
var _step2$value = _step2.value,
|
|
2300
|
+
id = _step2$value[0];
|
|
2301
|
+
listeners.push(onEntityChanged('Asset', id, function (asset) {
|
|
2302
|
+
return dispatch({
|
|
2303
|
+
type: 'set_asset',
|
|
2304
|
+
id: id,
|
|
2305
|
+
asset: asset
|
|
2306
|
+
});
|
|
2307
|
+
}));
|
|
2308
|
+
};
|
|
2309
|
+
|
|
2310
|
+
for (var _iterator2 = _createForOfIteratorHelperLoose(nonNilResources(state.assets)), _step2; !(_step2 = _iterator2()).done;) {
|
|
2311
|
+
_loop2();
|
|
2312
|
+
}
|
|
2313
|
+
|
|
1971
2314
|
return function () {
|
|
1972
2315
|
return listeners.forEach(function (off) {
|
|
1973
2316
|
return off();
|
|
@@ -1975,29 +2318,46 @@ function useEntitiesStore(props) {
|
|
|
1975
2318
|
};
|
|
1976
2319
|
}
|
|
1977
2320
|
|
|
1978
|
-
return props.sdk.navigator.onSlideInNavigation(function (
|
|
1979
|
-
var oldSlideLevel =
|
|
1980
|
-
newSlideLevel =
|
|
2321
|
+
return props.sdk.navigator.onSlideInNavigation(function (_ref8) {
|
|
2322
|
+
var oldSlideLevel = _ref8.oldSlideLevel,
|
|
2323
|
+
newSlideLevel = _ref8.newSlideLevel;
|
|
1981
2324
|
|
|
1982
2325
|
if (oldSlideLevel > newSlideLevel) {
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
}
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
2326
|
+
for (var _iterator3 = _createForOfIteratorHelperLoose(nonNilResources(state.entries)), _step3; !(_step3 = _iterator3()).done;) {
|
|
2327
|
+
var _step3$value = _step3.value,
|
|
2328
|
+
id = _step3$value[0];
|
|
2329
|
+
loadEntry(id);
|
|
2330
|
+
}
|
|
2331
|
+
|
|
2332
|
+
for (var _iterator4 = _createForOfIteratorHelperLoose(nonNilResources(state.assets)), _step4; !(_step4 = _iterator4()).done;) {
|
|
2333
|
+
var _step4$value = _step4.value,
|
|
2334
|
+
_id = _step4$value[0];
|
|
2335
|
+
loadAsset(_id);
|
|
2336
|
+
}
|
|
1993
2337
|
}
|
|
1994
2338
|
}); // eslint-disable-next-line react-hooks/exhaustive-deps -- TODO: Evaluate the dependencies
|
|
1995
2339
|
}, [props.sdk, state.assets, state.entries]);
|
|
1996
|
-
return
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2340
|
+
return React.useMemo(function () {
|
|
2341
|
+
return {
|
|
2342
|
+
/**
|
|
2343
|
+
* @deprecated use `getEntry` instead
|
|
2344
|
+
*/
|
|
2345
|
+
getOrLoadEntry: getEntry,
|
|
2346
|
+
|
|
2347
|
+
/**
|
|
2348
|
+
* @deprecated use `getAsset` instead
|
|
2349
|
+
*/
|
|
2350
|
+
getOrLoadAsset: getAsset,
|
|
2351
|
+
getResource: getResource,
|
|
2352
|
+
getEntry: getEntry,
|
|
2353
|
+
getAsset: getAsset,
|
|
2354
|
+
loadEntityScheduledActions: loadEntityScheduledActions,
|
|
2355
|
+
entries: state.entries,
|
|
2356
|
+
assets: state.assets,
|
|
2357
|
+
scheduledActions: state.scheduledActions,
|
|
2358
|
+
resources: state.resources
|
|
2359
|
+
};
|
|
2360
|
+
}, [getResource, getEntry, getAsset, loadEntityScheduledActions, state.entries, state.assets, state.scheduledActions, state.resources]);
|
|
2001
2361
|
}
|
|
2002
2362
|
|
|
2003
2363
|
var _constate = /*#__PURE__*/constate(useEntitiesStore),
|
|
@@ -2667,13 +3027,13 @@ function _openEntry() {
|
|
|
2667
3027
|
|
|
2668
3028
|
function FetchingWrappedEntryCard(props) {
|
|
2669
3029
|
var _useEntities = useEntities(),
|
|
2670
|
-
|
|
2671
|
-
|
|
3030
|
+
getEntry = _useEntities.getEntry,
|
|
3031
|
+
getAsset = _useEntities.getAsset,
|
|
2672
3032
|
loadEntityScheduledActions = _useEntities.loadEntityScheduledActions,
|
|
2673
3033
|
entries = _useEntities.entries;
|
|
2674
3034
|
|
|
2675
3035
|
React.useEffect(function () {
|
|
2676
|
-
|
|
3036
|
+
getEntry(props.entryId); // eslint-disable-next-line react-hooks/exhaustive-deps -- TODO: Evaluate the dependencies
|
|
2677
3037
|
}, [props.entryId]);
|
|
2678
3038
|
var size = props.viewType === 'link' ? 'small' : 'default';
|
|
2679
3039
|
var entry = entries[props.entryId];
|
|
@@ -2788,7 +3148,7 @@ function FetchingWrappedEntryCard(props) {
|
|
|
2788
3148
|
hasCardEditActions: hasCardEditActions,
|
|
2789
3149
|
hasCardMoveActions: hasCardMoveActions,
|
|
2790
3150
|
hasCardRemoveActions: hasCardRemoveActions,
|
|
2791
|
-
getAsset:
|
|
3151
|
+
getAsset: getAsset,
|
|
2792
3152
|
getEntityScheduledActions: loadEntityScheduledActions,
|
|
2793
3153
|
entry: (props == null ? void 0 : props.entity) || sharedCardProps.entity,
|
|
2794
3154
|
entryUrl: (props == null ? void 0 : props.entityUrl) || sharedCardProps.entityUrl
|
|
@@ -2938,11 +3298,12 @@ MultipleReferenceEditor.defaultProps = {
|
|
|
2938
3298
|
};
|
|
2939
3299
|
|
|
2940
3300
|
var styles$3 = {
|
|
2941
|
-
|
|
3301
|
+
container: /*#__PURE__*/emotion.css({
|
|
2942
3302
|
position: 'relative'
|
|
2943
3303
|
}),
|
|
2944
3304
|
item: /*#__PURE__*/emotion.css({
|
|
2945
|
-
marginBottom: tokens.spacingM
|
|
3305
|
+
marginBottom: tokens.spacingM,
|
|
3306
|
+
marginRight: tokens.spacingM
|
|
2946
3307
|
})
|
|
2947
3308
|
};
|
|
2948
3309
|
|
|
@@ -2958,45 +3319,56 @@ var SortableLink = /*#__PURE__*/reactSortableHoc.SortableElement(function (props
|
|
|
2958
3319
|
className: styles$3.item
|
|
2959
3320
|
}, props.children);
|
|
2960
3321
|
});
|
|
2961
|
-
var
|
|
2962
|
-
var lastIndex = props.items.length - 1;
|
|
3322
|
+
var SortableLinkListInternal = /*#__PURE__*/reactSortableHoc.SortableContainer(function (props) {
|
|
2963
3323
|
return React__default.createElement("div", {
|
|
2964
|
-
className: styles$3.
|
|
3324
|
+
className: emotion.cx(styles$3.container, props.className)
|
|
2965
3325
|
}, props.items.map(function (item, index) {
|
|
3326
|
+
var _item$sys$id;
|
|
3327
|
+
|
|
2966
3328
|
return React__default.createElement(SortableLink, {
|
|
2967
3329
|
disabled: props.isDisabled,
|
|
2968
|
-
key: item.sys.id + "-" + index,
|
|
3330
|
+
key: ((_item$sys$id = item.sys.id) != null ? _item$sys$id : item.sys.urn) + "-" + index,
|
|
2969
3331
|
index: index
|
|
2970
|
-
},
|
|
2971
|
-
|
|
3332
|
+
}, props.children(_extends({}, props, {
|
|
3333
|
+
item: item,
|
|
2972
3334
|
index: index,
|
|
2973
|
-
|
|
2974
|
-
isDisabled: props.isDisabled,
|
|
2975
|
-
entryId: item.sys.id,
|
|
2976
|
-
onRemove: function onRemove() {
|
|
2977
|
-
props.setValue(props.items.filter(function (_value, i) {
|
|
2978
|
-
return i !== index;
|
|
2979
|
-
}));
|
|
2980
|
-
},
|
|
2981
|
-
onMoveTop: index !== 0 ? function () {
|
|
2982
|
-
return props.onMove(index, 0);
|
|
2983
|
-
} : undefined,
|
|
2984
|
-
onMoveBottom: index !== lastIndex ? function () {
|
|
2985
|
-
return props.onMove(index, lastIndex);
|
|
2986
|
-
} : undefined,
|
|
2987
|
-
renderDragHandle: props.isDisabled ? undefined : DragHandle
|
|
3335
|
+
DragHandle: props.isDisabled ? undefined : DragHandle
|
|
2988
3336
|
})));
|
|
2989
3337
|
}));
|
|
2990
|
-
});
|
|
3338
|
+
}); // HOC does not support generics, so we mimic it via additional component
|
|
3339
|
+
|
|
3340
|
+
function SortableLinkList(props) {
|
|
3341
|
+
return React__default.createElement(SortableLinkListInternal, Object.assign({}, props, {
|
|
3342
|
+
children: props.children
|
|
3343
|
+
}));
|
|
3344
|
+
}
|
|
2991
3345
|
|
|
2992
3346
|
function MultipleEntryReferenceEditor(props) {
|
|
2993
3347
|
return React.createElement(MultipleReferenceEditor, Object.assign({}, props, {
|
|
2994
3348
|
entityType: "Entry"
|
|
2995
3349
|
}), function (childrenProps) {
|
|
2996
|
-
return React.createElement(SortableLinkList, Object.assign({},
|
|
2997
|
-
|
|
2998
|
-
|
|
2999
|
-
|
|
3350
|
+
return React.createElement(SortableLinkList, Object.assign({}, childrenProps), function (props) {
|
|
3351
|
+
var lastIndex = props.items.length - 1;
|
|
3352
|
+
return React.createElement(FetchingWrappedEntryCard, Object.assign({}, props, {
|
|
3353
|
+
key: props.item.sys.id + "-" + props.index,
|
|
3354
|
+
index: props.index,
|
|
3355
|
+
allContentTypes: childrenProps.allContentTypes,
|
|
3356
|
+
isDisabled: props.isDisabled,
|
|
3357
|
+
entryId: props.item.sys.id,
|
|
3358
|
+
onRemove: function onRemove() {
|
|
3359
|
+
childrenProps.setValue(props.items.filter(function (_value, i) {
|
|
3360
|
+
return i !== props.index;
|
|
3361
|
+
}));
|
|
3362
|
+
},
|
|
3363
|
+
onMoveTop: props.index !== 0 ? function () {
|
|
3364
|
+
return childrenProps.onMove(props.index, 0);
|
|
3365
|
+
} : undefined,
|
|
3366
|
+
onMoveBottom: props.index !== lastIndex ? function () {
|
|
3367
|
+
return childrenProps.onMove(props.index, lastIndex);
|
|
3368
|
+
} : undefined,
|
|
3369
|
+
renderDragHandle: props.DragHandle
|
|
3370
|
+
}));
|
|
3371
|
+
});
|
|
3000
3372
|
});
|
|
3001
3373
|
}
|
|
3002
3374
|
|
|
@@ -3233,12 +3605,12 @@ var WrappedAssetLink = function WrappedAssetLink(props) {
|
|
|
3233
3605
|
|
|
3234
3606
|
function FetchingWrappedAssetCard(props) {
|
|
3235
3607
|
var _useEntities = useEntities(),
|
|
3236
|
-
|
|
3608
|
+
getAsset = _useEntities.getAsset,
|
|
3237
3609
|
loadEntityScheduledActions = _useEntities.loadEntityScheduledActions,
|
|
3238
3610
|
assets = _useEntities.assets;
|
|
3239
3611
|
|
|
3240
3612
|
React.useEffect(function () {
|
|
3241
|
-
|
|
3613
|
+
getAsset(props.assetId); // eslint-disable-next-line react-hooks/exhaustive-deps -- TODO: Evaluate the dependencies
|
|
3242
3614
|
}, [props.assetId]);
|
|
3243
3615
|
var asset = assets[props.assetId];
|
|
3244
3616
|
var entityKey = asset === 'failed' ? 'failed' : asset === undefined ? 'undefined' : ":" + asset.sys.id + ":" + asset.sys.version;
|
|
@@ -3407,62 +3779,33 @@ SingleMediaEditor.defaultProps = {
|
|
|
3407
3779
|
};
|
|
3408
3780
|
|
|
3409
3781
|
var styles$6 = {
|
|
3410
|
-
|
|
3782
|
+
gridContainer: /*#__PURE__*/emotion.css({
|
|
3411
3783
|
position: 'relative',
|
|
3412
3784
|
display: 'flex',
|
|
3413
3785
|
flexWrap: 'wrap'
|
|
3414
|
-
}),
|
|
3415
|
-
container: /*#__PURE__*/emotion.css({
|
|
3416
|
-
position: 'relative'
|
|
3417
|
-
}),
|
|
3418
|
-
item: /*#__PURE__*/emotion.css({
|
|
3419
|
-
marginBottom: tokens.spacingM,
|
|
3420
|
-
marginRight: tokens.spacingM
|
|
3421
3786
|
})
|
|
3422
3787
|
};
|
|
3423
|
-
|
|
3424
|
-
var DragHandle$1 = function DragHandle(props) {
|
|
3425
|
-
var SortableDragHandle = reactSortableHoc.SortableHandle(function () {
|
|
3426
|
-
return props.drag;
|
|
3427
|
-
});
|
|
3428
|
-
return React__default.createElement(SortableDragHandle, null);
|
|
3429
|
-
};
|
|
3430
|
-
|
|
3431
|
-
var SortableLink$1 = /*#__PURE__*/reactSortableHoc.SortableElement(function (props) {
|
|
3432
|
-
return React__default.createElement("div", {
|
|
3433
|
-
className: styles$6.item
|
|
3434
|
-
}, props.children);
|
|
3435
|
-
});
|
|
3436
|
-
var SortableLinkList$1 = /*#__PURE__*/reactSortableHoc.SortableContainer(function (props) {
|
|
3437
|
-
return React__default.createElement("div", {
|
|
3438
|
-
className: props.viewType === 'card' ? styles$6.gridContainter : styles$6.container
|
|
3439
|
-
}, props.items.map(function (item, index) {
|
|
3440
|
-
return React__default.createElement(SortableLink$1, {
|
|
3441
|
-
disabled: props.isDisabled,
|
|
3442
|
-
key: item.sys.id + "-" + index,
|
|
3443
|
-
index: index
|
|
3444
|
-
}, React__default.createElement(FetchingWrappedAssetCard, Object.assign({}, props, {
|
|
3445
|
-
sdk: props.sdk,
|
|
3446
|
-
key: item.sys.id + "-" + index,
|
|
3447
|
-
assetId: item.sys.id,
|
|
3448
|
-
onRemove: function onRemove() {
|
|
3449
|
-
props.setValue(props.items.filter(function (_value, i) {
|
|
3450
|
-
return i !== index;
|
|
3451
|
-
}));
|
|
3452
|
-
},
|
|
3453
|
-
renderDragHandle: props.isDisabled ? undefined : DragHandle$1
|
|
3454
|
-
})));
|
|
3455
|
-
}));
|
|
3456
|
-
});
|
|
3457
|
-
|
|
3458
3788
|
function MultipleMediaEditor(props) {
|
|
3459
3789
|
return React.createElement(MultipleReferenceEditor, Object.assign({}, props, {
|
|
3460
3790
|
entityType: "Asset"
|
|
3461
3791
|
}), function (childrenProps) {
|
|
3462
|
-
|
|
3463
|
-
|
|
3464
|
-
|
|
3465
|
-
|
|
3792
|
+
var _cx;
|
|
3793
|
+
|
|
3794
|
+
return React.createElement(SortableLinkList, Object.assign({}, childrenProps, {
|
|
3795
|
+
className: emotion.cx((_cx = {}, _cx[styles$6.gridContainer] = childrenProps.viewType === 'card', _cx)),
|
|
3796
|
+
axis: childrenProps.viewType === 'card' ? 'xy' : 'y'
|
|
3797
|
+
}), function (props) {
|
|
3798
|
+
return React.createElement(FetchingWrappedAssetCard, Object.assign({}, props, {
|
|
3799
|
+
key: props.item.sys.id + "-" + props.index,
|
|
3800
|
+
assetId: props.item.sys.id,
|
|
3801
|
+
onRemove: function onRemove() {
|
|
3802
|
+
childrenProps.setValue(props.items.filter(function (_value, i) {
|
|
3803
|
+
return i !== props.index;
|
|
3804
|
+
}));
|
|
3805
|
+
},
|
|
3806
|
+
renderDragHandle: props.DragHandle
|
|
3807
|
+
}));
|
|
3808
|
+
});
|
|
3466
3809
|
});
|
|
3467
3810
|
}
|
|
3468
3811
|
MultipleMediaEditor.defaultProps = {
|
|
@@ -3480,6 +3823,7 @@ exports.MultipleMediaEditor = MultipleMediaEditor;
|
|
|
3480
3823
|
exports.ScheduledIconWithTooltip = ScheduledIconWithTooltip;
|
|
3481
3824
|
exports.SingleEntryReferenceEditor = SingleEntryReferenceEditor;
|
|
3482
3825
|
exports.SingleMediaEditor = SingleMediaEditor;
|
|
3826
|
+
exports.SortableLinkList = SortableLinkList;
|
|
3483
3827
|
exports.WrappedAssetCard = WrappedAssetCard;
|
|
3484
3828
|
exports.WrappedEntryCard = WrappedEntryCard;
|
|
3485
3829
|
exports.getScheduleTooltipContent = getScheduleTooltipContent;
|