All files / src/app/shared/formly/wrappers/input-addon-wrapper input-addon-wrapper.component.ts

45.45% Statements 5/11
0% Branches 0/6
0% Functions 0/2
40% Lines 4/10

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 321x 1x 1x                           1x                              
import { ChangeDetectionStrategy, Component } from '@angular/core';
import { FieldWrapper } from '@ngx-formly/core';
import { of } from 'rxjs';
 
/**
 * Wrapper to add input-addons to fields, using bootstrap styling.
 *
 *  @props **addonRight** - object of type ``{ text: string }`` or ``{ text: Observable<string> }`` that will be used to render an input addon to the right of the field.
 *  @props **addonLeft** - object of type ``{ text: string }`` or ``{ text: Observable<string> }`` that will be used to render an input addon to the left of the field.
 *
 */
@Component({
  selector: 'ish-input-addon-wrapper',
  templateUrl: './input-addon-wrapper.component.html',
  changeDetection: ChangeDetectionStrategy.OnPush,
})
export class InputAddonWrapperComponent extends FieldWrapper {
  get addonLeftText() {
    Iif (!this.props.addonLeft?.text) {
      return;
    }
    return typeof this.props.addonLeft.text === 'string' ? of(this.props.addonLeft.text) : this.props.addonLeft.text;
  }
 
  get addonRightText() {
    Iif (!this.props.addonRight?.text) {
      return;
    }
    return typeof this.props.addonRight.text === 'string' ? of(this.props.addonRight.text) : this.props.addonRight.text;
  }
}