@contentful/field-editor-reference 5.5.3 → 5.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.
@@ -1,9 +1,9 @@
1
1
  import React__default, { useState, useRef, useEffect, createElement, Fragment, useMemo, useCallback } from 'react';
2
2
  import { css, cx } from 'emotion';
3
3
  import tokens from '@contentful/f36-tokens';
4
- import get from 'lodash-es/get';
5
4
  import { Menu, TextInput, Button, Paragraph, Card, Flex, SectionHeading, IconButton, Tooltip, Text, EntryCard, MenuItem, MenuDivider, AssetCard } from '@contentful/f36-components';
6
5
  import { SearchIcon, PlusIcon, ChevronDownIcon, LinkIcon, CloseIcon, FolderOpenTrimmedIcon, ClockIcon } from '@contentful/f36-icons';
6
+ import get from 'lodash-es/get';
7
7
  import moment from 'moment';
8
8
  import { FieldConnector, isValidImage, entityHelpers, shortenStorageUnit } from '@contentful/field-editor-shared';
9
9
  import deepEqual from 'deep-equal';
@@ -190,7 +190,7 @@ var action = /*#__PURE__*/css({
190
190
  });
191
191
 
192
192
  /* eslint-disable @typescript-eslint/no-explicit-any */
193
- var MAX_ITEMS_WITHOUT_SEARCH = 20;
193
+ var MAX_ITEMS_WITHOUT_SEARCH = 5;
194
194
  var menuPlacementMap = {
195
195
  'bottom-left': 'bottom-start',
196
196
  'bottom-right': 'bottom-end'
@@ -396,7 +396,8 @@ var standardStyles = {
396
396
  var redesignStyles = /*#__PURE__*/_extends({}, standardStyles, {
397
397
  action: /*#__PURE__*/css({
398
398
  textDecoration: 'none',
399
- fontWeight: 'bold'
399
+ fontWeight: 'bold',
400
+ maxWidth: '300px'
400
401
  })
401
402
  });
402
403
 
@@ -3357,7 +3358,9 @@ var styles$3 = {
3357
3358
  position: 'relative'
3358
3359
  }),
3359
3360
  item: /*#__PURE__*/css({
3360
- marginBottom: tokens.spacingM
3361
+ marginBottom: tokens.spacingM,
3362
+ zIndex: tokens.zIndexModalContent // setting this to an index above 99 fixes dragged item disappearing issue
3363
+
3361
3364
  })
3362
3365
  };
3363
3366
 
@@ -4037,32 +4040,37 @@ function ResourceCard(props) {
4037
4040
  })));
4038
4041
  }
4039
4042
 
4040
- var toLinkItem = function toLinkItem(entry) {
4043
+ var toLinkItem = function toLinkItem(entry, apiUrl) {
4044
+ var _entry$sys$urn;
4045
+
4041
4046
  return {
4042
4047
  sys: {
4043
4048
  type: 'ResourceLink',
4044
4049
  linkType: 'Contentful:Entry',
4045
- urn: entry.sys.urn
4050
+ urn: (_entry$sys$urn = entry.sys.urn) != null ? _entry$sys$urn : "crn:" + apiUrl + ":::content:spaces/" + entry.sys.space.sys.id + "/entries/" + entry.sys.id
4046
4051
  }
4047
4052
  };
4048
4053
  };
4049
4054
 
4050
- var getUpdatedValue = function getUpdatedValue(field, entries) {
4055
+ var getUpdatedValue = function getUpdatedValue(field, entries, apiUrl) {
4051
4056
  var multiple = field.type === 'Array';
4052
4057
 
4053
4058
  if (multiple) {
4054
- var linkItems = entries.map(toLinkItem);
4059
+ var linkItems = entries.map(function (entry) {
4060
+ return toLinkItem(entry, apiUrl);
4061
+ });
4055
4062
  var prevValue = field.getValue() || [];
4056
4063
  return [].concat(prevValue, linkItems);
4057
4064
  } else {
4058
- return toLinkItem(entries[0]);
4065
+ return toLinkItem(entries[0], apiUrl);
4059
4066
  }
4060
4067
  };
4061
4068
 
4062
4069
  function useResourceLinkActions(_ref) {
4063
4070
  var dialogs = _ref.dialogs,
4064
4071
  field = _ref.field,
4065
- onAfterLink = _ref.onAfterLink;
4072
+ onAfterLink = _ref.onAfterLink,
4073
+ apiUrl = _ref.apiUrl;
4066
4074
  var handleAfterLink = useCallback(function (entries) {
4067
4075
  if (!onAfterLink) {
4068
4076
  return;
@@ -4072,11 +4080,11 @@ function useResourceLinkActions(_ref) {
4072
4080
  }, [onAfterLink]);
4073
4081
  var onLinkedExisting = useMemo(function () {
4074
4082
  return function (entries) {
4075
- var updatedValue = getUpdatedValue(field, entries);
4083
+ var updatedValue = getUpdatedValue(field, entries, apiUrl);
4076
4084
  field.setValue(updatedValue);
4077
4085
  handleAfterLink(entries);
4078
4086
  };
4079
- }, [field, handleAfterLink]);
4087
+ }, [field, handleAfterLink, apiUrl]);
4080
4088
  var multiple = field.type === 'Array';
4081
4089
  var onLinkExisting = useMemo(function () {
4082
4090
  var promptSelection = multiple ? /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee() {