@energycap/components 0.28.6 → 0.28.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.
@@ -8656,6 +8656,151 @@
8656
8656
  currentTab: [{ type: i0.Input }]
8657
8657
  };
8658
8658
 
8659
+ var FormControlLabelComponent = /** @class */ (function () {
8660
+ function FormControlLabelComponent(validationMessageService, translateService) {
8661
+ this.validationMessageService = validationMessageService;
8662
+ this.translateService = translateService;
8663
+ /**
8664
+ * The form control label
8665
+ */
8666
+ this.label = '';
8667
+ /**
8668
+ * The position of the form control label (top|bottom|left)
8669
+ */
8670
+ this.labelPosition = "top";
8671
+ /**An optional string to show if any of the underlying controls has an error. If falsy, one of the
8672
+ * errors from the underlying controls will be used.
8673
+ */
8674
+ this.overrideValidationError = "";
8675
+ /**An optional flag to hide the validation messages.
8676
+ */
8677
+ this.hideValidationMessage = false;
8678
+ /**
8679
+ * All current validation errors
8680
+ *
8681
+ * @type {string}
8682
+ * @memberof FormControlBase
8683
+ */
8684
+ this.validationErrors = "";
8685
+ this.allControlsTouched = false;
8686
+ this.componentDestroyed = new rxjs.Subject();
8687
+ }
8688
+ FormControlLabelComponent.prototype.ngOnInit = function () {
8689
+ return __awaiter(this, void 0, void 0, function () {
8690
+ var _this = this;
8691
+ return __generator(this, function (_a) {
8692
+ // subscribe to statusChanges Observable to take any errors and translate them
8693
+ if (this.control) {
8694
+ this.control.statusChanges
8695
+ .pipe(operators.takeUntil(this.componentDestroyed))
8696
+ .subscribe(function () {
8697
+ _this.translateValidationMessages(_this.getErrors(_this.control));
8698
+ });
8699
+ // (re)set validation messages
8700
+ this.translateValidationMessages(this.getErrors(this.control));
8701
+ }
8702
+ if (this.id) {
8703
+ this.attrId = this.id;
8704
+ }
8705
+ return [2 /*return*/];
8706
+ });
8707
+ });
8708
+ };
8709
+ /**
8710
+ * Angular onDestroy lifecyle hook.
8711
+ * Unsubscribe from any observables
8712
+ *
8713
+ * @see https://angular.io/guide/lifecycle-hooks
8714
+ * @memberof FormControlBase
8715
+ */
8716
+ FormControlLabelComponent.prototype.ngOnDestroy = function () {
8717
+ this.componentDestroyed.next();
8718
+ this.componentDestroyed.unsubscribe();
8719
+ };
8720
+ FormControlLabelComponent.prototype.getErrors = function (control) {
8721
+ var _this = this;
8722
+ control.markAsUntouched();
8723
+ var errors = null;
8724
+ var allTouched = true;
8725
+ var controlFound = false;
8726
+ forEachFormControl(control, function (control) {
8727
+ errors = _this.assignErrors(control, errors);
8728
+ if (control.untouched) {
8729
+ allTouched = false;
8730
+ }
8731
+ controlFound = true;
8732
+ });
8733
+ if (control.errors) {
8734
+ errors = Object.assign(errors || {}, control.errors);
8735
+ }
8736
+ if (allTouched && controlFound) {
8737
+ control.markAsTouched();
8738
+ }
8739
+ return errors;
8740
+ };
8741
+ FormControlLabelComponent.prototype.assignErrors = function (control, errors) {
8742
+ if (control.errors) {
8743
+ errors = Object.assign(errors || {}, control.errors);
8744
+ }
8745
+ return errors;
8746
+ };
8747
+ /**
8748
+ * Function that subscribes to the controls valueChanges Observable
8749
+ * to take any erros and translate them
8750
+ *
8751
+ * @param {*} [data]
8752
+ * @returns
8753
+ * @memberof FormControlBase
8754
+ */
8755
+ FormControlLabelComponent.prototype.translateValidationMessages = function (errors) {
8756
+ return __awaiter(this, void 0, void 0, function () {
8757
+ var messages;
8758
+ return __generator(this, function (_a) {
8759
+ switch (_a.label) {
8760
+ case 0:
8761
+ if (!errors) return [3 /*break*/, 4];
8762
+ if (!this.overrideValidationError) return [3 /*break*/, 1];
8763
+ this.validationErrors = this.translateService.instant(this.overrideValidationError);
8764
+ return [3 /*break*/, 3];
8765
+ case 1: return [4 /*yield*/, this.validationMessageService.getErrorMessages(errors)];
8766
+ case 2:
8767
+ messages = _a.sent();
8768
+ if (messages) {
8769
+ this.validationErrors = messages.join('; ');
8770
+ }
8771
+ _a.label = 3;
8772
+ case 3: return [3 /*break*/, 5];
8773
+ case 4:
8774
+ this.validationErrors = '';
8775
+ _a.label = 5;
8776
+ case 5: return [2 /*return*/];
8777
+ }
8778
+ });
8779
+ });
8780
+ };
8781
+ return FormControlLabelComponent;
8782
+ }());
8783
+ FormControlLabelComponent.decorators = [
8784
+ { type: i0.Component, args: [{
8785
+ selector: 'ec-form-control-label',
8786
+ template: "<div class=\"control control-label-{{labelPosition}}\" [class.ec-untouched]=\"control?.untouched\">\r\n <label *ngIf=\"label\" ngPreserveWhitespaces>\r\n\r\n <span id=\"{{id}}_label\">{{label | translate}}</span>\r\n\r\n <span *ngIf=\"!hideValidationMessage && validationErrors && control?.touched && control?.invalid\">{{validationErrors | translate}}</span>\r\n </label>\r\n</div>",
8787
+ styles: ["@-webkit-keyframes spin{0%{transform:rotate(0)}to{transform:rotate(1turn)}}@keyframes spin{0%{transform:rotate(0)}to{transform:rotate(1turn)}}:host{color:#1a1a23;display:block;font-family:Roboto,-apple-system,BlinkMacSystemFont,Segoe UI,Oxygen,Ubuntu,Fira Sans,Droid Sans,Helvetica Neue,sans-serif;font-size:1rem;margin-bottom:1rem;width:100%}:host :host-context(.form-condensed){margin-bottom:.5rem}:host .control{display:flex;flex-direction:column;width:100%}:host .control.control-label-bottom{flex-direction:column-reverse}:host .control.control-label-left{flex-direction:row}:host .control.control-label-left label{margin-right:.25rem}:host .control.control-label-right{flex-direction:row-reverse}:host .control.control-label-right label{margin-left:.25rem}:host .control.control-label-left,:host .control.control-label-right{align-items:center}:host .control.control-label-left label,:host .control.control-label-right label{flex:1 1;margin-bottom:0;margin-top:0}:host .control.control-label-left .control-input,:host .control.control-label-right .control-input{flex:2 2}:host .control.is-readonly input,:host .control.is-readonly select{-moz-user-select:none;-ms-user-select:none;-webkit-user-select:none;background-clip:border-box;background-color:rgba(26,26,35,.12);background-image:none;border-color:transparent;color:#1a1a23;opacity:1;overflow:hidden;pointer-events:none;user-select:none;white-space:nowrap}:host .control.invalid .textbox-group-input ::ng-deep .control input.ng-invalid,:host .control.invalid .textbox-group-input ::ng-deep .control input.ng-valid{background-color:#fff8cc;background-image:url('data:image/svg+xml;charset=utf8,<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 32 32\"><path fill=\"rgba(26, 26, 35, 0.66)\" d=\"M20.21 20.21h-8.42L10.95 0h10.1l-.84 20.21zm-8.42 3.37h8.42V32h-8.42z\"/></svg>');background-position:.25em;background-repeat:no-repeat;background-size:1em 1em;padding-left:1.5em}:host .control.invalid .textbox-group-input ::ng-deep .control input.ng-invalid:not(:focus),:host .control.invalid .textbox-group-input ::ng-deep .control input.ng-valid:not(:focus){border-color:#ffe433}:host .control.invalid:not(.open) .textbox-group-btn-right ::ng-deep button{background-color:#fff8cc}:host .control.invalid:not(.open) .textbox-group-btn-right ::ng-deep button:not(:focus){border-color:#ffe433}:host .textbox-group{display:flex;position:relative}:host input:focus,:host select:focus,:host textarea:focus{outline:none}label{color:rgba(26,26,35,.66);display:block;font-size:.75rem;line-height:1;margin:.375rem 0}.control.ec-untouched ::ng-deep input.ng-invalid.ng-touched{background-image:none;padding-left:.5rem}.control.ec-untouched ::ng-deep input.ng-invalid.ng-touched:not(.is-empty)~.units-left{left:0}.control.ec-untouched ::ng-deep input:required:not(:disabled).is-empty{background-color:#fff;background-image:url('data:image/svg+xml;charset=utf8,<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 32 32\"><path fill=\"%23ffe433\" d=\"M31.32 21.69l-.09.18-2.48 4.35c-.36.54-.77.62-1.25.27-.12 0-.2 0-.2-.09L19.53 22v9.37a1.26 1.26 0 0 1-.72.67h-5.26c-.59 0-.83-.3-.83-.89 0-.12.15-.21.15-.27V22l-8 4.71h-.12c-.42.66-.8.21-1.16-.27L1 21.82a.82.82 0 0 1 .35-1.26l.18-.1L9 16 .87 11.47v-.09c0-.36-.39-.74-.09-1.16l2.75-4.35v-.09c0-.42.82-.54 1.29-.36l8 4.62V.89c0-.59.18-.89.77-.89h5c.65 0 .91.3.91.89V10l7.94-4.53c.48-.29.72-.21 1.08.27l2.32 4.35v.09c.66.48.45.89-.08 1.25L23 16l7.91 4.53v.09c-.04.18.53.54.41 1.07z\"/></svg>');background-position:.25em;background-repeat:no-repeat;background-size:1em 1em;border-color:#d2d7d9;padding-left:1.5em}.control.ec-untouched ::ng-deep input:required:not(:disabled).is-empty:focus{border-color:#0084a9;box-shadow:0 0 0 1px #0084a9;position:relative;z-index:1}.control-label-left{display:flex}"]
8788
+ },] }
8789
+ ];
8790
+ FormControlLabelComponent.ctorParameters = function () { return [
8791
+ { type: ValidationMessageService },
8792
+ { type: i1.TranslateService }
8793
+ ]; };
8794
+ FormControlLabelComponent.propDecorators = {
8795
+ id: [{ type: i0.Input }],
8796
+ attrId: [{ type: i0.HostBinding, args: ['attr.id',] }],
8797
+ label: [{ type: i0.Input }],
8798
+ control: [{ type: i0.Input }],
8799
+ labelPosition: [{ type: i0.Input }],
8800
+ overrideValidationError: [{ type: i0.Input }],
8801
+ hideValidationMessage: [{ type: i0.Input }]
8802
+ };
8803
+
8659
8804
  var ComponentsModule = /** @class */ (function () {
8660
8805
  function ComponentsModule() {
8661
8806
  }
@@ -8736,7 +8881,8 @@
8736
8881
  TreeComponent,
8737
8882
  RelativeDatePipe,
8738
8883
  ResizableComponent,
8739
- HighlightTextPipe
8884
+ HighlightTextPipe,
8885
+ FormControlLabelComponent
8740
8886
  ],
8741
8887
  imports: [
8742
8888
  common.CommonModule,
@@ -8811,7 +8957,8 @@
8811
8957
  TreeComponent,
8812
8958
  RelativeDatePipe,
8813
8959
  ResizableComponent,
8814
- HighlightTextPipe
8960
+ HighlightTextPipe,
8961
+ FormControlLabelComponent
8815
8962
  ]
8816
8963
  },] }
8817
8964
  ];
@@ -9971,6 +10118,7 @@
9971
10118
  exports.FileUploadComponent = FileUploadComponent;
9972
10119
  exports.FormControlBase = FormControlBase;
9973
10120
  exports.FormControlComponent = FormControlComponent;
10121
+ exports.FormControlLabelComponent = FormControlLabelComponent;
9974
10122
  exports.FormGroupComponent = FormGroupComponent;
9975
10123
  exports.FormGroupHelper = FormGroupHelper;
9976
10124
  exports.HierarchyBase = HierarchyBase;