@yorkjs/hive-ui 2.1.7 → 2.1.9
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/package.json
CHANGED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
.progress
|
|
2
|
+
display flex
|
|
3
|
+
align-items center
|
|
4
|
+
position relative
|
|
5
|
+
width 100%
|
|
6
|
+
|
|
7
|
+
.track
|
|
8
|
+
flex auto
|
|
9
|
+
position relative
|
|
10
|
+
border-radius 6PX
|
|
11
|
+
|
|
12
|
+
.fill
|
|
13
|
+
height 100%
|
|
14
|
+
display flex
|
|
15
|
+
flex-direction column
|
|
16
|
+
justify-content center
|
|
17
|
+
transition all 0.4s
|
|
18
|
+
border-radius 6PX
|
|
19
|
+
position relative
|
|
20
|
+
|
|
21
|
+
.shimmer
|
|
22
|
+
content ''
|
|
23
|
+
position absolute
|
|
24
|
+
top 0
|
|
25
|
+
left 0
|
|
26
|
+
right 0
|
|
27
|
+
bottom 0
|
|
28
|
+
border-radius 6PX
|
|
29
|
+
animation shimmer 2s ease-in-out infinite
|
|
30
|
+
|
|
31
|
+
@keyframes shimmer
|
|
32
|
+
0%
|
|
33
|
+
background rgba(255, 255, 255, 0.1)
|
|
34
|
+
width 0
|
|
35
|
+
20%
|
|
36
|
+
background rgba(255, 255, 255, 0.5)
|
|
37
|
+
width 0
|
|
38
|
+
100%
|
|
39
|
+
background rgba(255, 255, 255, 0)
|
|
40
|
+
width 100%
|
|
41
|
+
|
|
42
|
+
.text
|
|
43
|
+
display flex
|
|
44
|
+
align-items center
|
|
45
|
+
position absolute
|
|
46
|
+
top 50%
|
|
47
|
+
transform translateY(-50%)
|
|
48
|
+
transition all 0.4s
|
|
49
|
+
|
|
50
|
+
.textOutside
|
|
51
|
+
display flex
|
|
52
|
+
align-items center
|
|
53
|
+
margin-left 8PX
|
|
54
|
+
|
|
55
|
+
.textInner
|
|
56
|
+
display flex
|
|
57
|
+
align-items center
|
|
58
|
+
padding 4PX 10PX
|
|
59
|
+
font-size 12PX
|
|
60
|
+
line-height 1
|
|
61
|
+
color #fff
|
|
62
|
+
white-space nowrap
|
|
63
|
+
border-radius 20PX
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import React, { FC, useMemo } from 'react'
|
|
2
|
+
import { View, Text } from '@tarojs/components'
|
|
3
|
+
|
|
4
|
+
import { formatClassNames } from '../../util/function'
|
|
5
|
+
|
|
6
|
+
import styles from './index.module.styl'
|
|
7
|
+
|
|
8
|
+
export interface ProgressProps {
|
|
9
|
+
/**
|
|
10
|
+
* 百分比
|
|
11
|
+
* @default 0
|
|
12
|
+
*/
|
|
13
|
+
percent?: number
|
|
14
|
+
/**
|
|
15
|
+
* 进度条背景颜色
|
|
16
|
+
* @default #f3f3f3
|
|
17
|
+
*/
|
|
18
|
+
background?: string
|
|
19
|
+
/**
|
|
20
|
+
* 进度条线条颜色
|
|
21
|
+
* @default linear-gradient(135deg, #fa2c19 0%, #fa6419 100%)
|
|
22
|
+
*/
|
|
23
|
+
color?: string
|
|
24
|
+
/**
|
|
25
|
+
* 进度条宽度
|
|
26
|
+
*/
|
|
27
|
+
strokeWidth?: string
|
|
28
|
+
/**
|
|
29
|
+
* 是否显示文字内容
|
|
30
|
+
* @default false
|
|
31
|
+
*/
|
|
32
|
+
showText?: boolean
|
|
33
|
+
/**
|
|
34
|
+
* 百分比文字是否外显(在进度条右侧)
|
|
35
|
+
* @default false
|
|
36
|
+
*/
|
|
37
|
+
textOutside?: boolean
|
|
38
|
+
/**
|
|
39
|
+
* 是否展示动画效果
|
|
40
|
+
* @default false
|
|
41
|
+
*/
|
|
42
|
+
animated?: boolean
|
|
43
|
+
/**
|
|
44
|
+
* 自定义类名
|
|
45
|
+
*/
|
|
46
|
+
className?: string
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const Progress: FC<ProgressProps> = ({
|
|
50
|
+
percent = 0,
|
|
51
|
+
background = 'var(--containerInner)',
|
|
52
|
+
color = 'linear-gradient(135deg, #fa2c19 0%, #fa6419 100%)',
|
|
53
|
+
strokeWidth = 10,
|
|
54
|
+
showText = false,
|
|
55
|
+
textOutside = false,
|
|
56
|
+
animated = false,
|
|
57
|
+
className = '',
|
|
58
|
+
}) => {
|
|
59
|
+
// 限制百分比在 0-100 之间,最多保留两位小数
|
|
60
|
+
const validPercent = useMemo(() => {
|
|
61
|
+
const p = Math.min(100, Math.max(0, percent))
|
|
62
|
+
return Math.round(p * 100) / 100
|
|
63
|
+
}, [percent])
|
|
64
|
+
|
|
65
|
+
const trackStyle: React.CSSProperties = {
|
|
66
|
+
height: `${strokeWidth}px`,
|
|
67
|
+
backgroundColor: background,
|
|
68
|
+
borderRadius: `${strokeWidth}px`,
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const fillStyle: React.CSSProperties = {
|
|
72
|
+
width: `${validPercent}%`,
|
|
73
|
+
height: `${strokeWidth}px`,
|
|
74
|
+
borderRadius: `${strokeWidth}px`,
|
|
75
|
+
background: color,
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const textStyle: React.CSSProperties = textOutside
|
|
79
|
+
? { marginLeft: '8px' }
|
|
80
|
+
: { right: `${100 - validPercent}%` }
|
|
81
|
+
|
|
82
|
+
const textInnerStyle: React.CSSProperties = textOutside
|
|
83
|
+
? { color: 'var(--textTitle' }
|
|
84
|
+
: { background: color }
|
|
85
|
+
|
|
86
|
+
return (
|
|
87
|
+
<View
|
|
88
|
+
className={
|
|
89
|
+
formatClassNames(
|
|
90
|
+
styles.progress,
|
|
91
|
+
className
|
|
92
|
+
)
|
|
93
|
+
}
|
|
94
|
+
>
|
|
95
|
+
<View
|
|
96
|
+
className={styles.track}
|
|
97
|
+
style={trackStyle}
|
|
98
|
+
>
|
|
99
|
+
<View className={styles.fill} style={fillStyle}>
|
|
100
|
+
{
|
|
101
|
+
animated
|
|
102
|
+
?
|
|
103
|
+
<View className={styles.shimmer} />
|
|
104
|
+
: null
|
|
105
|
+
}
|
|
106
|
+
</View>
|
|
107
|
+
|
|
108
|
+
{
|
|
109
|
+
(showText && !textOutside)
|
|
110
|
+
? (
|
|
111
|
+
<View
|
|
112
|
+
className={styles.text}
|
|
113
|
+
style={textStyle}
|
|
114
|
+
>
|
|
115
|
+
<Text
|
|
116
|
+
className={styles.textInner}
|
|
117
|
+
style={textInnerStyle}
|
|
118
|
+
>
|
|
119
|
+
{validPercent}%
|
|
120
|
+
</Text>
|
|
121
|
+
</View>
|
|
122
|
+
)
|
|
123
|
+
: null
|
|
124
|
+
}
|
|
125
|
+
</View>
|
|
126
|
+
|
|
127
|
+
{
|
|
128
|
+
(showText && textOutside)
|
|
129
|
+
? (
|
|
130
|
+
<View
|
|
131
|
+
className={styles.textOutside}
|
|
132
|
+
style={textStyle}
|
|
133
|
+
>
|
|
134
|
+
<Text
|
|
135
|
+
className={styles.textInner}
|
|
136
|
+
style={textInnerStyle}
|
|
137
|
+
>
|
|
138
|
+
{validPercent}%
|
|
139
|
+
</Text>
|
|
140
|
+
</View>
|
|
141
|
+
)
|
|
142
|
+
: null
|
|
143
|
+
}
|
|
144
|
+
</View>
|
|
145
|
+
)
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
export default React.memo(Progress)
|
|
@@ -6,12 +6,10 @@ import { formatClassNames } from '../../util/function'
|
|
|
6
6
|
import styles from './index.module.styl'
|
|
7
7
|
|
|
8
8
|
export interface TableColumn<T extends object> {
|
|
9
|
-
/**
|
|
10
|
-
|
|
9
|
+
/** 对应数据字段;同时作为列标识 */
|
|
10
|
+
dataIndex: keyof T
|
|
11
11
|
/** 列标题,支持自定义节点 */
|
|
12
12
|
title: React.ReactNode
|
|
13
|
-
/** 对应数据字段;不传时仅通过 render 展示 */
|
|
14
|
-
dataIndex?: keyof T
|
|
15
13
|
/** 列宽度;数字按 PX 处理,字符串原样使用 */
|
|
16
14
|
width?: number | string
|
|
17
15
|
/**
|
|
@@ -20,7 +18,7 @@ export interface TableColumn<T extends object> {
|
|
|
20
18
|
* @param record 当前行数据
|
|
21
19
|
* @param index 当前行索引
|
|
22
20
|
*/
|
|
23
|
-
render?: (value: T[keyof T]
|
|
21
|
+
render?: (value: T[keyof T], record: T, index: number) => React.ReactNode
|
|
24
22
|
}
|
|
25
23
|
|
|
26
24
|
export interface TableProps<T extends object> {
|
|
@@ -118,7 +116,7 @@ function Table<T extends object>(props: TableProps<T>) {
|
|
|
118
116
|
{
|
|
119
117
|
columns.map(column => (
|
|
120
118
|
<View
|
|
121
|
-
key={column.
|
|
119
|
+
key={String(column.dataIndex)}
|
|
122
120
|
className={styles['table-cell']}
|
|
123
121
|
style={getCellStyle(column.width)}
|
|
124
122
|
>
|
|
@@ -140,16 +138,14 @@ function Table<T extends object>(props: TableProps<T>) {
|
|
|
140
138
|
>
|
|
141
139
|
{
|
|
142
140
|
columns.map(column => {
|
|
143
|
-
const value = column.dataIndex
|
|
144
|
-
? record[column.dataIndex]
|
|
145
|
-
: undefined
|
|
141
|
+
const value = record[column.dataIndex]
|
|
146
142
|
const content = column.render
|
|
147
143
|
? column.render(value, record, rowIndex)
|
|
148
144
|
: value
|
|
149
145
|
|
|
150
146
|
return (
|
|
151
147
|
<View
|
|
152
|
-
key={`${currentRowKey}-${column.
|
|
148
|
+
key={`${currentRowKey}-${String(column.dataIndex)}`}
|
|
153
149
|
className={styles['table-cell']}
|
|
154
150
|
style={getCellStyle(column.width)}
|
|
155
151
|
>
|
package/src/index.ts
CHANGED
|
@@ -14,6 +14,7 @@ export { default as RemoteImage } from './components/RemoteImage'
|
|
|
14
14
|
export { default as Alert } from './components/Alert'
|
|
15
15
|
export { default as Switch } from './components/Switch'
|
|
16
16
|
export { default as SimpleModal } from './components/SimpleModal'
|
|
17
|
+
export { default as Progress } from './components/Progress'
|
|
17
18
|
|
|
18
19
|
export { default as FlowItem } from './item/FlowItem'
|
|
19
20
|
export { default as ListItem } from './item/ListItem'
|