1
- import { default as Rate } from 'antd/es/rate' ;
2
- import styled , { css } from 'styled-components' ;
3
- import { Section , sectionNames } from 'lowcoder-design' ;
4
- import { NumberControl , BoolCodeControl } from '../controls/codeControl' ;
5
- import { BoolControl } from '../controls/boolControl' ;
6
- import {
7
- changeEvent ,
8
- eventHandlerControl ,
9
- } from '../controls/eventHandlerControl' ;
10
- import { LabelControl } from '../controls/labelControl' ;
11
- import { numberExposingStateControl } from '../controls/codeStateControl' ;
12
- import { UICompBuilder , withDefault } from '../generators' ;
13
- import {
14
- CommonNameConfig ,
15
- NameConfig ,
16
- withExposingConfigs ,
17
- } from '../generators/withExposing' ;
18
- import {
19
- formDataChildren ,
20
- FormDataPropertyView ,
21
- } from './formComp/formDataConstants' ;
22
- import { styleControl } from 'comps/controls/styleControl' ;
23
- import {
24
- AnimationStyle ,
25
- InputFieldStyle ,
26
- LabelStyle ,
27
- RatingStyle ,
28
- RatingStyleType ,
29
- } from 'comps/controls/styleControlConstants' ;
30
- import { migrateOldData } from 'comps/generators/simpleGenerators' ;
31
- import {
32
- disabledPropertyView ,
33
- hiddenPropertyView ,
34
- } from 'comps/utils/propertyUtils' ;
35
- import { trans } from 'i18n' ;
36
-
37
- import { useContext , useEffect , useRef } from 'react' ;
38
- import { EditorContext } from 'comps/editorState' ;
1
+ import { default as Rate } from "antd/es/rate" ;
2
+ import styled , { css } from "styled-components" ;
3
+ import { Section , sectionNames } from "lowcoder-design" ;
4
+ import { NumberControl , BoolCodeControl } from "../controls/codeControl" ;
5
+ import { BoolControl } from "../controls/boolControl" ;
6
+ import { changeEvent , eventHandlerControl } from "../controls/eventHandlerControl" ;
7
+ import { LabelControl } from "../controls/labelControl" ;
8
+ import { numberExposingStateControl } from "../controls/codeStateControl" ;
9
+ import { UICompBuilder , withDefault } from "../generators" ;
10
+ import { CommonNameConfig , NameConfig , withExposingConfigs } from "../generators/withExposing" ;
11
+ import { formDataChildren , FormDataPropertyView } from "./formComp/formDataConstants" ;
12
+ import { styleControl } from "comps/controls/styleControl" ;
13
+ import { AnimationStyle , InputFieldStyle , LabelStyle , RatingStyle , RatingStyleType } from "comps/controls/styleControlConstants" ;
14
+ import { migrateOldData } from "comps/generators/simpleGenerators" ;
15
+ import { disabledPropertyView , hiddenPropertyView } from "comps/utils/propertyUtils" ;
16
+ import { trans } from "i18n" ;
17
+
18
+ import { useContext , useEffect , useRef } from "react" ;
19
+ import { EditorContext } from "comps/editorState" ;
39
20
40
21
const EventOptions = [ changeEvent ] as const ;
41
22
42
23
/**
43
24
* Compatible with old data 2022-08-23
44
25
*/
45
26
function fixOldData ( oldData : any ) {
46
- if ( oldData && oldData . hasOwnProperty ( ' unChecked' ) ) {
27
+ if ( oldData && oldData . hasOwnProperty ( " unChecked" ) ) {
47
28
return {
48
29
label : oldData . label ,
49
30
checked : oldData . checked ,
@@ -73,9 +54,9 @@ const RatingBasicComp = (function () {
73
54
...formDataChildren ,
74
55
} ;
75
56
return new UICompBuilder ( childrenMap , ( props ) => {
76
- const defaultValue = { ...props . defaultValue } . value ;
77
- const value = { ...props . value } . value ;
78
- const changeRef = useRef ( false ) ;
57
+ const defaultValue = { ...props . defaultValue } . value ;
58
+ const value = { ...props . value } . value ;
59
+ const changeRef = useRef ( false )
79
60
80
61
useEffect ( ( ) => {
81
62
props . value . onChange ( defaultValue ) ;
@@ -84,15 +65,15 @@ const RatingBasicComp = (function () {
84
65
useEffect ( ( ) => {
85
66
if ( ! changeRef . current ) return ;
86
67
87
- props . onEvent ( ' change' ) ;
68
+ props . onEvent ( " change" ) ;
88
69
changeRef . current = false ;
89
70
} , [ value ] ) ;
90
71
91
72
return props . label ( {
92
73
style : props . style ,
93
74
labelStyle : props . labelStyle ,
94
- inputFieldStyle : props . inputFieldStyle ,
95
- animationStyle : props . animationStyle ,
75
+ inputFieldStyle :props . inputFieldStyle ,
76
+ animationStyle :props . animationStyle ,
96
77
children : (
97
78
< RateStyled
98
79
count = { props . max }
@@ -112,40 +93,33 @@ const RatingBasicComp = (function () {
112
93
return (
113
94
< >
114
95
< Section name = { sectionNames . basic } >
115
- { children . defaultValue . propertyView ( {
116
- label : trans ( 'prop.defaultValue' ) ,
117
- } ) }
96
+ { children . defaultValue . propertyView ( { label : trans ( "prop.defaultValue" ) } ) }
118
97
{ children . max . propertyView ( {
119
- label : trans ( ' rating.max' ) ,
98
+ label : trans ( " rating.max" ) ,
120
99
} ) }
121
100
</ Section >
122
101
123
102
< FormDataPropertyView { ...children } />
124
103
125
- { [ 'logic' , 'both' ] . includes (
126
- useContext ( EditorContext ) . editorModeStatus
127
- ) && (
128
- < >
129
- < Section name = { sectionNames . interaction } >
130
- { children . onEvent . getPropertyView ( ) }
131
- { disabledPropertyView ( children ) }
132
- { hiddenPropertyView ( children ) }
133
- </ Section >
104
+ { [ "logic" , "both" ] . includes ( useContext ( EditorContext ) . editorModeStatus ) && (
105
+ < > < Section name = { sectionNames . interaction } >
106
+ { children . onEvent . getPropertyView ( ) }
107
+ { disabledPropertyView ( children ) }
108
+ { hiddenPropertyView ( children ) }
109
+ </ Section >
134
110
< Section name = { sectionNames . advanced } >
135
111
{ children . allowHalf . propertyView ( {
136
- label : trans ( ' rating.allowHalf' ) ,
112
+ label : trans ( " rating.allowHalf" ) ,
137
113
} ) }
138
114
</ Section >
139
115
</ >
140
116
) }
141
117
142
- { [ ' layout' , ' both' ] . includes (
143
- useContext ( EditorContext ) . editorModeStatus
144
- ) && children . label . getPropertyView ( ) }
118
+ { [ " layout" , " both" ] . includes ( useContext ( EditorContext ) . editorModeStatus ) && (
119
+ children . label . getPropertyView ( )
120
+ ) }
145
121
146
- { [ 'layout' , 'both' ] . includes (
147
- useContext ( EditorContext ) . editorModeStatus
148
- ) && (
122
+ { [ "layout" , "both" ] . includes ( useContext ( EditorContext ) . editorModeStatus ) && (
149
123
< >
150
124
< Section name = { sectionNames . style } >
151
125
{ children . style . getPropertyView ( ) }
@@ -168,8 +142,8 @@ const RatingBasicComp = (function () {
168
142
} ) ( ) ;
169
143
170
144
export const RatingComp = withExposingConfigs ( RatingBasicComp , [
171
- new NameConfig ( ' value' , trans ( ' export.ratingValueDesc' ) ) ,
172
- new NameConfig ( ' max' , trans ( ' export.ratingMaxDesc' ) ) ,
145
+ new NameConfig ( " value" , trans ( " export.ratingValueDesc" ) ) ,
146
+ new NameConfig ( " max" , trans ( " export.ratingMaxDesc" ) ) ,
173
147
...CommonNameConfig ,
174
148
] ) ;
175
149
@@ -191,6 +165,6 @@ const getStyle = (style: RatingStyleType) => {
191
165
` ;
192
166
} ;
193
167
194
- export const RateStyled = styled ( Rate ) < { $style : RatingStyleType } > `
168
+ export const RateStyled = styled ( Rate ) < { $style : RatingStyleType } > `
195
169
${ ( props ) => props . $style && getStyle ( props . $style ) }
196
170
` ;
0 commit comments