ng-inail-common 2.0.30-beta.3 → 2.0.30-beta.7

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.
@@ -4155,6 +4155,8 @@
4155
4155
  if (changes.value && !changes.value.firstChange) {
4156
4156
  this.hasError = false;
4157
4157
  this.error = undefined;
4158
+ this.hasErrorChange.emit(this.hasError);
4159
+ this.errorChange.emit(this.error);
4158
4160
  }
4159
4161
  // Se cambiano le options o gli array delle date abilitate/disabilitate
4160
4162
  // reinizializzo il componente
@@ -6756,6 +6758,170 @@
6756
6758
  sort: [{ type: core.Input }]
6757
6759
  };
6758
6760
 
6761
+ var HM_PLACEHOLDER = 'HH:MM';
6762
+ var HMS_PLACEHOLDER = 'HH:MM:SS';
6763
+ var ACCEPTED_INPUTS = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'Backspace', 'Delete'];
6764
+ var InputTimeComponent = /** @class */ (function (_super) {
6765
+ __extends(InputTimeComponent, _super);
6766
+ function InputTimeComponent(cdr, libConfig) {
6767
+ var _this = this;
6768
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
6769
+ _this = _super.call(this, cdr, libConfig) || this;
6770
+ _this.cdr = cdr;
6771
+ _this.libConfig = libConfig;
6772
+ _this.timeHMRegex = new RegExp(/^((([01]\d)|([2][0-3]))[:]([0-5]\d)$)/);
6773
+ _this.timeHMSRegex = new RegExp(/^((([01]\d)|([2][0-3]))[:]([0-5]\d)[:]([0-5]\d)$)/);
6774
+ _this.validInputRegx = new RegExp(/^([0-9]+[0-9:]*)$/);
6775
+ _this.nativeInputTypeTime = getConfigValue((_b = (_a = _this.libConfig) === null || _a === void 0 ? void 0 : _a.inputTimeComponent) === null || _b === void 0 ? void 0 : _b.nativeInputTypeTime, false);
6776
+ _this.withSeconds = getConfigValue((_d = (_c = _this.libConfig) === null || _c === void 0 ? void 0 : _c.inputTimeComponent) === null || _d === void 0 ? void 0 : _d.withSeconds, false);
6777
+ _this.selfValidation = getConfigValue((_f = (_e = _this.libConfig) === null || _e === void 0 ? void 0 : _e.inputTimeComponent) === null || _f === void 0 ? void 0 : _f.selfValidation, true);
6778
+ _this.selfValidationError = getConfigValue((_h = (_g = _this.libConfig) === null || _g === void 0 ? void 0 : _g.inputTimeComponent) === null || _h === void 0 ? void 0 : _h.selfValidationError, 'Orario non valido');
6779
+ _this.step = getConfigValue((_k = (_j = _this.libConfig) === null || _j === void 0 ? void 0 : _j.inputTimeComponent) === null || _k === void 0 ? void 0 : _k.step, undefined);
6780
+ _this.valueChange = new core.EventEmitter();
6781
+ _this.preventPasting = getConfigValue((_m = (_l = _this.libConfig) === null || _l === void 0 ? void 0 : _l.inputTimeComponent) === null || _m === void 0 ? void 0 : _m.preventPasting, false);
6782
+ _this.getType = function () { return _this.nativeInputTypeTime ? 'time' : 'text'; };
6783
+ _this.getStep = function () { return _this.nativeInputTypeTime ? _this.step : undefined; };
6784
+ _this.getMaxLength = function () { return _this.nativeInputTypeTime ? undefined : (_this.withSeconds ? 8 : 5); };
6785
+ _this.isBefore2Points = function (value) { return (value === null || value === void 0 ? void 0 : value.length) == 2 || (_this.withSeconds == true && (value === null || value === void 0 ? void 0 : value.length) == 5); };
6786
+ _this.isValidValue = function (value) { return _this.withSeconds ? _this.timeHMSRegex.test(value) : _this.timeHMRegex.test(value); };
6787
+ _this.isValidInput = function (value) { return _this.validInputRegx.test(value); };
6788
+ _this.logPrefix = "[inail-input-time]";
6789
+ _this.emitDebug('NgInailCommonConfig:');
6790
+ _this.emitDebug((_o = _this.libConfig) === null || _o === void 0 ? void 0 : _o.inputTimeComponent);
6791
+ _super.prototype.overrideConfig.call(_this, (_p = _this.libConfig) === null || _p === void 0 ? void 0 : _p.inputTimeComponent);
6792
+ _this.detach();
6793
+ return _this;
6794
+ }
6795
+ InputTimeComponent.prototype.ngOnChanges = function (changes) {
6796
+ var _a, _b, _c;
6797
+ _super.prototype.ngOnChanges.call(this, changes);
6798
+ 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);
6800
+ }
6801
+ this.placeholder = this.getNotBlankValue(this.placeholder);
6802
+ this.cdr.detectChanges();
6803
+ };
6804
+ InputTimeComponent.prototype.ngOnInit = function () {
6805
+ var _this = this;
6806
+ _super.prototype.ngOnInit.call(this);
6807
+ this.emitDebug("@ViewChild('formControl')");
6808
+ this.emitDebug(this.formControlElement);
6809
+ if (this.focus) {
6810
+ this.push(this.focus.subscribe(function (scroll) {
6811
+ _this.emitDebug("Catch focus!");
6812
+ setFocus(_this.formControlElement.nativeElement, scroll);
6813
+ }));
6814
+ }
6815
+ };
6816
+ InputTimeComponent.prototype.ngAfterViewInit = function () {
6817
+ };
6818
+ Object.defineProperty(InputTimeComponent.prototype, "value", {
6819
+ get: function () {
6820
+ return this.inputValue;
6821
+ },
6822
+ set: function (value) {
6823
+ this.emitDebug("@Input set value: " + this.inputValue + " -> " + value);
6824
+ this.setValue(value);
6825
+ },
6826
+ enumerable: false,
6827
+ configurable: true
6828
+ });
6829
+ InputTimeComponent.prototype.writeValue = function (value) {
6830
+ this.emitDebug("writeValue: " + value);
6831
+ this.setValue(value);
6832
+ };
6833
+ InputTimeComponent.prototype.setValue = function (value) {
6834
+ this.emitDebug("setValue: " + value);
6835
+ if (this.inputValue != value) {
6836
+ this.emitDebug("update value: " + this.inputValue + " -> " + value);
6837
+ if (!this.nativeInputTypeTime) {
6838
+ value = this.bonificaValore(value);
6839
+ this.inputValue = this.isBefore2Points(value) ? value + ":" : value;
6840
+ if (isNotBlankOrNull(this.inputValue) && this.selfValidation && !this.isValidValue(this.inputValue)) {
6841
+ // console.warn(this.inputValue, this.selfValidation, !this.isValidValue(this.inputValue))
6842
+ this.setDescError(this.selfValidationError);
6843
+ }
6844
+ else {
6845
+ this.cleanError();
6846
+ }
6847
+ }
6848
+ else {
6849
+ this.inputValue = value;
6850
+ this.cleanError();
6851
+ }
6852
+ this.cdr.detectChanges();
6853
+ this.emitDebug("this.valueChange.emit(" + this.inputValue + ")");
6854
+ this.valueChange.emit(this.inputValue);
6855
+ if (this.onChange) {
6856
+ this.onChange(value);
6857
+ }
6858
+ }
6859
+ };
6860
+ InputTimeComponent.prototype.bonificaValore = function (value) {
6861
+ var valoreBonificato = undefined;
6862
+ if (value != undefined) {
6863
+ var parti = value.replace(/([:]{2,})/g, ':').split(':');
6864
+ if (parti[0] != undefined && parti[0] == '24') {
6865
+ parti[0] = '00';
6866
+ }
6867
+ if (parti[1] != undefined && parti[1] == '60') {
6868
+ parti[1] = '00';
6869
+ }
6870
+ if (parti[2] != undefined && parti[2] == '60') {
6871
+ parti[2] = '00';
6872
+ }
6873
+ valoreBonificato = parti.join(':');
6874
+ }
6875
+ return valoreBonificato;
6876
+ };
6877
+ InputTimeComponent.prototype.onPaste = function ($event) {
6878
+ if (this.preventPasting === true) {
6879
+ $event.preventDefault();
6880
+ }
6881
+ };
6882
+ InputTimeComponent.prototype.onKeyDown = function (ev) {
6883
+ if (!ACCEPTED_INPUTS.some(function (v) { return v === ev.key; }) && ev.ctrlKey == false) {
6884
+ ev.preventDefault();
6885
+ }
6886
+ };
6887
+ InputTimeComponent.prototype.ngOnDestroy = function () {
6888
+ _super.prototype.ngOnDestroy.call(this);
6889
+ };
6890
+ return InputTimeComponent;
6891
+ }(FormElementComponent));
6892
+ InputTimeComponent.decorators = [
6893
+ { type: core.Component, args: [{
6894
+ 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",
6896
+ changeDetection: CHANGE_DETECTION_STRATEGY,
6897
+ encapsulation: core.ViewEncapsulation.None,
6898
+ providers: [
6899
+ {
6900
+ provide: forms.NG_VALUE_ACCESSOR,
6901
+ useExisting: core.forwardRef(function () { return InputTimeComponent; }),
6902
+ multi: true
6903
+ }
6904
+ ],
6905
+ styles: [".inail-input-time .form-control-wrapper:after{font-family:FontAwesome;content:\"\\f017\";right:30px;position:absolute;top:30px;font-size:17px}.inail-input-time input[type=time]{padding-right:33px}.inail-input-time .form-control-wrapper.no-label:after{top:11px}"]
6906
+ },] }
6907
+ ];
6908
+ InputTimeComponent.ctorParameters = function () { return [
6909
+ { type: core.ChangeDetectorRef },
6910
+ { type: undefined, decorators: [{ type: core.Inject, args: [NG_INAIL_COMMON_CONFIG,] }] }
6911
+ ]; };
6912
+ InputTimeComponent.propDecorators = {
6913
+ formControlElement: [{ type: core.ViewChild, args: ['formControl', { static: true },] }],
6914
+ nativeInputTypeTime: [{ type: core.Input }],
6915
+ withSeconds: [{ type: core.Input }],
6916
+ selfValidation: [{ type: core.Input }],
6917
+ selfValidationError: [{ type: core.Input }],
6918
+ step: [{ type: core.Input }],
6919
+ placeholder: [{ type: core.Input }],
6920
+ valueChange: [{ type: core.Output }],
6921
+ preventPasting: [{ type: core.Input }],
6922
+ value: [{ type: core.Input }]
6923
+ };
6924
+
6759
6925
  var NgInailCommonModule = /** @class */ (function () {
6760
6926
  function NgInailCommonModule() {
6761
6927
  }
@@ -6822,7 +6988,8 @@
6822
6988
  ContainerComponent,
6823
6989
  TrCheckboxComponent,
6824
6990
  ProgressBarComponent,
6825
- MultiSelectComponent
6991
+ MultiSelectComponent,
6992
+ InputTimeComponent
6826
6993
  ],
6827
6994
  imports: [
6828
6995
  common.CommonModule,
@@ -6872,7 +7039,8 @@
6872
7039
  ContainerComponent,
6873
7040
  TrCheckboxComponent,
6874
7041
  ProgressBarComponent,
6875
- MultiSelectComponent
7042
+ MultiSelectComponent,
7043
+ InputTimeComponent
6876
7044
  ],
6877
7045
  providers: [common.DatePipe]
6878
7046
  },] }
@@ -6909,6 +7077,7 @@
6909
7077
  exports.InputFileComponent = InputFileComponent;
6910
7078
  exports.InputNumberComponent = InputNumberComponent;
6911
7079
  exports.InputTextComponent = InputTextComponent;
7080
+ exports.InputTimeComponent = InputTimeComponent;
6912
7081
  exports.LoaderComponent = LoaderComponent;
6913
7082
  exports.MenuComponent = MenuComponent;
6914
7083
  exports.MenuIntranetComponent = MenuIntranetComponent;