Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,10 @@ lib/
~*
yarn.lock
package-lock.json
!tests/__mocks__/rc-util/lib
!tests/__mocks__/rc-util/lib

# umi
.umi
.umi-production
.umi-test
.env.local
22 changes: 22 additions & 0 deletions .umirc.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// more config: https://d.umijs.org/config
import { defineConfig } from 'dumi';

export default defineConfig({
title: 'rc-virtual-list',
favicon:
'https://avatars0.githubusercontent.com/u/9441414?s=200&v=4',
logo:
'https://avatars0.githubusercontent.com/u/9441414?s=200&v=4',
outputPath: '.doc',
exportStatic: {},
resolve: {
examples: ['none'],
},
styles: [
`
.markdown table {
width: auto !important;
}
`,
]
});
6 changes: 1 addition & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@

React Virtual List Component which worked with animation.

[![NPM version][npm-image]][npm-url]
[![build status][github-actions-image]][github-actions-url]
[![Test coverage][coveralls-image]][coveralls-url]
[![node version][node-image]][node-url]
[![npm download][download-image]][download-url]
[![NPM version][npm-image]][npm-url] [![dumi](https://img.shields.io/badge/docs%20by-dumi-blue?style=flat-square)](https://github.com/umijs/dumi) [![build status][github-actions-image]][github-actions-url] [![Test coverage][coveralls-image]][coveralls-url] [![node version][node-image]][node-url] [![npm download][download-image]][download-url]

[npm-image]: http://img.shields.io/npm/v/rc-virtual-list.svg?style=flat-square
[npm-url]: http://npmjs.org/package/rc-virtual-list
Expand Down
3 changes: 3 additions & 0 deletions docs/demo/animate.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## animate

<code src="../../examples/animate.tsx">
3 changes: 3 additions & 0 deletions docs/demo/basic.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## basic

<code src="../../examples/basic.tsx">
3 changes: 3 additions & 0 deletions docs/demo/height.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## height

<code src="../../examples/height.tsx">
3 changes: 3 additions & 0 deletions docs/demo/no-virtual.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## no-virtual

<code src="../../examples/no-virtual.tsx">
3 changes: 3 additions & 0 deletions docs/demo/switch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## switch

<code src="../../examples/switch.tsx">
5 changes: 5 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
title: rc-virtual-list
---

<embed src="../README.md"></embed>
3 changes: 3 additions & 0 deletions now.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,8 @@
"use": "@now/static-build",
"config": { "distDir": ".doc" }
}
],
"routes": [
{ "src": "/(.*)", "dest": "/dist/$1" }
]
}
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
"main": "./lib/index",
"module": "./es/index",
"scripts": {
"start": "cross-env NODE_ENV=development father doc dev --storybook",
"build": "father doc build --storybook",
"start": "dumi dev",
"build": "dumi build",
"compile": "father build",
"prepublishOnly": "npm run compile && np --no-cleanup --yolo --no-publish",
"lint": "eslint src/ --ext .tsx,.ts",
Expand All @@ -49,11 +49,13 @@
"@types/react-dom": "^16.8.4",
"@types/warning": "^3.0.0",
"cross-env": "^5.2.0",
"dumi": "^1.1.12",
"enzyme": "^3.1.0",
"enzyme-adapter-react-16": "^1.0.2",
"enzyme-to-json": "^3.1.4",
"eslint": "^7.6.0",
"father": "^2.29.10",
"glob": "^7.1.6",
"np": "^5.0.3",
"rc-animate": "^2.9.1",
"react": "^v16.9.0-alpha.0",
Expand Down
2 changes: 1 addition & 1 deletion src/List.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useRef, useState } from 'react';
import classNames from 'classnames';
import Filler from './Filler';
import ScrollBar from './ScrollBar';
import { RenderFunc, SharedConfig, GetKey } from './interface';
import type { RenderFunc, SharedConfig, GetKey } from './interface';
import useChildren from './hooks/useChildren';
import useHeights from './hooks/useHeights';
import useScrollTo from './hooks/useScrollTo';
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/useChildren.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import { SharedConfig, RenderFunc } from '../interface';
import type { SharedConfig, RenderFunc } from '../interface';
import { Item } from '../Item';

export default function useChildren<T>(
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/useDiffItem.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react';
import { findListDiffIndex } from '../utils/algorithmUtil';
import { GetKey } from '../interface';
import type { GetKey } from '../interface';

export default function useDiffItem<T>(
data: T[],
Expand Down
4 changes: 1 addition & 3 deletions src/hooks/useHeights.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import * as React from 'react';
import { useRef } from 'react';
import findDOMNode from 'rc-util/lib/Dom/findDOMNode';
import { GetKey } from '../interface';
import type { GetKey } from '../interface';
import CacheMap from '../utils/CacheMap';

type RefFunc = (instance: HTMLElement) => void;

export default function useHeights<T>(
getKey: GetKey<T>,
onItemAdd?: (item: T) => void,
Expand Down
6 changes: 3 additions & 3 deletions src/hooks/useScrollTo.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/* eslint-disable no-param-reassign */
import * as React from 'react';
import raf from 'rc-util/lib/raf';
import { ScrollTo } from '../List';
import { GetKey } from '../interface';
import CacheMap from '../utils/CacheMap';
import type { ScrollTo } from '../List';
import type { GetKey } from '../interface';
import type CacheMap from '../utils/CacheMap';

export default function useScrollTo<T>(
containerRef: React.RefObject<HTMLDivElement>,
Expand Down
3 changes: 2 additions & 1 deletion src/mock.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as React from 'react';
import { RawList, ListProps, ListRef } from './List';
import type { ListProps, ListRef } from './List';
import { RawList } from './List';

const List = React.forwardRef((props: ListProps<any>, ref: React.Ref<ListRef>) =>
RawList({ ...props, virtual: false }, ref),
Expand Down
2 changes: 1 addition & 1 deletion src/utils/CacheMap.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import type React from 'react';

// Firefox has low performance of map.
class CacheMap {
Expand Down
2 changes: 1 addition & 1 deletion src/utils/algorithmUtil.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as React from 'react';
import type * as React from 'react';
/**
* Get index with specific start index one by one. e.g.
* min: 3, max: 9, start: 6
Expand Down
16 changes: 16 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"compilerOptions": {
"target": "esnext",
"moduleResolution": "node",
"baseUrl": "./",
"jsx": "preserve",
"declaration": true,
"skipLibCheck": true,
"esModuleInterop": true,
"paths": {
"@/*": ["src/*"],
"@@/*": ["src/.umi/*"],
"rc-virtual-list": ["src/index.ts"]
}
}
}
29 changes: 29 additions & 0 deletions update-demo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
用于 dumi 改造使用,
可用于将 examples 的文件批量修改为 demo 引入形式,
其他项目根据具体情况使用。
*/

const fs = require('fs');
const glob = require('glob');

const paths = glob.sync('./examples/*.tsx');

paths.forEach(path => {
const name = path.split('/').pop().split('.')[0];
fs.writeFile(
`./docs/demo/${name}.md`,
`## ${name}

<code src="../../examples/${name}.tsx">
`,
'utf8',
function(error) {
if(error){
console.log(error);
return false;
}
console.log(`${name} 更新成功~`);
}
)
});