Skip to content

Commit

Permalink
Change types from interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
garryxiao committed Dec 6, 2024
1 parent a3a9e65 commit 3830b88
Show file tree
Hide file tree
Showing 5 changed files with 87 additions and 84 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@etsoo/react",
"version": "1.8.11",
"version": "1.8.12",
"description": "TypeScript ReactJs UI Independent Framework",
"main": "lib/index.js",
"types": "lib/index.d.ts",
Expand Down
4 changes: 2 additions & 2 deletions src/components/GridLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export type GridLoadDataPartialProps = {
/**
* Grid data loader
*/
export interface GridLoader<T extends object> {
export type GridLoader<T extends object> = {
/**
* Auto load data, otherwise call reset
* @default true
Expand Down Expand Up @@ -161,7 +161,7 @@ export interface GridLoader<T extends object> {
* Threshold at which to pre-fetch data; default is half of loadBatchSize
*/
threshold?: number | undefined;
}
};

type GridLoaderProps<T> = {
/**
Expand Down
80 changes: 42 additions & 38 deletions src/components/ScrollerGrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,44 +44,48 @@ export type ScrollerGridItemRendererProps<T> = Omit<
/**
* Scroller vertical grid props
*/
export interface ScrollerGridProps<T extends object>
extends GridLoader<T>,
Omit<VariableSizeGridProps<T>, "children" | "rowCount" | "rowHeight"> {
/**
* Footer renderer
*/
footerRenderer?: (rows: T[], states: GridLoaderStates<T>) => React.ReactNode;

/**
* Header renderer
*/
headerRenderer?: (states: GridLoaderStates<T>) => React.ReactNode;

/**
* Id field
*/
idField?: DataTypes.Keys<T>;

/**
* Item renderer
*/
itemRenderer: (props: ScrollerGridItemRendererProps<T>) => React.ReactElement;

/**
* Methods
*/
mRef?: React.Ref<ScrollerGridForwardRef<T>>;

/**
* On items select change
*/
onSelectChange?: (selectedItems: T[]) => void;

/**
* Returns the height of the specified row.
*/
rowHeight?: ((index: number) => number) | number;
}
export type ScrollerGridProps<T extends object> = GridLoader<T> &
Omit<VariableSizeGridProps<T>, "children" | "rowCount" | "rowHeight"> & {
/**
* Footer renderer
*/
footerRenderer?: (
rows: T[],
states: GridLoaderStates<T>
) => React.ReactNode;

/**
* Header renderer
*/
headerRenderer?: (states: GridLoaderStates<T>) => React.ReactNode;

/**
* Id field
*/
idField?: DataTypes.Keys<T>;

/**
* Item renderer
*/
itemRenderer: (
props: ScrollerGridItemRendererProps<T>
) => React.ReactElement;

/**
* Methods
*/
mRef?: React.Ref<ScrollerGridForwardRef<T>>;

/**
* On items select change
*/
onSelectChange?: (selectedItems: T[]) => void;

/**
* Returns the height of the specified row.
*/
rowHeight?: ((index: number) => number) | number;
};

/**
* Scroller grid forward ref
Expand Down
81 changes: 40 additions & 41 deletions src/components/ScrollerList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,47 +21,46 @@ import { GridMethodRef } from "./GridMethodRef";
/**
* Scroller vertical list props
*/
export interface ScrollerListProps<T extends object>
extends GridLoader<T>,
Omit<
ListProps<T>,
"outerRef" | "height" | "width" | "children" | "itemCount" // Exclude these props, shoud be exisited otherwise will be failed
> {
/**
* Methods ref
*/
mRef?: React.Ref<ScrollerListForwardRef<T>>;

/**
* Outer div ref
*/
oRef?: React.Ref<HTMLDivElement>;

/**
* Height of the list
*/
height?: number;

/**
* Width of the list
*/
width?: number | string;

/**
* Id field
*/
idField?: DataTypes.Keys<T>;

/**
* Item renderer
*/
itemRenderer: (props: ListChildComponentProps<T>) => React.ReactElement;

/**
* Item size, a function indicates its a variable size list
*/
itemSize: ((index: number) => number) | number;
}
export type ScrollerListProps<T extends object> = GridLoader<T> &
Omit<
ListProps<T>,
"outerRef" | "height" | "width" | "children" | "itemCount" // Exclude these props, shoud be exisited otherwise will be failed
> & {
/**
* Methods ref
*/
mRef?: React.Ref<ScrollerListForwardRef<T>>;

/**
* Outer div ref
*/
oRef?: React.Ref<HTMLDivElement>;

/**
* Height of the list
*/
height?: number;

/**
* Width of the list
*/
width?: number | string;

/**
* Id field
*/
idField?: DataTypes.Keys<T>;

/**
* Item renderer
*/
itemRenderer: (props: ListChildComponentProps<T>) => React.ReactElement;

/**
* Item size, a function indicates its a variable size list
*/
itemSize: ((index: number) => number) | number;
};

/**
* Scroller list ref
Expand Down

0 comments on commit 3830b88

Please sign in to comment.