Repository URL to install this package:
|
Version:
3.12.20 ▾
|
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); }
var _excluded = ["tabs", "subTabs", "showFileProduct", "files"];
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; }
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; }
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
import { FILECARD_TABS_IDS } from '@filerobot/utils/lib/constants';
import { useSelector, useDispatch } from 'react-redux';
import { transcodeVideoResolution } from '../../../thunks/video.thunks';
import { selectIsM1EdgyMeta } from '../../../slices/metadata.slice';
import { sharePanelOpened } from '../../../slices/panels.slice';
import { useExplorer } from '../../../hooks';
import { selectIsCurrentSelectionRemovingBackground } from '../../../slices/files.slice';
// CHECK THIS AGAIN FOR REFACTORING DROP DOWN & CONTEXT MENU
import { jsx as _jsx } from "react/jsx-runtime";
export default (function (_ref) {
var tabs = _ref.tabs,
subTabs = _ref.subTabs,
showFileProduct = _ref.showFileProduct,
files = _ref.files,
rest = _objectWithoutProperties(_ref, _excluded);
var _useExplorer = useExplorer(),
opts = _useExplorer.opts,
i18n = _useExplorer.i18n;
var dispatch = useDispatch();
var isM1EdgyMeta = useSelector(selectIsM1EdgyMeta);
var isCurrentSelectionRemovingBackground = useSelector(selectIsCurrentSelectionRemovingBackground);
var videoTranscoding = opts.videoTranscoding,
removeBackgroundFolder = opts.removeBackgroundFolder,
showRemoveBackgroundOption = opts.showRemoveBackgroundOption;
return tabs.map(function (tabId) {
var _tab$i18nStr, _tab$disabled, _tab$disabled2;
var tab = subTabs[tabId];
// Meta must be visible only for M1_EDGY
if (tabId === FILECARD_TABS_IDS.PRODUCT && !showFileProduct || tabId === FILECARD_TABS_IDS.META && !isM1EdgyMeta) return null;
var tabIcon = function tabIcon(color) {
if (typeof tab.icon === 'function') return tab.icon(color);
return /*#__PURE__*/_jsx(tab.icon, {
size: 16,
color: color
});
};
var handleClickTab = function handleClickTab() {
if (!tab.onClick) return;
tab.onClick(_objectSpread({
dispatch: dispatch,
files: files,
removeBackgroundFolder: removeBackgroundFolder,
toggleShare: function toggleShare(_files) {
return dispatch(sharePanelOpened(_files));
},
transcodeVideo: function transcodeVideo(videoFile) {
return dispatch(transcodeVideoResolution({
uuid: videoFile.uuid,
// We are adding uuid alone for being discovered from the extraReducer in updateFile of (files.slice).
file: videoFile,
i18n: i18n,
resolution: videoTranscoding.resolution
}));
}
}, rest));
};
return {
key: tabId,
content: (_tab$i18nStr = tab === null || tab === void 0 ? void 0 : tab.i18nStr) !== null && _tab$i18nStr !== void 0 ? _tab$i18nStr : tabId,
hideOption: function hideOption(passedCommonProps) {
var _tab$hideOption, _tab$hideOption2;
return (_tab$hideOption = tab === null || tab === void 0 ? void 0 : (_tab$hideOption2 = tab.hideOption) === null || _tab$hideOption2 === void 0 ? void 0 : _tab$hideOption2.call(tab, _objectSpread(_objectSpread({}, passedCommonProps), {}, {
showRemoveBackgroundOption: showRemoveBackgroundOption
}))) !== null && _tab$hideOption !== void 0 ? _tab$hideOption : tab === null || tab === void 0 ? void 0 : tab.hideOption;
},
disabled: (_tab$disabled = tab === null || tab === void 0 ? void 0 : (_tab$disabled2 = tab.disabled) === null || _tab$disabled2 === void 0 ? void 0 : _tab$disabled2.call(tab, {
isCurrentSelectionRemovingBackground: isCurrentSelectionRemovingBackground
})) !== null && _tab$disabled !== void 0 ? _tab$disabled : tab === null || tab === void 0 ? void 0 : tab.disabled,
onClick: handleClickTab,
prefix: function prefix(_ref2) {
var iconPrimaryColor = _ref2.iconPrimaryColor;
return (tab === null || tab === void 0 ? void 0 : tab.icon) && tabIcon(iconPrimaryColor);
}
};
}).filter(function (tab) {
return tab;
});
});