Skip to content

Commit bd2bf22

Browse files
authored
Merge branch 'master' into dependabot/npm_and_yarn/rc-component/father-plugin-2.1.3
2 parents 43b2dd8 + 7becdad commit bd2bf22

19 files changed

+196
-255
lines changed

.umirc.ts renamed to .dumirc.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ export default defineConfig({
44
themeConfig: {
55
name: 'Tree',
66
},
7+
outputPath: '.doc',
78
});

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ lib/
77
~*
88
yarn.lock
99
package-lock.json
10+
pnpm-lock.yaml
1011
!tests/__mocks__/rc-util/lib
12+
!tests/__mocks__/@rc-component/util/lib
1113
bun.lockb
1214

1315
# umi

README.md

Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,32 @@
1-
# rc-virtual-list
1+
# @rc-component/virtual-list
22

33
React Virtual List Component which worked with animation.
44

5-
[![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]
6-
7-
[npm-image]: http://img.shields.io/npm/v/rc-virtual-list.svg?style=flat-square
8-
[npm-url]: http://npmjs.org/package/rc-virtual-list
9-
[github-actions-image]: https://github.com/react-component/virtual-list/workflows/CI/badge.svg
10-
[github-actions-url]: https://github.com/react-component/virtual-list/actions
11-
[coveralls-image]: https://img.shields.io/codecov/c/github/react-component/virtual-list/master.svg?style=flat-square
12-
[coveralls-url]: https://codecov.io/gh/react-component/virtual-list
13-
[node-image]: https://img.shields.io/badge/node.js-%3E=_6.0-green.svg?style=flat-square
14-
[node-url]: http://nodejs.org/download/
15-
[download-image]: https://img.shields.io/npm/dm/rc-virtual-list.svg?style=flat-square
16-
[download-url]: https://npmjs.org/package/rc-virtual-list
5+
[![NPM version][npm-image]][npm-url]
6+
[![npm download][download-image]][download-url]
7+
[![build status][github-actions-image]][github-actions-url]
8+
[![Codecov][codecov-image]][codecov-url]
9+
[![bundle size][bundlephobia-image]][bundlephobia-url]
10+
[![dumi][dumi-image]][dumi-url]
11+
12+
[npm-image]: https://img.shields.io/npm/v/@rc-component/virtual-list.svg?style=flat-square
13+
[npm-url]: https://npmjs.org/package/@rc-component/virtual-list
14+
[travis-image]: https://img.shields.io/travis/react-component/virtual-list/master?style=flat-square
15+
[travis-url]: https://travis-ci.com/react-component/virtual-list
16+
[github-actions-image]: https://github.com/react-component/virtual-list/actions/workflows/main.yml/badge.svg
17+
[github-actions-url]: https://github.com/react-component/virtual-list/actions/workflows/main.yml
18+
[codecov-image]: https://img.shields.io/codecov/c/github/react-component/virtual-list/master.svg?style=flat-square
19+
[codecov-url]: https://app.codecov.io/gh/react-component/virtual-list
20+
[david-url]: https://david-dm.org/react-component/virtual-list
21+
[david-image]: https://david-dm.org/react-component/virtual-list/status.svg?style=flat-square
22+
[david-dev-url]: https://david-dm.org/react-component/virtual-list?type=dev
23+
[david-dev-image]: https://david-dm.org/react-component/virtual-list/dev-status.svg?style=flat-square
24+
[download-image]: https://img.shields.io/npm/dm/@rc-component/virtual-list.svg?style=flat-square
25+
[download-url]: https://npmjs.org/package/@rc-component/virtual-list
26+
[bundlephobia-url]: https://bundlephobia.com/package/@rc-component/virtual-list
27+
[bundlephobia-image]: https://badgen.net/bundlephobia/minzip/@rc-component/virtual-list
28+
[dumi-url]: https://github.com/umijs/dumi
29+
[dumi-image]: https://img.shields.io/badge/docs%20by-dumi-blue?style=flat-square
1730

1831
## Online Preview
1932

@@ -35,15 +48,15 @@ open http://localhost:8000/
3548

3649
## Install
3750

38-
[![rc-virtual-list](https://nodei.co/npm/rc-virtual-list.png)](https://npmjs.org/package/rc-virtual-list)
51+
[![@rc-component/virtual-list](https://nodei.co/npm/@rc-component/virtual-list.png)](https://npmjs.org/package/@rc-component/virtual-list)
3952

4053
## Usage
4154

42-
```js
43-
import List from 'rc-virtual-list';
55+
```tsx
56+
import List from '@rc-component/virtual-list';
4457

4558
<List data={[0, 1, 2]} height={200} itemHeight={30} itemKey="id">
46-
{index => <div>{index}</div>}
59+
{(index) => <div>{index}</div>}
4760
</List>;
4861
```
4962

examples/animate.tsx

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
import * as React from 'react';
44
// @ts-ignore
55
import CSSMotion from 'rc-animate/lib/CSSMotion';
6-
import classNames from 'classnames';
6+
import { clsx } from 'clsx';
77
import List, { ListRef } from '../src/List';
8-
import useLayoutEffect from 'rc-util/lib/hooks/useLayoutEffect';
8+
import useLayoutEffect from '@rc-component/util/lib/hooks/useLayoutEffect';
99
import './animate.less';
1010

1111
let uuid = 0;
@@ -74,7 +74,7 @@ const MyItem: React.ForwardRefRenderFunction<any, MyItemProps> = (
7474
motionName="motion"
7575
motionAppear={motionAppear}
7676
onAppearStart={getCollapsedHeight}
77-
onAppearActive={node => {
77+
onAppearActive={(node) => {
7878
motionRef.current = true;
7979
return getMaxHeight(node);
8080
}}
@@ -87,12 +87,7 @@ const MyItem: React.ForwardRefRenderFunction<any, MyItemProps> = (
8787
>
8888
{({ className, style }, passedMotionRef) => {
8989
return (
90-
<div
91-
ref={passedMotionRef}
92-
className={classNames('item', className)}
93-
style={style}
94-
data-id={id}
95-
>
90+
<div ref={passedMotionRef} className={clsx('item', className)} style={style} data-id={id}>
9691
<div style={{ height: itemUuid % 2 ? 100 : undefined }}>
9792
<button
9893
type="button"
@@ -145,7 +140,7 @@ const Demo = () => {
145140
};
146141

147142
const onLeave = (id: string) => {
148-
const newData = data.filter(item => item.id !== id);
143+
const newData = data.filter((item) => item.id !== id);
149144
setData(newData);
150145
};
151146

@@ -159,14 +154,14 @@ const Demo = () => {
159154
}
160155

161156
const onInsertBefore = (id: string) => {
162-
const index = data.findIndex(item => item.id === id);
157+
const index = data.findIndex((item) => item.id === id);
163158
const newData = [...data.slice(0, index), genItem(), ...data.slice(index)];
164159
setInsertIndex(index);
165160
setData(newData);
166161
lockForAnimation();
167162
};
168163
const onInsertAfter = (id: string) => {
169-
const index = data.findIndex(item => item.id === id) + 1;
164+
const index = data.findIndex((item) => item.id === id) + 1;
170165
const newData = [...data.slice(0, index), genItem(), ...data.slice(index)];
171166
setInsertIndex(index);
172167
setData(newData);

jest.config.js

Lines changed: 0 additions & 4 deletions
This file was deleted.

now.json

Lines changed: 0 additions & 14 deletions
This file was deleted.

package.json

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"name": "rc-virtual-list",
3-
"version": "3.18.6",
2+
"name": "@rc-component/virtual-list",
3+
"version": "1.0.0",
44
"description": "React Virtual List Component",
55
"engines": {
66
"node": ">=8.x"
@@ -31,7 +31,7 @@
3131
"start": "dumi dev",
3232
"build": "dumi build",
3333
"compile": "father build",
34-
"prepublishOnly": "npm run compile && np --no-cleanup --yolo --no-publish",
34+
"prepublishOnly": "npm run compile && rc-np",
3535
"lint": "eslint src/ --ext .tsx,.ts",
3636
"test": "rc-test",
3737
"now-build": "npm run build"
@@ -42,25 +42,22 @@
4242
},
4343
"devDependencies": {
4444
"@rc-component/father-plugin": "^2.1.3",
45+
"@rc-component/np": "^1.0.4",
4546
"@testing-library/jest-dom": "^5.17.0",
4647
"@testing-library/react": "^12.1.5",
47-
"@types/classnames": "^2.2.10",
4848
"@types/enzyme": "^3.10.5",
49-
"@types/jest": "^25.1.3",
49+
"@types/jest": "^30.0.0",
50+
"@types/node": "^24.10.1",
5051
"@types/react": "^18.0.8",
5152
"@types/react-dom": "^18.0.3",
5253
"@types/warning": "^3.0.0",
53-
"cheerio": "1.0.0-rc.12",
54-
"cross-env": "^5.2.0",
5554
"dumi": "^2.2.17",
5655
"enzyme": "^3.1.0",
5756
"enzyme-adapter-react-16": "^1.15.6",
58-
"enzyme-to-json": "^3.1.4",
5957
"eslint": "^8.56.0",
6058
"eslint-plugin-unicorn": "^55.0.0",
6159
"father": "^4.4.0",
6260
"glob": "^7.1.6",
63-
"np": "^7.5.0",
6461
"rc-animate": "^2.9.1",
6562
"rc-test": "^7.0.15",
6663
"react": "16.14.0",
@@ -69,8 +66,11 @@
6966
},
7067
"dependencies": {
7168
"@babel/runtime": "^7.20.0",
72-
"classnames": "^2.2.6",
73-
"rc-resize-observer": "^1.0.0",
74-
"rc-util": "^5.36.0"
69+
"@rc-component/resize-observer": "^1.0.1",
70+
"@rc-component/util": "^1.4.0",
71+
"clsx": "^2.1.1"
72+
},
73+
"publishConfig": {
74+
"access": "public"
7575
}
7676
}

src/Filler.tsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as React from 'react';
2-
import ResizeObserver from 'rc-resize-observer';
3-
import classNames from 'classnames';
2+
import ResizeObserver from '@rc-component/resize-observer';
3+
import { clsx } from 'clsx';
44

55
export type InnerProps = Pick<React.HTMLAttributes<HTMLDivElement>, 'role' | 'id'>;
66

@@ -80,9 +80,7 @@ const Filler = React.forwardRef(
8080
>
8181
<div
8282
style={innerStyle}
83-
className={classNames({
84-
[`${prefixCls}-holder-inner`]: prefixCls,
85-
})}
83+
className={clsx({ [`${prefixCls}-holder-inner`]: prefixCls })}
8684
ref={ref}
8785
{...innerProps}
8886
>

src/List.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import classNames from 'classnames';
2-
import type { ResizeObserverProps } from 'rc-resize-observer';
3-
import ResizeObserver from 'rc-resize-observer';
4-
import { useEvent } from 'rc-util';
5-
import useLayoutEffect from 'rc-util/lib/hooks/useLayoutEffect';
1+
import { clsx } from 'clsx';
2+
import type { ResizeObserverProps } from '@rc-component/resize-observer';
3+
import ResizeObserver from '@rc-component/resize-observer';
4+
import { useEvent } from '@rc-component/util';
5+
import useLayoutEffect from '@rc-component/util/lib/hooks/useLayoutEffect';
66
import * as React from 'react';
77
import { useRef, useState } from 'react';
88
import { flushSync } from 'react-dom';
@@ -37,7 +37,7 @@ export interface ScrollInfo {
3737

3838
export type ScrollConfig = ScrollTarget | ScrollPos;
3939

40-
export type ScrollTo = (arg: number | ScrollConfig) => void;
40+
export type ScrollTo = (arg?: number | ScrollConfig | null) => void;
4141

4242
export type ListRef = {
4343
nativeElement: HTMLDivElement;
@@ -146,7 +146,7 @@ export function RawList<T>(props: ListProps<T>, ref: React.Ref<ListRef>) {
146146
(Math.max(itemHeight * data.length, containerHeight) > height || !!scrollWidth);
147147
const isRTL = direction === 'rtl';
148148

149-
const mergedClassName = classNames(prefixCls, { [`${prefixCls}-rtl`]: isRTL }, className);
149+
const mergedClassName = clsx(prefixCls, { [`${prefixCls}-rtl`]: isRTL }, className);
150150
const mergedData = data || EMPTY_DATA;
151151
const componentRef = useRef<HTMLDivElement>();
152152
const fillerInnerRef = useRef<HTMLDivElement>();

0 commit comments

Comments
 (0)