@filerobot/utils
Advanced tools
Comparing version 0.0.0-beta.27 to 0.0.0-beta.31
@@ -7,3 +7,3 @@ function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); } | ||
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } | ||
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } | ||
@@ -10,0 +10,0 @@ function _isNativeFunction(fn) { return Function.toString.call(fn).indexOf("[native code]") !== -1; } |
import { VisibilityIcon, CodeIcon, TagsIcon, MetaIcon, DetailsIcon, CommentsIcon, HistoryIcon, BranchesIcon, SimilarityIcon, LinkIcon, ShareFolderIcon, ShareAssetsIcon, CommentsSolidIcon } from '@filerobot/icons'; | ||
import getFileLink from '@filerobot/utils/lib/getFileLink'; | ||
import copyText from '@filerobot/utils/lib/copyText'; | ||
import isImage from '../lib/isImage'; | ||
var FILE_TYPES_AND_ICONS = { | ||
@@ -149,2 +150,8 @@ _default: 'https://image.flaticon.com/icons/png/128/136/136549.png', | ||
}; | ||
var hideItem = function hideItem(_ref) { | ||
var currentSelection = _ref.currentSelection; | ||
return !isImage(currentSelection[0]); | ||
}; | ||
var FILECARD_TABS_OBJECTS = { | ||
@@ -155,3 +162,3 @@ DETAILS: { | ||
}, | ||
METADATA: { | ||
META: { | ||
i18nStr: 'fileCardSubTabMeta', | ||
@@ -178,11 +185,14 @@ icon: MetaIcon | ||
i18nStr: 'fileCardTabVariants', | ||
icon: BranchesIcon | ||
icon: BranchesIcon, | ||
hideItem: hideItem | ||
}, | ||
SIMILAR: { | ||
i18nStr: 'fileCardTabSimilar', | ||
icon: SimilarityIcon | ||
icon: SimilarityIcon, | ||
hideItem: hideItem | ||
}, | ||
COMMENTS: { | ||
i18nStr: 'fileCardTabComments', | ||
icon: CommentsIcon | ||
icon: CommentsIcon, | ||
hideItem: hideItem | ||
} | ||
@@ -194,5 +204,5 @@ }; | ||
icon: ShareAssetsIcon, | ||
onClick: function onClick(_ref) { | ||
var currentSelection = _ref.currentSelection, | ||
toggleShare = _ref.toggleShare; | ||
onClick: function onClick(_ref2) { | ||
var currentSelection = _ref2.currentSelection, | ||
toggleShare = _ref2.toggleShare; | ||
toggleShare(currentSelection); | ||
@@ -208,6 +218,6 @@ } | ||
icon: LinkIcon, | ||
onClick: function onClick(_ref2) { | ||
var currentSelection = _ref2.currentSelection, | ||
i18n = _ref2.i18n, | ||
info = _ref2.info; | ||
onClick: function onClick(_ref3) { | ||
var currentSelection = _ref3.currentSelection, | ||
i18n = _ref3.i18n, | ||
info = _ref3.info; | ||
var fileLink = getFileLink(currentSelection[0]); | ||
@@ -214,0 +224,0 @@ copyText(fileLink, i18n, info); |
import getFileNameAndExtension from './getFileNameAndExtension'; | ||
import mimeTypes from './mimeTypes'; | ||
import mimeTypes from './mimeTypes'; // if type is set in the file object already, use that | ||
// otherwise extract it from the file name (not the best) | ||
export default function getFileType(file) { | ||
var _file$data, _file$meta; | ||
var type = file.mime || file.type || ((_file$data = file.data) === null || _file$data === void 0 ? void 0 : _file$data.type) || ((_file$meta = file.meta) === null || _file$meta === void 0 ? void 0 : _file$meta.img_type); | ||
if (type) { | ||
return type; | ||
} | ||
var fileExtension = file.name ? getFileNameAndExtension(file.name).extension : null; | ||
fileExtension = fileExtension ? fileExtension.toLowerCase() : null; | ||
if (file.type) { | ||
// if mime type is set in the file object already, use that | ||
return file.type; | ||
} else if (fileExtension && mimeTypes[fileExtension]) { | ||
if (fileExtension && mimeTypes[fileExtension]) { | ||
// else, see if we can map extension to a mime type | ||
@@ -12,0 +19,0 @@ return mimeTypes[fileExtension]; |
@@ -0,0 +0,0 @@ /** |
@@ -0,2 +1,7 @@ | ||
import getFileType from './getFileType'; | ||
export default function isImage(file) { | ||
if (file === void 0) { | ||
file = {}; | ||
} | ||
if (!file) { | ||
@@ -6,15 +11,3 @@ return false; | ||
if (file.type && /^image\//.test(file.type)) { | ||
return true; | ||
} | ||
if (file.mime && /^image\//.test(file.mime)) { | ||
return true; | ||
} | ||
if (file.meta && file.meta.img_type) { | ||
return true; | ||
} | ||
return false; | ||
return /^image\//.test(getFileType(file).toLowerCase()); | ||
} |
@@ -1,6 +0,7 @@ | ||
export default function isPreviewSupported(fileType) { | ||
if (!fileType) return false; | ||
var fileTypeSpecific = fileType.split('/')[1]; // list of images that browsers can preview | ||
if (/^(jpe?g|gif|png|svg|svg\+xml|bmp|webp)$/.test(fileTypeSpecific)) { | ||
import isImage from './isImage'; | ||
import isPDF from './isPDF'; | ||
import isOpenedFromAdobe from './isOpenedFromAdobe'; | ||
export default function isPreviewSupported(file) { | ||
// Checking if we could show a preview for this item or not | ||
if (isImage(file) || isPDF(file) && !isOpenedFromAdobe()) { | ||
return true; | ||
@@ -7,0 +8,0 @@ } |
@@ -26,3 +26,3 @@ function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } | ||
var fieldRegionalVariants = metaRegionalGroups === null || metaRegionalGroups === void 0 ? void 0 : (_metaRegionalGroups$f = metaRegionalGroups.find(function (group) { | ||
return group.id === (field === null || field === void 0 ? void 0 : field.regional_variants_group_id); | ||
return group.uuid === (field === null || field === void 0 ? void 0 : field.regional_variants_group_uuid); | ||
})) === null || _metaRegionalGroups$f === void 0 ? void 0 : _metaRegionalGroups$f.variants; | ||
@@ -29,0 +29,0 @@ var fieldHasRegionalVars = (fieldRegionalVariants || []).length > 0; |
@@ -16,3 +16,3 @@ /** | ||
var fieldRegionalVariants = metaRegionalGroups === null || metaRegionalGroups === void 0 ? void 0 : (_metaRegionalGroups$f = metaRegionalGroups.find(function (group) { | ||
return group.id === (field === null || field === void 0 ? void 0 : field.regional_variants_group_id); | ||
return group.uuid === (field === null || field === void 0 ? void 0 : field.regional_variants_group_uuid); | ||
})) === null || _metaRegionalGroups$f === void 0 ? void 0 : _metaRegionalGroups$f.variants; | ||
@@ -23,3 +23,3 @@ | ||
fieldRegionalVariants.forEach(function (_ref) { | ||
var regionalVariantKey = _ref.key; | ||
var regionalVariantKey = _ref.internal_unique_value; | ||
defaultMetadata[field.key][regionalVariantKey] = value; | ||
@@ -26,0 +26,0 @@ }); |
@@ -7,3 +7,3 @@ function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); } | ||
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } | ||
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } | ||
@@ -10,0 +10,0 @@ function _isNativeFunction(fn) { return Function.toString.call(fn).indexOf("[native code]") !== -1; } |
@@ -6,3 +6,3 @@ { | ||
"types": "types/index.d.ts", | ||
"version": "0.0.0-beta.27", | ||
"version": "0.0.0-beta.31", | ||
"files": [ | ||
@@ -15,3 +15,3 @@ "/dist", | ||
"dependencies": { | ||
"@filerobot/icons": "0.0.0-beta.27", | ||
"@filerobot/icons": "0.0.0-beta.31", | ||
"abortcontroller-polyfill": "^1.4.0", | ||
@@ -18,0 +18,0 @@ "lodash.throttle": "^4.1.1" |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
113958
2473
+ Added@filerobot/icons@0.0.0-beta.31(transitive)
- Removed@filerobot/icons@0.0.0-beta.27(transitive)