ng-inail-common 2.0.30-beta.7 → 2.0.31-beta.0

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.
Files changed (25) hide show
  1. package/bundles/ng-inail-common.umd.js +123 -237
  2. package/bundles/ng-inail-common.umd.js.map +1 -1
  3. package/bundles/ng-inail-common.umd.min.js +2 -2
  4. package/bundles/ng-inail-common.umd.min.js.map +1 -1
  5. package/esm2015/lib/components/core/form/checkbox/checkbox.component.js +4 -2
  6. package/esm2015/lib/components/core/form/form-element.component.js +6 -3
  7. package/esm2015/lib/components/core/form/input-date/input-date.component.js +30 -215
  8. package/esm2015/lib/components/core/form/input-file/input-file.component.js +4 -2
  9. package/esm2015/lib/components/core/form/input-number/input-number.component.js +23 -7
  10. package/esm2015/lib/components/core/form/input-text/input-text.component.js +4 -2
  11. package/esm2015/lib/components/core/form/input-time/input-time.component.js +44 -8
  12. package/esm2015/lib/components/core/form/multi-select/multi-select.component.js +7 -3
  13. package/esm2015/lib/components/core/form/radio-select/radio-select.component.js +4 -2
  14. package/esm2015/lib/components/core/form/select/select.component.js +4 -2
  15. package/esm2015/lib/components/core/form/textarea/textarea.component.js +4 -2
  16. package/esm2015/lib/ng-inail-common.config.js +1 -1
  17. package/fesm2015/ng-inail-common.js +123 -237
  18. package/fesm2015/ng-inail-common.js.map +1 -1
  19. package/lib/components/core/form/form-element.component.d.ts +1 -0
  20. package/lib/components/core/form/input-date/input-date.component.d.ts +7 -0
  21. package/lib/components/core/form/input-number/input-number.component.d.ts +5 -0
  22. package/lib/components/core/form/input-time/input-time.component.d.ts +5 -0
  23. package/lib/ng-inail-common.config.d.ts +3 -0
  24. package/ng-inail-common.metadata.json +1 -1
  25. package/package.json +1 -1
@@ -2962,7 +2962,7 @@
2962
2962
  __extends(FormElementComponent, _super);
2963
2963
  function FormElementComponent(formElementCdr, formElementLibConfig) {
2964
2964
  var _this = this;
2965
- var _a, _b, _c, _d;
2965
+ var _a, _b, _c, _d, _e, _f;
2966
2966
  _this = _super.call(this, formElementCdr, formElementLibConfig) || this;
2967
2967
  _this.formElementCdr = formElementCdr;
2968
2968
  _this.formElementLibConfig = formElementLibConfig;
@@ -2977,6 +2977,7 @@
2977
2977
  _this.errorChange = new core.EventEmitter();
2978
2978
  _this.enterUp = new core.EventEmitter();
2979
2979
  _this.popover = false;
2980
+ _this.cleanErrorOnChange = getConfigValue((_f = (_e = _this.formElementLibConfig) === null || _e === void 0 ? void 0 : _e.formElementComponent) === null || _f === void 0 ? void 0 : _f.cleanErrorOnChange, true);
2980
2981
  _this.getLabel = function () { return "" + ((_this.required && _this.requiredSimbolPosition === 'left') ? _this.requiredSimbol + " " : '') + _this.label + ((_this.required && _this.requiredSimbolPosition === 'right') ? " " + _this.requiredSimbol : ''); };
2981
2982
  _this.isThereError = function () { return _this.hasError || isNotBlankOrNull(_this.error); };
2982
2983
  _this.showError = function () { return _this.isThereError() && isNotBlankOrNull(_this.error); };
@@ -2991,6 +2992,7 @@
2991
2992
  _super.prototype.overrideConfig.call(this, config);
2992
2993
  this.requiredSimbol = getConfigValue(config.requiredSimbol, this.requiredSimbol);
2993
2994
  this.requiredSimbolPosition = getConfigValue(config.requiredSimbolPosition, this.requiredSimbolPosition);
2995
+ this.cleanErrorOnChange = getConfigValue(config.cleanErrorOnChange, this.cleanErrorOnChange);
2994
2996
  }
2995
2997
  };
