UNPKG

ng-zorro-antd-mobile

Version:

An enterprise-class mobile UI components based on Ant Design and Angular

1,164 lines 125 kB
/** * @fileoverview added by tsickle * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ import { Component, ElementRef, ViewEncapsulation, HostListener, ViewChild, ViewContainerRef } from '@angular/core'; import { Subject } from 'rxjs'; import { takeUntil } from 'rxjs/operators'; import { LocaleProviderService } from '../locale-provider/locale-provider.service'; import { DatePickerOptions } from './date-picker-options.provider'; import { ToastService } from '../toast/toast.service'; import * as velocity from '../core/util/velocity'; var DatePickerComponent = /** @class */ (function () { function DatePickerComponent(elementRef, options, toast, localeProviderService) { this.elementRef = elementRef; this.options = options; this.toast = toast; this.localeProviderService = localeProviderService; this.transitionName = 'am-slide-up-enter am-slide-up-enter-active'; this.maskTransitionName = 'am-fade-enter am-fade-enter-active'; this.modeSwitch = [1, 1, 1, 1, 1, 1]; this.localMinDate = []; this.localMaxDate = []; this.currentTime = []; this.indexArray = []; this.min_date = []; this.max_date = []; this.current_time = [ new Date().getFullYear(), new Date().getMonth() + 1, new Date().getDate(), new Date().getHours(), new Date().getMinutes() ]; this.clos = 0; this.resultArr = []; this.data = []; this.dataWithStr = []; this.startY = 0; this.differY = 0; this.currentY = 0; this.len = 0; this.dom = null; this.index = 0; this.maxY = 0; this.lineHeight = 34; this.selectedTarget = []; this.isMouseDown = false; this.localeNew = {}; this.unsubscribe$ = new Subject(); this.Velocity = velocity.getVelocity(); this.errorMessage = ''; this.curTLessThanMin = false; this.curTMoreThanMax = false; } /** * @param {?} event * @return {?} */ DatePickerComponent.prototype.panstart = /** * @param {?} event * @return {?} */ function (event) { var _this = this; if (!event.target.classList.contains('am-picker-col-mask')) { return; } this.isMouseDown = true; event.preventDefault(); this.dom = event.target.parentElement.children[2]; this.len = this.dom.children.length; this.maxY = -(this.len - 1); if (this.dom.style.transform === 'translateY(0px)') { this.currentY = 0; this.maxY = -(this.len - 1); } else if (this.selectedTarget.length > 0) { this.selectedTarget.forEach((/** * @param {?} item * @return {?} */ function (item) { if (item.targetId === event.target.id) { _this.currentY = item.currentY; } })); } /** @type {?} */ var ev = this.getEventTarget(event); this.startY = ev.clientY; }; /** * @param {?} event * @return {?} */ DatePickerComponent.prototype.panmove = /** * @param {?} event * @return {?} */ function (event) { if (!event.target.classList.contains('am-picker-col-mask') || !this.isMouseDown) { return; } event.preventDefault(); /** @type {?} */ var ev = this.getEventTarget(event); this.differY = ev.clientY - this.startY; this.Velocity.record(this.differY); this.dom.style.transition = 'transform 0s'; this.dom.style.transform = "translateY(" + (this.currentY * this.lineHeight + this.differY) + "px)"; }; /** * @param {?} event * @return {?} */ DatePickerComponent.prototype.panend = /** * @param {?} event * @return {?} */ function (event) { var _this = this; if (!event.target.classList.contains('am-picker-col-mask') || !this.isMouseDown) { return; } this.isMouseDown = false; event.preventDefault(); /** @type {?} */ var ev = this.getEventTarget(event); this.differY = ev.clientY - this.startY; /** @type {?} */ var time = 0.3; /** @type {?} */ var velocityTemp = this.Velocity.getVelocity(this.differY) * 4; if (velocityTemp) { this.differY = velocityTemp * 40 + this.differY; time = Math.abs(velocityTemp) * 0.1; } this.dom.style.transition = 'transform ' + (time < 0.3 ? 0.3 : time) + 's'; if (this.differY <= -this.lineHeight / 2) { this.currentY += Math.floor(this.differY / this.lineHeight); if (this.currentY <= this.maxY) { this.currentY = this.maxY; } } else if (this.differY >= this.lineHeight / 2) { this.currentY += Math.floor(this.differY / this.lineHeight); if (this.currentY >= 0) { this.currentY = 0; } } if (this.selectedTarget.length > 0) { /** @type {?} */ var hasKey_1 = false; this.selectedTarget.forEach((/** * @param {?} item * @return {?} */ function (item) { if (item.targetId === event.target.id) { hasKey_1 = true; item.targetId = event.target.id; item.currentY = _this.currentY; } })); if (!hasKey_1) { this.selectedTarget.push({ targetId: event.target.id, currentY: this.currentY }); } } else { this.selectedTarget.push({ targetId: event.target.id, currentY: this.currentY }); } this.dom.style.transform = "translateY(" + this.currentY * this.lineHeight + "px)"; this.index = Math.floor(Math.abs(this.currentY / 1)); // 记录当前位移在数组中的索引,必须取整,否则会出现浮点数 this.current_time[this.indexArray[parseInt(event.target.id, 0)]] = this.resultArr[this.indexArray[parseInt(event.target.id, 0)]] = this.data[parseInt(event.target.id, 0)][this.index]; if (this.judgeTime(this.current_time, this.max_date)) { this.currentTime = this.current_time = this.max_date.slice(0, this.indexArray.length); this.resultArr = this.current_time; this.options.onValueChange.emit({ date: this.handleReslut(), index: event.target.id }); if (this.options.updateNgModel) { this.options.updateNgModel(this.handleReslut()); } if (this.ngModelOnChange) { this.ngModelOnChange(this.handleReslut()); } this.init(); } else if (this.judgeTime(this.min_date, this.current_time)) { this.currentTime = this.current_time = this.min_date.slice(0, this.indexArray.length); this.resultArr = this.currentTime; this.options.onValueChange.emit({ date: this.handleReslut(), index: event.target.id }); if (this.options.updateNgModel) { this.options.updateNgModel(this.handleReslut()); } if (this.ngModelOnChange) { this.ngModelOnChange(this.handleReslut()); } this.init(); } else { this.setCurrentSelected(0, this.differY < 0, this.index); this.options.onValueChange.emit({ date: this.handleReslut(), index: event.target.id }); if (this.options.updateNgModel) { this.options.updateNgModel(this.handleReslut()); } if (this.ngModelOnChange) { this.ngModelOnChange(this.handleReslut()); } } }; /** * @return {?} */ DatePickerComponent.prototype.init = /** * @return {?} */ function () { var _this = this; if (!this.checkTime() && this.options.showErrorToast) { setTimeout((/** * @return {?} */ function () { _this.toast.fail(_this.errorMessage, _this.options.showErrorToastInterval); }), 0); } this.initResult(); this.initReady(); this.getInitValueIndex(); }; /** * @return {?} */ DatePickerComponent.prototype.reloadPicker = /** * @return {?} */ function () { if (!this.picker || this.picker === undefined) { return; } this.currentPicker = this.picker.element.nativeElement; if (this.currentPicker && this.currentPicker.children.length > 0) { /** @type {?} */ var self_1 = this; setTimeout((/** * @return {?} */ function () { self_1.selectedTarget.forEach((/** * @param {?} item * @param {?} i * @return {?} */ function (item, i) { self_1.currentPicker.children[i].children[2].style.transition = 'transform .3s'; /** @type {?} */ var index = parseInt(item.currentY, 0); self_1.currentPicker.children[i].children[2].style.transform = "translateY(" + index * self_1.lineHeight + "px)"; })); }), 0); } }; /** * @return {?} */ DatePickerComponent.prototype.localeProvider = /** * @return {?} */ function () { /** @type {?} */ var self = this; if (self.options.locale || self.options.locale !== undefined) { self.localeProviderService.setLocale(self.options.locale); } self.localeProviderService.localeChange.pipe(takeUntil(self.unsubscribe$)).subscribe((/** * @param {?} _ * @return {?} */ function (_) { self.options.locale = self.localeProviderService.getLocale(); self.localeNew = self.localeProviderService.getLocaleSubObj('DatePicker'); self.options.okText = self.localeNew.okText; self.options.dismissText = self.localeNew.dismissText; self.init(); })); }; /** * @param {?} date * @return {?} */ DatePickerComponent.prototype.transformDateFormat = /** * @param {?} date * @return {?} */ function (date) { if (!date) { return ''; } else { return 'yyyy-mm-dd-HH-MM' .replace('yyyy', date.getFullYear() + '') .replace('mm', date.getMonth() + 1 + '') .replace('dd', date.getDate() + '') .replace('HH', date.getHours() + '') .replace('MM', date.getMinutes() + ''); } }; /** * @param {?} val * @return {?} */ DatePickerComponent.prototype.preZero = /** * @param {?} val * @return {?} */ function (val) { return val < 10 ? '0' + val : val + ''; }; /** * @return {?} */ DatePickerComponent.prototype.getInitValueIndex = /** * @return {?} */ function () { var _this = this; this.selectedTarget = []; this.indexArray.map((/** * @param {?} index * @param {?} i * @return {?} */ function (index, i) { _this.data.forEach((/** * @param {?} item * @param {?} j * @return {?} */ function (item, j) { item.forEach((/** * @param {?} item1 * @param {?} k * @return {?} */ function (item1, k) { if (_this.currentTime[index] === item1 && i === j) { _this.selectedTarget.push({ targetId: "" + i, currentY: -k }); } })); })); })); this.reloadPicker(); }; /** * @param {?} mode * @return {?} */ DatePickerComponent.prototype.checkMode = /** * @param {?} mode * @return {?} */ function (mode) { this.modeSwitch = [1, 1, 1, 1, 1, 1]; switch (mode) { case 'date': this.modeSwitch = [1, 1, 1, 0, 0, 0]; break; case 'time': if (this.options.use12Hours) { this.modeSwitch = [0, 0, 0, 1, 1, 1]; } else { this.modeSwitch = [0, 0, 0, 1, 1, 0]; } break; case 'datetime': if (this.options.use12Hours) { this.modeSwitch = [1, 1, 1, 1, 1, 1]; } else { this.modeSwitch = [1, 1, 1, 1, 1, 0]; } break; case 'year': this.modeSwitch = [1, 0, 0, 0, 0]; break; case 'month': this.modeSwitch = [1, 1, 0, 0, 0]; break; default: break; } /** @type {?} */ var tempIndexArray = []; for (var i = 0; i < this.modeSwitch.length; i++) { if (this.modeSwitch[i] > 0) { tempIndexArray.push(i); } } this.clos = tempIndexArray[tempIndexArray.length - 1] - tempIndexArray[0] + 1; this.indexArray = tempIndexArray; }; /** * @return {?} */ DatePickerComponent.prototype.initResult = /** * @return {?} */ function () { this.resultArr = []; for (var i = 0; i < this.clos; i++) { /** @type {?} */ var res = this.currentTime[i]; if (this.options.mode === 'time') { this.resultArr = this.currentTime; } else { this.resultArr.push(res); } } }; /** * @return {?} */ DatePickerComponent.prototype.checkTime = /** * @return {?} */ function () { /** @type {?} */ var min_Date = this.transformDateFormat(this.options.minDate).split('-'); if (min_Date.length > 0) { this.min_date = min_Date.map((/** * @param {?} item * @return {?} */ function (item) { return parseInt(item, 0); })); } /** @type {?} */ var max_Date = this.transformDateFormat(this.options.maxDate).split('-'); if (max_Date.length > 0) { this.max_date = max_Date.map((/** * @param {?} item * @return {?} */ function (item) { return parseInt(item, 0); })); } /** @type {?} */ var min_date = this.min_date; /** @type {?} */ var max_date = this.max_date; /** @type {?} */ var current_time = this.currentTime; this.localMinDate = []; if (this.localMinDate.length === 0) { for (var index = 0; index < this.indexArray.length; index++) { this.localMinDate.push(min_date[this.indexArray[index]]); } } this.localMaxDate = []; if (this.localMaxDate.length === 0) { for (var index = 0; index < this.indexArray.length; index++) { this.localMaxDate.push(max_date[this.indexArray[index]]); } } if (this.indexArray.length === this.localMinDate.length && this.localMinDate.length === this.localMaxDate.length) { /** @type {?} */ var minT = new Date(min_date[0], min_date[1], min_date[2], min_date[3], min_date[4]).getTime(); /** @type {?} */ var maxT = new Date(max_date[0], max_date[1], max_date[2], max_date[3], max_date[4]).getTime(); /** @type {?} */ var curT = new Date(current_time[0], current_time[1], current_time[2], current_time[3] || 0, current_time[4] || 0).getTime(); this.curTLessThanMin = false; this.curTMoreThanMax = false; if (curT < minT) { this.curTLessThanMin = true; this.currentTime = this.min_date; this.errorMessage = this.localeNew.curTLessthanMin; } if (curT > maxT) { this.curTMoreThanMax = true; this.currentTime = this.max_date; this.errorMessage = this.localeNew.curTMorethanMax; } /** @type {?} */ var _indexArrayIndex = 0; for (var i = 0; i < this.modeSwitch.length; i++) { if (this.modeSwitch[i] === 0) { switch (i) { case 0: min_date[i] = new Date().getFullYear(); max_date[i] = new Date().getFullYear(); break; case 1: min_date[i] = new Date().getMonth() + 1; max_date[i] = new Date().getMonth() + 1; break; case 2: min_date[i] = new Date().getDate(); max_date[i] = new Date().getDate(); break; case 3: min_date[i] = new Date().getHours(); max_date[i] = new Date().getHours(); break; case 4: min_date[i] = new Date().getMinutes(); max_date[i] = new Date().getMinutes(); break; case 5: min_date[i] = 0; max_date[i] = 1; break; } } else { switch (i) { case 0: this.localMinDate[_indexArrayIndex] = min_date[i] = this.localMinDate[_indexArrayIndex] >= 1900 ? this.localMinDate[_indexArrayIndex] : new Date().getFullYear(); this.localMaxDate[_indexArrayIndex] = max_date[i] = this.localMaxDate[_indexArrayIndex] >= 1900 ? this.localMaxDate[_indexArrayIndex] : new Date().getFullYear() + 1; break; case 1: this.localMinDate[_indexArrayIndex] = min_date[i] = this.localMinDate[_indexArrayIndex] > 0 && this.localMinDate[_indexArrayIndex] <= 12 ? this.localMinDate[_indexArrayIndex] : 1; this.localMaxDate[_indexArrayIndex] = max_date[i] = this.localMaxDate[_indexArrayIndex] > 0 && this.localMaxDate[_indexArrayIndex] <= 12 ? this.localMaxDate[_indexArrayIndex] : 12; break; case 2: this.localMinDate[_indexArrayIndex] = min_date[i] = this.localMinDate[_indexArrayIndex] > 0 && this.localMinDate[_indexArrayIndex] <= new Date(min_date[0], min_date[1], 0).getDate() ? this.localMinDate[_indexArrayIndex] : 1; this.localMaxDate[_indexArrayIndex] = max_date[i] = this.localMaxDate[_indexArrayIndex] > 0 && this.localMaxDate[_indexArrayIndex] <= new Date(max_date[0], max_date[1], 0).getDate() ? this.localMaxDate[_indexArrayIndex] : new Date(max_date[0], max_date[1], 0).getDate(); break; case 3: this.localMinDate[_indexArrayIndex] = min_date[i] = this.localMinDate[_indexArrayIndex] >= 0 && this.localMinDate[_indexArrayIndex] <= 23 ? this.localMinDate[_indexArrayIndex] : 0; if (this.options.use12Hours) { this.localMaxDate[_indexArrayIndex] = max_date[i] = this.localMaxDate[_indexArrayIndex] >= 0 && this.localMaxDate[_indexArrayIndex] <= 11 ? this.localMaxDate[_indexArrayIndex] : 11; } else { this.localMaxDate[_indexArrayIndex] = max_date[i] = this.localMaxDate[_indexArrayIndex] >= 0 && this.localMaxDate[_indexArrayIndex] <= 23 ? this.localMaxDate[_indexArrayIndex] : 23; } break; case 4: this.localMinDate[_indexArrayIndex] = min_date[i] = this.localMinDate[_indexArrayIndex] >= 0 && this.localMinDate[_indexArrayIndex] <= 59 ? this.localMinDate[_indexArrayIndex] : 0; this.localMaxDate[_indexArrayIndex] = max_date[i] = this.localMaxDate[_indexArrayIndex] >= 0 && this.localMaxDate[_indexArrayIndex] <= 59 ? this.localMaxDate[_indexArrayIndex] : 59; break; } } _indexArrayIndex++; } return minT <= curT && curT <= maxT; } else { this.errorMessage = this.localeNew.errorMessage; return false; } }; /** * @param {?} arr1 * @param {?} arr2 * @return {?} */ DatePickerComponent.prototype.judgeTime = /** * @param {?} arr1 * @param {?} arr2 * @return {?} */ function (arr1, arr2) { /** @type {?} */ var date1; /** @type {?} */ var date2; date1 = arr1.slice(0, 3).join('-') + ' ' + arr1.slice(3, 5).join(':'); date2 = arr2.slice(0, 3).join('-') + ' ' + arr2.slice(3, 5).join(':'); return new Date(date1).getTime() >= new Date(date2).getTime(); }; /** * @param {?} arr1 * @param {?} arr2 * @param {?} length * @return {?} */ DatePickerComponent.prototype.judgeEqualArray = /** * @param {?} arr1 * @param {?} arr2 * @param {?} length * @return {?} */ function (arr1, arr2, length) { /** @type {?} */ var status = true; for (var i = 0; i < length; i++) { if (arr1[i] != arr2[i]) { status = false; } } return status; }; /** * @return {?} */ DatePickerComponent.prototype.initReady = /** * @return {?} */ function () { /** @type {?} */ var realIdx = 0; for (var i = 0; i < this.clos; i++) { realIdx = this.indexArray[i]; /** @type {?} */ var min = 0; /** @type {?} */ var max = 0; /** @type {?} */ var tempArray = []; switch (realIdx) { case 0: this.initData(tempArray, this.localMinDate[i], this.localMaxDate[i], this.localeNew.year, i); break; case 1: min = this.judgeEqualArray(this.min_date, this.current_time, 1) ? this.localMinDate[i] : 1; max = this.judgeEqualArray(this.max_date, this.current_time, 1) ? this.localMaxDate[i] : 12; this.initData(tempArray, min, max, this.localeNew.month, i); break; case 2: min = this.judgeEqualArray(this.min_date, this.current_time, 2) ? this.localMinDate[i] : this.curTLessThanMin ? this.localMinDate[i] : 1; max = this.judgeEqualArray(this.max_date, this.current_time, 2) ? this.localMaxDate[i] : new Date(this.current_time[0], this.current_time[1], 0).getDate(); this.initData(tempArray, min, max, this.localeNew.day, i); break; case 3: min = this.judgeEqualArray(this.min_date, this.current_time, 3) ? this.localMinDate[i] : this.curTLessThanMin ? this.localMinDate[i] : 0; max = this.judgeEqualArray(this.max_date, this.current_time, 3) ? this.localMaxDate[i] : this.curTMoreThanMax ? this.localMaxDate[i] : 23; this.initData(tempArray, min, max, this.localeNew.hour, i); break; case 4: min = this.judgeEqualArray(this.min_date, this.current_time, 4) ? this.localMinDate[i] : this.curTLessThanMin ? this.localMinDate[i] : 0; max = this.judgeEqualArray(this.max_date, this.current_time, 4) ? this.localMaxDate[i] : this.curTMoreThanMax ? this.localMaxDate[i] : 59; this.initData(tempArray, min, max, this.localeNew.minute, i); break; case 5: min = 0; max = 1; this.initData(tempArray, min, max, 'use12Hours', i); break; } } }; /** * @param {?} tempArr * @param {?} min * @param {?} max * @param {?} str * @param {?} idx * @return {?} */ DatePickerComponent.prototype.initData = /** * @param {?} tempArr * @param {?} min * @param {?} max * @param {?} str * @param {?} idx * @return {?} */ function (tempArr, min, max, str, idx) { /** @type {?} */ var dataWithStr = []; /** @type {?} */ var increaseValue = str === this.localeNew.minute ? this.options.minuteStep : 1; for (min; min < max + 1; min += increaseValue) { tempArr.push(min); dataWithStr.push(min + str); } if (this.data.length > this.indexArray.length) { this.data = []; this.dataWithStr = []; } if (this.data.length > idx && this.data[idx].toString() !== tempArr.toString()) { this.data[idx] = tempArr; } else if (this.data.length > idx && this.data[idx].toString() === tempArr.toString()) { this.data[idx] = tempArr; } else { this.data.push(tempArr); } if (this.options.locale === undefined || this.options.locale.locale === 'zh_CN') { if (this.dataWithStr.length > idx && this.dataWithStr[idx].toString() !== dataWithStr.toString()) { this.dataWithStr[idx] = dataWithStr; } else if (this.dataWithStr.length > idx && this.dataWithStr[idx].toString() === dataWithStr.toString()) { this.dataWithStr[idx] = dataWithStr; } else { this.dataWithStr.push(dataWithStr); } } else { this.dataWithStr = this.data; } }; /** * @return {?} */ DatePickerComponent.prototype.ok = /** * @return {?} */ function () { this.options.onOk.emit(this.handleReslut()); this.setTransitionName(); }; /** * @return {?} */ DatePickerComponent.prototype.handleReslut = /** * @return {?} */ function () { var _this = this; /** @type {?} */ var result = ''; if (this.options.mode === 'datetime' || this.options.mode === 'time') { /** @type {?} */ var temp = this.resultArr; result = temp.slice(0, 3).join('-') + ' ' + temp.slice(3, 5).join(':'); } else { if (this.resultArr.length < 3) { this.resultArr.push('1'); } result = this.resultArr .map((/** * @param {?} v * @return {?} */ function (v) { return _this.preZero(parseInt(v, 0)); })) .join('-'); } this.resultDate = new Date(result.replace(/-/g, '/')); if (this.options.minDate.getTime() > this.resultDate.getTime()) { if (this.resultArr.length > 0) { for (var index = 0; index < this.resultArr.length; index++) { this.resultArr = this.min_date; this.currentTime = this.resultArr; this.current_time = this.currentTime; } } this.resultDate = this.options.minDate; } return this.resultDate; }; /** * @return {?} */ DatePickerComponent.prototype.cancel = /** * @return {?} */ function () { this.options.onDismiss.emit(); this.setTransitionName(); }; /** * @return {?} */ DatePickerComponent.prototype.setTransitionName = /** * @return {?} */ function () { var _this = this; this.transitionName = 'am-slide-up-leave am-slide-up-leave-active'; this.maskTransitionName = 'am-fade-leave am-fade-leave-active'; setTimeout((/** * @return {?} */ function () { _this.options.hidePicker(); }), 200); }; /** * @param {?} checkIdx * @param {?} sta * @param {?} indexT * @return {?} */ DatePickerComponent.prototype.setCurrentSelected = /** * @param {?} checkIdx * @param {?} sta * @param {?} indexT * @return {?} */ function (checkIdx, sta, indexT) { if (checkIdx >= this.clos - 1) { return; } /** @type {?} */ var status = null; if (sta) { status = this.judgeEqualArray(this.min_date, this.resultArr, checkIdx + 1); } else { status = this.judgeEqualArray(this.max_date, this.resultArr, checkIdx + 1); } if (!status) { /** @type {?} */ var min = 0; /** @type {?} */ var max = 0; /** @type {?} */ var str = ''; /** @type {?} */ var realIdx = this.indexArray[checkIdx]; switch (realIdx) { case 0: min = this.judgeEqualArray(this.min_date, this.current_time, 1) ? this.localMinDate[checkIdx + 1] : 1; max = this.judgeEqualArray(this.max_date, this.current_time, 1) ? this.localMaxDate[checkIdx + 1] : 12; str = '月'; break; case 1: min = this.judgeEqualArray(this.min_date, this.current_time, 2) ? this.localMinDate[checkIdx + 1] : this.curTLessThanMin ? this.localMinDate[checkIdx + 1] : 1; max = this.judgeEqualArray(this.max_date, this.current_time, 2) ? this.localMaxDate[checkIdx + 1] : new Date(this.current_time[0], this.current_time[1], 0).getDate(); str = '日'; break; case 2: min = this.judgeEqualArray(this.min_date, this.current_time, 3) ? this.localMinDate[checkIdx + 1] : this.curTLessThanMin ? this.localMinDate[checkIdx + 1] : 0; max = this.judgeEqualArray(this.max_date, this.current_time, 3) ? this.localMaxDate[checkIdx + 1] : this.curTMoreThanMax ? this.localMaxDate[checkIdx + 1] : 23; str = '时'; break; case 3: min = this.judgeEqualArray(this.min_date, this.current_time, 4) ? this.localMinDate[checkIdx + 1] : this.curTLessThanMin ? this.localMinDate[checkIdx + 1] : 0; max = this.judgeEqualArray(this.max_date, this.current_time, 4) ? this.localMaxDate[checkIdx + 1] : this.curTMoreThanMax ? this.localMaxDate[checkIdx + 1] : 59; str = '分'; break; } this.initRangeArr(min, max, indexT, checkIdx + 1, str); } this.setCurrentSelected(checkIdx + 1, sta, indexT); }; /** * @param {?} min * @param {?} max * @param {?} indexT * @param {?} checkIdx * @param {?} str * @return {?} */ DatePickerComponent.prototype.initRangeArr = /** * @param {?} min * @param {?} max * @param {?} indexT * @param {?} checkIdx * @param {?} str * @return {?} */ function (min, max, indexT, checkIdx, str) { var _this = this; /** @type {?} */ var realIdx = this.indexArray[checkIdx]; /** @type {?} */ var arr = []; /** @type {?} */ var targetLong = 0; /** @type {?} */ var increaseValue = str === this.localeNew.minute ? this.options.minuteStep : 1; for (var index = min; index < max + 1; index += increaseValue) { arr.push(index); } if (arr.indexOf(this.resultArr[checkIdx]) == -1) { if (-this.selectedTarget[checkIdx].currentY > max - min) { indexT = max - min; this.selectedTarget[checkIdx].currentY = -indexT; } targetLong = -arr.length * this.lineHeight; } else { targetLong = -arr.indexOf(this.resultArr[checkIdx]) * this.lineHeight; this.selectedTarget[checkIdx].currentY = -arr.indexOf(this.resultArr[checkIdx]); } if (this.data[checkIdx].toString() !== arr.toString()) { if (checkIdx >= 3) { this.current_time[realIdx] = -targetLong / this.lineHeight; this.resultArr[checkIdx] = -targetLong / this.lineHeight; } else { this.current_time[realIdx] = -targetLong / this.lineHeight + 1; this.resultArr[checkIdx] = -targetLong / this.lineHeight + 1; } this.data[checkIdx] = arr; this.dataWithStr[checkIdx] = this.options.locale.locale === 'zh_CN' ? arr.map((/** * @param {?} item * @return {?} */ function (item) { return item + str; })) : arr; setTimeout((/** * @return {?} */ function () { _this.selectedTarget.forEach((/** * @param {?} item * @param {?} i * @return {?} */ function (item, i) { if (i >= checkIdx) { _this.currentPicker.children[i].children[2].style.transition = ''; /** @type {?} */ var index = parseInt(item.currentY, 0); _this.currentPicker.children[i].children[2].style.transform = "translateY(" + index * _this.lineHeight + "px)"; } })); }), 0); } }; /** * @param {?} event * @return {?} */ DatePickerComponent.prototype.getEventTarget = /** * @param {?} event * @return {?} */ function (event) { if (event.type === 'mousedown' || event.type === 'mousemove' || event.type === 'mouseup' || event.type === 'mouseleave') { return event; } else { if (event && event.changedTouches && event.changedTouches[0]) { return event.changedTouches[0]; } return null; } }; /** * @return {?} */ DatePickerComponent.prototype.ngOnInit = /** * @return {?} */ function () { this.checkMode(this.options.mode); /** @type {?} */ var value = this.transformDateFormat(this.options.value).split('-'); if (value.length > 1) { this.current_time = this.currentTime = value.map((/** * @param {?} item * @return {?} */ function (item) { return parseInt(item, 0); })); } else { this.currentTime = this.current_time; } this.localeProvider(); }; /** * @return {?} */ DatePickerComponent.prototype.ngAfterViewInit = /** * @return {?} */ function () { this.reloadPicker(); }; /** * @return {?} */ DatePickerComponent.prototype.ngOnDestroy = /** * @return {?} */ function () { this.unsubscribe$.next(); this.unsubscribe$.complete(); }; DatePickerComponent.decorators = [ { type: Component, args: [{ selector: 'DatePicker, nzm-date-picker', template: "<div *ngIf=\"options.mask\" class=\"am-picker-popup-mask {{ maskTransitionName }}\" (click)=\"cancel()\"></div>\n<div class=\"am-picker-popup {{ transitionName }}\" style=\"z-index: 1000\">\n <div class=\"am-picker-popup-content\">\n <div class=\"am-picker-popup-body\">\n <div>\n <div class=\"am-picker-popup-header\">\n <div class=\"am-picker-popup-item am-picker-popup-header-left\" (click)=\"cancel()\">\n {{ options.dismissText }}\n </div>\n <div class=\"am-picker-popup-item am-picker-popup-title\">{{ options.title }}</div>\n <div class=\"am-picker-popup-item am-picker-popup-header-right\" (click)=\"ok()\">\n {{ options.okText }}\n </div>\n </div>\n <div #picker class=\"am-picker\" style=\"flex-direction: row; align-items: center;\">\n <div *ngFor=\"let item of dataWithStr; let i = index\" class=\"am-picker-col\">\n <div class=\"am-picker-col-indicator \" style=\"top: 102px;\"></div>\n <div id=\"{{ i }}\" class=\"am-picker-col-mask\" style=\"background-size: 100% 102px;\"></div>\n <div class=\"am-picker-col-content\">\n <div id=\"{{ i }}\" class=\"am-picker-col-item\" *ngFor=\"let val of item; let i = index\">\n {{ val.label ? val.label : val }}\n </div>\n </div>\n </div>\n </div>\n </div>\n </div>\n </div>\n</div>\n", encapsulation: ViewEncapsulation.None }] } ]; /** @nocollapse */ DatePickerComponent.ctorParameters = function () { return [ { type: ElementRef }, { type: DatePickerOptions }, { type: ToastService }, { type: LocaleProviderService } ]; }; DatePickerComponent.propDecorators = { picker: [{ type: ViewChild, args: ['picker', { static: true, read: ViewContainerRef },] }], panstart: [{ type: HostListener, args: ['mousedown', ['$event'],] }, { type: HostListener, args: ['touchstart', ['$event'],] }], panmove: [{ type: HostListener, args: ['mousemove', ['$event'],] }, { type: HostListener, args: ['touchmove', ['$event'],] }], panend: [{ type: HostListener, args: ['mouseleave', ['$event'],] }, { type: HostListener, args: ['mouseup', ['$event'],] }, { type: HostListener, args: ['touchend', ['$event'],] }] }; return DatePickerComponent; }()); export { DatePickerComponent }; if (false) { /** @type {?} */ DatePickerComponent.prototype.transitionName; /** @type {?} */ DatePickerComponent.prototype.maskTransitionName; /** @type {?} */ DatePickerComponent.prototype.modeSwitch; /** @type {?} */ DatePickerComponent.prototype.localMinDate; /** @type {?} */ DatePickerComponent.prototype.localMaxDate; /** @type {?} */ DatePickerComponent.prototype.currentTime; /** @type {?} */ DatePickerComponent.prototype.indexArray; /** @type {?} */ DatePickerComponent.prototype.min_date; /** @type {?} */ DatePickerComponent.prototype.max_date; /** @type {?} */ DatePickerComponent.prototype.current_time; /** @type {?} */ DatePickerComponent.prototype.clos; /** @type {?} */ DatePickerComponent.prototype.resultArr; /** @type {?} */ DatePickerComponent.prototype.resultDate; /** @type {?} */ DatePickerComponent.prototype.data; /** @type {?} */ DatePickerComponent.prototype.dataWithStr; /** @type {?} */ DatePickerComponent.prototype.startY; /** @type {?} */ DatePickerComponent.prototype.differY; /** @type {?} */ DatePickerComponent.prototype.currentY; /** @type {?} */ DatePickerComponent.prototype.len; /** @type {?} */ DatePickerComponent.prototype.dom; /** @type {?} */ DatePickerComponent.prototype.index; /** @type {?} */ DatePickerComponent.prototype.maxY; /** @type {?} */ DatePickerComponent.prototype.lineHeight; /** @type {?} */ DatePickerComponent.prototype.selectedTarget; /** @type {?} */ DatePickerComponent.prototype.isMouseDown; /** @type {?} */ DatePickerComponent.prototype.currentPicker; /** @type {?} */ DatePickerComponent.prototype.localeNew; /** @type {?} */ DatePickerComponent.prototype.unsubscribe$; /** @type {?} */ DatePickerComponent.prototype.Velocity; /** @type {?} */ DatePickerComponent.prototype.errorMessage; /** @type {?} */ DatePickerComponent.prototype.curTLessThanMin; /** @type {?} */ DatePickerComponent.prototype.curTMoreThanMax; /** @type {?} */ DatePickerComponent.prototype.ngModelOnChange; /** @type {?} */ DatePickerComponent.prototype.ngModelOnTouched; /** @type {?} */ DatePickerComponent.prototype.picker; /** @type {?} */ DatePickerComponent.prototype.elementRef; /** @type {?} */ DatePickerComponent.prototype.options; /** @type {?} */ DatePickerComponent.prototype.toast; /** @type {?} */ DatePickerComponent.prototype.localeProviderService; } //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZGF0ZS1waWNrZXIuY29tcG9uZW50LmpzIiwic291cmNlUm9vdCI6Im5nOi8vbmctem9ycm8tYW50ZC1tb2JpbGUvIiwic291cmNlcyI6WyJkYXRlLXBpY2tlci9kYXRlLXBpY2tlci5jb21wb25lbnQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7OztBQUFBLE9BQU8sRUFDTCxTQUFTLEVBRVQsVUFBVSxFQUNWLGlCQUFpQixFQUNqQixZQUFZLEVBQ1osU0FBUyxFQUNULGdCQUFnQixFQUdqQixNQUFNLGVBQWUsQ0FBQztBQUN2QixPQUFPLEVB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