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); }
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); }
import { useSelector, useDispatch } from 'react-redux';
import { Skeleton } from '@scaleflex/ui/core';
import NoCollections from '@filerobot/icons/lib/NoCollections';
import NoItems from '@filerobot/explorer/lib/components/NoItems';
import { useExplorerI18n } from '../../../hooks';
import { fetchCollectionsFiles, selectActiveCollectionsVirtualFoldersPaths, selectCollectionsActiveVirtualFolder, selectCollectionsFilteredVirtualFolders, selectIsActiveVirtualFolderLoading } from '../../../slices/collections.slice';
import Tree from './Tree';
import Styled from './CollectionVirtualFoldersTree.styled';
/**
* In current component we use extra component Tree, to be able to use React.memo optimisation.
* useBrowserContext works good but increase amount of rendering in some cases
*/
import { jsx as _jsx } from "react/jsx-runtime";
import { jsxs as _jsxs } from "react/jsx-runtime";
var CollectionVirtualFoldersTree = function CollectionVirtualFoldersTree(_ref) {
var searchTerm = _ref.searchTerm;
var dispatch = useDispatch();
var i18n = useExplorerI18n();
var activeCollectionVirtualFoldersPaths = useSelector(selectActiveCollectionsVirtualFoldersPaths);
var activeCollectionVirtualFolder = useSelector(selectCollectionsActiveVirtualFolder);
var isActiveCollectionVirtualFoldersLoading = useSelector(selectIsActiveVirtualFolderLoading);
var filteredFolders = useSelector(function (state) {
return selectCollectionsFilteredVirtualFolders(state, searchTerm);
});
var activateFolder = function activateFolder(folder) {
var nextFolder = folder ? _objectSpread(_objectSpread({}, folder), {}, {
parent: activeCollectionVirtualFolder
}) : null;
dispatch(fetchCollectionsFiles({
folder: nextFolder,
offset: 0
}));
};
if (isActiveCollectionVirtualFoldersLoading) {
return /*#__PURE__*/_jsxs(Styled.Container, {
children: [/*#__PURE__*/_jsx(Styled.FolderContainer, {
children: /*#__PURE__*/_jsx(Styled.Folder, {
children: /*#__PURE__*/_jsx(Skeleton, {
width: 200
})
})
}), /*#__PURE__*/_jsx(Styled.FolderContainer, {
children: /*#__PURE__*/_jsx(Styled.Folder, {
children: /*#__PURE__*/_jsx(Skeleton, {
width: 200
})
})
}), /*#__PURE__*/_jsx(Styled.FolderContainer, {
children: /*#__PURE__*/_jsx(Styled.Folder, {
children: /*#__PURE__*/_jsx(Skeleton, {
width: 200
})
})
})]
});
}
if (!activeCollectionVirtualFoldersPaths.length) {
return /*#__PURE__*/_jsx(NoItems, {
secondary: i18n('collectionsTreeNoGroupsFoldersLabel'),
icon: NoCollections,
mt: 80
});
}
if (!filteredFolders.length) {
return /*#__PURE__*/_jsx(NoItems, {
size: 100,
noSearchResults: true,
primary: i18n('mutualizedNoResults'),
secondary: i18n('mutualizedYourFilterMatchedResults', {
filter: searchTerm,
count: 0
})
});
}
return /*#__PURE__*/_jsx(Tree, {
activeCollectionVirtualFolders: filteredFolders,
activeCollectionVirtualFolder: activeCollectionVirtualFolder,
isActiveCollectionVirtualFoldersLoading: isActiveCollectionVirtualFoldersLoading,
activateFolder: activateFolder,
searchTerm: searchTerm
});
};
export default CollectionVirtualFoldersTree;