[6a3a178] | 1 | /**
|
---|
| 2 | * @license
|
---|
| 3 | * Copyright Google LLC All Rights Reserved.
|
---|
| 4 | *
|
---|
| 5 | * Use of this source code is governed by an MIT-style license that can be
|
---|
| 6 | * found in the LICENSE file at https://angular.io/license
|
---|
| 7 | */
|
---|
| 8 | import { AriaDescriber } from '@angular/cdk/a11y';
|
---|
| 9 | import { coerceBooleanProperty } from '@angular/cdk/coercion';
|
---|
| 10 | import { Directive, ElementRef, Inject, Input, NgZone, Optional, Renderer2, } from '@angular/core';
|
---|
| 11 | import { mixinDisabled } from '@angular/material/core';
|
---|
| 12 | import { ANIMATION_MODULE_TYPE } from '@angular/platform-browser/animations';
|
---|
| 13 | let nextId = 0;
|
---|
| 14 | // Boilerplate for applying mixins to MatBadge.
|
---|
| 15 | /** @docs-private */
|
---|
| 16 | const _MatBadgeBase = mixinDisabled(class {
|
---|
| 17 | });
|
---|
| 18 | /** Directive to display a text badge. */
|
---|
| 19 | export class MatBadge extends _MatBadgeBase {
|
---|
| 20 | constructor(_ngZone, _elementRef, _ariaDescriber, _renderer, _animationMode) {
|
---|
| 21 | super();
|
---|
| 22 | this._ngZone = _ngZone;
|
---|
| 23 | this._elementRef = _elementRef;
|
---|
| 24 | this._ariaDescriber = _ariaDescriber;
|
---|
| 25 | this._renderer = _renderer;
|
---|
| 26 | this._animationMode = _animationMode;
|
---|
[fa375fe] | 27 | /** Whether the badge has any content. */
|
---|
| 28 | this._hasContent = false;
|
---|
[6a3a178] | 29 | this._color = 'primary';
|
---|
| 30 | this._overlap = true;
|
---|
| 31 | /**
|
---|
| 32 | * Position the badge should reside.
|
---|
| 33 | * Accepts any combination of 'above'|'below' and 'before'|'after'
|
---|
| 34 | */
|
---|
| 35 | this.position = 'above after';
|
---|
| 36 | /** Size of the badge. Can be 'small', 'medium', or 'large'. */
|
---|
| 37 | this.size = 'medium';
|
---|
| 38 | /** Unique id for the badge */
|
---|
| 39 | this._id = nextId++;
|
---|
| 40 | if (typeof ngDevMode === 'undefined' || ngDevMode) {
|
---|
| 41 | const nativeElement = _elementRef.nativeElement;
|
---|
| 42 | if (nativeElement.nodeType !== nativeElement.ELEMENT_NODE) {
|
---|
| 43 | throw Error('matBadge must be attached to an element node.');
|
---|
| 44 | }
|
---|
| 45 | }
|
---|
| 46 | }
|
---|
| 47 | /** The color of the badge. Can be `primary`, `accent`, or `warn`. */
|
---|
| 48 | get color() { return this._color; }
|
---|
| 49 | set color(value) {
|
---|
| 50 | this._setColor(value);
|
---|
| 51 | this._color = value;
|
---|
| 52 | }
|
---|
| 53 | /** Whether the badge should overlap its contents or not */
|
---|
| 54 | get overlap() { return this._overlap; }
|
---|
| 55 | set overlap(val) {
|
---|
| 56 | this._overlap = coerceBooleanProperty(val);
|
---|
| 57 | }
|
---|
| 58 | /** Message used to describe the decorated element via aria-describedby */
|
---|
| 59 | get description() { return this._description; }
|
---|
| 60 | set description(newDescription) {
|
---|
[fa375fe] | 61 | if (newDescription !== this._description) {
|
---|
| 62 | const badgeElement = this._badgeElement;
|
---|
| 63 | this._updateHostAriaDescription(newDescription, this._description);
|
---|
| 64 | this._description = newDescription;
|
---|
| 65 | if (badgeElement) {
|
---|
| 66 | newDescription ? badgeElement.setAttribute('aria-label', newDescription) :
|
---|
| 67 | badgeElement.removeAttribute('aria-label');
|
---|
| 68 | }
|
---|
| 69 | }
|
---|
[6a3a178] | 70 | }
|
---|
| 71 | /** Whether the badge is hidden. */
|
---|
| 72 | get hidden() { return this._hidden; }
|
---|
| 73 | set hidden(val) {
|
---|
| 74 | this._hidden = coerceBooleanProperty(val);
|
---|
| 75 | }
|
---|
| 76 | /** Whether the badge is above the host or not */
|
---|
| 77 | isAbove() {
|
---|
| 78 | return this.position.indexOf('below') === -1;
|
---|
| 79 | }
|
---|
| 80 | /** Whether the badge is after the host or not */
|
---|
| 81 | isAfter() {
|
---|
| 82 | return this.position.indexOf('before') === -1;
|
---|
| 83 | }
|
---|
[fa375fe] | 84 | ngOnChanges(changes) {
|
---|
| 85 | const contentChange = changes['content'];
|
---|
| 86 | if (contentChange) {
|
---|
| 87 | const value = contentChange.currentValue;
|
---|
| 88 | this._hasContent = value != null && `${value}`.trim().length > 0;
|
---|
| 89 | this._updateTextContent();
|
---|
| 90 | }
|
---|
| 91 | }
|
---|
| 92 | ngOnDestroy() {
|
---|
| 93 | const badgeElement = this._badgeElement;
|
---|
| 94 | if (badgeElement) {
|
---|
| 95 | if (this.description) {
|
---|
| 96 | this._ariaDescriber.removeDescription(badgeElement, this.description);
|
---|
| 97 | }
|
---|
| 98 | // When creating a badge through the Renderer, Angular will keep it in an index.
|
---|
| 99 | // We have to destroy it ourselves, otherwise it'll be retained in memory.
|
---|
| 100 | if (this._renderer.destroyNode) {
|
---|
| 101 | this._renderer.destroyNode(badgeElement);
|
---|
| 102 | }
|
---|
| 103 | }
|
---|
| 104 | }
|
---|
[6a3a178] | 105 | /**
|
---|
[fa375fe] | 106 | * Gets the element into which the badge's content is being rendered.
|
---|
| 107 | * Undefined if the element hasn't been created (e.g. if the badge doesn't have content).
|
---|
[6a3a178] | 108 | */
|
---|
| 109 | getBadgeElement() {
|
---|
| 110 | return this._badgeElement;
|
---|
| 111 | }
|
---|
[fa375fe] | 112 | /** Injects a span element into the DOM with the content. */
|
---|
| 113 | _updateTextContent() {
|
---|
| 114 | if (!this._badgeElement) {
|
---|
[6a3a178] | 115 | this._badgeElement = this._createBadgeElement();
|
---|
| 116 | }
|
---|
[fa375fe] | 117 | else {
|
---|
| 118 | this._badgeElement.textContent = this._stringifyContent();
|
---|
[6a3a178] | 119 | }
|
---|
[fa375fe] | 120 | return this._badgeElement;
|
---|
[6a3a178] | 121 | }
|
---|
| 122 | /** Creates the badge element */
|
---|
| 123 | _createBadgeElement() {
|
---|
| 124 | const badgeElement = this._renderer.createElement('span');
|
---|
| 125 | const activeClass = 'mat-badge-active';
|
---|
[fa375fe] | 126 | const contentClass = 'mat-badge-content';
|
---|
| 127 | // Clear any existing badges which may have persisted from a server-side render.
|
---|
| 128 | this._clearExistingBadges(contentClass);
|
---|
[6a3a178] | 129 | badgeElement.setAttribute('id', `mat-badge-content-${this._id}`);
|
---|
[fa375fe] | 130 | badgeElement.classList.add(contentClass);
|
---|
| 131 | badgeElement.textContent = this._stringifyContent();
|
---|
[6a3a178] | 132 | if (this._animationMode === 'NoopAnimations') {
|
---|
| 133 | badgeElement.classList.add('_mat-animation-noopable');
|
---|
| 134 | }
|
---|
[fa375fe] | 135 | if (this.description) {
|
---|
| 136 | badgeElement.setAttribute('aria-label', this.description);
|
---|
| 137 | }
|
---|
[6a3a178] | 138 | this._elementRef.nativeElement.appendChild(badgeElement);
|
---|
| 139 | // animate in after insertion
|
---|
| 140 | if (typeof requestAnimationFrame === 'function' && this._animationMode !== 'NoopAnimations') {
|
---|
| 141 | this._ngZone.runOutsideAngular(() => {
|
---|
| 142 | requestAnimationFrame(() => {
|
---|
| 143 | badgeElement.classList.add(activeClass);
|
---|
| 144 | });
|
---|
| 145 | });
|
---|
| 146 | }
|
---|
| 147 | else {
|
---|
| 148 | badgeElement.classList.add(activeClass);
|
---|
| 149 | }
|
---|
| 150 | return badgeElement;
|
---|
| 151 | }
|
---|
[fa375fe] | 152 | /** Sets the aria-label property on the element */
|
---|
| 153 | _updateHostAriaDescription(newDescription, oldDescription) {
|
---|
| 154 | // ensure content available before setting label
|
---|
| 155 | const content = this._updateTextContent();
|
---|
| 156 | if (oldDescription) {
|
---|
| 157 | this._ariaDescriber.removeDescription(content, oldDescription);
|
---|
[6a3a178] | 158 | }
|
---|
| 159 | if (newDescription) {
|
---|
[fa375fe] | 160 | this._ariaDescriber.describe(content, newDescription);
|
---|
[6a3a178] | 161 | }
|
---|
| 162 | }
|
---|
| 163 | /** Adds css theme class given the color to the component host */
|
---|
| 164 | _setColor(colorPalette) {
|
---|
[fa375fe] | 165 | if (colorPalette !== this._color) {
|
---|
| 166 | const classList = this._elementRef.nativeElement.classList;
|
---|
| 167 | if (this._color) {
|
---|
| 168 | classList.remove(`mat-badge-${this._color}`);
|
---|
| 169 | }
|
---|
| 170 | if (colorPalette) {
|
---|
| 171 | classList.add(`mat-badge-${colorPalette}`);
|
---|
| 172 | }
|
---|
[6a3a178] | 173 | }
|
---|
| 174 | }
|
---|
| 175 | /** Clears any existing badges that might be left over from server-side rendering. */
|
---|
[fa375fe] | 176 | _clearExistingBadges(cssClass) {
|
---|
| 177 | const element = this._elementRef.nativeElement;
|
---|
| 178 | let childCount = element.children.length;
|
---|
| 179 | // Use a reverse while, because we'll be removing elements from the list as we're iterating.
|
---|
| 180 | while (childCount--) {
|
---|
| 181 | const currentChild = element.children[childCount];
|
---|
| 182 | if (currentChild.classList.contains(cssClass)) {
|
---|
| 183 | element.removeChild(currentChild);
|
---|
[6a3a178] | 184 | }
|
---|
| 185 | }
|
---|
| 186 | }
|
---|
[fa375fe] | 187 | /** Gets the string representation of the badge content. */
|
---|
| 188 | _stringifyContent() {
|
---|
| 189 | // Convert null and undefined to an empty string which is consistent
|
---|
| 190 | // with how Angular handles them in inside template interpolations.
|
---|
| 191 | const content = this.content;
|
---|
| 192 | return content == null ? '' : `${content}`;
|
---|
| 193 | }
|
---|
[6a3a178] | 194 | }
|
---|
| 195 | MatBadge.decorators = [
|
---|
| 196 | { type: Directive, args: [{
|
---|
| 197 | selector: '[matBadge]',
|
---|
| 198 | inputs: ['disabled: matBadgeDisabled'],
|
---|
| 199 | host: {
|
---|
| 200 | 'class': 'mat-badge',
|
---|
| 201 | '[class.mat-badge-overlap]': 'overlap',
|
---|
| 202 | '[class.mat-badge-above]': 'isAbove()',
|
---|
| 203 | '[class.mat-badge-below]': '!isAbove()',
|
---|
| 204 | '[class.mat-badge-before]': '!isAfter()',
|
---|
| 205 | '[class.mat-badge-after]': 'isAfter()',
|
---|
| 206 | '[class.mat-badge-small]': 'size === "small"',
|
---|
| 207 | '[class.mat-badge-medium]': 'size === "medium"',
|
---|
| 208 | '[class.mat-badge-large]': 'size === "large"',
|
---|
[fa375fe] | 209 | '[class.mat-badge-hidden]': 'hidden || !_hasContent',
|
---|
[6a3a178] | 210 | '[class.mat-badge-disabled]': 'disabled',
|
---|
| 211 | },
|
---|
| 212 | },] }
|
---|
| 213 | ];
|
---|
| 214 | MatBadge.ctorParameters = () => [
|
---|
| 215 | { type: NgZone },
|
---|
| 216 | { type: ElementRef },
|
---|
| 217 | { type: AriaDescriber },
|
---|
| 218 | { type: Renderer2 },
|
---|
| 219 | { type: String, decorators: [{ type: Optional }, { type: Inject, args: [ANIMATION_MODULE_TYPE,] }] }
|
---|
| 220 | ];
|
---|
| 221 | MatBadge.propDecorators = {
|
---|
| 222 | color: [{ type: Input, args: ['matBadgeColor',] }],
|
---|
| 223 | overlap: [{ type: Input, args: ['matBadgeOverlap',] }],
|
---|
| 224 | position: [{ type: Input, args: ['matBadgePosition',] }],
|
---|
| 225 | content: [{ type: Input, args: ['matBadge',] }],
|
---|
| 226 | description: [{ type: Input, args: ['matBadgeDescription',] }],
|
---|
| 227 | size: [{ type: Input, args: ['matBadgeSize',] }],
|
---|
| 228 | hidden: [{ type: Input, args: ['matBadgeHidden',] }]
|
---|
| 229 | };
|
---|
[fa375fe] | 230 | //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYmFkZ2UuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi9zcmMvbWF0ZXJpYWwvYmFkZ2UvYmFkZ2UudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7Ozs7OztHQU1HO0FBRUgsT0FBTyxFQUFDLGFBQWEsRUFBQyxNQUFNLG1CQUFtQixDQUFDO0FBQ2hELE9BQU8sRUFBZSxxQkFBcUIsRUFBQyxNQUFNLHVCQUF1QixDQUFDO0FBQzFFLE9BQU8sRUFDTCxTQUFTLEVBQ1QsVUFBVSxFQUNWLE1BQU0sRUFDTixLQUFLLEVBQ0wsTUFBTSxFQUdOLFFBQVEsRUFDUixTQUFTLEdBRVYsTU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