ng-inail-common 2.0.30-beta.8 → 2.0.30-beta.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4121,6 +4121,7 @@
4121
4121
  var ɵ0$3 = isValidInputModel;
4122
4122
  var isLongTime = function (o) { return o && (typeof o === 'number'); };
4123
4123
  var ɵ1$2 = isLongTime;
4124
+ var ACCEPTED_INPUTS = ['/', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'Backspace', 'Delete', "Tab", "ArrowLeft", "ArrowRight", "ArrowUp", "ArrowDown"];
4124
4125
  var InputDateComponent = /** @class */ (function (_super) {
4125
4126
  __extends(InputDateComponent, _super);
4126
4127
  function InputDateComponent(cdr, libConfig) {
@@ -4145,6 +4146,9 @@
4145
4146
  _this.isDataAbilitata = function (data) { return _this.enabledDates == undefined || !_this.enabledDates.length || _this.enabledDates.some(function (regex) { return _this.match(data, regex) != undefined; }); };
4146
4147
  _this.isDataDisabilitata = function (data) { return _this.disabledDates != undefined && _this.disabledDates.some(function (regex) { return _this.match(data, regex) != undefined; }); };
4147
4148
  _this.match = function (date, regex) { return date != undefined && date.match(new RegExp('^'.concat(regex).concat('$'), 'i')); };
4149
+ _this.isFirstDigitSlash = function (ev) { return ev.key == '/' && _this.visibleData == undefined; };
4150
+ _this.isDoubleSlash = function (ev) { return ev.key == '/' && ev.key == _this.previousDigit; };
4151
+ _this.isWrongDigit = function (ev) { return _this.isFirstDigitSlash(ev) || _this.isDoubleSlash(ev); };
4148
4152
  _this.logPrefix = "[inail-input-date]";
4149
4153
  _super.prototype.overrideConfig.call(_this, libConfig === null || libConfig === void 0 ? void 0 : libConfig.inputDateComponent);
4150
4154
  _this.detach();
@@ -4287,12 +4291,22 @@
4287
4291
  InputDateComponent.prototype.setDatepickerDate = function (date) {
4288
4292
  window['$'](this.formControlElement.nativeElement).datepicker('setDate', date);
4289
4293
  };
4294
+ InputDateComponent.prototype.onKeyDown = function (ev) {
4295
+ // console.warn(ev)
4296
+ // console.warn(this.visibleData, `${this.visibleData}`)
4297
+ if ((!ACCEPTED_INPUTS.some(function (v) { return v === ev.key; }) || this.isWrongDigit(ev)) && ev.ctrlKey == false) {
4298
+ ev.preventDefault();
4299
+ }
4300
+ else {
4301
+ this.previousDigit = ev.key;
4302
+ }
4303
+ };
4290
4304
  return InputDateComponent;
4291
4305
  }(FormElementComponent));
4292
4306
  InputDateComponent.decorators = [
4293
4307
  { type: core.Component, args: [{
4294
4308
  selector: 'inail-input-date',
4295
- template: "<div class=\"date datePicker {{getResponsiveClass()}} noPaddingLeft {{class}}\"\n [ngClass]=\"{'has-error': isThereDataError()}\">\n <div class=\"form-group\">\n <div class=\"input-relative\">\n <label *ngIf=\"label\"\n [ngClass]=\"{'sr-only': hiddenLabel}\"\n class=\"control-label {{labelClass}}\"\n title=\"{{labelTitle}}\"\n for=\"{{id}}\" [innerHTML]=\"getLabel()\"></label>\n <span *ngIf=\"showPopover()\"\n [style.padding-left.px]=\"5\">\n <inail-popover [iconClass]=\"popoverButtonIcon\"\n [buttonTitle]=\"popoverButtonTitle\"\n [header]=\"popoverHeader\"\n [content]=\"popoverContent\">\n </inail-popover>\n </span>\n <input id=\"{{id}}\"\n #formControl\n class=\"form-control\"\n [ngClass]=\"inputClass\"\n title=\"GG/MM/AAAA\"\n placeholder=\"GG/MM/AAAA\"\n type=\"text\"\n (change)=\"onChangeHandler($event)\"\n (paste)=\"onChangeHandler($event)\"\n (keyup)=\"onChangeHandler($event)\"\n [disabled]=\"this.disabled\"\n [readonly]=\"this.readonly\"\n [attr.aria-required]=\"required === true ? true : undefined\"\n [attr.aria-invalid]=\"isThereDataError() === true ? true : undefined\"\n [attr.aria-describedBy]=\"getAriaDescribedBy()\"\n (keyup.enter)=\"enterUp.emit()\"\n [(ngModel)]=\"this.visibleData\">\n <em class=\"fa fa-calendar\"\n title=\"Calendario\"\n (click)=\"formControl.focus()\"></em>\n </div>\n <div *ngIf=\"showDataError()\" [id]=\"id+'-description'\">\n <div class=\"msg msg-errore\">\n <strong [innerHTML]=\"'ERRORE: '+getDescError()\"></strong>\n </div>\n <div *ngIf=\"description\" [innerHTML]=\"description\"></div>\n </div>\n <div *ngIf=\"description && !showDataError()\"\n [id]=\"id+'-description'\"\n [innerHTML]=\"this.description\">\n </div>\n </div>\n</div>\n",
4309
+ template: "<div class=\"date datePicker {{getResponsiveClass()}} noPaddingLeft {{class}}\"\n [ngClass]=\"{'has-error': isThereDataError()}\">\n <div class=\"form-group\">\n <div class=\"input-relative\">\n <label *ngIf=\"label\"\n [ngClass]=\"{'sr-only': hiddenLabel}\"\n class=\"control-label {{labelClass}}\"\n title=\"{{labelTitle}}\"\n for=\"{{id}}\" [innerHTML]=\"getLabel()\"></label>\n <span *ngIf=\"showPopover()\"\n [style.padding-left.px]=\"5\">\n <inail-popover [iconClass]=\"popoverButtonIcon\"\n [buttonTitle]=\"popoverButtonTitle\"\n [header]=\"popoverHeader\"\n [content]=\"popoverContent\">\n </inail-popover>\n </span>\n <input id=\"{{id}}\"\n #formControl\n class=\"form-control\"\n [ngClass]=\"inputClass\"\n title=\"GG/MM/AAAA\"\n placeholder=\"GG/MM/AAAA\"\n type=\"text\"\n (change)=\"onChangeHandler($event)\"\n (paste)=\"onChangeHandler($event)\"\n (keyup)=\"onChangeHandler($event)\"\n [disabled]=\"this.disabled\"\n [readonly]=\"this.readonly\"\n [attr.aria-required]=\"required === true ? true : undefined\"\n [attr.aria-invalid]=\"isThereDataError() === true ? true : undefined\"\n [attr.aria-describedBy]=\"getAriaDescribedBy()\"\n (keyup.enter)=\"enterUp.emit()\"\n (keydown)=\"onKeyDown($event)\"\n [(ngModel)]=\"this.visibleData\">\n <em class=\"fa fa-calendar\"\n title=\"Calendario\"\n (click)=\"formControl.focus()\"></em>\n </div>\n <div *ngIf=\"showDataError()\" [id]=\"id+'-description'\">\n <div class=\"msg msg-errore\">\n <strong [innerHTML]=\"'ERRORE: '+getDescError()\"></strong>\n </div>\n <div *ngIf=\"description\" [innerHTML]=\"description\"></div>\n </div>\n <div *ngIf=\"description && !showDataError()\"\n [id]=\"id+'-description'\"\n [innerHTML]=\"this.description\">\n </div>\n </div>\n</div>\n",
4296
4310
  changeDetection: CHANGE_DETECTION_STRATEGY,
4297
4311
  encapsulation: core.ViewEncapsulation.None,
4298
4312
  providers: [
@@ -4318,209 +4332,6 @@
4318
4332
  reinit: [{ type: core.Input }],
4319
4333
  value: [{ type: core.Input }]
4320
4334
  };
4321
- // export class InputDateComponent extends FormElementComponent implements OnInit, OnChanges, AfterViewInit, OnDestroy {
4322
- //
4323
- // @ViewChild('formControl', {static: true})
4324
- // formControlElement: ElementRef<HTMLElement>;
4325
- //
4326
- // visibleData: string;
4327
- //
4328
- // changed: boolean;
4329
- //
4330
- // @Output()
4331
- // valueChange = new EventEmitter<string>();
4332
- //
4333
- // // @Input()
4334
- // // modelFormat: DateFormat;
4335
- //
4336
- // @Input()
4337
- // datepickerOptions: any;
4338
- //
4339
- // @Input()
4340
- // enabledDates: string[];
4341
- //
4342
- // @Input()
4343
- // disabledDates: string[];
4344
- //
4345
- // constructor(private cdr: ChangeDetectorRef) {
4346
- // super(cdr);
4347
- // this.detach();
4348
- // }
4349
- //
4350
- // ngOnChanges(changes: DatePickerChanges) {
4351
- //
4352
- // super.ngOnChanges(changes);
4353
- // this.emitDebug(`ngOnChanges:`);
4354
- // this.emitDebug(changes);
4355
- //
4356
- // if (changes.value && !changes.value.firstChange) {
4357
- //
4358
- // this.hasError = false;
4359
- // this.error = undefined;
4360
- // }
4361
- //
4362
- // this.cdr.detectChanges();
4363
- // }
4364
- //
4365
- // ngOnInit() {
4366
- //
4367
- // this.logPrefix = `[inail-input-date][${this.label}]`;
4368
- // super.ngOnInit();
4369
- //
4370
- // if (!this.datepickerOptions) {
4371
- //
4372
- // this.datepickerOptions = {
4373
- // autoclose: true,
4374
- // format: 'dd/mm/yyyy',
4375
- // weekStart: 1,
4376
- // todayBtn: 'linked',
4377
- // language: 'it',
4378
- // todayHighlight: true,
4379
- // orientation: 'auto top',
4380
- // enableOnReadonly: false
4381
- // };
4382
- // }
4383
- //
4384
- // if (this.disabledDates != undefined || this.enabledDates != undefined) {
4385
- //
4386
- // this.datepickerOptions.beforeShowDay = this.isEnabledDate
4387
- // }
4388
- //
4389
- // this.cdr.detectChanges();
4390
- // }
4391
- //
4392
- // private isEnabledDate = (date) => {
4393
- //
4394
- // // @ts-ignore
4395
- // var dateString = $.datepicker.formatDate('yy-mm-dd', date);
4396
- // return this.isDataAbilitata(dateString) && !this.isDataDisabilitata(dateString);
4397
- // };
4398
- //
4399
- // private isDataAbilitata = (data: string) => this.enabledDates == undefined || this.enabledDates.some(regex => this.match(data, regex) != undefined);
4400
- // private isDataDisabilitata = (data: string) => this.disabledDates != undefined && this.disabledDates.some(regex => this.match(data, regex) != undefined);
4401
- //
4402
- // match = (date: string, regex: string) => date != undefined && date.match(new RegExp('^'.concat(regex).concat('$'), 'i'));
4403
- //
4404
- // ngAfterViewInit(): void {
4405
- //
4406
- // this.emitDebug('ngAfterViewInit');
4407
- // this.emitDebug('nativeElement');
4408
- // this.emitDebug(this.formControlElement?.nativeElement);
4409
- //
4410
- // // Inizializzazione della libreria datepicker
4411
- // window['$'](this.formControlElement.nativeElement).datepicker(this.datepickerOptions);
4412
- //
4413
- // if (this.visibleData && isDate(this.visibleData)) {
4414
- //
4415
- // this.setDatepickerDate(this.visibleData)
4416
- // }
4417
- //
4418
- // setTimeout(() => {
4419
- //
4420
- // // @ts-ignore
4421
- // $('#' + this.id).on("change", () => {
4422
- //
4423
- // this.emitDebug('onChange');
4424
- // this.emitDebug(`visibleData: ${this.visibleData}`);
4425
- //
4426
- // // @ts-ignore
4427
- // let elem = $('#' + this.id)[0]
4428
- //
4429
- // this.emitDebug(`nativeElement value: ${elem?.value}`);
4430
- //
4431
- // if (elem != undefined && elem.value != this.visibleData) {
4432
- //
4433
- // this.emitDebug(`update value: ${this.value} -> ${elem.value}`);
4434
- // this.value = elem.value;
4435
- // }
4436
- //
4437
- // this.cdr.detectChanges();
4438
- // });
4439
- // });
4440
- //
4441
- // if (this.showPopover()) {
4442
- //
4443
- // // @ts-ignore
4444
- // $(`#${this.id}-popover`).popover();
4445
- // }
4446
- //
4447
- // this.cdr.detectChanges();
4448
- // }
4449
- //
4450
- // ngOnDestroy(): void {
4451
- //
4452
- // super.ngOnDestroy();
4453
- // }
4454
- //
4455
- // @Input()
4456
- // set value(val) {
4457
- //
4458
- // // console.warn('val', val, this.visibleData)
4459
- //
4460
- // let validFormat = isValidInputFormat(val);
4461
- //
4462
- // // console.warn('validFormat', validFormat)
4463
- //
4464
- // if (isNotBlankOrNull(val)) {
4465
- //
4466
- // this.visibleData = validFormat ? toItalianFormat(val) : val;
4467
- // } else {
4468
- //
4469
- // this.visibleData = undefined
4470
- // }
4471
- //
4472
- // // console.warn('visibleData', this.visibleData)
4473
- //
4474
- // setTimeout(() => {
4475
- //
4476
- // let vChange = validFormat ? toISO8601Format(this.visibleData) : this.visibleData
4477
- //
4478
- // // console.warn('vChange', vChange)
4479
- //
4480
- // this.valueChange.emit(validFormat ? toISO8601Format(this.visibleData) : this.visibleData);
4481
- //
4482
- // if (validFormat) {
4483
- //
4484
- // // console.warn(this.visibleData)
4485
- // this.setDatepickerDate(this.visibleData);
4486
- // }
4487
- // });
4488
- // }
4489
- //
4490
- // get isValid(): boolean {
4491
- //
4492
- // return isBlankOrNull(this.visibleData) || isInItalianFormat(this.visibleData);
4493
- // }
4494
- //
4495
- // checkDescError(): boolean {
4496
- //
4497
- // let descError: string = this.getDescError();
4498
- // return this.checkError() && isNotBlankOrNull(descError);
4499
- // }
4500
- //
4501
- // checkError(): boolean {
4502
- //
4503
- // return !this.isValid || this.hasError || isNotBlankOrNull(this.error);
4504
- // }
4505
- //
4506
- // getDescError(): string {
4507
- //
4508
- // return (isNotBlankOrNull(this.error) && !this.isValid)
4509
- // ? 'La data inserita non &egrave; valida'
4510
- // : this.error;
4511
- // }
4512
- //
4513
- // onChangeHandler($event: any) {
4514
- //
4515
- // // console.info('onChange', $event.target.value)
4516
- // this.value = $event.target.value;
4517
- // }
4518
- //
4519
- // private setDatepickerDate(date: string) {
4520
- //
4521
- // window['$'](this.formControlElement.nativeElement).datepicker('setDate', date);
4522
- // }
4523
- // }
4524
4335
 
4525
4336
  var clone$1 = function (obj) { return obj ? JSON.parse(JSON.stringify(obj)) : obj; };
4526
4337
  var ɵ0$4 = clone$1;
@@ -6076,6 +5887,7 @@
6076
5887
  inputText: [{ type: core.ViewChild, args: ['inputText', { static: true },] }]
6077
5888
  };
6078
5889
 
5890
+ var ACCEPTED_INPUTS$1 = [',', '-', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'Backspace', 'Delete', "Tab", "ArrowLeft", "ArrowRight", "ArrowUp", "ArrowDown"];
6079
5891
  var InputNumberComponent = /** @class */ (function (_super) {
6080
5892
  __extends(InputNumberComponent, _super);
6081
5893
  function InputNumberComponent(cdr, libConfig) {
@@ -6090,6 +5902,9 @@
6090
5902
  _this.numberOfDecimals = getConfigValue((_h = (_g = _this.libConfig) === null || _g === void 0 ? void 0 : _g.inputNumberComponent) === null || _h === void 0 ? void 0 : _h.numberOfDecimals, undefined);
6091
5903
  _this.hideArrows = getConfigValue((_k = (_j = _this.libConfig) === null || _j === void 0 ? void 0 : _j.inputNumberComponent) === null || _k === void 0 ? void 0 : _k.hideArrows, false);
6092
5904
  _this.valueChange = new core.EventEmitter();
5905
+ _this.isFirstDigitComma = function (ev) { return ev.key == ',' && _this.inputValue == undefined; };
5906
+ _this.isWrongMinus = function (ev) { return ev.key == '-' && ev.key == _this.previousDigit; };
5907
+ _this.isWrongDigit = function (ev) { return _this.isFirstDigitComma(ev) || _this.isWrongMinus(ev); };
6093
5908
  _this.logPrefix = "[inail-input-number]";
6094
5909
  _super.prototype.overrideConfig.call(_this, libConfig === null || libConfig === void 0 ? void 0 : libConfig.inputNumberComponent);
6095
5910
  _this.detach();
@@ -6191,12 +6006,22 @@
6191
6006
  }
6192
6007
  return true;
6193
6008
  };
6009
+ InputNumberComponent.prototype.onKeyDown = function (ev) {
6010
+ // console.warn(ev)
6011
+ // console.warn(`${this.inputValue}`)
6012
+ if ((!ACCEPTED_INPUTS$1.some(function (v) { return v === ev.key; }) || this.isWrongDigit(ev)) && ev.ctrlKey == false) {
6013
+ ev.preventDefault();
6014
+ }
6015
+ else {
6016
+ this.previousDigit = ev.key;
6017
+ }
6018
+ };
6194
6019
  return InputNumberComponent;
6195
6020
  }(FormElementComponent));
6196
6021
  InputNumberComponent.decorators = [
6197
6022
  { type: core.Component, args: [{
6198
6023
  selector: 'inail-input-number',
6199
- template: "<div class=\"form-group {{getResponsiveClass()}} noPaddingLeft {{class}} inail-input-number\"\n [ngClass]=\"{'has-error': isThereError(), 'no-arrows': hideArrows}\">\n <label *ngIf=\"label\"\n class=\"control-label {{labelClass}}\"\n [ngClass]=\"{'sr-only': hiddenLabel}\"\n [attr.title]=\"labelTitle\"\n [for]=\"id\"\n [innerHTML]=\"getLabel()\"></label>\n <span *ngIf=\"showPopover()\"\n [style.padding-left.px]=\"5\">\n <inail-popover [iconClass]=\"popoverButtonIcon\"\n [buttonTitle]=\"popoverButtonTitle\"\n [header]=\"popoverHeader\"\n [content]=\"popoverContent\">\n </inail-popover>\n </span>\n <input #formControl\n type=\"number\"\n [id]=\"id\"\n class=\"form-control {{inputClass}}\"\n [ngClass]=\"{'disabled': disabled}\"\n [disabled]=\"disabled\"\n [readonly]=\"readonly\"\n [attr.name]=\"name\"\n [attr.title]=\"title\"\n [attr.max]=\"max\"\n [attr.min]=\"min\"\n [attr.step]=\"step\"\n [attr.aria-required]=\"required === true ? true : undefined\"\n [attr.aria-invalid]=\"isThereError() === true ? true : undefined\"\n [attr.aria-describedBy]=\"getAriaDescribedBy()\"\n (keyup)=\"onKeyUp()\"\n (blur)=\"onBlur()\"\n (keyup.enter)=\"enterUp.emit()\"\n [value]=\"inputValue\"\n [(ngModel)]='value'>\n <!--<input type=\"text\"\n *ngIf=\"disabled\"\n [id]=\"id\"\n class=\"form-control disabled {{inputClass}}\"\n [attr.name]=\"name\"\n [attr.title]=\"title\"\n [disabled]=\"disabled\"\n [attr.aria-describedBy]=\"getAriaDescribedBy()\"\n [ngModel]='value'>-->\n <div *ngIf=\"showError()\" [id]=\"id+'-description'\">\n <div class=\"msg msg-errore\">\n <strong [innerHTML]=\"'ERRORE: '+this.error\"></strong>\n </div>\n <div *ngIf=\"description\" [innerHTML]=\"this.description\"></div>\n </div>\n <div *ngIf=\"description && !showError()\"\n [id]=\"id+'-description'\"\n [innerHTML]=\"this.description\">\n </div>\n</div>\n",
6024
+ template: "<div class=\"form-group {{getResponsiveClass()}} noPaddingLeft {{class}} inail-input-number\"\n [ngClass]=\"{'has-error': isThereError(), 'no-arrows': hideArrows}\">\n <label *ngIf=\"label\"\n class=\"control-label {{labelClass}}\"\n [ngClass]=\"{'sr-only': hiddenLabel}\"\n [attr.title]=\"labelTitle\"\n [for]=\"id\"\n [innerHTML]=\"getLabel()\"></label>\n <span *ngIf=\"showPopover()\"\n [style.padding-left.px]=\"5\">\n <inail-popover [iconClass]=\"popoverButtonIcon\"\n [buttonTitle]=\"popoverButtonTitle\"\n [header]=\"popoverHeader\"\n [content]=\"popoverContent\">\n </inail-popover>\n </span>\n <input #formControl\n type=\"number\"\n [id]=\"id\"\n class=\"form-control {{inputClass}}\"\n [ngClass]=\"{'disabled': disabled}\"\n [disabled]=\"disabled\"\n [readonly]=\"readonly\"\n [attr.name]=\"name\"\n [attr.title]=\"title\"\n [attr.max]=\"max\"\n [attr.min]=\"min\"\n [attr.step]=\"step\"\n [attr.aria-required]=\"required === true ? true : undefined\"\n [attr.aria-invalid]=\"isThereError() === true ? true : undefined\"\n [attr.aria-describedBy]=\"getAriaDescribedBy()\"\n (keyup)=\"onKeyUp()\"\n (blur)=\"onBlur()\"\n (keydown)=\"onKeyDown($event)\"\n (keyup.enter)=\"enterUp.emit()\"\n [value]=\"inputValue\"\n [(ngModel)]='value'>\n <!--<input type=\"text\"\n *ngIf=\"disabled\"\n [id]=\"id\"\n class=\"form-control disabled {{inputClass}}\"\n [attr.name]=\"name\"\n [attr.title]=\"title\"\n [disabled]=\"disabled\"\n [attr.aria-describedBy]=\"getAriaDescribedBy()\"\n [ngModel]='value'>-->\n <div *ngIf=\"showError()\" [id]=\"id+'-description'\">\n <div class=\"msg msg-errore\">\n <strong [innerHTML]=\"'ERRORE: '+this.error\"></strong>\n </div>\n <div *ngIf=\"description\" [innerHTML]=\"this.description\"></div>\n </div>\n <div *ngIf=\"description && !showError()\"\n [id]=\"id+'-description'\"\n [innerHTML]=\"this.description\">\n </div>\n</div>\n",
6200
6025
  changeDetection: CHANGE_DETECTION_STRATEGY,
6201
6026
  encapsulation: core.ViewEncapsulation.None,
6202
6027
  providers: [
@@ -6760,7 +6585,7 @@
6760
6585
 
6761
6586
  var HM_PLACEHOLDER = 'HH:MM';
6762
6587
  var HMS_PLACEHOLDER = 'HH:MM:SS';
6763
- var ACCEPTED_INPUTS = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'Backspace', 'Delete'];
6588
+ var ACCEPTED_INPUTS$2 = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'Backspace', 'Delete', "Tab", "ArrowLeft", "ArrowRight", "ArrowUp", "ArrowDown"];
6764
6589
  var InputTimeComponent = /** @class */ (function (_super) {
6765
6590
  __extends(InputTimeComponent, _super);
6766
6591
  function InputTimeComponent(cdr, libConfig) {
@@ -6884,7 +6709,7 @@
6884
6709
  }
6885
6710
  };
6886
6711
  InputTimeComponent.prototype.onKeyDown = function (ev) {
6887
- if (!ACCEPTED_INPUTS.some(function (v) { return v === ev.key; }) && ev.ctrlKey == false) {
6712
+ if (!ACCEPTED_INPUTS$2.some(function (v) { return v === ev.key; }) && ev.ctrlKey == false) {
6888
6713
  ev.preventDefault();
6889
6714
  }
6890
6715
  };