File tree Expand file tree Collapse file tree 5 files changed +11
-14
lines changed Expand file tree Collapse file tree 5 files changed +11
-14
lines changed Original file line number Diff line number Diff line change 1
1
import React from 'react' ;
2
2
3
- import { isValid } from '@gravity-ui/date-utils' ;
4
3
import type { DateTime } from '@gravity-ui/date-utils' ;
5
4
import { useControlledState } from '@gravity-ui/uikit' ;
6
5
@@ -84,7 +83,7 @@ export function useDateFieldState(props: DateFieldStateOptions): DateFieldState
84
83
}
85
84
86
85
const displayValue =
87
- value && isValid ( value ) && isAllSegmentsValid ( allSegments , validSegments )
86
+ value && value . isValid ( ) && isAllSegmentsValid ( allSegments , validSegments )
88
87
? value . timeZone ( timeZone )
89
88
: placeholderDate . timeZone ( timeZone ) ;
90
89
const sectionsState = useSectionsState ( sections , displayValue , validSegments ) ;
@@ -201,7 +200,7 @@ export function useDateFieldState(props: DateFieldStateOptions): DateFieldState
201
200
202
201
function setValueFromString ( str : string ) {
203
202
const date = parseDateFromString ( str , format , timeZone ) ;
204
- if ( isValid ( date ) ) {
203
+ if ( date . isValid ( ) ) {
205
204
handleUpdateDate ( date ) ;
206
205
return true ;
207
206
}
Original file line number Diff line number Diff line change 1
1
import React from 'react' ;
2
2
3
- import { dateTime , expandFormat , isValid } from '@gravity-ui/date-utils' ;
3
+ import { dateTime , expandFormat } from '@gravity-ui/date-utils' ;
4
4
import type { DateTime } from '@gravity-ui/date-utils' ;
5
5
6
6
import { mergeDateTime } from '../utils/dates' ;
@@ -612,7 +612,7 @@ export function formatSections(sections: DateFieldSection[]): string {
612
612
613
613
function parseDate ( options : { input : string ; format : string ; timeZone ?: string } ) {
614
614
let date = dateTime ( options ) ;
615
- if ( ! isValid ( date ) ) {
615
+ if ( ! date . isValid ( ) ) {
616
616
date = dateTime ( { ...options , format : undefined } ) ;
617
617
}
618
618
return date ;
@@ -624,7 +624,7 @@ function isDateStringWithTimeZone(str: string) {
624
624
625
625
export function parseDateFromString ( str : string , format : string , timeZone ?: string ) : DateTime {
626
626
let date = parseDate ( { input : str , format, timeZone} ) ;
627
- if ( isValid ( date ) ) {
627
+ if ( date . isValid ( ) ) {
628
628
if ( timeZone && ! isDateStringWithTimeZone ( str ) ) {
629
629
const time = parseDate ( { input : str , format} ) ;
630
630
date = mergeDateTime ( date , time ) ;
Original file line number Diff line number Diff line change 1
1
/* eslint-disable complexity */
2
2
import React from 'react' ;
3
3
4
- import { isValid } from '@gravity-ui/date-utils' ;
5
4
import type { DateTime } from '@gravity-ui/date-utils' ;
6
5
import { useControlledState } from '@gravity-ui/uikit' ;
7
6
@@ -98,8 +97,8 @@ export function useRangeDateFieldState(props: RangeDateFieldStateOptions): Range
98
97
99
98
const displayValue =
100
99
value &&
101
- isValid ( value . start ) &&
102
- isValid ( value . end ) &&
100
+ value . start . isValid ( ) &&
101
+ value . end . isValid ( ) &&
103
102
Object . keys ( validSegments . start ) . length >= Object . keys ( allSegments ) . length &&
104
103
Object . keys ( validSegments . end ) . length >= Object . keys ( allSegments ) . length
105
104
? { start : value . start . timeZone ( timeZone ) , end : value . end . timeZone ( timeZone ) }
@@ -236,7 +235,7 @@ export function useRangeDateFieldState(props: RangeDateFieldStateOptions): Range
236
235
const start = parseDateFromString ( list ?. [ 0 ] ?. trim ( ) , format , timeZone ) ;
237
236
const end = parseDateFromString ( list ?. [ 1 ] ?. trim ( ) , format , timeZone ) ;
238
237
const range = { start, end} ;
239
- if ( isValid ( range . start ) && isValid ( range . end ) ) {
238
+ if ( range . start . isValid ( ) && range . end . isValid ( ) ) {
240
239
handleUpdateRange ( range ) ;
241
240
return true ;
242
241
}
Original file line number Diff line number Diff line change 1
- import { isValid } from '@gravity-ui/date-utils' ;
2
1
import type { DateTime } from '@gravity-ui/date-utils' ;
3
2
4
3
import type { RangeValue } from '../../types' ;
5
4
6
5
export function isValidRange ( { start, end} : RangeValue < DateTime > ) : boolean {
7
- return isValid ( start ) && isValid ( end ) && ( start . isSame ( end ) || start . isBefore ( end ) ) ;
6
+ return start . isValid ( ) && end . isValid ( ) && ( start . isSame ( end ) || start . isBefore ( end ) ) ;
8
7
}
Original file line number Diff line number Diff line change 1
1
import React from 'react' ;
2
2
3
- import { dateTimeParse , isLikeRelative , isValid } from '@gravity-ui/date-utils' ;
3
+ import { dateTimeParse , isLikeRelative } from '@gravity-ui/date-utils' ;
4
4
import type { DateTime } from '@gravity-ui/date-utils' ;
5
5
import { useControlledState } from '@gravity-ui/uikit' ;
6
6
@@ -55,7 +55,7 @@ export function useRelativeDateFieldState(props: RelativeDateFieldOptions): Rela
55
55
setText ( t ) ;
56
56
if ( isLikeRelative ( t ) ) {
57
57
const date = dateTimeParse ( t ) ;
58
- if ( date && isValid ( date ) ) {
58
+ if ( date && date . isValid ( ) ) {
59
59
setValue ( t ) ;
60
60
} else {
61
61
setValue ( null ) ;
You can’t perform that action at this time.
0 commit comments