2023-03-01 08:50:51 +00:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* Rating component is a star based selection input.
|
|
|
|
*
|
|
|
|
* [Live Demo](https://www.primevue.org/rating/)
|
|
|
|
*
|
|
|
|
* @module rating
|
|
|
|
*
|
|
|
|
*/
|
2023-01-03 09:31:56 +00:00
|
|
|
import { VNode } from 'vue';
|
2023-07-06 11:17:08 +00:00
|
|
|
import { ComponentHooks } from '../basecomponent';
|
2023-09-05 08:50:46 +00:00
|
|
|
import { PassThroughOptions } from '../passthrough';
|
2024-04-02 08:24:31 +00:00
|
|
|
import { ClassComponent, DesignToken, GlobalComponentConstructor, PassThrough } from '../ts-helpers';
|
2022-09-06 12:03:37 +00:00
|
|
|
|
2023-07-11 22:42:43 +00:00
|
|
|
export declare type RatingPassThroughOptionType = RatingPassThroughAttributes | ((options: RatingPassThroughMethodOptions) => RatingPassThroughAttributes | string) | string | null | undefined;
|
2023-05-06 20:34:27 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Custom passthrough(pt) option method.
|
|
|
|
*/
|
|
|
|
export interface RatingPassThroughMethodOptions {
|
2023-09-05 06:50:04 +00:00
|
|
|
/**
|
|
|
|
* Defines instance.
|
|
|
|
*/
|
2023-07-06 12:01:33 +00:00
|
|
|
instance: any;
|
2023-09-05 06:50:04 +00:00
|
|
|
/**
|
|
|
|
* Defines valid properties.
|
|
|
|
*/
|
2023-05-06 20:34:27 +00:00
|
|
|
props: RatingProps;
|
2023-09-05 06:50:04 +00:00
|
|
|
/**
|
|
|
|
* Defines current inline state.
|
|
|
|
*/
|
2023-05-06 20:34:27 +00:00
|
|
|
state: RatingState;
|
2023-09-05 06:50:04 +00:00
|
|
|
/**
|
|
|
|
* Defines current options.
|
|
|
|
*/
|
2023-05-09 08:34:26 +00:00
|
|
|
context: RatingContext;
|
2023-12-10 21:41:17 +00:00
|
|
|
/**
|
|
|
|
* Defines valid attributes.
|
|
|
|
*/
|
|
|
|
attrs: any;
|
2023-12-05 11:06:32 +00:00
|
|
|
/**
|
|
|
|
* Defines parent options.
|
|
|
|
*/
|
|
|
|
parent: any;
|
2023-09-05 08:50:46 +00:00
|
|
|
/**
|
|
|
|
* Defines passthrough(pt) options in global config.
|
|
|
|
*/
|
|
|
|
global: object | undefined;
|
2023-05-06 20:34:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Custom passthrough(pt) options.
|
|
|
|
* @see {@link RatingProps.pt}
|
|
|
|
*/
|
|
|
|
export interface RatingPassThroughOptions {
|
|
|
|
/**
|
2023-08-01 14:01:12 +00:00
|
|
|
* Used to pass attributes to the root's DOM element.
|
2023-05-06 20:34:27 +00:00
|
|
|
*/
|
|
|
|
root?: RatingPassThroughOptionType;
|
|
|
|
/**
|
2024-05-03 12:23:10 +00:00
|
|
|
* Used to pass attributes to the option's DOM element.
|
2023-05-06 20:34:27 +00:00
|
|
|
*/
|
2024-05-03 12:23:10 +00:00
|
|
|
option?: RatingPassThroughOptionType;
|
2023-05-06 20:34:27 +00:00
|
|
|
/**
|
2023-08-01 14:01:12 +00:00
|
|
|
* Used to pass attributes to the on icon's DOM element.
|
2023-05-06 20:34:27 +00:00
|
|
|
*/
|
|
|
|
onIcon?: RatingPassThroughOptionType;
|
|
|
|
/**
|
2023-08-01 14:01:12 +00:00
|
|
|
* Used to pass attributes to the off icon's DOM element.
|
2023-05-06 20:34:27 +00:00
|
|
|
*/
|
|
|
|
offIcon?: RatingPassThroughOptionType;
|
2023-05-09 08:34:26 +00:00
|
|
|
/**
|
2024-05-06 15:32:04 +00:00
|
|
|
* Used to pass attributes to the hidden option input container's DOM element.
|
2023-05-09 08:34:26 +00:00
|
|
|
*/
|
2024-05-06 15:32:04 +00:00
|
|
|
hiddenOptionInputContainer?: RatingPassThroughOptionType;
|
2023-05-09 08:34:26 +00:00
|
|
|
/**
|
2024-05-03 12:23:10 +00:00
|
|
|
* Used to pass attributes to the hidden option input's DOM element.
|
2023-05-09 08:34:26 +00:00
|
|
|
*/
|
2024-05-03 12:23:10 +00:00
|
|
|
hiddenOptionInput?: RatingPassThroughOptionType;
|
2023-07-06 11:09:01 +00:00
|
|
|
/**
|
2023-11-07 06:16:39 +00:00
|
|
|
* Used to manage all lifecycle hooks.
|
2023-07-06 11:09:01 +00:00
|
|
|
* @see {@link BaseComponent.ComponentHooks}
|
|
|
|
*/
|
|
|
|
hooks?: ComponentHooks;
|
2023-05-06 20:34:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Custom passthrough attributes for each DOM elements
|
|
|
|
*/
|
|
|
|
export interface RatingPassThroughAttributes {
|
|
|
|
[key: string]: any;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Defines current inline state in Rating component.
|
|
|
|
*/
|
|
|
|
export interface RatingState {
|
|
|
|
/**
|
|
|
|
* name state as a number.
|
|
|
|
*/
|
|
|
|
name: string;
|
|
|
|
/**
|
|
|
|
* focusedOptionIndex state as a number.
|
|
|
|
*/
|
|
|
|
focusedOptionIndex: number;
|
|
|
|
}
|
|
|
|
|
2023-05-09 08:34:26 +00:00
|
|
|
/**
|
|
|
|
* Defines current options in Rating component.
|
|
|
|
*/
|
|
|
|
export interface RatingContext {
|
|
|
|
/**
|
2024-05-03 12:23:10 +00:00
|
|
|
* Current active state of the option as a boolean.
|
2023-05-09 08:34:26 +00:00
|
|
|
* @defaultValue false
|
|
|
|
*/
|
|
|
|
active: boolean;
|
|
|
|
/**
|
2024-05-03 12:23:10 +00:00
|
|
|
* Current focused state of option as a boolean.
|
2023-05-09 08:34:26 +00:00
|
|
|
* @defaultValue false
|
|
|
|
*/
|
|
|
|
focused: boolean;
|
|
|
|
}
|
|
|
|
|
2023-03-01 08:50:51 +00:00
|
|
|
/**
|
|
|
|
* Custom change event.
|
2023-03-06 20:35:39 +00:00
|
|
|
* @see {@link RatingEmits.change}
|
2023-03-01 08:50:51 +00:00
|
|
|
*/
|
2022-09-06 12:03:37 +00:00
|
|
|
export interface RatingChangeEvent {
|
|
|
|
/**
|
|
|
|
* Browser event
|
|
|
|
*/
|
|
|
|
originalEvent: Event;
|
|
|
|
/**
|
|
|
|
* Selected option value
|
|
|
|
*/
|
|
|
|
value: number;
|
|
|
|
}
|
|
|
|
|
2023-03-01 08:50:51 +00:00
|
|
|
/**
|
|
|
|
* Defines valid properties in Rating component.
|
|
|
|
*/
|
2022-09-06 12:03:37 +00:00
|
|
|
export interface RatingProps {
|
|
|
|
/**
|
|
|
|
* Value of the rating.
|
|
|
|
*/
|
|
|
|
modelValue?: number | undefined;
|
|
|
|
/**
|
|
|
|
* Name of the element.
|
|
|
|
*/
|
|
|
|
name?: string | undefined;
|
|
|
|
/**
|
|
|
|
* When present, it specifies that the element should be disabled.
|
2023-03-01 08:50:51 +00:00
|
|
|
* @defaultValue false
|
2022-09-06 12:03:37 +00:00
|
|
|
*/
|
|
|
|
disabled?: boolean | undefined;
|
|
|
|
/**
|
|
|
|
* When present, it specifies that component is read-only.
|
2023-03-01 08:50:51 +00:00
|
|
|
* @defaultValue false
|
2022-09-06 12:03:37 +00:00
|
|
|
*/
|
|
|
|
readonly?: boolean | undefined;
|
|
|
|
/**
|
|
|
|
* Number of stars.
|
2023-03-01 08:50:51 +00:00
|
|
|
* @defaultValue 5
|
2022-09-06 12:03:37 +00:00
|
|
|
*/
|
|
|
|
stars?: number | undefined;
|
2022-09-14 11:26:01 +00:00
|
|
|
/**
|
|
|
|
* Icon for the on state.
|
2023-04-18 10:51:10 +00:00
|
|
|
* @deprecated since v3.27.0. Use 'onicon' slot.
|
2022-09-14 11:26:01 +00:00
|
|
|
*/
|
|
|
|
onIcon?: string | undefined;
|
|
|
|
/**
|
|
|
|
* Icon for the off state.
|
2023-04-18 10:51:10 +00:00
|
|
|
* @deprecated since v3.27.0. Use 'officon' slot.
|
2022-09-14 11:26:01 +00:00
|
|
|
*/
|
|
|
|
offIcon?: string | undefined;
|
2024-04-02 08:24:31 +00:00
|
|
|
/**
|
|
|
|
* It generates scoped CSS variables using design tokens for the component.
|
|
|
|
*/
|
|
|
|
dt?: DesignToken<any>;
|
2023-05-06 20:34:27 +00:00
|
|
|
/**
|
2023-08-01 14:01:12 +00:00
|
|
|
* Used to pass attributes to DOM elements inside the component.
|
2023-05-06 20:34:27 +00:00
|
|
|
* @type {RatingPassThroughOptions}
|
|
|
|
*/
|
2023-09-05 11:28:04 +00:00
|
|
|
pt?: PassThrough<RatingPassThroughOptions>;
|
2023-09-05 08:50:46 +00:00
|
|
|
/**
|
|
|
|
* Used to configure passthrough(pt) options of the component.
|
|
|
|
* @type {PassThroughOptions}
|
|
|
|
*/
|
|
|
|
ptOptions?: PassThroughOptions;
|
2023-05-24 12:46:10 +00:00
|
|
|
/**
|
|
|
|
* When enabled, it removes component related styles in the core.
|
|
|
|
* @defaultValue false
|
|
|
|
*/
|
|
|
|
unstyled?: boolean;
|
2022-09-06 12:03:37 +00:00
|
|
|
}
|
|
|
|
|
2023-03-01 08:50:51 +00:00
|
|
|
/**
|
|
|
|
* Defines valid slots in Rating component.
|
|
|
|
*/
|
2022-09-06 12:03:37 +00:00
|
|
|
export interface RatingSlots {
|
2022-09-14 11:26:01 +00:00
|
|
|
/**
|
|
|
|
* Custom on icon template.
|
|
|
|
* @param {Object} scope - on icon slot's params.
|
|
|
|
*/
|
2023-03-01 08:50:51 +00:00
|
|
|
onicon(scope: {
|
2022-09-14 11:26:01 +00:00
|
|
|
/**
|
2024-05-03 12:23:10 +00:00
|
|
|
* Option value
|
2022-09-14 11:26:01 +00:00
|
|
|
*/
|
|
|
|
value: number;
|
2023-05-24 12:46:10 +00:00
|
|
|
/**
|
|
|
|
* Style class of the icon.
|
|
|
|
*/
|
|
|
|
class: string;
|
2023-03-01 08:50:51 +00:00
|
|
|
}): VNode[];
|
2022-09-14 11:26:01 +00:00
|
|
|
/**
|
|
|
|
* Custom off icon template.
|
|
|
|
* @param {Object} scope - off icon slot's params.
|
|
|
|
*/
|
2023-03-01 08:50:51 +00:00
|
|
|
officon(scope: {
|
2022-09-14 11:26:01 +00:00
|
|
|
/**
|
2024-05-03 12:23:10 +00:00
|
|
|
* Option value
|
2022-09-14 11:26:01 +00:00
|
|
|
*/
|
|
|
|
value: number;
|
2023-05-24 12:46:10 +00:00
|
|
|
/**
|
|
|
|
* Style class of the icon.
|
|
|
|
*/
|
|
|
|
class: string;
|
2023-03-01 08:50:51 +00:00
|
|
|
}): VNode[];
|
2022-09-06 12:03:37 +00:00
|
|
|
}
|
|
|
|
|
2023-03-01 08:50:51 +00:00
|
|
|
/**
|
|
|
|
* Defines valid emits in Rating component.
|
|
|
|
*/
|
|
|
|
export interface RatingEmits {
|
2022-09-06 12:03:37 +00:00
|
|
|
/**
|
|
|
|
* Emitted when the value changes.
|
|
|
|
* @param {number} value - New value.
|
|
|
|
*/
|
2023-03-01 08:50:51 +00:00
|
|
|
'update:modelValue'(value: number): void;
|
2022-09-06 12:03:37 +00:00
|
|
|
/**
|
|
|
|
* Callback to invoke when a suggestion is selected.
|
|
|
|
* @param {RatingChangeEvent} event - Custom change event.
|
|
|
|
*/
|
2023-03-01 08:50:51 +00:00
|
|
|
change(event: RatingChangeEvent): void;
|
2022-09-14 11:26:01 +00:00
|
|
|
/**
|
|
|
|
* Callback to invoke when the component receives focus.
|
|
|
|
* @param {Event} event - Browser event.
|
|
|
|
*/
|
2023-03-01 08:50:51 +00:00
|
|
|
focus(event: Event): void;
|
2022-09-14 11:26:01 +00:00
|
|
|
/**
|
|
|
|
* Callback to invoke when the component loses focus.
|
|
|
|
* @param {Event} event - Browser event.
|
|
|
|
*/
|
2023-03-01 08:50:51 +00:00
|
|
|
blur(event: Event): void;
|
|
|
|
}
|
2022-09-06 12:03:37 +00:00
|
|
|
|
2023-03-01 08:50:51 +00:00
|
|
|
/**
|
|
|
|
* **PrimeVue - Rating**
|
|
|
|
*
|
|
|
|
* _Rating component is a star based selection input._
|
|
|
|
*
|
|
|
|
* [Live Demo](https://www.primevue.org/rating/)
|
|
|
|
* --- ---
|
|
|
|
* ![PrimeVue](https://primefaces.org/cdn/primevue/images/logo-100.png)
|
|
|
|
*
|
|
|
|
* @group Component
|
|
|
|
*/
|
2023-03-01 14:48:23 +00:00
|
|
|
declare class Rating extends ClassComponent<RatingProps, RatingSlots, RatingEmits> {}
|
2022-09-06 12:03:37 +00:00
|
|
|
|
2024-03-14 22:58:11 +00:00
|
|
|
declare module 'vue' {
|
|
|
|
export interface GlobalComponents {
|
2022-09-14 11:26:01 +00:00
|
|
|
Rating: GlobalComponentConstructor<Rating>;
|
2022-09-06 12:03:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default Rating;
|