@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
|
@@ -5,7 +5,7 @@ import tokens from '@contentful/forma-36-tokens';
|
|
|
5
5
|
import get from 'lodash-es/get';
|
|
6
6
|
import moment from 'moment';
|
|
7
7
|
import deepEqual from 'deep-equal';
|
|
8
|
-
import { FieldConnector, entityHelpers } from '@contentful/field-editor-shared';
|
|
8
|
+
import { FieldConnector, isValidImage, entityHelpers, shortenStorageUnit } from '@contentful/field-editor-shared';
|
|
9
9
|
import constate from 'constate';
|
|
10
10
|
import isNumber from 'lodash-es/isNumber';
|
|
11
11
|
import arrayMove from 'array-move';
|
|
@@ -2485,15 +2485,6 @@ SingleReferenceEditor.defaultProps = {
|
|
|
2485
2485
|
hasCardEditActions: true
|
|
2486
2486
|
};
|
|
2487
2487
|
|
|
2488
|
-
/**
|
|
2489
|
-
* Checks whether the passed content type matches one of our valid MIME types
|
|
2490
|
-
*/
|
|
2491
|
-
function isValidImage(file) {
|
|
2492
|
-
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.
|
|
2493
|
-
'image/jpg', 'image/jpeg', 'image/pjpeg', 'image/x-jps', 'image/png', 'image/svg+xml'];
|
|
2494
|
-
return validMimeTypes.includes(file.contentType);
|
|
2495
|
-
}
|
|
2496
|
-
|
|
2497
2488
|
var getEntryTitle = entityHelpers.getEntryTitle,
|
|
2498
2489
|
getEntityDescription = entityHelpers.getEntityDescription,
|
|
2499
2490
|
getEntryStatus = entityHelpers.getEntryStatus,
|
|
@@ -3002,72 +2993,6 @@ function MultipleEntryReferenceEditor(props) {
|
|
|
3002
2993
|
});
|
|
3003
2994
|
}
|
|
3004
2995
|
|
|
3005
|
-
/**
|
|
3006
|
-
* Transforms a number into a localized string (en-US)
|
|
3007
|
-
* toLocaleString(1000); // "1,000"
|
|
3008
|
-
* @param {Number} number
|
|
3009
|
-
*/
|
|
3010
|
-
function toLocaleString(number) {
|
|
3011
|
-
return number.toLocaleString('en-US');
|
|
3012
|
-
}
|
|
3013
|
-
|
|
3014
|
-
function formatFloat(value, localize) {
|
|
3015
|
-
return localize ? toLocaleString(value) : value.toFixed(2) // remove floating point if not necessary
|
|
3016
|
-
.replace(/\.(0)*$|0*$/, '');
|
|
3017
|
-
}
|
|
3018
|
-
/**
|
|
3019
|
-
* Make a storage unit number more readable by making them smaller
|
|
3020
|
-
* shortenStorageUnit(1000, 'GB'); // "1 TB"
|
|
3021
|
-
* shortenStorageUnit(0.001, 'TB'); // "1 GB"
|
|
3022
|
-
* @param value
|
|
3023
|
-
* @param uom Unit of measure
|
|
3024
|
-
* @returns
|
|
3025
|
-
*/
|
|
3026
|
-
|
|
3027
|
-
|
|
3028
|
-
function shortenStorageUnit(value, uom) {
|
|
3029
|
-
if (value <= 0) {
|
|
3030
|
-
return '0 B';
|
|
3031
|
-
}
|
|
3032
|
-
|
|
3033
|
-
var units = ['PB', 'TB', 'GB', 'MB', 'KB', 'B'];
|
|
3034
|
-
|
|
3035
|
-
var getBigger = function getBigger(unit) {
|
|
3036
|
-
return units[units.indexOf(unit) - 1];
|
|
3037
|
-
};
|
|
3038
|
-
|
|
3039
|
-
var getSmaller = function getSmaller(unit) {
|
|
3040
|
-
return units[units.indexOf(unit) + 1];
|
|
3041
|
-
};
|
|
3042
|
-
|
|
3043
|
-
var isBiggestUnit = function isBiggestUnit(unit) {
|
|
3044
|
-
return units.indexOf(unit) === 0;
|
|
3045
|
-
};
|
|
3046
|
-
|
|
3047
|
-
var isSmallestUnit = function isSmallestUnit(unit) {
|
|
3048
|
-
return units.indexOf(unit) === units.length - 1;
|
|
3049
|
-
};
|
|
3050
|
-
|
|
3051
|
-
var reduce = function reduce(number, unit) {
|
|
3052
|
-
if (number < 0.99 && !isSmallestUnit(unit)) {
|
|
3053
|
-
return reduce(number * 1000, getSmaller(unit));
|
|
3054
|
-
} else if (number >= 1000 && !isBiggestUnit(unit)) {
|
|
3055
|
-
return reduce(number / 1000, getBigger(unit));
|
|
3056
|
-
} else {
|
|
3057
|
-
return {
|
|
3058
|
-
number: number,
|
|
3059
|
-
unit: unit
|
|
3060
|
-
};
|
|
3061
|
-
}
|
|
3062
|
-
};
|
|
3063
|
-
|
|
3064
|
-
var _reduce = reduce(value, uom),
|
|
3065
|
-
number = _reduce.number,
|
|
3066
|
-
unit = _reduce.unit;
|
|
3067
|
-
|
|
3068
|
-
return formatFloat(number, false) + " " + unit;
|
|
3069
|
-
}
|
|
3070
|
-
|
|
3071
2996
|
var styles$4 = {
|
|
3072
2997
|
cardDropdown: /*#__PURE__*/css({
|
|
3073
2998
|
width: '300px'
|