@contentful/field-editor-reference 4.3.11 → 4.5.1

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.
@@ -1,13 +1,14 @@
1
1
  import React__default, { useState, useRef, useEffect, createElement, Fragment, useMemo, useCallback, useReducer } from 'react';
2
- import { css } from 'emotion';
2
+ import { css, cx } from 'emotion';
3
3
  import tokens from '@contentful/f36-tokens';
4
4
  import get from 'lodash-es/get';
5
- import { Menu, TextInput, Button, Paragraph, Card, SectionHeading, IconButton, Tooltip, EntryCard, MenuItem, MenuDivider, Text, AssetCard } from '@contentful/f36-components';
6
- import { SearchIcon, PlusIcon, ChevronDownIcon, LinkIcon, CloseIcon, ClockIcon } from '@contentful/f36-icons';
5
+ import { Menu, TextInput, Button, Paragraph, Card, SectionHeading, IconButton, Tooltip, Flex, Text, EntryCard, MenuItem, MenuDivider, AssetCard } from '@contentful/f36-components';
6
+ import { SearchIcon, PlusIcon, ChevronDownIcon, LinkIcon, CloseIcon, FolderOpenTrimmedIcon, ClockIcon } from '@contentful/f36-icons';
7
7
  import moment from 'moment';
8
8
  import deepEqual from 'deep-equal';
9
9
  import { FieldConnector, isValidImage, entityHelpers, shortenStorageUnit } from '@contentful/field-editor-shared';
10
10
  import constate from 'constate';
11
+ import { createClient } from 'contentful-management';
11
12
  import isNumber from 'lodash-es/isNumber';
12
13
  import arrayMove from 'array-move';
13
14
  import { SortableContainer, SortableHandle, SortableElement } from 'react-sortable-hoc';
@@ -82,6 +83,44 @@ function _objectWithoutPropertiesLoose(source, excluded) {
82
83
  return target;
83
84
  }
84
85
 
