import * as ng_primitives_rating from 'ng-primitives/rating'; import * as _angular_core from '@angular/core'; import { WritableSignal, Signal, Provider } from '@angular/core'; import { NumberInput, BooleanInput } from '@angular/cdk/coercion'; import * as ng_primitives_state from 'ng-primitives/state'; import { SetterOptions } from 'ng-primitives/state'; import { Observable } from 'rxjs'; /** * Apply the `ngpRating` directive to an element that represents the rating. It * exposes the slider role and owns the value, keyboard, and form integration. * Project the star markup once via the `*ngpRatingItem` structural directive. */ declare class NgpRating { private readonly config; /** * The id of the rating. If not provided, a unique id will be generated. */ readonly id: _angular_core.InputSignal; /** * The value of the rating. When defined the rating is controlled. */ readonly value: _angular_core.InputSignalWithTransform; /** * The default value of the rating for uncontrolled usage. * @default 0 */ readonly defaultValue: _angular_core.InputSignalWithTransform; /** * Emits when the value changes. */ readonly valueChange: _angular_core.OutputEmitterRef; /** * The number of items in the rating. */ readonly count: _angular_core.InputSignalWithTransform; /** * Whether half values are allowed. */ readonly allowHalf: _angular_core.InputSignalWithTransform; /** * Whether the rating is disabled. */ readonly disabled: _angular_core.InputSignalWithTransform; /** * Whether the rating is read-only. */ readonly readonly: _angular_core.InputSignalWithTransform; /** * Whether re-selecting the current value clears the rating to 0 (deselection). */ readonly clearable: _angular_core.InputSignalWithTransform; /** * Produce the `aria-valuetext` announced to assistive technology. */ readonly valueText: _angular_core.InputSignal<(value: number, count: number) => string>; /** * The state of the rating. */ protected readonly state: ng_primitives_rating.NgpRatingState; /** * Set the value of the rating. */ setValue(value: number, options?: SetterOptions): void; static ɵfac: _angular_core.ɵɵFactoryDeclaration; static ɵdir: _angular_core.ɵɵDirectiveDeclaration; } /** * The derived render state for a single rating item (star). */ interface NgpRatingItemState { /** The 1-based position of the item. */ readonly index: number; /** Whether the item is fully filled. */ readonly checked: boolean; /** Whether the item is half filled (only when `allowHalf`). */ readonly half: boolean; /** The fill amount of the item, 0-1 (for fractional/readonly averages). */ readonly fraction: number; /** Whether the item is part of the current hover preview. */ readonly highlighted: boolean; } /** * Public state surface for the Rating primitive. */ interface NgpRatingState { /** The id of the rating. */ readonly id: Signal; /** The committed rating value. */ readonly value: WritableSignal; /** The number of items. */ readonly count: Signal; /** Whether half values are allowed. */ readonly allowHalf: Signal; /** Whether the rating is disabled (includes form control state). */ readonly disabled: Signal; /** Whether the rating is read-only. */ readonly readonly: Signal; /** Emits when the committed value changes. */ readonly valueChange: Observable; /** Set the committed value (clamped to `[0, count]`). */ setValue(value: number, options?: SetterOptions): void; /** Set the default value used in uncontrolled mode. */ setDefaultValue(value: number): void; /** Set the disabled state (merged with any form control disabled state). */ setDisabled(disabled: boolean): void; /** * @internal Commit an interactive value, clearing to 0 when re-selecting the * current value. */ commit(value: number): void; /** * @internal Set the hover preview value. */ preview(value: number): void; /** * @internal Derive the render state for the item at `index` (1-based). */ itemState(index: number): NgpRatingItemState; } /** * Inputs for configuring the Rating primitive. */ interface NgpRatingProps { /** The id of the rating. */ readonly id?: Signal; /** The committed rating value. When defined the rating is controlled. */ readonly value?: Signal; /** The default rating value for uncontrolled usage. */ readonly defaultValue?: Signal; /** The number of items. */ readonly count?: Signal; /** Whether half values are allowed. */ readonly allowHalf?: Signal; /** Whether the rating is disabled. */ readonly disabled?: Signal; /** Whether the rating is read-only. */ readonly readonly?: Signal; /** Whether re-selecting the current value clears the rating to 0. */ readonly clearable?: Signal; /** Produce the `aria-valuetext` string. */ readonly valueText?: Signal<(value: number, count: number) => string>; /** Callback fired when the committed value changes. */ readonly onValueChange?: (value: number) => void; } declare const NgpRatingStateToken: _angular_core.InjectionToken>; declare const ngpRating: ({ id, value: _value, defaultValue: _defaultValue, count, allowHalf, disabled: _disabled, readonly, clearable, valueText, onValueChange, }: NgpRatingProps) => NgpRatingState; declare const injectRatingState: { (): Signal; (options: ng_primitives_state.StateInjectionOptions): Signal; (options?: ng_primitives_state.StateInjectionOptions): Signal | Signal; }; declare const provideRatingState: (opts?: { inherit?: boolean; }) => _angular_core.FactoryProvider; interface NgpRatingConfig { /** * The default number of items in the rating. */ count: number; /** * Whether re-selecting the current value clears the rating to 0 (deselection). */ clearable: boolean; /** * Produce the `aria-valuetext` announced to assistive technology. Override * for localisation. */ valueText: (value: number, count: number) => string; } /** * Provide the default Rating configuration * @param config The Rating configuration * @returns The provider */ declare function provideRatingConfig(config: Partial): Provider[]; /** * The render context exposed to the `*ngpRatingItem` template. Every field is * derived reactively from the rating value / hover state, so the template * updates automatically as the rating changes. */ interface NgpRatingItemContext { $implicit: NgpRatingItemState; } /** * A structural directive that renders one item (star) per `count`, driven by the * parent `ngpRating`. Each generated element automatically receives the * `data-checked`, `data-half` and `data-highlighted` attributes and has its * pointer interactions wired up via the `ngpRatingItem` state function. */ declare class NgpRatingItem { private readonly template; private readonly viewContainer; private readonly state; static ngTemplateContextGuard(_: NgpRatingItem, context: unknown): context is NgpRatingItemContext; constructor(); static ɵfac: _angular_core.ɵɵFactoryDeclaration; static ɵdir: _angular_core.ɵɵDirectiveDeclaration; } /** * Inputs for the rating item state function. The parent passes exactly what the * item needs - the item never reaches back into the rating state. */ interface NgpRatingItemProps { /** The 1-based position of the item. */ readonly index: number; /** Whether the item is fully filled. */ readonly checked: Signal; /** Whether the item is half filled. */ readonly half: Signal; /** The fill amount of the item, 0-1. */ readonly fraction: Signal; /** Whether the item is part of the current hover preview. */ readonly highlighted: Signal; /** Whether half values are allowed (for pointer half-detection). */ readonly allowHalf: Signal; /** Preview the value the pointer is over. */ readonly preview: (value: number) => void; /** Commit the value the pointer selects. */ readonly commit: (value: number) => void; } /** * The state function for a single rendered rating item. Reflects the item's * state onto the element as data attributes, wires the pointer interactions * (hover preview + click, with half-value detection), and returns the item's * render state - which `renderList` exposes as the `*ngpRatingItem` context. * * Runs inside the render-pass injection context provided by `renderList`, so its * element is available via `injectElementRef()` and its `dataBinding` effects and * listeners are cleaned up automatically. */ declare const NgpRatingItemStateToken: _angular_core.InjectionToken<_angular_core.WritableSignal>; declare const ngpRatingItem: ({ index, checked, half, fraction, highlighted, allowHalf, preview, commit, }: NgpRatingItemProps) => NgpRatingItemState; declare const injectRatingItemState: { (): Signal; (options: ng_primitives_state.StateInjectionOptions): Signal; (options?: ng_primitives_state.StateInjectionOptions): Signal | Signal; }; declare const provideRatingItemState: (opts?: { inherit?: boolean; }) => _angular_core.FactoryProvider; export { NgpRating, NgpRatingItem, NgpRatingItemStateToken, NgpRatingStateToken, injectRatingItemState, injectRatingState, ngpRating, ngpRatingItem, provideRatingConfig, provideRatingItemState, provideRatingState }; export type { NgpRatingConfig, NgpRatingItemContext, NgpRatingItemProps, NgpRatingItemState, NgpRatingProps, NgpRatingState };