@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.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,22 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [4.4.0](https://github.com/contentful/field-editors/compare/@contentful/field-editor-reference@4.3.11...@contentful/field-editor-reference@4.4.0) (2022-07-06)
7
+
8
+ ### Features
9
+
10
+ - add optional space name to entry card ([#1176](https://github.com/contentful/field-editors/issues/1176)) ([62fae44](https://github.com/contentful/field-editors/commit/62fae44a63ad29597acf6ae0ba7f15373b1045c0))
11
+
12
+ ## [4.3.11](https://github.com/contentful/field-editors/compare/@contentful/field-editor-reference@4.3.10...@contentful/field-editor-reference@4.3.11) (2022-06-30)
13
+
14
+ ### Bug Fixes
15
+
16
+ - search input styles [HOMER-1048] ([#1170](https://github.com/contentful/field-editors/issues/1170)) ([bc96fb9](https://github.com/contentful/field-editors/commit/bc96fb93bcca5508bdca38eafc8377878e97fb4b))
17
+
18
+ ## [4.3.10](https://github.com/contentful/field-editors/compare/@contentful/field-editor-reference@4.3.9...@contentful/field-editor-reference@4.3.10) (2022-06-22)
19
+
20
+ **Note:** Version bump only for package @contentful/field-editor-reference
21
+
6
22
  ## [4.3.9](https://github.com/contentful/field-editors/compare/@contentful/field-editor-reference@4.3.8...@contentful/field-editor-reference@4.3.9) (2022-06-21)
7
23
 
8
24
  **Note:** Version bump only for package @contentful/field-editor-reference
@@ -0,0 +1,6 @@
1
+ /// <reference types="react" />
2
+ interface SpaceNameProps {
3
+ spaceName: string;
4
+ }
5
+ export declare function SpaceName(props: SpaceNameProps): JSX.Element;
6
+ export {};
@@ -14,6 +14,7 @@ export interface WrappedEntryCardProps {
14
14
  localeCode: string;
15
15
  defaultLocaleCode: string;
16
16
  contentType?: ContentType;
17
+ spaceName?: string;
17
18
  entry: Entry;
18
19
  renderDragHandle?: RenderDragFn;
19
20
  isClickable?: boolean;
@@ -9,8 +9,8 @@ var React__default = _interopDefault(React);
9
9
  var emotion = require('emotion');
10
10
  var tokens = _interopDefault(require('@contentful/f36-tokens'));
11
11
  var get = _interopDefault(require('lodash/get'));
12
- var f36Icons = require('@contentful/f36-icons');
13
12
  var f36Components = require('@contentful/f36-components');
13
+ var f36Icons = require('@contentful/f36-icons');
14
14
  var moment = _interopDefault(require('moment'));
15
15
  var deepEqual = _interopDefault(require('deep-equal'));
16
16
  var fieldEditorShared = require('@contentful/field-editor-shared');
@@ -115,20 +115,10 @@ var styles = {
115
115
  position: 'relative',
116
116
  padding: "0 " + tokens.spacing2Xs
117
117
  }),
118
- searchInput: function searchInput(parentHasDropdown) {
119
- return emotion.css({
120
- '& > input': {
121
- borderColor: 'transparent',
122
- borderRadius: parentHasDropdown ? 0 : undefined,
123
- borderLeft: parentHasDropdown ? 'none' : undefined,
124
- borderRight: parentHasDropdown ? 'none' : undefined,
125
- paddingRight: tokens.spacing2Xl,
126
- '::placeholder': {
127
- color: tokens.gray600
128
- }
129
- }
130
- });
131
- },
118
+ searchInput: /*#__PURE__*/emotion.css({
119
+ paddingRight: tokens.spacingXl,
120
+ textOverflow: 'ellipsis'
121
+ }),
132
122
  searchIcon: /*#__PURE__*/emotion.css({
133
123
  position: 'absolute',
134
124
  right: tokens.spacingM,
@@ -277,7 +267,7 @@ var CreateEntryMenuTrigger = function CreateEntryMenuTrigger(_ref) {
277
267
  ref: textField,
278
268
  className: styles.inputWrapper
279
269
  }, React__default.createElement(f36Components.TextInput, {
280
- className: styles.searchInput(hasDropdown),
270
+ className: styles.searchInput,
281
271
  placeholder: "Search all content types",
282
272
  testId: "add-entry-menu-search",
283
273
  value: searchInput,
@@ -1548,7 +1538,8 @@ function useLinkActionsProps(props) {
1548
1538
  slide: slide,
1549
1539
  index: index
1550
1540
  });
1551
- }, [entityType, props.onCreate, props.onAction]);
1541
+ }, // eslint-disable-next-line react-hooks/exhaustive-deps -- TODO: Evaluate the dependencies
1542
+ [entityType, props.onCreate, props.onAction]);
1552
1543
  var onLinkedExisting = React.useCallback(function (entities, index) {
1553
1544
  if (index === void 0) {
1554
1545
  index = itemsLength;
@@ -1565,7 +1556,8 @@ function useLinkActionsProps(props) {
1565
1556
  index: index === undefined ? undefined : index + i
1566
1557
  });
1567
1558
  });
1568
- }, [entityType, props.onLink, props.onAction]);
1559
+ }, // eslint-disable-next-line react-hooks/exhaustive-deps -- TODO: Evaluate the dependencies
1560
+ [entityType, props.onLink, props.onAction]);
1569
1561
  var onCreate = React.useCallback( /*#__PURE__*/function () {
1570
1562
  var _ref = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(contentTypeId, index) {
1571
1563
  var _yield$createEntity, entity, slide;
@@ -1687,7 +1679,7 @@ function useLinkActionsProps(props) {
1687
1679
  return function onLinkSeveralExisting(_x4) {
1688
1680
  return _ref3.apply(this, arguments);
1689
1681
  };
1690
- }(); // FIXME: The memoization might rerun every time due to the always changing callback identities above
1682
+ }(); // FIXME: The memoization might rerun every time due to the always changing callback identities above
1691
1683
 
1692
1684
 
1693
1685
  return React.useMemo(function () {
@@ -1707,7 +1699,9 @@ function useLinkActionsProps(props) {
1707
1699
  onLinkedExisting: onLinkedExisting,
1708
1700
  itemsLength: itemsLength
1709
1701
  };
1710
- }, [entityType, canLinkMultiple, isDisabled, isEmpty, isFull, editorPermissions.canCreateEntity, editorPermissions.canLinkEntity, actionLabels, editorPermissions.creatableContentTypes.map(function (ct) {
1702
+ }, // eslint-disable-next-line react-hooks/exhaustive-deps -- TODO: Evaluate the dependencies
1703
+ [entityType, canLinkMultiple, isDisabled, isEmpty, isFull, editorPermissions.canCreateEntity, editorPermissions.canLinkEntity, actionLabels, // eslint-disable-next-line react-hooks/exhaustive-deps -- TODO: Evaluate the dependencies
1704
+ editorPermissions.creatableContentTypes.map(function (ct) {
1711
1705
  return ct.sys.id;
1712
1706
  }).join(':'), onCreate, onLinkExisting, onLinkSeveralExisting, onCreated, onLinkedExisting, itemsLength]);
1713
1707
  }
@@ -1721,7 +1715,7 @@ function LinkEntityActions(_ref4) {
1721
1715
  return renderLinkActions(props);
1722
1716
  }
1723
1717
 
1724
- // eslint-disable-next-line no-restricted-imports
1718
+ // eslint-disable-next-line -- TODO: describe this disable no-restricted-imports
1725
1719
  /**
1726
1720
  * @param {Date|string} date A valid constructor argument for moment()
1727
1721
  * @param {boolean=} short Render only Today/Tomorrow/Yesterday if valid. Defaults to false
@@ -1801,7 +1795,7 @@ var ScheduledIconWithTooltip = function ScheduledIconWithTooltip(_ref) {
1801
1795
  });
1802
1796
  }); // This should only be ever called once. Following the eslint hint to add used
1803
1797
  // dependencies will cause page freeze (infinite loop)
1804
- // eslint-disable-next-line
1798
+ // eslint-disable-next-line -- TODO: describe this disable
1805
1799
  }, []);
1806
1800
 
1807
1801
  if (status.type === 'loading' || status.type === 'error') {
@@ -1997,7 +1991,7 @@ function useEntitiesStore(props) {
1997
1991
  }
1998
1992
  });
1999
1993
  }
2000
- });
1994
+ }); // eslint-disable-next-line react-hooks/exhaustive-deps -- TODO: Evaluate the dependencies
2001
1995
  }, [props.sdk, state.assets, state.entries]);
2002
1996
  return _extends({
2003
1997
  getOrLoadEntry: getOrLoadEntry,
@@ -2179,7 +2173,7 @@ function useContentTypePermissions(props) {
2179
2173
  return _checkContentTypeAccess.apply(this, arguments);
2180
2174
  }
2181
2175
 
2182
- void checkContentTypeAccess();
2176
+ void checkContentTypeAccess(); // eslint-disable-next-line react-hooks/exhaustive-deps -- TODO: Evaluate the dependencies
2183
2177
  }, [availableContentTypes]);
2184
2178
  return {
2185
2179
  creatableContentTypes: creatableContentTypes,
@@ -2191,7 +2185,7 @@ function useContentTypePermissions(props) {
2191
2185
  function fromFieldValidations(field) {
2192
2186
  var _field$items$validati, _field$items, _linkContentTypeValid, _linkMimetypeGroupVal;
2193
2187
 
2194
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
2188
+ // eslint-disable-next-line -- TODO: describe this disable @typescript-eslint/no-explicit-any
2195
2189
  var validations = [].concat(field.validations, (_field$items$validati = (_field$items = field.items) == null ? void 0 : _field$items.validations) != null ? _field$items$validati : []);
2196
2190
  var linkContentTypeValidations = validations.find(function (v) {
2197
2191
  return 'linkContentType' in v;
@@ -2319,7 +2313,7 @@ function useEditorPermissions(props) {
2319
2313
  return _checkCreateAccess.apply(this, arguments);
2320
2314
  }
2321
2315
 
2322
- void checkCreateAccess();
2316
+ void checkCreateAccess(); // eslint-disable-next-line react-hooks/exhaustive-deps -- TODO: Evaluate the dependencies
2323
2317
  }, [entityType, parameters.instance, creatableContentTypes]);
2324
2318
  React.useEffect(function () {
2325
2319
  if (parameters.instance.showLinkEntityAction === false) {
@@ -2381,7 +2375,7 @@ function useEditorPermissions(props) {
2381
2375
  return _checkLinkAccess.apply(this, arguments);
2382
2376
  }
2383
2377
 
2384
- void checkLinkAccess();
2378
+ void checkLinkAccess(); // eslint-disable-next-line react-hooks/exhaustive-deps -- TODO: Evaluate the dependencies
2385
2379
  }, [entityType, parameters.instance, readableContentTypes]);
2386
2380
  return {
2387
2381
  canCreateEntity: canCreateEntity,
@@ -2425,7 +2419,8 @@ function Editor(props) {
2425
2419
 
2426
2420
  var customCardRenderer = React.useCallback(function (cardProps, _, renderDefaultCard) {
2427
2421
  return props.renderCustomCard ? props.renderCustomCard(cardProps, linkActionsProps, renderDefaultCard) : false;
2428
- }, [linkActionsProps]);
2422
+ }, // eslint-disable-next-line react-hooks/exhaustive-deps -- TODO: Evaluate the dependencies
2423
+ [linkActionsProps]);
2429
2424
 
2430
2425
  if (!props.entityId) {
2431
2426
  return React.createElement(LinkEntityActions, Object.assign({
@@ -2459,11 +2454,40 @@ SingleReferenceEditor.defaultProps = {
2459
2454
  hasCardRemoveActions: true
2460
2455
  };
2461
2456
 
2457
+ var styles$1 = {
2458
+ spaceIcon: /*#__PURE__*/emotion.css({
2459
+ flexShrink: 0,
2460
+ fill: tokens.purple600
2461
+ }),
2462
+ spaceName: /*#__PURE__*/emotion.css({
2463
+ color: tokens.gray700,
2464
+ fontSize: tokens.fontSizeS,
2465
+ fontWeight: tokens.fontWeightDemiBold
2466
+ })
2467
+ };
2468
+ function SpaceName(props) {
2469
+ return React.createElement(f36Components.Tooltip, {
2470
+ placement: "top",
2471
+ as: "div",
2472
+ content: "Space"
2473
+ }, React.createElement(f36Components.Flex, {
2474
+ alignItems: "center",
2475
+ gap: "spacingXs",
2476
+ marginRight: "spacingS"
2477
+ }, React.createElement(f36Icons.FolderOpenTrimmedIcon, {
2478
+ className: styles$1.spaceIcon,
2479
+ size: "tiny",
2480
+ "aria-label": "Source space"
2481
+ }), React.createElement(f36Components.Text, {
2482
+ className: styles$1.spaceName
2483
+ }, props.spaceName)));
2484
+ }
2485
+
2462
2486
  var getEntryTitle = fieldEditorShared.entityHelpers.getEntryTitle,
2463
2487
  getEntityDescription = fieldEditorShared.entityHelpers.getEntityDescription,
2464
2488
  getEntryStatus = fieldEditorShared.entityHelpers.getEntryStatus,
2465
2489
  getEntryImage = fieldEditorShared.entityHelpers.getEntryImage;
2466
- var styles$1 = {
2490
+ var styles$2 = {
2467
2491
  scheduleIcon: /*#__PURE__*/emotion.css({
2468
2492
  marginRight: tokens.spacing2Xs
2469
2493
  })
@@ -2528,12 +2552,17 @@ function WrappedEntryCard(props) {
2528
2552
  size: props.size,
2529
2553
  isSelected: props.isSelected,
2530
2554
  status: status,
2531
- icon: React.createElement(ScheduledIconWithTooltip, {
2555
+ style: props.spaceName ? {
2556
+ backgroundColor: tokens.gray100
2557
+ } : undefined,
2558
+ icon: props.spaceName ? React.createElement(SpaceName, {
2559
+ spaceName: props.spaceName
2560
+ }) : React.createElement(ScheduledIconWithTooltip, {
2532
2561
  getEntityScheduledActions: props.getEntityScheduledActions,
2533
2562
  entityType: "Entry",
2534
2563
  entityId: props.entry.sys.id
2535
2564
  }, React.createElement(f36Icons.ClockIcon, {
2536
- className: styles$1.scheduleIcon,
2565
+ className: styles$2.scheduleIcon,
2537
2566
  size: "small",
2538
2567
  variant: "muted",
2539
2568
  testId: "schedule-icon"
@@ -2644,7 +2673,7 @@ function FetchingWrappedEntryCard(props) {
2644
2673
  entries = _useEntities.entries;
2645
2674
 
2646
2675
  React.useEffect(function () {
2647
- getOrLoadEntry(props.entryId);
2676
+ getOrLoadEntry(props.entryId); // eslint-disable-next-line react-hooks/exhaustive-deps -- TODO: Evaluate the dependencies
2648
2677
  }, [props.entryId]);
2649
2678
  var size = props.viewType === 'link' ? 'small' : 'default';
2650
2679
  var entry = entries[props.entryId];
@@ -2702,7 +2731,8 @@ function FetchingWrappedEntryCard(props) {
2702
2731
  type: 'rendered',
2703
2732
  entity: 'Entry'
2704
2733
  });
2705
- }
2734
+ } // eslint-disable-next-line react-hooks/exhaustive-deps -- TODO: Evaluate the dependencies
2735
+
2706
2736
  }, [entry]);
2707
2737
  return React.useMemo(function () {
2708
2738
  if (entry === 'failed') {
@@ -2776,7 +2806,7 @@ function FetchingWrappedEntryCard(props) {
2776
2806
  }
2777
2807
  }
2778
2808
 
2779
- return renderDefaultCard();
2809
+ return renderDefaultCard(); // eslint-disable-next-line react-hooks/exhaustive-deps -- TODO: Evaluate the dependencies
2780
2810
  }, [props, entityKey]);
2781
2811
  }
2782
2812
 
@@ -2875,7 +2905,8 @@ function Editor$1(props) {
2875
2905
  }));
2876
2906
  var customCardRenderer = React.useCallback(function (cardProps, _, renderDefaultCard) {
2877
2907
  return props.renderCustomCard ? props.renderCustomCard(cardProps, linkActionsProps, renderDefaultCard) : false;
2878
- }, [linkActionsProps]);
2908
+ }, // eslint-disable-next-line react-hooks/exhaustive-deps -- TODO: Evaluate the dependencies
2909
+ [linkActionsProps]);
2879
2910
  return React.createElement(React.Fragment, null, props.children(_extends({}, props, {
2880
2911
  onSortStart: onSortStart,
2881
2912
  onSortEnd: onSortEnd,
@@ -2906,7 +2937,7 @@ MultipleReferenceEditor.defaultProps = {
2906
2937
  hasCardEditActions: true
2907
2938
  };
2908
2939
 
2909
- var styles$2 = {
2940
+ var styles$3 = {
2910
2941
  containter: /*#__PURE__*/emotion.css({
2911
2942
  position: 'relative'
2912
2943
  }),
@@ -2924,13 +2955,13 @@ var DragHandle = function DragHandle(props) {
2924
2955
 
2925
2956
  var SortableLink = /*#__PURE__*/reactSortableHoc.SortableElement(function (props) {
2926
2957
  return React__default.createElement("div", {
2927
- className: styles$2.item
2958
+ className: styles$3.item
2928
2959
  }, props.children);
2929
2960
  });
2930
2961
  var SortableLinkList = /*#__PURE__*/reactSortableHoc.SortableContainer(function (props) {
2931
2962
  var lastIndex = props.items.length - 1;
2932
2963
  return React__default.createElement("div", {
2933
- className: styles$2.containter
2964
+ className: styles$3.containter
2934
2965
  }, props.items.map(function (item, index) {
2935
2966
  return React__default.createElement(SortableLink, {
2936
2967
  disabled: props.isDisabled,
@@ -3039,14 +3070,14 @@ var groupToIconMap = {
3039
3070
  code: 'code',
3040
3071
  markup: 'markup'
3041
3072
  };
3042
- var styles$3 = {
3073
+ var styles$4 = {
3043
3074
  scheduleIcon: /*#__PURE__*/emotion.css({
3044
3075
  marginRight: tokens.spacing2Xs
3045
3076
  })
3046
3077
  };
3047
3078
  var defaultProps$1 = {
3048
3079
  isClickable: true
3049
- }; // eslint-disable-next-line @typescript-eslint/no-explicit-any
3080
+ }; // eslint-disable-next-line -- TODO: describe this disable @typescript-eslint/no-explicit-any
3050
3081
 
3051
3082
  function getFileType(file) {
3052
3083
  if (!file) {
@@ -3101,7 +3132,7 @@ var WrappedAssetCard = function WrappedAssetCard(props) {
3101
3132
  entityType: "Asset",
3102
3133
  entityId: props.asset.sys.id
3103
3134
  }, React__default.createElement(f36Icons.ClockIcon, {
3104
- className: styles$3.scheduleIcon,
3135
+ className: styles$4.scheduleIcon,
3105
3136
  size: "small",
3106
3137
  variant: "muted",
3107
3138
  testId: "schedule-icon"
@@ -3132,7 +3163,7 @@ var WrappedAssetCard = function WrappedAssetCard(props) {
3132
3163
  };
3133
3164
  WrappedAssetCard.defaultProps = defaultProps$1;
3134
3165
 
3135
- var styles$4 = {
3166
+ var styles$5 = {
3136
3167
  scheduleIcon: /*#__PURE__*/emotion.css({
3137
3168
  marginRight: tokens.spacing2Xs
3138
3169
  })
@@ -3176,7 +3207,7 @@ var WrappedAssetLink = function WrappedAssetLink(props) {
3176
3207
  entityType: "Asset",
3177
3208
  entityId: props.asset.sys.id
3178
3209
  }, React__default.createElement(f36Icons.ClockIcon, {
3179
- className: styles$4.scheduleIcon,
3210
+ className: styles$5.scheduleIcon,
3180
3211
  size: "small",
3181
3212
  variant: "muted",
3182
3213
  testId: "schedule-icon"
@@ -3207,7 +3238,7 @@ function FetchingWrappedAssetCard(props) {
3207
3238
  assets = _useEntities.assets;
3208
3239
 
3209
3240
  React.useEffect(function () {
3210
- getOrLoadAsset(props.assetId);
3241
+ getOrLoadAsset(props.assetId); // eslint-disable-next-line react-hooks/exhaustive-deps -- TODO: Evaluate the dependencies
3211
3242
  }, [props.assetId]);
3212
3243
  var asset = assets[props.assetId];
3213
3244
  var entityKey = asset === 'failed' ? 'failed' : asset === undefined ? 'undefined' : ":" + asset.sys.id + ":" + asset.sys.version;
@@ -3217,7 +3248,8 @@ function FetchingWrappedAssetCard(props) {
3217
3248
  type: 'rendered',
3218
3249
  entity: 'Asset'
3219
3250
  });
3220
- }
3251
+ } // eslint-disable-next-line react-hooks/exhaustive-deps -- TODO: Evaluate the dependencies
3252
+
3221
3253
  }, [asset]);
3222
3254
 
3223
3255
  var onEdit = /*#__PURE__*/function () {
@@ -3349,7 +3381,7 @@ function FetchingWrappedAssetCard(props) {
3349
3381
  }
3350
3382
  }
3351
3383
 
3352
- return renderDefaultCard();
3384
+ return renderDefaultCard(); // eslint-disable-next-line react-hooks/exhaustive-deps -- TODO: Evaluate the dependencies
3353
3385
  }, [props, entityKey]);
3354
3386
  }
3355
3387
 
@@ -3374,7 +3406,7 @@ SingleMediaEditor.defaultProps = {
3374
3406
  isInitiallyDisabled: true
3375
3407
  };
3376
3408
 
3377
- var styles$5 = {
3409
+ var styles$6 = {
3378
3410
  gridContainter: /*#__PURE__*/emotion.css({
3379
3411
  position: 'relative',
3380
3412
  display: 'flex',
@@ -3398,12 +3430,12 @@ var DragHandle$1 = function DragHandle(props) {
3398
3430
 
3399
3431
  var SortableLink$1 = /*#__PURE__*/reactSortableHoc.SortableElement(function (props) {
3400
3432
  return React__default.createElement("div", {
3401
- className: styles$5.item
3433
+ className: styles$6.item
3402
3434
  }, props.children);
3403
3435
  });
3404
3436
  var SortableLinkList$1 = /*#__PURE__*/reactSortableHoc.SortableContainer(function (props) {
3405
3437
  return React__default.createElement("div", {
3406
- className: props.viewType === 'card' ? styles$5.gridContainter : styles$5.container
3438
+ className: props.viewType === 'card' ? styles$6.gridContainter : styles$6.container
3407
3439
  }, props.items.map(function (item, index) {
3408
3440
  return React__default.createElement(SortableLink$1, {
3409
3441
  disabled: props.isDisabled,