@rc-component/progress 1.0.1 → 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 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
- # @rc-component/progress
2
-
3
- Progress Bar.
4
-
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] [![npm download][download-image]][download-url] [![bundle size][bundlephobia-image]][bundlephobia-url]
6
-
7
- [npm-image]: http://img.shields.io/npm/v/@rc-component/progress.svg?style=flat-square
8
- [npm-url]: http://npmjs.org/package/@rc-component/progress
9
- [github-actions-image]: https://github.com/react-component/progress/workflows/CI/badge.svg
10
- [github-actions-url]: https://github.com/react-component/progress/actions
11
- [circleci-image]: https://img.shields.io/circleci/react-component/progress/master?style=flat-square
12
- [circleci-url]: https://circleci.com/gh/react-component/progress
13
- [coveralls-image]: https://img.shields.io/coveralls/react-component/progress.svg?style=flat-square
14
- [coveralls-url]: https://coveralls.io/r/react-component/progress?branch=master
15
- [david-url]: https://david-dm.org/react-component/progress
16
- [david-image]: https://david-dm.org/react-component/progress/status.svg?style=flat-square
17
- [david-dev-url]: https://david-dm.org/react-component/progress?type=dev
18
- [david-dev-image]: https://david-dm.org/react-component/progress/dev-status.svg?style=flat-square
19
- [download-image]: https://img.shields.io/npm/dm/@rc-component/progress.svg?style=flat-square
20
- [download-url]: https://npmjs.org/package/@rc-component/progress
21
- [bundlephobia-url]: https://bundlephobia.com/result?p=@rc-component/progress
22
- [bundlephobia-image]: https://badgen.net/bundlephobia/minzip/@rc-component/progress
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
- [![@rc-component/progress](https://nodei.co/npm/@rc-component/progress.png)](https://npmjs.org/package/@rc-component/progress)
27
+ ```bash
28
+ npm install @rc-component/progress
29
+ ```
39
30
 
40
31
  ## Usage
41
32
 
42
- ```js
43
- import { Line, Circle } from '@rc-component/progress';
44
-
33
+ ```tsx | pure
34
+ import { Circle, Line } from '@rc-component/progress';
45
35
  export default () => (
46
36
  <>
47
- <Line percent={10} strokeWidth={4} strokeColor="#D3D3D3" />
48
- <Circle percent={10} strokeWidth={4} strokeColor="#D3D3D3" />
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
- ## Compatibility
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
- | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/edge/edge_48x48.png" alt="IE / Edge" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)<br>IE / Edge | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/firefox/firefox_48x48.png" alt="Firefox" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)<br>Firefox | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/chrome/chrome_48x48.png" alt="Chrome" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)<br>Chrome | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/safari/safari_48x48.png" alt="Safari" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)<br>Safari | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/electron/electron_48x48.png" alt="Electron" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)<br>Electron |
56
- | --- | --- | --- | --- | --- |
57
- | IE11, Edge | last 2 versions | last 2 versions | last 2 versions | last 2 versions |
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
- ## API
68
+ ## Examples
60
69
 
61
- ### props
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
- npm install --save @rc-component/progress
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.
@@ -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) čŽ¸å¯č¯å‘å¸ƒã€‚
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import classNames from 'classnames';
2
+ import { clsx } from 'clsx';
3
3
  const Block = ({
4
4
  bg,
5
5
  children
@@ -37,7 +37,7 @@ const PtgCircle = /*#__PURE__*/React.forwardRef((props, ref) => {
37
37
  // ========================== Circle ==========================
38
38
  const halfSize = size / 2;
39
39
  const circleNode = /*#__PURE__*/React.createElement("circle", {
40
- className: classNames(`${prefixCls}-circle-path`, className),
40
+ className: clsx(`${prefixCls}-circle-path`, className),
41
41
  r: radius,
42
42
  cx: halfSize,
43
43
  cy: halfSize,
@@ -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
- import cls from 'classnames';
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";
@@ -107,7 +107,7 @@ const Circle = props => {
107
107
  stackPtg += (perimeterWithoutGap - circleStyleForStack.strokeDashoffset + stepGap) * 100 / perimeterWithoutGap;
108
108
  return /*#__PURE__*/React.createElement("circle", {
109
109
  key: index,
110
- className: cls(`${prefixCls}-circle-path`, classNames.track),
110
+ className: clsx(`${prefixCls}-circle-path`, classNames.track),
111
111
  r: radius,
112
112
  cx: halfSize,
113
113
  cy: halfSize,
@@ -125,7 +125,7 @@ const Circle = props => {
125
125
  });
126
126
  };
127
127
  return /*#__PURE__*/React.createElement("svg", _extends({
128
- className: cls(`${prefixCls}-circle`, classNames.root, className),
128
+ className: clsx(`${prefixCls}-circle`, classNames.root, className),
129
129
  viewBox: `0 0 ${VIEW_BOX_SIZE} ${VIEW_BOX_SIZE}`,
130
130
  style: {
131
131
  ...styles.root,
@@ -134,7 +134,7 @@ const Circle = props => {
134
134
  id: id,
135
135
  role: "presentation"
136
136
  }, restProps), !stepCount && /*#__PURE__*/React.createElement("circle", {
137
- className: cls(`${prefixCls}-circle-rail`, classNames.rail),
137
+ className: clsx(`${prefixCls}-circle-rail`, classNames.rail),
138
138
  r: radius,
139
139
  cx: halfSize,
140
140
  cy: halfSize,
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
- import classNames from 'classnames';
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
- className: classNames(`${prefixCls}-line`, className),
50
+ id: id,
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
- let dashPercent = 1;
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;
@@ -5,8 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
  var React = _interopRequireWildcard(require("react"));
8
- var _classnames = _interopRequireDefault(require("classnames"));
9
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
8
+ var _clsx = require("clsx");
10
9
  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); }
11
10
  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; }
12
11
  const Block = ({
@@ -46,7 +45,7 @@ const PtgCircle = /*#__PURE__*/React.forwardRef((props, ref) => {
46
45
  // ========================== Circle ==========================
47
46
  const halfSize = size / 2;
48
47
  const circleNode = /*#__PURE__*/React.createElement("circle", {
49
- className: (0, _classnames.default)(`${prefixCls}-circle-path`, className),
48
+ className: (0, _clsx.clsx)(`${prefixCls}-circle-path`, className),
50
49
  r: radius,
51
50
  cx: halfSize,
52
51
  cy: halfSize,
@@ -5,11 +5,11 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
  var React = _interopRequireWildcard(require("react"));
8
- var _classnames = _interopRequireDefault(require("classnames"));
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 _util = require("./util");
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 = _util.VIEW_BOX_SIZE / 2;
46
- const mergedId = (0, _useId.default)(id);
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, _util.getCircleStyle)(perimeter, perimeterWithoutGap, 0, 100, rotateDeg, gapDegree, gapPosition, railColor, mergedStrokeLinecap, strokeWidth);
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, _util.getCircleStyle)(perimeter, perimeterWithoutGap, stackPtg, ptg, rotateDeg, gapDegree, gapPosition, color, mergedStrokeLinecap, strokeWidth);
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: _util.VIEW_BOX_SIZE
103
+ size: _util2.VIEW_BOX_SIZE
104
104
  });
105
105
  }).reverse();
106
106
  };
@@ -112,11 +112,11 @@ 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, _util.getCircleStyle)(perimeter, perimeterWithoutGap, stackPtg, stepPtg, rotateDeg, gapDegree, gapPosition, color, 'butt', strokeWidth, stepGap);
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,
119
- className: (0, _classnames.default)(`${prefixCls}-circle-path`, classNames.track),
119
+ className: (0, _clsx.clsx)(`${prefixCls}-circle-path`, classNames.track),
120
120
  r: radius,
121
121
  cx: halfSize,
122
122
  cy: halfSize,
@@ -134,8 +134,8 @@ const Circle = props => {
134
134
  });
135
135
  };
136
136
  return /*#__PURE__*/React.createElement("svg", _extends({
137
- className: (0, _classnames.default)(`${prefixCls}-circle`, classNames.root, className),
138
- viewBox: `0 0 ${_util.VIEW_BOX_SIZE} ${_util.VIEW_BOX_SIZE}`,
137
+ className: (0, _clsx.clsx)(`${prefixCls}-circle`, classNames.root, className),
138
+ viewBox: `0 0 ${_util2.VIEW_BOX_SIZE} ${_util2.VIEW_BOX_SIZE}`,
139
139
  style: {
140
140
  ...styles.root,
141
141
  ...style
@@ -143,7 +143,7 @@ const Circle = props => {
143
143
  id: id,
144
144
  role: "presentation"
145
145
  }, restProps), !stepCount && /*#__PURE__*/React.createElement("circle", {
146
- className: (0, _classnames.default)(`${prefixCls}-circle-rail`, classNames.rail),
146
+ className: (0, _clsx.clsx)(`${prefixCls}-circle-rail`, classNames.rail),
147
147
  r: radius,
148
148
  cx: halfSize,
149
149
  cy: halfSize,
package/lib/Line.js CHANGED
@@ -5,10 +5,10 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
  var React = _interopRequireWildcard(require("react"));
8
- var _classnames = _interopRequireDefault(require("classnames"));
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, _useId.default)(id);
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
- className: (0, _classnames.default)(`${prefixCls}-line`, className),
59
+ id: id,
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
- let dashPercent = 1;
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`,
@@ -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.1",
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": "http://github.com/react-component/progress",
11
+ "homepage": "https://react-component.github.io/progress",
12
12
  "repository": {
13
13
  "type": "git",
14
- "url": "git@github.com:react-component/progress.git"
14
+ "url": "https://github.com/react-component/progress.git"
15
15
  },
16
16
  "bugs": {
17
- "url": "http://github.com/react-component/progress/issues"
17
+ "url": "https://github.com/react-component/progress/issues"
18
18
  },
19
19
  "license": "MIT",
20
20
  "main": "./lib/index",
@@ -25,49 +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 docs:build && npm run docs:deploy",
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 now-build && father doc deploy",
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 \"**/*.{ts,tsx,js,jsx,json,md}\"",
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
+ },
42
+ "dependencies": {
43
+ "@rc-component/util": "^1.11.1",
44
+ "clsx": "^2.1.1"
45
+ },
46
+ "devDependencies": {
47
+ "@eslint/js": "^10.0.1",
48
+ "@eslint/compat": "^2.1.0",
49
+ "@rc-component/father-plugin": "^2.2.0",
50
+ "@rc-component/np": "^1.0.4",
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"
41
78
  },
42
79
  "peerDependencies": {
43
80
  "react": ">=16.9.0",
44
81
  "react-dom": ">=16.9.0"
45
82
  },
46
- "dependencies": {
47
- "@rc-component/util": "^1.2.1",
48
- "classnames": "^2.2.6"
83
+ "publishConfig": {
84
+ "access": "public"
49
85
  },
50
- "devDependencies": {
51
- "@rc-component/father-plugin": "^2.0.4",
52
- "@rc-component/np": "^1.0.4",
53
- "@testing-library/react": "^13.0.0",
54
- "@types/classnames": "^2.2.9",
55
- "@types/jest": "^29.4.0",
56
- "@types/keyv": "3.1.4",
57
- "@types/react": "^18.0.9",
58
- "@types/react-dom": "^18.0.3",
59
- "@umijs/fabric": "^3.0.0",
60
- "cross-env": "^7.0.0",
61
- "dumi": "^2.0.0",
62
- "eslint": "^8.57.0",
63
- "eslint-plugin-jest": "^27.6.0",
64
- "eslint-plugin-unicorn": "^50.0.1",
65
- "father": "^4.0.0",
66
- "glob": "^8.0.1",
67
- "prettier": "^3.1.1",
68
- "rc-test": "^7.0.15",
69
- "react": "^18.0.0",
70
- "react-dom": "^18.0.0",
71
- "typescript": "^5.0.0"
72
- }
86
+ "lint-staged": {
87
+ "*": "prettier --write --ignore-unknown"
88
+ },
89
+ "types": "./es/index.d.ts"
73
90
  }