11
11
12
12
import { css , keyframes } from 'emotion'
13
13
import CBox from '../CBox'
14
- import { generateStripe , valueToPercent , forwardProps } from '../utils'
15
- import { baseProps } from '../config/props'
14
+ import { generateStripe , valueToPercent , createStyledAttrsMixin } from '../utils'
16
15
17
16
const stripe = keyframes ( {
18
17
from : { backgroundPosition : '1rem 0' } ,
@@ -39,18 +38,20 @@ const progressbarSizes = {
39
38
*/
40
39
const CProgressLabel = {
41
40
name : 'CProgressLabel' ,
42
- props : baseProps ,
43
- render ( h ) {
41
+ functional : true ,
42
+ render ( h , { data , slots , ... rest } ) {
44
43
return h ( CBox , {
44
+ ...rest ,
45
45
props : {
46
- textAlign : 'center' ,
47
- width : '100%' ,
48
- ...forwardProps ( this . $props )
46
+ as : data . attrs . as
49
47
} ,
50
48
attrs : {
49
+ textAlign : 'center' ,
50
+ width : '100%' ,
51
+ ...data . attrs ,
51
52
'data-chakra-component' : 'CProgressLabel'
52
53
}
53
- } , this . $ slots. default )
54
+ } , slots ( ) . default )
54
55
}
55
56
}
56
57
@@ -64,23 +65,22 @@ const CProgressLabel = {
64
65
*/
65
66
const CProgressTrack = {
66
67
name : 'CProgressTrack' ,
68
+ functional : true ,
67
69
props : {
68
- ...baseProps ,
69
70
size : [ String , Number , Array ]
70
71
} ,
71
- render ( h ) {
72
+ render ( h , { props , slots , data , ... rest } ) {
72
73
return h ( CBox , {
73
- props : {
74
+ ...rest ,
75
+ attrs : {
74
76
pos : 'relative' ,
75
- height : progressbarSizes [ this . size || 'md' ] ,
77
+ height : progressbarSizes [ props . size || 'md' ] ,
76
78
overflow : 'hidden' ,
77
79
w : '100%' ,
78
- ...forwardProps ( this . $props )
79
- } ,
80
- attrs : {
80
+ ...data . attrs ,
81
81
'data-chakra-component' : 'CProgressTrack'
82
82
}
83
- } , this . $ slots. default )
83
+ } , slots ( ) . default )
84
84
}
85
85
}
86
86
@@ -93,9 +93,8 @@ const CProgressTrack = {
93
93
* @see Docs https://vue.chakra-ui.com/progress
94
94
*/
95
95
const CProgressIndicator = {
96
- name : 'CProgressIndicator' ,
96
+ mixins : [ createStyledAttrsMixin ( 'CProgressIndicator' ) ] ,
97
97
props : {
98
- ...baseProps ,
99
98
isIndeterminate : Boolean ,
100
99
min : Number ,
101
100
max : Number ,
@@ -104,23 +103,27 @@ const CProgressIndicator = {
104
103
computed : {
105
104
percent ( ) {
106
105
return valueToPercent ( this . value , this . min , this . max )
106
+ } ,
107
+ componentStyles ( ) {
108
+ return {
109
+ height : '100%' ,
110
+ transition : 'all 0.3s' ,
111
+ width : `${ this . percent } %`
112
+ }
107
113
}
108
114
} ,
109
115
render ( h ) {
110
- return h ( CBox , {
111
- props : {
112
- height : '100%' ,
113
- transition : 'all 0.3s' ,
114
- width : `${ this . percent } %` ,
115
- ...forwardProps ( this . $props )
116
- } ,
116
+ return h ( this . as || 'div' , {
117
+ class : [ this . className ] ,
117
118
attrs : {
119
+ ...this . computedAttrs ,
118
120
'aria-valuemax' : this . max ,
119
121
'aria-valuemin' : this . min ,
120
122
'aria-valuenow' : this . isIndeterminate ? null : this . value ,
121
123
role : 'progressbar' ,
122
124
'data-chakra-component' : 'CProgressIndicator'
123
- }
125
+ } ,
126
+ on : this . computedListeners
124
127
} , this . $slots . default )
125
128
}
126
129
}
@@ -135,9 +138,9 @@ const CProgressIndicator = {
135
138
*/
136
139
const CProgress = {
137
140
name : 'CProgress' ,
141
+ inheritAttrs : false ,
138
142
inject : [ '$chakraColorMode' ] ,
139
143
props : {
140
- ...baseProps ,
141
144
color : {
142
145
type : String ,
143
146
default : 'blue'
@@ -201,13 +204,13 @@ const CProgress = {
201
204
202
205
return h ( CProgressTrack , {
203
206
props : {
204
- size : this . size ,
205
- bg : trackColor [ this . colorMode ] ,
206
- borderRadius : _borderRadius ,
207
- ...forwardProps ( this . $props )
207
+ size : this . size
208
208
} ,
209
209
attrs : {
210
- 'data-chakra-component' : 'CProgress'
210
+ bg : trackColor [ this . colorMode ] ,
211
+ borderRadius : _borderRadius ,
212
+ 'data-chakra-component' : 'CProgress' ,
213
+ ...this . $attrs
211
214
}
212
215
} , [
213
216
h ( CProgressIndicator , {
@@ -218,7 +221,9 @@ const CProgress = {
218
221
props : {
219
222
min : this . min ,
220
223
max : this . max ,
221
- value : this . value ,
224
+ value : this . value
225
+ } ,
226
+ attrs : {
222
227
bg : indicatorColor [ this . colorMode ] ,
223
228
borderRadius : this . __borderRadius ,
224
229
...this . isIndeterminate && {
0 commit comments