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 = ["containerWidth", "handleContextMenuToggle", "handleNavigatingThroughArrows", "handleToggleFiles", "openCurrentFolderContextMenu"];
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 { Notification } from '@scaleflex/ui/core';
import { useExplorerI18n } from '../../../../hooks';
import { useSearchView } from '../../searchView.hook';
import AssetsSection from '../AssetsSection';
import Styled from '../../GridView/SearchGridView/SearchGridView.styled';
import ListViewFilesSkeleton from '../FilesSkeleton';
import ListViewFoldersSkeleton from '../FoldersSkeleton';
import InfiniteScroll from '../../../InfiniteScroll/InfiniteScroll';
import { jsx as _jsx } from "react/jsx-runtime";
import { jsxs as _jsxs } from "react/jsx-runtime";
import { Fragment as _Fragment } from "react/jsx-runtime";
var SearchListView = function SearchListView(_ref) {
var containerWidth = _ref.containerWidth,
handleContextMenuToggle = _ref.handleContextMenuToggle,
handleNavigatingThroughArrows = _ref.handleNavigatingThroughArrows,
handleToggleFiles = _ref.handleToggleFiles,
openCurrentFolderContextMenu = _ref.openCurrentFolderContextMenu,
props = _objectWithoutProperties(_ref, _excluded);
var _useSearchView = useSearchView(),
searchViewDetails = _useSearchView.searchViewDetails,
isNotificationVisible = _useSearchView.isNotificationVisible,
setIsNotificationVisible = _useSearchView.setIsNotificationVisible;
var i18n = useExplorerI18n();
var renderRow = function renderRow(_ref2, isLoading, tableHeadStickTop) {
var filesUuids = _ref2.filesUuids,
fetchNextFiles = _ref2.fetchNextFiles,
noMoreFiles = _ref2.noMoreFiles;
return /*#__PURE__*/_jsx("div", {
onContextMenu: openCurrentFolderContextMenu,
children: filesUuids.length > 0 && /*#__PURE__*/_jsx(InfiniteScroll, {
dataLength: filesUuids.length,
next: fetchNextFiles,
hasMore: !noMoreFiles,
scrollableTarget: "scrollableElement",
children: /*#__PURE__*/_jsx(AssetsSection, _objectSpread({
filesUuids: filesUuids,
handleContextMenuToggle: handleContextMenuToggle,
handleNavigatingThroughArrows: handleNavigatingThroughArrows,
isDisabled: false,
containerWidth: containerWidth,
tableHeadStickTop: tableHeadStickTop,
hideHeader: !filesUuids.length
}, props))
})
});
};
var renderRows = function renderRows(_ref3) {
var _ref3$firstRowFilesUu = _ref3.firstRowFilesUuids,
firstRowFilesUuids = _ref3$firstRowFilesUu === void 0 ? [] : _ref3$firstRowFilesUu,
_ref3$firstRowIsNoMor = _ref3.firstRowIsNoMoreFiles,
firstRowIsNoMoreFiles = _ref3$firstRowIsNoMor === void 0 ? true : _ref3$firstRowIsNoMor,
firstRowFetchNextFiles = _ref3.firstRowFetchNextFiles,
_ref3$firstRowLoading = _ref3.firstRowLoading,
firstRowLoading = _ref3$firstRowLoading === void 0 ? false : _ref3$firstRowLoading,
_ref3$showSecondRow = _ref3.showSecondRow,
showSecondRow = _ref3$showSecondRow === void 0 ? true : _ref3$showSecondRow,
secondRowLabel = _ref3.secondRowLabel,
_ref3$secondRowFilesU = _ref3.secondRowFilesUuids,
secondRowFilesUuids = _ref3$secondRowFilesU === void 0 ? [] : _ref3$secondRowFilesU,
_ref3$secondRowIsNoMo = _ref3.secondRowIsNoMoreFiles,
secondRowIsNoMoreFiles = _ref3$secondRowIsNoMo === void 0 ? true : _ref3$secondRowIsNoMo,
secondRowFetchNextFiles = _ref3.secondRowFetchNextFiles,
_ref3$secondRowLoadin = _ref3.secondRowLoading,
secondRowLoading = _ref3$secondRowLoadin === void 0 ? false : _ref3$secondRowLoadin,
infoMessage = _ref3.infoMessage;
return /*#__PURE__*/_jsxs(_Fragment, {
children: [infoMessage && isNotificationVisible && /*#__PURE__*/_jsx("div", {
className: "filerobot-Provider-ItemCategory-wrapper",
children: /*#__PURE__*/_jsx(Notification, {
status: "info",
message: infoMessage,
onClose: function onClose() {
return setIsNotificationVisible(false);
}
})
}), firstRowLoading ? /*#__PURE__*/_jsx(ListViewFilesSkeleton, {
count: 5
}) : firstRowFilesUuids.length ? renderRow({
filesUuids: firstRowFilesUuids,
fetchNextFiles: firstRowFetchNextFiles,
noMoreFiles: firstRowIsNoMoreFiles
}) : null, showSecondRow && /*#__PURE__*/_jsxs("div", {
children: [/*#__PURE__*/_jsx(Styled.RowLabel, {
className: "filerobot-Provider-ItemCategory-wrapper",
children: secondRowLabel || i18n('searchExtendedWithCountLabel', {
files_count: (secondRowFilesUuids === null || secondRowFilesUuids === void 0 ? void 0 : secondRowFilesUuids.length) || 0
})
}), renderRow({
filesUuids: secondRowFilesUuids,
fetchNextFiles: secondRowFetchNextFiles,
noMoreFiles: secondRowIsNoMoreFiles
}, secondRowLoading, 35)]
})]
});
};
var renderContent = function renderContent() {
if (searchViewDetails !== null && searchViewDetails !== void 0 && searchViewDetails.showSkeletonLoader) {
return /*#__PURE__*/_jsxs(_Fragment, {
children: [/*#__PURE__*/_jsx(ListViewFoldersSkeleton, {}), /*#__PURE__*/_jsx(ListViewFilesSkeleton, {})]
});
}
if (searchViewDetails !== null && searchViewDetails !== void 0 && searchViewDetails.content) {
return searchViewDetails.content;
}
if (searchViewDetails !== null && searchViewDetails !== void 0 && searchViewDetails.itemsDetails) {
return renderRows(searchViewDetails.itemsDetails);
}
};
return /*#__PURE__*/_jsx(_Fragment, {
children: renderContent()
});
};
export default SearchListView;