555 lines
69 KiB
JavaScript
555 lines
69 KiB
JavaScript
|
|
import { fromEvent, merge, Subject } from 'rxjs';
|
||
|
|
import { filter, take, takeUntil } from 'rxjs/operators';
|
||
|
|
import { ChangeDetectionStrategy, Component, ContentChild, Directive, EventEmitter, forwardRef, inject, Inject, Injector, Input, Output, ViewChild, ViewEncapsulation, } from '@angular/core';
|
||
|
|
import { NG_VALUE_ACCESSOR } from '@angular/forms';
|
||
|
|
import { NgFor, NgIf, NgTemplateOutlet } from '@angular/common';
|
||
|
|
import { NgbDate } from './ngb-date';
|
||
|
|
import { NgbDatepickerService } from './datepicker-service';
|
||
|
|
import { NavigationEvent } from './datepicker-view-model';
|
||
|
|
import { isChangedDate, isChangedMonth } from './datepicker-tools';
|
||
|
|
import { hasClassName } from '../util/util';
|
||
|
|
import { NgbDatepickerDayView } from './datepicker-day-view';
|
||
|
|
import { NgbDatepickerNavigation } from './datepicker-navigation';
|
||
|
|
import * as i0 from "@angular/core";
|
||
|
|
import * as i1 from "./datepicker-i18n";
|
||
|
|
import * as i2 from "./datepicker-keyboard-service";
|
||
|
|
import * as i3 from "./datepicker-service";
|
||
|
|
import * as i4 from "./ngb-calendar";
|
||
|
|
import * as i5 from "./datepicker-config";
|
||
|
|
import * as i6 from "./adapters/ngb-date-adapter";
|
||
|
|
/**
|
||
|
|
* A directive that marks the content template that customizes the way datepicker months are displayed
|
||
|
|
*
|
||
|
|
* @since 5.3.0
|
||
|
|
*/
|
||
|
|
export class NgbDatepickerContent {
|
||
|
|
constructor(templateRef) {
|
||
|
|
this.templateRef = templateRef;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
NgbDatepickerContent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.0.0", ngImport: i0, type: NgbDatepickerContent, deps: [{ token: i0.TemplateRef }], target: i0.ɵɵFactoryTarget.Directive });
|
||
|
|
NgbDatepickerContent.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.0.0", type: NgbDatepickerContent, isStandalone: true, selector: "ng-template[ngbDatepickerContent]", ngImport: i0 });
|
||
|
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.0", ngImport: i0, type: NgbDatepickerContent, decorators: [{
|
||
|
|
type: Directive,
|
||
|
|
args: [{ selector: 'ng-template[ngbDatepickerContent]', standalone: true }]
|
||
|
|
}], ctorParameters: function () { return [{ type: i0.TemplateRef }]; } });
|
||
|
|
/**
|
||
|
|
* A component that renders one month including all the days, weekdays and week numbers. Can be used inside
|
||
|
|
* the `<ng-template ngbDatepickerMonths></ng-template>` when you want to customize months layout.
|
||
|
|
*
|
||
|
|
* For a usage example, see [custom month layout demo](#/components/datepicker/examples#custommonth)
|
||
|
|
*
|
||
|
|
* @since 5.3.0
|
||
|
|
*/
|
||
|
|
export class NgbDatepickerMonth {
|
||
|
|
constructor(i18n, datepicker, _keyboardService, _service) {
|
||
|
|
this.i18n = i18n;
|
||
|
|
this.datepicker = datepicker;
|
||
|
|
this._keyboardService = _keyboardService;
|
||
|
|
this._service = _service;
|
||
|
|
}
|
||
|
|
/**
|
||
|
|
* The first date of month to be rendered.
|
||
|
|
*
|
||
|
|
* This month must one of the months present in the
|
||
|
|
* [datepicker state](#/components/datepicker/api#NgbDatepickerState).
|
||
|
|
*/
|
||
|
|
set month(month) {
|
||
|
|
this.viewModel = this._service.getMonth(month);
|
||
|
|
}
|
||
|
|
onKeyDown(event) {
|
||
|
|
this._keyboardService.processKey(event, this.datepicker);
|
||
|
|
}
|
||
|
|
doSelect(day) {
|
||
|
|
if (!day.context.disabled && !day.hidden) {
|
||
|
|
this.datepicker.onDateSelect(day.date);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
NgbDatepickerMonth.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.0.0", ngImport: i0, type: NgbDatepickerMonth, deps: [{ token: i1.NgbDatepickerI18n }, { token: forwardRef(() => NgbDatepicker) }, { token: i2.NgbDatepickerKeyboardService }, { token: i3.NgbDatepickerService }], target: i0.ɵɵFactoryTarget.Component });
|
||
|
|
NgbDatepickerMonth.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.0.0", type: NgbDatepickerMonth, isStandalone: true, selector: "ngb-datepicker-month", inputs: { month: "month" }, host: { attributes: { "role": "grid" }, listeners: { "keydown": "onKeyDown($event)" } }, ngImport: i0, template: `
|
||
|
|
<div *ngIf="viewModel.weekdays.length > 0" class="ngb-dp-week ngb-dp-weekdays" role="row">
|
||
|
|
<div *ngIf="datepicker.showWeekNumbers" class="ngb-dp-weekday ngb-dp-showweek small">{{
|
||
|
|
i18n.getWeekLabel()
|
||
|
|
}}</div>
|
||
|
|
<div *ngFor="let weekday of viewModel.weekdays" class="ngb-dp-weekday small" role="columnheader">{{
|
||
|
|
weekday
|
||
|
|
}}</div>
|
||
|
|
</div>
|
||
|
|
<ng-template ngFor let-week [ngForOf]="viewModel.weeks">
|
||
|
|
<div *ngIf="!week.collapsed" class="ngb-dp-week" role="row">
|
||
|
|
<div *ngIf="datepicker.showWeekNumbers" class="ngb-dp-week-number small text-muted">{{
|
||
|
|
i18n.getWeekNumerals(week.number)
|
||
|
|
}}</div>
|
||
|
|
<div
|
||
|
|
*ngFor="let day of week.days"
|
||
|
|
(click)="doSelect(day); $event.preventDefault()"
|
||
|
|
class="ngb-dp-day"
|
||
|
|
role="gridcell"
|
||
|
|
[class.disabled]="day.context.disabled"
|
||
|
|
[tabindex]="day.tabindex"
|
||
|
|
[class.hidden]="day.hidden"
|
||
|
|
[class.ngb-dp-today]="day.context.today"
|
||
|
|
[attr.aria-label]="day.ariaLabel"
|
||
|
|
>
|
||
|
|
<ng-template [ngIf]="!day.hidden">
|
||
|
|
<ng-template
|
||
|
|
[ngTemplateOutlet]="datepicker.dayTemplate"
|
||
|
|
[ngTemplateOutletContext]="day.context"
|
||
|
|
></ng-template>
|
||
|
|
</ng-template>
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
</ng-template>
|
||
|
|
`, isInline: true, styles: ["ngb-datepicker-month{display:block}.ngb-dp-weekday,.ngb-dp-week-number{line-height:2rem;text-align:center;font-style:italic}.ngb-dp-weekday{color:var(--bs-info)}.ngb-dp-week{border-radius:.25rem;display:flex}.ngb-dp-weekdays{border-bottom:1px solid var(--bs-border-color);border-radius:0;background-color:var(--bs-light)}.ngb-dp-day,.ngb-dp-weekday,.ngb-dp-week-number{width:2rem;height:2rem}.ngb-dp-day{cursor:pointer}.ngb-dp-day.disabled,.ngb-dp-day.hidden{cursor:default;pointer-events:none}.ngb-dp-day[tabindex=\"0\"]{z-index:1}\n"], dependencies: [{ kind: "directive", type: NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: NgFor, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }], encapsulation: i0.ViewEncapsulation.None });
|
||
|
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.0", ngImport: i0, type: NgbDatepickerMonth, decorators: [{
|
||
|
|
type: Component,
|
||
|
|
args: [{ selector: 'ngb-datepicker-month', standalone: true, imports: [NgIf, NgFor, NgTemplateOutlet], host: { role: 'grid', '(keydown)': 'onKeyDown($event)' }, encapsulation: ViewEncapsulation.None, template: `
|
||
|
|
<div *ngIf="viewModel.weekdays.length > 0" class="ngb-dp-week ngb-dp-weekdays" role="row">
|
||
|
|
<div *ngIf="datepicker.showWeekNumbers" class="ngb-dp-weekday ngb-dp-showweek small">{{
|
||
|
|
i18n.getWeekLabel()
|
||
|
|
}}</div>
|
||
|
|
<div *ngFor="let weekday of viewModel.weekdays" class="ngb-dp-weekday small" role="columnheader">{{
|
||
|
|
weekday
|
||
|
|
}}</div>
|
||
|
|
</div>
|
||
|
|
<ng-template ngFor let-week [ngForOf]="viewModel.weeks">
|
||
|
|
<div *ngIf="!week.collapsed" class="ngb-dp-week" role="row">
|
||
|
|
<div *ngIf="datepicker.showWeekNumbers" class="ngb-dp-week-number small text-muted">{{
|
||
|
|
i18n.getWeekNumerals(week.number)
|
||
|
|
}}</div>
|
||
|
|
<div
|
||
|
|
*ngFor="let day of week.days"
|
||
|
|
(click)="doSelect(day); $event.preventDefault()"
|
||
|
|
class="ngb-dp-day"
|
||
|
|
role="gridcell"
|
||
|
|
[class.disabled]="day.context.disabled"
|
||
|
|
[tabindex]="day.tabindex"
|
||
|
|
[class.hidden]="day.hidden"
|
||
|
|
[class.ngb-dp-today]="day.context.today"
|
||
|
|
[attr.aria-label]="day.ariaLabel"
|
||
|
|
>
|
||
|
|
<ng-template [ngIf]="!day.hidden">
|
||
|
|
<ng-template
|
||
|
|
[ngTemplateOutlet]="datepicker.dayTemplate"
|
||
|
|
[ngTemplateOutletContext]="day.context"
|
||
|
|
></ng-template>
|
||
|
|
</ng-template>
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
</ng-template>
|
||
|
|
`, styles: ["ngb-datepicker-month{display:block}.ngb-dp-weekday,.ngb-dp-week-number{line-height:2rem;text-align:center;font-style:italic}.ngb-dp-weekday{color:var(--bs-info)}.ngb-dp-week{border-radius:.25rem;display:flex}.ngb-dp-weekdays{border-bottom:1px solid var(--bs-border-color);border-radius:0;background-color:var(--bs-light)}.ngb-dp-day,.ngb-dp-weekday,.ngb-dp-week-number{width:2rem;height:2rem}.ngb-dp-day{cursor:pointer}.ngb-dp-day.disabled,.ngb-dp-day.hidden{cursor:default;pointer-events:none}.ngb-dp-day[tabindex=\"0\"]{z-index:1}\n"] }]
|
||
|
|
}], ctorParameters: function () { return [{ type: i1.NgbDatepickerI18n }, { type: NgbDatepicker, decorators: [{
|
||
|
|
type: Inject,
|
||
|
|
args: [forwardRef(() => NgbDatepicker)]
|
||
|
|
}] }, { type: i2.NgbDatepickerKeyboardService }, { type: i3.NgbDatepickerService }]; }, propDecorators: { month: [{
|
||
|
|
type: Input
|
||
|
|
}] } });
|
||
|
|
/**
|
||
|
|
* A highly configurable component that helps you with selecting calendar dates.
|
||
|
|
*
|
||
|
|
* `NgbDatepicker` is meant to be displayed inline on a page or put inside a popup.
|
||
|
|
*/
|
||
|
|
export class NgbDatepicker {
|
||
|
|
constructor(_service, _calendar, _i18n, config, cd, _elementRef, _ngbDateAdapter, _ngZone) {
|
||
|
|
this._service = _service;
|
||
|
|
this._calendar = _calendar;
|
||
|
|
this._i18n = _i18n;
|
||
|
|
this._elementRef = _elementRef;
|
||
|
|
this._ngbDateAdapter = _ngbDateAdapter;
|
||
|
|
this._ngZone = _ngZone;
|
||
|
|
this.injector = inject(Injector);
|
||
|
|
this._controlValue = null;
|
||
|
|
this._destroyed$ = new Subject();
|
||
|
|
this._publicState = {};
|
||
|
|
/**
|
||
|
|
* An event emitted right before the navigation happens and displayed month changes.
|
||
|
|
*
|
||
|
|
* See [`NgbDatepickerNavigateEvent`](#/components/datepicker/api#NgbDatepickerNavigateEvent) for the payload info.
|
||
|
|
*/
|
||
|
|
this.navigate = new EventEmitter();
|
||
|
|
/**
|
||
|
|
* An event emitted when user selects a date using keyboard or mouse.
|
||
|
|
*
|
||
|
|
* The payload of the event is currently selected `NgbDate`.
|
||
|
|
*
|
||
|
|
* @since 5.2.0
|
||
|
|
*/
|
||
|
|
this.dateSelect = new EventEmitter();
|
||
|
|
this.onChange = (_) => { };
|
||
|
|
this.onTouched = () => { };
|
||
|
|
[
|
||
|
|
'contentTemplate',
|
||
|
|
'dayTemplate',
|
||
|
|
'dayTemplateData',
|
||
|
|
'displayMonths',
|
||
|
|
'firstDayOfWeek',
|
||
|
|
'footerTemplate',
|
||
|
|
'markDisabled',
|
||
|
|
'minDate',
|
||
|
|
'maxDate',
|
||
|
|
'navigation',
|
||
|
|
'outsideDays',
|
||
|
|
'showWeekNumbers',
|
||
|
|
'startDate',
|
||
|
|
'weekdays',
|
||
|
|
].forEach((input) => (this[input] = config[input]));
|
||
|
|
_service.dateSelect$.pipe(takeUntil(this._destroyed$)).subscribe((date) => {
|
||
|
|
this.dateSelect.emit(date);
|
||
|
|
});
|
||
|
|
_service.model$.pipe(takeUntil(this._destroyed$)).subscribe((model) => {
|
||
|
|
const newDate = model.firstDate;
|
||
|
|
const oldDate = this.model ? this.model.firstDate : null;
|
||
|
|
// update public state
|
||
|
|
this._publicState = {
|
||
|
|
maxDate: model.maxDate,
|
||
|
|
minDate: model.minDate,
|
||
|
|
firstDate: model.firstDate,
|
||
|
|
lastDate: model.lastDate,
|
||
|
|
focusedDate: model.focusDate,
|
||
|
|
months: model.months.map((viewModel) => viewModel.firstDate),
|
||
|
|
};
|
||
|
|
let navigationPrevented = false;
|
||
|
|
// emitting navigation event if the first month changes
|
||
|
|
if (!newDate.equals(oldDate)) {
|
||
|
|
this.navigate.emit({
|
||
|
|
current: oldDate ? { year: oldDate.year, month: oldDate.month } : null,
|
||
|
|
next: { year: newDate.year, month: newDate.month },
|
||
|
|
preventDefault: () => (navigationPrevented = true),
|
||
|
|
});
|
||
|
|
// can't prevent the very first navigation
|
||
|
|
if (navigationPrevented && oldDate !== null) {
|
||
|
|
this._service.open(oldDate);
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
const newSelectedDate = model.selectedDate;
|
||
|
|
const newFocusedDate = model.focusDate;
|
||
|
|
const oldFocusedDate = this.model ? this.model.focusDate : null;
|
||
|
|
this.model = model;
|
||
|
|
// handling selection change
|
||
|
|
if (isChangedDate(newSelectedDate, this._controlValue)) {
|
||
|
|
this._controlValue = newSelectedDate;
|
||
|
|
this.onTouched();
|
||
|
|
this.onChange(this._ngbDateAdapter.toModel(newSelectedDate));
|
||
|
|
}
|
||
|
|
// handling focus change
|
||
|
|
if (isChangedDate(newFocusedDate, oldFocusedDate) && oldFocusedDate && model.focusVisible) {
|
||
|
|
this.focus();
|
||
|
|
}
|
||
|
|
cd.markForCheck();
|
||
|
|
});
|
||
|
|
}
|
||
|
|
/**
|
||
|
|
* Returns the readonly public state of the datepicker
|
||
|
|
*
|
||
|
|
* @since 5.2.0
|
||
|
|
*/
|
||
|
|
get state() {
|
||
|
|
return this._publicState;
|
||
|
|
}
|
||
|
|
/**
|
||
|
|
* Returns the calendar service used in the specific datepicker instance.
|
||
|
|
*
|
||
|
|
* @since 5.3.0
|
||
|
|
*/
|
||
|
|
get calendar() {
|
||
|
|
return this._calendar;
|
||
|
|
}
|
||
|
|
/**
|
||
|
|
* Returns the i18n service used in the specific datepicker instance.
|
||
|
|
*
|
||
|
|
* @since 14.2.0
|
||
|
|
*/
|
||
|
|
get i18n() {
|
||
|
|
return this._i18n;
|
||
|
|
}
|
||
|
|
/**
|
||
|
|
* Focuses on given date.
|
||
|
|
*/
|
||
|
|
focusDate(date) {
|
||
|
|
this._service.focus(NgbDate.from(date));
|
||
|
|
}
|
||
|
|
/**
|
||
|
|
* Selects focused date.
|
||
|
|
*/
|
||
|
|
focusSelect() {
|
||
|
|
this._service.focusSelect();
|
||
|
|
}
|
||
|
|
focus() {
|
||
|
|
this._ngZone.onStable
|
||
|
|
.asObservable()
|
||
|
|
.pipe(take(1))
|
||
|
|
.subscribe(() => {
|
||
|
|
const elementToFocus = this._elementRef.nativeElement.querySelector('div.ngb-dp-day[tabindex="0"]');
|
||
|
|
if (elementToFocus) {
|
||
|
|
elementToFocus.focus();
|
||
|
|
}
|
||
|
|
});
|
||
|
|
}
|
||
|
|
/**
|
||
|
|
* Navigates to the provided date.
|
||
|
|
*
|
||
|
|
* With the default calendar we use ISO 8601: 'month' is 1=Jan ... 12=Dec.
|
||
|
|
* If nothing or invalid date provided calendar will open current month.
|
||
|
|
*
|
||
|
|
* Use the `[startDate]` input as an alternative.
|
||
|
|
*/
|
||
|
|
navigateTo(date) {
|
||
|
|
this._service.open(NgbDate.from(date ? (date.day ? date : { ...date, day: 1 }) : null));
|
||
|
|
}
|
||
|
|
ngAfterViewInit() {
|
||
|
|
this._ngZone.runOutsideAngular(() => {
|
||
|
|
const focusIns$ = fromEvent(this._contentEl.nativeElement, 'focusin');
|
||
|
|
const focusOuts$ = fromEvent(this._contentEl.nativeElement, 'focusout');
|
||
|
|
const { nativeElement } = this._elementRef;
|
||
|
|
// we're changing 'focusVisible' only when entering or leaving months view
|
||
|
|
// and ignoring all focus events where both 'target' and 'related' target are day cells
|
||
|
|
merge(focusIns$, focusOuts$)
|
||
|
|
.pipe(filter(({ target, relatedTarget }) => !(hasClassName(target, 'ngb-dp-day') &&
|
||
|
|
hasClassName(relatedTarget, 'ngb-dp-day') &&
|
||
|
|
nativeElement.contains(target) &&
|
||
|
|
nativeElement.contains(relatedTarget))), takeUntil(this._destroyed$))
|
||
|
|
.subscribe(({ type }) => this._ngZone.run(() => this._service.set({ focusVisible: type === 'focusin' })));
|
||
|
|
});
|
||
|
|
}
|
||
|
|
ngOnDestroy() {
|
||
|
|
this._destroyed$.next();
|
||
|
|
}
|
||
|
|
ngOnInit() {
|
||
|
|
if (this.model === undefined) {
|
||
|
|
const inputs = {};
|
||
|
|
[
|
||
|
|
'dayTemplateData',
|
||
|
|
'displayMonths',
|
||
|
|
'markDisabled',
|
||
|
|
'firstDayOfWeek',
|
||
|
|
'navigation',
|
||
|
|
'minDate',
|
||
|
|
'maxDate',
|
||
|
|
'outsideDays',
|
||
|
|
'weekdays',
|
||
|
|
].forEach((name) => (inputs[name] = this[name]));
|
||
|
|
this._service.set(inputs);
|
||
|
|
this.navigateTo(this.startDate);
|
||
|
|
}
|
||
|
|
if (!this.dayTemplate) {
|
||
|
|
this.dayTemplate = this._defaultDayTemplate;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
ngOnChanges(changes) {
|
||
|
|
const inputs = {};
|
||
|
|
[
|
||
|
|
'dayTemplateData',
|
||
|
|
'displayMonths',
|
||
|
|
'markDisabled',
|
||
|
|
'firstDayOfWeek',
|
||
|
|
'navigation',
|
||
|
|
'minDate',
|
||
|
|
'maxDate',
|
||
|
|
'outsideDays',
|
||
|
|
'weekdays',
|
||
|
|
]
|
||
|
|
.filter((name) => name in changes)
|
||
|
|
.forEach((name) => (inputs[name] = this[name]));
|
||
|
|
this._service.set(inputs);
|
||
|
|
if ('startDate' in changes) {
|
||
|
|
const { currentValue, previousValue } = changes.startDate;
|
||
|
|
if (isChangedMonth(previousValue, currentValue)) {
|
||
|
|
this.navigateTo(this.startDate);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
onDateSelect(date) {
|
||
|
|
this._service.focus(date);
|
||
|
|
this._service.select(date, { emitEvent: true });
|
||
|
|
}
|
||
|
|
onNavigateDateSelect(date) {
|
||
|
|
this._service.open(date);
|
||
|
|
}
|
||
|
|
onNavigateEvent(event) {
|
||
|
|
switch (event) {
|
||
|
|
case NavigationEvent.PREV:
|
||
|
|
this._service.open(this._calendar.getPrev(this.model.firstDate, 'm', 1));
|
||
|
|
break;
|
||
|
|
case NavigationEvent.NEXT:
|
||
|
|
this._service.open(this._calendar.getNext(this.model.firstDate, 'm', 1));
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
registerOnChange(fn) {
|
||
|
|
this.onChange = fn;
|
||
|
|
}
|
||
|
|
registerOnTouched(fn) {
|
||
|
|
this.onTouched = fn;
|
||
|
|
}
|
||
|
|
setDisabledState(disabled) {
|
||
|
|
this._service.set({ disabled });
|
||
|
|
}
|
||
|
|
writeValue(value) {
|
||
|
|
this._controlValue = NgbDate.from(this._ngbDateAdapter.fromModel(value));
|
||
|
|
this._service.select(this._controlValue);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
NgbDatepicker.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.0.0", ngImport: i0, type: NgbDatepicker, deps: [{ token: i3.NgbDatepickerService }, { token: i4.NgbCalendar }, { token: i1.NgbDatepickerI18n }, { token: i5.NgbDatepickerConfig }, { token: i0.ChangeDetectorRef }, { token: i0.ElementRef }, { token: i6.NgbDateAdapter }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Component });
|
||
|
|
NgbDatepicker.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.0.0", type: NgbDatepicker, isStandalone: true, selector: "ngb-datepicker", inputs: { contentTemplate: "contentTemplate", dayTemplate: "dayTemplate", dayTemplateData: "dayTemplateData", displayMonths: "displayMonths", firstDayOfWeek: "firstDayOfWeek", footerTemplate: "footerTemplate", markDisabled: "markDisabled", maxDate: "maxDate", minDate: "minDate", navigation: "navigation", outsideDays: "outsideDays", showWeekNumbers: "showWeekNumbers", startDate: "startDate", weekdays: "weekdays" }, outputs: { navigate: "navigate", dateSelect: "dateSelect" }, host: { properties: { "class.disabled": "model.disabled" } }, providers: [
|
||
|
|
{ provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => NgbDatepicker), multi: true },
|
||
|
|
NgbDatepickerService,
|
||
|
|
], queries: [{ propertyName: "contentTemplateFromContent", first: true, predicate: NgbDatepickerContent, descendants: true, static: true }], viewQueries: [{ propertyName: "_defaultDayTemplate", first: true, predicate: ["defaultDayTemplate"], descendants: true, static: true }, { propertyName: "_contentEl", first: true, predicate: ["content"], descendants: true, static: true }], exportAs: ["ngbDatepicker"], usesOnChanges: true, ngImport: i0, template: `
|
||
|
|
<ng-template
|
||
|
|
#defaultDayTemplate
|
||
|
|
let-date="date"
|
||
|
|
let-currentMonth="currentMonth"
|
||
|
|
let-selected="selected"
|
||
|
|
let-disabled="disabled"
|
||
|
|
let-focused="focused"
|
||
|
|
>
|
||
|
|
<div
|
||
|
|
ngbDatepickerDayView
|
||
|
|
[date]="date"
|
||
|
|
[currentMonth]="currentMonth"
|
||
|
|
[selected]="selected"
|
||
|
|
[disabled]="disabled"
|
||
|
|
[focused]="focused"
|
||
|
|
>
|
||
|
|
</div>
|
||
|
|
</ng-template>
|
||
|
|
|
||
|
|
<ng-template #defaultContentTemplate>
|
||
|
|
<div *ngFor="let month of model.months; let i = index" class="ngb-dp-month">
|
||
|
|
<div *ngIf="navigation === 'none' || (displayMonths > 1 && navigation === 'select')" class="ngb-dp-month-name">
|
||
|
|
{{ i18n.getMonthLabel(month.firstDate) }}
|
||
|
|
</div>
|
||
|
|
<ngb-datepicker-month [month]="month.firstDate"></ngb-datepicker-month>
|
||
|
|
</div>
|
||
|
|
</ng-template>
|
||
|
|
|
||
|
|
<div class="ngb-dp-header">
|
||
|
|
<ngb-datepicker-navigation
|
||
|
|
*ngIf="navigation !== 'none'"
|
||
|
|
[date]="model.firstDate!"
|
||
|
|
[months]="model.months"
|
||
|
|
[disabled]="model.disabled"
|
||
|
|
[showSelect]="model.navigation === 'select'"
|
||
|
|
[prevDisabled]="model.prevDisabled"
|
||
|
|
[nextDisabled]="model.nextDisabled"
|
||
|
|
[selectBoxes]="model.selectBoxes"
|
||
|
|
(navigate)="onNavigateEvent($event)"
|
||
|
|
(select)="onNavigateDateSelect($event)"
|
||
|
|
>
|
||
|
|
</ngb-datepicker-navigation>
|
||
|
|
</div>
|
||
|
|
|
||
|
|
<div class="ngb-dp-content" [class.ngb-dp-months]="!contentTemplate" #content>
|
||
|
|
<ng-template
|
||
|
|
[ngTemplateOutlet]="contentTemplate || contentTemplateFromContent?.templateRef || defaultContentTemplate"
|
||
|
|
[ngTemplateOutletContext]="{ $implicit: this }"
|
||
|
|
[ngTemplateOutletInjector]="injector"
|
||
|
|
></ng-template>
|
||
|
|
</div>
|
||
|
|
|
||
|
|
<ng-template [ngTemplateOutlet]="footerTemplate"></ng-template>
|
||
|
|
`, isInline: true, styles: ["ngb-datepicker{border:1px solid var(--bs-border-color);border-radius:.25rem;display:inline-block}ngb-datepicker-month{pointer-events:auto}ngb-datepicker.dropdown-menu{padding:0}ngb-datepicker.disabled .ngb-dp-weekday,ngb-datepicker.disabled .ngb-dp-week-number,ngb-datepicker.disabled .ngb-dp-month-name{color:var(--bs-text-muted)}.ngb-dp-body{z-index:1055}.ngb-dp-header{border-bottom:0;border-radius:.25rem .25rem 0 0;padding-top:.25rem;background-color:var(--bs-light)}.ngb-dp-months{display:flex}.ngb-dp-month{pointer-events:none}.ngb-dp-month-name{font-size:larger;height:2rem;line-height:2rem;text-align:center;background-color:var(--bs-light)}.ngb-dp-month+.ngb-dp-month .ngb-dp-month-name,.ngb-dp-month+.ngb-dp-month .ngb-dp-week{padding-left:1rem}.ngb-dp-month:last-child .ngb-dp-week{padding-right:.25rem}.ngb-dp-month:first-child .ngb-dp-week{padding-left:.25rem}.ngb-dp-month .ngb-dp-week:last-child{padding-bottom:.25rem}\n"], dependencies: [{ kind: "directive", type: NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: NgFor, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "component", type: NgbDatepickerDayView, selector: "[ngbDatepickerDayView]", inputs: ["currentMonth", "date", "disabled", "focused", "selected"] }, { kind: "component", type: NgbDatepickerMonth, selector: "ngb-datepicker-month", inputs: ["month"] }, { kind: "component", type: NgbDatepickerNavigation, selector: "ngb-datepicker-navigation", inputs: ["date", "disabled", "months", "showSelect", "prevDisabled", "nextDisabled", "selectBoxes"], outputs: ["navigate", "select"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
||
|
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.0", ngImport: i0, type: NgbDatepicker, decorators: [{
|
||
|
|
type: Component,
|
||
|
|
args: [{ exportAs: 'ngbDatepicker', selector: 'ngb-datepicker', standalone: true, imports: [NgIf, NgFor, NgTemplateOutlet, NgbDatepickerDayView, NgbDatepickerMonth, NgbDatepickerNavigation], changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, host: { '[class.disabled]': 'model.disabled' }, template: `
|
||
|
|
<ng-template
|
||
|
|
#defaultDayTemplate
|
||
|
|
let-date="date"
|
||
|
|
let-currentMonth="currentMonth"
|
||
|
|
let-selected="selected"
|
||
|
|
let-disabled="disabled"
|
||
|
|
let-focused="focused"
|
||
|
|
>
|
||
|
|
<div
|
||
|
|
ngbDatepickerDayView
|
||
|
|
[date]="date"
|
||
|
|
[currentMonth]="currentMonth"
|
||
|
|
[selected]="selected"
|
||
|
|
[disabled]="disabled"
|
||
|
|
[focused]="focused"
|
||
|
|
>
|
||
|
|
</div>
|
||
|
|
</ng-template>
|
||
|
|
|
||
|
|
<ng-template #defaultContentTemplate>
|
||
|
|
<div *ngFor="let month of model.months; let i = index" class="ngb-dp-month">
|
||
|
|
<div *ngIf="navigation === 'none' || (displayMonths > 1 && navigation === 'select')" class="ngb-dp-month-name">
|
||
|
|
{{ i18n.getMonthLabel(month.firstDate) }}
|
||
|
|
</div>
|
||
|
|
<ngb-datepicker-month [month]="month.firstDate"></ngb-datepicker-month>
|
||
|
|
</div>
|
||
|
|
</ng-template>
|
||
|
|
|
||
|
|
<div class="ngb-dp-header">
|
||
|
|
<ngb-datepicker-navigation
|
||
|
|
*ngIf="navigation !== 'none'"
|
||
|
|
[date]="model.firstDate!"
|
||
|
|
[months]="model.months"
|
||
|
|
[disabled]="model.disabled"
|
||
|
|
[showSelect]="model.navigation === 'select'"
|
||
|
|
[prevDisabled]="model.prevDisabled"
|
||
|
|
[nextDisabled]="model.nextDisabled"
|
||
|
|
[selectBoxes]="model.selectBoxes"
|
||
|
|
(navigate)="onNavigateEvent($event)"
|
||
|
|
(select)="onNavigateDateSelect($event)"
|
||
|
|
>
|
||
|
|
</ngb-datepicker-navigation>
|
||
|
|
</div>
|
||
|
|
|
||
|
|
<div class="ngb-dp-content" [class.ngb-dp-months]="!contentTemplate" #content>
|
||
|
|
<ng-template
|
||
|
|
[ngTemplateOutlet]="contentTemplate || contentTemplateFromContent?.templateRef || defaultContentTemplate"
|
||
|
|
[ngTemplateOutletContext]="{ $implicit: this }"
|
||
|
|
[ngTemplateOutletInjector]="injector"
|
||
|
|
></ng-template>
|
||
|
|
</div>
|
||
|
|
|
||
|
|
<ng-template [ngTemplateOutlet]="footerTemplate"></ng-template>
|
||
|
|
`, providers: [
|
||
|
|
{ provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => NgbDatepicker), multi: true },
|
||
|
|
NgbDatepickerService,
|
||
|
|
], styles: ["ngb-datepicker{border:1px solid var(--bs-border-color);border-radius:.25rem;display:inline-block}ngb-datepicker-month{pointer-events:auto}ngb-datepicker.dropdown-menu{padding:0}ngb-datepicker.disabled .ngb-dp-weekday,ngb-datepicker.disabled .ngb-dp-week-number,ngb-datepicker.disabled .ngb-dp-month-name{color:var(--bs-text-muted)}.ngb-dp-body{z-index:1055}.ngb-dp-header{border-bottom:0;border-radius:.25rem .25rem 0 0;padding-top:.25rem;background-color:var(--bs-light)}.ngb-dp-months{display:flex}.ngb-dp-month{pointer-events:none}.ngb-dp-month-name{font-size:larger;height:2rem;line-height:2rem;text-align:center;background-color:var(--bs-light)}.ngb-dp-month+.ngb-dp-month .ngb-dp-month-name,.ngb-dp-month+.ngb-dp-month .ngb-dp-week{padding-left:1rem}.ngb-dp-month:last-child .ngb-dp-week{padding-right:.25rem}.ngb-dp-month:first-child .ngb-dp-week{padding-left:.25rem}.ngb-dp-month .ngb-dp-week:last-child{padding-bottom:.25rem}\n"] }]
|
||
|
|
}], ctorParameters: function () { return [{ type: i3.NgbDatepickerService }, { type: i4.NgbCalendar }, { type: i1.NgbDatepickerI18n }, { type: i5.NgbDatepickerConfig }, { type: i0.ChangeDetectorRef }, { type: i0.ElementRef }, { type: i6.NgbDateAdapter }, { type: i0.NgZone }]; }, propDecorators: { _defaultDayTemplate: [{
|
||
|
|
type: ViewChild,
|
||
|
|
args: ['defaultDayTemplate', { static: true }]
|
||
|
|
}], _contentEl: [{
|
||
|
|
type: ViewChild,
|
||
|
|
args: ['content', { static: true }]
|
||
|
|
}], contentTemplate: [{
|
||
|
|
type: Input
|
||
|
|
}], contentTemplateFromContent: [{
|
||
|
|
type: ContentChild,
|
||
|
|
args: [NgbDatepickerContent, { static: true }]
|
||
|
|
}], dayTemplate: [{
|
||
|
|
type: Input
|
||
|
|
}], dayTemplateData: [{
|
||
|
|
type: Input
|
||
|
|
}], displayMonths: [{
|
||
|
|
type: Input
|
||
|
|
}], firstDayOfWeek: [{
|
||
|
|
type: Input
|
||
|
|
}], footerTemplate: [{
|
||
|
|
type: Input
|
||
|
|
}], markDisabled: [{
|
||
|
|
type: Input
|
||
|
|
}], maxDate: [{
|
||
|
|
type: Input
|
||
|
|
}], minDate: [{
|
||
|
|
type: Input
|
||
|
|
}], navigation: [{
|
||
|
|
type: Input
|
||
|
|
}], outsideDays: [{
|
||
|
|
type: Input
|
||
|
|
}], showWeekNumbers: [{
|
||
|
|
type: Input
|
||
|
|
}], startDate: [{
|
||
|
|
type: Input
|
||
|
|
}], weekdays: [{
|
||
|
|
type: Input
|
||
|
|
}], navigate: [{
|
||
|
|
type: Output
|
||
|
|
}], dateSelect: [{
|
||
|
|
type: Output
|
||
|
|
}] } });
|
||
|
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZGF0ZXBpY2tlci5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3NyYy9kYXRlcGlja2VyL2RhdGVwaWNrZXIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLFNBQVMsRUFBRSxLQUFLLEVBQUUsT0FBTyxFQUFFLE1BQU0sTUFBTSxDQUFDO0FBQ2pELE9BQU8sRUFBRSxNQUFNLEVBQUUsSUFBSSxFQUFFLFNBQVMsRUFBRSxNQUFNLGdCQUFnQixDQUFDO0FBQ3pELE9BQU8sRUFFTix1QkFBdUIsRUFFdkIsU0FBUyxFQUNULFlBQVksRUFDWixTQUFTLEVBRVQs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