UNPKG

3.86 kBTypeScriptView Raw
1import { EventEmitter, OnChanges, OnInit, SimpleChanges, TemplateRef } from '@angular/core';
2import { ControlValueAccessor } from '@angular/forms';
3import * as i0 from "@angular/core";
4/**
5 * The context for the custom star display template defined in the `starTemplate`.
6 */
7export 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 */
20export declare class NgbRating implements ControlValueAccessor, OnInit, OnChanges {
21 contexts: StarTemplateContext[];
22 nextRate: number;
23 private _config;
24 private _changeDetectorRef;
25 /**
26 * If `true`, the rating can't be changed or focused.
27 */
28 disabled: boolean;
29 /**
30 * The maximal rating that can be given.
31 */
32 max: number;
33 /**
34 * The current rating. Could be a decimal value like `3.75`.
35 */
36 rate: number;
37 /**
38 * If `true`, the rating can't be changed.
39 */
40 readonly: boolean;
41 /**
42 * If `true`, the rating can be reset to `0` by mouse clicking currently set rating.
43 */
44 resettable: boolean;
45 /**
46 * The template to override the way each star is displayed.
47 *
48 * Alternatively put an `<ng-template>` as the only child of your `<ngb-rating>` element
49 */
50 starTemplate: TemplateRef<StarTemplateContext>;
51 starTemplateFromContent: TemplateRef<StarTemplateContext>;
52 /**
53 * Allows setting a custom rating tabindex.
54 * If the component is disabled, `tabindex` will still be set to `-1`.
55 *
56 * @since 13.1.0
57 */
58 tabindex: string | number;
59 /**
60 * Allows to provide a function to set a custom aria-valuetext
61 *
62 * @since 14.1.0
63 */
64 ariaValueText(current: number, max: number): string;
65 /**
66 * An event emitted when the user is hovering over a given rating.
67 *
68 * Event payload equals to the rating being hovered over.
69 */
70 hover: EventEmitter<number>;
71 /**
72 * An event emitted when the user stops hovering over a given rating.
73 *
74 * Event payload equals to the rating of the last item being hovered over.
75 */
76 leave: EventEmitter<number>;
77 /**
78 * An event emitted when the rating is changed.
79 *
80 * Event payload equals to the newly selected rating.
81 */
82 rateChange: EventEmitter<number>;
83 onChange: (_: any) => void;
84 onTouched: () => void;
85 isInteractive(): boolean;
86 enter(value: number): void;
87 handleBlur(): void;
88 handleClick(value: number): void;
89 handleKeyDown(event: KeyboardEvent): void;
90 ngOnChanges(changes: SimpleChanges): void;
91 ngOnInit(): void;
92 registerOnChange(fn: (value: any) => any): void;
93 registerOnTouched(fn: () => any): void;
94 reset(): void;
95 setDisabledState(isDisabled: boolean): void;
96 update(value: number, internalChange?: boolean): void;
97 writeValue(value: any): void;
98 private _updateState;
99 private _updateMax;
100 private _setupContexts;
101 static ɵfac: i0.ɵɵFactoryDeclaration<NgbRating, never>;
102 static ɵcmp: i0.ɵɵComponentDeclaration<NgbRating, "ngb-rating", never, { "disabled": { "alias": "disabled"; "required": false; }; "max": { "alias": "max"; "required": false; }; "rate": { "alias": "rate"; "required": false; }; "readonly": { "alias": "readonly"; "required": false; }; "resettable": { "alias": "resettable"; "required": false; }; "starTemplate": { "alias": "starTemplate"; "required": false; }; "tabindex": { "alias": "tabindex"; "required": false; }; "ariaValueText": { "alias": "ariaValueText"; "required": false; }; }, { "hover": "hover"; "leave": "leave"; "rateChange": "rateChange"; }, ["starTemplateFromContent"], never, true, never>;
103}