@ptsecurity/mosaic 14.6.1 → 14.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/_theming.scss +3790 -2072
- package/_visual.scss +341 -0
- package/button/button.component.d.ts +2 -0
- package/card/card.component.d.ts +2 -0
- package/checkbox/checkbox.d.ts +1 -0
- package/code-block/README.md +32 -0
- package/code-block/actionbar.component.d.ts +22 -0
- package/code-block/code-block.component.d.ts +74 -0
- package/code-block/code-block.module.d.ts +14 -0
- package/code-block/code-block.types.d.ts +17 -0
- package/code-block/index.d.ts +1 -0
- package/code-block/public-api.d.ts +3 -0
- package/core/formatters/date/formatter.d.ts +55 -1
- package/core/option/action.d.ts +2 -0
- package/core/selection/pseudo-checkbox/pseudo-checkbox.d.ts +1 -0
- package/datepicker/calendar-body.component.d.ts +3 -11
- package/datepicker/calendar-header.component.d.ts +45 -0
- package/datepicker/calendar.component.d.ts +10 -81
- package/datepicker/datepicker-input.directive.d.ts +3 -3
- package/datepicker/datepicker-module.d.ts +8 -8
- package/datepicker/datepicker.component.d.ts +2 -12
- package/datepicker/month-view.component.d.ts +7 -26
- package/datepicker/public-api.d.ts +1 -2
- package/design-tokens/legacy-2017/tokens/components/code-block.json5 +704 -0
- package/design-tokens/legacy-2017/tokens.d.ts +341 -0
- package/design-tokens/pt-2022/tokens/components/code-block.json5 +697 -0
- package/design-tokens/pt-2022/tokens.d.ts +341 -0
- package/design-tokens/style-dictionary/configs/index.js +6 -8
- package/dropdown/dropdown-item.component.d.ts +1 -0
- package/esm2020/button/button.component.mjs +3 -3
- package/esm2020/card/card.component.mjs +3 -3
- package/esm2020/checkbox/checkbox.mjs +2 -2
- package/esm2020/code-block/actionbar.component.mjs +67 -0
- package/esm2020/code-block/code-block.component.mjs +157 -0
- package/esm2020/code-block/code-block.module.mjs +60 -0
- package/esm2020/code-block/code-block.types.mjs +2 -0
- package/esm2020/code-block/index.mjs +2 -0
- package/esm2020/code-block/ptsecurity-mosaic-code-block.mjs +5 -0
- package/esm2020/code-block/public-api.mjs +4 -0
- package/esm2020/core/formatters/date/formatter.mjs +77 -1
- package/esm2020/core/formatters/date/templates/en-US.mjs +56 -1
- package/esm2020/core/formatters/date/templates/ru-RU.mjs +92 -1
- package/esm2020/core/option/action.mjs +3 -2
- package/esm2020/core/selection/pseudo-checkbox/pseudo-checkbox.mjs +2 -2
- package/esm2020/core/version.mjs +2 -2
- package/esm2020/datepicker/calendar-body.component.mjs +9 -28
- package/esm2020/datepicker/calendar-header.component.mjs +135 -0
- package/esm2020/datepicker/calendar.component.mjs +25 -212
- package/esm2020/datepicker/datepicker-input.directive.mjs +54 -54
- package/esm2020/datepicker/datepicker-module.mjs +13 -17
- package/esm2020/datepicker/datepicker.component.mjs +10 -21
- package/esm2020/datepicker/month-view.component.mjs +32 -131
- package/esm2020/datepicker/public-api.mjs +2 -3
- package/esm2020/design-tokens/legacy-2017/tokens.mjs +342 -1
- package/esm2020/design-tokens/pt-2022/tokens.mjs +342 -1
- package/esm2020/dropdown/dropdown-item.component.mjs +2 -2
- package/esm2020/form-field/form-field.mjs +3 -2
- package/esm2020/form-field/hint.mjs +3 -2
- package/esm2020/icon/icon.component.mjs +3 -2
- package/esm2020/input/input-number-validators.mjs +3 -7
- package/esm2020/input/input.mjs +3 -2
- package/esm2020/link/link.component.mjs +3 -2
- package/esm2020/list/list-selection.component.mjs +3 -2
- package/esm2020/modal/modal.component.mjs +4 -3
- package/esm2020/progress-bar/progress-bar.component.mjs +3 -2
- package/esm2020/progress-spinner/progress-spinner.component.mjs +3 -2
- package/esm2020/radio/radio.component.mjs +3 -4
- package/esm2020/select/select.component.mjs +18 -6
- package/esm2020/select/select.module.mjs +6 -2
- package/esm2020/tabs/tab-group.component.mjs +2 -2
- package/esm2020/tabs/tab-label-wrapper.directive.mjs +2 -2
- package/esm2020/tabs/tab-nav-bar/tab-nav-bar.mjs +3 -2
- package/esm2020/tabs/tab.component.mjs +3 -2
- package/esm2020/tags/tag-list.component.mjs +3 -2
- package/esm2020/tags/tag.component.mjs +3 -2
- package/esm2020/textarea/textarea.component.mjs +3 -2
- package/esm2020/timezone/timezone-select.component.mjs +2 -2
- package/esm2020/toggle/toggle.component.mjs +3 -2
- package/esm2020/tree/control/flat-tree-control.mjs +1 -1
- package/esm2020/tree/toggle.mjs +3 -2
- package/esm2020/tree/tree-base.mjs +1 -1
- package/esm2020/tree-select/tree-select.component.mjs +3 -2
- package/fesm2015/ptsecurity-mosaic-button.mjs +2 -2
- package/fesm2015/ptsecurity-mosaic-button.mjs.map +1 -1
- package/fesm2015/ptsecurity-mosaic-card.mjs +2 -2
- package/fesm2015/ptsecurity-mosaic-card.mjs.map +1 -1
- package/fesm2015/ptsecurity-mosaic-checkbox.mjs +1 -1
- package/fesm2015/ptsecurity-mosaic-checkbox.mjs.map +1 -1
- package/fesm2015/ptsecurity-mosaic-code-block.mjs +280 -0
- package/fesm2015/ptsecurity-mosaic-code-block.mjs.map +1 -0
- package/fesm2015/ptsecurity-mosaic-core.mjs +226 -3
- package/fesm2015/ptsecurity-mosaic-core.mjs.map +1 -1
- package/fesm2015/ptsecurity-mosaic-datepicker.mjs +272 -906
- package/fesm2015/ptsecurity-mosaic-datepicker.mjs.map +1 -1
- package/fesm2015/ptsecurity-mosaic-design-tokens.mjs +1024 -1
- package/fesm2015/ptsecurity-mosaic-design-tokens.mjs.map +1 -1
- package/fesm2015/ptsecurity-mosaic-dropdown.mjs +1 -1
- package/fesm2015/ptsecurity-mosaic-dropdown.mjs.map +1 -1
- package/fesm2015/ptsecurity-mosaic-form-field.mjs +4 -2
- package/fesm2015/ptsecurity-mosaic-form-field.mjs.map +1 -1
- package/fesm2015/ptsecurity-mosaic-icon.mjs +2 -1
- package/fesm2015/ptsecurity-mosaic-icon.mjs.map +1 -1
- package/fesm2015/ptsecurity-mosaic-input.mjs +4 -7
- package/fesm2015/ptsecurity-mosaic-input.mjs.map +1 -1
- package/fesm2015/ptsecurity-mosaic-link.mjs +2 -1
- package/fesm2015/ptsecurity-mosaic-link.mjs.map +1 -1
- package/fesm2015/ptsecurity-mosaic-list.mjs +2 -1
- package/fesm2015/ptsecurity-mosaic-list.mjs.map +1 -1
- package/fesm2015/ptsecurity-mosaic-modal.mjs +3 -2
- package/fesm2015/ptsecurity-mosaic-modal.mjs.map +1 -1
- package/fesm2015/ptsecurity-mosaic-progress-bar.mjs +2 -1
- package/fesm2015/ptsecurity-mosaic-progress-bar.mjs.map +1 -1
- package/fesm2015/ptsecurity-mosaic-progress-spinner.mjs +2 -1
- package/fesm2015/ptsecurity-mosaic-progress-spinner.mjs.map +1 -1
- package/fesm2015/ptsecurity-mosaic-radio.mjs +2 -3
- package/fesm2015/ptsecurity-mosaic-radio.mjs.map +1 -1
- package/fesm2015/ptsecurity-mosaic-select.mjs +22 -6
- package/fesm2015/ptsecurity-mosaic-select.mjs.map +1 -1
- package/fesm2015/ptsecurity-mosaic-tabs.mjs +6 -4
- package/fesm2015/ptsecurity-mosaic-tabs.mjs.map +1 -1
- package/fesm2015/ptsecurity-mosaic-tags.mjs +4 -2
- package/fesm2015/ptsecurity-mosaic-tags.mjs.map +1 -1
- package/fesm2015/ptsecurity-mosaic-textarea.mjs +2 -1
- package/fesm2015/ptsecurity-mosaic-textarea.mjs.map +1 -1
- package/fesm2015/ptsecurity-mosaic-timezone.mjs +2 -2
- package/fesm2015/ptsecurity-mosaic-timezone.mjs.map +1 -1
- package/fesm2015/ptsecurity-mosaic-toggle.mjs +2 -1
- package/fesm2015/ptsecurity-mosaic-toggle.mjs.map +1 -1
- package/fesm2015/ptsecurity-mosaic-tree-select.mjs +2 -1
- package/fesm2015/ptsecurity-mosaic-tree-select.mjs.map +1 -1
- package/fesm2015/ptsecurity-mosaic-tree.mjs +2 -1
- package/fesm2015/ptsecurity-mosaic-tree.mjs.map +1 -1
- package/fesm2020/ptsecurity-mosaic-button.mjs +2 -2
- package/fesm2020/ptsecurity-mosaic-button.mjs.map +1 -1
- package/fesm2020/ptsecurity-mosaic-card.mjs +2 -2
- package/fesm2020/ptsecurity-mosaic-card.mjs.map +1 -1
- package/fesm2020/ptsecurity-mosaic-checkbox.mjs +1 -1
- package/fesm2020/ptsecurity-mosaic-checkbox.mjs.map +1 -1
- package/fesm2020/ptsecurity-mosaic-code-block.mjs +278 -0
- package/fesm2020/ptsecurity-mosaic-code-block.mjs.map +1 -0
- package/fesm2020/ptsecurity-mosaic-core.mjs +226 -3
- package/fesm2020/ptsecurity-mosaic-core.mjs.map +1 -1
- package/fesm2020/ptsecurity-mosaic-datepicker.mjs +270 -901
- package/fesm2020/ptsecurity-mosaic-datepicker.mjs.map +1 -1
- package/fesm2020/ptsecurity-mosaic-design-tokens.mjs +1024 -1
- package/fesm2020/ptsecurity-mosaic-design-tokens.mjs.map +1 -1
- package/fesm2020/ptsecurity-mosaic-dropdown.mjs +1 -1
- package/fesm2020/ptsecurity-mosaic-dropdown.mjs.map +1 -1
- package/fesm2020/ptsecurity-mosaic-form-field.mjs +4 -2
- package/fesm2020/ptsecurity-mosaic-form-field.mjs.map +1 -1
- package/fesm2020/ptsecurity-mosaic-icon.mjs +2 -1
- package/fesm2020/ptsecurity-mosaic-icon.mjs.map +1 -1
- package/fesm2020/ptsecurity-mosaic-input.mjs +4 -7
- package/fesm2020/ptsecurity-mosaic-input.mjs.map +1 -1
- package/fesm2020/ptsecurity-mosaic-link.mjs +2 -1
- package/fesm2020/ptsecurity-mosaic-link.mjs.map +1 -1
- package/fesm2020/ptsecurity-mosaic-list.mjs +2 -1
- package/fesm2020/ptsecurity-mosaic-list.mjs.map +1 -1
- package/fesm2020/ptsecurity-mosaic-modal.mjs +3 -2
- package/fesm2020/ptsecurity-mosaic-modal.mjs.map +1 -1
- package/fesm2020/ptsecurity-mosaic-progress-bar.mjs +2 -1
- package/fesm2020/ptsecurity-mosaic-progress-bar.mjs.map +1 -1
- package/fesm2020/ptsecurity-mosaic-progress-spinner.mjs +2 -1
- package/fesm2020/ptsecurity-mosaic-progress-spinner.mjs.map +1 -1
- package/fesm2020/ptsecurity-mosaic-radio.mjs +2 -3
- package/fesm2020/ptsecurity-mosaic-radio.mjs.map +1 -1
- package/fesm2020/ptsecurity-mosaic-select.mjs +22 -6
- package/fesm2020/ptsecurity-mosaic-select.mjs.map +1 -1
- package/fesm2020/ptsecurity-mosaic-tabs.mjs +6 -4
- package/fesm2020/ptsecurity-mosaic-tabs.mjs.map +1 -1
- package/fesm2020/ptsecurity-mosaic-tags.mjs +4 -2
- package/fesm2020/ptsecurity-mosaic-tags.mjs.map +1 -1
- package/fesm2020/ptsecurity-mosaic-textarea.mjs +2 -1
- package/fesm2020/ptsecurity-mosaic-textarea.mjs.map +1 -1
- package/fesm2020/ptsecurity-mosaic-timezone.mjs +2 -2
- package/fesm2020/ptsecurity-mosaic-timezone.mjs.map +1 -1
- package/fesm2020/ptsecurity-mosaic-toggle.mjs +2 -1
- package/fesm2020/ptsecurity-mosaic-toggle.mjs.map +1 -1
- package/fesm2020/ptsecurity-mosaic-tree-select.mjs +2 -1
- package/fesm2020/ptsecurity-mosaic-tree-select.mjs.map +1 -1
- package/fesm2020/ptsecurity-mosaic-tree.mjs +2 -1
- package/fesm2020/ptsecurity-mosaic-tree.mjs.map +1 -1
- package/form-field/form-field.d.ts +2 -0
- package/form-field/hint.d.ts +2 -0
- package/icon/icon.component.d.ts +2 -0
- package/input/input-number-validators.d.ts +2 -6
- package/input/input.d.ts +2 -0
- package/link/link.component.d.ts +2 -0
- package/list/list-selection.component.d.ts +2 -0
- package/package.json +12 -4
- package/prebuilt-themes/dark-theme.css +1 -1
- package/prebuilt-themes/default-theme.css +1 -1
- package/progress-bar/progress-bar.component.d.ts +2 -0
- package/progress-spinner/progress-spinner.component.d.ts +2 -0
- package/radio/radio.component.d.ts +2 -0
- package/select/select.component.d.ts +9 -2
- package/select/select.module.d.ts +1 -1
- package/tabs/tab-group.component.d.ts +1 -0
- package/tabs/tab-label-wrapper.directive.d.ts +1 -0
- package/tabs/tab-nav-bar/tab-nav-bar.d.ts +2 -0
- package/tabs/tab.component.d.ts +2 -0
- package/tags/tag-list.component.d.ts +2 -0
- package/tags/tag.component.d.ts +2 -0
- package/textarea/textarea.component.d.ts +2 -0
- package/toggle/toggle.component.d.ts +2 -0
- package/tree/control/flat-tree-control.d.ts +4 -4
- package/tree/toggle.d.ts +2 -0
- package/tree-select/tree-select.component.d.ts +2 -0
- package/datepicker/multi-year-view.component.d.ts +0 -72
- package/datepicker/year-view.component.d.ts +0 -90
- package/esm2020/datepicker/multi-year-view.component.mjs +0 -218
- package/esm2020/datepicker/year-view.component.mjs +0 -253
@@ -1,27 +1,30 @@
|
|
1
1
|
import { A11yModule } from '@angular/cdk/a11y';
|
2
|
-
import * as i3 from '@angular/cdk/overlay';
|
2
|
+
import * as i3$1 from '@angular/cdk/overlay';
|
3
3
|
import { Overlay, OverlayConfig, OverlayModule } from '@angular/cdk/overlay';
|
4
|
-
import * as i4 from '@angular/cdk/portal';
|
5
4
|
import { ComponentPortal, PortalModule } from '@angular/cdk/portal';
|
6
5
|
import * as i1 from '@angular/common';
|
7
6
|
import { DOCUMENT, CommonModule } from '@angular/common';
|
8
7
|
import * as i0 from '@angular/core';
|
9
8
|
import { EventEmitter, Component, ViewEncapsulation, ChangeDetectionStrategy, Input, Output, Injectable, Optional, Inject, ViewChild, InjectionToken, forwardRef, Directive, ContentChild, NgModule } from '@angular/core';
|
10
|
-
import * as
|
9
|
+
import * as i3 from '@ptsecurity/mosaic/button';
|
11
10
|
import { McButtonModule } from '@ptsecurity/mosaic/button';
|
12
|
-
import * as
|
11
|
+
import * as i7 from '@ptsecurity/mosaic/icon';
|
13
12
|
import { McIconModule } from '@ptsecurity/mosaic/icon';
|
14
|
-
import
|
13
|
+
import * as i5 from '@ptsecurity/mosaic/select';
|
14
|
+
import { McSelectModule } from '@ptsecurity/mosaic/select';
|
15
15
|
import * as i1$1 from '@ptsecurity/cdk/datetime';
|
16
16
|
import { MC_DATE_FORMATS } from '@ptsecurity/cdk/datetime';
|
17
|
+
import * as i4 from '@ptsecurity/mosaic/form-field';
|
18
|
+
import { McFormFieldControl } from '@ptsecurity/mosaic/form-field';
|
19
|
+
import * as i6 from '@ptsecurity/mosaic/core';
|
20
|
+
import { validationTooltipShowDelay, validationTooltipHideDelay } from '@ptsecurity/mosaic/core';
|
17
21
|
import { Subject, Subscription, merge, of } from 'rxjs';
|
18
|
-
import * as i2 from '@angular/cdk/bidi';
|
19
|
-
import { SPACE, ENTER, PAGE_DOWN, PAGE_UP, END, HOME, DOWN_ARROW, UP_ARROW, RIGHT_ARROW, LEFT_ARROW, TAB, ESCAPE, isLetterKey, hasModifierKey, isVerticalMovement, isHorizontalMovement, DELETE, BACKSPACE } from '@ptsecurity/cdk/keycodes';
|
20
22
|
import { coerceBooleanProperty } from '@angular/cdk/coercion';
|
21
23
|
import { NG_VALUE_ACCESSOR, NG_VALIDATORS, Validators } from '@angular/forms';
|
22
|
-
import {
|
23
|
-
import { McFormFieldControl } from '@ptsecurity/mosaic/form-field';
|
24
|
+
import { TAB, SPACE, UP_ARROW, DOWN_ARROW, LEFT_ARROW, RIGHT_ARROW, HOME, PAGE_UP, END, PAGE_DOWN, ESCAPE, isLetterKey, hasModifierKey, isVerticalMovement, isHorizontalMovement, DELETE, BACKSPACE } from '@ptsecurity/cdk/keycodes';
|
24
25
|
import '@ptsecurity/mosaic/tooltip';
|
26
|
+
import * as i5$1 from '@angular/cdk/bidi';
|
27
|
+
import { take } from 'rxjs/operators';
|
25
28
|
import { trigger, state, style, transition, animate } from '@angular/animations';
|
26
29
|
|
27
30
|
// tslint:disable:no-magic-numbers
|
@@ -30,10 +33,9 @@ import { trigger, state, style, transition, animate } from '@angular/animations'
|
|
30
33
|
* @docs-private
|
31
34
|
*/
|
32
35
|
class McCalendarCell {
|
33
|
-
constructor(value, displayValue,
|
36
|
+
constructor(value, displayValue, enabled, cssClasses) {
|
34
37
|
this.value = value;
|
35
38
|
this.displayValue = displayValue;
|
36
|
-
this.ariaLabel = ariaLabel;
|
37
39
|
this.enabled = enabled;
|
38
40
|
this.cssClasses = cssClasses;
|
39
41
|
}
|
@@ -43,9 +45,7 @@ class McCalendarCell {
|
|
43
45
|
* @docs-private
|
44
46
|
*/
|
45
47
|
class McCalendarBody {
|
46
|
-
constructor(
|
47
|
-
this.elementRef = elementRef;
|
48
|
-
this.ngZone = ngZone;
|
48
|
+
constructor() {
|
49
49
|
/** The number of columns in the table. */
|
50
50
|
this.numCols = 7;
|
51
51
|
/** The cell number of the active cell in the table. */
|
@@ -85,30 +85,15 @@ class McCalendarBody {
|
|
85
85
|
}
|
86
86
|
return cellNumber === this.activeCell;
|
87
87
|
}
|
88
|
-
/** Focuses the active cell after the microtask queue is empty. */
|
89
|
-
focusActiveCell() {
|
90
|
-
this.ngZone.runOutsideAngular(() => {
|
91
|
-
this.ngZone.onStable.asObservable().pipe(take(1)).subscribe(() => {
|
92
|
-
const activeCell = this.elementRef.nativeElement.querySelector('.mc-calendar__body_active');
|
93
|
-
if (activeCell) {
|
94
|
-
activeCell.focus();
|
95
|
-
}
|
96
|
-
});
|
97
|
-
});
|
98
|
-
}
|
99
88
|
}
|
100
|
-
/** @nocollapse */ McCalendarBody.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: McCalendarBody, deps: [
|
101
|
-
/** @nocollapse */ McCalendarBody.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.12", type: McCalendarBody, selector: "[mc-calendar-body]", inputs: {
|
89
|
+
/** @nocollapse */ McCalendarBody.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: McCalendarBody, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
90
|
+
/** @nocollapse */ McCalendarBody.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.12", type: McCalendarBody, selector: "[mc-calendar-body]", inputs: { rows: "rows", todayValue: "todayValue", selectedValue: "selectedValue", labelMinRequiredCells: "labelMinRequiredCells", numCols: "numCols", activeCell: "activeCell", cellAspectRatio: "cellAspectRatio" }, outputs: { selectedValueChange: "selectedValueChange" }, host: { classAttribute: "mc-calendar__body" }, exportAs: ["mcCalendarBody"], usesOnChanges: true, ngImport: i0, template: "<!-- Create the first row separately so we can include a special spacer cell. -->\n<tr *ngFor=\"let row of rows; let rowIndex = index\">\n <!--\n We mark this cell as aria-hidden so it doesn't get read out as one of the days in the week.\n The aspect ratio of the table cells is maintained by setting the top and bottom padding as a\n percentage of the width (a variant of the trick described here:\n https://www.w3schools.com/howto/howto_css_aspect_ratio.asp).\n -->\n <td *ngIf=\"rowIndex === 0 && firstRowOffset\"\n class=\"mc-calendar__body-label\"\n [attr.colspan]=\"firstRowOffset\">\n </td>\n\n <td *ngFor=\"let item of row; let colIndex = index\"\n class=\"mc-calendar__body-cell\"\n [ngClass]=\"item.cssClasses!\"\n [tabindex]=\"isActiveCell(rowIndex, colIndex) ? 0 : -1\"\n [class.mc-calendar__body_disabled]=\"!item.enabled\"\n [class.mc-calendar__body_active]=\"isActiveCell(rowIndex, colIndex)\"\n (click)=\"cellClicked(item)\"\n [style.width]=\"cellWidth\"\n [style.paddingTop]=\"cellPadding\"\n [style.paddingBottom]=\"cellPadding\">\n <div class=\"mc-calendar__body-cell-content\"\n [class.mc-selected]=\"selectedValue === item.value\"\n [class.mc-calendar__body-today]=\"todayValue === item.value\">\n {{ item.displayValue }}\n </div>\n </td>\n</tr>\n", styles: [".mc-calendar__body{min-width:224px;min-width:calc(7 * var(--mc-datepicker-body-size-cell-min-size, 32px))}.mc-calendar__body-cell{position:relative;height:0;line-height:0;text-align:center;outline:none;cursor:pointer}.mc-calendar__body_disabled{cursor:default}.mc-calendar__body-cell-content{position:absolute;top:5%;top:var(--mc-datepicker-body-size-cell-margin, 5%);left:5%;left:var(--mc-datepicker-body-size-cell-margin, 5%);padding:8px;padding:var(--mc-datepicker-body-size-cell-padding, 8px);display:flex;align-items:center;justify-content:center;box-sizing:border-box;width:90%;height:90%;line-height:1;border-width:1px;border-width:var(--mc-datepicker-body-size-cell-border-width, 1px);border-radius:0;border-radius:var(--mc-datepicker-body-size-cell-border-radius, 0);border-style:solid}.cdk-high-contrast-active .mc-calendar__body-cell-content{border:none}.cdk-high-contrast-active :host .mc-calendar__body-cell-content{border:none}mc-month-view .mc-calendar__body-cell-content{justify-content:flex-end}.cdk-high-contrast-active .mc-datepicker__popup:not(:empty),.cdk-high-contrast-active .mc-selected{outline:solid 1px}.cdk-high-contrast-active .mc-calendar__body-today{outline:dotted 1px}.cdk-high-contrast-active :host .mc-datepicker__popup:not(:empty),.cdk-high-contrast-active :host .mc-selected{outline:solid 1px}.cdk-high-contrast-active :host .mc-calendar__body-today{outline:dotted 1px}\n"], dependencies: [{ kind: "directive", type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
102
91
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: McCalendarBody, decorators: [{
|
103
92
|
type: Component,
|
104
93
|
args: [{ selector: '[mc-calendar-body]', exportAs: 'mcCalendarBody', host: {
|
105
|
-
class: 'mc-calendar__body'
|
106
|
-
|
107
|
-
|
108
|
-
}, encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, template: "<!--\n If there's not enough space in the first row, create a separate label row. We mark this row as\n aria-hidden because we don't want it to be read out as one of the weeks in the month.\n-->\n<tr *ngIf=\"firstRowOffset < labelMinRequiredCells\">\n <td class=\"mc-calendar__body-label\" [attr.colspan]=\"numCols\">\n {{ label }}\n </td>\n</tr>\n\n<!-- Create the first row separately so we can include a special spacer cell. -->\n<tr *ngFor=\"let row of rows; let rowIndex = index\">\n <!--\n We mark this cell as aria-hidden so it doesn't get read out as one of the days in the week.\n The aspect ratio of the table cells is maintained by setting the top and bottom padding as a\n percentage of the width (a variant of the trick described here:\n https://www.w3schools.com/howto/howto_css_aspect_ratio.asp).\n -->\n <td *ngIf=\"rowIndex === 0 && firstRowOffset\"\n class=\"mc-calendar__body-label\"\n [attr.colspan]=\"firstRowOffset\">\n {{ firstRowOffset >= labelMinRequiredCells ? label : '' }}\n </td>\n <td *ngFor=\"let item of row; let colIndex = index\"\n class=\"mc-calendar__body-cell\"\n [ngClass]=\"item.cssClasses!\"\n [tabindex]=\"isActiveCell(rowIndex, colIndex) ? 0 : -1\"\n [class.mc-calendar__body_disabled]=\"!item.enabled\"\n [class.mc-calendar__body_active]=\"isActiveCell(rowIndex, colIndex)\"\n (click)=\"cellClicked(item)\"\n [style.width]=\"cellWidth\"\n [style.paddingTop]=\"cellPadding\"\n [style.paddingBottom]=\"cellPadding\">\n <div class=\"mc-calendar__body-cell-content\"\n [class.mc-selected]=\"selectedValue === item.value\"\n [class.mc-calendar__body-today]=\"todayValue === item.value\">\n {{ item.displayValue }}\n </div>\n </td>\n</tr>\n", styles: [".mc-calendar__body{min-width:224px;min-width:calc(7 * var(--mc-datepicker-body-size-cell-min-size, 32px))}.mc-calendar__body-label{text-align:left;padding:8px 28px 12px 12px;padding:var(--mc-datepicker-body-size-label-paddings, 8px 28px 12px 12px)}.mc-calendar__body-cell{position:relative;height:0;line-height:0;text-align:center;outline:none;cursor:pointer}.mc-calendar__body_disabled{cursor:default}.mc-calendar__body-cell-content{position:absolute;top:5%;top:var(--mc-datepicker-body-size-cell-margin, 5%);left:5%;left:var(--mc-datepicker-body-size-cell-margin, 5%);padding:8px;padding:var(--mc-datepicker-body-size-cell-padding, 8px);display:flex;align-items:center;justify-content:center;box-sizing:border-box;width:90%;height:90%;line-height:1;border-width:1px;border-width:var(--mc-datepicker-body-size-cell-border-width, 1px);border-radius:0;border-radius:var(--mc-datepicker-body-size-cell-border-radius, 0);border-style:solid}.cdk-high-contrast-active .mc-calendar__body-cell-content{border:none}.cdk-high-contrast-active :host .mc-calendar__body-cell-content{border:none}mc-month-view .mc-calendar__body-cell-content{justify-content:flex-end}mc-multi-year-view .mc-calendar__body-cell-content,mc-year-view .mc-calendar__body-cell-content{justify-content:center}.cdk-high-contrast-active .mc-datepicker__popup:not(:empty),.cdk-high-contrast-active .mc-selected{outline:solid 1px}.cdk-high-contrast-active .mc-calendar__body-today{outline:dotted 1px}.cdk-high-contrast-active :host .mc-datepicker__popup:not(:empty),.cdk-high-contrast-active :host .mc-selected{outline:solid 1px}.cdk-high-contrast-active :host .mc-calendar__body-today{outline:dotted 1px}[dir=rtl] .mc-calendar__body-label{text-align:right}\n"] }]
|
109
|
-
}], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i0.NgZone }]; }, propDecorators: { label: [{
|
110
|
-
type: Input
|
111
|
-
}], rows: [{
|
94
|
+
class: 'mc-calendar__body'
|
95
|
+
}, encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, template: "<!-- Create the first row separately so we can include a special spacer cell. -->\n<tr *ngFor=\"let row of rows; let rowIndex = index\">\n <!--\n We mark this cell as aria-hidden so it doesn't get read out as one of the days in the week.\n The aspect ratio of the table cells is maintained by setting the top and bottom padding as a\n percentage of the width (a variant of the trick described here:\n https://www.w3schools.com/howto/howto_css_aspect_ratio.asp).\n -->\n <td *ngIf=\"rowIndex === 0 && firstRowOffset\"\n class=\"mc-calendar__body-label\"\n [attr.colspan]=\"firstRowOffset\">\n </td>\n\n <td *ngFor=\"let item of row; let colIndex = index\"\n class=\"mc-calendar__body-cell\"\n [ngClass]=\"item.cssClasses!\"\n [tabindex]=\"isActiveCell(rowIndex, colIndex) ? 0 : -1\"\n [class.mc-calendar__body_disabled]=\"!item.enabled\"\n [class.mc-calendar__body_active]=\"isActiveCell(rowIndex, colIndex)\"\n (click)=\"cellClicked(item)\"\n [style.width]=\"cellWidth\"\n [style.paddingTop]=\"cellPadding\"\n [style.paddingBottom]=\"cellPadding\">\n <div class=\"mc-calendar__body-cell-content\"\n [class.mc-selected]=\"selectedValue === item.value\"\n [class.mc-calendar__body-today]=\"todayValue === item.value\">\n {{ item.displayValue }}\n </div>\n </td>\n</tr>\n", styles: [".mc-calendar__body{min-width:224px;min-width:calc(7 * var(--mc-datepicker-body-size-cell-min-size, 32px))}.mc-calendar__body-cell{position:relative;height:0;line-height:0;text-align:center;outline:none;cursor:pointer}.mc-calendar__body_disabled{cursor:default}.mc-calendar__body-cell-content{position:absolute;top:5%;top:var(--mc-datepicker-body-size-cell-margin, 5%);left:5%;left:var(--mc-datepicker-body-size-cell-margin, 5%);padding:8px;padding:var(--mc-datepicker-body-size-cell-padding, 8px);display:flex;align-items:center;justify-content:center;box-sizing:border-box;width:90%;height:90%;line-height:1;border-width:1px;border-width:var(--mc-datepicker-body-size-cell-border-width, 1px);border-radius:0;border-radius:var(--mc-datepicker-body-size-cell-border-radius, 0);border-style:solid}.cdk-high-contrast-active .mc-calendar__body-cell-content{border:none}.cdk-high-contrast-active :host .mc-calendar__body-cell-content{border:none}mc-month-view .mc-calendar__body-cell-content{justify-content:flex-end}.cdk-high-contrast-active .mc-datepicker__popup:not(:empty),.cdk-high-contrast-active .mc-selected{outline:solid 1px}.cdk-high-contrast-active .mc-calendar__body-today{outline:dotted 1px}.cdk-high-contrast-active :host .mc-datepicker__popup:not(:empty),.cdk-high-contrast-active :host .mc-selected{outline:solid 1px}.cdk-high-contrast-active :host .mc-calendar__body-today{outline:dotted 1px}\n"] }]
|
96
|
+
}], propDecorators: { rows: [{
|
112
97
|
type: Input
|
113
98
|
}], todayValue: [{
|
114
99
|
type: Input
|
@@ -126,6 +111,131 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImpo
|
|
126
111
|
type: Output
|
127
112
|
}] } });
|
128
113
|
|
114
|
+
const defaultMinYear = 1900;
|
115
|
+
const defaultMaxYear = 2099;
|
116
|
+
/** Default header for McCalendar */
|
117
|
+
class McCalendarHeader {
|
118
|
+
constructor(adapter) {
|
119
|
+
this.adapter = adapter;
|
120
|
+
this.years = [];
|
121
|
+
// tslint:disable-next-line:no-magic-numbers
|
122
|
+
this._maxDate = this.adapter.createDate(defaultMaxYear, 11);
|
123
|
+
this._minDate = this.adapter.createDate(defaultMinYear, 1);
|
124
|
+
/** Emits when any date is activated. */
|
125
|
+
this.activeDateChange = new EventEmitter();
|
126
|
+
this.monthSelected = new EventEmitter();
|
127
|
+
this.yearSelected = new EventEmitter();
|
128
|
+
this.monthNames = this.adapter.getMonthNames('long')
|
129
|
+
.map((name, i) => ({ name, value: i }));
|
130
|
+
}
|
131
|
+
get activeDate() {
|
132
|
+
return this._activeDate;
|
133
|
+
}
|
134
|
+
set activeDate(value) {
|
135
|
+
this._activeDate = value;
|
136
|
+
this.updateSelectedValues();
|
137
|
+
}
|
138
|
+
get maxDate() {
|
139
|
+
return this._maxDate;
|
140
|
+
}
|
141
|
+
set maxDate(value) {
|
142
|
+
if (!value) {
|
143
|
+
return;
|
144
|
+
}
|
145
|
+
this._maxDate = value;
|
146
|
+
this.updateYearsArray();
|
147
|
+
}
|
148
|
+
get minDate() {
|
149
|
+
return this._minDate;
|
150
|
+
}
|
151
|
+
set minDate(value) {
|
152
|
+
if (!value) {
|
153
|
+
return;
|
154
|
+
}
|
155
|
+
this._minDate = value;
|
156
|
+
this.updateYearsArray();
|
157
|
+
}
|
158
|
+
get previousDisabled() {
|
159
|
+
return this.compareDate(this.activeDate, this.minDate) < 0;
|
160
|
+
}
|
161
|
+
get nextDisabled() {
|
162
|
+
return this.compareDate(this.activeDate, this.maxDate) >= 0;
|
163
|
+
}
|
164
|
+
ngAfterContentInit() {
|
165
|
+
this.updateYearsArray();
|
166
|
+
this.updateSelectedValues();
|
167
|
+
}
|
168
|
+
/** Handles when a new month is selected. */
|
169
|
+
onMonthSelected(month) {
|
170
|
+
const year = this.adapter.getYear(this.activeDate);
|
171
|
+
const normalizedDate = this.adapter.createDate(year, month);
|
172
|
+
const daysInMonth = this.adapter.getNumDaysInMonth(normalizedDate);
|
173
|
+
this.activeDate = this.adapter.createDate(year, month, Math.min(this.adapter.getDate(this.activeDate), daysInMonth));
|
174
|
+
this.monthSelected.emit(this.activeDate);
|
175
|
+
this.activeDateChange.emit(this.activeDate);
|
176
|
+
}
|
177
|
+
/** Handles when a new year is selected. */
|
178
|
+
onYearSelected(year) {
|
179
|
+
const month = this.adapter.getMonth(this.activeDate);
|
180
|
+
const daysInMonth = this.adapter.getNumDaysInMonth(this.adapter.createDate(year, month));
|
181
|
+
this.activeDate = this.adapter.createDate(year, month, Math.min(this.adapter.getDate(this.activeDate), daysInMonth));
|
182
|
+
this.yearSelected.emit(this.activeDate);
|
183
|
+
this.activeDateChange.emit(this.activeDate);
|
184
|
+
}
|
185
|
+
selectCurrentDate() {
|
186
|
+
this.activeDate = this.adapter.today();
|
187
|
+
this.activeDateChange.emit(this.activeDate);
|
188
|
+
}
|
189
|
+
/** Handles user clicks on the previous button. */
|
190
|
+
selectPreviousMonth() {
|
191
|
+
this.activeDate = this.adapter.addCalendarMonths(this.activeDate, -1);
|
192
|
+
this.activeDateChange.emit(this.activeDate);
|
193
|
+
}
|
194
|
+
/** Handles user clicks on the next button. */
|
195
|
+
selectNextMonth() {
|
196
|
+
this.activeDate = this.adapter.addCalendarMonths(this.activeDate, 1);
|
197
|
+
this.activeDateChange.emit(this.activeDate);
|
198
|
+
}
|
199
|
+
compareDate(first, second) {
|
200
|
+
const normalizedFirst = this.adapter.createDate(this.adapter.getYear(first), this.adapter.getMonth(first));
|
201
|
+
const normalizedSecond = this.adapter.createDate(this.adapter.getYear(second), this.adapter.getMonth(second));
|
202
|
+
return this.adapter.compareDate(normalizedFirst, normalizedSecond);
|
203
|
+
}
|
204
|
+
updateSelectedValues() {
|
205
|
+
this.selectedMonth = this.monthNames[this.adapter.getMonth(this.activeDate)].value;
|
206
|
+
const selectedYear = this.adapter.getYear(this.activeDate);
|
207
|
+
this.selectedYear = this.years.includes(selectedYear) ? selectedYear : this.years[0];
|
208
|
+
}
|
209
|
+
updateYearsArray() {
|
210
|
+
const minYear = this.adapter.getYear(this.minDate);
|
211
|
+
const maxYear = this.adapter.getYear(this.maxDate);
|
212
|
+
this.years = [];
|
213
|
+
for (let i = minYear; i <= maxYear; i++) {
|
214
|
+
this.years.push(i);
|
215
|
+
}
|
216
|
+
}
|
217
|
+
}
|
218
|
+
/** @nocollapse */ McCalendarHeader.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: McCalendarHeader, deps: [{ token: i1$1.DateAdapter }], target: i0.ɵɵFactoryTarget.Component });
|
219
|
+
/** @nocollapse */ McCalendarHeader.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.12", type: McCalendarHeader, selector: "mc-calendar-header", inputs: { activeDate: "activeDate", maxDate: "maxDate", minDate: "minDate" }, outputs: { activeDateChange: "activeDateChange", monthSelected: "monthSelected", yearSelected: "yearSelected" }, host: { classAttribute: "mc-calendar-header" }, exportAs: ["mcCalendarHeader"], ngImport: i0, template: "<div class=\"mc-calendar-header__select-group\">\n <mc-select\n class=\"mc-calendar-header__select\"\n #monthSelect=\"mcSelect\"\n [value]=\"selectedMonth\"\n [panelClass]=\"'mc-calendar-select-panel'\"\n (selectionChange)=\"onMonthSelected($event.value)\">\n\n <button class=\"mc-button_transparent layout-padding-right-xs\"\n mc-button\n mc-select-matcher\n [class.mc-active]=\"monthSelect.panelOpen\"\n [tabindex]=\"-1\">\n {{ monthSelect.triggerValue }}\n\n <i class=\"layout-padding-left-3xs\" mc-icon=\"mc-angle-down-S_16\"></i>\n </button>\n\n <mc-option *ngFor=\"let month of monthNames\"\n [mcTooltipDisabled]=\"true\"\n [value]=\"month.value\">\n {{ month.name }}\n </mc-option>\n </mc-select>\n\n <mc-select\n #yearSelect=\"mcSelect\"\n [value]=\"selectedYear\"\n [panelClass]=\"'mc-calendar-select-panel'\"\n (selectionChange)=\"onYearSelected($event.value)\">\n <button class=\"mc-button_transparent layout-padding-right-xs\"\n mc-button\n mc-select-matcher\n [class.mc-active]=\"yearSelect.panelOpen\"\n [tabindex]=\"-1\">\n {{ yearSelect.triggerValue }}\n\n <i class=\"layout-padding-left-3xs\" mc-icon=\"mc-angle-down-S_16\"></i>\n </button>\n\n <mc-option *ngFor=\"let year of years\"\n [mcTooltipDisabled]=\"true\"\n [value]=\"year\">\n {{ year }}\n </mc-option>\n </mc-select>\n</div>\n\n<div class=\"mc-calendar-header__button-group\">\n <button mc-button\n class=\"mc-button_transparent mc-calendar-header__previous-button\"\n [tabindex]=\"-1\"\n [disabled]=\"previousDisabled\"\n (click)=\"selectPreviousMonth()\">\n\n <i mc-icon=\"mc-angle-left-L_16\"></i>\n </button>\n\n <button mc-button\n class=\"mc-button_transparent\"\n [tabindex]=\"-1\"\n (click)=\"selectCurrentDate()\">\n\n <i mc-icon=\"mc-circle-8_16\"></i>\n </button>\n\n <button mc-button\n class=\"mc-button_transparent mc-calendar-header__next-button\"\n [tabindex]=\"-1\"\n [disabled]=\"nextDisabled\"\n (click)=\"selectNextMonth()\">\n\n <i mc-icon=\"mc-angle-right-L_16\"></i>\n </button>\n</div>\n", styles: [".mc-calendar-header{display:flex;flex-direction:row;justify-content:space-between;padding:16px 8px 12px;padding:var(--mc-datepicker-calendar-size-padding-top, 16px) var(--mc-datepicker-calendar-size-padding-horizontal, 8px) var(--mc-datepicker-calendar-size-padding-blocks, 12px) var(--mc-datepicker-calendar-size-padding-horizontal, 8px)}.mc-calendar-header__previous-button:after{border-left-width:2px;border-left-width:var(--mc-datepicker-calendar-size-icon-border-width, 2px);transform:translate(2px) rotate(-45deg);transform:var(--mc-datepicker-calendar-size-icon-prev-icon-transform, translateX(2px) rotate(-45deg))}.mc-calendar-header__next-button:after{border-right-width:2px;border-right-width:var(--mc-datepicker-calendar-size-icon-border-width, 2px);transform:translate(-2px) rotate(45deg);transform:var(--mc-datepicker-calendar-size-icon-nex-icon-transform, translateX(-2px) rotate(45deg))}.mc-calendar-header__select{width:auto!important}.mc-calendar-header__button-group,.mc-calendar-header__select-group{display:flex;flex-direction:row}.mc-calendar-select-panel{margin-top:2px;min-width:98%!important}.mc-calendar-select-panel .mc-select__content{max-height:384px}\n"], dependencies: [{ kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "component", type: i3.McButton, selector: "[mc-button]", inputs: ["color", "tabIndex", "disabled"] }, { kind: "directive", type: i3.McButtonCssStyler, selector: "[mc-button]" }, { kind: "directive", type: i4.McValidateDirective, selector: " input[mcInput], input[mcInputPassword], input[mcTimepicker], input[mcDatepicker], mc-select, mc-tag-list, textarea[mcTextarea], mc-tree-select ", exportAs: ["McValidate"] }, { kind: "component", type: i5.McSelect, selector: "mc-select", inputs: ["disabled", "tabIndex", "hiddenItemsText", "panelClass", "backdropClass", "errorStateMatcher", "sortComparator", "hasBackdrop", "placeholder", "required", "multiple", "compareWith", "value", "id", "hiddenItemsTextFormatter"], outputs: ["openedChange", "opened", "closed", "selectionChange", "valueChange"], exportAs: ["mcSelect"] }, { kind: "directive", type: i5.McSelectMatcher, selector: "mc-select-matcher, [mc-select-matcher]" }, { kind: "directive", type: i5.McOptionTooltip, selector: "mc-option" }, { kind: "component", type: i6.McOption, selector: "mc-option", inputs: ["value", "showCheckbox", "disabled"], outputs: ["onSelectionChange"], exportAs: ["mcOption"] }, { kind: "component", type: i7.McIcon, selector: "[mc-icon]", inputs: ["color"] }, { kind: "directive", type: i7.McIconCSSStyler, selector: "[mc-icon]" }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
220
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: McCalendarHeader, decorators: [{
|
221
|
+
type: Component,
|
222
|
+
args: [{ selector: 'mc-calendar-header', exportAs: 'mcCalendarHeader', host: {
|
223
|
+
class: 'mc-calendar-header'
|
224
|
+
}, encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, template: "<div class=\"mc-calendar-header__select-group\">\n <mc-select\n class=\"mc-calendar-header__select\"\n #monthSelect=\"mcSelect\"\n [value]=\"selectedMonth\"\n [panelClass]=\"'mc-calendar-select-panel'\"\n (selectionChange)=\"onMonthSelected($event.value)\">\n\n <button class=\"mc-button_transparent layout-padding-right-xs\"\n mc-button\n mc-select-matcher\n [class.mc-active]=\"monthSelect.panelOpen\"\n [tabindex]=\"-1\">\n {{ monthSelect.triggerValue }}\n\n <i class=\"layout-padding-left-3xs\" mc-icon=\"mc-angle-down-S_16\"></i>\n </button>\n\n <mc-option *ngFor=\"let month of monthNames\"\n [mcTooltipDisabled]=\"true\"\n [value]=\"month.value\">\n {{ month.name }}\n </mc-option>\n </mc-select>\n\n <mc-select\n #yearSelect=\"mcSelect\"\n [value]=\"selectedYear\"\n [panelClass]=\"'mc-calendar-select-panel'\"\n (selectionChange)=\"onYearSelected($event.value)\">\n <button class=\"mc-button_transparent layout-padding-right-xs\"\n mc-button\n mc-select-matcher\n [class.mc-active]=\"yearSelect.panelOpen\"\n [tabindex]=\"-1\">\n {{ yearSelect.triggerValue }}\n\n <i class=\"layout-padding-left-3xs\" mc-icon=\"mc-angle-down-S_16\"></i>\n </button>\n\n <mc-option *ngFor=\"let year of years\"\n [mcTooltipDisabled]=\"true\"\n [value]=\"year\">\n {{ year }}\n </mc-option>\n </mc-select>\n</div>\n\n<div class=\"mc-calendar-header__button-group\">\n <button mc-button\n class=\"mc-button_transparent mc-calendar-header__previous-button\"\n [tabindex]=\"-1\"\n [disabled]=\"previousDisabled\"\n (click)=\"selectPreviousMonth()\">\n\n <i mc-icon=\"mc-angle-left-L_16\"></i>\n </button>\n\n <button mc-button\n class=\"mc-button_transparent\"\n [tabindex]=\"-1\"\n (click)=\"selectCurrentDate()\">\n\n <i mc-icon=\"mc-circle-8_16\"></i>\n </button>\n\n <button mc-button\n class=\"mc-button_transparent mc-calendar-header__next-button\"\n [tabindex]=\"-1\"\n [disabled]=\"nextDisabled\"\n (click)=\"selectNextMonth()\">\n\n <i mc-icon=\"mc-angle-right-L_16\"></i>\n </button>\n</div>\n", styles: [".mc-calendar-header{display:flex;flex-direction:row;justify-content:space-between;padding:16px 8px 12px;padding:var(--mc-datepicker-calendar-size-padding-top, 16px) var(--mc-datepicker-calendar-size-padding-horizontal, 8px) var(--mc-datepicker-calendar-size-padding-blocks, 12px) var(--mc-datepicker-calendar-size-padding-horizontal, 8px)}.mc-calendar-header__previous-button:after{border-left-width:2px;border-left-width:var(--mc-datepicker-calendar-size-icon-border-width, 2px);transform:translate(2px) rotate(-45deg);transform:var(--mc-datepicker-calendar-size-icon-prev-icon-transform, translateX(2px) rotate(-45deg))}.mc-calendar-header__next-button:after{border-right-width:2px;border-right-width:var(--mc-datepicker-calendar-size-icon-border-width, 2px);transform:translate(-2px) rotate(45deg);transform:var(--mc-datepicker-calendar-size-icon-nex-icon-transform, translateX(-2px) rotate(45deg))}.mc-calendar-header__select{width:auto!important}.mc-calendar-header__button-group,.mc-calendar-header__select-group{display:flex;flex-direction:row}.mc-calendar-select-panel{margin-top:2px;min-width:98%!important}.mc-calendar-select-panel .mc-select__content{max-height:384px}\n"] }]
|
225
|
+
}], ctorParameters: function () { return [{ type: i1$1.DateAdapter }]; }, propDecorators: { activeDate: [{
|
226
|
+
type: Input
|
227
|
+
}], maxDate: [{
|
228
|
+
type: Input
|
229
|
+
}], minDate: [{
|
230
|
+
type: Input
|
231
|
+
}], activeDateChange: [{
|
232
|
+
type: Output
|
233
|
+
}], monthSelected: [{
|
234
|
+
type: Output
|
235
|
+
}], yearSelected: [{
|
236
|
+
type: Output
|
237
|
+
}] } });
|
238
|
+
|
129
239
|
/** @docs-private */
|
130
240
|
function createMissingDateImplError(provider) {
|
131
241
|
return Error(`McDatepicker: No provider found for ${provider}. You must import one of the existing ` +
|
@@ -176,26 +286,25 @@ const DAYS_PER_WEEK = 7;
|
|
176
286
|
* @docs-private
|
177
287
|
*/
|
178
288
|
class McMonthView {
|
179
|
-
constructor(changeDetectorRef, dateFormats,
|
289
|
+
constructor(changeDetectorRef, dateFormats, adapter) {
|
180
290
|
this.changeDetectorRef = changeDetectorRef;
|
181
291
|
this.dateFormats = dateFormats;
|
182
|
-
this.
|
183
|
-
this.dir = dir;
|
292
|
+
this.adapter = adapter;
|
184
293
|
/** Emits when a new date is selected. */
|
185
294
|
this.selectedChange = new EventEmitter();
|
186
295
|
/** Emits when any date is selected. */
|
187
296
|
this.userSelection = new EventEmitter();
|
188
297
|
/** Emits when any date is activated. */
|
189
298
|
this.activeDateChange = new EventEmitter();
|
190
|
-
if (!this.
|
299
|
+
if (!this.adapter) {
|
191
300
|
throw createMissingDateImplError('DateAdapter');
|
192
301
|
}
|
193
302
|
if (!this.dateFormats) {
|
194
303
|
throw createMissingDateImplError('MC_DATE_FORMATS');
|
195
304
|
}
|
196
|
-
const firstDayOfWeek = this.
|
197
|
-
const narrowWeekdays = this.
|
198
|
-
const longWeekdays = this.
|
305
|
+
const firstDayOfWeek = this.adapter.getFirstDayOfWeek();
|
306
|
+
const narrowWeekdays = this.adapter.getDayOfWeekNames('short');
|
307
|
+
const longWeekdays = this.adapter.getDayOfWeekNames('long');
|
199
308
|
// Rotate the labels for days of the week based on the configured first day of the week.
|
200
309
|
const weekdays = longWeekdays.map((long, i) => {
|
201
310
|
return { long, narrow: narrowWeekdays[i] };
|
@@ -203,7 +312,7 @@ class McMonthView {
|
|
203
312
|
this.weekdays = weekdays
|
204
313
|
.slice(firstDayOfWeek)
|
205
314
|
.concat(weekdays.slice(0, firstDayOfWeek));
|
206
|
-
this._activeDate = this.
|
315
|
+
this._activeDate = this.adapter.today();
|
207
316
|
}
|
208
317
|
/**
|
209
318
|
* The date to display in this month view (everything other than the month and year is ignored).
|
@@ -212,10 +321,9 @@ class McMonthView {
|
|
212
321
|
return this._activeDate;
|
213
322
|
}
|
214
323
|
set activeDate(value) {
|
215
|
-
const
|
216
|
-
|
217
|
-
|
218
|
-
if (!this.hasSameMonthAndYear(oldActiveDate, this._activeDate)) {
|
324
|
+
const oldValue = this._activeDate;
|
325
|
+
this._activeDate = value;
|
326
|
+
if (!this.hasSameMonthAndYear(oldValue, value)) {
|
219
327
|
this.init();
|
220
328
|
}
|
221
329
|
}
|
@@ -224,165 +332,73 @@ class McMonthView {
|
|
224
332
|
return this._selected;
|
225
333
|
}
|
226
334
|
set selected(value) {
|
227
|
-
this._selected =
|
335
|
+
this._selected = value;
|
228
336
|
this.selectedDate = this.getDateInCurrentMonth(this._selected);
|
229
337
|
}
|
230
|
-
/** The minimum selectable date. */
|
231
|
-
get minDate() {
|
232
|
-
return this._minDate;
|
233
|
-
}
|
234
|
-
set minDate(value) {
|
235
|
-
this._minDate = this.getValidDateOrNull(this.dateAdapter.deserialize(value));
|
236
|
-
}
|
237
|
-
/** The maximum selectable date. */
|
238
|
-
get maxDate() {
|
239
|
-
return this._maxDate;
|
240
|
-
}
|
241
|
-
set maxDate(value) {
|
242
|
-
this._maxDate = this.getValidDateOrNull(this.dateAdapter.deserialize(value));
|
243
|
-
}
|
244
338
|
ngAfterContentInit() {
|
245
339
|
this.init();
|
246
340
|
}
|
247
341
|
/** Handles when a new date is selected. */
|
248
342
|
dateSelected(date) {
|
249
343
|
if (this.selectedDate !== date) {
|
250
|
-
const selectedYear = this.
|
251
|
-
const selectedMonth = this.
|
252
|
-
const selectedDate = this.
|
344
|
+
const selectedYear = this.adapter.getYear(this.activeDate);
|
345
|
+
const selectedMonth = this.adapter.getMonth(this.activeDate);
|
346
|
+
const selectedDate = this.adapter.createDate(selectedYear, selectedMonth, date);
|
253
347
|
this.selectedChange.emit(selectedDate);
|
254
348
|
}
|
255
349
|
this.userSelection.emit();
|
256
350
|
}
|
257
|
-
/** Handles keydown events on the calendar body when calendar is in month view. */
|
258
|
-
handleCalendarBodyKeydown(event) {
|
259
|
-
// TODO(mmalerba): We currently allow keyboard navigation to disabled dates, but just prevent
|
260
|
-
// disabled ones from being selected. This may not be ideal, we should look into whether
|
261
|
-
// navigation should skip over disabled dates, and if so, how to implement that efficiently.
|
262
|
-
const oldActiveDate = this._activeDate;
|
263
|
-
const isRtl = this.isRtl();
|
264
|
-
// tslint:disable-next-line:deprecation
|
265
|
-
switch (event.keyCode) {
|
266
|
-
case LEFT_ARROW:
|
267
|
-
this.activeDate = this.dateAdapter.addCalendarDays(this._activeDate, isRtl ? 1 : -1);
|
268
|
-
break;
|
269
|
-
case RIGHT_ARROW:
|
270
|
-
this.activeDate = this.dateAdapter.addCalendarDays(this._activeDate, isRtl ? -1 : 1);
|
271
|
-
break;
|
272
|
-
case UP_ARROW:
|
273
|
-
this.activeDate = this.dateAdapter.addCalendarDays(this._activeDate, -7);
|
274
|
-
break;
|
275
|
-
case DOWN_ARROW:
|
276
|
-
this.activeDate = this.dateAdapter.addCalendarDays(this._activeDate, 7);
|
277
|
-
break;
|
278
|
-
case HOME:
|
279
|
-
this.activeDate = this.dateAdapter.addCalendarDays(this._activeDate, 1 - this.dateAdapter.getDate(this._activeDate));
|
280
|
-
break;
|
281
|
-
case END:
|
282
|
-
this.activeDate = this.dateAdapter.addCalendarDays(this._activeDate, (this.dateAdapter.getNumDaysInMonth(this._activeDate) - this.dateAdapter.getDate(this._activeDate)));
|
283
|
-
break;
|
284
|
-
case PAGE_UP:
|
285
|
-
this.activeDate = event.altKey ?
|
286
|
-
this.dateAdapter.addCalendarYears(this._activeDate, -1) :
|
287
|
-
this.dateAdapter.addCalendarMonths(this._activeDate, -1);
|
288
|
-
break;
|
289
|
-
case PAGE_DOWN:
|
290
|
-
this.activeDate = event.altKey ?
|
291
|
-
this.dateAdapter.addCalendarYears(this._activeDate, 1) :
|
292
|
-
this.dateAdapter.addCalendarMonths(this._activeDate, 1);
|
293
|
-
break;
|
294
|
-
case ENTER:
|
295
|
-
case SPACE:
|
296
|
-
if (!this.dateFilter || this.dateFilter(this._activeDate)) {
|
297
|
-
this.dateSelected(this.dateAdapter.getDate(this._activeDate));
|
298
|
-
this.userSelection.emit();
|
299
|
-
// Prevent unexpected default actions such as form submission.
|
300
|
-
event.preventDefault();
|
301
|
-
}
|
302
|
-
return;
|
303
|
-
default:
|
304
|
-
// Don't prevent default or focus active cell on keys that we don't explicitly handle.
|
305
|
-
return;
|
306
|
-
}
|
307
|
-
if (this.dateAdapter.compareDate(oldActiveDate, this.activeDate)) {
|
308
|
-
this.activeDateChange.emit(this.activeDate);
|
309
|
-
}
|
310
|
-
this.focusActiveCell();
|
311
|
-
// Prevent unexpected default actions such as form submission.
|
312
|
-
event.preventDefault();
|
313
|
-
}
|
314
351
|
/** Initializes this month view. */
|
315
352
|
init() {
|
316
353
|
this.selectedDate = this.getDateInCurrentMonth(this.selected);
|
317
|
-
this.todayDate = this.getDateInCurrentMonth(this.
|
318
|
-
|
319
|
-
this.
|
320
|
-
const firstOfMonth = this.dateAdapter.createDate(this.dateAdapter.getYear(this.activeDate), this.dateAdapter.getMonth(this.activeDate));
|
321
|
-
this.firstWeekOffset =
|
322
|
-
(DAYS_PER_WEEK + this.dateAdapter.getDayOfWeek(firstOfMonth) -
|
323
|
-
this.dateAdapter.getFirstDayOfWeek()) % DAYS_PER_WEEK;
|
354
|
+
this.todayDate = this.getDateInCurrentMonth(this.adapter.today());
|
355
|
+
const firstOfMonth = this.adapter.createDate(this.adapter.getYear(this.activeDate), this.adapter.getMonth(this.activeDate));
|
356
|
+
this.firstWeekOffset = (DAYS_PER_WEEK + this.adapter.getDayOfWeek(firstOfMonth) - this.adapter.getFirstDayOfWeek()) % DAYS_PER_WEEK;
|
324
357
|
this.createWeekCells();
|
325
358
|
this.changeDetectorRef.markForCheck();
|
326
359
|
}
|
327
|
-
/** Focuses the active cell after the microtask queue is empty. */
|
328
|
-
focusActiveCell() {
|
329
|
-
this.mcCalendarBody.focusActiveCell();
|
330
|
-
}
|
331
360
|
/** Creates McCalendarCells for the dates in this month. */
|
332
361
|
createWeekCells() {
|
333
|
-
const daysInMonth = this.
|
334
|
-
const dateNames = this.
|
362
|
+
const daysInMonth = this.adapter.getNumDaysInMonth(this.activeDate);
|
363
|
+
const dateNames = this.adapter.getDateNames();
|
335
364
|
this.weeks = [[]];
|
336
365
|
for (let i = 0, cell = this.firstWeekOffset; i < daysInMonth; i++, cell++) {
|
337
366
|
if (cell === DAYS_PER_WEEK) {
|
338
367
|
this.weeks.push([]);
|
339
368
|
cell = 0;
|
340
369
|
}
|
341
|
-
const date = this.
|
370
|
+
const date = this.adapter.createDate(this.adapter.getYear(this.activeDate), this.adapter.getMonth(this.activeDate), i + 1);
|
342
371
|
const enabled = this.shouldEnableDate(date);
|
343
|
-
const ariaLabel = this.dateAdapter.format(date, this.dateFormats.dateA11yLabel);
|
344
372
|
const cellClasses = this.dateClass ? this.dateClass(date) : undefined;
|
345
373
|
this.weeks[this.weeks.length - 1]
|
346
|
-
.push(new McCalendarCell(i + 1, dateNames[i],
|
374
|
+
.push(new McCalendarCell(i + 1, dateNames[i], enabled, cellClasses));
|
347
375
|
}
|
348
376
|
}
|
349
377
|
/** Date filter for the month */
|
350
378
|
shouldEnableDate(date) {
|
351
379
|
return !!date &&
|
352
380
|
(!this.dateFilter || this.dateFilter(date)) &&
|
353
|
-
(!this.minDate || this.
|
354
|
-
(!this.maxDate || this.
|
381
|
+
(!this.minDate || this.adapter.compareDate(date, this.minDate) >= 0) &&
|
382
|
+
(!this.maxDate || this.adapter.compareDate(date, this.maxDate) <= 0);
|
355
383
|
}
|
356
384
|
/**
|
357
385
|
* Gets the date in this month that the given Date falls on.
|
358
386
|
* Returns null if the given Date is in another month.
|
359
387
|
*/
|
360
388
|
getDateInCurrentMonth(date) {
|
361
|
-
return date && this.hasSameMonthAndYear(date, this.activeDate) ?
|
362
|
-
this.dateAdapter.getDate(date) : null;
|
389
|
+
return date && this.hasSameMonthAndYear(date, this.activeDate) ? this.adapter.getDate(date) : null;
|
363
390
|
}
|
364
391
|
/** Checks whether the 2 dates are non-null and fall within the same month of the same year. */
|
365
392
|
hasSameMonthAndYear(d1, d2) {
|
366
|
-
return !!(d1 && d2 && this.
|
367
|
-
this.
|
368
|
-
}
|
369
|
-
/**
|
370
|
-
* @param obj The object to check.
|
371
|
-
* @returns The given object if it is both a date instance and valid, otherwise null.
|
372
|
-
*/
|
373
|
-
getValidDateOrNull(obj) {
|
374
|
-
return (this.dateAdapter.isDateInstance(obj) && this.dateAdapter.isValid(obj)) ? obj : null;
|
375
|
-
}
|
376
|
-
/** Determines whether the user has the RTL layout direction. */
|
377
|
-
isRtl() {
|
378
|
-
return this.dir && this.dir.value === 'rtl';
|
393
|
+
return !!(d1 && d2 && this.adapter.getMonth(d1) === this.adapter.getMonth(d2) &&
|
394
|
+
this.adapter.getYear(d1) === this.adapter.getYear(d2));
|
379
395
|
}
|
380
396
|
}
|
381
|
-
/** @nocollapse */ McMonthView.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: McMonthView, deps: [{ token: i0.ChangeDetectorRef }, { token: MC_DATE_FORMATS, optional: true }, { token: i1$1.DateAdapter, optional: true }
|
382
|
-
/** @nocollapse */ McMonthView.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.12", type: McMonthView, selector: "mc-month-view", inputs: { activeDate: "activeDate", selected: "selected", minDate: "minDate", maxDate: "maxDate", dateFilter: "dateFilter", dateClass: "dateClass" }, outputs: { selectedChange: "selectedChange", userSelection: "userSelection", activeDateChange: "activeDateChange" }, viewQueries: [{ propertyName: "mcCalendarBody", first: true, predicate: McCalendarBody, descendants: true }], exportAs: ["mcMonthView"], ngImport: i0, template: "<table class=\"mc-calendar__table\">\n <thead class=\"mc-calendar__table-header\">\n <tr>\n <th *ngFor=\"let day of weekdays\" [attr.aria-label]=\"day.long\">{{day.narrow}}</th>\n </tr>\n <tr>\n <th class=\"mc-calendar__table-header-divider\" colspan=\"7\"></th>\n </tr>\n </thead>\n <tbody mc-calendar-body\n [
|
397
|
+
/** @nocollapse */ McMonthView.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: McMonthView, deps: [{ token: i0.ChangeDetectorRef }, { token: MC_DATE_FORMATS, optional: true }, { token: i1$1.DateAdapter, optional: true }], target: i0.ɵɵFactoryTarget.Component });
|
398
|
+
/** @nocollapse */ McMonthView.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.12", type: McMonthView, selector: "mc-month-view", inputs: { activeDate: "activeDate", selected: "selected", minDate: "minDate", maxDate: "maxDate", dateFilter: "dateFilter", dateClass: "dateClass" }, outputs: { selectedChange: "selectedChange", userSelection: "userSelection", activeDateChange: "activeDateChange" }, viewQueries: [{ propertyName: "mcCalendarBody", first: true, predicate: McCalendarBody, descendants: true }], exportAs: ["mcMonthView"], ngImport: i0, template: "<table class=\"mc-calendar__table\">\n <thead class=\"mc-calendar__table-header\">\n <tr>\n <th *ngFor=\"let day of weekdays\" [attr.aria-label]=\"day.long\">{{day.narrow}}</th>\n </tr>\n <tr>\n <th class=\"mc-calendar__table-header-divider\" colspan=\"7\"></th>\n </tr>\n </thead>\n <tbody mc-calendar-body\n [rows]=\"weeks\"\n [todayValue]=\"todayDate!\"\n [selectedValue]=\"selectedDate!\"\n [labelMinRequiredCells]=\"3\"\n [activeCell]=\"adapter.getDate(activeDate) - 1\"\n (selectedValueChange)=\"dateSelected($event)\">\n </tbody>\n</table>\n", dependencies: [{ kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "component", type: McCalendarBody, selector: "[mc-calendar-body]", inputs: ["rows", "todayValue", "selectedValue", "labelMinRequiredCells", "numCols", "activeCell", "cellAspectRatio"], outputs: ["selectedValueChange"], exportAs: ["mcCalendarBody"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
383
399
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: McMonthView, decorators: [{
|
384
400
|
type: Component,
|
385
|
-
args: [{ selector: 'mc-month-view', exportAs: 'mcMonthView', encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, template: "<table class=\"mc-calendar__table\">\n <thead class=\"mc-calendar__table-header\">\n <tr>\n <th *ngFor=\"let day of weekdays\" [attr.aria-label]=\"day.long\">{{day.narrow}}</th>\n </tr>\n <tr>\n <th class=\"mc-calendar__table-header-divider\" colspan=\"7\"></th>\n </tr>\n </thead>\n <tbody mc-calendar-body\n [
|
401
|
+
args: [{ selector: 'mc-month-view', exportAs: 'mcMonthView', encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, template: "<table class=\"mc-calendar__table\">\n <thead class=\"mc-calendar__table-header\">\n <tr>\n <th *ngFor=\"let day of weekdays\" [attr.aria-label]=\"day.long\">{{day.narrow}}</th>\n </tr>\n <tr>\n <th class=\"mc-calendar__table-header-divider\" colspan=\"7\"></th>\n </tr>\n </thead>\n <tbody mc-calendar-body\n [rows]=\"weeks\"\n [todayValue]=\"todayDate!\"\n [selectedValue]=\"selectedDate!\"\n [labelMinRequiredCells]=\"3\"\n [activeCell]=\"adapter.getDate(activeDate) - 1\"\n (selectedValueChange)=\"dateSelected($event)\">\n </tbody>\n</table>\n" }]
|
386
402
|
}], ctorParameters: function () { return [{ type: i0.ChangeDetectorRef }, { type: undefined, decorators: [{
|
387
403
|
type: Optional
|
388
404
|
}, {
|
@@ -390,8 +406,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImpo
|
|
390
406
|
args: [MC_DATE_FORMATS]
|
391
407
|
}] }, { type: i1$1.DateAdapter, decorators: [{
|
392
408
|
type: Optional
|
393
|
-
}] }, { type: i2.Directionality, decorators: [{
|
394
|
-
type: Optional
|
395
409
|
}] }]; }, propDecorators: { activeDate: [{
|
396
410
|
type: Input
|
397
411
|
}], selected: [{
|
@@ -415,478 +429,15 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImpo
|
|
415
429
|
args: [McCalendarBody, { static: false }]
|
416
430
|
}] } });
|
417
431
|
|
418
|
-
// tslint:disable:no-magic-numbers
|
419
|
-
const yearsPerPage = 24;
|
420
|
-
const yearsPerRow = 4;
|
421
|
-
/**
|
422
|
-
* An internal component used to display a year selector in the datepicker.
|
423
|
-
* @docs-private
|
424
|
-
*/
|
425
|
-
class McMultiYearView {
|
426
|
-
constructor(changeDetectorRef, dateAdapter, dir) {
|
427
|
-
this.changeDetectorRef = changeDetectorRef;
|
428
|
-
this.dateAdapter = dateAdapter;
|
429
|
-
this.dir = dir;
|
430
|
-
/** Emits when a new year is selected. */
|
431
|
-
this.selectedChange = new EventEmitter();
|
432
|
-
/** Emits the selected year. This doesn't imply a change on the selected date */
|
433
|
-
this.yearSelected = new EventEmitter();
|
434
|
-
/** Emits when any date is activated. */
|
435
|
-
this.activeDateChange = new EventEmitter();
|
436
|
-
if (!this.dateAdapter) {
|
437
|
-
throw createMissingDateImplError('DateAdapter');
|
438
|
-
}
|
439
|
-
this._activeDate = this.dateAdapter.today();
|
440
|
-
}
|
441
|
-
/** The date to display in this multi-year view (everything other than the year is ignored). */
|
442
|
-
get activeDate() {
|
443
|
-
return this._activeDate;
|
444
|
-
}
|
445
|
-
set activeDate(value) {
|
446
|
-
const oldActiveDate = this._activeDate;
|
447
|
-
const validDate = this.getValidDateOrNull(this.dateAdapter.deserialize(value)) || this.dateAdapter.today();
|
448
|
-
this._activeDate = this.dateAdapter.clampDate(validDate, this.minDate, this.maxDate);
|
449
|
-
if (Math.floor(this.dateAdapter.getYear(oldActiveDate) / yearsPerPage) !==
|
450
|
-
Math.floor(this.dateAdapter.getYear(this._activeDate) / yearsPerPage)) {
|
451
|
-
this.init();
|
452
|
-
}
|
453
|
-
}
|
454
|
-
/** The currently selected date. */
|
455
|
-
get selected() {
|
456
|
-
return this._selected;
|
457
|
-
}
|
458
|
-
set selected(value) {
|
459
|
-
this._selected = this.getValidDateOrNull(this.dateAdapter.deserialize(value));
|
460
|
-
this.selectedYear = this._selected && this.dateAdapter.getYear(this._selected);
|
461
|
-
}
|
462
|
-
/** The minimum selectable date. */
|
463
|
-
get minDate() {
|
464
|
-
return this._minDate;
|
465
|
-
}
|
466
|
-
set minDate(value) {
|
467
|
-
this._minDate = this.getValidDateOrNull(this.dateAdapter.deserialize(value));
|
468
|
-
}
|
469
|
-
/** The maximum selectable date. */
|
470
|
-
get maxDate() {
|
471
|
-
return this._maxDate;
|
472
|
-
}
|
473
|
-
set maxDate(value) {
|
474
|
-
this._maxDate = this.getValidDateOrNull(this.dateAdapter.deserialize(value));
|
475
|
-
}
|
476
|
-
ngAfterContentInit() {
|
477
|
-
this.init();
|
478
|
-
}
|
479
|
-
/** Initializes this multi-year view. */
|
480
|
-
init() {
|
481
|
-
this.todayYear = this.dateAdapter.getYear(this.dateAdapter.today());
|
482
|
-
const activeYear = this.dateAdapter.getYear(this._activeDate);
|
483
|
-
const activeOffset = activeYear % yearsPerPage;
|
484
|
-
this.years = [];
|
485
|
-
for (let i = 0, row = []; i < yearsPerPage; i++) {
|
486
|
-
row.push(activeYear - activeOffset + i);
|
487
|
-
if (row.length === yearsPerRow) {
|
488
|
-
this.years.push(row.map((year) => this.createCellForYear(year)));
|
489
|
-
row = [];
|
490
|
-
}
|
491
|
-
}
|
492
|
-
this.changeDetectorRef.markForCheck();
|
493
|
-
}
|
494
|
-
/** Handles when a new year is selected. */
|
495
|
-
onYearSelected(year) {
|
496
|
-
this.yearSelected.emit(this.dateAdapter.createDate(year));
|
497
|
-
const month = this.dateAdapter.getMonth(this.activeDate);
|
498
|
-
const daysInMonth = this.dateAdapter.getNumDaysInMonth(this.dateAdapter.createDate(year, month));
|
499
|
-
this.selectedChange.emit(this.dateAdapter.createDate(year, month, Math.min(this.dateAdapter.getDate(this.activeDate), daysInMonth)));
|
500
|
-
}
|
501
|
-
/** Handles keydown events on the calendar body when calendar is in multi-year view. */
|
502
|
-
handleCalendarBodyKeydown(event) {
|
503
|
-
// TODO(mmalerba): We currently allow keyboard navigation to disabled dates, but just prevent
|
504
|
-
// disabled ones from being selected. This may not be ideal, we should look into whether
|
505
|
-
// navigation should skip over disabled dates, and if so, how to implement that efficiently.
|
506
|
-
const oldActiveDate = this._activeDate;
|
507
|
-
const isRtl = this.isRtl();
|
508
|
-
// tslint:disable-next-line:deprecation
|
509
|
-
switch (event.keyCode) {
|
510
|
-
case LEFT_ARROW:
|
511
|
-
this.activeDate = this.dateAdapter.addCalendarYears(this._activeDate, isRtl ? 1 : -1);
|
512
|
-
break;
|
513
|
-
case RIGHT_ARROW:
|
514
|
-
this.activeDate = this.dateAdapter.addCalendarYears(this._activeDate, isRtl ? -1 : 1);
|
515
|
-
break;
|
516
|
-
case UP_ARROW:
|
517
|
-
this.activeDate = this.dateAdapter.addCalendarYears(this._activeDate, -yearsPerRow);
|
518
|
-
break;
|
519
|
-
case DOWN_ARROW:
|
520
|
-
this.activeDate = this.dateAdapter.addCalendarYears(this._activeDate, yearsPerRow);
|
521
|
-
break;
|
522
|
-
case HOME:
|
523
|
-
this.activeDate = this.dateAdapter.addCalendarYears(this._activeDate, -this.dateAdapter.getYear(this._activeDate) % yearsPerPage);
|
524
|
-
break;
|
525
|
-
case END:
|
526
|
-
this.activeDate = this.dateAdapter.addCalendarYears(this._activeDate, yearsPerPage - this.dateAdapter.getYear(this._activeDate) % yearsPerPage - 1);
|
527
|
-
break;
|
528
|
-
case PAGE_UP:
|
529
|
-
this.activeDate =
|
530
|
-
this.dateAdapter.addCalendarYears(this._activeDate, event.altKey ? -yearsPerPage * 10 : -yearsPerPage);
|
531
|
-
break;
|
532
|
-
case PAGE_DOWN:
|
533
|
-
this.activeDate =
|
534
|
-
this.dateAdapter.addCalendarYears(this._activeDate, event.altKey ? yearsPerPage * 10 : yearsPerPage);
|
535
|
-
break;
|
536
|
-
case ENTER:
|
537
|
-
case SPACE:
|
538
|
-
this.onYearSelected(this.dateAdapter.getYear(this._activeDate));
|
539
|
-
break;
|
540
|
-
default:
|
541
|
-
// Don't prevent default or focus active cell on keys that we don't explicitly handle.
|
542
|
-
return;
|
543
|
-
}
|
544
|
-
if (this.dateAdapter.compareDate(oldActiveDate, this.activeDate)) {
|
545
|
-
this.activeDateChange.emit(this.activeDate);
|
546
|
-
}
|
547
|
-
this.focusActiveCell();
|
548
|
-
// Prevent unexpected default actions such as form submission.
|
549
|
-
event.preventDefault();
|
550
|
-
}
|
551
|
-
getActiveCell() {
|
552
|
-
return this.dateAdapter.getYear(this.activeDate) % yearsPerPage;
|
553
|
-
}
|
554
|
-
/** Focuses the active cell after the microtask queue is empty. */
|
555
|
-
focusActiveCell() {
|
556
|
-
this.mcCalendarBody.focusActiveCell();
|
557
|
-
}
|
558
|
-
/** Creates an McCalendarCell for the given year. */
|
559
|
-
createCellForYear(year) {
|
560
|
-
const yearName = this.dateAdapter.getYearName(this.dateAdapter.createDate(year));
|
561
|
-
return new McCalendarCell(year, yearName, yearName, this.shouldEnableYear(year));
|
562
|
-
}
|
563
|
-
/** Whether the given year is enabled. */
|
564
|
-
shouldEnableYear(year) {
|
565
|
-
// disable if the year is greater than maxDate lower than minDate
|
566
|
-
if (year === undefined || year === null ||
|
567
|
-
(this.maxDate && year > this.dateAdapter.getYear(this.maxDate)) ||
|
568
|
-
(this.minDate && year < this.dateAdapter.getYear(this.minDate))) {
|
569
|
-
return false;
|
570
|
-
}
|
571
|
-
// enable if it reaches here and there's no filter defined
|
572
|
-
if (!this.dateFilter) {
|
573
|
-
return true;
|
574
|
-
}
|
575
|
-
const firstOfYear = this.dateAdapter.createDate(year);
|
576
|
-
// If any date in the year is enabled count the year as enabled.
|
577
|
-
for (let date = firstOfYear; this.dateAdapter.getYear(date) === year; date = this.dateAdapter.addCalendarDays(date, 1)) {
|
578
|
-
if (this.dateFilter(date)) {
|
579
|
-
return true;
|
580
|
-
}
|
581
|
-
}
|
582
|
-
return false;
|
583
|
-
}
|
584
|
-
/**
|
585
|
-
* @param obj The object to check.
|
586
|
-
* @returns The given object if it is both a date instance and valid, otherwise null.
|
587
|
-
*/
|
588
|
-
getValidDateOrNull(obj) {
|
589
|
-
return (this.dateAdapter.isDateInstance(obj) && this.dateAdapter.isValid(obj)) ? obj : null;
|
590
|
-
}
|
591
|
-
/** Determines whether the user has the RTL layout direction. */
|
592
|
-
isRtl() {
|
593
|
-
return this.dir && this.dir.value === 'rtl';
|
594
|
-
}
|
595
|
-
}
|
596
|
-
/** @nocollapse */ McMultiYearView.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: McMultiYearView, deps: [{ token: i0.ChangeDetectorRef }, { token: i1$1.DateAdapter, optional: true }, { token: i2.Directionality, optional: true }], target: i0.ɵɵFactoryTarget.Component });
|
597
|
-
/** @nocollapse */ McMultiYearView.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.12", type: McMultiYearView, selector: "mc-multi-year-view", inputs: { activeDate: "activeDate", selected: "selected", minDate: "minDate", maxDate: "maxDate", dateFilter: "dateFilter" }, outputs: { selectedChange: "selectedChange", yearSelected: "yearSelected", activeDateChange: "activeDateChange" }, viewQueries: [{ propertyName: "mcCalendarBody", first: true, predicate: McCalendarBody, descendants: true }], exportAs: ["mcMultiYearView"], ngImport: i0, template: "<table class=\"mc-calendar__table\">\n <thead class=\"mc-calendar__table-header\">\n <tr>\n <th class=\"mc-calendar__table-header-divider\" colspan=\"4\"></th>\n </tr>\n </thead>\n <tbody mc-calendar-body\n [rows]=\"years\"\n [todayValue]=\"todayYear\"\n [selectedValue]=\"selectedYear!\"\n [numCols]=\"4\"\n [cellAspectRatio]=\"4 / 7\"\n [activeCell]=\"getActiveCell()\"\n (selectedValueChange)=\"onYearSelected($event)\"\n (keydown)=\"handleCalendarBodyKeydown($event)\">\n </tbody>\n</table>\n", dependencies: [{ kind: "component", type: McCalendarBody, selector: "[mc-calendar-body]", inputs: ["label", "rows", "todayValue", "selectedValue", "labelMinRequiredCells", "numCols", "activeCell", "cellAspectRatio"], outputs: ["selectedValueChange"], exportAs: ["mcCalendarBody"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
598
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: McMultiYearView, decorators: [{
|
599
|
-
type: Component,
|
600
|
-
args: [{ selector: 'mc-multi-year-view', exportAs: 'mcMultiYearView', encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, template: "<table class=\"mc-calendar__table\">\n <thead class=\"mc-calendar__table-header\">\n <tr>\n <th class=\"mc-calendar__table-header-divider\" colspan=\"4\"></th>\n </tr>\n </thead>\n <tbody mc-calendar-body\n [rows]=\"years\"\n [todayValue]=\"todayYear\"\n [selectedValue]=\"selectedYear!\"\n [numCols]=\"4\"\n [cellAspectRatio]=\"4 / 7\"\n [activeCell]=\"getActiveCell()\"\n (selectedValueChange)=\"onYearSelected($event)\"\n (keydown)=\"handleCalendarBodyKeydown($event)\">\n </tbody>\n</table>\n" }]
|
601
|
-
}], ctorParameters: function () { return [{ type: i0.ChangeDetectorRef }, { type: i1$1.DateAdapter, decorators: [{
|
602
|
-
type: Optional
|
603
|
-
}] }, { type: i2.Directionality, decorators: [{
|
604
|
-
type: Optional
|
605
|
-
}] }]; }, propDecorators: { activeDate: [{
|
606
|
-
type: Input
|
607
|
-
}], selected: [{
|
608
|
-
type: Input
|
609
|
-
}], minDate: [{
|
610
|
-
type: Input
|
611
|
-
}], maxDate: [{
|
612
|
-
type: Input
|
613
|
-
}], dateFilter: [{
|
614
|
-
type: Input
|
615
|
-
}], selectedChange: [{
|
616
|
-
type: Output
|
617
|
-
}], yearSelected: [{
|
618
|
-
type: Output
|
619
|
-
}], activeDateChange: [{
|
620
|
-
type: Output
|
621
|
-
}], mcCalendarBody: [{
|
622
|
-
type: ViewChild,
|
623
|
-
args: [McCalendarBody, { static: false }]
|
624
|
-
}] } });
|
625
|
-
|
626
|
-
/**
|
627
|
-
* An internal component used to display a single year in the datepicker.
|
628
|
-
* @docs-private
|
629
|
-
*/
|
630
|
-
class McYearView {
|
631
|
-
constructor(changeDetectorRef, dateFormats, dateAdapter, dir) {
|
632
|
-
this.changeDetectorRef = changeDetectorRef;
|
633
|
-
this.dateFormats = dateFormats;
|
634
|
-
this.dateAdapter = dateAdapter;
|
635
|
-
this.dir = dir;
|
636
|
-
/** Emits when a new month is selected. */
|
637
|
-
this.selectedChange = new EventEmitter();
|
638
|
-
/** Emits the selected month. This doesn't imply a change on the selected date */
|
639
|
-
this.monthSelected = new EventEmitter();
|
640
|
-
/** Emits when any date is activated. */
|
641
|
-
this.activeDateChange = new EventEmitter();
|
642
|
-
if (!this.dateAdapter) {
|
643
|
-
throw createMissingDateImplError('DateAdapter');
|
644
|
-
}
|
645
|
-
if (!this.dateFormats) {
|
646
|
-
throw createMissingDateImplError('MC_DATE_FORMATS');
|
647
|
-
}
|
648
|
-
this._activeDate = this.dateAdapter.today();
|
649
|
-
}
|
650
|
-
/** The date to display in this year view (everything other than the year is ignored). */
|
651
|
-
get activeDate() {
|
652
|
-
return this._activeDate;
|
653
|
-
}
|
654
|
-
set activeDate(value) {
|
655
|
-
const oldActiveDate = this._activeDate;
|
656
|
-
const validDate = this.getValidDateOrNull(this.dateAdapter.deserialize(value)) || this.dateAdapter.today();
|
657
|
-
this._activeDate = this.dateAdapter.clampDate(validDate, this.minDate, this.maxDate);
|
658
|
-
if (this.dateAdapter.getYear(oldActiveDate) !== this.dateAdapter.getYear(this._activeDate)) {
|
659
|
-
this.init();
|
660
|
-
}
|
661
|
-
}
|
662
|
-
/** The currently selected date. */
|
663
|
-
get selected() {
|
664
|
-
return this._selected;
|
665
|
-
}
|
666
|
-
set selected(value) {
|
667
|
-
this._selected = this.getValidDateOrNull(this.dateAdapter.deserialize(value));
|
668
|
-
this.selectedMonth = this.getMonthInCurrentYear(this._selected);
|
669
|
-
}
|
670
|
-
/** The minimum selectable date. */
|
671
|
-
get minDate() {
|
672
|
-
return this._minDate;
|
673
|
-
}
|
674
|
-
set minDate(value) {
|
675
|
-
this._minDate = this.getValidDateOrNull(this.dateAdapter.deserialize(value));
|
676
|
-
}
|
677
|
-
/** The maximum selectable date. */
|
678
|
-
get maxDate() {
|
679
|
-
return this._maxDate;
|
680
|
-
}
|
681
|
-
set maxDate(value) {
|
682
|
-
this._maxDate = this.getValidDateOrNull(this.dateAdapter.deserialize(value));
|
683
|
-
}
|
684
|
-
ngAfterContentInit() {
|
685
|
-
this.init();
|
686
|
-
}
|
687
|
-
/** Handles when a new month is selected. */
|
688
|
-
onMonthSelected(month) {
|
689
|
-
const year = this.dateAdapter.getYear(this.activeDate);
|
690
|
-
const normalizedDate = this.dateAdapter.createDate(year, month);
|
691
|
-
this.monthSelected.emit(normalizedDate);
|
692
|
-
const daysInMonth = this.dateAdapter.getNumDaysInMonth(normalizedDate);
|
693
|
-
this.selectedChange.emit(this.dateAdapter.createDate(year, month, Math.min(this.dateAdapter.getDate(this.activeDate), daysInMonth)));
|
694
|
-
}
|
695
|
-
/** Handles keydown events on the calendar body when calendar is in year view. */
|
696
|
-
handleCalendarBodyKeydown(event) {
|
697
|
-
// TODO(mmalerba): We currently allow keyboard navigation to disabled dates, but just prevent
|
698
|
-
// disabled ones from being selected. This may not be ideal, we should look into whether
|
699
|
-
// navigation should skip over disabled dates, and if so, how to implement that efficiently.
|
700
|
-
const oldActiveDate = this._activeDate;
|
701
|
-
const isRtl = this.isRtl();
|
702
|
-
const VERTICAL_SHIFT = 4;
|
703
|
-
const PAGE_SHIFT = 10;
|
704
|
-
const MAX_MONTH_INDEX = 11;
|
705
|
-
// tslint:disable-next-line:deprecation
|
706
|
-
switch (event.keyCode) {
|
707
|
-
case LEFT_ARROW:
|
708
|
-
this.activeDate = this.dateAdapter.addCalendarMonths(this._activeDate, isRtl ? 1 : -1);
|
709
|
-
break;
|
710
|
-
case RIGHT_ARROW:
|
711
|
-
this.activeDate = this.dateAdapter.addCalendarMonths(this._activeDate, isRtl ? -1 : 1);
|
712
|
-
break;
|
713
|
-
case UP_ARROW:
|
714
|
-
this.activeDate = this.dateAdapter.addCalendarMonths(this._activeDate, -VERTICAL_SHIFT);
|
715
|
-
break;
|
716
|
-
case DOWN_ARROW:
|
717
|
-
this.activeDate = this.dateAdapter.addCalendarMonths(this._activeDate, VERTICAL_SHIFT);
|
718
|
-
break;
|
719
|
-
case HOME:
|
720
|
-
this.activeDate = this.dateAdapter.addCalendarMonths(this._activeDate, -this.dateAdapter.getMonth(this._activeDate));
|
721
|
-
break;
|
722
|
-
case END:
|
723
|
-
this.activeDate = this.dateAdapter.addCalendarMonths(this._activeDate, MAX_MONTH_INDEX - this.dateAdapter.getMonth(this._activeDate));
|
724
|
-
break;
|
725
|
-
case PAGE_UP:
|
726
|
-
this.activeDate =
|
727
|
-
this.dateAdapter.addCalendarYears(this._activeDate, event.altKey ? -PAGE_SHIFT : -1);
|
728
|
-
break;
|
729
|
-
case PAGE_DOWN:
|
730
|
-
this.activeDate =
|
731
|
-
this.dateAdapter.addCalendarYears(this._activeDate, event.altKey ? PAGE_SHIFT : 1);
|
732
|
-
break;
|
733
|
-
case ENTER:
|
734
|
-
case SPACE:
|
735
|
-
this.onMonthSelected(this.dateAdapter.getMonth(this._activeDate));
|
736
|
-
break;
|
737
|
-
default:
|
738
|
-
// Don't prevent default or focus active cell on keys that we don't explicitly handle.
|
739
|
-
return;
|
740
|
-
}
|
741
|
-
if (this.dateAdapter.compareDate(oldActiveDate, this.activeDate)) {
|
742
|
-
this.activeDateChange.emit(this.activeDate);
|
743
|
-
}
|
744
|
-
this.focusActiveCell();
|
745
|
-
// Prevent unexpected default actions such as form submission.
|
746
|
-
event.preventDefault();
|
747
|
-
}
|
748
|
-
/** Initializes this year view. */
|
749
|
-
init() {
|
750
|
-
this.selectedMonth = this.getMonthInCurrentYear(this.selected);
|
751
|
-
this.todayMonth = this.getMonthInCurrentYear(this.dateAdapter.today());
|
752
|
-
this.yearLabel = this.dateAdapter.getYearName(this.activeDate);
|
753
|
-
const monthNames = this.dateAdapter.getMonthNames('short');
|
754
|
-
// First row of months only contains 5 elements so we can fit the year label on the same row.
|
755
|
-
// tslint:disable-next-line:no-magic-numbers
|
756
|
-
this.months = [[0, 1, 2, 3], [4, 5, 6, 7], [8, 9, 10, 11]]
|
757
|
-
.map((row) => row.map((month) => this.createCellForMonth(month, monthNames[month])));
|
758
|
-
this.changeDetectorRef.markForCheck();
|
759
|
-
}
|
760
|
-
/** Focuses the active cell after the microtask queue is empty. */
|
761
|
-
focusActiveCell() {
|
762
|
-
this.mcCalendarBody.focusActiveCell();
|
763
|
-
}
|
764
|
-
/**
|
765
|
-
* Gets the month in this year that the given Date falls on.
|
766
|
-
* Returns null if the given Date is in another year.
|
767
|
-
*/
|
768
|
-
getMonthInCurrentYear(date) {
|
769
|
-
return date && this.dateAdapter.getYear(date) === this.dateAdapter.getYear(this.activeDate) ?
|
770
|
-
this.dateAdapter.getMonth(date) : null;
|
771
|
-
}
|
772
|
-
/** Creates an McCalendarCell for the given month. */
|
773
|
-
createCellForMonth(month, monthName) {
|
774
|
-
const ariaLabel = this.dateAdapter.format(this.dateAdapter.createDate(this.dateAdapter.getYear(this.activeDate), month), this.dateFormats.monthYearA11yLabel);
|
775
|
-
const newMonthName = monthName[0].toLocaleUpperCase() + monthName.substr(1);
|
776
|
-
return new McCalendarCell(month, newMonthName, ariaLabel, this.shouldEnableMonth(month));
|
777
|
-
}
|
778
|
-
/** Whether the given month is enabled. */
|
779
|
-
shouldEnableMonth(month) {
|
780
|
-
const activeYear = this.dateAdapter.getYear(this.activeDate);
|
781
|
-
if (month === undefined || month === null ||
|
782
|
-
this.isYearAndMonthAfterMaxDate(activeYear, month) ||
|
783
|
-
this.isYearAndMonthBeforeMinDate(activeYear, month)) {
|
784
|
-
return false;
|
785
|
-
}
|
786
|
-
if (!this.dateFilter) {
|
787
|
-
return true;
|
788
|
-
}
|
789
|
-
const firstOfMonth = this.dateAdapter.createDate(activeYear, month);
|
790
|
-
// If any date in the month is enabled count the month as enabled.
|
791
|
-
for (let date = firstOfMonth; this.dateAdapter.getMonth(date) === month; date = this.dateAdapter.addCalendarDays(date, 1)) {
|
792
|
-
if (this.dateFilter(date)) {
|
793
|
-
return true;
|
794
|
-
}
|
795
|
-
}
|
796
|
-
return false;
|
797
|
-
}
|
798
|
-
/**
|
799
|
-
* Tests whether the combination month/year is after this.maxDate, considering
|
800
|
-
* just the month and year of this.maxDate
|
801
|
-
*/
|
802
|
-
isYearAndMonthAfterMaxDate(year, month) {
|
803
|
-
if (this.maxDate) {
|
804
|
-
const maxYear = this.dateAdapter.getYear(this.maxDate);
|
805
|
-
const maxMonth = this.dateAdapter.getMonth(this.maxDate);
|
806
|
-
return year > maxYear || (year === maxYear && month > maxMonth);
|
807
|
-
}
|
808
|
-
return false;
|
809
|
-
}
|
810
|
-
/**
|
811
|
-
* Tests whether the combination month/year is before this.minDate, considering
|
812
|
-
* just the month and year of this.minDate
|
813
|
-
*/
|
814
|
-
isYearAndMonthBeforeMinDate(year, month) {
|
815
|
-
if (this.minDate) {
|
816
|
-
const minYear = this.dateAdapter.getYear(this.minDate);
|
817
|
-
const minMonth = this.dateAdapter.getMonth(this.minDate);
|
818
|
-
return year < minYear || (year === minYear && month < minMonth);
|
819
|
-
}
|
820
|
-
return false;
|
821
|
-
}
|
822
|
-
/**
|
823
|
-
* @param obj The object to check.
|
824
|
-
* @returns The given object if it is both a date instance and valid, otherwise null.
|
825
|
-
*/
|
826
|
-
getValidDateOrNull(obj) {
|
827
|
-
return (this.dateAdapter.isDateInstance(obj) && this.dateAdapter.isValid(obj)) ? obj : null;
|
828
|
-
}
|
829
|
-
/** Determines whether the user has the RTL layout direction. */
|
830
|
-
isRtl() {
|
831
|
-
return this.dir && this.dir.value === 'rtl';
|
832
|
-
}
|
833
|
-
}
|
834
|
-
/** @nocollapse */ McYearView.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: McYearView, deps: [{ token: i0.ChangeDetectorRef }, { token: MC_DATE_FORMATS, optional: true }, { token: i1$1.DateAdapter, optional: true }, { token: i2.Directionality, optional: true }], target: i0.ɵɵFactoryTarget.Component });
|
835
|
-
/** @nocollapse */ McYearView.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.12", type: McYearView, selector: "mc-year-view", inputs: { activeDate: "activeDate", selected: "selected", minDate: "minDate", maxDate: "maxDate", dateFilter: "dateFilter" }, outputs: { selectedChange: "selectedChange", monthSelected: "monthSelected", activeDateChange: "activeDateChange" }, viewQueries: [{ propertyName: "mcCalendarBody", first: true, predicate: McCalendarBody, descendants: true }], exportAs: ["mcYearView"], ngImport: i0, template: "<table class=\"mc-calendar__table\">\n <thead class=\"mc-calendar__table-header\">\n <tr>\n <th class=\"mc-calendar__table-header-divider\" colspan=\"4\"></th>\n </tr>\n </thead>\n <tbody mc-calendar-body\n [label]=\"yearLabel\"\n [rows]=\"months\"\n [todayValue]=\"todayMonth!\"\n [selectedValue]=\"selectedMonth!\"\n [labelMinRequiredCells]=\"2\"\n [numCols]=\"4\"\n [cellAspectRatio]=\"4 / 7\"\n [activeCell]=\"dateAdapter.getMonth(activeDate)\"\n (selectedValueChange)=\"onMonthSelected($event)\"\n (keydown)=\"handleCalendarBodyKeydown($event)\">\n </tbody>\n</table>\n", dependencies: [{ kind: "component", type: McCalendarBody, selector: "[mc-calendar-body]", inputs: ["label", "rows", "todayValue", "selectedValue", "labelMinRequiredCells", "numCols", "activeCell", "cellAspectRatio"], outputs: ["selectedValueChange"], exportAs: ["mcCalendarBody"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
836
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: McYearView, decorators: [{
|
837
|
-
type: Component,
|
838
|
-
args: [{ selector: 'mc-year-view', exportAs: 'mcYearView', encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, template: "<table class=\"mc-calendar__table\">\n <thead class=\"mc-calendar__table-header\">\n <tr>\n <th class=\"mc-calendar__table-header-divider\" colspan=\"4\"></th>\n </tr>\n </thead>\n <tbody mc-calendar-body\n [label]=\"yearLabel\"\n [rows]=\"months\"\n [todayValue]=\"todayMonth!\"\n [selectedValue]=\"selectedMonth!\"\n [labelMinRequiredCells]=\"2\"\n [numCols]=\"4\"\n [cellAspectRatio]=\"4 / 7\"\n [activeCell]=\"dateAdapter.getMonth(activeDate)\"\n (selectedValueChange)=\"onMonthSelected($event)\"\n (keydown)=\"handleCalendarBodyKeydown($event)\">\n </tbody>\n</table>\n" }]
|
839
|
-
}], ctorParameters: function () { return [{ type: i0.ChangeDetectorRef }, { type: undefined, decorators: [{
|
840
|
-
type: Optional
|
841
|
-
}, {
|
842
|
-
type: Inject,
|
843
|
-
args: [MC_DATE_FORMATS]
|
844
|
-
}] }, { type: i1$1.DateAdapter, decorators: [{
|
845
|
-
type: Optional
|
846
|
-
}] }, { type: i2.Directionality, decorators: [{
|
847
|
-
type: Optional
|
848
|
-
}] }]; }, propDecorators: { activeDate: [{
|
849
|
-
type: Input
|
850
|
-
}], selected: [{
|
851
|
-
type: Input
|
852
|
-
}], minDate: [{
|
853
|
-
type: Input
|
854
|
-
}], maxDate: [{
|
855
|
-
type: Input
|
856
|
-
}], dateFilter: [{
|
857
|
-
type: Input
|
858
|
-
}], selectedChange: [{
|
859
|
-
type: Output
|
860
|
-
}], monthSelected: [{
|
861
|
-
type: Output
|
862
|
-
}], activeDateChange: [{
|
863
|
-
type: Output
|
864
|
-
}], mcCalendarBody: [{
|
865
|
-
type: ViewChild,
|
866
|
-
args: [McCalendarBody, { static: false }]
|
867
|
-
}] } });
|
868
|
-
|
869
|
-
/**
|
870
|
-
* Possible views for the calendar.
|
871
|
-
* @docs-private
|
872
|
-
*/
|
873
|
-
var McCalendarView;
|
874
|
-
(function (McCalendarView) {
|
875
|
-
McCalendarView["Month"] = "month";
|
876
|
-
McCalendarView["Year"] = "year";
|
877
|
-
McCalendarView["MultiYear"] = "multi-year";
|
878
|
-
})(McCalendarView || (McCalendarView = {}));
|
879
432
|
/**
|
880
433
|
* A calendar that is used as part of the datepicker.
|
881
434
|
* @docs-private
|
882
435
|
*/
|
883
436
|
class McCalendar {
|
884
|
-
constructor(intl,
|
885
|
-
this.
|
437
|
+
constructor(intl, adapter, dateFormats, changeDetectorRef) {
|
438
|
+
this.adapter = adapter;
|
886
439
|
this.dateFormats = dateFormats;
|
887
440
|
this.changeDetectorRef = changeDetectorRef;
|
888
|
-
/** Whether the calendar should be started in month or year view. */
|
889
|
-
this.startView = McCalendarView.Month;
|
890
441
|
/** Emits when the currently selected date changes. */
|
891
442
|
this.selectedChange = new EventEmitter();
|
892
443
|
/**
|
@@ -905,13 +456,7 @@ class McCalendar {
|
|
905
456
|
* Emits whenever there is a state change that the header may need to respond to.
|
906
457
|
*/
|
907
458
|
this.stateChanges = new Subject();
|
908
|
-
|
909
|
-
* Used for scheduling that focus should be moved to the active cell on the next tick.
|
910
|
-
* We need to schedule it, rather than do it immediately, because we have to wait
|
911
|
-
* for Angular to re-evaluate the view children.
|
912
|
-
*/
|
913
|
-
this.moveFocusOnNextTick = false;
|
914
|
-
if (!this.dateAdapter) {
|
459
|
+
if (!this.adapter) {
|
915
460
|
throw createMissingDateImplError('DateAdapter');
|
916
461
|
}
|
917
462
|
if (!this.dateFormats) {
|
@@ -927,59 +472,46 @@ class McCalendar {
|
|
927
472
|
return this._startAt;
|
928
473
|
}
|
929
474
|
set startAt(value) {
|
930
|
-
|
475
|
+
const deserializedValue = this.getValidDateOrNull(this.adapter.deserialize(value));
|
476
|
+
this._startAt = deserializedValue !== null ?
|
477
|
+
this.adapter.clampDate(deserializedValue, this.minDate, this.maxDate) : null;
|
931
478
|
}
|
932
479
|
/** The currently selected date. */
|
933
480
|
get selected() {
|
934
481
|
return this._selected;
|
935
482
|
}
|
936
483
|
set selected(value) {
|
937
|
-
this._selected = this.
|
484
|
+
this._selected = this.adapter.deserialize(value);
|
938
485
|
}
|
939
486
|
/** The minimum selectable date. */
|
940
487
|
get minDate() {
|
941
488
|
return this._minDate;
|
942
489
|
}
|
943
490
|
set minDate(value) {
|
944
|
-
this._minDate = this.
|
491
|
+
this._minDate = this.adapter.deserialize(value);
|
492
|
+
this.startAt = this._startAt;
|
945
493
|
}
|
946
494
|
/** The maximum selectable date. */
|
947
495
|
get maxDate() {
|
948
496
|
return this._maxDate;
|
949
497
|
}
|
950
498
|
set maxDate(value) {
|
951
|
-
this._maxDate = this.
|
499
|
+
this._maxDate = this.adapter.deserialize(value);
|
500
|
+
this.startAt = this._startAt;
|
952
501
|
}
|
953
502
|
/**
|
954
503
|
* The current active date. This determines which time period is shown and which date is
|
955
504
|
* highlighted when using keyboard navigation.
|
956
505
|
*/
|
957
506
|
get activeDate() {
|
958
|
-
return this.
|
507
|
+
return this._activeDate;
|
959
508
|
}
|
960
509
|
set activeDate(value) {
|
961
|
-
this.
|
510
|
+
this._activeDate = this.adapter.clampDate(value, this.minDate, this.maxDate);
|
962
511
|
this.stateChanges.next();
|
963
512
|
}
|
964
|
-
/** Whether the calendar is in month view. */
|
965
|
-
get currentView() {
|
966
|
-
return this._currentView;
|
967
|
-
}
|
968
|
-
set currentView(value) {
|
969
|
-
this._currentView = value;
|
970
|
-
this.moveFocusOnNextTick = true;
|
971
|
-
}
|
972
513
|
ngAfterContentInit() {
|
973
|
-
this.
|
974
|
-
this.activeDate = this.startAt || this.dateAdapter.today();
|
975
|
-
// Assign to the private property since we don't want to move focus on init.
|
976
|
-
this._currentView = this.startView;
|
977
|
-
}
|
978
|
-
ngAfterViewChecked() {
|
979
|
-
if (this.moveFocusOnNextTick) {
|
980
|
-
this.moveFocusOnNextTick = false;
|
981
|
-
this.focusActiveCell();
|
982
|
-
}
|
514
|
+
this.activeDate = this.startAt || this.adapter.today();
|
983
515
|
}
|
984
516
|
ngOnDestroy() {
|
985
517
|
this.intlChanges.unsubscribe();
|
@@ -988,66 +520,44 @@ class McCalendar {
|
|
988
520
|
ngOnChanges(changes) {
|
989
521
|
const change = changes.minDate || changes.maxDate || changes.dateFilter;
|
990
522
|
if (change && !change.firstChange) {
|
991
|
-
|
992
|
-
if (view) {
|
523
|
+
if (this.monthView) {
|
993
524
|
// We need to `detectChanges` manually here, because the `minDate`, `maxDate` etc. are
|
994
525
|
// passed down to the view via data bindings which won't be up-to-date when we call `init`.
|
995
526
|
this.changeDetectorRef.detectChanges();
|
996
|
-
|
527
|
+
this.monthView.init();
|
997
528
|
}
|
998
529
|
}
|
999
530
|
this.stateChanges.next();
|
1000
531
|
}
|
1001
|
-
focusActiveCell() {
|
1002
|
-
this.getCurrentViewComponent().focusActiveCell();
|
1003
|
-
}
|
1004
532
|
/** Updates today's date after an update of the active date */
|
1005
533
|
updateTodaysDate() {
|
1006
|
-
|
1007
|
-
(this.currentView === McCalendarView.Year ? this.yearView : this.multiYearView);
|
1008
|
-
view.ngAfterContentInit();
|
534
|
+
this.monthView.ngAfterContentInit();
|
1009
535
|
}
|
1010
536
|
/** Handles date selection in the month view. */
|
1011
537
|
dateSelected(date) {
|
1012
|
-
if (!this.
|
538
|
+
if (!this.adapter.sameDate(date, this.selected)) {
|
1013
539
|
this.selectedChange.emit(date);
|
1014
540
|
}
|
1015
541
|
}
|
1016
|
-
/** Handles year selection in the multiyear view. */
|
1017
|
-
yearSelectedInMultiYearView(normalizedYear) {
|
1018
|
-
this.yearSelected.emit(normalizedYear);
|
1019
|
-
}
|
1020
|
-
/** Handles month selection in the year view. */
|
1021
|
-
monthSelectedInYearView(normalizedMonth) {
|
1022
|
-
this.monthSelected.emit(normalizedMonth);
|
1023
|
-
}
|
1024
542
|
userSelected() {
|
1025
543
|
this.userSelection.emit();
|
1026
544
|
}
|
1027
|
-
/** Handles year/month selection in the multi-year/year views. */
|
1028
|
-
goToDateInView(date, view) {
|
1029
|
-
this.activeDate = date;
|
1030
|
-
this.currentView = view;
|
1031
|
-
}
|
1032
545
|
/**
|
1033
546
|
* @param obj The object to check.
|
1034
547
|
* @returns The given object if it is both a date instance and valid, otherwise null.
|
1035
548
|
*/
|
549
|
+
// todo выглядит как костыль от которого нужно избавиться
|
1036
550
|
getValidDateOrNull(obj) {
|
1037
|
-
return (this.
|
1038
|
-
}
|
1039
|
-
/** Returns the component instance that corresponds to the current calendar view. */
|
1040
|
-
getCurrentViewComponent() {
|
1041
|
-
return this.monthView || this.yearView || this.multiYearView;
|
551
|
+
return (this.adapter.isDateInstance(obj) && this.adapter.isValid(obj)) ? obj : null;
|
1042
552
|
}
|
1043
553
|
}
|
1044
554
|
/** @nocollapse */ McCalendar.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: McCalendar, deps: [{ token: McDatepickerIntl }, { token: i1$1.DateAdapter, optional: true }, { token: MC_DATE_FORMATS, optional: true }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
|
1045
|
-
/** @nocollapse */ McCalendar.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.12", type: McCalendar, selector: "mc-calendar", inputs: { startAt: "startAt", selected: "selected", minDate: "minDate", maxDate: "maxDate",
|
555
|
+
/** @nocollapse */ McCalendar.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.12", type: McCalendar, selector: "mc-calendar", inputs: { startAt: "startAt", selected: "selected", minDate: "minDate", maxDate: "maxDate", dateFilter: "dateFilter", dateClass: "dateClass" }, outputs: { selectedChange: "selectedChange", yearSelected: "yearSelected", monthSelected: "monthSelected", userSelection: "userSelection" }, host: { classAttribute: "mc-calendar" }, viewQueries: [{ propertyName: "monthView", first: true, predicate: McMonthView, descendants: true }], exportAs: ["mcCalendar"], usesOnChanges: true, ngImport: i0, template: "<mc-calendar-header\n [(activeDate)]=\"activeDate\"\n [maxDate]=\"maxDate\"\n [minDate]=\"minDate\"\n (monthSelected)=\"monthSelected.emit(activeDate)\"\n (yearSelected)=\"yearSelected.emit(activeDate)\">\n</mc-calendar-header>\n\n<div class=\"mc-calendar__content\">\n <mc-month-view\n [(activeDate)]=\"activeDate\"\n [selected]=\"selected\"\n [dateFilter]=\"dateFilter\"\n [maxDate]=\"maxDate\"\n [minDate]=\"minDate\"\n [dateClass]=\"dateClass\"\n (selectedChange)=\"dateSelected($event!)\"\n (userSelection)=\"userSelected()\">\n </mc-month-view>\n</div>\n", styles: [".mc-calendar{display:block}.mc-calendar__content{padding:0 8px 8px;padding:0 var(--mc-datepicker-calendar-size-padding-horizontal, 8px) var(--mc-datepicker-calendar-size-padding-horizontal, 8px) var(--mc-datepicker-calendar-size-padding-horizontal, 8px);outline:none}.mc-calendar__table{border-spacing:0;border-collapse:collapse;width:100%}.mc-calendar__table-header th{text-align:center;height:30px}.mc-calendar__table-header th.mc-calendar__table-header-divider{position:relative;height:10px;height:calc(var(--mc-datepicker-calendar-size-padding-blocks, 12px) - 2px)}.mc-calendar__table-header th.mc-calendar__table-header-divider:after{content:\"\";position:absolute;top:0;left:-8px;left:calc(-1 * var(--mc-datepicker-calendar-size-padding-horizontal, 8px));right:-8px;right:calc(-1 * var(--mc-datepicker-calendar-size-padding-horizontal, 8px));height:1px;height:var(--mc-datepicker-calendar-size-divider-width, 1px)}\n"], dependencies: [{ kind: "component", type: McMonthView, selector: "mc-month-view", inputs: ["activeDate", "selected", "minDate", "maxDate", "dateFilter", "dateClass"], outputs: ["selectedChange", "userSelection", "activeDateChange"], exportAs: ["mcMonthView"] }, { kind: "component", type: McCalendarHeader, selector: "mc-calendar-header", inputs: ["activeDate", "maxDate", "minDate"], outputs: ["activeDateChange", "monthSelected", "yearSelected"], exportAs: ["mcCalendarHeader"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
1046
556
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: McCalendar, decorators: [{
|
1047
557
|
type: Component,
|
1048
558
|
args: [{ selector: 'mc-calendar', exportAs: 'mcCalendar', host: {
|
1049
559
|
class: 'mc-calendar'
|
1050
|
-
}, encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, template: "<
|
560
|
+
}, encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, template: "<mc-calendar-header\n [(activeDate)]=\"activeDate\"\n [maxDate]=\"maxDate\"\n [minDate]=\"minDate\"\n (monthSelected)=\"monthSelected.emit(activeDate)\"\n (yearSelected)=\"yearSelected.emit(activeDate)\">\n</mc-calendar-header>\n\n<div class=\"mc-calendar__content\">\n <mc-month-view\n [(activeDate)]=\"activeDate\"\n [selected]=\"selected\"\n [dateFilter]=\"dateFilter\"\n [maxDate]=\"maxDate\"\n [minDate]=\"minDate\"\n [dateClass]=\"dateClass\"\n (selectedChange)=\"dateSelected($event!)\"\n (userSelection)=\"userSelected()\">\n </mc-month-view>\n</div>\n", styles: [".mc-calendar{display:block}.mc-calendar__content{padding:0 8px 8px;padding:0 var(--mc-datepicker-calendar-size-padding-horizontal, 8px) var(--mc-datepicker-calendar-size-padding-horizontal, 8px) var(--mc-datepicker-calendar-size-padding-horizontal, 8px);outline:none}.mc-calendar__table{border-spacing:0;border-collapse:collapse;width:100%}.mc-calendar__table-header th{text-align:center;height:30px}.mc-calendar__table-header th.mc-calendar__table-header-divider{position:relative;height:10px;height:calc(var(--mc-datepicker-calendar-size-padding-blocks, 12px) - 2px)}.mc-calendar__table-header th.mc-calendar__table-header-divider:after{content:\"\";position:absolute;top:0;left:-8px;left:calc(-1 * var(--mc-datepicker-calendar-size-padding-horizontal, 8px));right:-8px;right:calc(-1 * var(--mc-datepicker-calendar-size-padding-horizontal, 8px));height:1px;height:var(--mc-datepicker-calendar-size-divider-width, 1px)}\n"] }]
|
1051
561
|
}], ctorParameters: function () { return [{ type: McDatepickerIntl }, { type: i1$1.DateAdapter, decorators: [{
|
1052
562
|
type: Optional
|
1053
563
|
}] }, { type: undefined, decorators: [{
|
@@ -1063,10 +573,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImpo
|
|
1063
573
|
type: Input
|
1064
574
|
}], maxDate: [{
|
1065
575
|
type: Input
|
1066
|
-
}], headerComponent: [{
|
1067
|
-
type: Input
|
1068
|
-
}], startView: [{
|
1069
|
-
type: Input
|
1070
576
|
}], dateFilter: [{
|
1071
577
|
type: Input
|
1072
578
|
}], dateClass: [{
|
@@ -1082,129 +588,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImpo
|
|
1082
588
|
}], monthView: [{
|
1083
589
|
type: ViewChild,
|
1084
590
|
args: [McMonthView, { static: false }]
|
1085
|
-
}], yearView: [{
|
1086
|
-
type: ViewChild,
|
1087
|
-
args: [McYearView, { static: false }]
|
1088
|
-
}], multiYearView: [{
|
1089
|
-
type: ViewChild,
|
1090
|
-
args: [McMultiYearView, { static: false }]
|
1091
591
|
}] } });
|
1092
|
-
/** Default header for McCalendar */
|
1093
|
-
class McCalendarHeader {
|
1094
|
-
constructor(intl, calendar, dateAdapter, dateFormats, changeDetectorRef) {
|
1095
|
-
this.intl = intl;
|
1096
|
-
this.calendar = calendar;
|
1097
|
-
this.dateAdapter = dateAdapter;
|
1098
|
-
this.dateFormats = dateFormats;
|
1099
|
-
this.calendar.stateChanges.subscribe(() => changeDetectorRef.markForCheck());
|
1100
|
-
}
|
1101
|
-
/** The label for the current calendar view. */
|
1102
|
-
get periodButtonText() {
|
1103
|
-
if (this.calendar.currentView === McCalendarView.Month) {
|
1104
|
-
const label = this.dateAdapter.format(this.calendar.activeDate, this.dateFormats.monthYearLabel);
|
1105
|
-
return (label[0].toLocaleUpperCase() + label.substr(1)).replace('.', '');
|
1106
|
-
}
|
1107
|
-
if (this.calendar.currentView === McCalendarView.Year) {
|
1108
|
-
return this.dateAdapter.getYearName(this.calendar.activeDate);
|
1109
|
-
}
|
1110
|
-
const activeYear = this.dateAdapter.getYear(this.calendar.activeDate);
|
1111
|
-
const firstYearInView = this.dateAdapter.getYearName(
|
1112
|
-
// tslint:disable-next-line:no-magic-numbers
|
1113
|
-
this.dateAdapter.createDate(activeYear - activeYear % 24));
|
1114
|
-
const lastYearInView = this.dateAdapter.getYearName(
|
1115
|
-
// tslint:disable-next-line:no-magic-numbers
|
1116
|
-
this.dateAdapter.createDate(activeYear + yearsPerPage - 1 - activeYear % 24));
|
1117
|
-
return `${firstYearInView} \u2013 ${lastYearInView}`;
|
1118
|
-
}
|
1119
|
-
get periodButtonLabel() {
|
1120
|
-
return this.calendar.currentView === McCalendarView.Month ?
|
1121
|
-
this.intl.switchToMultiYearViewLabel : this.intl.switchToMonthViewLabel;
|
1122
|
-
}
|
1123
|
-
/** The label for the previous button. */
|
1124
|
-
get prevButtonLabel() {
|
1125
|
-
return {
|
1126
|
-
[McCalendarView.Month]: this.intl.prevMonthLabel,
|
1127
|
-
[McCalendarView.Year]: this.intl.prevYearLabel,
|
1128
|
-
[McCalendarView.MultiYear]: this.intl.prevMultiYearLabel
|
1129
|
-
}[this.calendar.currentView];
|
1130
|
-
}
|
1131
|
-
/** The label for the next button. */
|
1132
|
-
get nextButtonLabel() {
|
1133
|
-
return {
|
1134
|
-
[McCalendarView.Month]: this.intl.nextMonthLabel,
|
1135
|
-
[McCalendarView.Year]: this.intl.nextYearLabel,
|
1136
|
-
[McCalendarView.MultiYear]: this.intl.nextMultiYearLabel
|
1137
|
-
}[this.calendar.currentView];
|
1138
|
-
}
|
1139
|
-
/** Handles user clicks on the period label. */
|
1140
|
-
currentPeriodClicked() {
|
1141
|
-
if ([McCalendarView.Month, McCalendarView.MultiYear].includes(this.calendar.currentView)) {
|
1142
|
-
this.calendar.currentView = McCalendarView.Year;
|
1143
|
-
}
|
1144
|
-
else if (this.calendar.currentView === McCalendarView.Year) {
|
1145
|
-
this.calendar.currentView = McCalendarView.Month;
|
1146
|
-
}
|
1147
|
-
}
|
1148
|
-
/** Handles user clicks on the previous button. */
|
1149
|
-
previousClicked() {
|
1150
|
-
if (this.calendar.currentView === McCalendarView.Month) {
|
1151
|
-
this.calendar.activeDate = this.dateAdapter.addCalendarMonths(this.calendar.activeDate, -1);
|
1152
|
-
}
|
1153
|
-
else {
|
1154
|
-
this.calendar.activeDate = this.dateAdapter.addCalendarYears(this.calendar.activeDate, this.calendar.currentView === McCalendarView.Year ? -1 : -yearsPerPage);
|
1155
|
-
}
|
1156
|
-
}
|
1157
|
-
/** Handles user clicks on the next button. */
|
1158
|
-
nextClicked() {
|
1159
|
-
if (this.calendar.currentView === McCalendarView.Month) {
|
1160
|
-
this.calendar.activeDate = this.dateAdapter.addCalendarMonths(this.calendar.activeDate, 1);
|
1161
|
-
}
|
1162
|
-
else {
|
1163
|
-
this.calendar.activeDate = this.dateAdapter.addCalendarYears(this.calendar.activeDate, this.calendar.currentView === McCalendarView.Year ? 1 : yearsPerPage);
|
1164
|
-
}
|
1165
|
-
}
|
1166
|
-
/** Whether the previous period button is enabled. */
|
1167
|
-
previousEnabled() {
|
1168
|
-
if (!this.calendar.minDate) {
|
1169
|
-
return true;
|
1170
|
-
}
|
1171
|
-
return !this.calendar.minDate || !this.isSameView(this.calendar.activeDate, this.calendar.minDate);
|
1172
|
-
}
|
1173
|
-
/** Whether the next period button is enabled. */
|
1174
|
-
nextEnabled() {
|
1175
|
-
return !this.calendar.maxDate || !this.isSameView(this.calendar.activeDate, this.calendar.maxDate);
|
1176
|
-
}
|
1177
|
-
/** Whether the two dates represent the same view in the current view mode (month or year). */
|
1178
|
-
isSameView(firstDate, secondDate) {
|
1179
|
-
const firstYear = this.dateAdapter.getYear(firstDate);
|
1180
|
-
const secondYear = this.dateAdapter.getYear(secondDate);
|
1181
|
-
const firstMonth = this.dateAdapter.getMonth(firstDate);
|
1182
|
-
const secondMonth = this.dateAdapter.getMonth(secondDate);
|
1183
|
-
if (this.calendar.currentView === McCalendarView.Month) {
|
1184
|
-
return firstYear === secondYear && firstMonth === secondMonth;
|
1185
|
-
}
|
1186
|
-
if (this.calendar.currentView === McCalendarView.Year) {
|
1187
|
-
return firstYear === secondYear;
|
1188
|
-
}
|
1189
|
-
// Otherwise we are in 'multi-year' view.
|
1190
|
-
return Math.floor(firstYear / yearsPerPage) === Math.floor(secondYear / yearsPerPage);
|
1191
|
-
}
|
1192
|
-
}
|
1193
|
-
/** @nocollapse */ McCalendarHeader.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: McCalendarHeader, deps: [{ token: McDatepickerIntl }, { token: McCalendar }, { token: i1$1.DateAdapter, optional: true }, { token: MC_DATE_FORMATS, optional: true }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
|
1194
|
-
/** @nocollapse */ McCalendarHeader.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.12", type: McCalendarHeader, selector: "mc-calendar-header", host: { classAttribute: "mc-calendar-header" }, exportAs: ["mcCalendarHeader"], ngImport: i0, template: "<button mc-button\n [tabindex]=\"'-1'\"\n class=\"mc-button_transparent mc-calendar__period-button\"\n (click)=\"currentPeriodClicked()\">\n {{ periodButtonText }}\n\n <i class=\"mc mc-icon\"\n [class.mc-angle-up-M_16]=\"calendar.currentView !== 'month'\"\n [class.mc-angle-down-M_16]=\"calendar.currentView === 'month'\">\n </i>\n</button>\n\n<div class=\"mc-calendar-spacer\"></div>\n\n<button mc-button\n [tabindex]=\"'-1'\"\n class=\"mc-button_transparent mc-calendar__previous-button\"\n [disabled]=\"!previousEnabled()\"\n (click)=\"previousClicked()\">\n\n <i mc-icon=\"mc-angle-left-L_16\"></i>\n</button>\n\n<button mc-button\n [tabindex]=\"'-1'\"\n class=\"mc-button_transparent mc-calendar__next-button\"\n [disabled]=\"!nextEnabled()\"\n (click)=\"nextClicked()\">\n\n <i mc-icon=\"mc-angle-right-L_16\"></i>\n</button>\n", dependencies: [{ kind: "component", type: i8.McButton, selector: "[mc-button]", inputs: ["color", "tabIndex", "disabled"] }, { kind: "directive", type: i8.McButtonCssStyler, selector: "[mc-button]" }, { kind: "component", type: i9.McIcon, selector: "[mc-icon]", inputs: ["color"] }, { kind: "directive", type: i9.McIconCSSStyler, selector: "[mc-icon]" }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
1195
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: McCalendarHeader, decorators: [{
|
1196
|
-
type: Component,
|
1197
|
-
args: [{ selector: 'mc-calendar-header', exportAs: 'mcCalendarHeader', host: {
|
1198
|
-
class: 'mc-calendar-header'
|
1199
|
-
}, encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, template: "<button mc-button\n [tabindex]=\"'-1'\"\n class=\"mc-button_transparent mc-calendar__period-button\"\n (click)=\"currentPeriodClicked()\">\n {{ periodButtonText }}\n\n <i class=\"mc mc-icon\"\n [class.mc-angle-up-M_16]=\"calendar.currentView !== 'month'\"\n [class.mc-angle-down-M_16]=\"calendar.currentView === 'month'\">\n </i>\n</button>\n\n<div class=\"mc-calendar-spacer\"></div>\n\n<button mc-button\n [tabindex]=\"'-1'\"\n class=\"mc-button_transparent mc-calendar__previous-button\"\n [disabled]=\"!previousEnabled()\"\n (click)=\"previousClicked()\">\n\n <i mc-icon=\"mc-angle-left-L_16\"></i>\n</button>\n\n<button mc-button\n [tabindex]=\"'-1'\"\n class=\"mc-button_transparent mc-calendar__next-button\"\n [disabled]=\"!nextEnabled()\"\n (click)=\"nextClicked()\">\n\n <i mc-icon=\"mc-angle-right-L_16\"></i>\n</button>\n" }]
|
1200
|
-
}], ctorParameters: function () { return [{ type: McDatepickerIntl }, { type: McCalendar }, { type: i1$1.DateAdapter, decorators: [{
|
1201
|
-
type: Optional
|
1202
|
-
}] }, { type: undefined, decorators: [{
|
1203
|
-
type: Optional
|
1204
|
-
}, {
|
1205
|
-
type: Inject,
|
1206
|
-
args: [MC_DATE_FORMATS]
|
1207
|
-
}] }, { type: i0.ChangeDetectorRef }]; } });
|
1208
592
|
|
1209
593
|
/**
|
1210
594
|
* Animations used by the mosaic datepicker.
|
@@ -1282,7 +666,7 @@ class McDatepickerContent {
|
|
1282
666
|
}
|
1283
667
|
}
|
1284
668
|
/** @nocollapse */ McDatepickerContent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: McDatepickerContent, deps: [{ token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
|
1285
|
-
/** @nocollapse */ McDatepickerContent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.12", type: McDatepickerContent, selector: "mc-datepicker__content", host: { listeners: { "@transformPanel.done": "animationDone.next()" }, properties: { "@transformPanel": "animationState" }, classAttribute: "mc-datepicker__content" }, viewQueries: [{ propertyName: "calendar", first: true, predicate: McCalendar, descendants: true }], exportAs: ["mcDatepickerContent"], ngImport: i0, template: "<mc-calendar [id]=\"datepicker.id\"\n [ngClass]=\"datepicker.panelClass\"\n [
|
669
|
+
/** @nocollapse */ McDatepickerContent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.12", type: McDatepickerContent, selector: "mc-datepicker__content", host: { listeners: { "@transformPanel.done": "animationDone.next()" }, properties: { "@transformPanel": "animationState" }, classAttribute: "mc-datepicker__content" }, viewQueries: [{ propertyName: "calendar", first: true, predicate: McCalendar, descendants: true }], exportAs: ["mcDatepickerContent"], ngImport: i0, template: "<mc-calendar [id]=\"datepicker.id\"\n [@fadeInCalendar]=\"'enter'\"\n [ngClass]=\"datepicker.panelClass\"\n [dateClass]=\"datepicker.dateClass\"\n\n [startAt]=\"datepicker.startAt\"\n [minDate]=\"datepicker.minDate\"\n [maxDate]=\"datepicker.maxDate\"\n [dateFilter]=\"datepicker.dateFilter\"\n\n [selected]=\"datepicker.selected\"\n\n (selectedChange)=\"datepicker.select($event)\"\n (yearSelected)=\"datepicker.selectYear($event)\"\n (monthSelected)=\"datepicker.selectMonth($event)\"\n (userSelection)=\"datepicker.close()\">\n</mc-calendar>\n", styles: [".mc-datepicker__content{display:block;border-width:1px;border-style:solid;border-radius:0;border-radius:var(--mc-datepicker-calendar-size-border-radius, 0)}.mc-datepicker__content .mc-calendar{width:296px;height:348px}\n"], dependencies: [{ kind: "directive", type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "component", type: McCalendar, selector: "mc-calendar", inputs: ["startAt", "selected", "minDate", "maxDate", "dateFilter", "dateClass"], outputs: ["selectedChange", "yearSelected", "monthSelected", "userSelection"], exportAs: ["mcCalendar"] }], animations: [
|
1286
670
|
mcDatepickerAnimations.transformPanel,
|
1287
671
|
mcDatepickerAnimations.fadeInCalendar
|
1288
672
|
], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
@@ -1295,7 +679,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImpo
|
|
1295
679
|
}, animations: [
|
1296
680
|
mcDatepickerAnimations.transformPanel,
|
1297
681
|
mcDatepickerAnimations.fadeInCalendar
|
1298
|
-
], encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, template: "<mc-calendar [id]=\"datepicker.id\"\n [ngClass]=\"datepicker.panelClass\"\n [
|
682
|
+
], encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, template: "<mc-calendar [id]=\"datepicker.id\"\n [@fadeInCalendar]=\"'enter'\"\n [ngClass]=\"datepicker.panelClass\"\n [dateClass]=\"datepicker.dateClass\"\n\n [startAt]=\"datepicker.startAt\"\n [minDate]=\"datepicker.minDate\"\n [maxDate]=\"datepicker.maxDate\"\n [dateFilter]=\"datepicker.dateFilter\"\n\n [selected]=\"datepicker.selected\"\n\n (selectedChange)=\"datepicker.select($event)\"\n (yearSelected)=\"datepicker.selectYear($event)\"\n (monthSelected)=\"datepicker.selectMonth($event)\"\n (userSelection)=\"datepicker.close()\">\n</mc-calendar>\n", styles: [".mc-datepicker__content{display:block;border-width:1px;border-style:solid;border-radius:0;border-radius:var(--mc-datepicker-calendar-size-border-radius, 0)}.mc-datepicker__content .mc-calendar{width:296px;height:348px}\n"] }]
|
1299
683
|
}], ctorParameters: function () { return [{ type: i0.ChangeDetectorRef }]; }, propDecorators: { calendar: [{
|
1300
684
|
type: ViewChild,
|
1301
685
|
args: [McCalendar]
|
@@ -1314,8 +698,6 @@ class McDatepicker {
|
|
1314
698
|
this.document = document;
|
1315
699
|
this._hasBackdrop = false;
|
1316
700
|
this._opened = false;
|
1317
|
-
/** The view that the calendar should start in. */
|
1318
|
-
this.startView = McCalendarView.Month;
|
1319
701
|
/**
|
1320
702
|
* Emits selected year in multiyear view.
|
1321
703
|
* This doesn't imply a change on the selected date.
|
@@ -1359,10 +741,12 @@ class McDatepicker {
|
|
1359
741
|
get startAt() {
|
1360
742
|
// If an explicit startAt is set we start there, otherwise we start at whatever the currently
|
1361
743
|
// selected value is.
|
1362
|
-
return this._startAt ||
|
744
|
+
return this._startAt || this.datepickerInput?.value;
|
1363
745
|
}
|
1364
746
|
set startAt(value) {
|
1365
|
-
|
747
|
+
const deserializedValue = this.dateAdapter.deserialize(value);
|
748
|
+
this._startAt = deserializedValue !== null ?
|
749
|
+
this.dateAdapter.clampDate(deserializedValue, this.minDate, this.maxDate) : null;
|
1366
750
|
}
|
1367
751
|
/** Whether the datepicker pop-up should be disabled. */
|
1368
752
|
get disabled() {
|
@@ -1497,7 +881,7 @@ class McDatepicker {
|
|
1497
881
|
// Update the position once the calendar has rendered.
|
1498
882
|
this.ngZone.onStable.asObservable()
|
1499
883
|
.pipe(take(1))
|
1500
|
-
.subscribe(() => this.popupRef
|
884
|
+
.subscribe(() => this.popupRef?.updatePosition());
|
1501
885
|
}
|
1502
886
|
}
|
1503
887
|
/** Create the popup. */
|
@@ -1555,16 +939,9 @@ class McDatepicker {
|
|
1555
939
|
}
|
1556
940
|
]);
|
1557
941
|
}
|
1558
|
-
/**
|
1559
|
-
* @param obj The object to check.
|
1560
|
-
* @returns The given object if it is both a date instance and valid, otherwise null.
|
1561
|
-
*/
|
1562
|
-
getValidDateOrNull(obj) {
|
1563
|
-
return (this.dateAdapter.isDateInstance(obj) && this.dateAdapter.isValid(obj)) ? obj : null;
|
1564
|
-
}
|
1565
942
|
}
|
1566
|
-
/** @nocollapse */ McDatepicker.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: McDatepicker, deps: [{ token: i3.Overlay }, { token: i0.NgZone }, { token: i0.ViewContainerRef }, { token: MC_DATEPICKER_SCROLL_STRATEGY }, { token: i1$1.DateAdapter, optional: true }, { token:
|
1567
|
-
/** @nocollapse */ McDatepicker.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.12", type: McDatepicker, selector: "mc-datepicker", inputs: { hasBackdrop: "hasBackdrop", startAt: "startAt", disabled: "disabled", opened: "opened", minDate: "minDate", maxDate: "maxDate",
|
943
|
+
/** @nocollapse */ McDatepicker.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: McDatepicker, deps: [{ token: i3$1.Overlay }, { token: i0.NgZone }, { token: i0.ViewContainerRef }, { token: MC_DATEPICKER_SCROLL_STRATEGY }, { token: i1$1.DateAdapter, optional: true }, { token: i5$1.Directionality, optional: true }, { token: DOCUMENT, optional: true }], target: i0.ɵɵFactoryTarget.Component });
|
944
|
+
/** @nocollapse */ McDatepicker.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.12", type: McDatepicker, selector: "mc-datepicker", inputs: { hasBackdrop: "hasBackdrop", startAt: "startAt", disabled: "disabled", opened: "opened", minDate: "minDate", maxDate: "maxDate", panelClass: "panelClass", dateClass: "dateClass", backdropClass: "backdropClass" }, outputs: { yearSelected: "yearSelected", monthSelected: "monthSelected", openedStream: "opened", closedStream: "closed" }, providers: [{ provide: McFormFieldControl, useExisting: McDatepicker }], exportAs: ["mcDatepicker"], ngImport: i0, template: '', isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
1568
945
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: McDatepicker, decorators: [{
|
1569
946
|
type: Component,
|
1570
947
|
args: [{
|
@@ -1575,12 +952,12 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImpo
|
|
1575
952
|
encapsulation: ViewEncapsulation.None,
|
1576
953
|
providers: [{ provide: McFormFieldControl, useExisting: McDatepicker }]
|
1577
954
|
}]
|
1578
|
-
}], ctorParameters: function () { return [{ type: i3.Overlay }, { type: i0.NgZone }, { type: i0.ViewContainerRef }, { type: undefined, decorators: [{
|
955
|
+
}], ctorParameters: function () { return [{ type: i3$1.Overlay }, { type: i0.NgZone }, { type: i0.ViewContainerRef }, { type: undefined, decorators: [{
|
1579
956
|
type: Inject,
|
1580
957
|
args: [MC_DATEPICKER_SCROLL_STRATEGY]
|
1581
958
|
}] }, { type: i1$1.DateAdapter, decorators: [{
|
1582
959
|
type: Optional
|
1583
|
-
}] }, { type:
|
960
|
+
}] }, { type: i5$1.Directionality, decorators: [{
|
1584
961
|
type: Optional
|
1585
962
|
}] }, { type: undefined, decorators: [{
|
1586
963
|
type: Optional
|
@@ -1599,10 +976,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImpo
|
|
1599
976
|
type: Input
|
1600
977
|
}], maxDate: [{
|
1601
978
|
type: Input
|
1602
|
-
}], calendarHeaderComponent: [{
|
1603
|
-
type: Input
|
1604
|
-
}], startView: [{
|
1605
|
-
type: Input
|
1606
979
|
}], yearSelected: [{
|
1607
980
|
type: Output
|
1608
981
|
}], monthSelected: [{
|
@@ -1734,10 +1107,10 @@ class McDatepickerInputEvent {
|
|
1734
1107
|
let uniqueComponentIdSuffix = 0;
|
1735
1108
|
/** Directive used to connect an input to a McDatepicker. */
|
1736
1109
|
class McDatepickerInput {
|
1737
|
-
constructor(elementRef, renderer,
|
1110
|
+
constructor(elementRef, renderer, adapter, dateFormats) {
|
1738
1111
|
this.elementRef = elementRef;
|
1739
1112
|
this.renderer = renderer;
|
1740
|
-
this.
|
1113
|
+
this.adapter = adapter;
|
1741
1114
|
this.dateFormats = dateFormats;
|
1742
1115
|
this.stateChanges = new Subject();
|
1743
1116
|
this.controlType = 'datepicker';
|
@@ -1836,21 +1209,21 @@ class McDatepickerInput {
|
|
1836
1209
|
};
|
1837
1210
|
/** The form control validator for the min date. */
|
1838
1211
|
this.minValidator = (control) => {
|
1839
|
-
const controlValue = this.
|
1840
|
-
return !this.min || !controlValue || this.
|
1212
|
+
const controlValue = this.adapter.deserialize(control.value);
|
1213
|
+
return !this.min || !controlValue || this.adapter.compareDateTime(this.min, controlValue) <= 0 ?
|
1841
1214
|
null :
|
1842
1215
|
{ mcDatepickerMin: { min: this.min, actual: controlValue } };
|
1843
1216
|
};
|
1844
1217
|
/** The form control validator for the max date. */
|
1845
1218
|
this.maxValidator = (control) => {
|
1846
|
-
const controlValue = this.
|
1847
|
-
return !this.max || !controlValue || this.
|
1219
|
+
const controlValue = this.adapter.deserialize(control.value);
|
1220
|
+
return !this.max || !controlValue || this.adapter.compareDateTime(this.max, controlValue) >= 0 ?
|
1848
1221
|
null :
|
1849
1222
|
{ mcDatepickerMax: { max: this.max, actual: controlValue } };
|
1850
1223
|
};
|
1851
1224
|
/** The form control validator for the date filter. */
|
1852
1225
|
this.filterValidator = (control) => {
|
1853
|
-
const controlValue = this.
|
1226
|
+
const controlValue = this.adapter.deserialize(control.value);
|
1854
1227
|
return !this.dateFilter || !controlValue || this.dateFilter(controlValue) ?
|
1855
1228
|
null : { mcDatepickerFilter: true };
|
1856
1229
|
};
|
@@ -1860,14 +1233,14 @@ class McDatepickerInput {
|
|
1860
1233
|
this.maxValidator,
|
1861
1234
|
this.filterValidator
|
1862
1235
|
]);
|
1863
|
-
if (!this.
|
1236
|
+
if (!this.adapter) {
|
1864
1237
|
throw createMissingDateImplError('DateAdapter');
|
1865
1238
|
}
|
1866
1239
|
if (!this.dateFormats) {
|
1867
1240
|
throw createMissingDateImplError('MC_DATE_FORMATS');
|
1868
1241
|
}
|
1869
1242
|
this.setFormat(dateFormats.dateInput);
|
1870
|
-
this.localeSubscription =
|
1243
|
+
this.localeSubscription = adapter.localeChanges
|
1871
1244
|
.subscribe(this.updateLocaleParams);
|
1872
1245
|
}
|
1873
1246
|
get required() {
|
@@ -1903,13 +1276,13 @@ class McDatepickerInput {
|
|
1903
1276
|
return this._value;
|
1904
1277
|
}
|
1905
1278
|
set value(value) {
|
1906
|
-
let newValue = this.
|
1907
|
-
this.lastValueValid = !newValue || this.
|
1279
|
+
let newValue = this.adapter.deserialize(value);
|
1280
|
+
this.lastValueValid = !newValue || this.adapter.isValid(newValue);
|
1908
1281
|
newValue = this.getValidDateOrNull(newValue);
|
1909
1282
|
const oldDate = this.value;
|
1910
1283
|
this._value = newValue;
|
1911
1284
|
this.formatValue(newValue);
|
1912
|
-
if (!this.
|
1285
|
+
if (!this.adapter.sameDate(oldDate, newValue)) {
|
1913
1286
|
this.valueChange.emit(newValue);
|
1914
1287
|
}
|
1915
1288
|
}
|
@@ -1918,7 +1291,7 @@ class McDatepickerInput {
|
|
1918
1291
|
return this._min;
|
1919
1292
|
}
|
1920
1293
|
set min(value) {
|
1921
|
-
this._min = this.
|
1294
|
+
this._min = this.adapter.deserialize(value);
|
1922
1295
|
this.validatorOnChange();
|
1923
1296
|
}
|
1924
1297
|
/** The maximum valid date. */
|
@@ -1926,7 +1299,7 @@ class McDatepickerInput {
|
|
1926
1299
|
return this._max;
|
1927
1300
|
}
|
1928
1301
|
set max(value) {
|
1929
|
-
this._max = this.
|
1302
|
+
this._max = this.adapter.deserialize(value);
|
1930
1303
|
this.validatorOnChange();
|
1931
1304
|
}
|
1932
1305
|
/** Whether the datepicker-input is disabled. */
|
@@ -2122,20 +1495,20 @@ class McDatepickerInput {
|
|
2122
1495
|
this.updateValue(newTimeObj);
|
2123
1496
|
}
|
2124
1497
|
toISO8601(value) {
|
2125
|
-
return this.
|
1498
|
+
return this.adapter.toIso8601(value);
|
2126
1499
|
}
|
2127
1500
|
saveTimePart(selected) {
|
2128
1501
|
if (!this.value) {
|
2129
1502
|
return selected;
|
2130
1503
|
}
|
2131
|
-
const years = this.
|
2132
|
-
const month = this.
|
2133
|
-
const day = this.
|
2134
|
-
const hours = this.
|
2135
|
-
const minutes = this.
|
2136
|
-
const seconds = this.
|
2137
|
-
const milliseconds = this.
|
2138
|
-
return this.
|
1504
|
+
const years = this.adapter.getYear(selected);
|
1505
|
+
const month = this.adapter.getMonth(selected);
|
1506
|
+
const day = this.adapter.getDate(selected);
|
1507
|
+
const hours = this.adapter.getHours(this.value);
|
1508
|
+
const minutes = this.adapter.getMinutes(this.value);
|
1509
|
+
const seconds = this.adapter.getSeconds(this.value);
|
1510
|
+
const milliseconds = this.adapter.getMilliseconds(this.value);
|
1511
|
+
return this.adapter.createDateTime(years, month, day, hours, minutes, seconds, milliseconds);
|
2139
1512
|
}
|
2140
1513
|
setFormat(format) {
|
2141
1514
|
// @ts-ignore
|
@@ -2146,7 +1519,7 @@ class McDatepickerInput {
|
|
2146
1519
|
this.getDigitPositions(format);
|
2147
1520
|
}
|
2148
1521
|
updateValue(newValue) {
|
2149
|
-
if (!this.
|
1522
|
+
if (!this.adapter.sameDate(newValue, this.value)) {
|
2150
1523
|
this._value = newValue;
|
2151
1524
|
this.cvaOnChange(newValue);
|
2152
1525
|
this.valueChange.emit(newValue);
|
@@ -2241,22 +1614,22 @@ class McDatepickerInput {
|
|
2241
1614
|
return this.createDateTime(date);
|
2242
1615
|
}
|
2243
1616
|
getDefaultValue() {
|
2244
|
-
const defaultValue = this.value || this.
|
1617
|
+
const defaultValue = this.value || this.adapter.today();
|
2245
1618
|
return {
|
2246
|
-
year: this.
|
2247
|
-
month: this.
|
2248
|
-
date: this.
|
2249
|
-
hours: this.
|
2250
|
-
minutes: this.
|
2251
|
-
seconds: this.
|
2252
|
-
milliseconds: this.
|
1619
|
+
year: this.adapter.getYear(defaultValue),
|
1620
|
+
month: this.adapter.getMonth(defaultValue),
|
1621
|
+
date: this.adapter.getDate(defaultValue),
|
1622
|
+
hours: this.adapter.getHours(defaultValue),
|
1623
|
+
minutes: this.adapter.getMinutes(defaultValue),
|
1624
|
+
seconds: this.adapter.getSeconds(defaultValue),
|
1625
|
+
milliseconds: this.adapter.getMilliseconds(defaultValue)
|
2253
1626
|
};
|
2254
1627
|
}
|
2255
1628
|
getTimeStringFromDate(value, timeFormat) {
|
2256
|
-
if (!value || !this.
|
1629
|
+
if (!value || !this.adapter.isValid(value)) {
|
2257
1630
|
return '';
|
2258
1631
|
}
|
2259
|
-
return this.
|
1632
|
+
return this.adapter.format(value, timeFormat);
|
2260
1633
|
}
|
2261
1634
|
getDateEditMetrics(cursorPosition) {
|
2262
1635
|
for (const digit of [this.firstDigit, this.secondDigit, this.thirdDigit]) {
|
@@ -2267,13 +1640,13 @@ class McDatepickerInput {
|
|
2267
1640
|
return [this.thirdDigit.value, this.thirdDigit.start, this.thirdDigit.end];
|
2268
1641
|
}
|
2269
1642
|
incrementDate(dateVal, whatToIncrement) {
|
2270
|
-
let year = this.
|
2271
|
-
let month = this.
|
2272
|
-
let day = this.
|
1643
|
+
let year = this.adapter.getYear(dateVal);
|
1644
|
+
let month = this.adapter.getMonth(dateVal);
|
1645
|
+
let day = this.adapter.getDate(dateVal);
|
2273
1646
|
switch (whatToIncrement) {
|
2274
1647
|
case DateParts.day:
|
2275
1648
|
day++;
|
2276
|
-
if (day > this.
|
1649
|
+
if (day > this.adapter.getNumDaysInMonth(dateVal)) {
|
2277
1650
|
day = 1;
|
2278
1651
|
}
|
2279
1652
|
break;
|
@@ -2299,17 +1672,17 @@ class McDatepickerInput {
|
|
2299
1672
|
return this.createDate(year, month, day);
|
2300
1673
|
}
|
2301
1674
|
getLastDayFor(year, month) {
|
2302
|
-
return this.
|
1675
|
+
return this.adapter.getNumDaysInMonth(this.createDate(year, month, 1));
|
2303
1676
|
}
|
2304
1677
|
decrementDate(dateVal, whatToDecrement) {
|
2305
|
-
let year = this.
|
2306
|
-
let month = this.
|
2307
|
-
let day = this.
|
1678
|
+
let year = this.adapter.getYear(dateVal);
|
1679
|
+
let month = this.adapter.getMonth(dateVal);
|
1680
|
+
let day = this.adapter.getDate(dateVal);
|
2308
1681
|
switch (whatToDecrement) {
|
2309
1682
|
case DateParts.day:
|
2310
1683
|
day--;
|
2311
1684
|
if (day < 1) {
|
2312
|
-
day = this.
|
1685
|
+
day = this.adapter.getNumDaysInMonth(dateVal);
|
2313
1686
|
}
|
2314
1687
|
break;
|
2315
1688
|
case DateParts.month:
|
@@ -2404,16 +1777,9 @@ class McDatepickerInput {
|
|
2404
1777
|
}
|
2405
1778
|
/** Formats a value and sets it on the input element. */
|
2406
1779
|
formatValue(value) {
|
2407
|
-
const formattedValue = value ? this.
|
1780
|
+
const formattedValue = value ? this.adapter.format(value, this.dateFormats.dateInput) : '';
|
2408
1781
|
this.setViewValue(formattedValue);
|
2409
1782
|
}
|
2410
|
-
/**
|
2411
|
-
* @param obj The object to check.
|
2412
|
-
* @returns The given object if it is both a date instance and valid, otherwise null.
|
2413
|
-
*/
|
2414
|
-
getValidDateOrNull(obj) {
|
2415
|
-
return (this.dateAdapter.isDateInstance(obj) && this.dateAdapter.isValid(obj)) ? obj : null;
|
2416
|
-
}
|
2417
1783
|
setControl(control) {
|
2418
1784
|
if (this.control) {
|
2419
1785
|
return;
|
@@ -2422,6 +1788,13 @@ class McDatepickerInput {
|
|
2422
1788
|
this.control.valueChanges
|
2423
1789
|
.subscribe((value) => this._value = value);
|
2424
1790
|
}
|
1791
|
+
/**
|
1792
|
+
* @param obj The object to check.
|
1793
|
+
* @returns The given object if it is both a date instance and valid, otherwise null.
|
1794
|
+
*/
|
1795
|
+
getValidDateOrNull(obj) {
|
1796
|
+
return (this.adapter.isDateInstance(obj) && this.adapter.isValid(obj)) ? obj : null;
|
1797
|
+
}
|
2425
1798
|
getDigitPositions(format) {
|
2426
1799
|
const formatInLowerCase = format.toLowerCase();
|
2427
1800
|
formatInLowerCase
|
@@ -2451,13 +1824,13 @@ class McDatepickerInput {
|
|
2451
1824
|
}
|
2452
1825
|
}
|
2453
1826
|
createDate(year, month, day) {
|
2454
|
-
return this.
|
1827
|
+
return this.adapter.createDateTime(year, month, day, this.adapter.getHours(this.value), this.adapter.getMinutes(this.value), this.adapter.getSeconds(this.value), this.adapter.getMilliseconds(this.value));
|
2455
1828
|
}
|
2456
1829
|
createDateTime(value) {
|
2457
1830
|
if (Object.values(value).some(isNaN)) {
|
2458
1831
|
return null;
|
2459
1832
|
}
|
2460
|
-
return this.
|
1833
|
+
return this.adapter.createDateTime(value.year, value.month - 1, value.date, value.hours, value.minutes, value.seconds, value.milliseconds);
|
2461
1834
|
}
|
2462
1835
|
correctCursorPosition() {
|
2463
1836
|
if (this.selectionStart && this.separatorPositions.includes(this.selectionStart)) {
|
@@ -2584,7 +1957,7 @@ class McDatepickerToggle {
|
|
2584
1957
|
}
|
2585
1958
|
}
|
2586
1959
|
/** @nocollapse */ McDatepickerToggle.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: McDatepickerToggle, deps: [{ token: McDatepickerIntl }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
|
2587
|
-
/** @nocollapse */ McDatepickerToggle.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.12", type: McDatepickerToggle, selector: "mc-datepicker-toggle", inputs: { disabled: "disabled", datepicker: ["for", "datepicker"], tabIndex: "tabIndex" }, host: { properties: { "class.mc-active": "datepicker && datepicker.opened" }, classAttribute: "mc-datepicker-toggle" }, queries: [{ propertyName: "customIcon", first: true, predicate: McDatepickerToggleIcon, descendants: true }], viewQueries: [{ propertyName: "button", first: true, predicate: ["button"], descendants: true }], exportAs: ["mcDatepickerToggle"], usesOnChanges: true, ngImport: i0, template: "<!--todo need simplify this-->\n<button\n #button\n mc-button\n type=\"button\"\n class=\"mc-datepicker-toggle__button\"\n aria-haspopup=\"true\"\n [attr.aria-label]=\"intl.openCalendarLabel\"\n [tabIndex]=\"tabIndex\"\n [disabled]=\"disabled\"\n (click)=\"open($event)\">\n\n <i *ngIf=\"!customIcon\" mc-icon=\"mc-calendar_16\" class=\"mc-datepicker-toggle__default-icon\"></i>\n\n <ng-content select=\"[mcDatepickerToggleIcon]\"></ng-content>\n</button>\n", styles: [".mc-datepicker-toggle:focus{outline:0}.mc-datepicker-toggle__button.mc-icon-button{width:30px;width:var(--mc-datepicker-toggle-size-width, 30px);height:30px;height:var(--mc-datepicker-toggle-size-height, 30px);margin-left:2px}.mc-form-field-appearance-legacy .mc-form-field-prefix .mc-datepicker-toggle__default-icon,.mc-form-field-appearance-legacy .mc-form-field-suffix .mc-datepicker-toggle__default-icon{width:1em}.mc-form-field:not(.mc-form-field-appearance-legacy) .mc-form-field-prefix .mc-datepicker-toggle__default-icon,.mc-form-field:not(.mc-form-field-appearance-legacy) .mc-form-field-suffix .mc-datepicker-toggle__default-icon{display:block;width:1.5em;height:1.5em}.mc-form-field:not(.mc-form-field-appearance-legacy) .mc-form-field-prefix .mc-icon-button .mc-datepicker-toggle__default-icon,.mc-form-field:not(.mc-form-field-appearance-legacy) .mc-form-field-suffix .mc-icon-button .mc-datepicker-toggle__default-icon{margin:auto}\n"], dependencies: [{ kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type:
|
1960
|
+
/** @nocollapse */ McDatepickerToggle.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.12", type: McDatepickerToggle, selector: "mc-datepicker-toggle", inputs: { disabled: "disabled", datepicker: ["for", "datepicker"], tabIndex: "tabIndex" }, host: { properties: { "class.mc-active": "datepicker && datepicker.opened" }, classAttribute: "mc-datepicker-toggle" }, queries: [{ propertyName: "customIcon", first: true, predicate: McDatepickerToggleIcon, descendants: true }], viewQueries: [{ propertyName: "button", first: true, predicate: ["button"], descendants: true }], exportAs: ["mcDatepickerToggle"], usesOnChanges: true, ngImport: i0, template: "<!--todo need simplify this-->\n<button\n #button\n mc-button\n type=\"button\"\n class=\"mc-datepicker-toggle__button\"\n aria-haspopup=\"true\"\n [attr.aria-label]=\"intl.openCalendarLabel\"\n [tabIndex]=\"tabIndex\"\n [disabled]=\"disabled\"\n (click)=\"open($event)\">\n\n <i *ngIf=\"!customIcon\" mc-icon=\"mc-calendar_16\" class=\"mc-datepicker-toggle__default-icon\"></i>\n\n <ng-content select=\"[mcDatepickerToggleIcon]\"></ng-content>\n</button>\n", styles: [".mc-datepicker-toggle:focus{outline:0}.mc-datepicker-toggle__button.mc-icon-button{width:30px;width:var(--mc-datepicker-toggle-size-width, 30px);height:30px;height:var(--mc-datepicker-toggle-size-height, 30px);margin-left:2px}.mc-form-field-appearance-legacy .mc-form-field-prefix .mc-datepicker-toggle__default-icon,.mc-form-field-appearance-legacy .mc-form-field-suffix .mc-datepicker-toggle__default-icon{width:1em}.mc-form-field:not(.mc-form-field-appearance-legacy) .mc-form-field-prefix .mc-datepicker-toggle__default-icon,.mc-form-field:not(.mc-form-field-appearance-legacy) .mc-form-field-suffix .mc-datepicker-toggle__default-icon{display:block;width:1.5em;height:1.5em}.mc-form-field:not(.mc-form-field-appearance-legacy) .mc-form-field-prefix .mc-icon-button .mc-datepicker-toggle__default-icon,.mc-form-field:not(.mc-form-field-appearance-legacy) .mc-form-field-suffix .mc-icon-button .mc-datepicker-toggle__default-icon{margin:auto}\n"], dependencies: [{ kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: i3.McButton, selector: "[mc-button]", inputs: ["color", "tabIndex", "disabled"] }, { kind: "directive", type: i3.McButtonCssStyler, selector: "[mc-button]" }, { kind: "component", type: i7.McIcon, selector: "[mc-icon]", inputs: ["color"] }, { kind: "directive", type: i7.McIconCSSStyler, selector: "[mc-icon]" }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
2588
1961
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: McDatepickerToggle, decorators: [{
|
2589
1962
|
type: Component,
|
2590
1963
|
args: [{ selector: 'mc-datepicker-toggle', host: {
|
@@ -2617,13 +1990,13 @@ class McDatepickerModule {
|
|
2617
1990
|
McDatepickerToggle,
|
2618
1991
|
McDatepickerToggleIcon,
|
2619
1992
|
McMonthView,
|
2620
|
-
McYearView,
|
2621
|
-
McMultiYearView,
|
2622
1993
|
McCalendarHeader], imports: [CommonModule,
|
2623
1994
|
McButtonModule,
|
2624
1995
|
OverlayModule,
|
2625
1996
|
A11yModule,
|
2626
1997
|
PortalModule,
|
1998
|
+
McButtonModule,
|
1999
|
+
McSelectModule,
|
2627
2000
|
McIconModule], exports: [McCalendar,
|
2628
2001
|
McCalendarBody,
|
2629
2002
|
McDatepicker,
|
@@ -2632,10 +2005,7 @@ class McDatepickerModule {
|
|
2632
2005
|
McDatepickerToggle,
|
2633
2006
|
McDatepickerToggleIcon,
|
2634
2007
|
McMonthView,
|
2635
|
-
|
2636
|
-
McMultiYearView,
|
2637
|
-
McCalendarHeader,
|
2638
|
-
McButtonModule] });
|
2008
|
+
McCalendarHeader] });
|
2639
2009
|
/** @nocollapse */ McDatepickerModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: McDatepickerModule, providers: [
|
2640
2010
|
McDatepickerIntl,
|
2641
2011
|
MC_DATEPICKER_SCROLL_STRATEGY_FACTORY_PROVIDER
|
@@ -2644,7 +2014,9 @@ class McDatepickerModule {
|
|
2644
2014
|
OverlayModule,
|
2645
2015
|
A11yModule,
|
2646
2016
|
PortalModule,
|
2647
|
-
|
2017
|
+
McButtonModule,
|
2018
|
+
McSelectModule,
|
2019
|
+
McIconModule] });
|
2648
2020
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: McDatepickerModule, decorators: [{
|
2649
2021
|
type: NgModule,
|
2650
2022
|
args: [{
|
@@ -2654,6 +2026,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImpo
|
|
2654
2026
|
OverlayModule,
|
2655
2027
|
A11yModule,
|
2656
2028
|
PortalModule,
|
2029
|
+
McButtonModule,
|
2030
|
+
McSelectModule,
|
2657
2031
|
McIconModule
|
2658
2032
|
],
|
2659
2033
|
exports: [
|
@@ -2665,10 +2039,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImpo
|
|
2665
2039
|
McDatepickerToggle,
|
2666
2040
|
McDatepickerToggleIcon,
|
2667
2041
|
McMonthView,
|
2668
|
-
|
2669
|
-
McMultiYearView,
|
2670
|
-
McCalendarHeader,
|
2671
|
-
McButtonModule
|
2042
|
+
McCalendarHeader
|
2672
2043
|
],
|
2673
2044
|
declarations: [
|
2674
2045
|
McCalendar,
|
@@ -2679,8 +2050,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImpo
|
|
2679
2050
|
McDatepickerToggle,
|
2680
2051
|
McDatepickerToggleIcon,
|
2681
2052
|
McMonthView,
|
2682
|
-
McYearView,
|
2683
|
-
McMultiYearView,
|
2684
2053
|
McCalendarHeader
|
2685
2054
|
],
|
2686
2055
|
providers: [
|
@@ -2694,5 +2063,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImpo
|
|
2694
2063
|
* Generated bundle index. Do not edit.
|
2695
2064
|
*/
|
2696
2065
|
|
2697
|
-
export { MAX_YEAR, MC_DATEPICKER_SCROLL_STRATEGY, MC_DATEPICKER_SCROLL_STRATEGY_FACTORY, MC_DATEPICKER_SCROLL_STRATEGY_FACTORY_PROVIDER, MC_DATEPICKER_VALIDATORS, MC_DATEPICKER_VALUE_ACCESSOR, McCalendar, McCalendarBody, McCalendarCell, McCalendarHeader,
|
2066
|
+
export { MAX_YEAR, MC_DATEPICKER_SCROLL_STRATEGY, MC_DATEPICKER_SCROLL_STRATEGY_FACTORY, MC_DATEPICKER_SCROLL_STRATEGY_FACTORY_PROVIDER, MC_DATEPICKER_VALIDATORS, MC_DATEPICKER_VALUE_ACCESSOR, McCalendar, McCalendarBody, McCalendarCell, McCalendarHeader, McDatepicker, McDatepickerContent, McDatepickerInput, McDatepickerInputEvent, McDatepickerIntl, McDatepickerModule, McDatepickerToggle, McDatepickerToggleIcon, McMonthView, mcDatepickerAnimations };
|
2698
2067
|
//# sourceMappingURL=ptsecurity-mosaic-datepicker.mjs.map
|