@contentful/field-editor-reference 2.20.6 → 2.20.10
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 +32 -0
- package/dist/field-editor-reference.cjs.development.js +2 -77
- package/dist/field-editor-reference.cjs.development.js.map +1 -1
- package/dist/field-editor-reference.cjs.production.min.js +1 -1
- package/dist/field-editor-reference.cjs.production.min.js.map +1 -1
- package/dist/field-editor-reference.esm.js +1 -76
- package/dist/field-editor-reference.esm.js.map +1 -1
- package/package.json +4 -4
- package/dist/assets/WrappedAssetCard/shortenStorageUnit.d.ts +0 -17
- package/dist/utils/isValidImage.d.ts +0 -5
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,38 @@
|
|
|
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.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)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @contentful/field-editor-reference
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## [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)
|
|
15
|
+
|
|
16
|
+
**Note:** Version bump only for package @contentful/field-editor-reference
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
## [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)
|
|
23
|
+
|
|
24
|
+
**Note:** Version bump only for package @contentful/field-editor-reference
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
## [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)
|
|
31
|
+
|
|
32
|
+
**Note:** Version bump only for package @contentful/field-editor-reference
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
6
38
|
## [2.20.6](https://github.com/contentful/field-editors/compare/@contentful/field-editor-reference@2.20.5...@contentful/field-editor-reference@2.20.6) (2021-08-19)
|
|
7
39
|
|
|
8
40
|
**Note:** Version bump only for package @contentful/field-editor-reference
|
|
@@ -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,
|