primevue-mirror/components/lib/rating/Rating.d.ts

267 lines
6.3 KiB
TypeScript
Raw Normal View History

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';
2022-09-06 12:03:37 +00:00
import { ClassComponent, GlobalComponentConstructor } from '../ts-helpers';
2023-05-06 20:34:27 +00:00
export declare type RatingPassThroughOptionType = RatingPassThroughAttributes | ((options: RatingPassThroughMethodOptions) => RatingPassThroughAttributes) | null | undefined;
/**
* Custom passthrough(pt) option method.
*/
export interface RatingPassThroughMethodOptions {
props: RatingProps;
state: RatingState;
2023-05-09 08:34:26 +00:00
context: RatingContext;
2023-05-06 20:34:27 +00:00
}
/**
* Custom passthrough(pt) options.
* @see {@link RatingProps.pt}
*/
export interface RatingPassThroughOptions {
/**
* Uses to pass attributes to the root's DOM element.
*/
root?: RatingPassThroughOptionType;
/**
* Uses to pass attributes to the cancel icon's DOM element.
*/
cancelIcon?: RatingPassThroughOptionType;
/**
* Uses to pass attributes to the item's DOM element.
*/
item?: RatingPassThroughOptionType;
/**
* Uses to pass attributes to the on icon's DOM element.
*/
onIcon?: RatingPassThroughOptionType;
/**
* Uses to pass attributes to the off icon's DOM element.
*/
offIcon?: RatingPassThroughOptionType;
2023-05-09 08:34:26 +00:00
/**
* Uses to pass attributes to the hidden cancel inputW wapper's DOM element.
*/
hiddenCancelInputWrapper?: RatingPassThroughOptionType;
/**
* Uses to pass attributes to the hidden cancel input's DOM element.
*/
hiddenCancelInput?: RatingPassThroughOptionType;
/**
* Uses to pass attributes to the hidden item input wrapper's DOM element.
*/
hiddenItemInputWrapper?: RatingPassThroughOptionType;
/**
* Uses to pass attributes to the hidden item input's DOM element.
*/
hiddenItemInput?: RatingPassThroughOptionType;
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 {
/**
* Current active state of the item as a boolean.
* @defaultValue false
*/
active: boolean;
/**
2023-05-10 08:08:56 +00:00
* Current focused state of item 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;
/**
* When specified a cancel icon is displayed to allow clearing the value.
2023-03-01 08:50:51 +00:00
* @defaultValue true
2022-09-06 12:03:37 +00:00
*/
cancel?: boolean | undefined;
2022-09-14 11:26:01 +00:00
/**
* Icon for the on state.
* @deprecated since v3.27.0. Use 'onicon' slot.
2022-09-14 11:26:01 +00:00
*/
onIcon?: string | undefined;
/**
* Icon for the off state.
* @deprecated since v3.27.0. Use 'officon' slot.
2022-09-14 11:26:01 +00:00
*/
offIcon?: string | undefined;
/**
* Icon for the cancelable state.
* @deprecated since v3.27.0. Use 'cancelicon' slot.
2022-09-14 11:26:01 +00:00
*/
cancelIcon?: string | undefined;
2023-05-06 20:34:27 +00:00
/**
* Uses to pass attributes to DOM elements inside the component.
* @type {RatingPassThroughOptions}
*/
pt?: RatingPassThroughOptions;
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 cancel icon template.
*/
2023-05-24 12:46:10 +00:00
cancelicon(scope: {
/**
* Style class of the icon.
*/
class: string;
}): VNode[];
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
/**
* Item value
*/
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
/**
* Item value
*/
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
declare module '@vue/runtime-core' {
interface GlobalComponents {
2022-09-14 11:26:01 +00:00
Rating: GlobalComponentConstructor<Rating>;
2022-09-06 12:03:37 +00:00
}
}
export default Rating;