@@ -59,6 +59,7 @@ import { timeZoneOptions } from "./timeZone";
59
59
const EventOptions = [ changeEvent , focusEvent , blurEvent ] as const ;
60
60
61
61
const validationChildren = {
62
+ showValidationWhenEmpty : BoolControl ,
62
63
required : BoolControl ,
63
64
minTime : StringControl ,
64
65
maxTime : StringControl ,
@@ -116,7 +117,7 @@ function validate(
116
117
}
117
118
118
119
const current = dayjs ( props . value . value , TimeParser ) ;
119
- if ( props . required && ! current . isValid ( ) ) {
120
+ if ( props . required && ( ! Boolean ( props . value . value ) || ! current . isValid ( ) ) ) {
120
121
return { validateStatus : "error" , help : trans ( "prop.required" ) } ;
121
122
}
122
123
return { validateStatus : "success" } ;
@@ -197,6 +198,7 @@ export const timePickerControl = new UICompBuilder(childrenMap, (props) => {
197
198
onBlur = { ( ) => props . onEvent ( "blur" ) }
198
199
suffixIcon = { hasIcon ( props . suffixIcon ) && props . suffixIcon } />
199
200
) ,
201
+ showValidationWhenEmpty : props . showValidationWhenEmpty ,
200
202
...validate ( props ) ,
201
203
} ) ;
202
204
} )
@@ -217,6 +219,9 @@ export const timePickerControl = new UICompBuilder(childrenMap, (props) => {
217
219
{ ( useContext ( EditorContext ) . editorModeStatus === "logic" || useContext ( EditorContext ) . editorModeStatus === "both" ) && (
218
220
< > < Section name = { sectionNames . validation } >
219
221
{ requiredPropertyView ( children ) }
222
+ { children . showValidationWhenEmpty . propertyView ( {
223
+ label : trans ( "prop.showEmptyValidation" )
224
+ } ) }
220
225
{ minTimePropertyView ( children ) }
221
226
{ maxTimePropertyView ( children ) }
222
227
{ children . customRule . propertyView ( { } ) }
@@ -338,6 +343,7 @@ export const timeRangeControl = (function () {
338
343
animationStyle :props . animationStyle ,
339
344
children : children ,
340
345
onMouseDown : ( e ) => e . stopPropagation ( ) ,
346
+ showValidationWhenEmpty : props . showValidationWhenEmpty ,
341
347
...( startResult . validateStatus !== "success"
342
348
? startResult
343
349
: endResult . validateStatus !== "success"
@@ -366,6 +372,9 @@ export const timeRangeControl = (function () {
366
372
{ ( useContext ( EditorContext ) . editorModeStatus === "logic" || useContext ( EditorContext ) . editorModeStatus === "both" ) && (
367
373
< > < Section name = { sectionNames . validation } >
368
374
{ requiredPropertyView ( children ) }
375
+ { children . showValidationWhenEmpty . propertyView ( {
376
+ label : trans ( "prop.showEmptyValidation" )
377
+ } ) }
369
378
{ minTimePropertyView ( children ) }
370
379
{ maxTimePropertyView ( children ) }
371
380
{ children . customRule . propertyView ( { } ) }
0 commit comments