@@ -103,6 +103,34 @@ export function cloneValue(value: any): any {
103
103
return value ;
104
104
}
105
105
106
+ /**
107
+ * Parse provided input to Date.
108
+ * @param value input to parse
109
+ * @returns Date if parse succeed or null
110
+ * @hidden
111
+ */
112
+ export function parseDate ( value : any ) : Date | null {
113
+ // if value is Invalid Date return null
114
+ if ( isDate ( value ) ) {
115
+ return ! isNaN ( value . getTime ( ) ) ? value : null ;
116
+ }
117
+ return value ? new Date ( value ) : null ;
118
+ }
119
+
120
+ /**
121
+ * Returns an array with unique dates only.
122
+ * @param columnValues collection of date values (might be numbers or ISO 8601 strings)
123
+ * @returns collection of unique dates.
124
+ * @hidden
125
+ */
126
+ export function uniqueDates ( columnValues : any [ ] ) {
127
+ return columnValues . reduce ( ( a , c ) => {
128
+ if ( ! a . cache [ c . label ] ) { a . result . push ( c ) ; }
129
+ a . cache [ c . label ] = true ;
130
+ return a ;
131
+ } , { result : [ ] , cache : { } } ) . result ;
132
+ }
133
+
106
134
/**
107
135
* Checks if provided variable is Object
108
136
* @param value Value to check
@@ -119,8 +147,8 @@ export function isObject(value: any): boolean {
119
147
* @returns true if provided variable is Date
120
148
* @hidden
121
149
*/
122
- export function isDate ( value : any ) {
123
- return Object . prototype . toString . call ( value ) === '[object Date]' ;
150
+ export function isDate ( value : any ) : boolean {
151
+ return value instanceof Date ;
124
152
}
125
153
126
154
/**
@@ -326,9 +354,9 @@ export interface CancelableBrowserEventArgs extends CancelableEventArgs {
326
354
event ?: Event ;
327
355
}
328
356
329
- export interface IBaseCancelableBrowserEventArgs extends CancelableBrowserEventArgs , IBaseEventArgs { }
357
+ export interface IBaseCancelableBrowserEventArgs extends CancelableBrowserEventArgs , IBaseEventArgs { }
330
358
331
- export interface IBaseCancelableEventArgs extends CancelableEventArgs , IBaseEventArgs { }
359
+ export interface IBaseCancelableEventArgs extends CancelableEventArgs , IBaseEventArgs { }
332
360
333
361
export const HORIZONTAL_NAV_KEYS = new Set ( [ 'arrowleft' , 'left' , 'arrowright' , 'right' , 'home' , 'end' ] ) ;
334
362
@@ -349,7 +377,8 @@ export const NAVIGATION_KEYS = new Set([
349
377
] ) ;
350
378
export const ROW_EXPAND_KEYS = new Set ( 'right down arrowright arrowdown' . split ( ' ' ) ) ;
351
379
export const ROW_COLLAPSE_KEYS = new Set ( 'left up arrowleft arrowup' . split ( ' ' ) ) ;
352
- export const SUPPORTED_KEYS = new Set ( [ ...Array . from ( NAVIGATION_KEYS ) , 'enter' , 'f2' , 'escape' , 'esc' , 'pagedown' , 'pageup' , '+' , 'add' ] ) ;
380
+ export const ROW_ADD_KEYS = new Set ( [ '+' , 'add' , '≠' , '±' , '=' ] ) ;
381
+ export const SUPPORTED_KEYS = new Set ( [ ...Array . from ( NAVIGATION_KEYS ) , ...Array . from ( ROW_ADD_KEYS ) , 'enter' , 'f2' , 'escape' , 'esc' , 'pagedown' , 'pageup' ] ) ;
353
382
export const HEADER_KEYS = new Set ( [ ...Array . from ( NAVIGATION_KEYS ) , 'escape' , 'esc' , 'l' ,
354
383
/** This symbol corresponds to the Alt + L combination under MAC. */
355
384
'¬' ] ) ;
@@ -464,7 +493,7 @@ export function yieldingLoop(count: number, chunkSize: number, callback: (index:
464
493
let i = 0 ;
465
494
const chunk = ( ) => {
466
495
const end = Math . min ( i + chunkSize , count ) ;
467
- for ( ; i < end ; ++ i ) {
496
+ for ( ; i < end ; ++ i ) {
468
497
callback ( i ) ;
469
498
}
470
499
if ( i < count ) {
0 commit comments