@scaleflex/widget-utils 4.1.0 → 4.4.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.
- package/CHANGELOG.md +24 -0
- package/package.json +3 -3
- package/lib/AbortController.js +0 -20
- package/lib/BlurHash/base83.js +0 -10
- package/lib/BlurHash/decode.js +0 -80
- package/lib/BlurHash/error.js +0 -28
- package/lib/BlurHash/utils.js +0 -22
- package/lib/CustomDate.js +0 -157
- package/lib/EventTracker.js +0 -42
- package/lib/FOCUSABLE_ELEMENTS.js +0 -1
- package/lib/LinkHelper.js +0 -153
- package/lib/NetworkError.js +0 -30
- package/lib/ProgressTimeout.js +0 -45
- package/lib/RateLimitedQueue.js +0 -197
- package/lib/RequestError.js +0 -36
- package/lib/Timeframes/getDateRange.js +0 -45
- package/lib/TranslationMissingKeysConsoleHelper.js +0 -113
- package/lib/Translator.js +0 -200
- package/lib/addUrlParams.js +0 -27
- package/lib/adjustUpdatedFolders.js +0 -22
- package/lib/asyncTimeout.js +0 -6
- package/lib/audioMimeTypes.js +0 -3
- package/lib/blobToDataURI.js +0 -13
- package/lib/callIfFunction.js +0 -10
- package/lib/canEditVideo.js +0 -9
- package/lib/canvasToBlob.js +0 -18
- package/lib/capitalizeFirstLetter.js +0 -4
- package/lib/checkConnection.js +0 -4
- package/lib/checkFileOrFolderNameValidation.js +0 -4
- package/lib/checkIfPngSvgGIF.js +0 -3
- package/lib/checkImageIfPngJpegOrWebpOrAvif.js +0 -5
- package/lib/checkItemsSupportExportWithReason.js +0 -41
- package/lib/checkPermissions.js +0 -26
- package/lib/cloudimageSupportedInputMimeTypes.js +0 -2
- package/lib/clsx.js +0 -14
- package/lib/constants.js +0 -570
- package/lib/convertBytesToMb.js +0 -5
- package/lib/convertGbToBytes.js +0 -4
- package/lib/convertVideoFileTypeToSupported.js +0 -17
- package/lib/copyText.js +0 -25
- package/lib/createFolderVirtualPath.js +0 -14
- package/lib/createThunk.js +0 -349
- package/lib/customEncodeURIComponent.js +0 -47
- package/lib/dataURItoBlob.js +0 -33
- package/lib/dataURItoFile.js +0 -4
- package/lib/dateStrToClearDateTime.js +0 -20
- package/lib/debounce.js +0 -14
- package/lib/deepEqual.js +0 -23
- package/lib/deepMerge.js +0 -56
- package/lib/deserializeFunction.js +0 -5
- package/lib/documentMimeTypes.js +0 -2
- package/lib/downloadFromBlob.js +0 -16
- package/lib/emitSocketProgress.js +0 -18
- package/lib/escapeRegExp.js +0 -4
- package/lib/extractFileDataNoBlob.js +0 -12
- package/lib/fetchWithNetworkError.js +0 -14
- package/lib/fieldsQueriesGetters.js +0 -46
- package/lib/findAllDOMElements.js +0 -18
- package/lib/findAllRegexMatchesInString.js +0 -16
- package/lib/findDOMElement.js +0 -17
- package/lib/findIndex.js +0 -9
- package/lib/formatDuration.js +0 -22
- package/lib/formatNumbers.js +0 -32
- package/lib/formatResolution.js +0 -17
- package/lib/formatSeconds.js +0 -14
- package/lib/generateFileId.js +0 -53
- package/lib/generateI18nKeyFromString.js +0 -11
- package/lib/generatePsdThumbnail/adaptHexBoundries.js +0 -9
- package/lib/generatePsdThumbnail/bufferToHex.js +0 -12
- package/lib/generatePsdThumbnail/generatePsdThumbnail.js +0 -36
- package/lib/generatePsdThumbnail/generatePsdThumbnailBytes.js +0 -8
- package/lib/generatePsdThumbnail/generatePsdThumbnailHex.js +0 -4
- package/lib/generateSelectInputPlaceholder.js +0 -24
- package/lib/getActionErrorState.js +0 -17
- package/lib/getArraysMutualObjects.js +0 -12
- package/lib/getBytesRemaining.js +0 -9
- package/lib/getClientTimezone.js +0 -5
- package/lib/getCloudimagePrefixedUrl.js +0 -23
- package/lib/getDateDaysFromNow.js +0 -17
- package/lib/getDateMinusDay.js +0 -5
- package/lib/getDateString.js +0 -20
- package/lib/getDaysLeft.js +0 -9
- package/lib/getDecodedUriComponent.js +0 -10
- package/lib/getDownloadSpeed.js +0 -7
- package/lib/getDroppedFiles/index.js +0 -24
- package/lib/getDroppedFiles/utils/fallbackApi.js +0 -7
- package/lib/getDroppedFiles/utils/webkitGetAsEntryApi/getFilesAndDirectoriesFromDirectory.js +0 -36
- package/lib/getDroppedFiles/utils/webkitGetAsEntryApi/getRelativePath.js +0 -16
- package/lib/getDroppedFiles/utils/webkitGetAsEntryApi/index.js +0 -57
- package/lib/getEncodedWrappedUrl.js +0 -7
- package/lib/getFileAssetsTokenUrl.js +0 -14
- package/lib/getFileCdnLink.js +0 -6
- package/lib/getFileDefaultIcon.js +0 -14
- package/lib/getFileDetails.js +0 -81
- package/lib/getFileExtension.js +0 -32
- package/lib/getFileLink.js +0 -17
- package/lib/getFileNameAndExtension.js +0 -22
- package/lib/getFileType.js +0 -23
- package/lib/getFileTypeExtension.js +0 -22
- package/lib/getFilterFileFormatIcon.js +0 -6
- package/lib/getFolderDetails.js +0 -30
- package/lib/getFormattedPreviewUrl.js +0 -79
- package/lib/getHoursAndMinutes.js +0 -9
- package/lib/getImageEditUrl.js +0 -36
- package/lib/getImgFileDimensions.js +0 -25
- package/lib/getItemIcon.js +0 -112
- package/lib/getItemPath.js +0 -10
- package/lib/getItemPreviewWidthHeight.js +0 -10
- package/lib/getItemsSizeInBytes.js +0 -12
- package/lib/getJsonParsedValue.js +0 -11
- package/lib/getLinkWithNewParams.js +0 -13
- package/lib/getMetadataMultiSelectQuery.js +0 -66
- package/lib/getNormalizedItems.js +0 -55
- package/lib/getObjectsMutualProperties.js +0 -32
- package/lib/getRandomNumber.js +0 -12
- package/lib/getSocketHost.js +0 -7
- package/lib/getSpeed.js +0 -8
- package/lib/getTime.js +0 -18
- package/lib/getTimeStamp.js +0 -18
- package/lib/handleError.js +0 -13
- package/lib/handlePressEnter.js +0 -9
- package/lib/handlePromise.js +0 -39
- package/lib/hasProperty.js +0 -3
- package/lib/hexToRgb.js +0 -15
- package/lib/htmlSanitizer.js +0 -6
- package/lib/humanReadableDate.js +0 -45
- package/lib/humanReadableDateWithTranslations.js +0 -29
- package/lib/i18n.client.js +0 -54
- package/lib/ignoreEvent.js +0 -10
- package/lib/index.js +0 -0
- package/lib/injectVirtualPathToFolders.js +0 -24
- package/lib/isAi.js +0 -7
- package/lib/isArchive.js +0 -12
- package/lib/isAudio.js +0 -9
- package/lib/isAudioAndSupportsPlayback.js +0 -10
- package/lib/isCloudimageFastPreviewSupported.js +0 -16
- package/lib/isDOMElement.js +0 -9
- package/lib/isDocument.js +0 -10
- package/lib/isDragDropSupported.js +0 -20
- package/lib/isEmptyObject.js +0 -4
- package/lib/isEps.js +0 -8
- package/lib/isFile.js +0 -5
- package/lib/isFileSupportedByCloudimage.js +0 -14
- package/lib/isFolder.js +0 -4
- package/lib/isFontFile.js +0 -9
- package/lib/isFunction.js +0 -4
- package/lib/isImage.js +0 -11
- package/lib/isJpg.js +0 -8
- package/lib/isMobileDevice.js +0 -12
- package/lib/isNetworkError.js +0 -7
- package/lib/isNumber.js +0 -4
- package/lib/isObjectType.js +0 -5
- package/lib/isObjectURL.js +0 -10
- package/lib/isOpenedFromAdobe.js +0 -3
- package/lib/isOtf.js +0 -10
- package/lib/isPdf.js +0 -9
- package/lib/isPhotoshopFile.js +0 -8
- package/lib/isPreviewSupported.js +0 -12
- package/lib/isPromise.js +0 -5
- package/lib/metadata/checkFieldValidation.js +0 -51
- package/lib/metadata/generateItemMetadataState.js +0 -63
- package/lib/metadata/generateMetadataDefaultState.js +0 -30
- package/lib/metadata/getFileCustomMetadataGroups.js +0 -23
- package/lib/metadata/getGeoPointValidationErrors.js +0 -32
- package/lib/metadata/getMetaAttachmentFields.js +0 -9
- package/lib/metadata/getMetadataEmptyAssets.js +0 -28
- package/lib/metadata/getMetadataFieldGeoPointValue.js +0 -42
- package/lib/metadata/getMetadataFieldVariantValue.js +0 -31
- package/lib/metadata/getMetadataGroups.js +0 -16
- package/lib/metadata/getRequiredMetadataFields.js +0 -13
- package/lib/metadata/isM0LegacyMetaVersion.js +0 -5
- package/lib/metadata/isM1EdgyMetaVersion.js +0 -5
- package/lib/metadata/mapMetaAttachmentsObjsToUuids.js +0 -21
- package/lib/metadata/updateValidationErrors.js +0 -59
- package/lib/metadata/validateItemMetadata.js +0 -70
- package/lib/styledComponentsMixins/truncate.mixin.js +0 -8
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { LAYOUTS_IDS } from './constants';
|
|
2
|
-
var getItemPreviewWidthAndHeight = function getItemPreviewWidthAndHeight(viewLayout) {
|
|
3
|
-
var isListView = viewLayout === LAYOUTS_IDS.LIST;
|
|
4
|
-
var baseWidth = isListView ? 100 : 200;
|
|
5
|
-
var baseHeight = isListView ? 70 : 150;
|
|
6
|
-
var width = parseInt(baseWidth * devicePixelRatio);
|
|
7
|
-
var height = parseInt(baseHeight * devicePixelRatio);
|
|
8
|
-
return [width, height];
|
|
9
|
-
};
|
|
10
|
-
export default getItemPreviewWidthAndHeight;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
-
var getItemsSizeInBytes = function getItemsSizeInBytes() {
|
|
3
|
-
var items = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
4
|
-
return items.reduce(function (totalItemsSize) {
|
|
5
|
-
var _currentItem$size, _currentItem$size2;
|
|
6
|
-
var currentItem = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
7
|
-
var itemSize = ((_currentItem$size = currentItem.size) === null || _currentItem$size === void 0 ? void 0 : _currentItem$size.total_recursive_bytes) || ((_currentItem$size2 = currentItem.size) === null || _currentItem$size2 === void 0 ? void 0 : _currentItem$size2.bytes) || currentItem.total_recursive_bytes || _typeof(currentItem.size) !== 'object' && currentItem.size || 0;
|
|
8
|
-
totalItemsSize += Number(itemSize);
|
|
9
|
-
return totalItemsSize;
|
|
10
|
-
}, 0);
|
|
11
|
-
};
|
|
12
|
-
export default getItemsSizeInBytes;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
// if the value is a possible (JSON string) then we need to parse it to JS object, if not and it's a real string or other type then return it.
|
|
2
|
-
var getJsonParsedValue = function getJsonParsedValue(value) {
|
|
3
|
-
var parsedValue = value;
|
|
4
|
-
if (typeof parsedValue === 'string') {
|
|
5
|
-
try {
|
|
6
|
-
parsedValue = JSON.parse(parsedValue);
|
|
7
|
-
} catch (e) {}
|
|
8
|
-
}
|
|
9
|
-
return parsedValue;
|
|
10
|
-
};
|
|
11
|
-
export default getJsonParsedValue;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export default (function (link, imageParams) {
|
|
2
|
-
var separator = link !== null && link !== void 0 && link.includes('?') ? '&' : '?';
|
|
3
|
-
var params = Object.keys(imageParams).filter(function (key) {
|
|
4
|
-
return imageParams[key] !== 'auto';
|
|
5
|
-
}).filter(function (key) {
|
|
6
|
-
return imageParams[key];
|
|
7
|
-
}).map(function (key) {
|
|
8
|
-
return "".concat(key, "=").concat(imageParams[key]);
|
|
9
|
-
}).join('&');
|
|
10
|
-
return Object.keys(imageParams).some(function (key) {
|
|
11
|
-
return imageParams[key] && imageParams[key] !== 'auto';
|
|
12
|
-
}) ? "".concat(link).concat(separator).concat(params) : link;
|
|
13
|
-
});
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { isStaticSelectOption } from '@scaleflex/widget-explorer/lib/utils/filters';
|
|
2
|
-
import { FILTER_CONDITIONS } from './constants';
|
|
3
|
-
import { getFieldValueQuery } from './fieldsQueriesGetters';
|
|
4
|
-
var createStaticValueIsQuery = function createStaticValueIsQuery(key, value) {
|
|
5
|
-
return "".concat(key, ":").concat(value.join(','));
|
|
6
|
-
};
|
|
7
|
-
var createIsQuery = function createIsQuery(key, value) {
|
|
8
|
-
if (isStaticSelectOption(value)) {
|
|
9
|
-
return createStaticValueIsQuery(key, value);
|
|
10
|
-
}
|
|
11
|
-
return "".concat(key, ":=").concat(value.join(','));
|
|
12
|
-
};
|
|
13
|
-
var createIsNotQuery = function createIsNotQuery(key, value) {
|
|
14
|
-
return value.map(function (item) {
|
|
15
|
-
return "".concat(key, ":-").concat(item);
|
|
16
|
-
}).join(' ');
|
|
17
|
-
};
|
|
18
|
-
var createContainsQuery = function createContainsQuery(metadataFilter, value) {
|
|
19
|
-
return getFieldValueQuery(metadataFilter, value);
|
|
20
|
-
};
|
|
21
|
-
var createContainsNotQuery = function createContainsNotQuery(_ref) {
|
|
22
|
-
var metadataFilter = _ref.metadataFilter,
|
|
23
|
-
key = _ref.key,
|
|
24
|
-
value = _ref.value,
|
|
25
|
-
extraValue = _ref.extraValue;
|
|
26
|
-
var valueQuery = getFieldValueQuery(metadataFilter, value);
|
|
27
|
-
var extraValueQuery = extraValue.map(function (item) {
|
|
28
|
-
return "".concat(key, ":-").concat(item);
|
|
29
|
-
}).join(' ');
|
|
30
|
-
return "".concat(valueQuery, " ").concat(extraValueQuery).trim();
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Generates a multi-select field query based on the metadata filter.
|
|
35
|
-
* Docs: https://scaleflexhq.atlassian.net/wiki/spaces/FIL/pages/466452497
|
|
36
|
-
*
|
|
37
|
-
* @param {Object} metadataFilter - The metadata filter object.
|
|
38
|
-
* @returns {string} - The resulting query string.
|
|
39
|
-
*/
|
|
40
|
-
|
|
41
|
-
export var getMetadataMultiSelectQuery = function getMetadataMultiSelectQuery(metadataFilter) {
|
|
42
|
-
var key = metadataFilter.key,
|
|
43
|
-
_metadataFilter$value = metadataFilter.value,
|
|
44
|
-
value = _metadataFilter$value === void 0 ? [] : _metadataFilter$value,
|
|
45
|
-
_metadataFilter$condi = metadataFilter.condition,
|
|
46
|
-
condition = _metadataFilter$condi === void 0 ? FILTER_CONDITIONS.IS : _metadataFilter$condi,
|
|
47
|
-
_metadataFilter$extra = metadataFilter.extraValue,
|
|
48
|
-
extraValue = _metadataFilter$extra === void 0 ? [] : _metadataFilter$extra;
|
|
49
|
-
switch (condition) {
|
|
50
|
-
case FILTER_CONDITIONS.IS:
|
|
51
|
-
return createIsQuery(key, value);
|
|
52
|
-
case FILTER_CONDITIONS.IS_NOT:
|
|
53
|
-
return createIsNotQuery(key, value);
|
|
54
|
-
case FILTER_CONDITIONS.CONTAINS:
|
|
55
|
-
return createContainsQuery(metadataFilter, value.join(','));
|
|
56
|
-
case FILTER_CONDITIONS.CONTAINS_NOT:
|
|
57
|
-
return createContainsNotQuery({
|
|
58
|
-
metadataFilter: metadataFilter,
|
|
59
|
-
key: key,
|
|
60
|
-
value: value.join(','),
|
|
61
|
-
extraValue: extraValue
|
|
62
|
-
});
|
|
63
|
-
default:
|
|
64
|
-
return '';
|
|
65
|
-
}
|
|
66
|
-
};
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
-
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
5
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
6
|
-
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
7
|
-
/**
|
|
8
|
-
* Retrieves the value of a nested property from an object using a string key.
|
|
9
|
-
*
|
|
10
|
-
* @param {string} key - The string key representing the nested property.
|
|
11
|
-
* @param {object} item - The object from which to retrieve the nested property.
|
|
12
|
-
* @return {*} - The value of the nested property.
|
|
13
|
-
*/
|
|
14
|
-
export var getItemKey = function getItemKey(key, item) {
|
|
15
|
-
if (key.includes('.')) {
|
|
16
|
-
var properties = key.split('.');
|
|
17
|
-
return properties.reduce(function (property, prop) {
|
|
18
|
-
return property[prop];
|
|
19
|
-
}, item);
|
|
20
|
-
} else {
|
|
21
|
-
return item[key];
|
|
22
|
-
}
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Generates a normalized version of the given items array.
|
|
27
|
-
*
|
|
28
|
-
* @param {Array} items - The array of items to be normalized.
|
|
29
|
-
* @param {Object} options - options for the function, consists of the following.
|
|
30
|
-
* @param {Object} extraProps - (optional) Additional properties to add to each normalized item.
|
|
31
|
-
* @param {string} key - (optional) The key to use as the unique identifier for each item.
|
|
32
|
-
* @param {string} returnedKey - (optional) the key used in the function's returned's object.
|
|
33
|
-
* @return {Object} An object containing the normalized slices and an array of UUIDs.
|
|
34
|
-
*/
|
|
35
|
-
var getNormalizedItems = function getNormalizedItems(items, options) {
|
|
36
|
-
var _ref = options || {},
|
|
37
|
-
_ref$extraProps = _ref.extraProps,
|
|
38
|
-
extraProps = _ref$extraProps === void 0 ? {} : _ref$extraProps,
|
|
39
|
-
_ref$key = _ref.key,
|
|
40
|
-
key = _ref$key === void 0 ? 'uuid' : _ref$key,
|
|
41
|
-
_ref$returnedKey = _ref.returnedKey,
|
|
42
|
-
returnedKey = _ref$returnedKey === void 0 ? 'uuids' : _ref$returnedKey;
|
|
43
|
-
var normalizedSlices = {};
|
|
44
|
-
var normalizedItemsUuids = [];
|
|
45
|
-
items.forEach(function (item) {
|
|
46
|
-
var itemKey = getItemKey(key, item);
|
|
47
|
-
var normalizedItem = _objectSpread(_objectSpread({}, item), extraProps);
|
|
48
|
-
normalizedSlices[itemKey] = normalizedItem;
|
|
49
|
-
normalizedItemsUuids.push(itemKey);
|
|
50
|
-
});
|
|
51
|
-
return _defineProperty({
|
|
52
|
-
normalizedSlices: normalizedSlices
|
|
53
|
-
}, returnedKey, normalizedItemsUuids);
|
|
54
|
-
};
|
|
55
|
-
export default getNormalizedItems;
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
-
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
3
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
4
|
-
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
5
|
-
function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
|
|
6
|
-
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
7
|
-
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
8
|
-
function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
|
|
9
|
-
function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
|
|
10
|
-
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
11
|
-
var _getObjectsMutualProperties = function getObjectsMutualProperties() {
|
|
12
|
-
var arrayOfObjects = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [{}];
|
|
13
|
-
return Array.isArray(arrayOfObjects) && (arrayOfObjects.length > 1 ? arrayOfObjects.reduce(function (prevObj, currObj) {
|
|
14
|
-
var commonObj = {};
|
|
15
|
-
Object.keys(prevObj).forEach(function (key) {
|
|
16
|
-
if (prevObj[key] && currObj[key]) {
|
|
17
|
-
if (prevObj[key] === currObj[key]) {
|
|
18
|
-
commonObj[key] = prevObj[key];
|
|
19
|
-
} else if (Array.isArray(prevObj[key]) && Array.isArray(currObj[key])) {
|
|
20
|
-
var mutualProps = _getObjectsMutualProperties([].concat(_toConsumableArray(prevObj[key]), _toConsumableArray(currObj[key])));
|
|
21
|
-
commonObj[key] = Object.keys(mutualProps).map(function (key) {
|
|
22
|
-
return _defineProperty({}, key, mutualProps[key]);
|
|
23
|
-
});
|
|
24
|
-
} else if (_typeof(prevObj[key]) === 'object' && _typeof(currObj[key]) === 'object') {
|
|
25
|
-
commonObj[key] = _getObjectsMutualProperties([prevObj[key], currObj[key]]);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
return commonObj;
|
|
30
|
-
}) : arrayOfObjects[0] || {});
|
|
31
|
-
};
|
|
32
|
-
export default _getObjectsMutualProperties;
|
package/lib/getRandomNumber.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @returns {number} -- random number between min and max
|
|
3
|
-
*
|
|
4
|
-
* @param {number} min -- minimum number
|
|
5
|
-
* @param {number} max -- maximum number
|
|
6
|
-
*/
|
|
7
|
-
var getRandomNumber = function getRandomNumber(min, max) {
|
|
8
|
-
min = Math.ceil(min);
|
|
9
|
-
max = Math.floor(max);
|
|
10
|
-
return Math.floor(Math.random() * (max - min) + min);
|
|
11
|
-
};
|
|
12
|
-
export default getRandomNumber;
|
package/lib/getSocketHost.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export default function getSocketHost(url) {
|
|
2
|
-
// get the host domain
|
|
3
|
-
var regex = /^(?:https?:\/\/|\/\/)?(?:[^@\n]+@)?(?:www\.)?([^\n]+)/i;
|
|
4
|
-
var host = regex.exec(url)[1];
|
|
5
|
-
var socketProtocol = /^http:\/\//i.test(url) ? 'ws' : 'wss';
|
|
6
|
-
return "".concat(socketProtocol, "://").concat(host);
|
|
7
|
-
}
|
package/lib/getSpeed.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export default function getSpeed() {
|
|
2
|
-
var fileProgress = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
3
|
-
var totalFinished = fileProgress.bytesFinished || fileProgress.percentage;
|
|
4
|
-
var endTime = new Date().getTime();
|
|
5
|
-
var timeDuration = (endTime - fileProgress.startedAt) / 1000;
|
|
6
|
-
var uploadSpeedInBps = totalFinished / timeDuration;
|
|
7
|
-
return uploadSpeedInBps;
|
|
8
|
-
}
|
package/lib/getTime.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Returns a timestamp in the format of `hours:minutes Am or PM`
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
export default function getTime() {
|
|
6
|
-
var showAmPm = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
7
|
-
var i18n = arguments.length > 1 ? arguments[1] : undefined;
|
|
8
|
-
var date = new Date();
|
|
9
|
-
var hours = date.getHours();
|
|
10
|
-
var minutes = date.getMinutes();
|
|
11
|
-
var ampm = hours >= 12 ? (i18n === null || i18n === void 0 ? void 0 : i18n('mutualizedTimePeriodPm')) || 'PM' : (i18n === null || i18n === void 0 ? void 0 : i18n('mutualizedTimePeriodAm')) || 'AM';
|
|
12
|
-
hours = hours % 12;
|
|
13
|
-
hours = hours || 12; // the hour '0' should be '12'
|
|
14
|
-
hours = hours < 10 ? '0' + hours : hours;
|
|
15
|
-
minutes = minutes < 10 ? '0' + minutes : minutes;
|
|
16
|
-
var strTime = hours + ':' + minutes + (showAmPm ? ' ' + ampm : '');
|
|
17
|
-
return strTime;
|
|
18
|
-
}
|
package/lib/getTimeStamp.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Returns a timestamp in the format of `hours:minutes:seconds`
|
|
3
|
-
*/
|
|
4
|
-
export default function getTimeStamp() {
|
|
5
|
-
var noSeconds = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
6
|
-
var date = new Date();
|
|
7
|
-
var hours = pad(date.getHours().toString());
|
|
8
|
-
var minutes = pad(date.getMinutes().toString());
|
|
9
|
-
var seconds = pad(date.getSeconds().toString());
|
|
10
|
-
return hours + ':' + minutes + (noSeconds ? ':' + seconds : '');
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Adds zero to strings shorter than two characters
|
|
15
|
-
*/
|
|
16
|
-
function pad(str) {
|
|
17
|
-
return str.length !== 2 ? 0 + str : str;
|
|
18
|
-
}
|
package/lib/handleError.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
var handleError = function handleError(error, infoFn) {
|
|
2
|
-
var _ref;
|
|
3
|
-
if (!error || !infoFn) {
|
|
4
|
-
return;
|
|
5
|
-
}
|
|
6
|
-
var message = error.message,
|
|
7
|
-
details = error.details;
|
|
8
|
-
infoFn({
|
|
9
|
-
message: (_ref = message !== null && message !== void 0 ? message : error.status) !== null && _ref !== void 0 ? _ref : error.toString(),
|
|
10
|
-
details: details
|
|
11
|
-
}, 'error', 5000);
|
|
12
|
-
};
|
|
13
|
-
export default handleError;
|
package/lib/handlePressEnter.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
var handlePressEnter = function handlePressEnter() {
|
|
2
|
-
var event = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
3
|
-
var callback = arguments.length > 1 ? arguments[1] : undefined;
|
|
4
|
-
if ((event.key === 'Enter' || event.keyCode === 13) && typeof callback === 'function') {
|
|
5
|
-
event.preventDefault();
|
|
6
|
-
callback();
|
|
7
|
-
}
|
|
8
|
-
};
|
|
9
|
-
export default handlePressEnter;
|
package/lib/handlePromise.js
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
2
|
-
import isPromise from './isPromise';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Wraps the promise passed with try/catch block and fires the callback provided depending on success/failture.
|
|
6
|
-
*
|
|
7
|
-
* @param (promise: promise) - promise to be processed
|
|
8
|
-
* @param (successCallback: function) - callback function to be implemented incase of success
|
|
9
|
-
* @param (errorCallback: function) - callback function to be implemented incase of error caught
|
|
10
|
-
- assuming default clbk function would be info(error: error instance, type: error, timeout: 5000)
|
|
11
|
-
* @param (finishCallback: function) - callback function to be implemented after finishing in both cases success/fail.
|
|
12
|
-
*/
|
|
13
|
-
var handlePromise = function handlePromise(promise) {
|
|
14
|
-
var successCallback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function () {
|
|
15
|
-
return null;
|
|
16
|
-
};
|
|
17
|
-
var errorCallback = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : function () {
|
|
18
|
-
return null;
|
|
19
|
-
};
|
|
20
|
-
var finishCallback = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : function () {
|
|
21
|
-
return null;
|
|
22
|
-
};
|
|
23
|
-
if (isPromise(promise)) {
|
|
24
|
-
// To throw the rejection of the promise to be able to use (.catch)
|
|
25
|
-
if (typeof promise.throwRejection === 'function') {
|
|
26
|
-
promise.throwRejection();
|
|
27
|
-
}
|
|
28
|
-
var newPromise = promise.then(successCallback)["catch"](function (error) {
|
|
29
|
-
if (typeof errorCallback === 'function') {
|
|
30
|
-
errorCallback(error, 'error', 5000);
|
|
31
|
-
}
|
|
32
|
-
})["finally"](finishCallback);
|
|
33
|
-
|
|
34
|
-
// To copy the properties of the original promise eg. if it's thunk function we will have (abort, requestId...etc.)
|
|
35
|
-
_extends(newPromise, promise);
|
|
36
|
-
return newPromise;
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
export default handlePromise;
|
package/lib/hasProperty.js
DELETED
package/lib/hexToRgb.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
// Imported from https://stackoverflow.com/questions/5623838/rgb-to-hex-and-hex-to-rgb
|
|
2
|
-
var hexToRgb = function hexToRgb(hex) {
|
|
3
|
-
// Expand shorthand form (e.g. "03F") to full form (e.g. "0033FF")
|
|
4
|
-
var shorthandRegex = /^#?([a-f\d])([a-f\d])([a-f\d])$/i;
|
|
5
|
-
hex = hex.replace(shorthandRegex, function (m, r, g, b) {
|
|
6
|
-
return r + r + g + g + b + b;
|
|
7
|
-
});
|
|
8
|
-
var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
|
|
9
|
-
return result ? {
|
|
10
|
-
r: parseInt(result[1], 16),
|
|
11
|
-
g: parseInt(result[2], 16),
|
|
12
|
-
b: parseInt(result[3], 16)
|
|
13
|
-
} : {};
|
|
14
|
-
};
|
|
15
|
-
export default hexToRgb;
|
package/lib/htmlSanitizer.js
DELETED
package/lib/humanReadableDate.js
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
-
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
5
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
6
|
-
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
7
|
-
/**
|
|
8
|
-
* @param {Date} date
|
|
9
|
-
* @param {object} [translations] - Object with translations. Notice: it's used for Hub.
|
|
10
|
-
* @returns {string} - For example: "18 hours ago"
|
|
11
|
-
*/
|
|
12
|
-
var humanReadableDate = function humanReadableDate(date, translationsList) {
|
|
13
|
-
var translations = _objectSpread({
|
|
14
|
-
ago: 'ago',
|
|
15
|
-
second: 'second',
|
|
16
|
-
seconds: 'seconds',
|
|
17
|
-
minute: 'minute',
|
|
18
|
-
minutes: 'minutes',
|
|
19
|
-
hour: 'hour',
|
|
20
|
-
hours: 'hours',
|
|
21
|
-
day: 'day',
|
|
22
|
-
days: 'days',
|
|
23
|
-
month: 'month',
|
|
24
|
-
months: 'months',
|
|
25
|
-
year: 'year',
|
|
26
|
-
years: 'years'
|
|
27
|
-
}, translationsList || {});
|
|
28
|
-
var timeAgo = function timeAgo(interval, periodMultiple, periodSingle) {
|
|
29
|
-
return "".concat(Math.floor(interval), " ").concat(Math.floor(interval) > 1 ? periodMultiple : periodSingle, " ").concat(translations.ago);
|
|
30
|
-
};
|
|
31
|
-
var seconds = Math.floor((new Date() - new Date(date)) / 1000);
|
|
32
|
-
var interval = seconds / 31536000;
|
|
33
|
-
if (interval > 1) return timeAgo(interval, translations.years, translations.year);
|
|
34
|
-
interval = seconds / 2592000;
|
|
35
|
-
if (interval > 1) return timeAgo(interval, translations.months, translations.month);
|
|
36
|
-
interval = seconds / 86400;
|
|
37
|
-
if (interval > 1) return timeAgo(interval, translations.days, translations.day);
|
|
38
|
-
interval = seconds / 3600;
|
|
39
|
-
if (interval > 1) return timeAgo(interval, translations.hours, translations.hour);
|
|
40
|
-
interval = seconds / 60;
|
|
41
|
-
if (interval > 1) return timeAgo(interval, translations.minutes, translations.minute);
|
|
42
|
-
interval = seconds;
|
|
43
|
-
return timeAgo(interval, translations.seconds, translations.second);
|
|
44
|
-
};
|
|
45
|
-
export default humanReadableDate;
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import capitalizeFirstLetter from './capitalizeFirstLetter';
|
|
2
|
-
import humanReadableDate from './humanReadableDate';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Wrapper over function humanReadableDate but with translations
|
|
6
|
-
*/
|
|
7
|
-
var humanReadableDateWithTranslations = function humanReadableDateWithTranslations(date, i18n) {
|
|
8
|
-
var t = function t(str) {
|
|
9
|
-
return i18n("timeAgo".concat(str.split(' ').filter(Boolean).map(function (item) {
|
|
10
|
-
return capitalizeFirstLetter(item.trim());
|
|
11
|
-
}).join('')), str) || str;
|
|
12
|
-
};
|
|
13
|
-
return humanReadableDate(date, {
|
|
14
|
-
ago: t('ago'),
|
|
15
|
-
second: t('second'),
|
|
16
|
-
seconds: t('seconds'),
|
|
17
|
-
minute: t('minute'),
|
|
18
|
-
minutes: t('minutes'),
|
|
19
|
-
hour: t('hour'),
|
|
20
|
-
hours: t('hours'),
|
|
21
|
-
day: t('day'),
|
|
22
|
-
days: t('days'),
|
|
23
|
-
month: t('month'),
|
|
24
|
-
months: t('months'),
|
|
25
|
-
year: t('year'),
|
|
26
|
-
years: t('years')
|
|
27
|
-
});
|
|
28
|
-
};
|
|
29
|
-
export default humanReadableDateWithTranslations;
|
package/lib/i18n.client.js
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import RequestError from '@scaleflex/widget-utils/lib/RequestError';
|
|
2
|
-
import { I18N_GRID_UUID, I18N_PROD_BASE_URL } from '@scaleflex/widget-utils/lib/constants';
|
|
3
|
-
var hardcodedErrorMsg = 'Error while loading languages.';
|
|
4
|
-
export var getBackendTranslations = function getBackendTranslations(_ref) {
|
|
5
|
-
var i18nFetchApiEndpoint = _ref.i18nFetchApiEndpoint;
|
|
6
|
-
return new Promise(function (resolve, reject) {
|
|
7
|
-
var xhr = new XMLHttpRequest();
|
|
8
|
-
xhr.responseType = 'json';
|
|
9
|
-
xhr.onload = function () {
|
|
10
|
-
if (xhr.status >= 200 && xhr.status < 300) {
|
|
11
|
-
resolve(xhr.response);
|
|
12
|
-
} else {
|
|
13
|
-
var _xhr$response, _xhr$response2, _xhr$response3, _xhr$response4;
|
|
14
|
-
reject(new RequestError({
|
|
15
|
-
code: xhr.status,
|
|
16
|
-
message: ((_xhr$response = xhr.response) === null || _xhr$response === void 0 ? void 0 : _xhr$response.msg) || "Error code ".concat(xhr.status),
|
|
17
|
-
details: ((_xhr$response2 = xhr.response) === null || _xhr$response2 === void 0 ? void 0 : _xhr$response2.hint) || ((_xhr$response3 = xhr.response) === null || _xhr$response3 === void 0 ? void 0 : _xhr$response3.msg) || ((_xhr$response4 = xhr.response) === null || _xhr$response4 === void 0 ? void 0 : _xhr$response4.detail) || hardcodedErrorMsg
|
|
18
|
-
}));
|
|
19
|
-
}
|
|
20
|
-
};
|
|
21
|
-
xhr.onerror = function () {
|
|
22
|
-
reject(new RequestError({
|
|
23
|
-
code: xhr.status,
|
|
24
|
-
message: hardcodedErrorMsg
|
|
25
|
-
}));
|
|
26
|
-
};
|
|
27
|
-
xhr.open('GET', "".concat(i18nFetchApiEndpoint, "/export?grid=").concat(I18N_GRID_UUID));
|
|
28
|
-
xhr.send();
|
|
29
|
-
});
|
|
30
|
-
};
|
|
31
|
-
export var sendMissingTranslationToBackend = function sendMissingTranslationToBackend(missingTranslation) {
|
|
32
|
-
return new Promise(function (resolve, reject) {
|
|
33
|
-
var xhr = new XMLHttpRequest();
|
|
34
|
-
xhr.responseType = 'json';
|
|
35
|
-
xhr.onload = function () {
|
|
36
|
-
if (xhr.status >= 200 && xhr.status < 300) {
|
|
37
|
-
resolve(xhr.response);
|
|
38
|
-
} else {
|
|
39
|
-
var _xhr$response5;
|
|
40
|
-
console.warn("Error in sending translation key to backend ".concat((_xhr$response5 = xhr.response) === null || _xhr$response5 === void 0 ? void 0 : _xhr$response5.hint, ", ").concat(xhr.status));
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
xhr.onerror = function () {
|
|
44
|
-
var _xhr$response6;
|
|
45
|
-
console.warn("Error in sending translation key to backend ".concat((_xhr$response6 = xhr.response) === null || _xhr$response6 === void 0 ? void 0 : _xhr$response6.hint, ", ").concat(xhr.status));
|
|
46
|
-
};
|
|
47
|
-
var payload = {
|
|
48
|
-
grid_uuid: I18N_GRID_UUID,
|
|
49
|
-
translations_requests: [missingTranslation]
|
|
50
|
-
};
|
|
51
|
-
xhr.open('POST', "".concat(I18N_PROD_BASE_URL, "/api/import/request-translations?grid_uuid=").concat(I18N_GRID_UUID));
|
|
52
|
-
xhr.send(JSON.stringify(payload));
|
|
53
|
-
});
|
|
54
|
-
};
|
package/lib/ignoreEvent.js
DELETED
package/lib/index.js
DELETED
|
File without changes
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import createFoldervirtualPath from './createFolderVirtualPath';
|
|
2
|
-
import removeEmptyFolders from './removeEmptyFolders';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Util used to add vitual pathes to folders
|
|
6
|
-
* @property { _folders } array
|
|
7
|
-
* @property { parentPath } string
|
|
8
|
-
* @returns { folderWithPath }
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
var _injectVirtualPathToFolders = function injectVirtualPathToFolders() {
|
|
12
|
-
var _folders = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
13
|
-
var parentPath = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
14
|
-
return _folders.map(function (folder) {
|
|
15
|
-
var folderWithPath = createFoldervirtualPath(folder, parentPath);
|
|
16
|
-
var subFolders = folder.folders;
|
|
17
|
-
if (subFolders) {
|
|
18
|
-
var nonEmptySubFolders = removeEmptyFolders(subFolders);
|
|
19
|
-
folderWithPath.folders = _injectVirtualPathToFolders(nonEmptySubFolders, folderWithPath.path);
|
|
20
|
-
}
|
|
21
|
-
return folderWithPath;
|
|
22
|
-
});
|
|
23
|
-
};
|
|
24
|
-
export default _injectVirtualPathToFolders;
|
package/lib/isAi.js
DELETED
package/lib/isArchive.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import getFileExtension from './getFileExtension';
|
|
2
|
-
export default function isArchive() {
|
|
3
|
-
var file = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
4
|
-
if (!file) {
|
|
5
|
-
return false;
|
|
6
|
-
}
|
|
7
|
-
var ArchiveExtensions = ['zip', 'tar', 'rar', 'gz', '7z'];
|
|
8
|
-
var fileType = getFileExtension(file).toLowerCase();
|
|
9
|
-
return ArchiveExtensions.some(function (ext) {
|
|
10
|
-
return fileType.includes(ext);
|
|
11
|
-
});
|
|
12
|
-
}
|
package/lib/isAudio.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import getFileType from './getFileType';
|
|
2
|
-
import AudioMimeTypes from './audioMimeTypes';
|
|
3
|
-
export default function isAudio(file) {
|
|
4
|
-
if (!file) {
|
|
5
|
-
return false;
|
|
6
|
-
}
|
|
7
|
-
var fileType = getFileType(file).toLowerCase();
|
|
8
|
-
return AudioMimeTypes.includes(fileType);
|
|
9
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { SUPPORTED_AUDIO_PLAYBACK_MMIE_TYPE } from './constants';
|
|
2
|
-
import getFileType from './getFileType';
|
|
3
|
-
import isAudio from './isAudio';
|
|
4
|
-
export default function isAudioAndSupportsPlayback(file) {
|
|
5
|
-
if (!file || !isAudio(file)) {
|
|
6
|
-
return false;
|
|
7
|
-
}
|
|
8
|
-
var fileType = getFileType(file).toLowerCase();
|
|
9
|
-
return SUPPORTED_AUDIO_PLAYBACK_MMIE_TYPE.includes(fileType);
|
|
10
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { BYTES_TO_MEGA_BYTES, LARGE_FILE_SIZE_IN_MB } from './constants';
|
|
2
|
-
import isAi from './isAi';
|
|
3
|
-
import isEps from './isEps';
|
|
4
|
-
import isJpg from './isJpg';
|
|
5
|
-
import isTiff from './isTiff';
|
|
6
|
-
export default function isCloudimageFastPreviewSupported(file) {
|
|
7
|
-
if (!file) return false;
|
|
8
|
-
var _ref = (file === null || file === void 0 ? void 0 : file.size) || {},
|
|
9
|
-
_ref$bytes = _ref.bytes,
|
|
10
|
-
bytes = _ref$bytes === void 0 ? 1 : _ref$bytes;
|
|
11
|
-
var isLargeJpgFile = bytes / BYTES_TO_MEGA_BYTES > LARGE_FILE_SIZE_IN_MB && isJpg(file);
|
|
12
|
-
if (isTiff(file) || isAi(file) || isEps(file) || isLargeJpgFile) {
|
|
13
|
-
return true;
|
|
14
|
-
}
|
|
15
|
-
return false;
|
|
16
|
-
}
|
package/lib/isDOMElement.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
-
/**
|
|
3
|
-
* Check if an object is a DOM element. Duck-typing based on `nodeType`.
|
|
4
|
-
*
|
|
5
|
-
* @param {*} obj
|
|
6
|
-
*/
|
|
7
|
-
export default function isDOMElement(obj) {
|
|
8
|
-
return obj && _typeof(obj) === 'object' && obj.nodeType === Node.ELEMENT_NODE;
|
|
9
|
-
}
|
package/lib/isDocument.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import DocumentMimeTypes from './documentMimeTypes';
|
|
2
|
-
import getFileType from './getFileType';
|
|
3
|
-
export default function isDocument() {
|
|
4
|
-
var file = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
5
|
-
if (!file) {
|
|
6
|
-
return false;
|
|
7
|
-
}
|
|
8
|
-
var fileType = getFileType(file).toLowerCase();
|
|
9
|
-
return DocumentMimeTypes.includes(fileType);
|
|
10
|
-
}
|