Something went wrong. Try again.
Self-hosted file management and sharing system, supports multiple storage providers. forked from tdvorak.tngl.sh/cloudreve
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149import { alpha, Box, Skeleton, styled, Typography } from "@mui/material";import { memo, useCallback, useEffect } from "react";import { useAppDispatch } from "../../../../redux/hooks.ts";import { navigateReconcile } from "../../../../redux/thunks/filemanager.ts";import useActionDisplayOpt from "../../ContextMenu/useActionDisplayOpt.ts";import { FileBlockProps } from "../Explorer.tsx";import { useFileBlockState } from "../GridView/GridFile.tsx";import Cell from "./Cell.tsx";
const RowContainer = styled(Box, { shouldForwardProp: (prop) => prop !== "selected" && prop !== "transparent" && prop !== "isDropOver" && prop !== "disabled" && prop !== "taller",})<{ selected: boolean; transparent?: boolean; isDropOver?: boolean; disabled?: boolean; taller?: boolean;}>(({ theme, disabled, transparent, isDropOver, selected, taller }) => { let bgColor = "initial"; let bgColorHover = theme.palette.action.hover;
if (selected) { bgColor = alpha(theme.palette.primary.main, 0.18); bgColorHover = bgColor; } return { minHeight: taller ? "60px" : "36px", borderBottom: `1px solid ${theme.palette.divider}`, display: "flex", backgroundColor: bgColor, "&:hover": { backgroundColor: bgColorHover, }, pointerEvents: disabled ? "none" : "auto", opacity: transparent || disabled ? 0.5 : 1, transition: "all 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms", transitionProperty: "background-color,opacity,box-shadow", boxShadow: isDropOver ? `inset 0 0 0 2px ${theme.palette.primary.light}` : "none", };});
const Column = styled(Box, { shouldForwardProp: (prop) => prop !== "w",})<{ w: number }>(({ theme, w }) => ({ display: "flex", alignItems: "center", width: `${w}px`, padding: "0 10px",}));
const Row = memo((props: FileBlockProps) => { const { file, columns, search, isDragging, isDropOver, showThumb } = props; const dispatch = useAppDispatch();
const { fmIndex, isSelected, isLoadingIndicator, noThumb, uploading, ref, inView, fileTag, onClick, onDoubleClicked, hoverStateOff, hoverStateOn, onContextMenu, setRefFunc, disabled, fileDisabled, thumbWidth, thumbHeight, } = useFileBlockState(props);
const targetDisplayOptions = useActionDisplayOpt([file]);
useEffect(() => { if (!inView) { return; }
if (isLoadingIndicator) { if (file.first) { dispatch(navigateReconcile(fmIndex, { next_page: true })); } return; } }, [inView]);
const stopPop = useCallback((e: React.MouseEvent<HTMLElement>) => { e.stopPropagation(); }, []);
return ( <RowContainer data-fm-row transparent={isDragging || fileDisabled} isDropOver={isDropOver && !isDragging} ref={setRefFunc} selected={!!isSelected} taller={showThumb} onMouseDown={stopPop} onClick={onClick} onDoubleClick={onDoubleClicked} onMouseEnter={hoverStateOn} onMouseLeave={hoverStateOff} onContextMenu={onContextMenu} disabled={disabled} > {columns?.map((column, index) => ( <Column w={column.width ?? column.defaults.width} key={index}> <Typography sx={{ width: "100%", textOverflow: "ellipsis", whiteSpace: "nowrap", overflow: "hidden", }} variant={"body2"} component={"div"} > {!file.placeholder && ( <Cell actionDisplayOpt={targetDisplayOptions} isSelected={!!isSelected} search={search} column={column} file={file} uploading={uploading} fileTag={fileTag} noThumb={noThumb} showThumb={showThumb} thumbWidth={thumbWidth} thumbHeight={thumbHeight} /> )}
{file.placeholder && <Skeleton variant={"text"} width={0.5 * (column.width ?? column.defaults.width)} />} </Typography> </Column> ))} </RowContainer> );});
export default Row;