rating.d.ts 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. import { ChangeDetectorRef, EventEmitter, OnChanges, OnInit, SimpleChanges, TemplateRef } from '@angular/core';
  2. import { NgbRatingConfig } from './rating-config';
  3. import { ControlValueAccessor } from '@angular/forms';
  4. /**
  5. * The context for the custom star display template defined in the `starTemplate`.
  6. */
  7. export interface StarTemplateContext {
  8. /**
  9. * The star fill percentage, an integer in the `[0, 100]` range.
  10. */
  11. fill: number;
  12. /**
  13. * Index of the star, starts with `0`.
  14. */
  15. index: number;
  16. }
  17. /**
  18. * A directive that helps visualising and interacting with a star rating bar.
  19. */
  20. export declare class NgbRating implements ControlValueAccessor, OnInit, OnChanges {
  21. private _changeDetectorRef;
  22. contexts: StarTemplateContext[];
  23. disabled: boolean;
  24. nextRate: number;
  25. /**
  26. * The maximal rating that can be given.
  27. */
  28. max: number;
  29. /**
  30. * The current rating. Could be a decimal value like `3.75`.
  31. */
  32. rate: number;
  33. /**
  34. * If `true`, the rating can't be changed.
  35. */
  36. readonly: boolean;
  37. /**
  38. * If `true`, the rating can be reset to `0` by mouse clicking currently set rating.
  39. */
  40. resettable: boolean;
  41. /**
  42. * The template to override the way each star is displayed.
  43. *
  44. * Alternatively put an `<ng-template>` as the only child of your `<ngb-rating>` element
  45. */
  46. starTemplate: TemplateRef<StarTemplateContext>;
  47. starTemplateFromContent: TemplateRef<StarTemplateContext>;
  48. /**
  49. * An event emitted when the user is hovering over a given rating.
  50. *
  51. * Event payload equals to the rating being hovered over.
  52. */
  53. hover: EventEmitter<number>;
  54. /**
  55. * An event emitted when the user stops hovering over a given rating.
  56. *
  57. * Event payload equals to the rating of the last item being hovered over.
  58. */
  59. leave: EventEmitter<number>;
  60. /**
  61. * An event emitted when the user selects a new rating.
  62. *
  63. * Event payload equals to the newly selected rating.
  64. */
  65. rateChange: EventEmitter<number>;
  66. onChange: (_: any) => void;
  67. onTouched: () => void;
  68. constructor(config: NgbRatingConfig, _changeDetectorRef: ChangeDetectorRef);
  69. ariaValueText(): string;
  70. enter(value: number): void;
  71. handleBlur(): void;
  72. handleClick(value: number): void;
  73. handleKeyDown(event: KeyboardEvent): void;
  74. ngOnChanges(changes: SimpleChanges): void;
  75. ngOnInit(): void;
  76. registerOnChange(fn: (value: any) => any): void;
  77. registerOnTouched(fn: () => any): void;
  78. reset(): void;
  79. setDisabledState(isDisabled: boolean): void;
  80. update(value: number, internalChange?: boolean): void;
  81. writeValue(value: any): void;
  82. private _getFillValue;
  83. private _updateState;
  84. }