Skip to content

Commit

Permalink
feat: js 转 ts
Browse files Browse the repository at this point in the history
  • Loading branch information
jamie6689 committed Jun 12, 2024
1 parent bf2c91b commit f2eca4f
Show file tree
Hide file tree
Showing 41 changed files with 5,748 additions and 4,212 deletions.
3 changes: 0 additions & 3 deletions .babelrc

This file was deleted.

9 changes: 9 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
src/
*.ts
*.tsx
*.map
rollup.config.js
.babelrc
.eslintrc.js
tests/
lib/VirtualizedListV2
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
registry="https://registry.npmmirror.com"
7 changes: 7 additions & 0 deletions babel.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"presets": [
"@babel/preset-env",
"@babel/preset-react",
"@babel/preset-typescript" // 添加对 TypeScript 的支持
]
}
16 changes: 8 additions & 8 deletions build/asset-manifest.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"files": {
"main.css": "/react-virtualized-list/build/static/css/main.91612258.css",
"main.js": "/react-virtualized-list/build/static/js/main.5cb797a1.js",
"static/js/845.6038aacd.chunk.js": "/react-virtualized-list/build/static/js/845.6038aacd.chunk.js",
"index.html": "/react-virtualized-list/build/index.html",
"main.91612258.css.map": "/react-virtualized-list/build/static/css/main.91612258.css.map",
"main.5cb797a1.js.map": "/react-virtualized-list/build/static/js/main.5cb797a1.js.map",
"845.6038aacd.chunk.js.map": "/react-virtualized-list/build/static/js/845.6038aacd.chunk.js.map"
"main.css": "/static/css/main.91612258.css",
"main.js": "/static/js/main.eee57e94.js",
"static/js/845.6038aacd.chunk.js": "/static/js/845.6038aacd.chunk.js",
"index.html": "/index.html",
"main.91612258.css.map": "/static/css/main.91612258.css.map",
"main.eee57e94.js.map": "/static/js/main.eee57e94.js.map",
"845.6038aacd.chunk.js.map": "/static/js/845.6038aacd.chunk.js.map"
},
"entrypoints": [
"static/css/main.91612258.css",
"static/js/main.5cb797a1.js"
"static/js/main.eee57e94.js"
]
}
2 changes: 1 addition & 1 deletion build/index.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/react-virtualized-list/build/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="Web site created using create-react-app"/><link rel="apple-touch-icon" href="/react-virtualized-list/build/logo192.png"/><link rel="manifest" href="/react-virtualized-list/build/manifest.json"/><title>React App</title><script defer="defer" src="/react-virtualized-list/build/static/js/main.5cb797a1.js"></script><link href="/react-virtualized-list/build/static/css/main.91612258.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="Web site created using create-react-app"/><link rel="apple-touch-icon" href="/logo192.png"/><link rel="manifest" href="/manifest.json"/><title>React App</title><script defer="defer" src="/static/js/main.eee57e94.js"></script><link href="/static/css/main.91612258.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
3 changes: 0 additions & 3 deletions build/static/js/main.5cb797a1.js

This file was deleted.

1 change: 0 additions & 1 deletion build/static/js/main.5cb797a1.js.map

This file was deleted.

3 changes: 3 additions & 0 deletions build/static/js/main.eee57e94.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions build/static/js/main.eee57e94.js.map

Large diffs are not rendered by default.

20 changes: 20 additions & 0 deletions lib/VirtualizedListV2/VirtualizedList.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import React, { CSSProperties } from 'react';
interface VirtualizedListProps<T> {
listData: T[];
renderItem: (itemData: T, fetchData: any) => React.ReactNode;
refreshOnVisible?: boolean;
fetchItemData?: ((item: T) => Promise<any>) | null;
containerHeight?: string;
itemStyle?: CSSProperties;
listClassName?: string | null;
itemClassName?: string | null;
observerOptions?: IntersectionObserverInit;
onLoadMore?: () => Promise<void>;
hasMore?: boolean;
loader?: React.ReactNode;
endMessage?: React.ReactNode;
itemLoader?: React.ReactNode;
emptyListMessage?: React.ReactNode;
}
declare const VirtualizedList: <T>({ listData, renderItem, refreshOnVisible, fetchItemData, containerHeight, itemStyle, listClassName, itemClassName, observerOptions, onLoadMore, hasMore, loader, endMessage, itemLoader, emptyListMessage, }: VirtualizedListProps<T>) => import("react/jsx-runtime").JSX.Element;
export default VirtualizedList;
11 changes: 11 additions & 0 deletions lib/VirtualizedListV2/VirtualizedListItem.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { ReactNode, ReactElement } from 'react';
interface VirtualizedListItemProps<T> {
item: T;
isVisible: boolean;
refreshOnVisible: boolean;
fetchItemData: ((item: T) => Promise<any>) | null;
children: (item: T, data: any) => ReactNode;
itemLoader: ReactNode;
}
declare const VirtualizedListItem: <T>({ item, isVisible, refreshOnVisible, fetchItemData, children, itemLoader }: VirtualizedListItemProps<T>) => ReactElement;
export default VirtualizedListItem;
4 changes: 4 additions & 0 deletions lib/VirtualizedListV2/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import VirtualizedList from './VirtualizedList';
import useIntersectionObserver from './useIntersectionObserver';
export { useIntersectionObserver };
export default VirtualizedList;
10 changes: 10 additions & 0 deletions lib/VirtualizedListV2/useIntersectionObserver.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
interface UseIntersectionObserverOptions extends IntersectionObserverInit {
root?: Element | Document | null;
rootMargin?: string;
threshold?: number | number[];
}
declare const useIntersectionObserver: (nodes: (Element | null)[], onVisibilityChange?: ((isVisible: boolean, entry: IntersectionObserverEntry) => void) | null | undefined, onEntryUpdate?: ((entry: IntersectionObserverEntry) => void) | null | undefined, options?: UseIntersectionObserverOptions) => {
observe: (node: Element | null) => void;
unobserve: (node: Element | null) => void;
};
export default useIntersectionObserver;
2 changes: 2 additions & 0 deletions lib/VirtualizedListV2/utils.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
declare const debounce: <T extends (...args: any[]) => void>(func: T, delay: number) => (...args: Parameters<T>) => void;
export { debounce };
2 changes: 1 addition & 1 deletion lib/bundle.cjs.js

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

2 changes: 1 addition & 1 deletion lib/bundle.esm.js

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

1 change: 1 addition & 0 deletions lib/bundle.umd.js

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

Loading

0 comments on commit f2eca4f

Please sign in to comment.