ng-zorro-antd
Version:
An enterprise-class UI components based on Ant Design and Angular
1,356 lines (1,328 loc) • 87.7 kB
JavaScript
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/cdk/overlay'), require('@angular/core'), require('@angular/forms'), require('ng-zorro-antd/core'), require('@angular/common'), require('ng-zorro-antd/i18n'), require('ng-zorro-antd/icon'), require('rxjs'), require('rxjs/operators')) :
typeof define === 'function' && define.amd ? define('ng-zorro-antd/time-picker', ['exports', '@angular/cdk/overlay', '@angular/core', '@angular/forms', 'ng-zorro-antd/core', '@angular/common', 'ng-zorro-antd/i18n', 'ng-zorro-antd/icon', 'rxjs', 'rxjs/operators'], factory) :
(global = global || self, factory((global['ng-zorro-antd'] = global['ng-zorro-antd'] || {}, global['ng-zorro-antd']['time-picker'] = {}), global.ng.cdk.overlay, global.ng.core, global.ng.forms, global['ng-zorro-antd'].core, global.ng.common, global['ng-zorro-antd'].i18n, global['ng-zorro-antd'].icon, global.rxjs, global.rxjs.operators));
}(this, function (exports, overlay, core, forms, core$1, common, i18n, icon, rxjs, operators) { 'use strict';
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
/* global Reflect, Promise */
var extendStatics = function(d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
function __extends(d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
}
var __assign = function() {
__assign = Object.assign || function __assign(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
function __rest(s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
t[p[i]] = s[p[i]];
}
return t;
}
function __decorate(decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
}
function __param(paramIndex, decorator) {
return function (target, key) { decorator(target, key, paramIndex); }
}
function __metadata(metadataKey, metadataValue) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
}
function __awaiter(thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
}
function __generator(thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
}
function __exportStar(m, exports) {
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
}
function __values(o) {
var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
if (m) return m.call(o);
return {
next: function () {
if (o && i >= o.length) o = void 0;
return { value: o && o[i++], done: !o };
}
};
}
function __read(o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m) return o;
var i = m.call(o), r, ar = [], e;
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
}
catch (error) { e = { error: error }; }
finally {
try {
if (r && !r.done && (m = i["return"])) m.call(i);
}
finally { if (e) throw e.error; }
}
return ar;
}
function __spread() {
for (var ar = [], i = 0; i < arguments.length; i++)
ar = ar.concat(__read(arguments[i]));
return ar;
}
function __spreadArrays() {
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
for (var r = Array(s), k = 0, i = 0; i < il; i++)
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
r[k] = a[j];
return r;
};
function __await(v) {
return this instanceof __await ? (this.v = v, this) : new __await(v);
}
function __asyncGenerator(thisArg, _arguments, generator) {
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
var g = generator.apply(thisArg, _arguments || []), i, q = [];
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
function fulfill(value) { resume("next", value); }
function reject(value) { resume("throw", value); }
function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
}
function __asyncDelegator(o) {
var i, p;
return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
}
function __asyncValues(o) {
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
var m = o[Symbol.asyncIterator], i;
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
}
function __makeTemplateObject(cooked, raw) {
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
return cooked;
};
function __importStar(mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result.default = mod;
return result;
}
function __importDefault(mod) {
return (mod && mod.__esModule) ? mod : { default: mod };
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var NzTimePickerComponent = /** @class */ (function () {
function NzTimePickerComponent(nzConfigService, element, renderer, updateCls, cdr) {
this.nzConfigService = nzConfigService;
this.element = element;
this.renderer = renderer;
this.updateCls = updateCls;
this.cdr = cdr;
this._value = null;
this.isInit = false;
this.overlayPositions = [
{
originX: 'start',
originY: 'top',
overlayX: 'end',
overlayY: 'top',
offsetX: 0,
offsetY: 0
}
];
this.nzSize = null;
this.nzPlaceHolder = '';
this.nzDefaultOpenValue = new Date();
this.nzOpen = false;
this.nzOpenChange = new core.EventEmitter();
this.nzHideDisabledOptions = false;
this.nzDisabled = false;
this.nzAutoFocus = false;
}
Object.defineProperty(NzTimePickerComponent.prototype, "value", {
get: /**
* @return {?}
*/
function () {
return this._value;
},
set: /**
* @param {?} value
* @return {?}
*/
function (value) {
this._value = value;
if (this._onChange) {
this._onChange(this.value);
}
if (this._onTouched) {
this._onTouched();
}
},
enumerable: true,
configurable: true
});
/**
* @return {?}
*/
NzTimePickerComponent.prototype.open = /**
* @return {?}
*/
function () {
if (this.nzDisabled) {
return;
}
this.nzOpen = true;
this.nzOpenChange.emit(this.nzOpen);
};
/**
* @return {?}
*/
NzTimePickerComponent.prototype.close = /**
* @return {?}
*/
function () {
this.nzOpen = false;
this.cdr.markForCheck();
this.nzOpenChange.emit(this.nzOpen);
};
/**
* @return {?}
*/
NzTimePickerComponent.prototype.updateAutoFocus = /**
* @return {?}
*/
function () {
if (this.isInit && !this.nzDisabled) {
if (this.nzAutoFocus) {
this.renderer.setAttribute(this.inputRef.nativeElement, 'autofocus', 'autofocus');
}
else {
this.renderer.removeAttribute(this.inputRef.nativeElement, 'autofocus');
}
}
};
/**
* @return {?}
*/
NzTimePickerComponent.prototype.onClickClearBtn = /**
* @return {?}
*/
function () {
this.value = null;
};
/**
* @private
* @return {?}
*/
NzTimePickerComponent.prototype.setClassMap = /**
* @private
* @return {?}
*/
function () {
var _a;
this.updateCls.updateHostClass(this.element.nativeElement, (_a = {},
_a["ant-time-picker"] = true,
_a["ant-time-picker-" + this.nzSize] = core$1.isNotNil(this.nzSize),
_a));
};
/**
* @return {?}
*/
NzTimePickerComponent.prototype.focus = /**
* @return {?}
*/
function () {
if (this.inputRef.nativeElement) {
this.inputRef.nativeElement.focus();
}
};
/**
* @return {?}
*/
NzTimePickerComponent.prototype.blur = /**
* @return {?}
*/
function () {
if (this.inputRef.nativeElement) {
this.inputRef.nativeElement.blur();
}
};
/**
* @return {?}
*/
NzTimePickerComponent.prototype.ngOnInit = /**
* @return {?}
*/
function () {
this.setClassMap();
this.origin = new overlay.CdkOverlayOrigin(this.element);
};
/**
* @param {?} changes
* @return {?}
*/
NzTimePickerComponent.prototype.ngOnChanges = /**
* @param {?} changes
* @return {?}
*/
function (changes) {
var nzUse12Hours = changes.nzUse12Hours, nzFormat = changes.nzFormat, nzDisabled = changes.nzDisabled, nzAutoFocus = changes.nzAutoFocus;
if (nzUse12Hours && !nzUse12Hours.previousValue && nzUse12Hours.currentValue && !nzFormat) {
this.nzFormat = 'h:mm:ss a';
}
if (nzDisabled) {
/** @type {?} */
var value = nzDisabled.currentValue;
/** @type {?} */
var input = (/** @type {?} */ (this.inputRef.nativeElement));
if (value) {
this.renderer.setAttribute(input, 'disabled', '');
}
else {
this.renderer.removeAttribute(input, 'disabled');
}
}
if (nzAutoFocus) {
this.updateAutoFocus();
}
};
/**
* @return {?}
*/
NzTimePickerComponent.prototype.ngAfterViewInit = /**
* @return {?}
*/
function () {
this.isInit = true;
this.updateAutoFocus();
};
/**
* @param {?} time
* @return {?}
*/
NzTimePickerComponent.prototype.writeValue = /**
* @param {?} time
* @return {?}
*/
function (time) {
this._value = time;
this.cdr.markForCheck();
};
/**
* @param {?} fn
* @return {?}
*/
NzTimePickerComponent.prototype.registerOnChange = /**
* @param {?} fn
* @return {?}
*/
function (fn) {
this._onChange = fn;
};
/**
* @param {?} fn
* @return {?}
*/
NzTimePickerComponent.prototype.registerOnTouched = /**
* @param {?} fn
* @return {?}
*/
function (fn) {
this._onTouched = fn;
};
/**
* @param {?} isDisabled
* @return {?}
*/
NzTimePickerComponent.prototype.setDisabledState = /**
* @param {?} isDisabled
* @return {?}
*/
function (isDisabled) {
this.nzDisabled = isDisabled;
this.cdr.markForCheck();
};
NzTimePickerComponent.decorators = [
{ type: core.Component, args: [{
encapsulation: core.ViewEncapsulation.None,
changeDetection: core.ChangeDetectionStrategy.OnPush,
selector: 'nz-time-picker',
exportAs: 'nzTimePicker',
template: "<input\n #inputElement\n nzType=\"text\"\n [nzTime]=\"nzFormat\"\n class=\"ant-time-picker-input\"\n [placeholder]=\"nzPlaceHolder || ('TimePicker.placeholder' | nzI18n)\"\n [(ngModel)]=\"value\"\n readonly=\"readonly\"\n (click)=\"open()\">\n<span class=\"ant-time-picker-icon\">\n <i nz-icon nzType=\"clock-circle\"></i>\n</span>\n<i\n *ngIf=\"nzAllowEmpty && value\"\n nz-icon\n nzType=\"close-circle\"\n nzTheme=\"fill\"\n class=\"anticon anticon-close-circle ant-time-picker-clear\"\n tabindex=\"-1\"\n [attr.aria-label]=\"nzClearText\"\n [attr.title]=\"nzClearText\"\n (click)=\"onClickClearBtn()\"\n></i>\n\n<ng-template\n cdkConnectedOverlay\n nzConnectedOverlay\n cdkConnectedOverlayHasBackdrop\n [cdkConnectedOverlayPositions]=\"overlayPositions\"\n [cdkConnectedOverlayOrigin]=\"origin\"\n [cdkConnectedOverlayOpen]=\"nzOpen\"\n [cdkConnectedOverlayOffsetY]=\"-2\"\n (detach)=\"close()\"\n (backdropClick)=\"close()\">\n <nz-time-picker-panel\n [ngClass]=\"nzPopupClassName\"\n [@slideMotion]=\"'bottom'\"\n [format]=\"nzFormat\"\n [nzHourStep]=\"nzHourStep\"\n [nzMinuteStep]=\"nzMinuteStep\"\n [nzSecondStep]=\"nzSecondStep\"\n [nzDisabledHours]=\"nzDisabledHours\"\n [nzDisabledMinutes]=\"nzDisabledMinutes\"\n [nzDisabledSeconds]=\"nzDisabledSeconds\"\n [nzPlaceHolder]=\"nzPlaceHolder || ('TimePicker.placeholder' | nzI18n)\"\n [nzHideDisabledOptions]=\"nzHideDisabledOptions\"\n [nzUse12Hours]=\"nzUse12Hours\"\n [nzDefaultOpenValue]=\"nzDefaultOpenValue\"\n [nzAddOn]=\"nzAddOn\"\n [opened]=\"nzOpen\"\n [nzClearText]=\"nzClearText\"\n [nzAllowEmpty]=\"nzAllowEmpty\"\n [(ngModel)]=\"value\">\n </nz-time-picker-panel>\n</ng-template>\n\n",
animations: [core$1.slideMotion],
providers: [core$1.NzUpdateHostClassService, { provide: forms.NG_VALUE_ACCESSOR, useExisting: NzTimePickerComponent, multi: true }]
}] }
];
/** @nocollapse */
NzTimePickerComponent.ctorParameters = function () { return [
{ type: core$1.NzConfigService },
{ type: core.ElementRef },
{ type: core.Renderer2 },
{ type: core$1.NzUpdateHostClassService },
{ type: core.ChangeDetectorRef }
]; };
NzTimePickerComponent.propDecorators = {
inputRef: [{ type: core.ViewChild, args: ['inputElement', { static: true },] }],
nzSize: [{ type: core.Input }],
nzHourStep: [{ type: core.Input }],
nzMinuteStep: [{ type: core.Input }],
nzSecondStep: [{ type: core.Input }],
nzClearText: [{ type: core.Input }],
nzPopupClassName: [{ type: core.Input }],
nzPlaceHolder: [{ type: core.Input }],
nzAddOn: [{ type: core.Input }],
nzDefaultOpenValue: [{ type: core.Input }],
nzDisabledHours: [{ type: core.Input }],
nzDisabledMinutes: [{ type: core.Input }],
nzDisabledSeconds: [{ type: core.Input }],
nzFormat: [{ type: core.Input }],
nzOpen: [{ type: core.Input }],
nzUse12Hours: [{ type: core.Input }],
nzOpenChange: [{ type: core.Output }],
nzHideDisabledOptions: [{ type: core.Input }],
nzAllowEmpty: [{ type: core.Input }],
nzDisabled: [{ type: core.Input }],
nzAutoFocus: [{ type: core.Input }]
};
__decorate([
core$1.WithConfig(1),
__metadata("design:type", Number)
], NzTimePickerComponent.prototype, "nzHourStep", void 0);
__decorate([
core$1.WithConfig(1),
__metadata("design:type", Number)
], NzTimePickerComponent.prototype, "nzMinuteStep", void 0);
__decorate([
core$1.WithConfig(1),
__metadata("design:type", Number)
], NzTimePickerComponent.prototype, "nzSecondStep", void 0);
__decorate([
core$1.WithConfig('clear'),
__metadata("design:type", String)
], NzTimePickerComponent.prototype, "nzClearText", void 0);
__decorate([
core$1.WithConfig(),
__metadata("design:type", String)
], NzTimePickerComponent.prototype, "nzPopupClassName", void 0);
__decorate([
core$1.WithConfig('HH:mm:ss'),
__metadata("design:type", String)
], NzTimePickerComponent.prototype, "nzFormat", void 0);
__decorate([
core$1.WithConfig(false), core$1.InputBoolean(),
__metadata("design:type", Boolean)
], NzTimePickerComponent.prototype, "nzUse12Hours", void 0);
__decorate([
core$1.InputBoolean(),
__metadata("design:type", Object)
], NzTimePickerComponent.prototype, "nzHideDisabledOptions", void 0);
__decorate([
core$1.WithConfig(true), core$1.InputBoolean(),
__metadata("design:type", Boolean)
], NzTimePickerComponent.prototype, "nzAllowEmpty", void 0);
__decorate([
core$1.InputBoolean(),
__metadata("design:type", Object)
], NzTimePickerComponent.prototype, "nzDisabled", void 0);
__decorate([
core$1.InputBoolean(),
__metadata("design:type", Object)
], NzTimePickerComponent.prototype, "nzAutoFocus", void 0);
return NzTimePickerComponent;
}());
if (false) {
/**
* @type {?}
* @private
*/
NzTimePickerComponent.prototype._value;
/**
* @type {?}
* @private
*/
NzTimePickerComponent.prototype._onChange;
/**
* @type {?}
* @private
*/
NzTimePickerComponent.prototype._onTouched;
/** @type {?} */
NzTimePickerComponent.prototype.isInit;
/** @type {?} */
NzTimePickerComponent.prototype.origin;
/** @type {?} */
NzTimePickerComponent.prototype.overlayPositions;
/** @type {?} */
NzTimePickerComponent.prototype.inputRef;
/** @type {?} */
NzTimePickerComponent.prototype.nzSize;
/** @type {?} */
NzTimePickerComponent.prototype.nzHourStep;
/** @type {?} */
NzTimePickerComponent.prototype.nzMinuteStep;
/** @type {?} */
NzTimePickerComponent.prototype.nzSecondStep;
/** @type {?} */
NzTimePickerComponent.prototype.nzClearText;
/** @type {?} */
NzTimePickerComponent.prototype.nzPopupClassName;
/** @type {?} */
NzTimePickerComponent.prototype.nzPlaceHolder;
/** @type {?} */
NzTimePickerComponent.prototype.nzAddOn;
/** @type {?} */
NzTimePickerComponent.prototype.nzDefaultOpenValue;
/** @type {?} */
NzTimePickerComponent.prototype.nzDisabledHours;
/** @type {?} */
NzTimePickerComponent.prototype.nzDisabledMinutes;
/** @type {?} */
NzTimePickerComponent.prototype.nzDisabledSeconds;
/** @type {?} */
NzTimePickerComponent.prototype.nzFormat;
/** @type {?} */
NzTimePickerComponent.prototype.nzOpen;
/** @type {?} */
NzTimePickerComponent.prototype.nzUse12Hours;
/** @type {?} */
NzTimePickerComponent.prototype.nzOpenChange;
/** @type {?} */
NzTimePickerComponent.prototype.nzHideDisabledOptions;
/** @type {?} */
NzTimePickerComponent.prototype.nzAllowEmpty;
/** @type {?} */
NzTimePickerComponent.prototype.nzDisabled;
/** @type {?} */
NzTimePickerComponent.prototype.nzAutoFocus;
/** @type {?} */
NzTimePickerComponent.prototype.nzConfigService;
/**
* @type {?}
* @private
*/
NzTimePickerComponent.prototype.element;
/**
* @type {?}
* @private
*/
NzTimePickerComponent.prototype.renderer;
/**
* @type {?}
* @private
*/
NzTimePickerComponent.prototype.updateCls;
/** @type {?} */
NzTimePickerComponent.prototype.cdr;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var NzTimeValueAccessorDirective = /** @class */ (function () {
function NzTimeValueAccessorDirective(dateHelper, elementRef) {
this.dateHelper = dateHelper;
this.elementRef = elementRef;
}
/**
* @return {?}
*/
NzTimeValueAccessorDirective.prototype.keyup = /**
* @return {?}
*/
function () {
this.changed();
};
/**
* @return {?}
*/
NzTimeValueAccessorDirective.prototype.blur = /**
* @return {?}
*/
function () {
this.touched();
};
/**
* @return {?}
*/
NzTimeValueAccessorDirective.prototype.changed = /**
* @return {?}
*/
function () {
if (this._onChange) {
/** @type {?} */
var value = this.dateHelper.parseTime(this.elementRef.nativeElement.value);
this._onChange((/** @type {?} */ (value)));
}
};
/**
* @return {?}
*/
NzTimeValueAccessorDirective.prototype.touched = /**
* @return {?}
*/
function () {
if (this._onTouch) {
this._onTouch();
}
};
/**
* @return {?}
*/
NzTimeValueAccessorDirective.prototype.setRange = /**
* @return {?}
*/
function () {
this.elementRef.nativeElement.focus();
this.elementRef.nativeElement.setSelectionRange(0, this.elementRef.nativeElement.value.length);
};
/**
* @param {?} value
* @return {?}
*/
NzTimeValueAccessorDirective.prototype.writeValue = /**
* @param {?} value
* @return {?}
*/
function (value) {
this.elementRef.nativeElement.value = this.dateHelper.format(value, this.nzTime);
};
/**
* @param {?} fn
* @return {?}
*/
NzTimeValueAccessorDirective.prototype.registerOnChange = /**
* @param {?} fn
* @return {?}
*/
function (fn) {
this._onChange = fn;
};
/**
* @param {?} fn
* @return {?}
*/
NzTimeValueAccessorDirective.prototype.registerOnTouched = /**
* @param {?} fn
* @return {?}
*/
function (fn) {
this._onTouch = fn;
};
NzTimeValueAccessorDirective.decorators = [
{ type: core.Directive, args: [{
selector: 'input[nzTime]',
exportAs: 'nzTime',
providers: [{ provide: forms.NG_VALUE_ACCESSOR, useExisting: NzTimeValueAccessorDirective, multi: true }]
},] }
];
/** @nocollapse */
NzTimeValueAccessorDirective.ctorParameters = function () { return [
{ type: i18n.DateHelperService },
{ type: core.ElementRef }
]; };
NzTimeValueAccessorDirective.propDecorators = {
nzTime: [{ type: core.Input }],
keyup: [{ type: core.HostListener, args: ['keyup',] }],
blur: [{ type: core.HostListener, args: ['blur',] }]
};
return NzTimeValueAccessorDirective;
}());
if (false) {
/**
* @type {?}
* @private
*/
NzTimeValueAccessorDirective.prototype._onChange;
/**
* @type {?}
* @private
*/
NzTimeValueAccessorDirective.prototype._onTouch;
/** @type {?} */
NzTimeValueAccessorDirective.prototype.nzTime;
/**
* @type {?}
* @private
*/
NzTimeValueAccessorDirective.prototype.dateHelper;
/**
* @type {?}
* @private
*/
NzTimeValueAccessorDirective.prototype.elementRef;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var TimeHolder = /** @class */ (function () {
function TimeHolder() {
this._seconds = undefined;
this._hours = undefined;
this._minutes = undefined;
this._selected12Hours = undefined;
this._use12Hours = false;
this._defaultOpenValue = new Date();
this._changes = new rxjs.Subject();
}
/**
* @return {?}
*/
TimeHolder.prototype.setDefaultValueIfNil = /**
* @return {?}
*/
function () {
if (!core$1.isNotNil(this._value)) {
this._value = new Date(this.defaultOpenValue);
}
};
/**
* @template THIS
* @this {THIS}
* @param {?} value
* @param {?} disabled
* @return {THIS}
*/
TimeHolder.prototype.setMinutes = /**
* @template THIS
* @this {THIS}
* @param {?} value
* @param {?} disabled
* @return {THIS}
*/
function (value, disabled) {
if (disabled) {
return (/** @type {?} */ (this));
}
(/** @type {?} */ (this)).setDefaultValueIfNil();
(/** @type {?} */ (this)).minutes = value;
return (/** @type {?} */ (this));
};
/**
* @template THIS
* @this {THIS}
* @param {?} value
* @param {?} disabled
* @return {THIS}
*/
TimeHolder.prototype.setHours = /**
* @template THIS
* @this {THIS}
* @param {?} value
* @param {?} disabled
* @return {THIS}
*/
function (value, disabled) {
if (disabled) {
return (/** @type {?} */ (this));
}
(/** @type {?} */ (this)).setDefaultValueIfNil();
(/** @type {?} */ (this)).hours = value;
return (/** @type {?} */ (this));
};
/**
* @template THIS
* @this {THIS}
* @param {?} value
* @param {?} disabled
* @return {THIS}
*/
TimeHolder.prototype.setSeconds = /**
* @template THIS
* @this {THIS}
* @param {?} value
* @param {?} disabled
* @return {THIS}
*/
function (value, disabled) {
if (disabled) {
return (/** @type {?} */ (this));
}
(/** @type {?} */ (this)).setDefaultValueIfNil();
(/** @type {?} */ (this)).seconds = value;
return (/** @type {?} */ (this));
};
/**
* @template THIS
* @this {THIS}
* @param {?} value
* @return {THIS}
*/
TimeHolder.prototype.setUse12Hours = /**
* @template THIS
* @this {THIS}
* @param {?} value
* @return {THIS}
*/
function (value) {
(/** @type {?} */ (this))._use12Hours = value;
return (/** @type {?} */ (this));
};
Object.defineProperty(TimeHolder.prototype, "changes", {
get: /**
* @return {?}
*/
function () {
return this._changes.asObservable();
},
enumerable: true,
configurable: true
});
Object.defineProperty(TimeHolder.prototype, "value", {
get: /**
* @return {?}
*/
function () {
return this._value;
},
set: /**
* @param {?} value
* @return {?}
*/
function (value) {
if (value !== this._value) {
this._value = value;
if (core$1.isNotNil(this._value)) {
this._hours = (/** @type {?} */ (this._value)).getHours();
this._minutes = (/** @type {?} */ (this._value)).getMinutes();
this._seconds = (/** @type {?} */ (this._value)).getSeconds();
if (this._use12Hours && core$1.isNotNil(this._hours)) {
this._selected12Hours = this._hours >= 12 ? 'PM' : 'AM';
}
}
else {
this._clear();
}
}
},
enumerable: true,
configurable: true
});
/**
* @template THIS
* @this {THIS}
* @param {?} value
* @param {?=} use12Hours
* @return {THIS}
*/
TimeHolder.prototype.setValue = /**
* @template THIS
* @this {THIS}
* @param {?} value
* @param {?=} use12Hours
* @return {THIS}
*/
function (value, use12Hours) {
if (core$1.isNotNil(use12Hours)) {
(/** @type {?} */ (this))._use12Hours = (/** @type {?} */ (use12Hours));
}
(/** @type {?} */ (this)).value = value;
return (/** @type {?} */ (this));
};
/**
* @return {?}
*/
TimeHolder.prototype.clear = /**
* @return {?}
*/
function () {
this._clear();
this.update();
};
Object.defineProperty(TimeHolder.prototype, "isEmpty", {
get: /**
* @return {?}
*/
function () {
return !(core$1.isNotNil(this._hours) || core$1.isNotNil(this._minutes) || core$1.isNotNil(this._seconds));
},
enumerable: true,
configurable: true
});
/**
* @private
* @return {?}
*/
TimeHolder.prototype._clear = /**
* @private
* @return {?}
*/
function () {
this._hours = undefined;
this._minutes = undefined;
this._seconds = undefined;
this._selected12Hours = undefined;
};
/**
* @private
* @return {?}
*/
TimeHolder.prototype.update = /**
* @private
* @return {?}
*/
function () {
if (this.isEmpty) {
this._value = undefined;
}
else {
if (!core$1.isNotNil(this._hours)) {
this._hours = this.defaultHours;
}
else {
(/** @type {?} */ (this._value)).setHours((/** @type {?} */ (this.hours)));
}
if (!core$1.isNotNil(this._minutes)) {
this._minutes = this.defaultMinutes;
}
else {
(/** @type {?} */ (this._value)).setMinutes((/** @type {?} */ (this.minutes)));
}
if (!core$1.isNotNil(this._seconds)) {
this._seconds = this.defaultSeconds;
}
else {
(/** @type {?} */ (this._value)).setSeconds((/** @type {?} */ (this.seconds)));
}
if (this._use12Hours) {
if (!core$1.isNotNil(this._selected12Hours)) {
this._selected12Hours = this.default12Hours;
}
if (this.selected12Hours === 'PM' && (/** @type {?} */ (this._hours)) < 12) {
(/** @type {?} */ (this._hours)) += 12;
(/** @type {?} */ (this._value)).setHours((/** @type {?} */ (this._hours)));
}
if (this.selected12Hours === 'AM' && (/** @type {?} */ (this._hours)) >= 12) {
(/** @type {?} */ (this._hours)) -= 12;
(/** @type {?} */ (this._value)).setHours((/** @type {?} */ (this._hours)));
}
}
this._value = new Date((/** @type {?} */ (this._value)));
}
this.changed();
};
/**
* @return {?}
*/
TimeHolder.prototype.changed = /**
* @return {?}
*/
function () {
this._changes.next(this._value);
};
Object.defineProperty(TimeHolder.prototype, "viewHours", {
/**
* @description
* UI view hours
* Get viewHours which is selected in `time-picker-panel` and its range is [12, 1, 2, ..., 11]
*/
get: /**
* \@description
* UI view hours
* Get viewHours which is selected in `time-picker-panel` and its range is [12, 1, 2, ..., 11]
* @return {?}
*/
function () {
return this._use12Hours && core$1.isNotNil(this._hours) ? this.calculateViewHour((/** @type {?} */ (this._hours))) : this._hours;
},
enumerable: true,
configurable: true
});
Object.defineProperty(TimeHolder.prototype, "realHours", {
/**
* @description
* Value hours
* Get realHours and its range is [0, 1, 2, ..., 22, 23]
*/
get: /**
* \@description
* Value hours
* Get realHours and its range is [0, 1, 2, ..., 22, 23]
* @return {?}
*/
function () {
return this._hours;
},
enumerable: true,
configurable: true
});
Object.defineProperty(TimeHolder.prototype, "hours", {
/**
* @description
* Same as realHours
* @see realHours
*/
get: /**
* \@description
* Same as realHours
* @see realHours
* @return {?}
*/
function () {
return this._hours;
},
/**
* @description
* Set viewHours to realHours
*/
set: /**
* \@description
* Set viewHours to realHours
* @param {?} value
* @return {?}
*/
function (value) {
if (value !== this._hours) {
if (this._use12Hours) {
if (this.selected12Hours === 'PM' && value !== 12) {
(/** @type {?} */ (this._hours)) = ((/** @type {?} */ (value))) + 12;
}
else if (this.selected12Hours === 'AM' && value === 12) {
this._hours = 0;
}
else {
this._hours = value;
}
}
else {
this._hours = value;
}
this.update();
}
},
enumerable: true,
configurable: true
});
Object.defineProperty(TimeHolder.prototype, "minutes", {
get: /**
* @return {?}
*/
function () {
return this._minutes;
},
set: /**
* @param {?} value
* @return {?}
*/
function (value) {
if (value !== this._minutes) {
this._minutes = value;
this.update();
}
},
enumerable: true,
configurable: true
});
Object.defineProperty(TimeHolder.prototype, "seconds", {
get: /**
* @return {?}
*/
function () {
return this._seconds;
},
set: /**
* @param {?} value
* @return {?}
*/
function (value) {
if (value !== this._seconds) {
this._seconds = value;
this.update();
}
},
enumerable: true,
configurable: true
});
Object.defineProperty(TimeHolder.prototype, "selected12Hours", {
get: /**
* @return {?}
*/
function () {
return this._selected12Hours;
},
set: /**
* @param {?} value
* @return {?}
*/
function (value) {
if ((/** @type {?} */ (value)).toUpperCase() !== this._selected12Hours) {
this._selected12Hours = (/** @type {?} */ (value)).toUpperCase();
this.update();
}
},
enumerable: true,
configurable: true
});
Object.defineProperty(TimeHolder.prototype, "defaultOpenValue", {
get: /**
* @return {?}
*/
function () {
return this._defaultOpenValue;
},
set: /**
* @param {?} value
* @return {?}
*/
function (value) {
if (this._defaultOpenValue !== value) {
this._defaultOpenValue = value;
this.update();
}
},
enumerable: true,
configurable: true
});
/**
* @template THIS
* @this {THIS}
* @param {?} value
* @return {THIS}
*/
TimeHolder.prototype.setDefaultOpenValue = /**
* @template THIS
* @this {THIS}
* @param {?} value
* @return {THIS}
*/
function (value) {
(/** @type {?} */ (this)).defaultOpenValue = value;
return (/** @type {?} */ (this));
};
Object.defineProperty(TimeHolder.prototype, "defaultViewHours", {
/**
* @description
* Get deafultViewHours when defaultOpenValue is setted
* @see viewHours
*/
get: /**
* \@description
* Get deafultViewHours when defaultOpenValue is setted
* @see viewHours
* @return {?}
*/
function () {
/** @type {?} */
var hours = this._defaultOpenValue.getHours();
return this._use12Hours && core$1.isNotNil(hours) ? this.calculateViewHour(hours) : hours;
},
enumerable: true,
configurable: true
});
Object.defineProperty(TimeHolder.prototype, "defaultRealHours", {
/**
* @description
* Get defaultRealHours when defaultOpenValue is setted
* @see realHours
*/
get: /**
* \@description
* Get defaultRealHours when defaultOpenValue is setted
* @see realHours
* @return {?}
*/
function () {
return this._defaultOpenValue.getHours();
},
enumerable: true,
configurable: true
});
Object.defineProperty(TimeHolder.prototype, "defaultHours", {
/**
* @description
* Same as defaultRealHours
*/
get: /**
* \@description
* Same as defaultRealHours
* @return {?}
*/
function () {
return this._defaultOpenValue.getHours();
},
enumerable: true,
configurable: true
});
Object.defineProperty(TimeHolder.prototype, "defaultMinutes", {
get: /**
* @return {?}
*/
function () {
return this._defaultOpenValue.getMinutes();
},
enumerable: true,
configurable: true
});
Object.defineProperty(TimeHolder.prototype, "defaultSeconds", {
get: /**
* @return {?}
*/
function () {
return this._defaultOpenValue.getSeconds();
},
enumerable: true,
configurable: true
});
Object.defineProperty(TimeHolder.prototype, "default12Hours", {
get: /**
* @return {?}
*/
function () {
return this._defaultOpenValue.getHours() >= 12 ? 'PM' : 'AM';
},
enumerable: true,
configurable: true
});
/**
* @private
* @param {?} value
* @return {?}
*/
TimeHolder.prototype.calculateViewHour = /**
* @private
* @param {?} value
* @return {?}
*/
function (value) {
/** @type {?} */
var selected12Hours = this._selected12Hours || this.default12Hours;
if (selected12Hours === 'PM' && value > 12) {
return value - 12;
}
if (selected12Hours === 'AM' && value === 0) {
return 12;
}
return value;
};
return TimeHolder;
}());
if (false) {
/**
* @type {?}
* @private
*/
TimeHolder.prototype._seconds;
/**
* @type {?}
* @private
*/
TimeHolder.prototype._hours;
/**
* @type {?}
* @private
*/
TimeHolder.prototype._minutes;
/**
* @type {?}
* @private
*/
TimeHolder.prototype._selected12Hours;
/**
* @type {?}
* @private
*/
TimeHolder.prototype._use12Hours;
/**
* @type {?}
* @private
*/
TimeHolder.prototype._defaultOpenValue;
/**
* @type {?}
* @private
*/
TimeHolder.prototype._value;
/**
* @type {?}
* @private
*/
TimeHolder.prototype._changes;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/**
* @param {?} length
* @param {?=} step
* @param {?=} start
* @return {?}
*/
function makeRange(length, step, start) {
if (step === void 0) { step = 1; }
if (start === void 0) { start = 0; }
return new Array(Math.ceil(length / step)).fill(0).map((/**
* @param {?} _
* @param {?} i
* @return {?}
*/