@contentful/field-editor-reference 2.20.7 → 2.20.11

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,41 @@
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
+ ## [2.20.11](https://github.com/contentful/field-editors/compare/@contentful/field-editor-reference@2.20.10...@contentful/field-editor-reference@2.20.11) (2021-10-06)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **reference:** consistent ordering of link actions ([#884](https://github.com/contentful/field-editors/issues/884)) ([1a6bae7](https://github.com/contentful/field-editors/commit/1a6bae7825b09d91151bd80e7f55c0c1cf5ec27c))
12
+
13
+
14
+
15
+
16
+
17
+ ## [2.20.10](https://github.com/contentful/field-editors/compare/@contentful/field-editor-reference@2.20.9...@contentful/field-editor-reference@2.20.10) (2021-09-20)
18
+
19
+ **Note:** Version bump only for package @contentful/field-editor-reference
20
+
21
+
22
+
23
+
24
+
25
+ ## [2.20.9](https://github.com/contentful/field-editors/compare/@contentful/field-editor-reference@2.20.8...@contentful/field-editor-reference@2.20.9) (2021-09-17)
26
+
27
+ **Note:** Version bump only for package @contentful/field-editor-reference
28
+
29
+
30
+
31
+
32
+
33
+ ## [2.20.8](https://github.com/contentful/field-editors/compare/@contentful/field-editor-reference@2.20.7...@contentful/field-editor-reference@2.20.8) (2021-09-17)
34
+
35
+ **Note:** Version bump only for package @contentful/field-editor-reference
36
+
37
+
38
+
39
+
40
+
6
41
  ## [2.20.7](https://github.com/contentful/field-editors/compare/@contentful/field-editor-reference@2.20.6...@contentful/field-editor-reference@2.20.7) (2021-09-16)
7
42
 
8
43
  **Note:** Version bump only for package @contentful/field-editor-reference
@@ -604,18 +604,18 @@ function CombinedAssetLinkActions(props) {
604
604
  }, React.createElement(forma36ReactComponents.DropdownList, {
605
605
  testId: testIds$1.dropdown
606
606
  }, React.createElement(forma36ReactComponents.DropdownListItem, {
607
- testId: testIds$1.createAndLink,
607
+ testId: testIds$1.linkExisting,
608
608
  onClick: function onClick() {
609
609
  setOpen(false);
610
- props.onCreate();
610
+ props.onLinkExisting();
611
611
  }
612
- }, "Add new media"), React.createElement(forma36ReactComponents.DropdownListItem, {
613
- testId: testIds$1.linkExisting,
612
+ }, "Add existing media"), React.createElement(forma36ReactComponents.DropdownListItem, {
613
+ testId: testIds$1.createAndLink,
614
614
  onClick: function onClick() {
615
615
  setOpen(false);
616
- props.onLinkExisting();
616
+ props.onCreate();
617
617
  }
618
- }, "Add existing media")));
618
+ }, "Add new media")));
619
619
  }
620
620
 
621
621
  var card = /*#__PURE__*/emotion.css({
@@ -2492,15 +2492,6 @@ SingleReferenceEditor.defaultProps = {
2492
2492
  hasCardEditActions: true
2493
2493
  };
2494
2494
 
2495
- /**
2496
- * Checks whether the passed content type matches one of our valid MIME types
2497
- */
2498
- function isValidImage(file) {
2499
- var validMimeTypes = ['image/bmp', 'image/x-windows-bmp', 'image/gif', 'image/webp', // This is not a valid MIME type but we supported it in the past.
2500
- 'image/jpg', 'image/jpeg', 'image/pjpeg', 'image/x-jps', 'image/png', 'image/svg+xml'];
2501
- return validMimeTypes.includes(file.contentType);
2502
- }
2503
-
2504
2495
  var getEntryTitle = fieldEditorShared.entityHelpers.getEntryTitle,
2505
2496
  getEntityDescription = fieldEditorShared.entityHelpers.getEntityDescription,
2506
2497
  getEntryStatus = fieldEditorShared.entityHelpers.getEntryStatus,
@@ -2581,7 +2572,7 @@ function WrappedEntryCard(props) {
2581
2572
  color: "muted",
2582
2573
  testId: "schedule-icon"
2583
2574
  })),
