@contentful/field-editor-reference 2.20.9 → 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 +8 -0
- package/dist/field-editor-reference.cjs.development.js +1 -67
- 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 -67
- package/dist/field-editor-reference.esm.js.map +1 -1
- package/package.json +2 -2
- package/dist/assets/WrappedAssetCard/shortenStorageUnit.d.ts +0 -17
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,14 @@
|
|
|
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
|
+
|
|
6
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)
|
|
7
15
|
|
|
8
16
|
**Note:** Version bump only for package @contentful/field-editor-reference
|
|
@@ -3000,72 +3000,6 @@ function MultipleEntryReferenceEditor(props) {
|
|
|
3000
3000
|
});
|
|
3001
3001
|
}
|
|
3002
3002
|
|
|
3003
|
-
/**
|
|
3004
|
-
* Transforms a number into a localized string (en-US)
|
|
3005
|
-
* toLocaleString(1000); // "1,000"
|
|
3006
|
-
* @param {Number} number
|
|
3007
|
-
*/
|
|
3008
|
-
function toLocaleString(number) {
|
|
3009
|
-
return number.toLocaleString('en-US');
|
|
3010
|
-
}
|
|
3011
|
-
|
|
3012
|
-
function formatFloat(value, localize) {
|
|
3013
|
-
return localize ? toLocaleString(value) : value.toFixed(2) // remove floating point if not necessary
|
|
3014
|
-
.replace(/\.(0)*$|0*$/, '');
|
|
3015
|
-
}
|
|
3016
|
-
/**
|
|
3017
|
-
* Make a storage unit number more readable by making them smaller
|
|
3018
|
-
* shortenStorageUnit(1000, 'GB'); // "1 TB"
|
|
3019
|
-
* shortenStorageUnit(0.001, 'TB'); // "1 GB"
|
|
3020
|
-
* @param value
|
|
3021
|
-
* @param uom Unit of measure
|
|
3022
|
-
* @returns
|
|
3023
|
-
*/
|
|
3024
|
-
|
|
3025
|
-
|
|
3026
|
-
function shortenStorageUnit(value, uom) {
|
|
3027
|
-
if (value <= 0) {
|
|
3028
|
-
return '0 B';
|
|
3029
|
-
}
|
|
3030
|
-
|
|
3031
|
-
var units = ['PB', 'TB', 'GB', 'MB', 'KB', 'B'];
|
|
3032
|
-
|
|
3033
|
-
var getBigger = function getBigger(unit) {
|
|
3034
|
-
return units[units.indexOf(unit) - 1];
|
|
3035
|
-
};
|
|
3036
|
-
|
|
3037
|
-
var getSmaller = function getSmaller(unit) {
|
|
3038
|
-
return units[units.indexOf(unit) + 1];
|
|
3039
|
-
};
|
|
3040
|
-
|
|
3041
|
-
var isBiggestUnit = function isBiggestUnit(unit) {
|
|
3042
|
-
return units.indexOf(unit) === 0;
|
|
3043
|
-
};
|
|
3044
|
-
|
|
3045
|
-
var isSmallestUnit = function isSmallestUnit(unit) {
|
|
3046
|
-
return units.indexOf(unit) === units.length - 1;
|
|
3047
|
-
};
|
|
3048
|
-
|
|
3049
|
-
var reduce = function reduce(number, unit) {
|
|
3050
|
-
if (number < 0.99 && !isSmallestUnit(unit)) {
|
|
3051
|
-
return reduce(number * 1000, getSmaller(unit));
|
|
3052
|
-
} else if (number >= 1000 && !isBiggestUnit(unit)) {
|
|
3053
|
-
return reduce(number / 1000, getBigger(unit));
|
|
3054
|
-
} else {
|
|
3055
|
-
return {
|
|
3056
|
-
number: number,
|
|
3057
|
-
unit: unit
|
|
3058
|
-
};
|
|
3059
|
-
}
|
|
3060
|
-
};
|
|
3061
|
-
|
|
3062
|
-
var _reduce = reduce(value, uom),
|
|
3063
|
-
number = _reduce.number,
|
|
3064
|
-
unit = _reduce.unit;
|
|
3065
|
-
|
|
3066
|
-
return formatFloat(number, false) + " " + unit;
|
|
3067
|
-
}
|
|
3068
|
-
|
|
3069
3003
|
var styles$4 = {
|
|
3070
3004
|
cardDropdown: /*#__PURE__*/emotion.css({
|
|
3071
3005
|
width: '300px'
|
|
@@ -3098,7 +3032,7 @@ function renderAssetInfo(props) {
|
|
|
3098
3032
|
isTitle: true
|
|
3099
3033
|
}, "File info"), fileName && React__default.createElement(forma36ReactComponents.DropdownListItem, null, React__default.createElement("div", {
|
|
3100
3034
|
className: styles$4.truncated
|
|
3101
|
-
}, 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));
|
|
3102
3036
|
}
|
|
3103
3037
|
function renderActions(props) {
|
|
3104
3038
|
var entityFile = props.entityFile,
|