@rc-component/progress 1.0.2 â 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +103 -137
- package/README.zh-CN.md +129 -0
- package/es/Circle/index.js +1 -1
- package/es/Line.js +5 -14
- package/es/interface.d.ts +3 -1
- package/lib/Circle/index.js +9 -9
- package/lib/Line.js +6 -15
- package/lib/interface.d.ts +3 -1
- package/package.json +50 -32
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2019-present react-component
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,163 +1,129 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
## Example
|
|
25
|
-
|
|
26
|
-
https://progress.react-component.vercel.app/
|
|
27
|
-
|
|
28
|
-
## Screenshots
|
|
29
|
-
|
|
30
|
-
<img src="https://t.alipayobjects.com/images/T12p8gXjpgXXXXXXXX.gif" />
|
|
31
|
-
|
|
32
|
-
## Browsers
|
|
33
|
-
|
|
34
|
-
* support IE9+, Chrome, Firefox, Safari
|
|
1
|
+
<div align="center">
|
|
2
|
+
<h1>@rc-component/progress</h1>
|
|
3
|
+
<p><sub><a href="https://ant.design"><img alt="Ant Design" height="14" src="https://gw.alipayobjects.com/zos/rmsportal/KDpgvguMpGfqaHPjicRK.svg" style="vertical-align: -0.125em;" /></a> Part of the Ant Design ecosystem.</sub></p>
|
|
4
|
+
<p>đ Lightweight React line and circle progress indicators with SVG rendering.</p>
|
|
5
|
+
|
|
6
|
+
<p>
|
|
7
|
+
<a href="https://npmjs.org/package/@rc-component/progress"><img alt="NPM version" src="https://img.shields.io/npm/v/@rc-component/progress.svg?style=flat-square"></a>
|
|
8
|
+
<a href="https://npmjs.org/package/@rc-component/progress"><img alt="npm downloads" src="https://img.shields.io/npm/dm/@rc-component/progress.svg?style=flat-square"></a>
|
|
9
|
+
<a href="https://github.com/react-component/progress/actions/workflows/react-component-ci.yml"><img alt="build status" src="https://github.com/react-component/progress/actions/workflows/react-component-ci.yml/badge.svg"></a>
|
|
10
|
+
<a href="https://app.codecov.io/gh/react-component/progress"><img alt="Codecov" src="https://img.shields.io/codecov/c/github/react-component/progress/master.svg?style=flat-square"></a>
|
|
11
|
+
<a href="https://bundlephobia.com/package/@rc-component/progress"><img alt="bundle size" src="https://img.shields.io/bundlephobia/minzip/@rc-component/progress?style=flat-square"></a>
|
|
12
|
+
<a href="https://github.com/umijs/dumi"><img alt="dumi" src="https://img.shields.io/badge/docs%20by-dumi-blue?style=flat-square"></a>
|
|
13
|
+
</p>
|
|
14
|
+
</div>
|
|
15
|
+
|
|
16
|
+
<p align="center">English | <a href="./README.zh-CN.md">įŽäŊ䏿</a></p>
|
|
17
|
+
|
|
18
|
+
## Highlights
|
|
19
|
+
|
|
20
|
+
- `Line` and `Circle` progress components rendered with SVG.
|
|
21
|
+
- Single value, segmented value, gradient color, and indeterminate loading states.
|
|
22
|
+
- Semantic `classNames` and `styles` slots for root, rail, and track customization.
|
|
23
|
+
- TypeScript definitions for the shared progress props.
|
|
35
24
|
|
|
36
25
|
## Install
|
|
37
26
|
|
|
38
|
-
|
|
27
|
+
```bash
|
|
28
|
+
npm install @rc-component/progress
|
|
29
|
+
```
|
|
39
30
|
|
|
40
31
|
## Usage
|
|
41
32
|
|
|
42
|
-
```
|
|
43
|
-
import {
|
|
44
|
-
|
|
33
|
+
```tsx | pure
|
|
34
|
+
import { Circle, Line } from '@rc-component/progress';
|
|
45
35
|
export default () => (
|
|
46
36
|
<>
|
|
47
|
-
|
|
48
|
-
|
|
37
|
+
<Line percent={42} strokeWidth={4} strokeColor="#1677ff" />
|
|
38
|
+
<Circle percent={75} strokeWidth={6} strokeColor="#52c41a" />
|
|
49
39
|
</>
|
|
50
40
|
);
|
|
51
41
|
```
|
|
52
42
|
|
|
53
|
-
|
|
43
|
+
```tsx | pure
|
|
44
|
+
import { Circle } from '@rc-component/progress';
|
|
45
|
+
export default () => (
|
|
46
|
+
<Circle
|
|
47
|
+
percent={[30, 20, 10]}
|
|
48
|
+
strokeWidth={6}
|
|
49
|
+
strokeColor={['#1677ff', '#52c41a', '#faad14']}
|
|
50
|
+
railWidth={6}
|
|
51
|
+
/>
|
|
52
|
+
);
|
|
53
|
+
```
|
|
54
54
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
55
|
+
The SVG is decorative by default. When using it as the progress indicator itself, provide progress semantics and an accessible name with standard SVG/ARIA props:
|
|
56
|
+
|
|
57
|
+
```tsx | pure
|
|
58
|
+
<Line
|
|
59
|
+
percent={42}
|
|
60
|
+
role="progressbar"
|
|
61
|
+
aria-label="Upload progress"
|
|
62
|
+
aria-valuemin={0}
|
|
63
|
+
aria-valuemax={100}
|
|
64
|
+
aria-valuenow={42}
|
|
65
|
+
/>
|
|
66
|
+
```
|
|
58
67
|
|
|
59
|
-
##
|
|
68
|
+
## Examples
|
|
60
69
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
<table class="table table-bordered table-striped">
|
|
64
|
-
<thead>
|
|
65
|
-
<tr>
|
|
66
|
-
<th style="width: 100px;">name</th>
|
|
67
|
-
<th style="width: 50px;">type</th>
|
|
68
|
-
<th style="width: 50px;">default</th>
|
|
69
|
-
<th>description</th>
|
|
70
|
-
</tr>
|
|
71
|
-
</thead>
|
|
72
|
-
<tbody>
|
|
73
|
-
<tr>
|
|
74
|
-
<td>strokeWidth</td>
|
|
75
|
-
<td>Number</td>
|
|
76
|
-
<td>1</td>
|
|
77
|
-
<td>Width of the stroke. Unit is percentage of SVG canvas size.</td>
|
|
78
|
-
</tr>
|
|
79
|
-
<tr>
|
|
80
|
-
<td>strokeColor</td>
|
|
81
|
-
<td>String</td>
|
|
82
|
-
<td>#2db7f5</td>
|
|
83
|
-
<td>Stroke color.</td>
|
|
84
|
-
</tr>
|
|
85
|
-
<tr>
|
|
86
|
-
<td>railWidth</td>
|
|
87
|
-
<td>Number</td>
|
|
88
|
-
<td>1</td>
|
|
89
|
-
<td>Width of the rail stroke. Unit is percentage of SVG canvas size. Rail is always centered relative to actual progress path. If railWidth is not defined, it is the same as strokeWidth.</td>
|
|
90
|
-
</tr>
|
|
91
|
-
<tr>
|
|
92
|
-
<td>railColor</td>
|
|
93
|
-
<td>String</td>
|
|
94
|
-
<td>#D9D9D9</td>
|
|
95
|
-
<td>Color for lighter rail stroke underneath the actual progress path.</td>
|
|
96
|
-
</tr>
|
|
97
|
-
<tr>
|
|
98
|
-
<td>strokeLinecap</td>
|
|
99
|
-
<td>String</td>
|
|
100
|
-
<td>'round'</td>
|
|
101
|
-
<td>The shape to be used at the end of the progress bar: can be `butt`, `square` or `round`.</td>
|
|
102
|
-
</tr>
|
|
103
|
-
<tr>
|
|
104
|
-
<td>prefixCls</td>
|
|
105
|
-
<td>String</td>
|
|
106
|
-
<td>rc-progress</td>
|
|
107
|
-
<td>prefix className for component</td>
|
|
108
|
-
</tr>
|
|
109
|
-
<tr>
|
|
110
|
-
<td>className</td>
|
|
111
|
-
<td>String</td>
|
|
112
|
-
<td></td>
|
|
113
|
-
<td>customized className</td>
|
|
114
|
-
</tr>
|
|
115
|
-
<tr>
|
|
116
|
-
<td>style</td>
|
|
117
|
-
<td>Object</td>
|
|
118
|
-
<td></td>
|
|
119
|
-
<td>style object will be added to svg element</td>
|
|
120
|
-
</tr>
|
|
121
|
-
<tr>
|
|
122
|
-
<td>percent</td>
|
|
123
|
-
<td>Number | Number[]</td>
|
|
124
|
-
<td>0</td>
|
|
125
|
-
<td>the percent of the progress</td>
|
|
126
|
-
</tr>
|
|
127
|
-
<tr>
|
|
128
|
-
<td>gapDegree</td>
|
|
129
|
-
<td>Number</td>
|
|
130
|
-
<td>0</td>
|
|
131
|
-
<td>the gap degree of half circle, 0 - 360</td>
|
|
132
|
-
</tr>
|
|
133
|
-
<tr>
|
|
134
|
-
<td>gapPosition</td>
|
|
135
|
-
<td>String</td>
|
|
136
|
-
<td>top</td>
|
|
137
|
-
<td>the gap position: can be `top`, `bottom`, `left`, or `right`. </td>
|
|
138
|
-
</tr>
|
|
139
|
-
<tr>
|
|
140
|
-
<td>loading</td>
|
|
141
|
-
<td>Boolean</td>
|
|
142
|
-
<td>false</td>
|
|
143
|
-
<td>If it is true the indeterminate progress will be enabled.</td>
|
|
144
|
-
</tr>
|
|
145
|
-
</tbody>
|
|
146
|
-
</table>
|
|
147
|
-
|
|
148
|
-
## Installation
|
|
70
|
+
Run the local dumi site:
|
|
149
71
|
|
|
72
|
+
```bash
|
|
73
|
+
npm install
|
|
74
|
+
npm start
|
|
150
75
|
```
|
|
151
|
-
|
|
152
|
-
|
|
76
|
+
|
|
77
|
+
Then open `http://localhost:8000`.
|
|
78
|
+
|
|
79
|
+
## API
|
|
80
|
+
|
|
81
|
+
`Line` and `Circle` share the same base props.
|
|
82
|
+
|
|
83
|
+
| Name | Type | Default | Description |
|
|
84
|
+
| --- | --- | --- | --- |
|
|
85
|
+
| `className` | string | - | Additional class name for the root node. |
|
|
86
|
+
| `classNames` | Partial<Record<'root' \| 'rail' \| 'track', string>> | - | Semantic class names for internal slots. |
|
|
87
|
+
| `gapDegree` | number | - | Gap degree for circle progress. |
|
|
88
|
+
| `gapPosition` | `'top'` \| `'right'` \| `'bottom'` \| `'left'` | `'bottom'` | Gap position for circle progress. |
|
|
89
|
+
| `id` | string | - | Root element id. |
|
|
90
|
+
| `loading` | boolean | false | Render an indeterminate loading animation. |
|
|
91
|
+
| `onClick` | React.MouseEventHandler | - | Click handler for the root SVG. |
|
|
92
|
+
| `percent` | number \| number[] | 0 | Progress percent. Arrays render multiple tracks. |
|
|
93
|
+
| `prefixCls` | string | `'rc-progress'` | Prefix class name. |
|
|
94
|
+
| `railColor` | string | `'#D9D9D9'` | Rail color. |
|
|
95
|
+
| `railWidth` | number | 1 | Rail stroke width. |
|
|
96
|
+
| `steps` | number \| { count: number; gap: number } | - | Render progress as discrete steps. |
|
|
97
|
+
| `strokeColor` | string \| Record<string, string \| boolean> \| Array<string \| Record<string, string \| boolean>> | `'#2db7f5'` | Track color, gradient object, or per-track colors. |
|
|
98
|
+
| `strokeLinecap` | `'round'` \| `'butt'` \| `'square'` | `'round'` | Stroke line cap. |
|
|
99
|
+
| `strokeWidth` | number | 1 | Track stroke width. |
|
|
100
|
+
| `style` | React.CSSProperties | - | Root style. |
|
|
101
|
+
| `styles` | Partial<Record<'root' \| 'rail' \| 'track', React.CSSProperties>> | - | Semantic styles for internal slots. |
|
|
102
|
+
| `transition` | string | - | CSS transition for track updates. |
|
|
103
|
+
|
|
104
|
+
Standard SVG attributes, including `role` and `aria-*`, are forwarded to the root SVG.
|
|
153
105
|
|
|
154
106
|
## Development
|
|
155
107
|
|
|
156
|
-
```
|
|
108
|
+
```bash
|
|
157
109
|
npm install
|
|
158
110
|
npm start
|
|
111
|
+
npm test
|
|
112
|
+
npm run tsc
|
|
113
|
+
npm run compile
|
|
114
|
+
npm run build
|
|
159
115
|
```
|
|
160
116
|
|
|
117
|
+
The dumi site runs at `http://localhost:8000` by default.
|
|
118
|
+
|
|
119
|
+
## Release
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
npm run prepublishOnly
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
The release flow is handled by `@rc-component/np` through the `rc-np` command after the package build.
|
|
126
|
+
|
|
161
127
|
## License
|
|
162
128
|
|
|
163
|
-
@rc-component/progress is released under the MIT license.
|
|
129
|
+
@rc-component/progress is released under the [MIT](./LICENSE) license.
|
package/README.zh-CN.md
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
<h1>@rc-component/progress</h1>
|
|
3
|
+
<p><sub><a href="https://ant.design"><img alt="Ant Design" height="14" src="https://gw.alipayobjects.com/zos/rmsportal/KDpgvguMpGfqaHPjicRK.svg" style="vertical-align: -0.125em;" /></a> Ant Design įæįä¸é¨åã</sub></p>
|
|
4
|
+
<p>đ React čŋåēĻæĄįģäģļīŧæ¯æįēŋåãååŊĸåčĒåŽäščŋåēĻåąį¤ēã</p>
|
|
5
|
+
|
|
6
|
+
<p>
|
|
7
|
+
<a href="https://npmjs.org/package/@rc-component/progress"><img alt="NPM version" src="https://img.shields.io/npm/v/@rc-component/progress.svg?style=flat-square"></a>
|
|
8
|
+
<a href="https://npmjs.org/package/@rc-component/progress"><img alt="npm downloads" src="https://img.shields.io/npm/dm/@rc-component/progress.svg?style=flat-square"></a>
|
|
9
|
+
<a href="https://github.com/react-component/progress/actions/workflows/react-component-ci.yml"><img alt="build status" src="https://github.com/react-component/progress/actions/workflows/react-component-ci.yml/badge.svg"></a>
|
|
10
|
+
<a href="https://app.codecov.io/gh/react-component/progress"><img alt="Codecov" src="https://img.shields.io/codecov/c/github/react-component/progress/master.svg?style=flat-square"></a>
|
|
11
|
+
<a href="https://bundlephobia.com/package/@rc-component/progress"><img alt="bundle size" src="https://img.shields.io/bundlephobia/minzip/@rc-component/progress?style=flat-square"></a>
|
|
12
|
+
<a href="https://github.com/umijs/dumi"><img alt="dumi" src="https://img.shields.io/badge/docs%20by-dumi-blue?style=flat-square"></a>
|
|
13
|
+
</p>
|
|
14
|
+
</div>
|
|
15
|
+
|
|
16
|
+
<p align="center"><a href="./README.md">English</a> | įŽäŊ䏿</p>
|
|
17
|
+
|
|
18
|
+
## įšæ§
|
|
19
|
+
|
|
20
|
+
- `Line` å `Circle` äŊŋ፠SVG æ¸˛æįčŋåēĻįģäģļã
|
|
21
|
+
- ååŧãåæŽĩåŧãæ¸åéĸč˛åä¸įĄŽåŽįå čŊŊįļæã
|
|
22
|
+
- į¨äēæ šãå¯ŧčŊ¨åčŊ¨éåŽåļįč¯äš `classNames` å `styles` ææ§Ŋã
|
|
23
|
+
- ä¸ēå
ąäēĢčŋåēĻåąæ§æäž TypeScript įąģååŽäšã
|
|
24
|
+
|
|
25
|
+
## åŽčŖ
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
npm install @rc-component/progress
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## äŊŋį¨
|
|
32
|
+
|
|
33
|
+
```tsx | pure
|
|
34
|
+
import { Circle, Line } from '@rc-component/progress';
|
|
35
|
+
export default () => (
|
|
36
|
+
<>
|
|
37
|
+
<Line percent={42} strokeWidth={4} strokeColor="#1677ff" />
|
|
38
|
+
<Circle percent={75} strokeWidth={6} strokeColor="#52c41a" />
|
|
39
|
+
</>
|
|
40
|
+
);
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
```tsx | pure
|
|
44
|
+
import { Circle } from '@rc-component/progress';
|
|
45
|
+
export default () => (
|
|
46
|
+
<Circle
|
|
47
|
+
percent={[30, 20, 10]}
|
|
48
|
+
strokeWidth={6}
|
|
49
|
+
strokeColor={['#1677ff', '#52c41a', '#faad14']}
|
|
50
|
+
railWidth={6}
|
|
51
|
+
/>
|
|
52
|
+
);
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
SVG éģ莤äŊä¸ēčŖ
éĨ°å
į´ ãåŊ SVG æŦčēĢäŊä¸ēčŋåēĻæį¤ē卿ļīŧå¯éčŋæ å SVGīŧARIA åąæ§æäžčŋåēĻč¯äšåæ éįĸåį§°īŧ
|
|
56
|
+
|
|
57
|
+
```tsx | pure
|
|
58
|
+
<Line
|
|
59
|
+
percent={42}
|
|
60
|
+
role="progressbar"
|
|
61
|
+
aria-label="ä¸äŧ čŋåēĻ"
|
|
62
|
+
aria-valuemin={0}
|
|
63
|
+
aria-valuemax={100}
|
|
64
|
+
aria-valuenow={42}
|
|
65
|
+
/>
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## į¤ēäž
|
|
69
|
+
|
|
70
|
+
čŋčĄæŦå° dumi įĢįšīŧ
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
npm install
|
|
74
|
+
npm start
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
įļåæåŧ `http://localhost:8000`ã
|
|
78
|
+
|
|
79
|
+
## API
|
|
80
|
+
|
|
81
|
+
`Line` å `Circle` å
ąäēĢį¸åįåēįĄåąæ§ã
|
|
82
|
+
|
|
83
|
+
| åį§° | įąģå | éģ莤åŧ | 蝴æ |
|
|
84
|
+
| --- | --- | --- | --- |
|
|
85
|
+
| `className` | string | - | æ ščįšįéå classNameã |
|
|
86
|
+
| `classNames` | Partial<Record<'root' \| 'rail' \| 'track', string>> | - | å
鍿æ§Ŋįč¯äšå classNameã |
|
|
87
|
+
| `gapDegree` | number | - | į¯åŊĸčŋåēĻįŧēåŖč§åēĻã |
|
|
88
|
+
| `gapPosition` | `'top'` \| `'right'` \| `'bottom'` \| `'left'` | `'bottom'` | åžĒį¯čŋåēĻįé´éäŊįŊŽã |
|
|
89
|
+
| `id` | string | - | æ šå
į´ IDã |
|
|
90
|
+
| `loading` | boolean | false | æ¸˛æä¸įĄŽåŽįå čŊŊå¨įģã |
|
|
91
|
+
| `onClick` | React.MouseEventHandler | - | ååģæ š SVG įå¤įį¨åēã |
|
|
92
|
+
| `percent` | number \| number[] | 0 | čŋåēĻįžåæ¯ãæ°įģäŧæ¸˛æå¤æĄčŊ¨éã |
|
|
93
|
+
| `prefixCls` | string | `'rc-progress'` | åįŧ classNameã |
|
|
94
|
+
| `railColor` | string | `'#D9D9D9'` | å¯ŧčŊ¨éĸč˛ã |
|
|
95
|
+
| `railWidth` | number | 1 | å¯ŧčŊ¨čĄį¨åŽŊåēĻã |
|
|
96
|
+
| `steps` | number \| { count: number; gap: number } | - | äģĨįĻģæŖæĨéĒ¤æ¸˛æčŋåēĻã |
|
|
97
|
+
| `strokeColor` | string \| Record<string, string \| boolean> \| Array<string \| Record<string, string \| boolean>> | `'#2db7f5'` | čŊ¨ééĸč˛ãæ¸åå¯ščąĄææ¯æĄčŊ¨éįéĸč˛ã |
|
|
98
|
+
| `strokeLinecap` | `'round'` \| `'butt'` \| `'square'` | `'round'` | æčžšįĢ¯įšæ ˇåŧã |
|
|
99
|
+
| `strokeWidth` | number | 1 | čŊ¨éæčžšåŽŊåēĻã |
|
|
100
|
+
| `style` | React.CSSProperties | - | æ šæ ˇåŧã |
|
|
101
|
+
| `styles` | Partial<Record<'root' \| 'rail' \| 'track', React.CSSProperties>> | - | å
鍿æ§Ŋįč¯äšåæ ˇåŧã |
|
|
102
|
+
| `transition` | string | - | į¨äēčˇč¸Ēæ´æ°į CSS čŋæ¸Ąã |
|
|
103
|
+
|
|
104
|
+
æ å SVG åąæ§īŧå
æŦ `role` å `aria-*`īŧäŧéäŧ å°æ š SVGã
|
|
105
|
+
|
|
106
|
+
## æŦå°åŧå
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
npm install
|
|
110
|
+
npm start
|
|
111
|
+
npm test
|
|
112
|
+
npm run tsc
|
|
113
|
+
npm run compile
|
|
114
|
+
npm run build
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
dumi įĢįšéģ莤čŋčĄå¨ `http://localhost:8000`ã
|
|
118
|
+
|
|
119
|
+
## åå¸
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
npm run prepublishOnly
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
å
æåģēåŽæåīŧå叿ĩį¨įą `@rc-component/np` éčŋ `rc-np` åŊäģ¤å¤įã
|
|
126
|
+
|
|
127
|
+
## 莸å¯č¯
|
|
128
|
+
|
|
129
|
+
@rc-component/progress åēäē [MIT](./LICENSE) 莸å¯č¯åå¸ã
|
package/es/Circle/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import { clsx } from 'clsx';
|
|
4
|
+
import { useId } from '@rc-component/util';
|
|
4
5
|
import { defaultProps, useTransitionDuration } from "../common";
|
|
5
|
-
import useId from "@rc-component/util/es/hooks/useId";
|
|
6
6
|
import PtgCircle from "./PtgCircle";
|
|
7
7
|
import { VIEW_BOX_SIZE, getCircleStyle } from "./util";
|
|
8
8
|
import getIndeterminateCircle from "../utils/getIndeterminateCircle";
|
package/es/Line.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import { clsx } from 'clsx';
|
|
4
|
+
import { useId } from '@rc-component/util';
|
|
4
5
|
import { useTransitionDuration, defaultProps } from "./common";
|
|
5
6
|
import getIndeterminateLine from "./utils/getIndeterminateLine";
|
|
6
|
-
import useId from "@rc-component/util/es/hooks/useId";
|
|
7
7
|
const Line = props => {
|
|
8
8
|
const {
|
|
9
9
|
id,
|
|
@@ -47,10 +47,12 @@ const Line = props => {
|
|
|
47
47
|
strokeWidth
|
|
48
48
|
});
|
|
49
49
|
return /*#__PURE__*/React.createElement("svg", _extends({
|
|
50
|
+
id: id,
|
|
50
51
|
className: clsx(`${prefixCls}-line`, className),
|
|
51
52
|
viewBox: viewBoxString,
|
|
52
53
|
preserveAspectRatio: "none",
|
|
53
|
-
style: style
|
|
54
|
+
style: style,
|
|
55
|
+
role: "presentation"
|
|
54
56
|
}, restProps), /*#__PURE__*/React.createElement("path", {
|
|
55
57
|
className: `${prefixCls}-line-rail`,
|
|
56
58
|
d: pathString,
|
|
@@ -59,18 +61,7 @@ const Line = props => {
|
|
|
59
61
|
strokeWidth: railWidth || strokeWidth,
|
|
60
62
|
fillOpacity: "0"
|
|
61
63
|
}), percentList.map((ptg, index) => {
|
|
62
|
-
|
|
63
|
-
switch (strokeLinecap) {
|
|
64
|
-
case 'round':
|
|
65
|
-
dashPercent = 1 - strokeWidth / 100;
|
|
66
|
-
break;
|
|
67
|
-
case 'square':
|
|
68
|
-
dashPercent = 1 - strokeWidth / 2 / 100;
|
|
69
|
-
break;
|
|
70
|
-
default:
|
|
71
|
-
dashPercent = 1;
|
|
72
|
-
break;
|
|
73
|
-
}
|
|
64
|
+
const dashPercent = strokeLinecap === 'round' ? 1 - strokeWidth / 100 : strokeLinecap === 'square' ? 1 - strokeWidth / 2 / 100 : 1;
|
|
74
65
|
const pathStyle = {
|
|
75
66
|
strokeDasharray: `${ptg * dashPercent}px, 100px`,
|
|
76
67
|
strokeDashoffset: `-${stackPtg}px`,
|
package/es/interface.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
export type SemanticName = 'root' | 'rail' | 'track';
|
|
3
|
-
export interface ProgressProps {
|
|
3
|
+
export interface ProgressProps extends Omit<React.SVGAttributes<SVGSVGElement>, 'strokeWidth' | 'strokeLinecap'> {
|
|
4
4
|
id?: string;
|
|
5
|
+
/** Component geometry width, rather than the root SVG stroke-width attribute. */
|
|
5
6
|
strokeWidth?: number;
|
|
6
7
|
railWidth?: number;
|
|
7
8
|
className?: string;
|
|
@@ -10,6 +11,7 @@ export interface ProgressProps {
|
|
|
10
11
|
percent?: number | number[];
|
|
11
12
|
strokeColor?: StrokeColorType;
|
|
12
13
|
railColor?: string;
|
|
14
|
+
/** Component path line cap, rather than the root SVG stroke-linecap attribute. */
|
|
13
15
|
strokeLinecap?: StrokeLinecapType;
|
|
14
16
|
prefixCls?: string;
|
|
15
17
|
style?: React.CSSProperties;
|
package/lib/Circle/index.js
CHANGED
|
@@ -6,10 +6,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var React = _interopRequireWildcard(require("react"));
|
|
8
8
|
var _clsx = require("clsx");
|
|
9
|
+
var _util = require("@rc-component/util");
|
|
9
10
|
var _common = require("../common");
|
|
10
|
-
var _useId = _interopRequireDefault(require("@rc-component/util/lib/hooks/useId"));
|
|
11
11
|
var _PtgCircle = _interopRequireDefault(require("./PtgCircle"));
|
|
12
|
-
var
|
|
12
|
+
var _util2 = require("./util");
|
|
13
13
|
var _getIndeterminateCircle = _interopRequireDefault(require("../utils/getIndeterminateCircle"));
|
|
14
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
15
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
@@ -42,8 +42,8 @@ const Circle = props => {
|
|
|
42
42
|
..._common.defaultProps,
|
|
43
43
|
...props
|
|
44
44
|
};
|
|
45
|
-
const halfSize =
|
|
46
|
-
const mergedId = (0,
|
|
45
|
+
const halfSize = _util2.VIEW_BOX_SIZE / 2;
|
|
46
|
+
const mergedId = (0, _util.useId)(id);
|
|
47
47
|
const gradientId = `${mergedId}-gradient`;
|
|
48
48
|
const radius = halfSize - strokeWidth / 2;
|
|
49
49
|
const perimeter = Math.PI * 2 * radius;
|
|
@@ -68,13 +68,13 @@ const Circle = props => {
|
|
|
68
68
|
id: mergedId,
|
|
69
69
|
loading
|
|
70
70
|
});
|
|
71
|
-
const circleStyle = (0,
|
|
71
|
+
const circleStyle = (0, _util2.getCircleStyle)(perimeter, perimeterWithoutGap, 0, 100, rotateDeg, gapDegree, gapPosition, railColor, mergedStrokeLinecap, strokeWidth);
|
|
72
72
|
const paths = (0, _common.useTransitionDuration)();
|
|
73
73
|
const getStokeList = () => {
|
|
74
74
|
let stackPtg = 0;
|
|
75
75
|
return percentList.map((ptg, index) => {
|
|
76
76
|
const color = strokeColorList[index] || strokeColorList[strokeColorList.length - 1];
|
|
77
|
-
const circleStyleForStack = (0,
|
|
77
|
+
const circleStyleForStack = (0, _util2.getCircleStyle)(perimeter, perimeterWithoutGap, stackPtg, ptg, rotateDeg, gapDegree, gapPosition, color, mergedStrokeLinecap, strokeWidth);
|
|
78
78
|
stackPtg += ptg;
|
|
79
79
|
return /*#__PURE__*/React.createElement(_PtgCircle.default, {
|
|
80
80
|
key: index,
|
|
@@ -100,7 +100,7 @@ const Circle = props => {
|
|
|
100
100
|
|
|
101
101
|
paths[index] = elem;
|
|
102
102
|
},
|
|
103
|
-
size:
|
|
103
|
+
size: _util2.VIEW_BOX_SIZE
|
|
104
104
|
});
|
|
105
105
|
}).reverse();
|
|
106
106
|
};
|
|
@@ -112,7 +112,7 @@ const Circle = props => {
|
|
|
112
112
|
return new Array(stepCount).fill(null).map((_, index) => {
|
|
113
113
|
const color = index <= current - 1 ? strokeColorList[0] : railColor;
|
|
114
114
|
const stroke = color && typeof color === 'object' ? `url(#${gradientId})` : undefined;
|
|
115
|
-
const circleStyleForStack = (0,
|
|
115
|
+
const circleStyleForStack = (0, _util2.getCircleStyle)(perimeter, perimeterWithoutGap, stackPtg, stepPtg, rotateDeg, gapDegree, gapPosition, color, 'butt', strokeWidth, stepGap);
|
|
116
116
|
stackPtg += (perimeterWithoutGap - circleStyleForStack.strokeDashoffset + stepGap) * 100 / perimeterWithoutGap;
|
|
117
117
|
return /*#__PURE__*/React.createElement("circle", {
|
|
118
118
|
key: index,
|
|
@@ -135,7 +135,7 @@ const Circle = props => {
|
|
|
135
135
|
};
|
|
136
136
|
return /*#__PURE__*/React.createElement("svg", _extends({
|
|
137
137
|
className: (0, _clsx.clsx)(`${prefixCls}-circle`, classNames.root, className),
|
|
138
|
-
viewBox: `0 0 ${
|
|
138
|
+
viewBox: `0 0 ${_util2.VIEW_BOX_SIZE} ${_util2.VIEW_BOX_SIZE}`,
|
|
139
139
|
style: {
|
|
140
140
|
...styles.root,
|
|
141
141
|
...style
|
package/lib/Line.js
CHANGED
|
@@ -6,9 +6,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var React = _interopRequireWildcard(require("react"));
|
|
8
8
|
var _clsx = require("clsx");
|
|
9
|
+
var _util = require("@rc-component/util");
|
|
9
10
|
var _common = require("./common");
|
|
10
11
|
var _getIndeterminateLine = _interopRequireDefault(require("./utils/getIndeterminateLine"));
|
|
11
|
-
var _useId = _interopRequireDefault(require("@rc-component/util/lib/hooks/useId"));
|
|
12
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
13
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
14
14
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
@@ -32,7 +32,7 @@ const Line = props => {
|
|
|
32
32
|
..._common.defaultProps,
|
|
33
33
|
...props
|
|
34
34
|
};
|
|
35
|
-
const mergedId = (0,
|
|
35
|
+
const mergedId = (0, _util.useId)(id);
|
|
36
36
|
|
|
37
37
|
// eslint-disable-next-line no-param-reassign
|
|
38
38
|
delete restProps.gapPosition;
|
|
@@ -56,10 +56,12 @@ const Line = props => {
|
|
|
56
56
|
strokeWidth
|
|
57
57
|
});
|
|
58
58
|
return /*#__PURE__*/React.createElement("svg", _extends({
|
|
59
|
+
id: id,
|
|
59
60
|
className: (0, _clsx.clsx)(`${prefixCls}-line`, className),
|
|
60
61
|
viewBox: viewBoxString,
|
|
61
62
|
preserveAspectRatio: "none",
|
|
62
|
-
style: style
|
|
63
|
+
style: style,
|
|
64
|
+
role: "presentation"
|
|
63
65
|
}, restProps), /*#__PURE__*/React.createElement("path", {
|
|
64
66
|
className: `${prefixCls}-line-rail`,
|
|
65
67
|
d: pathString,
|
|
@@ -68,18 +70,7 @@ const Line = props => {
|
|
|
68
70
|
strokeWidth: railWidth || strokeWidth,
|
|
69
71
|
fillOpacity: "0"
|
|
70
72
|
}), percentList.map((ptg, index) => {
|
|
71
|
-
|
|
72
|
-
switch (strokeLinecap) {
|
|
73
|
-
case 'round':
|
|
74
|
-
dashPercent = 1 - strokeWidth / 100;
|
|
75
|
-
break;
|
|
76
|
-
case 'square':
|
|
77
|
-
dashPercent = 1 - strokeWidth / 2 / 100;
|
|
78
|
-
break;
|
|
79
|
-
default:
|
|
80
|
-
dashPercent = 1;
|
|
81
|
-
break;
|
|
82
|
-
}
|
|
73
|
+
const dashPercent = strokeLinecap === 'round' ? 1 - strokeWidth / 100 : strokeLinecap === 'square' ? 1 - strokeWidth / 2 / 100 : 1;
|
|
83
74
|
const pathStyle = {
|
|
84
75
|
strokeDasharray: `${ptg * dashPercent}px, 100px`,
|
|
85
76
|
strokeDashoffset: `-${stackPtg}px`,
|
package/lib/interface.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
export type SemanticName = 'root' | 'rail' | 'track';
|
|
3
|
-
export interface ProgressProps {
|
|
3
|
+
export interface ProgressProps extends Omit<React.SVGAttributes<SVGSVGElement>, 'strokeWidth' | 'strokeLinecap'> {
|
|
4
4
|
id?: string;
|
|
5
|
+
/** Component geometry width, rather than the root SVG stroke-width attribute. */
|
|
5
6
|
strokeWidth?: number;
|
|
6
7
|
railWidth?: number;
|
|
7
8
|
className?: string;
|
|
@@ -10,6 +11,7 @@ export interface ProgressProps {
|
|
|
10
11
|
percent?: number | number[];
|
|
11
12
|
strokeColor?: StrokeColorType;
|
|
12
13
|
railColor?: string;
|
|
14
|
+
/** Component path line cap, rather than the root SVG stroke-linecap attribute. */
|
|
13
15
|
strokeLinecap?: StrokeLinecapType;
|
|
14
16
|
prefixCls?: string;
|
|
15
17
|
style?: React.CSSProperties;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rc-component/progress",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "progress ui component for react",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -8,13 +8,13 @@
|
|
|
8
8
|
"react-progress",
|
|
9
9
|
"progress"
|
|
10
10
|
],
|
|
11
|
-
"homepage": "
|
|
11
|
+
"homepage": "https://react-component.github.io/progress",
|
|
12
12
|
"repository": {
|
|
13
13
|
"type": "git",
|
|
14
|
-
"url": "
|
|
14
|
+
"url": "https://github.com/react-component/progress.git"
|
|
15
15
|
},
|
|
16
16
|
"bugs": {
|
|
17
|
-
"url": "
|
|
17
|
+
"url": "https://github.com/react-component/progress/issues"
|
|
18
18
|
},
|
|
19
19
|
"license": "MIT",
|
|
20
20
|
"main": "./lib/index",
|
|
@@ -25,48 +25,66 @@
|
|
|
25
25
|
],
|
|
26
26
|
"scripts": {
|
|
27
27
|
"start": "dumi dev",
|
|
28
|
+
"build": "npm run docs:build",
|
|
28
29
|
"docs:build": "dumi build",
|
|
29
|
-
"docs:deploy": "gh-pages -d dist",
|
|
30
|
-
"deploy": "npm run
|
|
30
|
+
"docs:deploy": "gh-pages -d docs-dist",
|
|
31
|
+
"deploy": "npm run gh-pages",
|
|
31
32
|
"compile": "father build",
|
|
32
|
-
"prepare": "dumi setup",
|
|
33
|
-
"gh-pages": "npm run
|
|
33
|
+
"prepare": "husky && dumi setup",
|
|
34
|
+
"gh-pages": "cross-env GH_PAGES=1 npm run docs:build && npm run docs:deploy",
|
|
34
35
|
"prepublishOnly": "npm run compile && rc-np",
|
|
35
36
|
"lint": "eslint src/ --ext .ts,.tsx,.jsx,.js",
|
|
36
|
-
"prettier": "prettier --write
|
|
37
|
+
"prettier": "prettier --write --ignore-unknown .",
|
|
37
38
|
"test": "rc-test",
|
|
38
39
|
"tsc": "tsc --noEmit",
|
|
39
|
-
"coverage": "father test --coverage"
|
|
40
|
-
"now-build": "npm run docs:build"
|
|
40
|
+
"coverage": "father test --coverage"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@rc-component/util": "^1.
|
|
43
|
+
"@rc-component/util": "^1.11.1",
|
|
44
44
|
"clsx": "^2.1.1"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"@
|
|
47
|
+
"@eslint/js": "^10.0.1",
|
|
48
|
+
"@eslint/compat": "^2.1.0",
|
|
49
|
+
"@rc-component/father-plugin": "^2.2.0",
|
|
48
50
|
"@rc-component/np": "^1.0.4",
|
|
49
|
-
"@testing-library/
|
|
50
|
-
"@
|
|
51
|
-
"@
|
|
52
|
-
"@types/
|
|
53
|
-
"@types/
|
|
54
|
-
"@types/
|
|
55
|
-
"@
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
"
|
|
59
|
-
"eslint
|
|
60
|
-
"
|
|
61
|
-
"
|
|
62
|
-
"
|
|
63
|
-
"
|
|
64
|
-
"
|
|
65
|
-
"
|
|
66
|
-
"
|
|
51
|
+
"@testing-library/dom": "^10.4.1",
|
|
52
|
+
"@testing-library/jest-dom": "^6.9.1",
|
|
53
|
+
"@testing-library/react": "^16.3.2",
|
|
54
|
+
"@types/jest": "^30.0.0",
|
|
55
|
+
"@types/keyv": "^4.2.0",
|
|
56
|
+
"@types/node": "^26.0.1",
|
|
57
|
+
"@types/react": "^19.2.17",
|
|
58
|
+
"@types/react-dom": "^19.2.3",
|
|
59
|
+
"cross-env": "^10.1.0",
|
|
60
|
+
"dumi": "^2.4.38",
|
|
61
|
+
"eslint": "^10.6.0",
|
|
62
|
+
"eslint-config-prettier": "^10.1.8",
|
|
63
|
+
"eslint-plugin-jest": "^29.15.4",
|
|
64
|
+
"eslint-plugin-react": "^7.37.5",
|
|
65
|
+
"eslint-plugin-react-hooks": "^7.1.1",
|
|
66
|
+
"father": "^4.6.24",
|
|
67
|
+
"gh-pages": "^6.3.0",
|
|
68
|
+
"glob": "^13.0.6",
|
|
69
|
+
"globals": "^17.7.0",
|
|
70
|
+
"husky": "^9.1.7",
|
|
71
|
+
"lint-staged": "^17.0.8",
|
|
72
|
+
"prettier": "^3.9.4",
|
|
73
|
+
"rc-test": "^7.1.3",
|
|
74
|
+
"react": "^19.2.7",
|
|
75
|
+
"react-dom": "^19.2.7",
|
|
76
|
+
"typescript": "^6.0.3",
|
|
77
|
+
"typescript-eslint": "^8.62.1"
|
|
67
78
|
},
|
|
68
79
|
"peerDependencies": {
|
|
69
80
|
"react": ">=16.9.0",
|
|
70
81
|
"react-dom": ">=16.9.0"
|
|
71
|
-
}
|
|
82
|
+
},
|
|
83
|
+
"publishConfig": {
|
|
84
|
+
"access": "public"
|
|
85
|
+
},
|
|
86
|
+
"lint-staged": {
|
|
87
|
+
"*": "prettier --write --ignore-unknown"
|
|
88
|
+
},
|
|
89
|
+
"types": "./es/index.d.ts"
|
|
72
90
|
}
|