|
| 1 | +import { Directive, ElementRef, Input, Renderer2 } from '@angular/core'; |
| 2 | +import { type Chip, chipTag } from '@ni/nimble-components/dist/esm/chip'; |
| 3 | +import { ChipAppearance } from '@ni/nimble-components/dist/esm/chip/types'; |
| 4 | +import { type BooleanValueOrAttribute, toBooleanProperty } from '@ni/nimble-angular/internal-utilities'; |
| 5 | + |
| 6 | +export type { Chip }; |
| 7 | +export { chipTag }; |
| 8 | +export { ChipAppearance }; |
| 9 | + |
| 10 | +/** |
| 11 | + * Directive to provide Angular integration for the chip. |
| 12 | + */ |
| 13 | +@Directive({ |
| 14 | + selector: 'nimble-chip', |
| 15 | + standalone: false |
| 16 | +}) |
| 17 | +export class NimbleChipDirective { |
| 18 | + public get removable(): boolean { |
| 19 | + return this.elementRef.nativeElement.removable; |
| 20 | + } |
| 21 | + |
| 22 | + @Input() public set removable(value: BooleanValueOrAttribute) { |
| 23 | + this.renderer.setProperty(this.elementRef.nativeElement, 'removable', toBooleanProperty(value)); |
| 24 | + } |
| 25 | + |
| 26 | + public get disabled(): boolean { |
| 27 | + return this.elementRef.nativeElement.disabled; |
| 28 | + } |
| 29 | + |
| 30 | + @Input() public set disabled(value: BooleanValueOrAttribute) { |
| 31 | + this.renderer.setProperty(this.elementRef.nativeElement, 'disabled', toBooleanProperty(value)); |
| 32 | + } |
| 33 | + |
| 34 | + public get appearance(): ChipAppearance { |
| 35 | + return this.elementRef.nativeElement.appearance; |
| 36 | + } |
| 37 | + |
| 38 | + @Input() public set appearance(value: ChipAppearance) { |
| 39 | + this.renderer.setProperty(this.elementRef.nativeElement, 'appearance', value); |
| 40 | + } |
| 41 | + |
| 42 | + public constructor(private readonly renderer: Renderer2, private readonly elementRef: ElementRef<Chip>) {} |
| 43 | +} |
0 commit comments