@contentful/field-editor-reference 4.3.9 → 4.4.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.
@@ -2,8 +2,8 @@ import React__default, { useState, useRef, useEffect, createElement, Fragment, u
2
2
  import { css } from 'emotion';
3
3
  import tokens from '@contentful/f36-tokens';
4
4
  import get from 'lodash-es/get';
5
- import { SearchIcon, PlusIcon, ChevronDownIcon, LinkIcon, CloseIcon, ClockIcon } from '@contentful/f36-icons';
6
- import { Menu, TextInput, Button, Paragraph, Card, SectionHeading, IconButton, Tooltip, EntryCard, MenuItem, MenuDivider, Text, AssetCard } from '@contentful/f36-components';
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';
@@ -108,20 +108,10 @@ var styles = {
108
108
  position: 'relative',
109
109
  padding: "0 " + tokens.spacing2Xs
110
110
  }),
111
- searchInput: function searchInput(parentHasDropdown) {
112
- return css({
113
- '& > input': {
114
- borderColor: 'transparent',
115
- borderRadius: parentHasDropdown ? 0 : undefined,
116
- borderLeft: parentHasDropdown ? 'none' : undefined,
117
- borderRight: parentHasDropdown ? 'none' : undefined,
118
- paddingRight: tokens.spacing2Xl,
119
- '::placeholder': {
120
- color: tokens.gray600
121
- }
122
- }
123
- });
124
- },
111
+ searchInput: /*#__PURE__*/css({
112
+ paddingRight: tokens.spacingXl,
113
+ textOverflow: 'ellipsis'
114
+ }),
125
115
  searchIcon: /*#__PURE__*/css({
126
116
  position: 'absolute',
127
117
  right: tokens.spacingM,
@@ -270,7 +260,7 @@ var CreateEntryMenuTrigger = function CreateEntryMenuTrigger(_ref) {
270
260
  ref: textField,
271
261
  className: styles.inputWrapper
272
262
  }, React__default.createElement(TextInput, {
273
- className: styles.searchInput(hasDropdown),
263
+ className: styles.searchInput,
274
264
  placeholder: "Search all content types",
275
265
  testId: "add-entry-menu-search",
276
266
  value: searchInput,
@@ -1541,7 +1531,8 @@ function useLinkActionsProps(props) {
1541
1531
  slide: slide,
1542
1532
  index: index
1543
1533
  });
1544
- }, [entityType, props.onCreate, props.onAction]);
1534
+ }, // eslint-disable-next-line react-hooks/exhaustive-deps -- TODO: Evaluate the dependencies
1535
+ [entityType, props.onCreate, props.onAction]);
1545
1536
  var onLinkedExisting = useCallback(function (entities, index) {
1546
1537
  if (index === void 0) {
1547
1538
  index = itemsLength;
@@ -1558,7 +1549,8 @@ function useLinkActionsProps(props) {
1558
1549
  index: index === undefined ? undefined : index + i
1559
1550
  });
1560
1551
  });