2996
2998
  FormElementComponent.prototype.ngOnChanges = function (changes) {
@@ -3082,7 +3084,8 @@
3082
3084
  popoverButtonIcon: [{ type: core.Input }],
3083
3085
  popoverButtonTitle: [{ type: core.Input }],
3084
3086
  popoverHeader: [{ type: core.Input }],
3085
- popoverContent: [{ type: core.Input }]
3087
+ popoverContent: [{ type: core.Input }],
3088
+ cleanErrorOnChange: [{ type: core.Input }]
3086
3089
  };
3087
3090
 
3088
3091
  /**
@@ -3237,7 +3240,9 @@
3237
3240
  this.cdr.detectChanges();
3238
3241
  this.emitDebug("this.valueChange.emit(" + value + ")");
3239
3242
  this.valueChange.emit(value);
3240
- this.cleanError();
3243
+ if (this.cleanErrorOnChange) {
3244
+ this.cleanError();
3245
+ }
3241
3246
  if (this.onChange) {
3242
3247
  this.onChange(value);
3243
3248
  }
@@ -3354,7 +3359,9 @@
3354
3359
  _this.emitDebug("this.valueChange.emit(" + _this.selectedValue + ")");
3355
3360
  _this.valueChange.emit(_this.selectedValue);
3356
3361
  _this.select.emit(_this.options.find(function (opt) { return (opt === null || opt === void 0 ? void 0 : opt.value) === _this.selectedValue; }));
3357
- _this.cleanError();
3362
+ if (_this.cleanErrorOnChange) {
3363
+ _this.cleanError();
3364
+ }
3358
3365
  if (_this.onChange) {
3359
3366
  _this.onChange(_this.selectedValue);
3360
3367
  }
@@ -4070,7 +4077,9 @@
4070
4077
  this.cdr.detectChanges();
4071
4078
  this.emitDebug("this.valueChange.emit(" + value + ")");
4072
4079
  this.valueChange.emit(value);
4073
- this.cleanError();
4080
+ if (this.cleanErrorOnChange) {
4081
+ this.cleanError();
4082
+ }
4074
4083
  if (this.onChange) {
4075
4084
  this.onChange(value);
4076
4085
  }
@@ -4121,11 +4130,12 @@
4121
4130
  var ɵ0$3 = isValidInputModel;
4122
4131
  var isLongTime = function (o) { return o && (typeof o === 'number'); };
4123
4132
  var ɵ1$2 = isLongTime;
4133
+ var ACCEPTED_INPUTS = ['/', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'Backspace', 'Delete', "Tab", "ArrowLeft", "ArrowRight", "ArrowUp", "ArrowDown"];
4124
4134
  var InputDateComponent = /** @class */ (function (_super) {
4125
4135
  __extends(InputDateComponent, _super);
4126
4136
  function InputDateComponent(cdr, libConfig) {
4127
4137
  var _this = this;
4128
- var _a, _b;
4138
+ var _a, _b, _c, _d, _e, _f;
4129
4139
  _this = _super.call(this, cdr, libConfig) || this;
4130
4140
  _this.cdr = cdr;
4131
4141
  _this.libConfig = libConfig;
@@ -4134,10 +4144,12 @@
4134
4144
  // modelFormat: DateFormat;
4135
4145
  // https://bootstrap-datepicker.readthedocs.io/en/latest/options.html
4136
4146
  _this.options = getConfigValue((_b = (_a = _this.libConfig) === null || _a === void 0 ? void 0 : _a.inputDateComponent) === null || _b === void 0 ? void 0 : _b.options, undefined);
4147
+ _this.selfValidation = getConfigValue((_d = (_c = _this.libConfig) === null || _c === void 0 ? void 0 : _c.inputDateComponent) === null || _d === void 0 ? void 0 : _d.selfValidation, true);
4148
+ _this.selfValidationError = getConfigValue((_f = (_e = _this.libConfig) === null || _e === void 0 ? void 0 : _e.inputDateComponent) === null || _f === void 0 ? void 0 : _f.selfValidationError, 'La data inserita non è valida');
4137
4149
  _this.isValidInputValue = function () { return isBlankOrNull(_this.visibleData) || isInItalianFormat(_this.visibleData); };
4138
- _this.isThereDataError = function () { return _this.isThereError() || !_this.isValidInputValue(); };
4150
+ _this.isThereDataError = function () { return _this.isThereError() || (!_this.isValidInputValue() && _this.selfValidation); };
4139
4151
  _this.showDataError = function () { return _this.isThereDataError() && isNotBlankOrNull(_this.getDescError()); };
4140
- _this.getDescError = function () { return (isBlankOrNull(_this.error) && !_this.isValidInputValue()) ? "La data inserita non è valida" : _this.error; };
4152
+ _this.getDescError = function () { return (_this.selfValidation && isBlankOrNull(_this.error) && !_this.isValidInputValue()) ? _this.selfValidationError : _this.error; };
4141
4153
  _this.isEnabledDate = function (date) {
4142
4154
  var dateString = dateToString(date, 'ISO8061');
4143
4155
  return _this.isDataAbilitata(dateString) && !_this.isDataDisabilitata(dateString);
@@ -4145,6 +4157,9 @@
4145
4157
  _this.isDataAbilitata = function (data) { return _this.enabledDates == undefined || !_this.enabledDates.length || _this.enabledDates.some(function (regex) { return _this.match(data, regex) != undefined; }); };
4146
4158
  _this.isDataDisabilitata = function (data) { return _this.disabledDates != undefined && _this.disabledDates.some(function (regex) { return _this.match(data, regex) != undefined; }); };
4147
4159
  _this.match = function (date, regex) { return date != undefined && date.match(new RegExp('^'.concat(regex).concat('$'), 'i')); };
4160
+ _this.isFirstDigitSlash = function (ev) { return ev.key == '/' && _this.visibleData == undefined; };
4161
+ _this.isDoubleSlash = function (ev) { return ev.key == '/' && ev.key == _this.previousDigit; };
4162
+ _this.isWrongDigit = function (ev) { return _this.isFirstDigitSlash(ev) || _this.isDoubleSlash(ev); };
4148
4163
  _this.logPrefix = "[inail-input-date]";
4149
4164
  _super.prototype.overrideConfig.call(_this, libConfig === null || libConfig === void 0 ? void 0 : libConfig.inputDateComponent);
4150
4165
  _this.detach();
@@ -4152,12 +4167,10 @@
4152
4167
  }
4153
4168
  InputDateComponent.prototype.ngOnChanges = function (changes) {
4154
4169
  _super.prototype.ngOnChanges.call(this, changes);
4155
- if (changes.value && !changes.value.firstChange) {
4156
- this.hasError = false;
4157
- this.error = undefined;
4158
- this.hasErrorChange.emit(this.hasError);
4159
- this.errorChange.emit(this.error);
4160
- }
4170
+ // if (changes.value && !changes.value.firstChange && this.cleanErrorOnChange) {
4171
+ //
4172
+ // this.cleanError();
4173
+ // }
4161
4174
  // Se cambiano le options o gli array delle date abilitate/disabilitate
4162
4175
  // reinizializzo il componente
4163
4176
  if ((changes.options && !changes.options.firstChange)
@@ -4274,7 +4287,9 @@
4274
4287
  _this.setDatepickerDate(_this.visibleData);
4275
4288
  }
4276
4289
  });
4277
- this.cleanError();
4290
+ if (this.cleanErrorOnChange) {
4291
+ this.cleanError();
4292
+ }
4278
4293
  this.cdr.detectChanges();
4279
4294
  if (this.onChange) {
4280
4295
  this.onChange(value);
@@ -4287,12 +4302,22 @@
4287
4302
  InputDateComponent.prototype.setDatepickerDate = function (date) {
4288
4303
  window['$'](this.formControlElement.nativeElement).datepicker('setDate', date);
4289
4304
  };
4305
+ InputDateComponent.prototype.onKeyDown = function (ev) {
4306
+ // console.warn(ev)
4307
+ // console.warn(this.visibleData, `${this.visibleData}`)
4308
+ if ((!ACCEPTED_INPUTS.some(function (v) { return v === ev.key; }) || this.isWrongDigit(ev)) && ev.ctrlKey == false) {
4309
+ ev.preventDefault();
4310
+ }
4311
+ else {
4312
+ this.previousDigit = ev.key;
4313
+ }
4314
+ };
4290
4315
  return InputDateComponent;
4291
4316
  }(FormElementComponent));
4292
4317
  InputDateComponent.decorators = [
4293
4318
  { type: core.Component, args: [{
4294
4319
  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",
4320
+ 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
4321
  changeDetection: CHANGE_DETECTION_STRATEGY,
4297
4322
  encapsulation: core.ViewEncapsulation.None,
4298
4323
  providers: [
@@ -4313,214 +4338,13 @@
4313
4338
  formControlElement: [{ type: core.ViewChild, args: ['formControl', { static: true },] }],
4314
4339
  valueChange: [{ type: core.Output }],
4315
4340
  options: [{ type: core.Input }],
4341
+ selfValidation: [{ type: core.Input }],
4342
+ selfValidationError: [{ type: core.Input }],
4316
4343
  enabledDates: [{ type: core.Input }],
4317
4344
  disabledDates: [{ type: core.Input }],
4318
4345
  reinit: [{ type: core.Input }],
4319
4346
  value: [{ type: core.Input }]
4320
4347
  };
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
4348
 
4525
4349
  var clone$1 = function (obj) { return obj ? JSON.parse(JSON.stringify(obj)) : obj; };
4526
4350
  var ɵ0$4 = clone$1;
@@ -4599,7 +4423,9 @@
4599
4423
  _this.emitDebug("this.valueChange.emit(" + _this.selectedValue + ")");
4600
4424
  _this.valueChange.emit(_this.selectedValue);
4601
4425
  _this.select.emit(_this.options.find(function (opt) { return (opt === null || opt === void 0 ? void 0 : opt.value) === _this.selectedValue; }));
4602
- _this.cleanError();
4426
+ if (_this.cleanErrorOnChange) {
4427
+ _this.cleanError();
4428
+ }
4603
4429
  if (_this.onChange) {
4604
4430
  _this.onChange(_this.selectedValue);
4605
4431
  }
@@ -4721,7 +4547,9 @@
4721
4547
  this.emitDebug("this.checkedChange.emit(" + value + ")");
4722
4548
  this.checkedChange.emit(value);
4723
4549
  this.emitState();
4724
- this.cleanError();
4550
+ if (this.cleanErrorOnChange) {
4551
+ this.cleanError();
4552
+ }
4725
4553
  if (this.onChange) {
4726
4554
  this.onChange(value);
4727
4555
  }
@@ -6043,7 +5871,9 @@
6043
5871
  if (!this.addButton) {
6044
5872
  this.fileChange.emit(this.fileModel);
6045
5873
  }
6046
- this.cleanError();
5874
+ if (this.cleanErrorOnChange) {
5875
+ this.cleanError();
5876
+ }
6047
5877
  this.cdr.detectChanges();
6048
5878
  };
6049
5879
  InputFileComponent.prototype.reset = function () {
@@ -6076,6 +5906,7 @@
6076
5906
  inputText: [{ type: core.ViewChild, args: ['inputText', { static: true },] }]
6077
5907
  };
6078
5908
 
5909
+ var ACCEPTED_INPUTS$1 = [',', '-', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'Backspace', 'Delete', "Tab", "ArrowLeft", "ArrowRight", "ArrowUp", "ArrowDown"];
6079
5910
  var InputNumberComponent = /** @class */ (function (_super) {
6080
5911
  __extends(InputNumberComponent, _super);
6081
5912
  function InputNumberComponent(cdr, libConfig) {
@@ -6090,6 +5921,9 @@
6090
5921
  _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
5922
  _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
5923
  _this.valueChange = new core.EventEmitter();
5924
+ _this.isFirstDigitComma = function (ev) { return ev.key == ',' && _this.inputValue == undefined; };
5925
+ _this.isWrongMinus = function (ev) { return ev.key == '-' && ev.key == _this.previousDigit; };
5926
+ _this.isWrongDigit = function (ev) { return _this.isFirstDigitComma(ev) || _this.isWrongMinus(ev); };
6093
5927
  _this.logPrefix = "[inail-input-number]";
6094
5928
  _super.prototype.overrideConfig.call(_this, libConfig === null || libConfig === void 0 ? void 0 : libConfig.inputNumberComponent);
6095
5929
  _this.detach();
@@ -6100,10 +5934,10 @@
6100
5934
  if (changes.value) {
6101
5935
  this.previousValue = changes.value.previousValue;
6102
5936
  this.normalizzaValore();
6103
- if (!changes.value.firstChange) {
6104
- this.hasError = false;
6105
- this.error = undefined;
6106
- }
5937
+ // if (!changes.value.firstChange) {
5938
+ //
5939
+ // this.cleanError()
5940
+ // }
6107
5941
  }
6108
5942
  this.cdr.detectChanges();
6109
5943
  };
@@ -6147,7 +5981,9 @@
6147
5981
  this.cdr.detectChanges();
6148
5982
  this.emitDebug("this.valueChange.emit(" + value + ")");
6149
5983
  this.valueChange.emit(value);
6150
- this.cleanError();
5984
+ if (this.cleanErrorOnChange) {
5985
+ this.cleanError();
5986
+ }
6151
5987
  if (this.onChange) {
6152
5988
  this.onChange(value);
6153
5989
  }
@@ -6191,12 +6027,22 @@
6191
6027
  }
6192
6028
  return true;
6193
6029
  };
6030
+ InputNumberComponent.prototype.onKeyDown = function (ev) {
6031
+ // console.warn(ev)
6032
+ // console.warn(`${this.inputValue}`)
6033
+ if ((!ACCEPTED_INPUTS$1.some(function (v) { return v === ev.key; }) || this.isWrongDigit(ev)) && ev.ctrlKey == false) {
6034
+ ev.preventDefault();
6035
+ }
6036
+ else {
6037
+ this.previousDigit = ev.key;
6038
+ }
6039
+ };
6194
6040
  return InputNumberComponent;
6195
6041
  }(FormElementComponent));
6196
6042
  InputNumberComponent.decorators = [
6197
6043
  { type: core.Component, args: [{
6198
6044
  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",
6045
+ 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
6046
  changeDetection: CHANGE_DETECTION_STRATEGY,
6201
6047
  encapsulation: core.ViewEncapsulation.None,
6202
6048
  providers: [
@@ -6721,11 +6567,15 @@
6721
6567
  if (!cb.firstChange) {
6722
6568
  if (cb.checked && !this.isChecked(cb.value)) {
6723
6569
  this.pushValue(cb.value);
6724
- this.cleanError();
6570
+ if (this.cleanErrorOnChange) {
6571
+ this.cleanError();
6572
+ }
6725
6573
  }
6726
6574
  else if (!cb.checked && this.isChecked(cb.value)) {
6727
6575
  this.values = this.values.filter(function (value) { return value != cb.value; });
6728
- this.cleanError();
6576
+ if (this.cleanErrorOnChange) {
6577
+ this.cleanError();
6578
+ }
6729
6579
  }
6730
6580
  this.valuesChange.emit(this.values);
6731
6581
  this.inputTextValue = this.getInputTextValue();
@@ -6760,7 +6610,7 @@
6760
6610
 
6761
6611
  var HM_PLACEHOLDER = 'HH:MM';
6762
6612
  var HMS_PLACEHOLDER = 'HH:MM:SS';
6763
- var ACCEPTED_INPUTS = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'Backspace', 'Delete'];
6613
+ var ACCEPTED_INPUTS$2 = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'Backspace', 'Delete', "Tab", "ArrowLeft", "ArrowRight", "ArrowUp", "ArrowDown"];
6764
6614
  var InputTimeComponent = /** @class */ (function (_super) {
6765
6615
  __extends(InputTimeComponent, _super);
6766
6616
  function InputTimeComponent(cdr, libConfig) {
@@ -6796,22 +6646,26 @@
6796
6646
  var _a, _b, _c;
6797
6647
  _super.prototype.ngOnChanges.call(this, changes);
6798
6648
  if (((_a = changes === null || changes === void 0 ? void 0 : changes.withSeconds) === null || _a === void 0 ? void 0 : _a.currentValue) != undefined) {
6799
- this.placeholder = getConfigValue((_c = (_b = this.libConfig) === null || _b === void 0 ? void 0 : _b.inputTimeComponent) === null || _c === void 0 ? void 0 : _c.placeholder, this.withSeconds ? HMS_PLACEHOLDER : HM_PLACEHOLDER);
6649
+ this.defaultPlaceholder = getConfigValue((_c = (_b = this.libConfig) === null || _b === void 0 ? void 0 : _b.inputTimeComponent) === null || _c === void 0 ? void 0 : _c.placeholder, this.withSeconds ? HMS_PLACEHOLDER : HM_PLACEHOLDER);
6800
6650
  }
6801
- this.placeholder = this.getNotBlankValue(this.placeholder);
6651
+ this.placeholderVisualizzato = this.getNotBlankValue(this.placeholder) || this.defaultPlaceholder;
6802
6652
  this.cdr.detectChanges();
6803
6653
  };
6804
6654
  InputTimeComponent.prototype.ngOnInit = function () {
6805
6655
  var _this = this;
6656
+ var _a, _b;
6806
6657
  _super.prototype.ngOnInit.call(this);
6807
6658
  this.emitDebug("@ViewChild('formControl')");
6808
6659
  this.emitDebug(this.formControlElement);
6660
+ this.defaultPlaceholder = getConfigValue((_b = (_a = this.libConfig) === null || _a === void 0 ? void 0 : _a.inputTimeComponent) === null || _b === void 0 ? void 0 : _b.placeholder, this.withSeconds ? HMS_PLACEHOLDER : HM_PLACEHOLDER);
6661
+ this.placeholderVisualizzato = this.getNotBlankValue(this.placeholder) || this.defaultPlaceholder;
6809
6662
  if (this.focus) {
6810
6663
  this.push(this.focus.subscribe(function (scroll) {
6811
6664
  _this.emitDebug("Catch focus!");
6812
6665
  setFocus(_this.formControlElement.nativeElement, scroll);
6813
6666
  }));
6814
6667
  }
6668
+ this.cdr.detectChanges();
6815
6669
  };
6816
6670
  InputTimeComponent.prototype.ngAfterViewInit = function () {
6817
6671
  };
@@ -6842,12 +6696,16 @@
6842
6696
  this.setDescError(this.selfValidationError);
6843
6697
  }
6844
6698
  else {
6845
- this.cleanError();
6699
+ if (this.cleanErrorOnChange) {
6700
+ this.cleanError();
6701
+ }
6846
6702
  }
6847
6703
  }
6848
6704
  else {
6849
6705
  this.inputValue = value;
6850
- this.cleanError();
6706
+ if (this.cleanErrorOnChange) {
6707
+ this.cleanError();
6708
+ }
6851
6709
  }
6852
6710
  this.cdr.detectChanges();
6853
6711
  this.emitDebug("this.valueChange.emit(" + this.inputValue + ")");
@@ -6880,10 +6738,38 @@
6880
6738
  }
6881
6739
  };
6882
6740
  InputTimeComponent.prototype.onKeyDown = function (ev) {
6883
- if (!ACCEPTED_INPUTS.some(function (v) { return v === ev.key; }) && ev.ctrlKey == false) {
6741
+ if (!ACCEPTED_INPUTS$2.some(function (v) { return v === ev.key; }) && ev.ctrlKey == false) {
6884
6742
  ev.preventDefault();
6885
6743
  }
6886
6744
  };
6745
+ InputTimeComponent.prototype.onFocusOut = function () {
6746
+ this.completaValoreInInput();
6747
+ };
6748
+ InputTimeComponent.prototype.completaParteOrario = function (value) {
6749
+ if (isBlankOrNull(value)) {
6750
+ value = '00';
6751
+ }
6752
+ else if (value.length == 1) {
6753
+ value = "0" + value;
6754
+ }
6755
+ return value;
6756
+ };
6757
+ InputTimeComponent.prototype.completaValoreInInput = function () {
6758
+ if (isNotBlankOrNull(this.inputValue) && (this.inputValue.length < 5 || (this.withSeconds && this.inputValue.length < 8))) {
6759
+ var partiOrario = this.inputValue.split(':');
6760
+ var numeroParti = this.withSeconds ? 3 : 2;
6761
+ for (var i = 0; i < numeroParti; i++) {
6762
+ partiOrario[i] = this.completaParteOrario(partiOrario[i]);
6763
+ }
6764
+ var value = partiOrario[0] + ":" + partiOrario[1];
6765
+ if (partiOrario[2]) {
6766
+ value = value + ":" + partiOrario[2];
6767
+ }
6768
+ if (value && this.isValidValue(value)) {
6769
+ this.setValue(value);
6770
+ }
6771
+ }
6772
+ };
6887
6773
  InputTimeComponent.prototype.ngOnDestroy = function () {
6888
6774
  _super.prototype.ngOnDestroy.call(this);
6889
6775
  };
@@ -6892,7 +6778,7 @@
6892
6778
  InputTimeComponent.decorators = [
6893
6779
  { type: core.Component, args: [{
6894
6780
  selector: 'inail-input-time',
6895
- template: "<div class=\"form-group {{getResponsiveClass()}} noPaddingLeft {{class}} inail-input-time\"\n [ngClass]=\"{'has-error': isThereError()}\">\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 <div class=\"form-control-wrapper\"\n [ngClass]=\"{'no-label' : hiddenLabel || !label}\">\n <input #formControl\n [id]=\"id\"\n [attr.type]=\"getType()\"\n [attr.step]=\"getStep()\"\n class=\"form-control {{inputClass}}\"\n [ngClass]=\"{'disabled': disabled}\"\n [attr.name]=\"name\"\n [attr.title]=\"title\"\n [attr.maxlength]=\"getMaxLength()\"\n [disabled]=\"disabled\"\n [readonly]=\"readonly\"\n [attr.placeholder]=\"placeholder\"\n [attr.aria-required]=\"required === true ? true : undefined\"\n [attr.aria-invalid]=\"isThereError() === true ? true : undefined\"\n [attr.aria-describedBy]=\"getAriaDescribedBy()\"\n (blur)=\"onBlur()\"\n (keydown)=\"onKeyDown($event)\"\n (paste)=\"onPaste($event)\"\n (keyup.enter)=\"enterUp.emit()\"\n [(ngModel)]=\"value\">\n </div>\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 <debug-pre *ngIf=\"showState\">\n <state-propertie [label]=\"'id'\" [propertie]=\"id\"></state-propertie>\n <state-propertie [label]=\"'label'\" [propertie]=\"label\"></state-propertie>\n <state-propertie [label]=\"'inputValue'\" [propertie]=\"inputValue\"></state-propertie>\n <state-propertie [label]=\"'placeholder'\" [propertie]=\"placeholder\" [hideIfNull]=\"false\"></state-propertie>\n <inail-form-element-state-properties [formElement]=\"this\"></inail-form-element-state-properties>\n </debug-pre>\n</div>\n",
6781
+ template: "<div class=\"form-group {{getResponsiveClass()}} noPaddingLeft {{class}} inail-input-time\"\n [ngClass]=\"{'has-error': isThereError()}\">\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 <div class=\"form-control-wrapper\"\n [ngClass]=\"{'no-label' : hiddenLabel || !label}\">\n <input #formControl\n [id]=\"id\"\n [attr.type]=\"getType()\"\n [attr.step]=\"getStep()\"\n class=\"form-control {{inputClass}}\"\n [ngClass]=\"{'disabled': disabled}\"\n [attr.name]=\"name\"\n [attr.title]=\"title\"\n [attr.maxlength]=\"getMaxLength()\"\n [disabled]=\"disabled\"\n [readonly]=\"readonly\"\n [attr.placeholder]=\"placeholderVisualizzato\"\n [attr.aria-required]=\"required === true ? true : undefined\"\n [attr.aria-invalid]=\"isThereError() === true ? true : undefined\"\n [attr.aria-describedBy]=\"getAriaDescribedBy()\"\n (blur)=\"onBlur()\"\n (focusout)=\"onFocusOut()\"\n (keydown)=\"onKeyDown($event)\"\n (paste)=\"onPaste($event)\"\n (keyup.enter)=\"enterUp.emit()\"\n [(ngModel)]=\"value\">\n </div>\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 <debug-pre *ngIf=\"showState\">\n <state-propertie [label]=\"'id'\" [propertie]=\"id\"></state-propertie>\n <state-propertie [label]=\"'label'\" [propertie]=\"label\"></state-propertie>\n <state-propertie [label]=\"'inputValue'\" [propertie]=\"inputValue\"></state-propertie>\n <state-propertie [label]=\"'placeholder'\" [propertie]=\"placeholder\"></state-propertie>\n <state-propertie [label]=\"'defaultPlaceholder'\" [propertie]=\"defaultPlaceholder\"></state-propertie>\n <inail-form-element-state-properties [formElement]=\"this\"></inail-form-element-state-properties>\n </debug-pre>\n</div>\n",
6896
6782
  changeDetection: CHANGE_DETECTION_STRATEGY,
6897
6783
  encapsulation: core.ViewEncapsulation.None,
6898
6784
  providers: [