chore: copia de libs/shared con prefijo Pi y APIs de terceros actualizadas
This commit is contained in:
40
libs/ui/src/lib/util/affix/affix.directive.ts
Normal file
40
libs/ui/src/lib/util/affix/affix.directive.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
import { Directive, ElementRef, HostBinding, Input, OnInit, Renderer2 } from '@angular/core';
|
||||
import { unit } from '../models';
|
||||
|
||||
@Directive()
|
||||
export abstract class PiBaseAffixDirective implements OnInit {
|
||||
@HostBinding('class') get classes(): string {
|
||||
return ['pi-affix', `pi-affix__appearance--${this.appearance}`].join(' ');
|
||||
}
|
||||
|
||||
@Input() unit: unit | string | undefined;
|
||||
@Input() appearance: 'ghost' | 'fill' = 'ghost';
|
||||
|
||||
constructor(private renderer: Renderer2, private el: ElementRef) {}
|
||||
|
||||
ngOnInit() {
|
||||
if (this.unit) {
|
||||
const span = this.renderer.createElement('span');
|
||||
const text = this.renderer.createText(this.unit);
|
||||
|
||||
this.renderer.appendChild(span, text);
|
||||
this.renderer.appendChild(this.el.nativeElement, span);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Directive({
|
||||
standalone: false,
|
||||
selector: 'pi-prefix',
|
||||
})
|
||||
export class PiPrefixDirective extends PiBaseAffixDirective {
|
||||
@HostBinding('class') className = 'pi-affix__prefix';
|
||||
}
|
||||
|
||||
@Directive({
|
||||
standalone: false,
|
||||
selector: 'pi-suffix',
|
||||
})
|
||||
export class PiSuffixDirective extends PiBaseAffixDirective {
|
||||
@HostBinding('class') className = 'pi-affix__suffix';
|
||||
}
|
||||
Reference in New Issue
Block a user