@@ -17,6 +17,10 @@ import { trans } from "i18n";
17
17
18
18
import { useContext , useEffect , useRef } from "react" ;
19
19
import { EditorContext } from "comps/editorState" ;
20
+ import { CompTypeContext } from "../utils/compTypeContext" ;
21
+ import { ThemeContext } from "../utils/themeContext" ;
22
+ import { setInitialCompStyles } from "../utils/themeUtil" ;
23
+
20
24
21
25
const EventOptions = [ changeEvent ] as const ;
22
26
@@ -43,20 +47,37 @@ const RatingBasicComp = (function () {
43
47
allowHalf : BoolControl ,
44
48
disabled : BoolCodeControl ,
45
49
onEvent : eventHandlerControl ( EventOptions ) ,
46
- style : withDefault ( styleControl ( InputFieldStyle ) , { background : 'transparent' } ) ,
47
- animationStyle : styleControl ( AnimationStyle ) ,
50
+ style : styleControl ( InputFieldStyle , 'style' ) ,
51
+ animationStyle : styleControl ( AnimationStyle , 'animationStyle' ) ,
48
52
labelStyle : styleControl (
49
53
LabelStyle . filter (
50
54
( style ) => [ 'accent' , 'validate' ] . includes ( style . name ) === false
51
- )
55
+ ) ,
56
+ 'labelStyle' ,
52
57
) ,
53
- inputFieldStyle : migrateOldData ( styleControl ( RatingStyle ) , fixOldData ) ,
58
+ inputFieldStyle : migrateOldData ( styleControl ( RatingStyle , 'inputFieldStyle' ) , fixOldData ) ,
54
59
...formDataChildren ,
55
60
} ;
56
- return new UICompBuilder ( childrenMap , ( props ) => {
61
+ return new UICompBuilder ( childrenMap , ( props , dispatch ) => {
57
62
const defaultValue = { ...props . defaultValue } . value ;
58
63
const value = { ...props . value } . value ;
59
- const changeRef = useRef ( false )
64
+ const changeRef = useRef ( false ) ;
65
+ const theme = useContext ( ThemeContext ) ;
66
+ const compType = useContext ( CompTypeContext ) ;
67
+ const compTheme = theme ?. theme ?. components ?. [ compType ] ;
68
+
69
+ const styleProps : Record < string , any > = { } ;
70
+ [ 'style' , 'animationStyle' , 'labelStyle' , 'inputFieldStyle' ] . forEach ( ( key : string ) => {
71
+ styleProps [ key ] = ( props as any ) [ key ] ;
72
+ } ) ;
73
+
74
+ useEffect ( ( ) => {
75
+ setInitialCompStyles ( {
76
+ dispatch,
77
+ compTheme,
78
+ styleProps,
79
+ } ) ;
80
+ } , [ ] ) ;
60
81
61
82
useEffect ( ( ) => {
62
83
props . value . onChange ( defaultValue ) ;
0 commit comments