badge.d.ts 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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 { ElementRef, NgZone, OnChanges, OnDestroy, Renderer2, SimpleChanges } from '@angular/core';
  10. import { CanDisable, CanDisableCtor, ThemePalette } from '@angular/material/core';
  11. /** @docs-private */
  12. declare class MatBadgeBase {
  13. }
  14. declare const _MatBadgeMixinBase: CanDisableCtor & typeof MatBadgeBase;
  15. export declare type MatBadgePosition = 'above after' | 'above before' | 'below before' | 'below after';
  16. export declare type MatBadgeSize = 'small' | 'medium' | 'large';
  17. /** Directive to display a text badge. */
  18. export declare class MatBadge extends _MatBadgeMixinBase implements OnDestroy, OnChanges, CanDisable {
  19. private _ngZone;
  20. private _elementRef;
  21. private _ariaDescriber;
  22. private _renderer;
  23. private _animationMode?;
  24. /** Whether the badge has any content. */
  25. _hasContent: boolean;
  26. /** The color of the badge. Can be `primary`, `accent`, or `warn`. */
  27. color: ThemePalette;
  28. private _color;
  29. /** Whether the badge should overlap its contents or not */
  30. overlap: boolean;
  31. private _overlap;
  32. /**
  33. * Position the badge should reside.
  34. * Accepts any combination of 'above'|'below' and 'before'|'after'
  35. */
  36. position: MatBadgePosition;
  37. /** The content for the badge */
  38. content: string;
  39. /** Message used to describe the decorated element via aria-describedby */
  40. description: string;
  41. private _description;
  42. /** Size of the badge. Can be 'small', 'medium', or 'large'. */
  43. size: MatBadgeSize;
  44. /** Whether the badge is hidden. */
  45. hidden: boolean;
  46. private _hidden;
  47. /** Unique id for the badge */
  48. _id: number;
  49. private _badgeElement;
  50. constructor(_ngZone: NgZone, _elementRef: ElementRef<HTMLElement>, _ariaDescriber: AriaDescriber, _renderer: Renderer2, _animationMode?: string | undefined);
  51. /** Whether the badge is above the host or not */
  52. isAbove(): boolean;
  53. /** Whether the badge is after the host or not */
  54. isAfter(): boolean;
  55. ngOnChanges(changes: SimpleChanges): void;
  56. ngOnDestroy(): void;
  57. /**
  58. * Gets the element into which the badge's content is being rendered.
  59. * Undefined if the element hasn't been created (e.g. if the badge doesn't have content).
  60. */
  61. getBadgeElement(): HTMLElement | undefined;
  62. /** Injects a span element into the DOM with the content. */
  63. private _updateTextContent;
  64. /** Creates the badge element */
  65. private _createBadgeElement;
  66. /** Sets the aria-label property on the element */
  67. private _updateHostAriaDescription;
  68. /** Adds css theme class given the color to the component host */
  69. private _setColor;
  70. /** Clears any existing badges that might be left over from server-side rendering. */
  71. private _clearExistingBadges;
  72. }
  73. export {};