@ptsecurity/mosaic 15.9.3 → 15.9.5
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/datepicker/calendar-header.component.d.ts +13 -13
- package/datepicker/datepicker-input.directive.d.ts +10 -0
- package/esm2020/core/version.mjs +2 -2
- package/esm2020/datepicker/calendar-header.component.mjs +42 -13
- package/esm2020/datepicker/datepicker-input.directive.mjs +103 -23
- package/esm2020/input/input-number.mjs +196 -41
- package/fesm2015/ptsecurity-mosaic-core.mjs +1 -1
- package/fesm2015/ptsecurity-mosaic-core.mjs.map +1 -1
- package/fesm2015/ptsecurity-mosaic-datepicker.mjs +143 -34
- package/fesm2015/ptsecurity-mosaic-datepicker.mjs.map +1 -1
- package/fesm2015/ptsecurity-mosaic-input.mjs +198 -41
- package/fesm2015/ptsecurity-mosaic-input.mjs.map +1 -1
- package/fesm2020/ptsecurity-mosaic-core.mjs +1 -1
- package/fesm2020/ptsecurity-mosaic-core.mjs.map +1 -1
- package/fesm2020/ptsecurity-mosaic-datepicker.mjs +143 -34
- package/fesm2020/ptsecurity-mosaic-datepicker.mjs.map +1 -1
- package/fesm2020/ptsecurity-mosaic-input.mjs +195 -40
- package/fesm2020/ptsecurity-mosaic-input.mjs.map +1 -1
- package/input/input-number.d.ts +50 -10
- package/package.json +4 -4
@@ -123,8 +123,9 @@ class McCalendarHeader {
|
|
123
123
|
this.activeDateChange = new EventEmitter();
|
124
124
|
this.monthSelected = new EventEmitter();
|
125
125
|
this.yearSelected = new EventEmitter();
|
126
|
-
this.monthNames = this.adapter.getMonthNames('long')
|
127
|
-
|
126
|
+
this.monthNames = this.adapter.getMonthNames('long').map((name, i) => {
|
127
|
+
return { name, nameShort: this.adapter.getMonthNames('short')[i], value: i, disabled: false };
|
128
|
+
});
|
128
129
|
}
|
129
130
|
get activeDate() {
|
130
131
|
return this._activeDate;
|
@@ -132,6 +133,7 @@ class McCalendarHeader {
|
|
132
133
|
set activeDate(value) {
|
133
134
|
this._activeDate = value;
|
134
135
|
this.updateSelectedValues();
|
136
|
+
this.updateSelectionOptions();
|
135
137
|
}
|
136
138
|
get maxDate() {
|
137
139
|
return this._maxDate;
|
@@ -141,7 +143,7 @@ class McCalendarHeader {
|
|
141
143
|
return;
|
142
144
|
}
|
143
145
|
this._maxDate = value;
|
144
|
-
this.
|
146
|
+
this.updateYearsOptions();
|
145
147
|
}
|
146
148
|
get minDate() {
|
147
149
|
return this._minDate;
|
@@ -151,16 +153,20 @@ class McCalendarHeader {
|
|
151
153
|
return;
|
152
154
|
}
|
153
155
|
this._minDate = value;
|
154
|
-
this.
|
156
|
+
this.updateYearsOptions();
|
155
157
|
}
|
156
158
|
get previousDisabled() {
|
157
|
-
return this.compareDate(this.activeDate, this.minDate)
|
159
|
+
return this.compareDate(this.activeDate, this.minDate) <= 0;
|
160
|
+
}
|
161
|
+
get currentDisabled() {
|
162
|
+
const today = this.adapter.today();
|
163
|
+
return this.compareDate(today, this.minDate) < 0 || this.compareDate(today, this.maxDate) > 0;
|
158
164
|
}
|
159
165
|
get nextDisabled() {
|
160
166
|
return this.compareDate(this.activeDate, this.maxDate) >= 0;
|
161
167
|
}
|
162
168
|
ngAfterContentInit() {
|
163
|
-
this.
|
169
|
+
this.updateSelectionOptions();
|
164
170
|
this.updateSelectedValues();
|
165
171
|
}
|
166
172
|
/** Handles when a new month is selected. */
|
@@ -179,6 +185,7 @@ class McCalendarHeader {
|
|
179
185
|
this.activeDate = this.adapter.createDate(year, month, Math.min(this.adapter.getDate(this.activeDate), daysInMonth));
|
180
186
|
this.yearSelected.emit(this.activeDate);
|
181
187
|
this.activeDateChange.emit(this.activeDate);
|
188
|
+
this.updateMonthOptions();
|
182
189
|
}
|
183
190
|
selectCurrentDate() {
|
184
191
|
this.activeDate = this.adapter.today();
|
@@ -202,25 +209,47 @@ class McCalendarHeader {
|
|
202
209
|
updateSelectedValues() {
|
203
210
|
this.selectedMonth = this.monthNames[this.adapter.getMonth(this.activeDate)].value;
|
204
211
|
const year = this.adapter.getYear(this.activeDate);
|
205
|
-
this.selectedYear = this.years.find((
|
206
|
-
|
212
|
+
this.selectedYear = this.years.find((item) => item === year) || this.years[0];
|
213
|
+
}
|
214
|
+
updateSelectionOptions() {
|
215
|
+
this.updateYearsOptions();
|
216
|
+
this.updateMonthOptions();
|
207
217
|
}
|
208
|
-
|
218
|
+
updateYearsOptions() {
|
209
219
|
const minYear = this.adapter.getYear(this.minDate);
|
210
220
|
const maxYear = this.adapter.getYear(this.maxDate);
|
211
221
|
this.years = [];
|
212
222
|
for (let key = minYear; key <= maxYear; key++) {
|
213
|
-
this.years.push(
|
223
|
+
this.years.push(key);
|
224
|
+
}
|
225
|
+
}
|
226
|
+
updateMonthOptions() {
|
227
|
+
if (!this._activeDate) {
|
228
|
+
return;
|
229
|
+
}
|
230
|
+
const minYear = this.adapter.getYear(this.minDate);
|
231
|
+
const minMonth = this.adapter.getMonth(this.minDate);
|
232
|
+
const maxYear = this.adapter.getYear(this.maxDate);
|
233
|
+
const maxMonth = this.adapter.getMonth(this.maxDate);
|
234
|
+
const currentYear = this.adapter.getYear(this._activeDate);
|
235
|
+
if (currentYear === minYear && currentYear === maxYear) {
|
236
|
+
this.monthNames.forEach((month) => (month.disabled = month.value < minMonth || month.value > maxMonth));
|
237
|
+
}
|
238
|
+
else if (currentYear === minYear) {
|
239
|
+
this.monthNames.forEach((month) => (month.disabled = month.value < minMonth));
|
240
|
+
}
|
241
|
+
else if (currentYear === maxYear) {
|
242
|
+
this.monthNames.forEach((month) => (month.disabled = month.value > maxMonth));
|
214
243
|
}
|
215
244
|
}
|
216
245
|
}
|
217
246
|
/** @nocollapse */ McCalendarHeader.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: McCalendarHeader, deps: [{ token: i1$1.DateAdapter }], target: i0.ɵɵFactoryTarget.Component });
|
218
|
-
/** @nocollapse */ McCalendarHeader.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.9", 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
|
247
|
+
/** @nocollapse */ McCalendarHeader.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.9", 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 [disabled]=\"month.disabled\"\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 {{ selectedYear }}\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 [disabled]=\"currentDisabled\"\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: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:var(--mc-datepicker-calendar-size-icon-border-width, 2px);transform:var(--mc-datepicker-calendar-size-icon-prev-icon-transform, translateX(2px) rotate(-45deg))}.mc-calendar-header__next-button:after{border-right-width:var(--mc-datepicker-calendar-size-icon-border-width, 2px);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;overflow-x:hidden;scrollbar-gutter:stable}.mc-calendar-select-panel .mc-select__content .mc-option{min-width:65px}\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], textarea[mcTextarea], mc-select, mc-tree-select, mc-tag-list ", 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: i1$1.McOption, selector: "mc-option", inputs: ["value", "showCheckbox", "disabled"], outputs: ["onSelectionChange"], exportAs: ["mcOption"] }, { kind: "component", type: i6.McIcon, selector: "[mc-icon]", inputs: ["color"] }, { kind: "directive", type: i6.McIconCSSStyler, selector: "[mc-icon]" }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
219
248
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: McCalendarHeader, decorators: [{
|
220
249
|
type: Component,
|
221
250
|
args: [{ selector: 'mc-calendar-header', exportAs: 'mcCalendarHeader', host: {
|
222
251
|
class: 'mc-calendar-header'
|
223
|
-
}, 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
|
252
|
+
}, 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 [disabled]=\"month.disabled\"\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 {{ selectedYear }}\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 [disabled]=\"currentDisabled\"\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: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:var(--mc-datepicker-calendar-size-icon-border-width, 2px);transform:var(--mc-datepicker-calendar-size-icon-prev-icon-transform, translateX(2px) rotate(-45deg))}.mc-calendar-header__next-button:after{border-right-width:var(--mc-datepicker-calendar-size-icon-border-width, 2px);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;overflow-x:hidden;scrollbar-gutter:stable}.mc-calendar-select-panel .mc-select__content .mc-option{min-width:65px}\n"] }]
|
224
253
|
}], ctorParameters: function () { return [{ type: i1$1.DateAdapter }]; }, propDecorators: { activeDate: [{
|
225
254
|
type: Input
|
226
255
|
}], maxDate: [{
|
@@ -1651,22 +1680,86 @@ class McDatepickerInput {
|
|
1651
1680
|
}
|
1652
1681
|
return [this.thirdDigit.value, this.thirdDigit.start, this.thirdDigit.end];
|
1653
1682
|
}
|
1654
|
-
|
1655
|
-
|
1656
|
-
|
1657
|
-
|
1683
|
+
isMaxMonth(date) {
|
1684
|
+
return this.adapter.getMonth(date) === this.getMaxMonth(date);
|
1685
|
+
}
|
1686
|
+
isMinMonth(date) {
|
1687
|
+
return this.adapter.getMonth(date) === this.getMinMonth(date);
|
1688
|
+
}
|
1689
|
+
isMaxYear(date) {
|
1690
|
+
return this.adapter.getYear(date) === this.getMaxYear();
|
1691
|
+
}
|
1692
|
+
isMinYear(date) {
|
1693
|
+
return this.adapter.getYear(date) === this.getMinYear();
|
1694
|
+
}
|
1695
|
+
getMaxDate(date) {
|
1696
|
+
if (this.datepicker.maxDate && this.isMaxYear(date) && this.isMaxMonth(date)) {
|
1697
|
+
return this.adapter.getDate(this.datepicker.maxDate);
|
1698
|
+
}
|
1699
|
+
return this.adapter.getNumDaysInMonth(date);
|
1700
|
+
}
|
1701
|
+
getMinDate(date) {
|
1702
|
+
if (this.datepicker.minDate && this.isMinYear(date) && this.isMinMonth(date)) {
|
1703
|
+
return this.adapter.getDate(this.datepicker.minDate);
|
1704
|
+
}
|
1705
|
+
return 1;
|
1706
|
+
}
|
1707
|
+
getMaxMonth(date) {
|
1708
|
+
if (this.datepicker.maxDate && this.isMaxYear(date)) {
|
1709
|
+
return this.adapter.getMonth(this.datepicker.maxDate);
|
1710
|
+
}
|
1711
|
+
// tslint:disable-next-line:no-magic-numbers
|
1712
|
+
return 11;
|
1713
|
+
}
|
1714
|
+
getMinMonth(date) {
|
1715
|
+
if (this.datepicker.minDate && this.isMinYear(date)) {
|
1716
|
+
return this.adapter.getMonth(this.datepicker.minDate);
|
1717
|
+
}
|
1718
|
+
return 0;
|
1719
|
+
}
|
1720
|
+
getMaxYear() {
|
1721
|
+
if (this.datepicker.maxDate) {
|
1722
|
+
return this.adapter.getYear(this.datepicker.maxDate);
|
1723
|
+
}
|
1724
|
+
return MAX_YEAR;
|
1725
|
+
}
|
1726
|
+
getMinYear() {
|
1727
|
+
if (this.datepicker.minDate) {
|
1728
|
+
return this.adapter.getYear(this.datepicker.minDate);
|
1729
|
+
}
|
1730
|
+
return 1;
|
1731
|
+
}
|
1732
|
+
incrementDate(date, whatToIncrement) {
|
1733
|
+
let year = this.adapter.getYear(date);
|
1734
|
+
let month = this.adapter.getMonth(date);
|
1735
|
+
let day = this.adapter.getDate(date);
|
1658
1736
|
switch (whatToIncrement) {
|
1659
1737
|
case DateParts.day:
|
1660
1738
|
day++;
|
1661
|
-
if (day > this.
|
1662
|
-
|
1739
|
+
if (day > this.getMaxDate(date)) {
|
1740
|
+
if (this.isMaxYear(date) && this.isMaxMonth(date)) {
|
1741
|
+
day = this.getMaxDate(date);
|
1742
|
+
}
|
1743
|
+
else if (this.isMinYear(date) && this.isMinMonth(date)) {
|
1744
|
+
day = this.getMinDate(date);
|
1745
|
+
}
|
1746
|
+
else {
|
1747
|
+
day = 1;
|
1748
|
+
}
|
1663
1749
|
}
|
1664
1750
|
break;
|
1665
1751
|
case DateParts.month:
|
1666
1752
|
month++;
|
1667
|
-
|
1668
|
-
|
1669
|
-
|
1753
|
+
if (month > this.getMaxMonth(date)) {
|
1754
|
+
if (this.isMaxYear(date)) {
|
1755
|
+
month = this.getMaxMonth(date);
|
1756
|
+
}
|
1757
|
+
else if (this.isMinYear(date)) {
|
1758
|
+
month = this.getMinMonth(date);
|
1759
|
+
}
|
1760
|
+
else {
|
1761
|
+
month = 0;
|
1762
|
+
}
|
1670
1763
|
}
|
1671
1764
|
const lastDay = this.getLastDayFor(year, month);
|
1672
1765
|
if (day > lastDay) {
|
@@ -1675,8 +1768,8 @@ class McDatepickerInput {
|
|
1675
1768
|
break;
|
1676
1769
|
case DateParts.year:
|
1677
1770
|
year++;
|
1678
|
-
if (year >
|
1679
|
-
year =
|
1771
|
+
if (year > this.getMaxYear()) {
|
1772
|
+
year = this.getMaxYear();
|
1680
1773
|
}
|
1681
1774
|
break;
|
1682
1775
|
default:
|
@@ -1686,22 +1779,38 @@ class McDatepickerInput {
|
|
1686
1779
|
getLastDayFor(year, month) {
|
1687
1780
|
return this.adapter.getNumDaysInMonth(this.createDate(year, month, 1));
|
1688
1781
|
}
|
1689
|
-
decrementDate(
|
1690
|
-
let year = this.adapter.getYear(
|
1691
|
-
let month = this.adapter.getMonth(
|
1692
|
-
let day = this.adapter.getDate(
|
1782
|
+
decrementDate(date, whatToDecrement) {
|
1783
|
+
let year = this.adapter.getYear(date);
|
1784
|
+
let month = this.adapter.getMonth(date);
|
1785
|
+
let day = this.adapter.getDate(date);
|
1693
1786
|
switch (whatToDecrement) {
|
1694
1787
|
case DateParts.day:
|
1695
1788
|
day--;
|
1696
|
-
if (day <
|
1697
|
-
|
1789
|
+
if (day < this.getMinDate(date)) {
|
1790
|
+
if (this.isMinYear(date) && this.isMinMonth(date)) {
|
1791
|
+
day = this.getMinDate(date);
|
1792
|
+
}
|
1793
|
+
else if (this.isMaxYear(date) && this.isMaxMonth(date)) {
|
1794
|
+
day = this.getMaxDate(date);
|
1795
|
+
}
|
1796
|
+
else {
|
1797
|
+
day = this.adapter.getNumDaysInMonth(date);
|
1798
|
+
}
|
1698
1799
|
}
|
1699
1800
|
break;
|
1700
1801
|
case DateParts.month:
|
1701
1802
|
month--;
|
1702
|
-
if (month <
|
1703
|
-
|
1704
|
-
|
1803
|
+
if (month < this.getMinMonth(date)) {
|
1804
|
+
if (year === this.getMinYear()) {
|
1805
|
+
month = this.getMinMonth(date);
|
1806
|
+
}
|
1807
|
+
else if (this.isMaxYear(date)) {
|
1808
|
+
month = this.getMaxMonth(date);
|
1809
|
+
}
|
1810
|
+
else {
|
1811
|
+
// tslint:disable-next-line:no-magic-numbers
|
1812
|
+
month = 11;
|
1813
|
+
}
|
1705
1814
|
}
|
1706
1815
|
const lastDay = this.getLastDayFor(year, month);
|
1707
1816
|
if (day > lastDay) {
|
@@ -1710,8 +1819,8 @@ class McDatepickerInput {
|
|
1710
1819
|
break;
|
1711
1820
|
case DateParts.year:
|
1712
1821
|
year--;
|
1713
|
-
if (year <
|
1714
|
-
year =
|
1822
|
+
if (year < this.getMinYear()) {
|
1823
|
+
year = this.getMinYear();
|
1715
1824
|
}
|
1716
1825
|
break;
|
1717
1826
|
default:
|