86
+ function _unsupportedIterableToArray(o, minLen) {
87
+ if (!o) return;
88
+ if (typeof o === "string") return _arrayLikeToArray(o, minLen);
89
+ var n = Object.prototype.toString.call(o).slice(8, -1);
90
+ if (n === "Object" && o.constructor) n = o.constructor.name;
91
+ if (n === "Map" || n === "Set") return Array.from(o);
92
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
93
+ }
94
+
95
+ function _arrayLikeToArray(arr, len) {
96
+ if (len == null || len > arr.length) len = arr.length;
97
+
98
+ for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
99
+
100
+ return arr2;
101
+ }
102
+
103
+ function _createForOfIteratorHelperLoose(o, allowArrayLike) {
104
+ var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
105
+ if (it) return (it = it.call(o)).next.bind(it);
106
+
107
+ if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
108
+ if (it) o = it;
109
+ var i = 0;
110
+ return function () {
111
+ if (i >= o.length) return {
112
+ done: true
113
+ };
114
+ return {
115
+ done: false,
116
+ value: o[i++]
117
+ };
118
+ };
119
+ }
120
+
121
+ throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
122
+ }
123
+
85
124
  var container = /*#__PURE__*/css({
86
125
  display: 'flex',
87
126
  border: "1px dashed " + tokens.gray500,
@@ -1822,7 +1861,7 @@ function AssetThumbnail(props) {
1822
1861
  }
1823
1862
 
1824
1863
  function reducer(state, action) {
1825
- var _extends2, _extends3, _extends4, _extends5, _extends6;
1864
+ var _extends2, _extends3, _extends4, _extends5, _extends6, _extends7, _extends8;
1826
1865
 
1827
1866
  switch (action.type) {
1828
1867
  case 'set_entry':
@@ -1850,6 +1889,16 @@ function reducer(state, action) {
1850
1889
  scheduledActions: _extends({}, state.scheduledActions, (_extends6 = {}, _extends6[action.key] = action.actions, _extends6))
1851
1890
  });
1852
1891
 
1892
+ case 'set_resource':
1893
+ return _extends({}, state, {
1894
+ resources: _extends({}, state.resources, (_extends7 = {}, _extends7[action.resourceType + "." + action.urn] = action.resourceInfo, _extends7))
1895
+ });
1896
+
1897
+ case 'set_resource_failed':
1898
+ return _extends({}, state, {
1899
+ resources: _extends({}, state.resources, (_extends8 = {}, _extends8[action.resourceType + "." + action.urn] = 'failed', _extends8))
1900
+ });
1901
+
1853
1902
  default:
1854
1903
  return state;
1855
1904
  }
@@ -1858,10 +1907,34 @@ function reducer(state, action) {
1858
1907
  var initialState = {
1859
1908
  entries: {},
1860
1909
  assets: {},
1861
- scheduledActions: {}
1910
+ scheduledActions: {},
1911
+ resources: {}
1912
+ };
1913
+
1914
+ var isNotNil = function isNotNil(entity) {
1915
+ return Boolean(entity && entity !== 'failed');
1916
+ };
1917
+
1918
+ var nonNilResources = function nonNilResources(map) {
1919
+ return Object.entries(map).filter(function (_ref) {
1920
+ var value = _ref[1];
1921
+ return isNotNil(value);
1922
+ });
1862
1923
  };
1863
1924
 
1864
1925
  function useEntitiesStore(props) {
1926
+ var spaceId = props.sdk.ids.space;
1927
+ var environmentId = props.sdk.ids.environment;
1928
+
1929
+ var _React$useState = useState(function () {
1930
+ return createClient({
1931
+ apiAdapter: props.sdk.cmaAdapter
1932
+ }, {
1933
+ type: 'plain'
1934
+ });
1935
+ }),
1936
+ cmaClient = _React$useState[0];
1937
+
1865
1938
  var _React$useReducer = useReducer(reducer, initialState),
1866
1939
  state = _React$useReducer[0],
1867
1940
  dispatch = _React$useReducer[1];
@@ -1889,78 +1962,348 @@ function useEntitiesStore(props) {
1889
1962
  return [];
1890
1963
  });
1891
1964
  }, [props.sdk.space, state.scheduledActions]);
1892
- var loadEntry = useCallback(function (id) {
1893
- return props.sdk.space.getEntry(id).then(function (entry) {
1894
- dispatch({
1895
- type: 'set_entry',
1896
- id: id,
1897
- entry: entry
1898
- });
1899
- return entry;
1900
- })["catch"](function () {
1901
- dispatch({
1902
- type: 'set_entry_failed',
1903
- id: id
1904
- });
1905
- });
1906
- }, [props.sdk.space]);
1907
- var loadAsset = useCallback(function (id) {
1908
- return props.sdk.space.getAsset(id).then(function (asset) {
1909
- dispatch({
1910
- type: 'set_asset',
1911
- id: id,
1912
- asset: asset
1913
- });
1914
- return asset;
1915
- })["catch"](function () {
1916
- dispatch({
1917
- type: 'set_asset_failed',
1918
- id: id
1919
- });
1920
- });
1921
- }, [props.sdk.space]);
1922
- var getOrLoadAsset = useCallback(function (id) {
1923
- if (state.assets[id] && state.assets[id] !== 'failed') {
1924
- return Promise.resolve(state.assets[id]);
1925
- }
1965
+ var loadEntry = useCallback( /*#__PURE__*/function () {
1966
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(entryId) {
1967
+ var entry;
1968
+ return runtime_1.wrap(function _callee$(_context) {
1969
+ while (1) {
1970
+ switch (_context.prev = _context.next) {
1971
+ case 0:
1972
+ _context.prev = 0;
1973
+ _context.next = 3;
1974
+ return cmaClient.entry.get({
1975
+ spaceId: spaceId,
1976
+ environmentId: environmentId,
1977
+ entryId: entryId
1978
+ });
1926
1979
 
1927
- return loadAsset(id);
1928
- }, [state.assets, loadAsset]);
1929
- var getOrLoadEntry = useCallback(function (id) {
1930
- if (state.entries[id] && state.entries[id] !== 'failed') {
1931
- return Promise.resolve(state.entries[id]);
1932
- }
1980
+ case 3:
1981
+ entry = _context.sent;
1982
+ dispatch({
1983
+ type: 'set_entry',
1984
+ id: entryId,
1985
+ entry: entry
1986
+ });
1987
+ return _context.abrupt("return", entry);
1988
+
1989
+ case 8:
1990
+ _context.prev = 8;
1991
+ _context.t0 = _context["catch"](0);
1992
+ dispatch({
1993
+ type: 'set_entry_failed',
1994
+ id: entryId
1995
+ });
1996
+ return _context.abrupt("return");
1997
+
1998
+ case 12:
1999
+ case "end":
2000
+ return _context.stop();
2001
+ }
2002
+ }
2003
+ }, _callee, null, [[0, 8]]);
2004
+ }));
2005
+
2006
+ return function (_x) {
2007
+ return _ref2.apply(this, arguments);
2008
+ };
2009
+ }(), [cmaClient, spaceId, environmentId]);
2010
+ var getEntry = useCallback( /*#__PURE__*/function () {
2011
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(entryId) {
2012
+ var cachedEntry;
2013
+ return runtime_1.wrap(function _callee2$(_context2) {
2014
+ while (1) {
2015
+ switch (_context2.prev = _context2.next) {
2016
+ case 0:
2017
+ cachedEntry = state.entries[entryId];
2018
+
2019
+ if (!isNotNil(cachedEntry)) {
2020
+ _context2.next = 3;
2021
+ break;
2022
+ }
2023
+
2024
+ return _context2.abrupt("return", cachedEntry);
2025
+
2026
+ case 3:
2027
+ return _context2.abrupt("return", loadEntry(entryId));
2028
+
2029
+ case 4:
2030
+ case "end":
2031
+ return _context2.stop();
2032
+ }
2033
+ }
2034
+ }, _callee2);
2035
+ }));
2036
+
2037
+ return function (_x2) {
2038
+ return _ref3.apply(this, arguments);
2039
+ };
2040
+ }(), [loadEntry, state.entries]);
2041
+ var loadAsset = useCallback( /*#__PURE__*/function () {
2042
+ var _ref4 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3(assetId) {
2043
+ var asset;
2044
+ return runtime_1.wrap(function _callee3$(_context3) {
2045
+ while (1) {
2046
+ switch (_context3.prev = _context3.next) {
2047
+ case 0:
2048
+ _context3.prev = 0;
2049
+ _context3.next = 3;
2050
+ return cmaClient.asset.get({
2051
+ spaceId: spaceId,
2052
+ environmentId: environmentId,
2053
+ assetId: assetId
2054
+ });
2055
+
2056
+ case 3:
2057
+ asset = _context3.sent;
2058
+ dispatch({
2059
+ type: 'set_asset',
2060
+ id: assetId,
2061
+ asset: asset
2062
+ });
2063
+ return _context3.abrupt("return", asset);
2064
+
2065
+ case 8:
2066
+ _context3.prev = 8;
2067
+ _context3.t0 = _context3["catch"](0);
2068
+ dispatch({
2069
+ type: 'set_asset_failed',
2070
+ id: assetId
2071
+ });
2072
+ return _context3.abrupt("return");
2073
+
2074
+ case 12:
2075
+ case "end":
2076
+ return _context3.stop();
2077
+ }
2078
+ }
2079
+ }, _callee3, null, [[0, 8]]);
2080
+ }));
2081
+
2082
+ return function (_x3) {
2083
+ return _ref4.apply(this, arguments);
2084
+ };
2085
+ }(), [cmaClient, spaceId, environmentId]);
2086
+ var getAsset = useCallback( /*#__PURE__*/function () {
2087
+ var _ref5 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee4(assetId) {
2088
+ var cachedAsset;
2089
+ return runtime_1.wrap(function _callee4$(_context4) {
2090
+ while (1) {
2091
+ switch (_context4.prev = _context4.next) {
2092
+ case 0:
2093
+ cachedAsset = state.assets[assetId];
2094
+
2095
+ if (!isNotNil(cachedAsset)) {
2096
+ _context4.next = 3;
2097
+ break;
2098
+ }
2099
+
2100
+ return _context4.abrupt("return", cachedAsset);
2101
+
2102
+ case 3:
2103
+ return _context4.abrupt("return", loadAsset(assetId));
2104
+
2105
+ case 4:
2106
+ case "end":
2107
+ return _context4.stop();
2108
+ }
2109
+ }
2110
+ }, _callee4);
2111
+ }));
2112
+
2113
+ return function (_x4) {
2114
+ return _ref5.apply(this, arguments);
2115
+ };
2116
+ }(), [loadAsset, state.assets]);
2117
+ var loadContentfulEntry = useCallback( /*#__PURE__*/function () {
2118
+ var _ref6 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee5(urn) {
2119
+ var _locales$items$find;
2120
+
2121
+ var resourceId, _resourceId$split, spaceId, entryId, environmentId, _yield$Promise$all, space, entry, contentTypeId, _yield$Promise$all2, contentType, locales, defaultLocaleCode;
2122
+
2123
+ return runtime_1.wrap(function _callee5$(_context5) {
2124
+ while (1) {
2125
+ switch (_context5.prev = _context5.next) {
2126
+ case 0:
2127
+ resourceId = urn.split(':', 6)[5];
2128
+ _resourceId$split = resourceId.split('/'), spaceId = _resourceId$split[1], entryId = _resourceId$split[3];
2129
+ environmentId = 'master';
2130
+ _context5.t0 = Promise;
2131
+ _context5.next = 6;
2132
+ return cmaClient.space.get({
2133
+ spaceId: spaceId
2134
+ });
2135
+
2136
+ case 6:
2137
+ _context5.t1 = _context5.sent;
2138
+ _context5.next = 9;
2139
+ return cmaClient.entry.get({
2140
+ spaceId: spaceId,
2141
+ environmentId: environmentId,
2142
+ entryId: entryId
2143
+ });
2144
+
2145
+ case 9:
2146
+ _context5.t2 = _context5.sent;
2147
+ _context5.t3 = [_context5.t1, _context5.t2];
2148
+ _context5.next = 13;
2149
+ return _context5.t0.all.call(_context5.t0, _context5.t3);
2150
+
2151
+ case 13:
2152
+ _yield$Promise$all = _context5.sent;
2153
+ space = _yield$Promise$all[0];
2154
+ entry = _yield$Promise$all[1];
2155
+ contentTypeId = entry.sys.contentType.sys.id;
2156
+ _context5.t4 = Promise;
2157
+ _context5.next = 20;
2158
+ return cmaClient.contentType.get({
2159
+ contentTypeId: contentTypeId,
2160
+ spaceId: spaceId,
2161
+ environmentId: environmentId
2162
+ });
2163
+
2164
+ case 20:
2165
+ _context5.t5 = _context5.sent;
2166
+ _context5.next = 23;
2167
+ return cmaClient.locale.getMany({
2168
+ spaceId: spaceId,
2169
+ environmentId: environmentId,
2170
+ query: {
2171
+ limit: 100
2172
+ }
2173
+ });
1933
2174
 
1934
- return loadEntry(id);
1935
- }, [state.entries, loadEntry]);
2175
+ case 23:
2176
+ _context5.t6 = _context5.sent;
2177
+ _context5.t7 = [_context5.t5, _context5.t6];
2178
+ _context5.next = 27;
2179
+ return _context5.t4.all.call(_context5.t4, _context5.t7);
2180
+
2181
+ case 27:
2182
+ _yield$Promise$all2 = _context5.sent;
2183
+ contentType = _yield$Promise$all2[0];
2184
+ locales = _yield$Promise$all2[1];
2185
+ defaultLocaleCode = (_locales$items$find = locales.items.find(function (locale) {
2186
+ return locale["default"];
2187
+ })) == null ? void 0 : _locales$items$find.code;
2188
+ return _context5.abrupt("return", {
2189
+ resource: entry,
2190
+ defaultLocaleCode: defaultLocaleCode,
2191
+ space: space,
2192
+ contentType: contentType
2193
+ });
2194
+
2195
+ case 32:
2196
+ case "end":
2197
+ return _context5.stop();
2198
+ }
2199
+ }
2200
+ }, _callee5);
2201
+ }));
2202
+
2203
+ return function (_x5) {
2204
+ return _ref6.apply(this, arguments);
2205
+ };
2206
+ }(), [cmaClient]);
2207
+ var getResource = useCallback( /*#__PURE__*/function () {
2208
+ var _ref7 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee6(resourceType, urn) {
2209
+ var cachedResource, resourceInfo;
2210
+ return runtime_1.wrap(function _callee6$(_context6) {
2211
+ while (1) {
2212
+ switch (_context6.prev = _context6.next) {
2213
+ case 0:
2214
+ cachedResource = state.resources[resourceType + "." + urn];
2215
+
2216
+ if (!isNotNil(cachedResource)) {
2217
+ _context6.next = 3;
2218
+ break;
2219
+ }
2220
+
2221
+ return _context6.abrupt("return", cachedResource);
2222
+
2223
+ case 3:
2224
+ _context6.prev = 3;
2225
+
2226
+ if (!(resourceType === 'Contentful:Entry')) {
2227
+ _context6.next = 8;
2228
+ break;
2229
+ }
2230
+
2231
+ _context6.next = 7;
2232
+ return loadContentfulEntry(urn);
2233
+
2234
+ case 7:
2235
+ resourceInfo = _context6.sent;
2236
+
2237
+ case 8:
2238
+ dispatch({
2239
+ type: 'set_resource',
2240
+ resourceType: resourceType,
2241
+ urn: urn,
2242
+ resourceInfo: resourceInfo
2243
+ });
2244
+ return _context6.abrupt("return", resourceInfo);
2245
+
2246
+ case 12:
2247
+ _context6.prev = 12;
2248
+ _context6.t0 = _context6["catch"](3);
2249
+ dispatch({
2250
+ type: 'set_resource_failed',
2251
+ resourceType: resourceType,
2252
+ urn: urn
2253
+ });
2254
+ return _context6.abrupt("return");
2255
+
2256
+ case 16:
2257
+ case "end":
2258
+ return _context6.stop();
2259
+ }
2260
+ }
2261
+ }, _callee6, null, [[3, 12]]);
2262
+ }));
2263
+
2264
+ return function (_x6, _x7) {
2265
+ return _ref7.apply(this, arguments);
2266
+ };
2267
+ }(), [loadContentfulEntry, state.resources]);
1936
2268
  useEffect(function () {
1937
2269
  // @ts-expect-error
1938
2270
  if (typeof props.sdk.space.onEntityChanged !== 'undefined') {
1939
2271
  // @ts-expect-error
1940
2272
  var onEntityChanged = props.sdk.space.onEntityChanged;
1941
2273
  var listeners = [];
1942
- Object.keys(state.entries).forEach(function (id) {
1943
- if (state.entries[id] && state.entries['id'] !== 'failed') {
1944
- listeners.push(onEntityChanged('Entry', id, function (entry) {
1945
- return dispatch({
1946
- type: 'set_entry',
1947
- id: id,
1948
- entry: entry
1949
- });
1950
- }));
1951
- }
1952
- });
1953
- Object.keys(state.assets).forEach(function (id) {
1954
- if (state.assets[id] && state.assets['id'] !== 'failed') {
1955
- listeners.push(onEntityChanged('Asset', id, function (asset) {
1956
- return dispatch({
1957
- type: 'set_asset',
1958
- id: id,
1959
- asset: asset
1960
- });
1961
- }));
1962
- }
1963
- });
2274
+
2275
+ var _loop = function _loop() {
2276
+ var _step$value = _step.value,
2277
+ id = _step$value[0];
2278
+ listeners.push(onEntityChanged('Entry', id, function (entry) {
2279
+ return dispatch({
2280
+ type: 'set_entry',
2281
+ id: id,
2282
+ entry: entry
2283
+ });
2284
+ }));
2285
+ };
2286
+
2287
+ for (var _iterator = _createForOfIteratorHelperLoose(nonNilResources(state.entries)), _step; !(_step = _iterator()).done;) {
2288
+ _loop();
2289
+ }
2290
+
2291
+ var _loop2 = function _loop2() {
2292
+ var _step2$value = _step2.value,
2293
+ id = _step2$value[0];
2294
+ listeners.push(onEntityChanged('Asset', id, function (asset) {
2295
+ return dispatch({
2296
+ type: 'set_asset',
2297
+ id: id,
2298
+ asset: asset
2299
+ });
2300
+ }));
2301
+ };
2302
+
2303
+ for (var _iterator2 = _createForOfIteratorHelperLoose(nonNilResources(state.assets)), _step2; !(_step2 = _iterator2()).done;) {
2304
+ _loop2();
2305
+ }
2306
+
1964
2307
  return function () {
1965
2308
  return listeners.forEach(function (off) {
1966
2309
  return off();
@@ -1968,29 +2311,46 @@ function useEntitiesStore(props) {
1968
2311
  };
1969
2312
  }
1970
2313
 
1971
- return props.sdk.navigator.onSlideInNavigation(function (_ref) {
1972
- var oldSlideLevel = _ref.oldSlideLevel,
1973
- newSlideLevel = _ref.newSlideLevel;
2314
+ return props.sdk.navigator.onSlideInNavigation(function (_ref8) {
2315
+ var oldSlideLevel = _ref8.oldSlideLevel,
2316
+ newSlideLevel = _ref8.newSlideLevel;
1974
2317
 
1975
2318
  if (oldSlideLevel > newSlideLevel) {
1976
- Object.keys(state.entries).map(function (id) {
1977
- if (state.entries[id] && state.entries[id] !== 'failed') {
1978
- loadEntry(id);
1979
- }
1980
- });
1981
- Object.keys(state.assets).map(function (id) {
1982
- if (state.assets[id] && state.assets[id] !== 'failed') {
1983
- loadAsset(id);
1984
- }
1985
- });
2319
+ for (var _iterator3 = _createForOfIteratorHelperLoose(nonNilResources(state.entries)), _step3; !(_step3 = _iterator3()).done;) {
2320
+ var _step3$value = _step3.value,
2321
+ id = _step3$value[0];
2322
+ loadEntry(id);
2323
+ }
2324
+
2325
+ for (var _iterator4 = _createForOfIteratorHelperLoose(nonNilResources(state.assets)), _step4; !(_step4 = _iterator4()).done;) {
2326
+ var _step4$value = _step4.value,
2327
+ _id = _step4$value[0];
2328
+ loadAsset(_id);
2329
+ }
1986
2330
  }
1987
2331
  }); // eslint-disable-next-line react-hooks/exhaustive-deps -- TODO: Evaluate the dependencies
1988
2332
  }, [props.sdk, state.assets, state.entries]);
1989
- return _extends({
1990
- getOrLoadEntry: getOrLoadEntry,
1991
- getOrLoadAsset: getOrLoadAsset,
1992
- loadEntityScheduledActions: loadEntityScheduledActions
1993
- }, state);
2333
+ return useMemo(function () {
2334
+ return {
2335
+ /**
2336
+ * @deprecated use `getEntry` instead
2337
+ */
2338
+ getOrLoadEntry: getEntry,
2339
+
2340
+ /**
2341
+ * @deprecated use `getAsset` instead
2342
+ */
2343
+ getOrLoadAsset: getAsset,
2344
+ getResource: getResource,
2345
+ getEntry: getEntry,
2346
+ getAsset: getAsset,
2347
+ loadEntityScheduledActions: loadEntityScheduledActions,
2348
+ entries: state.entries,
2349
+ assets: state.assets,
2350
+ scheduledActions: state.scheduledActions,
2351
+ resources: state.resources
2352
+ };
2353
+ }, [getResource, getEntry, getAsset, loadEntityScheduledActions, state.entries, state.assets, state.scheduledActions, state.resources]);
1994
2354
  }
1995
2355
 
1996
2356
  var _constate = /*#__PURE__*/constate(useEntitiesStore),
@@ -2447,11 +2807,40 @@ SingleReferenceEditor.defaultProps = {
2447
2807
  hasCardRemoveActions: true
2448
2808
  };
2449
2809
 
2810
+ var styles$1 = {
2811
+ spaceIcon: /*#__PURE__*/css({
2812
+ flexShrink: 0,
2813
+ fill: tokens.purple600
2814
+ }),
2815
+ spaceName: /*#__PURE__*/css({
2816
+ color: tokens.gray700,
2817
+ fontSize: tokens.fontSizeS,
2818
+ fontWeight: tokens.fontWeightDemiBold
2819
+ })
2820
+ };
2821
+ function SpaceName(props) {
2822
+ return createElement(Tooltip, {
2823
+ placement: "top",
2824
+ as: "div",
2825
+ content: "Space"
2826
+ }, createElement(Flex, {
2827
+ alignItems: "center",
2828
+ gap: "spacingXs",
2829
+ marginRight: "spacingS"
2830
+ }, createElement(FolderOpenTrimmedIcon, {
2831
+ className: styles$1.spaceIcon,
2832
+ size: "tiny",
2833
+ "aria-label": "Source space"
2834
+ }), createElement(Text, {
2835
+ className: styles$1.spaceName
2836
+ }, props.spaceName)));
2837
+ }
2838
+
2450
2839
  var getEntryTitle = entityHelpers.getEntryTitle,
2451
2840
  getEntityDescription = entityHelpers.getEntityDescription,
2452
2841
  getEntryStatus = entityHelpers.getEntryStatus,
2453
2842
  getEntryImage = entityHelpers.getEntryImage;
2454
- var styles$1 = {
2843
+ var styles$2 = {
2455
2844
  scheduleIcon: /*#__PURE__*/css({
2456
2845
  marginRight: tokens.spacing2Xs
2457
2846
  })
@@ -2516,12 +2905,17 @@ function WrappedEntryCard(props) {
2516
2905
  size: props.size,
2517
2906
  isSelected: props.isSelected,
2518
2907
  status: status,
2519
- icon: createElement(ScheduledIconWithTooltip, {
2908
+ style: props.spaceName ? {
2909
+ backgroundColor: tokens.gray100
2910
+ } : undefined,
2911
+ icon: props.spaceName ? createElement(SpaceName, {
2912
+ spaceName: props.spaceName
2913
+ }) : createElement(ScheduledIconWithTooltip, {
2520
2914
  getEntityScheduledActions: props.getEntityScheduledActions,
2521
2915
  entityType: "Entry",
2522
2916
  entityId: props.entry.sys.id
2523
2917
  }, createElement(ClockIcon, {
2524
- className: styles$1.scheduleIcon,
2918
+ className: styles$2.scheduleIcon,
2525
2919
  size: "small",
2526
2920
  variant: "muted",
2527
2921
  testId: "schedule-icon"
@@ -2626,13 +3020,13 @@ function _openEntry() {
2626
3020
 
2627
3021
  function FetchingWrappedEntryCard(props) {
2628
3022
  var _useEntities = useEntities(),
2629
- getOrLoadEntry = _useEntities.getOrLoadEntry,
2630
- getOrLoadAsset = _useEntities.getOrLoadAsset,
3023
+ getEntry = _useEntities.getEntry,
3024
+ getAsset = _useEntities.getAsset,
2631
3025
  loadEntityScheduledActions = _useEntities.loadEntityScheduledActions,
2632
3026
  entries = _useEntities.entries;
2633
3027
 
2634
3028
  useEffect(function () {
2635
- getOrLoadEntry(props.entryId); // eslint-disable-next-line react-hooks/exhaustive-deps -- TODO: Evaluate the dependencies
3029
+ getEntry(props.entryId); // eslint-disable-next-line react-hooks/exhaustive-deps -- TODO: Evaluate the dependencies
2636
3030
  }, [props.entryId]);
2637
3031
  var size = props.viewType === 'link' ? 'small' : 'default';
2638
3032
  var entry = entries[props.entryId];
@@ -2747,7 +3141,7 @@ function FetchingWrappedEntryCard(props) {
2747
3141
  hasCardEditActions: hasCardEditActions,
2748
3142
  hasCardMoveActions: hasCardMoveActions,
2749
3143
  hasCardRemoveActions: hasCardRemoveActions,
2750
- getAsset: getOrLoadAsset,
3144
+ getAsset: getAsset,
2751
3145
  getEntityScheduledActions: loadEntityScheduledActions,
2752
3146
  entry: (props == null ? void 0 : props.entity) || sharedCardProps.entity,
2753
3147
  entryUrl: (props == null ? void 0 : props.entityUrl) || sharedCardProps.entityUrl
@@ -2896,12 +3290,13 @@ MultipleReferenceEditor.defaultProps = {
2896
3290
  hasCardEditActions: true
2897
3291
  };
2898
3292
 
2899
- var styles$2 = {
2900
- containter: /*#__PURE__*/css({
3293
+ var styles$3 = {
3294
+ container: /*#__PURE__*/css({
2901
3295
  position: 'relative'
2902
3296
  }),
2903
3297
  item: /*#__PURE__*/css({
2904
- marginBottom: tokens.spacingM
3298
+ marginBottom: tokens.spacingM,
3299
+ marginRight: tokens.spacingM
2905
3300
  })
2906
3301
  };
2907
3302
 
@@ -2914,48 +3309,59 @@ var DragHandle = function DragHandle(props) {
2914
3309
 
2915
3310
  var SortableLink = /*#__PURE__*/SortableElement(function (props) {
2916
3311
  return React__default.createElement("div", {
2917
- className: styles$2.item
3312
+ className: styles$3.item
2918
3313
  }, props.children);
2919
3314
  });
2920
- var SortableLinkList = /*#__PURE__*/SortableContainer(function (props) {
2921
- var lastIndex = props.items.length - 1;
3315
+ var SortableLinkListInternal = /*#__PURE__*/SortableContainer(function (props) {
2922
3316
  return React__default.createElement("div", {
2923
- className: styles$2.containter
3317
+ className: cx(styles$3.container, props.className)
2924
3318
  }, props.items.map(function (item, index) {
3319
+ var _item$sys$id;
3320
+
2925
3321
  return React__default.createElement(SortableLink, {
2926
3322
  disabled: props.isDisabled,
2927
- key: item.sys.id + "-" + index,
3323
+ key: ((_item$sys$id = item.sys.id) != null ? _item$sys$id : item.sys.urn) + "-" + index,
2928
3324
  index: index
2929
- }, React__default.createElement(FetchingWrappedEntryCard, Object.assign({}, props, {
2930
- key: item.sys.id + "-" + index,
3325
+ }, props.children(_extends({}, props, {
3326
+ item: item,
2931
3327
  index: index,
2932
- allContentTypes: props.allContentTypes,
2933
- isDisabled: props.isDisabled,
2934
- entryId: item.sys.id,
2935
- onRemove: function onRemove() {
2936
- props.setValue(props.items.filter(function (_value, i) {
2937
- return i !== index;
2938
- }));
2939
- },
2940
- onMoveTop: index !== 0 ? function () {
2941
- return props.onMove(index, 0);
2942
- } : undefined,
2943
- onMoveBottom: index !== lastIndex ? function () {
2944
- return props.onMove(index, lastIndex);
2945
- } : undefined,
2946
- renderDragHandle: props.isDisabled ? undefined : DragHandle
3328
+ DragHandle: props.isDisabled ? undefined : DragHandle
2947
3329
  })));
2948
3330
  }));
2949
- });
3331
+ }); // HOC does not support generics, so we mimic it via additional component
3332
+
3333
+ function SortableLinkList(props) {
3334
+ return React__default.createElement(SortableLinkListInternal, Object.assign({}, props, {
3335
+ children: props.children
3336
+ }));
3337
+ }
2950
3338
 
2951
3339
  function MultipleEntryReferenceEditor(props) {
2952
3340
  return createElement(MultipleReferenceEditor, Object.assign({}, props, {
2953
3341
  entityType: "Entry"
2954
3342
  }), function (childrenProps) {
2955
- return createElement(SortableLinkList, Object.assign({}, props, childrenProps, {
2956
- axis: "y",
2957
- useDragHandle: true
2958
- }));
3343
+ return createElement(SortableLinkList, Object.assign({}, childrenProps), function (props) {
3344
+ var lastIndex = props.items.length - 1;
3345
+ return createElement(FetchingWrappedEntryCard, Object.assign({}, props, {
3346
+ key: props.item.sys.id + "-" + props.index,
3347
+ index: props.index,
3348
+ allContentTypes: childrenProps.allContentTypes,
3349
+ isDisabled: props.isDisabled,
3350
+ entryId: props.item.sys.id,
3351
+ onRemove: function onRemove() {
3352
+ childrenProps.setValue(props.items.filter(function (_value, i) {
3353
+ return i !== props.index;
3354
+ }));
3355
+ },
3356
+ onMoveTop: props.index !== 0 ? function () {
3357
+ return childrenProps.onMove(props.index, 0);
3358
+ } : undefined,
3359
+ onMoveBottom: props.index !== lastIndex ? function () {
3360
+ return childrenProps.onMove(props.index, lastIndex);
3361
+ } : undefined,
3362
+ renderDragHandle: props.DragHandle
3363
+ }));
3364
+ });
2959
3365
  });
2960
3366
  }
2961
3367
 
@@ -3029,7 +3435,7 @@ var groupToIconMap = {
3029
3435
  code: 'code',
3030
3436
  markup: 'markup'
3031
3437
  };
3032
- var styles$3 = {
3438
+ var styles$4 = {
3033
3439
  scheduleIcon: /*#__PURE__*/css({
3034
3440
  marginRight: tokens.spacing2Xs
3035
3441
  })
@@ -3091,7 +3497,7 @@ var WrappedAssetCard = function WrappedAssetCard(props) {
3091
3497
  entityType: "Asset",
3092
3498
  entityId: props.asset.sys.id
3093
3499
  }, React__default.createElement(ClockIcon, {
3094
- className: styles$3.scheduleIcon,
3500
+ className: styles$4.scheduleIcon,
3095
3501
  size: "small",
3096
3502
  variant: "muted",
3097
3503
  testId: "schedule-icon"
@@ -3122,7 +3528,7 @@ var WrappedAssetCard = function WrappedAssetCard(props) {
3122
3528
  };
3123
3529
  WrappedAssetCard.defaultProps = defaultProps$1;
3124
3530
 
3125
- var styles$4 = {
3531
+ var styles$5 = {
3126
3532
  scheduleIcon: /*#__PURE__*/css({
3127
3533
  marginRight: tokens.spacing2Xs
3128
3534
  })
@@ -3166,7 +3572,7 @@ var WrappedAssetLink = function WrappedAssetLink(props) {
3166
3572
  entityType: "Asset",
3167
3573
  entityId: props.asset.sys.id
3168
3574
  }, React__default.createElement(ClockIcon, {
3169
- className: styles$4.scheduleIcon,
3575
+ className: styles$5.scheduleIcon,
3170
3576
  size: "small",
3171
3577
  variant: "muted",
3172
3578
  testId: "schedule-icon"
@@ -3192,12 +3598,12 @@ var WrappedAssetLink = function WrappedAssetLink(props) {
3192
3598
 
3193
3599
  function FetchingWrappedAssetCard(props) {
3194
3600
  var _useEntities = useEntities(),
3195
- getOrLoadAsset = _useEntities.getOrLoadAsset,
3601
+ getAsset = _useEntities.getAsset,
3196
3602
  loadEntityScheduledActions = _useEntities.loadEntityScheduledActions,
3197
3603
  assets = _useEntities.assets;
3198
3604
 
3199
3605
  useEffect(function () {
3200
- getOrLoadAsset(props.assetId); // eslint-disable-next-line react-hooks/exhaustive-deps -- TODO: Evaluate the dependencies
3606
+ getAsset(props.assetId); // eslint-disable-next-line react-hooks/exhaustive-deps -- TODO: Evaluate the dependencies
3201
3607
  }, [props.assetId]);
3202
3608
  var asset = assets[props.assetId];
3203
3609
  var entityKey = asset === 'failed' ? 'failed' : asset === undefined ? 'undefined' : ":" + asset.sys.id + ":" + asset.sys.version;
@@ -3365,68 +3771,39 @@ SingleMediaEditor.defaultProps = {
3365
3771
  isInitiallyDisabled: true
3366
3772
  };
3367
3773
 
3368
- var styles$5 = {
3369
- gridContainter: /*#__PURE__*/css({
3774
+ var styles$6 = {
3775
+ gridContainer: /*#__PURE__*/css({
3370
3776
  position: 'relative',
3371
3777
  display: 'flex',
3372
3778
  flexWrap: 'wrap'
3373
- }),
3374
- container: /*#__PURE__*/css({
3375
- position: 'relative'
3376
- }),
3377
- item: /*#__PURE__*/css({
3378
- marginBottom: tokens.spacingM,
3379
- marginRight: tokens.spacingM
3380
3779
  })
3381
3780
  };
3382
-
3383
- var DragHandle$1 = function DragHandle(props) {
3384
- var SortableDragHandle = SortableHandle(function () {
3385
- return props.drag;
3386
- });
3387
- return React__default.createElement(SortableDragHandle, null);
3388
- };
3389
-
3390
- var SortableLink$1 = /*#__PURE__*/SortableElement(function (props) {
3391
- return React__default.createElement("div", {
3392
- className: styles$5.item
3393
- }, props.children);
3394
- });
3395
- var SortableLinkList$1 = /*#__PURE__*/SortableContainer(function (props) {
3396
- return React__default.createElement("div", {
3397
- className: props.viewType === 'card' ? styles$5.gridContainter : styles$5.container
3398
- }, props.items.map(function (item, index) {
3399
- return React__default.createElement(SortableLink$1, {
3400
- disabled: props.isDisabled,
3401
- key: item.sys.id + "-" + index,
3402
- index: index
3403
- }, React__default.createElement(FetchingWrappedAssetCard, Object.assign({}, props, {
3404
- sdk: props.sdk,
3405
- key: item.sys.id + "-" + index,
3406
- assetId: item.sys.id,
3407
- onRemove: function onRemove() {
3408
- props.setValue(props.items.filter(function (_value, i) {
3409
- return i !== index;
3410
- }));
3411
- },
3412
- renderDragHandle: props.isDisabled ? undefined : DragHandle$1
3413
- })));
3414
- }));
3415
- });
3416
-
3417
3781
  function MultipleMediaEditor(props) {
3418
3782
  return createElement(MultipleReferenceEditor, Object.assign({}, props, {
3419
3783
  entityType: "Asset"
3420
3784
  }), function (childrenProps) {
3421
- return createElement(SortableLinkList$1, Object.assign({}, props, childrenProps, {
3422
- axis: props.viewType === 'card' ? 'xy' : 'y',
3423
- useDragHandle: true
3424
- }));
3785
+ var _cx;
3786
+
3787
+ return createElement(SortableLinkList, Object.assign({}, childrenProps, {
3788
+ className: cx((_cx = {}, _cx[styles$6.gridContainer] = childrenProps.viewType === 'card', _cx)),
3789
+ axis: childrenProps.viewType === 'card' ? 'xy' : 'y'
3790
+ }), function (props) {
3791
+ return createElement(FetchingWrappedAssetCard, Object.assign({}, props, {
3792
+ key: props.item.sys.id + "-" + props.index,
3793
+ assetId: props.item.sys.id,
3794
+ onRemove: function onRemove() {
3795
+ childrenProps.setValue(props.items.filter(function (_value, i) {
3796
+ return i !== props.index;
3797
+ }));
3798
+ },
3799
+ renderDragHandle: props.DragHandle
3800
+ }));
3801
+ });
3425
3802
  });
3426
3803
  }
3427
3804
  MultipleMediaEditor.defaultProps = {
3428
3805
  isInitiallyDisabled: true
3429
3806
  };
3430
3807
 
3431
- export { AssetThumbnail, CombinedLinkActions, CreateEntryLinkButton, CreateEntryMenuTrigger, EntityProvider, MissingEntityCard, MultipleEntryReferenceEditor, MultipleMediaEditor, ScheduledIconWithTooltip, SingleEntryReferenceEditor, SingleMediaEditor, WrappedAssetCard, WrappedEntryCard, getScheduleTooltipContent, useEntities };
3808
+ export { AssetThumbnail, CombinedLinkActions, CreateEntryLinkButton, CreateEntryMenuTrigger, EntityProvider, MissingEntityCard, MultipleEntryReferenceEditor, MultipleMediaEditor, ScheduledIconWithTooltip, SingleEntryReferenceEditor, SingleMediaEditor, SortableLinkList, WrappedAssetCard, WrappedEntryCard, getScheduleTooltipContent, useEntities };
3432
3809
  //# sourceMappingURL=field-editor-reference.esm.js.map