1- import findDOMNode from 'rc-util/lib/Dom/findDOMNode ' ;
1+ import classNames from 'classnames ' ;
22import useMergedState from 'rc-util/lib/hooks/useMergedState' ;
33import KeyCode from 'rc-util/lib/KeyCode' ;
44import pickAttrs from 'rc-util/lib/pickAttrs' ;
55import React from 'react' ;
6- import classNames from 'classnames' ;
7-
86import type { StarProps } from './Star' ;
97import Star from './Star' ;
108import useRefs from './useRefs' ;
@@ -41,8 +39,6 @@ function Rate(props: RateProps, ref: React.Ref<RateRef>) {
4139 // Base
4240 prefixCls = 'rc-rate' ,
4341 className,
44- style,
45- id,
4642
4743 // Value
4844 defaultValue,
@@ -67,7 +63,6 @@ function Rate(props: RateProps, ref: React.Ref<RateRef>) {
6763 onFocus,
6864 onBlur,
6965 onKeyDown,
70- onMouseEnter,
7166 onMouseLeave,
7267
7368 ...restProps
@@ -102,7 +97,7 @@ function Rate(props: RateProps, ref: React.Ref<RateRef>) {
10297 const reverse = direction === 'rtl' ;
10398 let starValue = index + 1 ;
10499 if ( allowHalf ) {
105- const starEle = findDOMNode < HTMLElement > ( getStarRef ( index ) ) ;
100+ const starEle = getStarRef ( index ) ;
106101 const leftDis = getOffsetLeft ( starEle ) ;
107102 const width = starEle . clientWidth ;
108103 if ( reverse && x - leftDis > width / 2 ) {
@@ -219,8 +214,9 @@ function Rate(props: RateProps, ref: React.Ref<RateRef>) {
219214
220215 // =========================== Render ===========================
221216 // >>> Star
222- const starNodes = new Array ( count ) . fill ( 0 ) . map ( ( _ , index ) => {
223- return (
217+ const starNodes = new Array ( count )
218+ . fill ( 0 )
219+ . map ( ( item , index ) => (
224220 < Star
225221 ref = { setStarRef ( index ) }
226222 index = { index }
@@ -231,32 +227,30 @@ function Rate(props: RateProps, ref: React.Ref<RateRef>) {
231227 value = { hoverValue === null ? value : hoverValue }
232228 onClick = { onClick }
233229 onHover = { onHover }
234- key = { index }
230+ key = { item || index }
235231 character = { character }
236232 characterRender = { characterRender }
237233 focused = { focused }
238234 />
239- ) ;
235+ ) ) ;
236+
237+ const classString = classNames ( prefixCls , className , {
238+ [ `${ prefixCls } -disabled` ] : disabled ,
239+ [ `${ prefixCls } -rtl` ] : direction === 'rtl' ,
240240 } ) ;
241241
242242 // >>> Node
243243 return (
244244 < ul
245- className = { classNames ( prefixCls , className , {
246- [ `${ prefixCls } -disabled` ] : disabled ,
247- [ `${ prefixCls } -rtl` ] : direction === 'rtl' ,
248- } ) }
249- style = { style }
250- id = { id }
251- onMouseEnter = { onMouseEnter }
245+ className = { classString }
252246 onMouseLeave = { onMouseLeaveCallback }
253247 tabIndex = { disabled ? - 1 : tabIndex }
254248 onFocus = { disabled ? null : onInternalFocus }
255249 onBlur = { disabled ? null : onInternalBlur }
256250 onKeyDown = { disabled ? null : onInternalKeyDown }
257251 ref = { rateRef }
258252 role = "radiogroup"
259- { ...pickAttrs ( restProps , { aria : true , data : true } ) }
253+ { ...pickAttrs ( restProps , { aria : true , data : true , attr : true } ) }
260254 >
261255 { starNodes }
262256 </ ul >
0 commit comments