Repository URL to install this package:
|
Version:
3.12.2 ▾
|
import { TIME_OPTIONS } from './constants';
import getItemIcon from './getItemIcon';
import getFileExtension from './getFileExtension';
import prettyFileSize from './prettyFileSize';
export default (function (file, language) {
var _fileInfo$img_w, _fileInfo$img_h, _file$info, _file$info$brand, _file$info$brand$extr, _file$info$brand$extr2;
var fileInfo = file === null || file === void 0 ? void 0 : file.info;
var width = (_fileInfo$img_w = fileInfo === null || fileInfo === void 0 ? void 0 : fileInfo.img_w) !== null && _fileInfo$img_w !== void 0 ? _fileInfo$img_w : fileInfo === null || fileInfo === void 0 ? void 0 : fileInfo.video_w;
var height = (_fileInfo$img_h = fileInfo === null || fileInfo === void 0 ? void 0 : fileInfo.img_h) !== null && _fileInfo$img_h !== void 0 ? _fileInfo$img_h : fileInfo === null || fileInfo === void 0 ? void 0 : fileInfo.video_h;
var isDefined = width && height;
var type = file.type;
var videoDuration = fileInfo === null || fileInfo === void 0 ? void 0 : fileInfo.video_duration;
var transcodingProgress = file.transcodingProgress;
var uuid = file.uuid;
var name = file.name;
var extension = getFileExtension(file);
var mime = file.type;
var url = file.url;
var preview = file.preview || getItemIcon({
fileOrFolder: file
});
var createdAt = file.created_at ? new Date(file.created_at).toLocaleTimeString(language, TIME_OPTIONS) : '';
var modifiedAt = file.updated_at ? new Date(file.modified_at).toLocaleTimeString(language, TIME_OPTIONS) : '';
var ratio = isDefined ? (width / height).toPrecision(3) : 0;
var size = prettyFileSize(file.size);
var tags = file !== null && file !== void 0 && file.tags ? file.tags : {};
var resolution = isDefined ? width + 'x' + height : null;
var visibility = file.visibility;
var logoAndBrandClasses = (_file$info = file.info) === null || _file$info === void 0 ? void 0 : (_file$info$brand = _file$info.brand) === null || _file$info$brand === void 0 ? void 0 : (_file$info$brand$extr = _file$info$brand.extracted) === null || _file$info$brand$extr === void 0 ? void 0 : (_file$info$brand$extr2 = _file$info$brand$extr.classes) === null || _file$info$brand$extr2 === void 0 ? void 0 : _file$info$brand$extr2.map(function (item) {
return item.label;
});
var meta = file.meta;
return {
uuid: uuid,
name: name,
createdAt: createdAt,
extension: extension,
url: url,
width: width,
height: height,
ratio: ratio,
size: size,
resolution: resolution,
tags: tags,
visibility: visibility,
modifiedAt: modifiedAt,
mime: mime,
meta: meta,
type: type,
preview: preview,
fileInfo: fileInfo,
videoDuration: videoDuration,
transcodingProgress: transcodingProgress,
logoAndBrandClasses: logoAndBrandClasses
};
});