-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(datepicker): added month and year view (#2540)
feat(datepicker): added min\max dates boundaries
- Loading branch information
Showing
52 changed files
with
1,741 additions
and
685 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import { UnitOfTime } from '../types'; | ||
import { endOf, startOf } from './start-end-of'; | ||
|
||
export function isAfter(date1: Date, date2: Date, units: UnitOfTime = 'milliseconds'): boolean { | ||
if (!date1 || !date2) { | ||
return false; | ||
} | ||
|
||
if (units === 'milliseconds') { | ||
return date1.valueOf() > date2.valueOf(); | ||
} | ||
|
||
return date2.valueOf() < startOf(date1, units).valueOf(); | ||
} | ||
|
||
export function isBefore(date1: Date, date2: Date, units: UnitOfTime = 'milliseconds'): boolean { | ||
if (!date1 || !date2) { | ||
return false; | ||
} | ||
|
||
if (units === 'milliseconds') { | ||
return date1.valueOf() < date2.valueOf(); | ||
} | ||
|
||
return endOf(date1, units).valueOf() < date2.valueOf(); | ||
} | ||
|
||
export function isBetween(date: Date, | ||
from: Date, | ||
to: Date, | ||
units: UnitOfTime, | ||
inclusivity = '()'): boolean { | ||
const leftBound = inclusivity[0] === '(' | ||
? isAfter(date, from, units) : | ||
!isBefore(date, from, units); | ||
const rightBound = inclusivity[1] === ')' | ||
? isBefore(date, to, units) | ||
: !isAfter(date, to, units); | ||
|
||
return leftBound && rightBound; | ||
} | ||
|
||
export function isSame(date1: Date, date2: Date, units: UnitOfTime = 'milliseconds'): boolean { | ||
if (!date1 || !date2) { | ||
return false; | ||
} | ||
|
||
if (units === 'milliseconds') { | ||
return date1.valueOf() === date2.valueOf(); | ||
} | ||
|
||
const inputMs = date2.valueOf(); | ||
|
||
return startOf(date1, units).valueOf() <= inputMs | ||
&& inputMs <= endOf(date1, units).valueOf(); | ||
} | ||
|
||
export function isSameOrAfter(date1: Date, date2: Date, units?: UnitOfTime): boolean { | ||
return isSame(date1, date2, units) || isAfter(date1, date2, units); | ||
} | ||
|
||
export function isSameOrBefore(date1: Date, date2: Date, units?: UnitOfTime): boolean { | ||
return isSame(date1, date2, units) || isBefore(date1, date2, units); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// datepicker container component | ||
/* tslint:disable no-empty */ | ||
import { BsCustomDates } from '../themes/bs/bs-custom-dates-view.component'; | ||
import { BsDatepickerEffects } from '../reducer/bs-datepicker.effects'; | ||
import { Observable } from 'rxjs/Observable'; | ||
import { | ||
BsDatepickerViewMode, BsNavigationEvent, CalendarCellViewModel, CellHoverEvent, DatepickerRenderOptions, | ||
DaysCalendarViewModel, DayViewModel, | ||
MonthsCalendarViewModel, | ||
YearsCalendarViewModel | ||
} from '../models/index'; | ||
|
||
export abstract class BsDatepickerContainer { | ||
/** @deperecated */ | ||
_customRangesFish: BsCustomDates[] = [ | ||
{label: 'today', value: new Date()}, | ||
{label: 'today1', value: new Date()}, | ||
{label: 'today2', value: new Date()}, | ||
{label: 'today3', value: new Date()} | ||
]; | ||
|
||
_effects: BsDatepickerEffects; | ||
|
||
set minDate(value: Date) { | ||
this._effects.setMinDate(value); | ||
} | ||
|
||
set maxDate(value: Date) { | ||
this._effects.setMaxDate(value); | ||
} | ||
|
||
|
||
viewMode: Observable<BsDatepickerViewMode>; | ||
daysCalendar: Observable<DaysCalendarViewModel[]>; | ||
monthsCalendar: Observable<MonthsCalendarViewModel[]>; | ||
yearsCalendar: Observable<YearsCalendarViewModel[]>; | ||
options: Observable<DatepickerRenderOptions>; | ||
|
||
setViewMode(event: BsDatepickerViewMode): void {} | ||
|
||
navigateTo(event: BsNavigationEvent): void {} | ||
|
||
dayHoverHandler(event: CellHoverEvent): void {} | ||
|
||
monthHoverHandler(event: CellHoverEvent): void {} | ||
|
||
yearHoverHandler(event: CellHoverEvent): void {} | ||
|
||
daySelectHandler(day: DayViewModel): void {}; | ||
|
||
monthSelectHandler(event: CalendarCellViewModel): void {} | ||
|
||
yearSelectHandler(event: CalendarCellViewModel): void {} | ||
|
||
_stopPropagation(event: any): void { | ||
event.stopPropagation(); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.