@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
@@ -122,8 +122,9 @@ class McCalendarHeader {
|
|
122
122
|
this.activeDateChange = new EventEmitter();
|
123
123
|
this.monthSelected = new EventEmitter();
|
124
124
|
this.yearSelected = new EventEmitter();
|
125
|
-
this.monthNames = this.adapter.getMonthNames('long')
|
126
|
-
|
125
|
+
this.monthNames = this.adapter.getMonthNames('long').map((name, i) => {
|
126
|
+
return { name, nameShort: this.adapter.getMonthNames('short')[i], value: i, disabled: false };
|
127
|
+
});
|
127
128
|
}
|
128
129
|
get activeDate() {
|
129
130
|
return this._activeDate;
|
@@ -131,6 +132,7 @@ class McCalendarHeader {
|
|
131
132
|
set activeDate(value) {
|
132
133
|
this._activeDate = value;
|
133
134
|
this.updateSelectedValues();
|
135
|
+
this.updateSelectionOptions();
|
134
136
|
}
|
135
137
|
get maxDate() {
|
136
138
|
return this._maxDate;
|
@@ -140,7 +142,7 @@ class McCalendarHeader {
|
|
140
142
|
return;
|
141
143
|
}
|
142
144
|
this._maxDate = value;
|
143
|
-
this.
|
145
|
+
this.updateYearsOptions();
|
144
146
|
}
|
145
147
|
get minDate() {
|
146
148
|
return this._minDate;
|
@@ -150,16 +152,20 @@ class McCalendarHeader {
|
|
150
152
|
return;
|
151
153
|
}
|
152
154
|
this._minDate = value;
|
153
|
-
this.
|
155
|
+
this.updateYearsOptions();
|
154
156
|
}
|
155
157
|
get previousDisabled() {
|
156
|
-
return this.compareDate(this.activeDate, this.minDate)
|
158
|
+
return this.compareDate(this.activeDate, this.minDate) <= 0;
|
159
|
+
}
|
160
|
+
get currentDisabled() {
|
161
|
+
const today = this.adapter.today();
|
162
|
+
return this.compareDate(today, this.minDate) < 0 || this.compareDate(today, this.maxDate) > 0;
|
157
163
|
}
|
158
164
|
get nextDisabled() {
|
159
165
|
return this.compareDate(this.activeDate, this.maxDate) >= 0;
|
160
166
|
}
|
161
167
|
ngAfterContentInit() {
|
162
|
-
this.
|
168
|
+
this.updateSelectionOptions();
|
163
169
|
this.updateSelectedValues();
|
164
170
|
}
|
165
171
|
/** Handles when a new month is selected. */
|
@@ -178,6 +184,7 @@ class McCalendarHeader {
|
|
178
184
|
this.activeDate = this.adapter.createDate(year, month, Math.min(this.adapter.getDate(this.activeDate), daysInMonth));
|
179
185
|
this.yearSelected.emit(this.activeDate);
|
180
186
|
this.activeDateChange.emit(this.activeDate);
|
187
|
+
this.updateMonthOptions();
|
181
188
|
}
|
182
189
|
selectCurrentDate() {
|
183
190
|
this.activeDate = this.adapter.today();
|
@@ -201,25 +208,47 @@ class McCalendarHeader {
|
|
201
208
|
updateSelectedValues() {
|
202
209
|
this.selectedMonth = this.monthNames[this.adapter.getMonth(this.activeDate)].value;
|
203
210
|
const year = this.adapter.getYear(this.activeDate);
|
204
|
-
this.selectedYear = this.years.find((
|
205
|
-
|
211
|
+
this.selectedYear = this.years.find((item) => item === year) || this.years[0];
|
212
|
+
}
|
213
|
+
updateSelectionOptions() {
|
214
|
+
this.updateYearsOptions();
|
215
|
+
this.updateMonthOptions();
|
206
216
|
}
|
207
|
-
|
217
|
+
updateYearsOptions() {
|
208
218
|
const minYear = this.adapter.getYear(this.minDate);
|
209
219
|
const maxYear = this.adapter.getYear(this.maxDate);
|
210
220
|
this.years = [];
|
211
221
|
for (let key = minYear; key <= maxYear; key++) {
|
212
|
-
this.years.push(
|
222
|
+
this.years.push(key);
|
223
|
+
}
|
224
|
+
}
|
225
|
+
updateMonthOptions() {
|
226
|
+
if (!this._activeDate) {
|
227
|
+
return;
|
228
|
+
}
|
229
|
+
const minYear = this.adapter.getYear(this.minDate);
|
230
|
+
const minMonth = this.adapter.getMonth(this.minDate);
|
231
|
+
const maxYear = this.adapter.getYear(this.maxDate);
|
232
|
+
const maxMonth = this.adapter.getMonth(this.maxDate);
|
233
|
+
const currentYear = this.adapter.getYear(this._activeDate);
|
234
|
+
if (currentYear === minYear && currentYear === maxYear) {
|
235
|
+
this.monthNames.forEach((month) => (month.disabled = month.value < minMonth || month.value > maxMonth));
|
236
|
+
}
|
237
|
+
else if (currentYear === minYear) {
|
238
|
+
this.monthNames.forEach((month) => (month.disabled = month.value < minMonth));
|
239
|
+
}
|
240
|
+
else if (currentYear === maxYear) {
|
241
|
+
this.monthNames.forEach((month) => (month.disabled = month.value > maxMonth));
|
213
242
|
}
|
214
243
|
}
|
215
244
|
}
|
216
245
|
/** @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 });
|
217
|
-
/** @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
|
246
|
+
/** @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 });
|
218
247
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: McCalendarHeader, decorators: [{
|
219
248
|
type: Component,
|
220
249
|
args: [{ selector: 'mc-calendar-header', exportAs: 'mcCalendarHeader', host: {
|
221
250
|
class: 'mc-calendar-header'
|
222
|
-
}, 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
|
251
|
+
}, 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"] }]
|
223
252
|
}], ctorParameters: function () { return [{ type: i1$1.DateAdapter }]; }, propDecorators: { activeDate: [{
|
224
253
|
type: Input
|
225
254
|
}], maxDate: [{
|
@@ -1253,22 +1282,86 @@ class McDatepickerInput {
|
|
1253
1282
|
}
|
1254
1283
|
return [this.thirdDigit.value, this.thirdDigit.start, this.thirdDigit.end];
|
1255
1284
|
}
|
1256
|
-
|
1257
|
-
|
1258
|
-
|
1259
|
-
|
1285
|
+
isMaxMonth(date) {
|
1286
|
+
return this.adapter.getMonth(date) === this.getMaxMonth(date);
|
1287
|
+
}
|
1288
|
+
isMinMonth(date) {
|
1289
|
+
return this.adapter.getMonth(date) === this.getMinMonth(date);
|
1290
|
+
}
|
1291
|
+
isMaxYear(date) {
|
1292
|
+
return this.adapter.getYear(date) === this.getMaxYear();
|
1293
|
+
}
|
1294
|
+
isMinYear(date) {
|
1295
|
+
return this.adapter.getYear(date) === this.getMinYear();
|
1296
|
+
}
|
1297
|
+
getMaxDate(date) {
|
1298
|
+
if (this.datepicker.maxDate && this.isMaxYear(date) && this.isMaxMonth(date)) {
|
1299
|
+
return this.adapter.getDate(this.datepicker.maxDate);
|
1300
|
+
}
|
1301
|
+
return this.adapter.getNumDaysInMonth(date);
|
1302
|
+
}
|
1303
|
+
getMinDate(date) {
|
1304
|
+
if (this.datepicker.minDate && this.isMinYear(date) && this.isMinMonth(date)) {
|
1305
|
+
return this.adapter.getDate(this.datepicker.minDate);
|
1306
|
+
}
|
1307
|
+
return 1;
|
1308
|
+
}
|
1309
|
+
getMaxMonth(date) {
|
1310
|
+
if (this.datepicker.maxDate && this.isMaxYear(date)) {
|
1311
|
+
return this.adapter.getMonth(this.datepicker.maxDate);
|
1312
|
+
}
|
1313
|
+
// tslint:disable-next-line:no-magic-numbers
|
1314
|
+
return 11;
|
1315
|
+
}
|
1316
|
+
getMinMonth(date) {
|
1317
|
+
if (this.datepicker.minDate && this.isMinYear(date)) {
|
1318
|
+
return this.adapter.getMonth(this.datepicker.minDate);
|
1319
|
+
}
|
1320
|
+
return 0;
|
1321
|
+
}
|
1322
|
+
getMaxYear() {
|
1323
|
+
if (this.datepicker.maxDate) {
|
1324
|
+
return this.adapter.getYear(this.datepicker.maxDate);
|
1325
|
+
}
|
1326
|
+
return MAX_YEAR;
|
1327
|
+
}
|
1328
|
+
getMinYear() {
|
1329
|
+
if (this.datepicker.minDate) {
|
1330
|
+
return this.adapter.getYear(this.datepicker.minDate);
|
1331
|
+
}
|
1332
|
+
return 1;
|
1333
|
+
}
|
1334
|
+
incrementDate(date, whatToIncrement) {
|
1335
|
+
let year = this.adapter.getYear(date);
|
1336
|
+
let month = this.adapter.getMonth(date);
|
1337
|
+
let day = this.adapter.getDate(date);
|
1260
1338
|
switch (whatToIncrement) {
|
1261
1339
|
case DateParts.day:
|
1262
1340
|
day++;
|
1263
|
-
if (day > this.
|
1264
|
-
|
1341
|
+
if (day > this.getMaxDate(date)) {
|
1342
|
+
if (this.isMaxYear(date) && this.isMaxMonth(date)) {
|
1343
|
+
day = this.getMaxDate(date);
|
1344
|
+
}
|
1345
|
+
else if (this.isMinYear(date) && this.isMinMonth(date)) {
|
1346
|
+
day = this.getMinDate(date);
|
1347
|
+
}
|
1348
|
+
else {
|
1349
|
+
day = 1;
|
1350
|
+
}
|
1265
1351
|
}
|
1266
1352
|
break;
|
1267
1353
|
case DateParts.month:
|
1268
1354
|
month++;
|
1269
|
-
|
1270
|
-
|
1271
|
-
|
1355
|
+
if (month > this.getMaxMonth(date)) {
|
1356
|
+
if (this.isMaxYear(date)) {
|
1357
|
+
month = this.getMaxMonth(date);
|
1358
|
+
}
|
1359
|
+
else if (this.isMinYear(date)) {
|
1360
|
+
month = this.getMinMonth(date);
|
1361
|
+
}
|
1362
|
+
else {
|
1363
|
+
month = 0;
|
1364
|
+
}
|
1272
1365
|
}
|
1273
1366
|
const lastDay = this.getLastDayFor(year, month);
|
1274
1367
|
if (day > lastDay) {
|
@@ -1277,8 +1370,8 @@ class McDatepickerInput {
|
|
1277
1370
|
break;
|
1278
1371
|
case DateParts.year:
|
1279
1372
|
year++;
|
1280
|
-
if (year >
|
1281
|
-
year =
|
1373
|
+
if (year > this.getMaxYear()) {
|
1374
|
+
year = this.getMaxYear();
|
1282
1375
|
}
|
1283
1376
|
break;
|
1284
1377
|
default:
|
@@ -1288,22 +1381,38 @@ class McDatepickerInput {
|
|
1288
1381
|
getLastDayFor(year, month) {
|
1289
1382
|
return this.adapter.getNumDaysInMonth(this.createDate(year, month, 1));
|
1290
1383
|
}
|
1291
|
-
decrementDate(
|
1292
|
-
let year = this.adapter.getYear(
|
1293
|
-
let month = this.adapter.getMonth(
|
1294
|
-
let day = this.adapter.getDate(
|
1384
|
+
decrementDate(date, whatToDecrement) {
|
1385
|
+
let year = this.adapter.getYear(date);
|
1386
|
+
let month = this.adapter.getMonth(date);
|
1387
|
+
let day = this.adapter.getDate(date);
|
1295
1388
|
switch (whatToDecrement) {
|
1296
1389
|
case DateParts.day:
|
1297
1390
|
day--;
|
1298
|
-
if (day <
|
1299
|
-
|
1391
|
+
if (day < this.getMinDate(date)) {
|
1392
|
+
if (this.isMinYear(date) && this.isMinMonth(date)) {
|
1393
|
+
day = this.getMinDate(date);
|
1394
|
+
}
|
1395
|
+
else if (this.isMaxYear(date) && this.isMaxMonth(date)) {
|
1396
|
+
day = this.getMaxDate(date);
|
1397
|
+
}
|
1398
|
+
else {
|
1399
|
+
day = this.adapter.getNumDaysInMonth(date);
|
1400
|
+
}
|
1300
1401
|
}
|
1301
1402
|
break;
|
1302
1403
|
case DateParts.month:
|
1303
1404
|
month--;
|
1304
|
-
if (month <
|
1305
|
-
|
1306
|
-
|
1405
|
+
if (month < this.getMinMonth(date)) {
|
1406
|
+
if (year === this.getMinYear()) {
|
1407
|
+
month = this.getMinMonth(date);
|
1408
|
+
}
|
1409
|
+
else if (this.isMaxYear(date)) {
|
1410
|
+
month = this.getMaxMonth(date);
|
1411
|
+
}
|
1412
|
+
else {
|
1413
|
+
// tslint:disable-next-line:no-magic-numbers
|
1414
|
+
month = 11;
|
1415
|
+
}
|
1307
1416
|
}
|
1308
1417
|
const lastDay = this.getLastDayFor(year, month);
|
1309
1418
|
if (day > lastDay) {
|
@@ -1312,8 +1421,8 @@ class McDatepickerInput {
|
|
1312
1421
|
break;
|
1313
1422
|
case DateParts.year:
|
1314
1423
|
year--;
|
1315
|
-
if (year <
|
1316
|
-
year =
|
1424
|
+
if (year < this.getMinYear()) {
|
1425
|
+
year = this.getMinYear();
|
1317
1426
|
}
|
1318
1427
|
break;
|
1319
1428
|
default:
|