2584
- thumbnailElement: file && isValidImage(file) ? React.createElement(AssetThumbnail, {
2575
+ thumbnailElement: file && fieldEditorShared.isValidImage(file) ? React.createElement(AssetThumbnail, {
2585
2576
  file: file
2586
2577
  }) : null,
2587
2578
  cardDragHandleComponent: props.cardDragHandle,
@@ -3009,72 +3000,6 @@ function MultipleEntryReferenceEditor(props) {
3009
3000
  });
3010
3001
  }
3011
3002
 
3012
- /**
3013
- * Transforms a number into a localized string (en-US)
3014
- * toLocaleString(1000); // "1,000"
3015
- * @param {Number} number
3016
- */
3017
- function toLocaleString(number) {
3018
- return number.toLocaleString('en-US');
3019
- }
3020
-
3021
- function formatFloat(value, localize) {
3022
- return localize ? toLocaleString(value) : value.toFixed(2) // remove floating point if not necessary
3023
- .replace(/\.(0)*$|0*$/, '');
3024
- }
3025
- /**
3026
- * Make a storage unit number more readable by making them smaller
3027
- * shortenStorageUnit(1000, 'GB'); // "1 TB"
3028
- * shortenStorageUnit(0.001, 'TB'); // "1 GB"
3029
- * @param value
3030
- * @param uom Unit of measure
3031
- * @returns
3032
- */
3033
-
3034
-
3035
- function shortenStorageUnit(value, uom) {
3036
- if (value <= 0) {
3037
- return '0 B';
3038
- }
3039
-
3040
- var units = ['PB', 'TB', 'GB', 'MB', 'KB', 'B'];
3041
-
3042
- var getBigger = function getBigger(unit) {
3043
- return units[units.indexOf(unit) - 1];
3044
- };
3045
-
3046
- var getSmaller = function getSmaller(unit) {
3047
- return units[units.indexOf(unit) + 1];
3048
- };
3049
-
3050
- var isBiggestUnit = function isBiggestUnit(unit) {
3051
- return units.indexOf(unit) === 0;
3052
- };
3053
-
3054
- var isSmallestUnit = function isSmallestUnit(unit) {
3055
- return units.indexOf(unit) === units.length - 1;
3056
- };
3057
-
3058
- var reduce = function reduce(number, unit) {
3059
- if (number < 0.99 && !isSmallestUnit(unit)) {
3060
- return reduce(number * 1000, getSmaller(unit));
3061
- } else if (number >= 1000 && !isBiggestUnit(unit)) {
3062
- return reduce(number / 1000, getBigger(unit));
3063
- } else {
3064
- return {
3065
- number: number,
3066
- unit: unit
3067
- };
3068
- }
3069
- };
3070
-
3071
- var _reduce = reduce(value, uom),
3072
- number = _reduce.number,
3073
- unit = _reduce.unit;
3074
-
3075
- return formatFloat(number, false) + " " + unit;
3076
- }
3077
-
3078
3003
  var styles$4 = {
3079
3004
  cardDropdown: /*#__PURE__*/emotion.css({
3080
3005
  width: '300px'
@@ -3107,7 +3032,7 @@ function renderAssetInfo(props) {
3107
3032
  isTitle: true
3108
3033
  }, "File info"), fileName && React__default.createElement(forma36ReactComponents.DropdownListItem, null, React__default.createElement("div", {
3109
3034
  className: styles$4.truncated
3110
- }, fileName)), mimeType && React__default.createElement(forma36ReactComponents.DropdownListItem, null, React__default.createElement("div", null, mimeType)), fileSize && React__default.createElement(forma36ReactComponents.DropdownListItem, null, shortenStorageUnit(fileSize, 'B')), image && React__default.createElement(forma36ReactComponents.DropdownListItem, null, image.width + " \xD7 " + image.height));
3035
+ }, fileName)), mimeType && React__default.createElement(forma36ReactComponents.DropdownListItem, null, React__default.createElement("div", null, mimeType)), fileSize && React__default.createElement(forma36ReactComponents.DropdownListItem, null, fieldEditorShared.shortenStorageUnit(fileSize, 'B')), image && React__default.createElement(forma36ReactComponents.DropdownListItem, null, image.width + " \xD7 " + image.height));
3111
3036
  }
3112
3037
  function renderActions(props) {
3113
3038
  var entityFile = props.entityFile,