mirror of
https://github.com/jeffvli/feishin.git
synced 2026-05-09 20:29:36 +02:00
progress
This commit is contained in:
@@ -21,10 +21,21 @@ import { ExpandedListItem } from '/@/renderer/components/item-list/expanded-list
|
|||||||
import { useItemListState } from '/@/renderer/components/item-list/helpers/item-list-state';
|
import { useItemListState } from '/@/renderer/components/item-list/helpers/item-list-state';
|
||||||
import { LibraryItem } from '/@/shared/types/domain-types';
|
import { LibraryItem } from '/@/shared/types/domain-types';
|
||||||
|
|
||||||
interface ItemTableListProps<CellProps extends object> {
|
export interface ItemTableListColumn {
|
||||||
|
id: string;
|
||||||
|
label: string;
|
||||||
|
width: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface CellProps {
|
||||||
|
columns: ItemTableListColumn[];
|
||||||
|
data: unknown[];
|
||||||
|
}
|
||||||
|
|
||||||
|
interface ItemTableListProps {
|
||||||
CellComponent: JSXElementConstructor<CellComponentProps<CellProps>>;
|
CellComponent: JSXElementConstructor<CellComponentProps<CellProps>>;
|
||||||
cellProps: GridProps<CellProps>['cellProps'];
|
|
||||||
columnCount: number;
|
columnCount: number;
|
||||||
|
columns: ItemTableListColumn[];
|
||||||
columnWidth: ((index: number, cellProps: CellProps) => number) | number;
|
columnWidth: ((index: number, cellProps: CellProps) => number) | number;
|
||||||
data: unknown[];
|
data: unknown[];
|
||||||
enableExpansion?: boolean;
|
enableExpansion?: boolean;
|
||||||
@@ -40,11 +51,11 @@ interface ItemTableListProps<CellProps extends object> {
|
|||||||
itemType: LibraryItem;
|
itemType: LibraryItem;
|
||||||
onCellsRendered: GridProps<CellProps>['onCellsRendered'];
|
onCellsRendered: GridProps<CellProps>['onCellsRendered'];
|
||||||
onEndReached?: (index: number) => void;
|
onEndReached?: (index: number) => void;
|
||||||
onItemClick?: (item: unknown, index: number) => void;
|
onItemClick?: (item: unknown, index: number, event: MouseEvent<HTMLDivElement>) => void;
|
||||||
onItemContextMenu?: (item: unknown, index: number) => void;
|
onItemContextMenu?: (item: unknown, index: number, event: MouseEvent<HTMLDivElement>) => void;
|
||||||
onItemDoubleClick?: (item: unknown, index: number) => void;
|
onItemDoubleClick?: (item: unknown, index: number, event: MouseEvent<HTMLDivElement>) => void;
|
||||||
onRangeChanged?: (range: { endIndex: number; startIndex: number }) => void;
|
onRangeChanged?: (range: { endIndex: number; startIndex: number }) => void;
|
||||||
onScroll?: (e: UIEvent<HTMLDivElement>) => void;
|
onScroll?: (event: UIEvent<HTMLDivElement>) => void;
|
||||||
onScrollEnd?: () => void;
|
onScrollEnd?: () => void;
|
||||||
onStartReached?: (index: number) => void;
|
onStartReached?: (index: number) => void;
|
||||||
ref?: Ref<GridImperativeAPI>;
|
ref?: Ref<GridImperativeAPI>;
|
||||||
@@ -68,11 +79,12 @@ const expandedAnimationVariants: Variants = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
export const ItemTableList = <CellProps extends object>({
|
export const ItemTableList = ({
|
||||||
CellComponent,
|
CellComponent,
|
||||||
cellProps,
|
|
||||||
columnCount,
|
columnCount,
|
||||||
|
columns,
|
||||||
columnWidth,
|
columnWidth,
|
||||||
|
data,
|
||||||
initialTopMostItemIndex,
|
initialTopMostItemIndex,
|
||||||
itemType,
|
itemType,
|
||||||
onCellsRendered,
|
onCellsRendered,
|
||||||
@@ -89,7 +101,7 @@ export const ItemTableList = <CellProps extends object>({
|
|||||||
stickyColumnCount,
|
stickyColumnCount,
|
||||||
stickyRowCount,
|
stickyRowCount,
|
||||||
totalItemCount,
|
totalItemCount,
|
||||||
}: ItemTableListProps<CellProps>) => {
|
}: ItemTableListProps) => {
|
||||||
const totalRowCount = totalItemCount - (stickyRowCount ?? 0);
|
const totalRowCount = totalItemCount - (stickyRowCount ?? 0);
|
||||||
const totalColumnCount = columnCount - (stickyColumnCount ?? 0);
|
const totalColumnCount = columnCount - (stickyColumnCount ?? 0);
|
||||||
const stickyRowRef = useRef<HTMLDivElement>(null);
|
const stickyRowRef = useRef<HTMLDivElement>(null);
|
||||||
@@ -272,6 +284,11 @@ export const ItemTableList = <CellProps extends object>({
|
|||||||
return undefined;
|
return undefined;
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
const cellProps = {
|
||||||
|
columns,
|
||||||
|
data,
|
||||||
|
};
|
||||||
|
|
||||||
const internalState = useItemListState();
|
const internalState = useItemListState();
|
||||||
|
|
||||||
const hasExpanded = internalState.hasExpanded();
|
const hasExpanded = internalState.hasExpanded();
|
||||||
@@ -337,14 +354,14 @@ export const ItemTableList = <CellProps extends object>({
|
|||||||
);
|
);
|
||||||
|
|
||||||
const RowCell = useCallback(
|
const RowCell = useCallback(
|
||||||
(cellProps: CellComponentProps & CellProps) => {
|
(cellProps: CellComponentProps<CellProps>) => {
|
||||||
return (
|
return (
|
||||||
<CellComponent
|
<CellComponent
|
||||||
{...cellProps}
|
{...cellProps}
|
||||||
columnIndex={cellProps.columnIndex + (stickyColumnCount ?? 0)}
|
columnIndex={cellProps.columnIndex + (stickyColumnCount ?? 0)}
|
||||||
onClick={() => {
|
// onClick={(e) => {
|
||||||
console.log('click', cellProps.rowIndex);
|
// onItemClick?.(cellProps.data[cellProps.rowIndex], cellProps.rowIndex, e);
|
||||||
}}
|
// }}
|
||||||
rowIndex={cellProps.rowIndex + (stickyRowCount ?? 0)}
|
rowIndex={cellProps.rowIndex + (stickyRowCount ?? 0)}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user