1561
- }, [entityType, props.onLink, props.onAction]);
1552
+ }, // eslint-disable-next-line react-hooks/exhaustive-deps -- TODO: Evaluate the dependencies
1553
+ [entityType, props.onLink, props.onAction]);
1562
1554
  var onCreate = useCallback( /*#__PURE__*/function () {
1563
1555
  var _ref = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(contentTypeId, index) {
1564
1556
  var _yield$createEntity, entity, slide;
@@ -1680,7 +1672,7 @@ function useLinkActionsProps(props) {
1680
1672
  return function onLinkSeveralExisting(_x4) {
1681
1673
  return _ref3.apply(this, arguments);
1682
1674
  };
1683
- }(); // FIXME: The memoization might rerun every time due to the always changing callback identities above
1675
+ }(); // FIXME: The memoization might rerun every time due to the always changing callback identities above
1684
1676
 
1685
1677
 
1686
1678
  return useMemo(function () {
@@ -1700,7 +1692,9 @@ function useLinkActionsProps(props) {
1700
1692
  onLinkedExisting: onLinkedExisting,
1701
1693
  itemsLength: itemsLength
1702
1694
  };
1703
- }, [entityType, canLinkMultiple, isDisabled, isEmpty, isFull, editorPermissions.canCreateEntity, editorPermissions.canLinkEntity, actionLabels, editorPermissions.creatableContentTypes.map(function (ct) {
1695
+ }, // eslint-disable-next-line react-hooks/exhaustive-deps -- TODO: Evaluate the dependencies
1696
+ [entityType, canLinkMultiple, isDisabled, isEmpty, isFull, editorPermissions.canCreateEntity, editorPermissions.canLinkEntity, actionLabels, // eslint-disable-next-line react-hooks/exhaustive-deps -- TODO: Evaluate the dependencies
1697
+ editorPermissions.creatableContentTypes.map(function (ct) {
1704
1698
  return ct.sys.id;
1705
1699
  }).join(':'), onCreate, onLinkExisting, onLinkSeveralExisting, onCreated, onLinkedExisting, itemsLength]);
1706
1700
  }
@@ -1714,7 +1708,7 @@ function LinkEntityActions(_ref4) {
1714
1708
  return renderLinkActions(props);
1715
1709
  }
1716
1710
 
1717
- // eslint-disable-next-line no-restricted-imports
1711
+ // eslint-disable-next-line -- TODO: describe this disable no-restricted-imports
1718
1712
  /**
1719
1713
  * @param {Date|string} date A valid constructor argument for moment()
1720
1714
  * @param {boolean=} short Render only Today/Tomorrow/Yesterday if valid. Defaults to false
@@ -1794,7 +1788,7 @@ var ScheduledIconWithTooltip = function ScheduledIconWithTooltip(_ref) {
1794
1788
  });
1795
1789
  }); // This should only be ever called once. Following the eslint hint to add used
1796
1790
  // dependencies will cause page freeze (infinite loop)
1797
- // eslint-disable-next-line
1791
+ // eslint-disable-next-line -- TODO: describe this disable
1798
1792
  }, []);
1799
1793
 
1800
1794
  if (status.type === 'loading' || status.type === 'error') {
@@ -1990,7 +1984,7 @@ function useEntitiesStore(props) {
1990
1984
  }
1991
1985
  });
1992
1986
  }
1993
- });
1987
+ }); // eslint-disable-next-line react-hooks/exhaustive-deps -- TODO: Evaluate the dependencies
1994
1988
  }, [props.sdk, state.assets, state.entries]);
1995
1989
  return _extends({
1996
1990
  getOrLoadEntry: getOrLoadEntry,
@@ -2172,7 +2166,7 @@ function useContentTypePermissions(props) {
2172
2166
  return _checkContentTypeAccess.apply(this, arguments);
2173
2167
  }
2174
2168
 
2175
- void checkContentTypeAccess();
2169
+ void checkContentTypeAccess(); // eslint-disable-next-line react-hooks/exhaustive-deps -- TODO: Evaluate the dependencies
2176
2170
  }, [availableContentTypes]);
2177
2171
  return {
2178
2172
  creatableContentTypes: creatableContentTypes,
@@ -2184,7 +2178,7 @@ function useContentTypePermissions(props) {
2184
2178
  function fromFieldValidations(field) {
2185
2179
  var _field$items$validati, _field$items, _linkContentTypeValid, _linkMimetypeGroupVal;
2186
2180
 
2187
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
2181
+ // eslint-disable-next-line -- TODO: describe this disable @typescript-eslint/no-explicit-any
2188
2182
  var validations = [].concat(field.validations, (_field$items$validati = (_field$items = field.items) == null ? void 0 : _field$items.validations) != null ? _field$items$validati : []);
2189
2183
  var linkContentTypeValidations = validations.find(function (v) {
2190
2184
  return 'linkContentType' in v;
@@ -2312,7 +2306,7 @@ function useEditorPermissions(props) {
2312
2306
  return _checkCreateAccess.apply(this, arguments);
2313
2307
  }
2314
2308
 
2315
- void checkCreateAccess();
2309
+ void checkCreateAccess(); // eslint-disable-next-line react-hooks/exhaustive-deps -- TODO: Evaluate the dependencies
2316
2310
  }, [entityType, parameters.instance, creatableContentTypes]);
2317
2311
  useEffect(function () {
2318
2312
  if (parameters.instance.showLinkEntityAction === false) {
@@ -2374,7 +2368,7 @@ function useEditorPermissions(props) {
2374
2368
  return _checkLinkAccess.apply(this, arguments);
2375
2369
  }
2376
2370
 
2377
- void checkLinkAccess();
2371
+ void checkLinkAccess(); // eslint-disable-next-line react-hooks/exhaustive-deps -- TODO: Evaluate the dependencies
2378
2372
  }, [entityType, parameters.instance, readableContentTypes]);
2379
2373
  return {
2380
2374
  canCreateEntity: canCreateEntity,
@@ -2418,7 +2412,8 @@ function Editor(props) {
2418
2412
 
2419
2413
  var customCardRenderer = useCallback(function (cardProps, _, renderDefaultCard) {
2420
2414
  return props.renderCustomCard ? props.renderCustomCard(cardProps, linkActionsProps, renderDefaultCard) : false;
2421
- }, [linkActionsProps]);
2415
+ }, // eslint-disable-next-line react-hooks/exhaustive-deps -- TODO: Evaluate the dependencies
2416
+ [linkActionsProps]);
2422
2417
 
2423
2418
  if (!props.entityId) {
2424
2419
  return createElement(LinkEntityActions, Object.assign({
@@ -2452,11 +2447,40 @@ SingleReferenceEditor.defaultProps = {
2452
2447
  hasCardRemoveActions: true
2453
2448
  };
2454
2449
 
2450
+ var styles$1 = {
2451
+ spaceIcon: /*#__PURE__*/css({
2452
+ flexShrink: 0,
2453
+ fill: tokens.purple600
2454
+ }),
2455
+ spaceName: /*#__PURE__*/css({
2456
+ color: tokens.gray700,
2457
+ fontSize: tokens.fontSizeS,
2458
+ fontWeight: tokens.fontWeightDemiBold
2459
+ })
2460
+ };
2461
+ function SpaceName(props) {
2462
+ return createElement(Tooltip, {
2463
+ placement: "top",
2464
+ as: "div",
2465
+ content: "Space"
2466
+ }, createElement(Flex, {
2467
+ alignItems: "center",
2468
+ gap: "spacingXs",
2469
+ marginRight: "spacingS"
2470
+ }, createElement(FolderOpenTrimmedIcon, {
2471
+ className: styles$1.spaceIcon,
2472
+ size: "tiny",
2473
+ "aria-label": "Source space"
2474
+ }), createElement(Text, {
2475
+ className: styles$1.spaceName
2476
+ }, props.spaceName)));
2477
+ }
2478
+
2455
2479
  var getEntryTitle = entityHelpers.getEntryTitle,
2456
2480
  getEntityDescription = entityHelpers.getEntityDescription,
2457
2481
  getEntryStatus = entityHelpers.getEntryStatus,
2458
2482
  getEntryImage = entityHelpers.getEntryImage;
2459
- var styles$1 = {
2483
+ var styles$2 = {
2460
2484
  scheduleIcon: /*#__PURE__*/css({
2461
2485
  marginRight: tokens.spacing2Xs
2462
2486
  })
@@ -2521,12 +2545,17 @@ function WrappedEntryCard(props) {
2521
2545
  size: props.size,
2522
2546
  isSelected: props.isSelected,
2523
2547
  status: status,
2524
- icon: createElement(ScheduledIconWithTooltip, {
2548
+ style: props.spaceName ? {
2549
+ backgroundColor: tokens.gray100
2550
+ } : undefined,
2551
+ icon: props.spaceName ? createElement(SpaceName, {
2552
+ spaceName: props.spaceName
2553
+ }) : createElement(ScheduledIconWithTooltip, {
2525
2554
  getEntityScheduledActions: props.getEntityScheduledActions,
2526
2555
  entityType: "Entry",
2527
2556
  entityId: props.entry.sys.id
2528
2557
  }, createElement(ClockIcon, {
2529
- className: styles$1.scheduleIcon,
2558
+ className: styles$2.scheduleIcon,
2530
2559
  size: "small",
2531
2560
  variant: "muted",
2532
2561
  testId: "schedule-icon"
@@ -2637,7 +2666,7 @@ function FetchingWrappedEntryCard(props) {
2637
2666
  entries = _useEntities.entries;
2638
2667
 
2639
2668
  useEffect(function () {
2640
- getOrLoadEntry(props.entryId);
2669
+ getOrLoadEntry(props.entryId); // eslint-disable-next-line react-hooks/exhaustive-deps -- TODO: Evaluate the dependencies
2641
2670
  }, [props.entryId]);
2642
2671
  var size = props.viewType === 'link' ? 'small' : 'default';
2643
2672
  var entry = entries[props.entryId];
@@ -2695,7 +2724,8 @@ function FetchingWrappedEntryCard(props) {
2695
2724
  type: 'rendered',
2696
2725
  entity: 'Entry'
2697
2726
  });
2698
- }
2727
+ } // eslint-disable-next-line react-hooks/exhaustive-deps -- TODO: Evaluate the dependencies
2728
+
2699
2729
  }, [entry]);
2700
2730
  return useMemo(function () {
2701
2731
  if (entry === 'failed') {
@@ -2769,7 +2799,7 @@ function FetchingWrappedEntryCard(props) {
2769
2799
  }
2770
2800
  }
2771
2801
 
2772
- return renderDefaultCard();
2802
+ return renderDefaultCard(); // eslint-disable-next-line react-hooks/exhaustive-deps -- TODO: Evaluate the dependencies
2773
2803
  }, [props, entityKey]);
2774
2804
  }
2775
2805
 
@@ -2868,7 +2898,8 @@ function Editor$1(props) {
2868
2898
  }));
2869
2899
  var customCardRenderer = useCallback(function (cardProps, _, renderDefaultCard) {
2870
2900
  return props.renderCustomCard ? props.renderCustomCard(cardProps, linkActionsProps, renderDefaultCard) : false;
2871
- }, [linkActionsProps]);
2901
+ }, // eslint-disable-next-line react-hooks/exhaustive-deps -- TODO: Evaluate the dependencies
2902
+ [linkActionsProps]);
2872
2903
  return createElement(Fragment, null, props.children(_extends({}, props, {
2873
2904
  onSortStart: onSortStart,
2874
2905
  onSortEnd: onSortEnd,
@@ -2899,7 +2930,7 @@ MultipleReferenceEditor.defaultProps = {
2899
2930
  hasCardEditActions: true
2900
2931
  };
2901
2932
 
2902
- var styles$2 = {
2933
+ var styles$3 = {
2903
2934
  containter: /*#__PURE__*/css({
2904
2935
  position: 'relative'
2905
2936
  }),
@@ -2917,13 +2948,13 @@ var DragHandle = function DragHandle(props) {
2917
2948
 
2918
2949
  var SortableLink = /*#__PURE__*/SortableElement(function (props) {
2919
2950
  return React__default.createElement("div", {
2920
- className: styles$2.item
2951
+ className: styles$3.item
2921
2952
  }, props.children);
2922
2953
  });
2923
2954
  var SortableLinkList = /*#__PURE__*/SortableContainer(function (props) {
2924
2955
  var lastIndex = props.items.length - 1;
2925
2956
  return React__default.createElement("div", {
2926
- className: styles$2.containter
2957
+ className: styles$3.containter
2927
2958
  }, props.items.map(function (item, index) {
2928
2959
  return React__default.createElement(SortableLink, {
2929
2960
  disabled: props.isDisabled,
@@ -3032,14 +3063,14 @@ var groupToIconMap = {
3032
3063
  code: 'code',
3033
3064
  markup: 'markup'
3034
3065
  };
3035
- var styles$3 = {
3066
+ var styles$4 = {
3036
3067
  scheduleIcon: /*#__PURE__*/css({
3037
3068
  marginRight: tokens.spacing2Xs
3038
3069
  })
3039
3070
  };
3040
3071
  var defaultProps$1 = {
3041
3072
  isClickable: true
3042
- }; // eslint-disable-next-line @typescript-eslint/no-explicit-any
3073
+ }; // eslint-disable-next-line -- TODO: describe this disable @typescript-eslint/no-explicit-any
3043
3074
 
3044
3075
  function getFileType(file) {
3045
3076
  if (!file) {
@@ -3094,7 +3125,7 @@ var WrappedAssetCard = function WrappedAssetCard(props) {
3094
3125
  entityType: "Asset",
3095
3126
  entityId: props.asset.sys.id
3096
3127
  }, React__default.createElement(ClockIcon, {
3097
- className: styles$3.scheduleIcon,
3128
+ className: styles$4.scheduleIcon,
3098
3129
  size: "small",
3099
3130
  variant: "muted",
3100
3131
  testId: "schedule-icon"
@@ -3125,7 +3156,7 @@ var WrappedAssetCard = function WrappedAssetCard(props) {
3125
3156
  };
3126
3157
  WrappedAssetCard.defaultProps = defaultProps$1;
3127
3158
 
3128
- var styles$4 = {
3159
+ var styles$5 = {
3129
3160
  scheduleIcon: /*#__PURE__*/css({
3130
3161
  marginRight: tokens.spacing2Xs
3131
3162
  })
@@ -3169,7 +3200,7 @@ var WrappedAssetLink = function WrappedAssetLink(props) {
3169
3200
  entityType: "Asset",
3170
3201
  entityId: props.asset.sys.id
3171
3202
  }, React__default.createElement(ClockIcon, {
3172
- className: styles$4.scheduleIcon,
3203
+ className: styles$5.scheduleIcon,
3173
3204
  size: "small",
3174
3205
  variant: "muted",
3175
3206
  testId: "schedule-icon"
@@ -3200,7 +3231,7 @@ function FetchingWrappedAssetCard(props) {
3200
3231
  assets = _useEntities.assets;
3201
3232
 
3202
3233
  useEffect(function () {
3203
- getOrLoadAsset(props.assetId);
3234
+ getOrLoadAsset(props.assetId); // eslint-disable-next-line react-hooks/exhaustive-deps -- TODO: Evaluate the dependencies
3204
3235
  }, [props.assetId]);
3205
3236
  var asset = assets[props.assetId];
3206
3237
  var entityKey = asset === 'failed' ? 'failed' : asset === undefined ? 'undefined' : ":" + asset.sys.id + ":" + asset.sys.version;
@@ -3210,7 +3241,8 @@ function FetchingWrappedAssetCard(props) {
3210
3241
  type: 'rendered',
3211
3242
  entity: 'Asset'
3212
3243
  });
3213
- }
3244
+ } // eslint-disable-next-line react-hooks/exhaustive-deps -- TODO: Evaluate the dependencies
3245
+
3214
3246
  }, [asset]);
3215
3247
 
3216
3248
  var onEdit = /*#__PURE__*/function () {
@@ -3342,7 +3374,7 @@ function FetchingWrappedAssetCard(props) {
3342
3374
  }
3343
3375
  }
3344
3376
 
3345
- return renderDefaultCard();
3377
+ return renderDefaultCard(); // eslint-disable-next-line react-hooks/exhaustive-deps -- TODO: Evaluate the dependencies
3346
3378
  }, [props, entityKey]);
3347
3379
  }
3348
3380
 
@@ -3367,7 +3399,7 @@ SingleMediaEditor.defaultProps = {
3367
3399
  isInitiallyDisabled: true
3368
3400
  };
3369
3401
 
3370
- var styles$5 = {
3402
+ var styles$6 = {
3371
3403
  gridContainter: /*#__PURE__*/css({
3372
3404
  position: 'relative',
3373
3405
  display: 'flex',
@@ -3391,12 +3423,12 @@ var DragHandle$1 = function DragHandle(props) {
3391
3423
 
3392
3424
  var SortableLink$1 = /*#__PURE__*/SortableElement(function (props) {
3393
3425
  return React__default.createElement("div", {
3394
- className: styles$5.item
3426
+ className: styles$6.item
3395
3427
  }, props.children);
3396
3428
  });
3397
3429
  var SortableLinkList$1 = /*#__PURE__*/SortableContainer(function (props) {
3398
3430
  return React__default.createElement("div", {
3399
- className: props.viewType === 'card' ? styles$5.gridContainter : styles$5.container
3431
+ className: props.viewType === 'card' ? styles$6.gridContainter : styles$6.container
3400
3432
  }, props.items.map(function (item, index) {
3401
3433
  return React__default.createElement(SortableLink$1, {
3402
3434
  disabled: props.isDisabled,