-
e.stopPropagation()}
- className={clsx(
- 'sticky top-0 z-20 table-header-group',
- isScrolled && 'top-bar-blur !bg-app/90',
- props.listViewHeadersClassName
- )}
- >
- {table.getHeaderGroups().map((headerGroup) => (
-
- {headerGroup.headers.map((header, i) => {
- const size = header.column.getSize();
- return (
-
- {header.isPlaceholder ? null : (
-
- {flexRender(
- header.column.columnDef.header,
- header.getContext()
- )}
-
-
- {{
- asc:
,
- desc:
- }[header.column.getIsSorted() as string] ?? null}
-
- {(i !== headerGroup.headers.length - 1 ||
- (i === headerGroup.headers.length - 1 &&
- !locked)) && (
-
e.stopPropagation()}
- onMouseDown={(e) => {
- setLocked(false);
- header.getResizeHandler()(e);
- }}
- onTouchStart={header.getResizeHandler()}
- className="absolute right-0 h-[70%] w-2 cursor-col-resize border-r border-app-line/50"
- />
- )}
-
- )}
-
- );
- })}
-
- ))}
-
-
-
-
- {virtualRows.map((virtualRow) => {
- const row = rows[virtualRow.index]!;
- const selected = explorerStore.selectedRowIndex === row.index;
-
- return (
-
-
-
- );
- })}
-
-
-
- );
-};
diff --git a/interface/app/$libraryId/Explorer/MediaView.tsx b/interface/app/$libraryId/Explorer/MediaView.tsx
deleted file mode 100644
index 0f9a1e51d..000000000
--- a/interface/app/$libraryId/Explorer/MediaView.tsx
+++ /dev/null
@@ -1,224 +0,0 @@
-/* eslint-disable react-hooks/exhaustive-deps */
-import { useVirtualizer } from '@tanstack/react-virtual';
-import clsx from 'clsx';
-import { ArrowsOutSimple } from 'phosphor-react';
-import { memo, useEffect, useMemo, useState } from 'react';
-import React from 'react';
-import { useKey, useOnWindowResize } from 'rooks';
-import { ExplorerItem } from '@sd/client';
-import { Button } from '@sd/ui';
-import { getExplorerStore, useDismissibleNoticeStore, useExplorerStore } from '~/hooks';
-import FileThumb from './File/Thumb';
-import { ViewItem } from './View';
-import { useExplorerViewContext } from './ViewContext';
-
-interface MediaViewItemProps {
- data: ExplorerItem;
- index: number;
-}
-
-const MediaViewItem = memo(({ data, index }: MediaViewItemProps) => {
- const explorerStore = useExplorerStore();
- const selected = explorerStore.selectedRowIndex === index;
-
- return (
-
-
-
-
-
-
-
- );
-});
-
-export default () => {
- const explorerStore = useExplorerStore();
- const dismissibleNoticeStore = useDismissibleNoticeStore();
- const { data, scrollRef, onLoadMore, hasNextPage, isFetchingNextPage } =
- useExplorerViewContext();
-
- const gridPadding = 2;
- const scrollBarWidth = 6;
-
- const [width, setWidth] = useState(0);
- const [lastSelectedIndex, setLastSelectedIndex] = useState(explorerStore.selectedRowIndex);
-
- // Virtualizer count calculation
- const amountOfColumns = explorerStore.mediaColumns;
- const amountOfRows = Math.ceil(data.length / amountOfColumns);
-
- // Virtualizer item size calculation
- const itemSize = (width - gridPadding * 2 - scrollBarWidth) / amountOfColumns;
-
- const rowVirtualizer = useVirtualizer({
- count: amountOfRows,
- getScrollElement: () => scrollRef.current,
- estimateSize: () => (itemSize < 0 ? 0 : itemSize),
- measureElement: () => itemSize,
- paddingStart: gridPadding,
- paddingEnd: gridPadding,
- overscan: !dismissibleNoticeStore.mediaView ? 8 : 4
- });
-
- const columnVirtualizer = useVirtualizer({
- horizontal: true,
- count: amountOfColumns,
- getScrollElement: () => scrollRef.current,
- estimateSize: () => (itemSize < 0 ? 0 : itemSize),
- measureElement: () => itemSize,
- paddingStart: gridPadding,
- paddingEnd: gridPadding
- });
-
- const virtualRows = rowVirtualizer.getVirtualItems();
- const virtualColumns = columnVirtualizer.getVirtualItems();
-
- useEffect(() => {
- const lastRow = virtualRows[virtualRows.length - 1];
- if (
- (!lastRow || lastRow.index === amountOfRows - 1) &&
- hasNextPage &&
- !isFetchingNextPage
- ) {
- onLoadMore?.();
- }
- }, [hasNextPage, onLoadMore, isFetchingNextPage, virtualRows, virtualColumns, data.length]);
-
- function handleWindowResize() {
- if (scrollRef.current) {
- setWidth(scrollRef.current.offsetWidth);
- }
- }
-
- // Resize view on initial render and reset selected item
- useEffect(() => {
- handleWindowResize();
- getExplorerStore().selectedRowIndex = null;
-
- return () => {
- getExplorerStore().selectedRowIndex = null;
- };
- }, []);
-
- // Resize view on window resize
- useOnWindowResize(handleWindowResize);
-
- // Resize view on item selection/deselection
- useEffect(() => {
- const { selectedRowIndex } = explorerStore;
-
- setLastSelectedIndex(selectedRowIndex);
-
- if (explorerStore.showInspector && typeof lastSelectedIndex !== typeof selectedRowIndex) {
- handleWindowResize();
- }
- }, [explorerStore.selectedRowIndex]);
-
- // Resize view on inspector toggle
- useEffect(() => {
- if (explorerStore.selectedRowIndex !== null) {
- handleWindowResize();
- }
- }, [explorerStore.showInspector]);
-
- // Measure virtual item on size change
- useEffect(() => {
- rowVirtualizer.measure();
- columnVirtualizer.measure();
- }, [rowVirtualizer, columnVirtualizer, itemSize]);
-
- // Force recalculate range
- // https://github.com/TanStack/virtual/issues/485
- useMemo(() => {
- // @ts-ignore
- rowVirtualizer.calculateRange();
- // @ts-ignore
- columnVirtualizer.calculateRange();
- }, [amountOfRows, amountOfColumns, rowVirtualizer, columnVirtualizer]);
-
- // Select item with arrow up key
- useKey('ArrowUp', (e) => {
- e.preventDefault();
-
- const { selectedRowIndex } = explorerStore;
-
- if (selectedRowIndex === null) return;
-
- getExplorerStore().selectedRowIndex = Math.max(selectedRowIndex - 1, 0);
- });
-
- // Select item with arrow down key
- useKey('ArrowDown', (e) => {
- e.preventDefault();
-
- const { selectedRowIndex } = explorerStore;
-
- if (selectedRowIndex === null) return;
-
- getExplorerStore().selectedRowIndex = Math.min(selectedRowIndex + 1, data.length - 1);
- });
-
- if (!width) return null;
-
- return (
-
- {virtualRows.map((virtualRow) => (
-
- {virtualColumns.map((virtualColumn, i) => {
- const index = virtualRow.index * amountOfColumns + i;
- const item = data[index];
-
- if (!item) return null;
- return (
-
-
-
- );
- })}
-
- ))}
-
- );
-};
diff --git a/interface/app/$libraryId/Explorer/OptionsPanel.tsx b/interface/app/$libraryId/Explorer/OptionsPanel.tsx
index beda53ba8..019d93c1d 100644
--- a/interface/app/$libraryId/Explorer/OptionsPanel.tsx
+++ b/interface/app/$libraryId/Explorer/OptionsPanel.tsx
@@ -12,7 +12,7 @@ import {
const Heading = tw.div`text-ink-dull text-xs font-semibold`;
const Subheading = tw.div`text-ink-dull mb-1 text-xs font-medium`;
-const sortOptions: Record
= {
+export const sortOptions: Record = {
'none': 'None',
'name': 'Name',
'sizeInBytes': 'Size',
@@ -91,6 +91,7 @@ export default () => {