Repository URL to install this package:
|
Version:
3.12.18 ▾
|
import { RemoveBg, Similar, Transcode } from '@scaleflex/icons';
import { isBackgroundRemoved, isRemoveBackgroundNotSupported } from '@filerobot/explorer/lib/utils/removeBackground';
import isSupportedVideo from '@filerobot/utils/lib/isSupportedVideo';
import { removeFilesBackground } from '../../../slices/files.slice';
import { jsx as _jsx } from "react/jsx-runtime";
var handleClickTranscodeVideo = function handleClickTranscodeVideo(_ref) {
var transcodeVideo = _ref.transcodeVideo,
files = _ref.files;
files.forEach(function (videoSelected) {
if (isSupportedVideo(videoSelected)) {
transcodeVideo(videoSelected);
}
});
};
var FileCardOptions = {
SIMILAR: {
i18nStr: 'mutualizedFindSimilarLabel',
icon: function icon(color) {
return /*#__PURE__*/_jsx(Similar, {
size: 16,
color: color
});
},
// TODO: Uncomment when find similar logic is ready
// hideOption: ({ files }) => !isImage(files[0])
hideOption: function hideOption() {
return true;
}
},
REMOVE_BACKGROUND: {
i18nStr: 'mutualizedRemoveBackgroundLabel',
icon: function icon(color) {
return /*#__PURE__*/_jsx(RemoveBg, {
color: color
});
},
onClick: function onClick(_ref2) {
var dispatch = _ref2.dispatch,
files = _ref2.files,
removeBackgroundFolder = _ref2.removeBackgroundFolder;
return dispatch(removeFilesBackground({
files: files,
removeBackgroundFolder: removeBackgroundFolder
}));
},
hideOption: function hideOption(_ref3) {
var files = _ref3.files,
showRemoveBackgroundOption = _ref3.showRemoveBackgroundOption;
return !showRemoveBackgroundOption || isRemoveBackgroundNotSupported(files) || isBackgroundRemoved(files);
},
disabled: function disabled(_ref4) {
var isCurrentSelectionRemovingBackground = _ref4.isCurrentSelectionRemovingBackground;
return isCurrentSelectionRemovingBackground;
}
},
TRANSCODE_VIDEO: {
i18nStr: 'contextMenuTranscodeVideoLabel',
onClick: handleClickTranscodeVideo,
hideOption: function hideOption(_ref5) {
var files = _ref5.files;
return files.map(function (selectedVideo) {
var _selectedVideo$type, _selectedVideo$info;
return !((_selectedVideo$type = selectedVideo.type) !== null && _selectedVideo$type !== void 0 && _selectedVideo$type.includes('video')) && !isSupportedVideo(selectedVideo) && !((_selectedVideo$info = selectedVideo.info) !== null && _selectedVideo$info !== void 0 && _selectedVideo$info.playlists);
}).some(function (val) {
return val;
});
},
icon: function icon(color) {
return /*#__PURE__*/_jsx(Transcode, {
size: 14,
color: color
});
}
}
};
export default FileCardOptions;