@logo-software/timepicker
Version:
Timepicker helps users select and set a specific time in your timesheet in 24-hour format.
825 lines (817 loc) • 57.4 kB
JavaScript
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/forms'), require('@logo-software/popover'), require('@angular/common'), require('moment')) :
typeof define === 'function' && define.amd ? define('@logo-software/timepicker', ['exports', '@angular/core', '@angular/forms', '@logo-software/popover', '@angular/common', 'moment'], factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global["logo-software"] = global["logo-software"] || {}, global["logo-software"].timepicker = {}), global.ng.core, global.ng.forms, global.popover, global.ng.common, global.momentNs));
})(this, (function (exports, core, forms, popover, common, momentNs) { 'use strict';
function _interopNamespace(e) {
if (e && e.__esModule) return e;
var n = Object.create(null);
if (e) {
Object.keys(e).forEach(function (k) {
if (k !== 'default') {
var d = Object.getOwnPropertyDescriptor(e, k);
Object.defineProperty(n, k, d.get ? d : {
enumerable: true,
get: function () { return e[k]; }
});
}
});
}
n["default"] = e;
return Object.freeze(n);
}
var momentNs__namespace = /*#__PURE__*/_interopNamespace(momentNs);
/**
* @license
* Copyright LOGO YAZILIM SANAYİ VE TİCARET A.Ş. All Rights Reserved.
*
* Save to the extent permitted by law, you may not use, copy, modify,
* distribute or create derivative works of this material or any part
* of it without the prior written consent of LOGO YAZILIM SANAYİ VE TİCARET A.Ş. Limited.
* Any reproduction of this material must contain this notice.
*/
/**
* IconPosition sets the clock icon position on the input. Default is left.
*/
exports.IconPosition = void 0;
(function (IconPosition) {
IconPosition["ICON_LEFT"] = "left";
IconPosition["ICON_RIGHT"] = "right";
IconPosition["ICON_DEFAULT"] = "left";
})(exports.IconPosition || (exports.IconPosition = {}));
/**
* Set the sizes of the input. Default is medium.
*/
exports.Sizes = void 0;
(function (Sizes) {
Sizes["LARGE"] = "large";
Sizes["MEDIUM"] = "medium";
Sizes["SMALL"] = "small";
Sizes["DEFAULT"] = "medium";
})(exports.Sizes || (exports.Sizes = {}));
/**
* The Timepicker is the component of itself. Provides a proxy to Timepicker options as well as custom picker options.
* Add the below code to your code stack and give initializer parameters.
*
* <sub>app.component.html</sub>
*
* ```html
* <logo-timepicker
* [id]="'myLogoTimer'"
* [(ngModel)]="setTime"
* [size]="'medium'"
* [iconPosition]="'left'"
* [cssClasses]="'my-own-theme-css'"
* >
* </logo-timepicker>
* ```
*/
var TimepickerComponent = /** @class */ (function () {
function TimepickerComponent(popoverService) {
var _this = this;
this.popoverService = popoverService;
/**
* The size of the timepicker. It accepts Sizes enum.
*/
this.size = exports.Sizes.DEFAULT;
/**
* The position of the clock icon. It accepts IconPosition enum.
*/
this.iconPosition = exports.IconPosition.ICON_DEFAULT;
/**
* Set disabled status of the element
*/
this.isDisabled = false;
this.hours = [];
this.minutes = [];
this.selectedHour = '00';
this.selectedMinute = '00';
this.time = null;
this.ngModelChange = new core.EventEmitter();
this.onChange = new core.EventEmitter();
this.PopoverPosition = popover.PopoverPosition;
this.hours = Array.from({ length: 24 }, function (x, i) { return i < 10 ? '0' + i : '' + i; });
this.minutes = Array.from({ length: 60 }, function (x, i) { return i < 10 ? '0' + i : '' + i; });
if (!this.subscribtion) {
this.subscribtion = this.popoverService.openWatcher.subscribe(function (status) {
if (!status) {
_this.setInputTime(_this.ngModel);
}
});
}
}
Object.defineProperty(TimepickerComponent.prototype, "ngModel", {
get: function () {
return this._ngModel;
},
/**
* Set model
*/
set: function (value) {
this._ngModel = value.trim();
this.setInputTime(value);
},
enumerable: false,
configurable: true
});
TimepickerComponent.prototype.onResize = function (event) {
this.popoverService.closePopover();
};
TimepickerComponent.prototype.ngOnDestroy = function () {
this.subscribtion.unsubscribe();
};
TimepickerComponent.prototype.setInputTime = function (value) {
var split = value.trim().split(':');
this.selectedHour = split[0];
this.selectedMinute = split[1];
this.setTime();
};
/**
* This function shows the clock selection popover
*/
TimepickerComponent.prototype.showClockSelector = function () {
this.popoverService.showPopover('timePopover-' + this.id);
};
/**
* This function closes the clock selection popover
*/
TimepickerComponent.prototype.closeClockSelector = function () {
this.popoverService.closePopover();
};
/**
* This function sets the hour of the clock
*/
TimepickerComponent.prototype.setHour = function ($event) {
this.selectedHour = $event.target.value;
this.setTime();
};
/**
* This function sets the minutes of the clock
*/
TimepickerComponent.prototype.setMin = function ($event) {
this.selectedMinute = $event.target.value;
this.setTime();
};
/**
* This function sets the certain time with setted hours and minutes.
*/
TimepickerComponent.prototype.setTime = function () {
this.time = this.selectedHour + ':' + this.selectedMinute;
};
/**
* This function handles the writing of the input
*/
TimepickerComponent.prototype.handleWriteTime = function ($event) {
var findTime = $event.target.value.split(':', 2);
findTime[0] === undefined || findTime[0].length < 2 ? this.selectedHour = '00' : this.selectedHour = findTime[0];
findTime[1] === undefined || findTime[1].length < 2 ? this.selectedMinute = '00' : this.selectedMinute = findTime[1];
};
TimepickerComponent.prototype.apply = function () {
this.ngModelChange.emit(this.time);
this.onChange.emit(this.time);
this.popoverService.closePopover();
};
TimepickerComponent.prototype.registerOnChange = function (fn) {
};
TimepickerComponent.prototype.registerOnTouched = function (fn) {
};
TimepickerComponent.prototype.writeValue = function (obj) {
};
TimepickerComponent.prototype.setDisabledState = function (isDisabled) {
};
return TimepickerComponent;
}());
TimepickerComponent.decorators = [
{ type: core.Component, args: [{
selector: 'logo-timepicker',
template: "<div class=\"logo-timepicker {{cssClasses}}\">\n <div class=\"input-w-icon {{iconPosition}} {{size}}\">\n <span class=\"le-time_clock_circle_2\"></span>\n <input\n [logoPopover]=\"'timePopover-' + id\"\n (keyup)=\"handleWriteTime($event)\"\n [ngModel]=\"time\"\n [placeholder]=\"'00:00'\"\n [regexp]=\"'^[0-2]{1}$|^[0-2]{1}[0-9]{1}$|^[0-2]{1}[0-9]{1}[0-5]{1}$|^[0-2]{1}[0-9]{1}[0-5]{1}[0-9]{1}$'\"\n [value]=\"time != null ? time : ''\"\n [disabled]=\"isDisabled\"\n class=\"icon-{{iconPosition}} bordered {{size}}\"\n id=\"{{id}}\"\n logoMask\n />\n </div>\n <logo-popover\n [hasSearch]=\"false\"\n [id]=\"'timePopover-' + id\"\n [isBackClick]=\"false\"\n [position]=\"PopoverPosition.POPOVER_BOTTOM_LEFT\"\n >\n <div class=\"selection-input\">\n <div class=\"selection\">\n <select (change)=\"setHour($event)\" [(ngModel)]=\"selectedHour\" class=\"popoverSelect\" id=\"{{id}}Hours\">\n <option *ngFor=\"let hour of hours\" [value]=\"hour\">{{hour}}</option>\n </select>\n </div>\n <div>:</div>\n <div class=\"selection\">\n <select (change)=\"setMin($event)\" [(ngModel)]=\"selectedMinute\" class=\"popoverSelect\" id=\"{{id}}Mins\">\n <option *ngFor=\"let min of minutes\" [value]=\"min\">{{min}}</option>\n </select>\n </div>\n </div>\n <div class=\"btn-area\">\n <button (click)=\"apply()\" class=\"approve-btn\">Uygula</button>\n </div>\n </logo-popover>\n</div>\n",
providers: [{
provide: forms.NG_VALUE_ACCESSOR,
useExisting: core.forwardRef(function () { return TimepickerComponent; }),
multi: true,
}],
styles: [".dotted{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.logo-tooltip .tip.on-bottom:after,.logo-tooltip .tip.on-top:after{border-left:7px solid transparent;border-right:7px solid transparent}.logo-tooltip .tip.on-left:after,.logo-tooltip .tip.on-right:after{border-top:7px solid transparent;border-bottom:7px solid transparent}.logo-tooltip{position:relative;color:#e94a34;cursor:pointer}.logo-tooltip .tip{position:absolute;width:180px;color:#fff;font-size:14px;font-style:normal;line-height:1.4;text-align:center;border-radius:3px;background:#333;padding:8px 12px;box-sizing:border-box;cursor:auto;z-index:10;opacity:0;visibility:hidden;transition:all .25s ease-in}.logo-tooltip .tip:after{position:absolute;width:0;height:0;content:\"\"}.logo-tooltip .tip.on-top{bottom:25px;left:0}.logo-tooltip .tip.on-top:after{bottom:-7px;left:10px;border-top:7px solid #333}.logo-tooltip .tip.on-right{top:-5px;left:103%}.logo-tooltip .tip.on-right:after{top:37%;left:-7px;border-right:7px solid #333}.logo-tooltip .tip.on-bottom{top:25px;left:0}.logo-tooltip .tip.on-bottom:after{top:-7px;left:10px;border-bottom:7px solid #333}.logo-tooltip .tip.on-left{top:-100%;right:103%}.logo-tooltip .tip.on-left:after{top:37%;right:-7px;border-left:7px solid #333}.logo-tooltip:hover .tip{opacity:1;visibility:visible}.logo-tooltip:hover .tip.on-top{transform:translateY(-15px)}.logo-tooltip:hover .tip.on-right{transform:translateX(15px)}.logo-tooltip:hover .tip.on-bottom{transform:translateY(15px)}.logo-tooltip:hover .tip.on-left{transform:translateX(-15px)}.test{content:\"a\";content:\"ba\";content:\"aa\";content:\"aade\";content:\"abde\"}:root .basic,:root .gray,:root .secondary{color:var(--leds-contrast-90pct)}:root .danger,:root .info,:root .success,:root .warning{color:var(--white)}:root .outline.primary,:root .outline.primary:active,:root .outline.primary:focus,:root .outline.primary:hover{border-color:var(--light-600)}:root .outline.primary:hover{background-color:rgba(var(--neutral-500-rgb),var(--ghost-hover));color:var(--primary)}:root .outline.primary:active{background-color:rgba(var(--neutral-500-rgb),var(--ghost-active));color:var(--primary)}:root .outline.primary:focus{background-color:rgba(var(--neutral-500-rgb),var(--ghost-focus));color:var(--primary)}:root .outline.secondary{color:var(--leds-contrast-90pct)}:root .outline.secondary,:root .outline.secondary:active,:root .outline.secondary:focus,:root .outline.secondary:hover{border-color:var(--light-600)}:root .outline.secondary:hover{background-color:rgba(var(--neutral-500-rgb),var(--ghost-hover));color:var(--leds-contrast-90pct)}:root .outline.secondary:active{background-color:rgba(var(--neutral-500-rgb),var(--ghost-active));color:var(--leds-contrast-90pct)}:root .outline.secondary:focus{background-color:rgba(var(--neutral-500-rgb),var(--ghost-focus));color:var(--leds-contrast-90pct)}:root .outline.basic{color:var(--leds-contrast-90pct)}:root .outline.basic,:root .outline.basic:active,:root .outline.basic:focus,:root .outline.basic:hover{border-color:var(--light-600)}:root .outline.basic:hover{background-color:rgba(var(--neutral-500-rgb),var(--ghost-hover));color:var(--leds-contrast-90pct)}:root .outline.basic:active{background-color:rgba(var(--neutral-500-rgb),var(--ghost-active));color:var(--leds-contrast-90pct)}:root .outline.basic:focus{background-color:rgba(var(--neutral-500-rgb),var(--ghost-focus));color:var(--leds-contrast-90pct)}:root .outline.neutral,:root .outline.neutral:active,:root .outline.neutral:focus,:root .outline.neutral:hover{border-color:var(--light-600)}:root .outline.neutral:hover{background-color:rgba(var(--neutral-500-rgb),var(--ghost-hover));color:var(--neutral)}:root .outline.neutral:active{background-color:rgba(var(--neutral-500-rgb),var(--ghost-active));color:var(--neutral)}:root .outline.neutral:focus{background-color:rgba(var(--neutral-500-rgb),var(--ghost-focus));color:var(--neutral)}:root .outline.light{border-color:rgba(var(--light-rgb),.5)}:root .outline.light:active,:root .outline.light:focus,:root .outline.light:hover{border-color:var(--light)}:root .outline.light:hover{background-color:rgba(var(--neutral-500-rgb),var(--ghost-hover));color:var(--white)}:root .outline.light:active{background-color:rgba(var(--neutral-500-rgb),var(--ghost-active));color:var(--white)}:root .outline.light:focus{background-color:rgba(var(--neutral-500-rgb),var(--ghost-focus));color:var(--white)}:root .outline.dark,:root .outline.dark:active,:root .outline.dark:focus,:root .outline.dark:hover{border-color:var(--light-600)}:root .outline.dark:hover{background-color:rgba(var(--neutral-500-rgb),var(--ghost-hover));color:var(--dark)}:root .outline.dark:active{background-color:rgba(var(--neutral-500-rgb),var(--ghost-active));color:var(--dark)}:root .outline.dark:focus{background-color:rgba(var(--neutral-500-rgb),var(--ghost-focus));color:var(--dark)}:root .outline.gray{color:var(--leds-contrast-90pct)}:root .outline.gray,:root .outline.gray:active,:root .outline.gray:focus,:root .outline.gray:hover{border-color:var(--light-600)}:root .outline.gray:hover{background-color:rgba(var(--neutral-500-rgb),var(--ghost-hover));color:var(--leds-contrast-90pct)}:root .outline.gray:active{background-color:rgba(var(--neutral-500-rgb),var(--ghost-active));color:var(--leds-contrast-90pct)}:root .outline.gray:focus{background-color:rgba(var(--neutral-500-rgb),var(--ghost-focus));color:var(--leds-contrast-90pct)}:root .outline.info{color:var(--info)}:root .outline.info,:root .outline.info:active,:root .outline.info:focus,:root .outline.info:hover{border-color:var(--light-600)}:root .outline.info:hover{background-color:rgba(var(--neutral-500-rgb),var(--ghost-hover));color:var(--info)}:root .outline.info:active{background-color:rgba(var(--neutral-500-rgb),var(--ghost-active));color:var(--info)}:root .outline.info:focus{background-color:rgba(var(--neutral-500-rgb),var(--ghost-focus));color:var(--info)}:root .outline.danger{color:var(--danger)}:root .outline.danger,:root .outline.danger:active,:root .outline.danger:focus,:root .outline.danger:hover{border-color:var(--light-600)}:root .outline.danger:hover{background-color:rgba(var(--neutral-500-rgb),var(--ghost-hover));color:var(--danger)}:root .outline.danger:active{background-color:rgba(var(--neutral-500-rgb),var(--ghost-active));color:var(--danger)}:root .outline.danger:focus{background-color:rgba(var(--neutral-500-rgb),var(--ghost-focus));color:var(--danger)}:root .outline.warning{color:var(--warning)}:root .outline.warning,:root .outline.warning:active,:root .outline.warning:focus,:root .outline.warning:hover{border-color:var(--light-600)}:root .outline.warning:hover{background-color:rgba(var(--neutral-500-rgb),var(--ghost-hover));color:var(--warning)}:root .outline.warning:active{background-color:rgba(var(--neutral-500-rgb),var(--ghost-active));color:var(--warning)}:root .outline.warning:focus{background-color:rgba(var(--neutral-500-rgb),var(--ghost-focus));color:var(--warning)}:root .outline.success{color:var(--success)}:root .outline.success,:root .outline.success:active,:root .outline.success:focus,:root .outline.success:hover{border-color:var(--light-600)}:root .outline.success:hover{background-color:rgba(var(--neutral-500-rgb),var(--ghost-hover));color:var(--success)}:root .outline.success:active{background-color:rgba(var(--neutral-500-rgb),var(--ghost-active));color:var(--success)}:root .outline.success:focus{background-color:rgba(var(--neutral-500-rgb),var(--ghost-focus));color:var(--success)}:root .ghost.primary:hover{background-color:rgba(var(--neutral-500-rgb),var(--ghost-hover));color:var(--primary)}:root .ghost.primary:active{background-color:rgba(var(--neutral-500-rgb),var(--ghost-active));color:var(--primary)}:root .ghost.primary:focus{background-color:rgba(var(--neutral-500-rgb),var(--ghost-focus));color:var(--primary)}:root .ghost.secondary,:root .ghost.secondary:hover{color:var(--leds-contrast-90pct)}:root .ghost.secondary:hover{background-color:rgba(var(--neutral-500-rgb),var(--ghost-hover))}:root .ghost.secondary:active{background-color:rgba(var(--neutral-500-rgb),var(--ghost-active));color:var(--leds-contrast-90pct)}:root .ghost.secondary:focus{background-color:rgba(var(--neutral-500-rgb),var(--ghost-focus))}:root .ghost.basic,:root .ghost.basic:hover,:root .ghost.secondary:focus{color:var(--leds-contrast-90pct)}:root .ghost.basic:hover{background-color:rgba(var(--neutral-500-rgb),var(--ghost-hover))}:root .ghost.basic:active{background-color:rgba(var(--neutral-500-rgb),var(--ghost-active));color:var(--leds-contrast-90pct)}:root .ghost.basic:focus{background-color:rgba(var(--neutral-500-rgb),var(--ghost-focus));color:var(--leds-contrast-90pct)}:root .ghost.neutral:hover{background-color:rgba(var(--neutral-500-rgb),var(--ghost-hover));color:var(--neutral)}:root .ghost.neutral:active{background-color:rgba(var(--neutral-500-rgb),var(--ghost-active));color:var(--neutral)}:root .ghost.neutral:focus{background-color:rgba(var(--neutral-500-rgb),var(--ghost-focus));color:var(--neutral)}:root .ghost.light:hover{background-color:rgba(var(--neutral-500-rgb),var(--ghost-hover));color:var(--white)}:root .ghost.light:active{background-color:rgba(var(--neutral-500-rgb),var(--ghost-active));color:var(--white)}:root .ghost.light:focus{background-color:rgba(var(--neutral-500-rgb),var(--ghost-focus));color:var(--white)}:root .ghost.dark:hover{background-color:rgba(var(--neutral-500-rgb),var(--ghost-hover));color:var(--dark)}:root .ghost.dark:active{background-color:rgba(var(--neutral-500-rgb),var(--ghost-active));color:var(--dark)}:root .ghost.dark:focus{background-color:rgba(var(--neutral-500-rgb),var(--ghost-focus));color:var(--dark)}:root .ghost.gray,:root .ghost.gray:hover{color:var(--leds-contrast-90pct)}:root .ghost.gray:hover{background-color:rgba(var(--neutral-500-rgb),var(--ghost-hover))}:root .ghost.gray:active{background-color:rgba(var(--neutral-500-rgb),var(--ghost-active));color:var(--leds-contrast-90pct)}:root .ghost.gray:focus{background-color:rgba(var(--neutral-500-rgb),var(--ghost-focus));color:var(--leds-contrast-90pct)}:root .ghost.info{color:var(--info)}:root .ghost.info:hover{background-color:rgba(var(--neutral-500-rgb),var(--ghost-hover));color:var(--info)}:root .ghost.info:active{background-color:rgba(var(--neutral-500-rgb),var(--ghost-active));color:var(--info)}:root .ghost.info:focus{background-color:rgba(var(--neutral-500-rgb),var(--ghost-focus));color:var(--info)}:root .ghost.danger{color:var(--danger)}:root .ghost.danger:hover{background-color:rgba(var(--neutral-500-rgb),var(--ghost-hover));color:var(--danger)}:root .ghost.danger:active{background-color:rgba(var(--neutral-500-rgb),var(--ghost-active));color:var(--danger)}:root .ghost.danger:focus{background-color:rgba(var(--neutral-500-rgb),var(--ghost-focus));color:var(--danger)}:root .ghost.warning{color:var(--warning)}:root .ghost.warning:hover{background-color:rgba(var(--neutral-500-rgb),var(--ghost-hover));color:var(--warning)}:root .ghost.warning:active{background-color:rgba(var(--neutral-500-rgb),var(--ghost-active));color:var(--warning)}:root .ghost.warning:focus{background-color:rgba(var(--neutral-500-rgb),var(--ghost-focus));color:var(--warning)}:root .ghost.success{color:var(--success)}:root .ghost.success:hover{background-color:rgba(var(--neutral-500-rgb),var(--ghost-hover));color:var(--success)}:root .ghost.success:active{background-color:rgba(var(--neutral-500-rgb),var(--ghost-active));color:var(--success)}:root .ghost.success:focus{background-color:rgba(var(--neutral-500-rgb),var(--ghost-focus));color:var(--success)}[class*=\" le-\"],[class^=le-]{position:relative}[class*=\" le-\"]:before,[class^=le-]:before{height:100%;top:0;-webkit-mask-size:14px;mask-size:14px}.le-time_clock_circle_2:before{-webkit-mask-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg width='24' height='24' viewBox='0 0 24 24' fill='currentColor' xmlns='http://www.w3.org/2000/svg'%3E %3Cg id='time_clock_circle_2'%3E %3Cpath id='Shape' fill-rule='evenodd' clip-rule='evenodd' d='M12 2C6.47715 2 2 6.47715 2 12C2 17.5228 6.47715 22 12 22C17.5228 22 22 17.5228 22 12C21.994 6.47963 17.5204 2.00597 12 2ZM16.3333 16.3508C16.0192 16.6833 15.4979 16.7061 15.1558 16.4025L11.0233 12.6142C10.85 12.4569 10.7508 12.234 10.75 12V7.41667C10.75 6.95643 11.1231 6.58333 11.5833 6.58333C12.0436 6.58333 12.4167 6.95643 12.4167 7.41667V11.6333L16.2783 15.1733C16.4421 15.3222 16.5399 15.5301 16.5502 15.7511C16.5605 15.9721 16.4825 16.1882 16.3333 16.3517V16.3508Z' fill='%235A5A5A'/%3E %3C/g%3E %3C/svg%3E\");-webkit-mask-repeat:no-repeat;-webkit-mask-position:center;display:inline-block;content:\"\";position:absolute;background:currentColor}:host{display:inline-block}:host logo-popover{width:100%}:host ::ng-deep .selection-input{display:flex;width:160px;align-items:center;justify-content:space-between}:host ::ng-deep .selection-input .selection{width:40%;text-align:center}:host ::ng-deep .selection-input .selection select{width:100%}:host ::ng-deep .selection-input .selection:last-child{position:relative;z-index:1}:host ::ng-deep .btn-area{text-align:center;margin-top:10px}:host ::ng-deep .btn-area button{width:100%}"]
},] }
];
TimepickerComponent.ctorParameters = function () { return [
{ type: popover.PopoverService }
]; };
TimepickerComponent.propDecorators = {
id: [{ type: core.Input }],
size: [{ type: core.Input }],
iconPosition: [{ type: core.Input }],
cssClasses: [{ type: core.Input }],
isDisabled: [{ type: core.Input }],
ngModelChange: [{ type: core.Output }],
onChange: [{ type: core.Output }],
ngModel: [{ type: core.Input }],
onResize: [{ type: core.HostListener, args: ['window:resize', ['$event'],] }]
};
/******************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */
/* 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 (Object.prototype.hasOwnProperty.call(b, p))
d[p] = b[p]; };
return extendStatics(d, b);
};
function __extends(d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
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) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
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) : adopt(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 };
}
}
var __createBinding = Object.create ? (function (o, m, k, k2) {
if (k2 === undefined)
k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function () { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function (o, m, k, k2) {
if (k2 === undefined)
k2 = k;
o[k2] = m[k];
});
function __exportStar(m, o) {
for (var p in m)
if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p))
__createBinding(o, m, p);
}
function __values(o) {
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
if (m)
return m.call(o);
if (o && typeof o.length === "number")
return {
next: function () {
if (o && i >= o.length)
o = void 0;
return { value: o && o[i++], done: !o };
}
};
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
}
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;
}
/** @deprecated */
function __spread() {
for (var ar = [], i = 0; i < arguments.length; i++)
ar = ar.concat(__read(arguments[i]));
return ar;
}
/** @deprecated */
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 __spreadArray(to, from, pack) {
if (pack || arguments.length === 2)
for (var i = 0, l = from.length, ar; i < l; i++) {
if (ar || !(i in from)) {
if (!ar)
ar = Array.prototype.slice.call(from, 0, i);
ar[i] = from[i];
}
}
return to.concat(ar || Array.prototype.slice.call(from));
}
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;
}
;
var __setModuleDefault = Object.create ? (function (o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function (o, v) {
o["default"] = v;
};
function __importStar(mod) {
if (mod && mod.__esModule)
return mod;
var result = {};
if (mod != null)
for (var k in mod)
if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k))
__createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
}
function __importDefault(mod) {
return (mod && mod.__esModule) ? mod : { default: mod };
}
function __classPrivateFieldGet(receiver, state, kind, f) {
if (kind === "a" && !f)
throw new TypeError("Private accessor was defined without a getter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
throw new TypeError("Cannot read private member from an object whose class did not declare it");
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
}
function __classPrivateFieldSet(receiver, state, value, kind, f) {
if (kind === "m")
throw new TypeError("Private method is not writable");
if (kind === "a" && !f)
throw new TypeError("Private accessor was defined without a setter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
throw new TypeError("Cannot write private member to an object whose class did not declare it");
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
}
function __classPrivateFieldIn(state, receiver) {
if (receiver === null || (typeof receiver !== "object" && typeof receiver !== "function"))
throw new TypeError("Cannot use 'in' operator on non-object");
return typeof state === "function" ? receiver === state : state.has(receiver);
}
/**
* @license
* Copyright LOGO YAZILIM SANAYİ VE TİCARET A.Ş. All Rights Reserved.
*
* Save to the extent permitted by law, you may not use, copy, modify,
* distribute or create derivative works of this material or any part
* of it without the prior written consent of LOGO YAZILIM SANAYİ VE TİCARET A.Ş. Limited.
* Any reproduction of this material must contain this notice.
*/
/**
* Util class for common javascript operations
*/
var Util = /** @class */ (function () {
function Util() {
}
/**
* https://gist.github.com/barlas/760cbf77b31c6922d159
* This method returns turkish chars to english lowercase version
*
* __Usage:__
* ```javascript
* Util.turkishToLower("türkçeişğİIiıŞÜĞ");
* ```
*/
Util.turkishToLower = function (value) {
var string = value;
var letters = { 'İ': 'i', 'I': 'ı', 'Ş': 'ş', 'Ğ': 'ğ', 'Ü': 'ü', 'Ö': 'ö', 'Ç': 'ç' };
string = string.replace(/(([İIŞĞÜÇÖ]))/g, function (letter) {
return letters[letter];
});
return string.toLowerCase();
};
/**
* https://gist.github.com/barlas/760cbf77b31c6922d159
* This method returns turkish chars to english uppercase version
* Usage: Util.turkishToUpper("türkçeişğİIiıŞÜĞ");
*/
Util.turkishToUpper = function (value) {
var string = value;
var letters = { 'i': 'İ', 'ş': 'Ş', 'ğ': 'Ğ', 'ü': 'Ü', 'ö': 'Ö', 'ç': 'Ç', 'ı': 'I' };
string = string.replace(/(([iışğüçö]))/g, function (letter) {
return letters[letter];
});
return string.toUpperCase();
};
/**
* Creates an array of unique values
* @param array - The arrays to inspect
*/
Util.union = function () {
var array = [];
for (var _i = 0; _i < arguments.length; _i++) {
array[_i] = arguments[_i];
}
var newFlatArray = __spread(array).flat(Infinity);
var filter = function (item, pos) {
return newFlatArray.indexOf(item) === pos;
};
return newFlatArray.filter(filter);
};
/**
* Find index of given value inside array
* Usage:
* @param array - source array
* @param value - variable will be find index
* @returns - Array<number>
*/
Util.findAllIndex = function (array, value) {
var method = function (a, e, i) {
if (e === value) {
a.push(i);
}
return a;
};
return array.reduce(method, []);
};
/**
* Remove character from given string with given count
* Usage: Util.removeCharsBetween('serkan', 3, 2);
* @param value - String value will be split
* @param start - start position, 0 (zero) is first char
* @param count - how much char will be get
*/
Util.removeCharsBetween = function (value, start, count) {
if (count === void 0) { count = 1; }
var str = value.split('');
str.splice(start, count);
return str.join('');
};
return Util;
}());
/**
* @license
* Copyright LOGO YAZILIM SANAYİ VE TİCARET A.Ş. All Rights Reserved.
*
* Save to the extent permitted by law, you may not use, copy, modify,
* distribute or create derivative works of this material or any part
* of it without the prior written consent of LOGO YAZILIM SANAYİ VE TİCARET A.Ş. Limited.
* Any reproduction of this material must contain this notice.
*/
var moment = momentNs__namespace;
var selectionStart;
/**
* An input mask is a string of characters that indicates the format of valid input values. You can help
* people enter data correctly into input by providing input masks for fields that contain data that is
* always formatted a certain way. For example, you can use an input mask to make
* sure that people enter correctly formatted phone numbers into a phone number field.
*
* __Usage Example:__
*
* <input [(ngModel)]="tourDate" masker />
*
* For __Time__ correction example, this will be check for HH:mm format:
* ```html
* <input
* logoMask
* [regexp]="'^[0-2]{1}$|^[0-2]{1}[0-9]{1}$|^[0-2]{1}[0-9]{1}[0-5]{1}$|^[0-2]{1}[0-9]{1}[0-5]{1}[0-9]{1}$'"
* [placeholder]="HH:mm"
* />
* ```
* @stacked-example(MaskDirective, logo/core-sample/mask-directive-showcase/mask-directive-showcase.component)
* For __Date__ correction example, this will be check for YYYY-MM-DD format:
* ```html
* <input
* logoMask
* [placeholder]="'YYYY-MM-DD'"
* [regexp]="'^\\d+$'"
* />
* ```
*
* Full usage example with contains conditions:
*
* ```html
* <input
* logoMask
* [(ngModel)]="value"
* (change)="onDateChangeHandler($event)"
* (click)="onInputClick($event)"
* [placeholder]="'XX-00000'"
* [conditions]="[{cases: [{position: 2, regexp:'^[0-9]$'}], placeholder: 'X-0000000000'}]"
* [case]="'lower'"
* [regexp]="'^X{1,2}$|^X{1,2}[0-9]*$'"
* [maskType]="'date'"
* #dateRef
* />
* ```
*
* __Another Example:__
* ```html
* <input
* logoMask
* [placeholder]="'XX-0000000000'"
* [conditions]="[{cases: [{position: 2, regexp: '^[0-9]$'}], placeholder: 'X-0000000000'}]"
* [regexp]="'^[A-ZĞÜŞİÖÇ]{1,2}$|^[A-ZĞÜŞİÖÇ]{1,2}[0-9]*$'"
* [case]="'upper'"
* />
* ```
*/
var MaskDirective = /** @class */ (function () {
function MaskDirective(elementRef) {
this.elementRef = elementRef;
/**
* Case use for upper or lower case selection
* For example [case]="'lower'" it makes all char to lowercase
*/
this.case = null; // "upper|lower"
/**
* Conditions uses for set special status different than defined placeholder.
* If placeholder set to 'XX-00000' and 'X-00000' also acceptable you need this property
* For example [conditions]="[{cases: [{position: 2, regexp:'^[0-9]$'}], placeholder: 'X-0000000000'}]"
* With this at 2 position if inserted char is a digit (regexp) then placeholder will be redefine to 'X-0000000000'
*/
this.conditions = [];
this.ngModelChange = new core.EventEmitter();
this.oldValue = '';
this.defaultChars = '^\\wğüşıöçĞÜŞİÖÇ';
}
Object.defineProperty(MaskDirective.prototype, "regexp", {
/**
* This propert removes inserted char if format not same with defined pattern.
* For example [regexp]="'^9{1,3}$|^9{3}[0-9]*$'"
* Above example just accepts beginning 999 then accept digits like 999123456
*/
get: function () {
return this._regexp;
},
set: function (value) {
this._regexp = value;
},
enumerable: false,
configurable: true
});
Object.defineProperty(MaskDirective.prototype, "placeholder", {
/**
* Used for format check. What format will be used for display text.
* if need some special chars like "- / or space" this will be looks their position
* and will be added automatically
* For example : [placeholder] = {TK-1234} This format will be add "-" char automatically to third cursor position.
* And also will restrict insert more than char length to textbox.
*/
get: function () {
return this._placeholder;
},
set: function (value) {
this._placeholder = value;
if (typeof value !== 'undefined' && this.input) {
this.setPlaceholder(value);
}
if (!this.maxLength) {
this.maxLength = this.placeholder.length;
}
},
enumerable: false,
configurable: true
});
Object.defineProperty(MaskDirective.prototype, "maxLength", {
/**
* This property used for definition of acceptable max char length of the input field
* For example, [maxLength]='13' it sets the input file's acceptable chars length to max 13
*/
get: function () {
return this._maxLength;
},
set: function (value) {
var length = this.elementRef.nativeElement.maxLength;
var maxLength = length ? length : this._placeholder.length;
this._maxLength = (typeof value !== 'undefined' && value !== null) ? value : maxLength;
if (value && this.input) {
this.setInputAttributes();
}
},
enumerable: false,
configurable: true
});
Object.defineProperty(MaskDirective.prototype, "extendedChars", {
get: function () {
return this._extendedChars;
},
set: function (value) {
this._extendedChars = value;
if (typeof value !== 'undefined' && this.input) {
this.setPlaceholder(this.placeholder);
}
},
enumerable: false,
configurable: true
});
MaskDirective.prototype.ngOnInit = function () {
this.input = this.elementRef.nativeElement;
if (this._placeholder) {
this.setPlaceholder(this._placeholder);
}
};
MaskDirective.prototype.setPlaceholder = function (placeholder) {
var specialChars;
this.acceptedChars = "[" + this.defaultChars + this._extendedChars + "]";
specialChars = placeholder.match(new RegExp(this.acceptedChars, 'g'));
this.list = specialChars && Util.union(specialChars).map(function (value) {
'use strict';
return { what: value, position: Util.findAllIndex(placeholder.split(''), value) };
});
this.setInputAttributes();
};
MaskDirective.prototype.setInputAttributes = function () {
this.input.setAttribute('maxLength', this._maxLength);
this.input.setAttribute('placeholder', this._placeholder);
};
MaskDirective.prototype.clear = function (value) {
return value.replace(new RegExp(this.acceptedChars, 'g'), ''); // Removes every non-digit character;
};
MaskDirective.prototype.isValid = function (value) {
var convertDate = new Date(value);
return Object.prototype.toString.call(convertDate) === '[object Date]' && !isNaN(convertDate.getTime());
};
MaskDirective.prototype.onFocus = function ($event) {
this.oldValue = this.input.value;
};
MaskDirective.prototype.onBlur = function ($event) {
if (this.maskType === 'date' && !this.isValid(this.input.value)) {
this.emit(this.oldValue);
}
};
MaskDirective.prototype.onKeyDown = function ($event) {
select