primevue
Version:
PrimeVue is a premium UI library for Vue featuring a rich set of 90+ components, a theme designer, various theme alternatives such as Material, Bootstrap, Tailwind, premium templates and professional support. In addition, it integrates with PrimeBlock, wh
317 lines (301 loc) • 8.16 kB
TypeScript
/**
*
* Compare is a compound, headless component for comparing two visual layers with a draggable slider.
*
* [Live Demo](https://www.primevue.dev/compare/)
*
* @module compare
*
*/
import type { DefineComponent, DesignToken, EmitFn, PassThrough } from '@primevue/core';
import type { ComponentHooks } from '@primevue/core/basecomponent';
import type { PassThroughOptions } from 'primevue/passthrough';
import type { Component, HTMLAttributes, VNode } from 'vue';
export declare type ComparePassThroughOptionType = ComparePassThroughAttributes | ((options: ComparePassThroughMethodOptions) => ComparePassThroughAttributes | string) | string | null | undefined;
/**
* Custom passthrough(pt) option method.
*/
export interface ComparePassThroughMethodOptions {
/**
* Defines instance.
*/
instance: any;
/**
* Defines valid properties.
*/
props: CompareProps;
/**
* Defines current inline state.
*/
state: CompareState;
/**
* Defines valid attributes.
*/
attrs: any;
/**
* Defines parent options.
*/
parent: any;
/**
* Defines passthrough(pt) options in global config.
*/
global: object | undefined;
}
/**
* Custom passthrough(pt) options.
* @see {@link CompareProps.pt}
*/
export interface ComparePassThroughOptions {
/**
* Used to pass attributes to the root's DOM element.
*/
root?: ComparePassThroughOptionType;
/**
* Used to pass attributes to CompareItem elements.
*/
item?: ComparePassThroughOptionType;
/**
* Used to pass attributes to CompareHandle element.
*/
handle?: ComparePassThroughOptionType;
/**
* Used to pass attributes to CompareIndicator element.
*/
indicator?: ComparePassThroughOptionType;
/**
* Used to pass attributes to the hidden range input.
*/
input?: ComparePassThroughOptionType;
/**
* Used to manage all lifecycle hooks.
* @see {@link BaseComponent.ComponentHooks}
*/
hooks?: ComponentHooks;
}
/**
* Custom passthrough attributes for each DOM elements.
*/
export interface ComparePassThroughAttributes {
[key: string]: any;
}
/**
* Event fired when the compare value interaction ends.
*/
export interface CompareValueChangeEndEvent {
/**
* Browser event that finished the interaction.
*/
originalEvent: Event;
/**
* Current compare value.
*/
value: number;
}
/**
* Defines current inline state in Compare component.
*/
export interface CompareState {
/**
* Current value.
*/
d_value: number;
/**
* Whether the handle is being dragged.
*/
isDragging: boolean;
/**
* Whether the current pointerdown started on the handle.
*/
isHandlePointerDown: boolean;
/**
* Pointer offset from the visual handle center in pixels.
*/
dragOffsetPx: number;
}
/**
* Defines valid properties in Compare component.
*/
export interface CompareProps {
/**
* Value of the component. Pair with `v-model` for two-way binding.
*/
modelValue?: number | undefined;
/**
* Minimum boundary value.
* @defaultValue 0
*/
min?: number | undefined;
/**
* Maximum boundary value.
* @defaultValue 100
*/
max?: number | undefined;
/**
* Step factor to increment/decrement the value.
* @defaultValue 1
*/
step?: number | undefined;
/**
* Orientation of the compare slider.
* @defaultValue horizontal
*/
orientation?: 'horizontal' | 'vertical' | undefined;
/**
* Whether the slider moves on hover.
* @defaultValue false
*/
slideOnHover?: boolean | undefined;
/**
* Whether the component is disabled.
* @defaultValue false
*/
disabled?: boolean | undefined;
/**
* Whether the component is read-only.
* @defaultValue false
*/
readonly?: boolean | undefined;
/**
* When present, it specifies that the component should be invalid.
* @defaultValue false
*/
invalid?: boolean | undefined;
/**
* The tab index of the hidden range input.
*/
tabindex?: number | undefined;
/**
* Establishes a string value that labels the component.
*/
ariaLabel?: string | undefined;
/**
* Establishes relationships between the component and label(s).
*/
ariaLabelledby?: string | undefined;
/**
* Name of the hidden input.
*/
name?: string | undefined;
/**
* Use to change the HTML tag of root element.
* @defaultValue DIV
*/
as?: string | Component | undefined;
/**
* When enabled, it changes the default rendered element for the one passed as a child element.
* @defaultValue false
*/
asChild?: boolean | undefined;
/**
* It generates scoped CSS variables using design tokens for the component.
*/
dt?: DesignToken<any>;
/**
* Used to pass attributes to DOM elements inside the component.
* @type {ComparePassThroughOptions}
*/
pt?: PassThrough<ComparePassThroughOptions>;
/**
* Used to configure passthrough(pt) options of the component.
* @type {PassThroughOptions}
*/
ptOptions?: PassThroughOptions;
/**
* When enabled, it removes component related styles in the core.
* @defaultValue false
*/
unstyled?: boolean;
}
/**
* Root element attributes forwarded to the consumer when `asChild` is enabled.
*/
export interface CompareA11yAttrs extends HTMLAttributes {
/**
* Current orientation.
*/
'data-orientation': 'horizontal' | 'vertical';
}
/**
* Defines valid slots in Compare component.
*/
export interface CompareSlots {
/**
* Default slot, place `CompareItem`, `CompareHandle` and `CompareIndicator` inside.
* Receives scope props when `asChild` is enabled.
* @param {Object} scope - default slot's params.
*/
default(scope: {
/**
* Computed class name for the root.
*/
class: string | object | Array<string | object>;
/**
* Attributes to spread on the consumer's root element.
*/
a11yAttrs: CompareA11yAttrs;
/**
* Current compare value.
*/
value: number;
/**
* Whether the handle is being dragged.
*/
isDragging: boolean;
}): VNode[];
}
/**
* Defines valid emits in Compare component.
*/
export interface CompareEmitsOptions {
/**
* Emitted when the compare value changes.
* @param {number} value - New value.
*/
'update:modelValue'(value: number): void;
/**
* Emitted when pointer or input interaction ends.
* @param {CompareValueChangeEndEvent} event - Custom value change end event.
*/
'value-change-end'(event: CompareValueChangeEndEvent): void;
/**
* Emitted when the hidden input receives focus.
* @param {Event} event - Browser event.
*/
focus(event: Event): void;
/**
* Emitted when the hidden input loses focus.
* @param {Event} event - Browser event.
*/
blur(event: Event): void;
}
export declare type CompareEmits = EmitFn<CompareEmitsOptions>;
/**
* Defines valid public methods exposed by the Compare component instance.
*/
export interface CompareMethods {
/**
* Returns the current value as a percentage in the min/max range.
*
* @memberof Compare
*/
getValuePercent(value: number): number;
}
/**
* **PrimeVue - Compare**
*
* _Compare is a compound, headless component for comparing two visual layers with a draggable slider._
*
* [Live Demo](https://www.primevue.dev/compare/)
* --- ---
* 
*
* @group Component
*
*/
declare const Compare: DefineComponent<CompareProps, CompareSlots, CompareEmits, CompareMethods>;
declare module 'vue' {
export interface GlobalComponents {
Compare: DefineComponent<CompareProps, CompareSlots, CompareEmits, CompareMethods>;
}
}
export default Compare;