|
1 | 1 | import { Directive, HostBinding, Input } from '@angular/core';
|
2 |
| -import { Colors } from '../coreui.types'; |
| 2 | +import { BooleanInput, coerceBooleanProperty } from '@angular/cdk/coercion'; |
3 | 3 |
|
4 | 4 | @Directive({
|
5 |
| - selector: '[cPlaceholder]' |
| 5 | + selector: '[cPlaceholder]', |
| 6 | + exportAs: 'cPlaceholder' |
6 | 7 | })
|
7 | 8 | export class PlaceholderDirective {
|
8 | 9 |
|
9 |
| - constructor() { } |
| 10 | + static ngAcceptInputType_visible: BooleanInput; |
10 | 11 |
|
11 |
| - /** |
12 |
| - * Animation type for placeholder |
13 |
| - * @type 'glow' | 'wave' |
14 |
| - * @default undefined |
15 |
| - */ |
16 |
| - @Input() animation?: 'glow' | 'wave'; |
| 12 | + constructor() { } |
17 | 13 |
|
18 | 14 | /**
|
19 |
| - * Custom color for placeholder |
20 |
| - * @type Colors |
21 |
| - * @default undefined |
| 15 | + * placeholder toggler |
| 16 | + * @type boolean |
| 17 | + * @default true |
22 | 18 | */
|
23 |
| - @Input('cPlaceholderColor') color?: Colors; |
| 19 | + @Input('cPlaceholder') |
| 20 | + set visible(value: boolean) { |
| 21 | + this._visible = coerceBooleanProperty(value); |
| 22 | + } |
| 23 | + get visible() { |
| 24 | + return this._visible; |
| 25 | + } |
| 26 | + private _visible: boolean = false; |
24 | 27 |
|
25 | 28 | /**
|
26 | 29 | * Size the placeholder extra small, small, large.
|
27 | 30 | */
|
28 | 31 | @Input('cPlaceholderSize') size?: 'xs' | 'sm' | 'lg';
|
29 | 32 |
|
| 33 | + @HostBinding('attr.aria-hidden') |
| 34 | + get ariaHidden(): boolean | null { |
| 35 | + return this.visible ? null : true; |
| 36 | + }; |
| 37 | + |
30 | 38 | @HostBinding('class')
|
31 | 39 | get hostClasses(): any {
|
32 | 40 | return {
|
33 |
| - 'placeholder': true, |
34 |
| - [`placeholder-${this.animation}`]: !!this.animation, |
35 |
| - [`placeholder-${this.size}`]: !!this.size, |
36 |
| - [`bg-${this.color}`]: !!this.color |
| 41 | + 'placeholder': this.visible, |
| 42 | + [`placeholder-${this.size}`]: !!this.size |
37 | 43 | };
|
38 | 44 | }
|
39 |
| - |
40 | 45 | }
|
0 commit comments