@@ -36,9 +36,16 @@ export const TextBoxLine = React.memo(React.forwardRef(function TextBoxLine(prop
36
36
return LineBaseController . propEquals ( prev , next ) ;
37
37
} ) ;
38
38
39
- export const PasswordLine = React . memo ( React . forwardRef ( function PasswordLine ( props : TextBoxLineProps , ref : React . Ref < TextBoxLineController > ) {
39
+ export class PasswordLineController extends ValueBaseController < TextBoxLineProps > {
40
+ init ( p : TextBoxLineProps ) {
41
+ super . init ( p ) ;
42
+ this . assertType ( "PasswordLine" , [ "string" ] ) ;
43
+ }
44
+ }
40
45
41
- const c = useController ( TextBoxLineController , props , ref ) ;
46
+ export const PasswordLine = React . memo ( React . forwardRef ( function PasswordLine ( props : TextBoxLineProps , ref : React . Ref < PasswordLineController > ) {
47
+
48
+ const c = useController ( PasswordLineController , props , ref ) ;
42
49
43
50
if ( c . isHidden )
44
51
return null ;
@@ -51,9 +58,16 @@ export const PasswordLine = React.memo(React.forwardRef(function PasswordLine(pr
51
58
return LineBaseController . propEquals ( prev , next ) ;
52
59
} ) ;
53
60
54
- export const GuidLine = React . memo ( React . forwardRef ( function GuidLine ( props : TextBoxLineProps , ref : React . Ref < TextBoxLineController > ) {
61
+ export class GuidLineController extends ValueBaseController < TextBoxLineProps > {
62
+ init ( p : TextBoxLineProps ) {
63
+ super . init ( p ) ;
64
+ this . assertType ( "TextBoxLine" , [ "Guid" ] ) ;
65
+ }
66
+ }
55
67
56
- const c = useController ( TextBoxLineController , props , ref ) ;
68
+ export const GuidLine = React . memo ( React . forwardRef ( function GuidLine ( props : TextBoxLineProps , ref : React . Ref < GuidLineController > ) {
69
+
70
+ const c = useController ( GuidLineController , props , ref ) ;
57
71
58
72
if ( c . isHidden )
59
73
return null ;
@@ -148,68 +162,3 @@ function internalTextBox(vl: TextBoxLineController, type: "password" | "color" |
148
162
</ FormGroup >
149
163
) ;
150
164
}
151
-
152
- export interface ColorTextBoxProps {
153
- value : string | null ;
154
- onChange : ( newValue : string | null ) => void ;
155
- formControlClass ?: string ;
156
- groupClass ?: string ;
157
- textValueHtmlAttributes ?: React . HTMLAttributes < HTMLInputElement > ;
158
- groupHtmlAttributes ?: React . HTMLAttributes < HTMLInputElement > ;
159
- innerRef ?: React . Ref < HTMLInputElement > ;
160
- }
161
-
162
- export function ColorTextBox ( p : ColorTextBoxProps ) {
163
-
164
- const [ text , setText ] = React . useState < string | undefined > ( undefined ) ;
165
-
166
- const value = text != undefined ? text : p . value != undefined ? p . value : "" ;
167
-
168
- return (
169
- < span { ...p . groupHtmlAttributes } className = { addClass ( p . groupHtmlAttributes , classes ( p . groupClass ) ) } >
170
- < input type = "text"
171
- autoComplete = "asdfasf" /*Not in https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofill*/
172
- { ...p . textValueHtmlAttributes }
173
- className = { addClass ( p . textValueHtmlAttributes , classes ( p . formControlClass ) ) }
174
- value = { value }
175
- onBlur = { handleOnBlur }
176
- onChange = { handleOnChange }
177
- onFocus = { handleOnFocus }
178
- ref = { p . innerRef } />
179
- < input type = "color"
180
- className = { classes ( p . formControlClass , "sf-color" ) }
181
- value = { value }
182
- onBlur = { handleOnBlur }
183
- onChange = { handleOnChange }
184
- />
185
- </ span > ) ;
186
-
187
- function handleOnFocus ( e : React . FocusEvent < any > ) {
188
- const input = e . currentTarget as HTMLInputElement ;
189
-
190
- input . setSelectionRange ( 0 , input . value != null ? input . value . length : 0 ) ;
191
-
192
- if ( p . textValueHtmlAttributes ?. onFocus )
193
- p . textValueHtmlAttributes . onFocus ( e ) ;
194
- } ;
195
-
196
- function handleOnBlur ( e : React . FocusEvent < any > ) {
197
-
198
- const input = e . currentTarget as HTMLInputElement ;
199
-
200
- var result = input . value == undefined || input . value . length == 0 ? null : input . value ;
201
-
202
- setText ( undefined ) ;
203
- if ( p . value != result )
204
- p . onChange ( result ) ;
205
- if ( p . textValueHtmlAttributes ?. onBlur )
206
- p . textValueHtmlAttributes . onBlur ( e ) ;
207
- }
208
-
209
- function handleOnChange ( e : React . SyntheticEvent < any > ) {
210
- const input = e . currentTarget as HTMLInputElement ;
211
- setText ( input . value ) ;
212
- if ( p . onChange )
213
- p . onChange ( input . value ) ;
214
- }
215
- }
0 commit comments