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

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