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
241 lines (227 loc) • 7.23 kB
TypeScript
/**
*
* GalleryItem represents a single slide in the Gallery. Items register themselves with the parent Gallery on
* mount and the parent assigns them a sequential `index`. The active item is rendered with `data-active`
* (CSS-driven visibility), absolute-centered inside `GalleryContent`, and supports drag-to-pan, pinch-to-zoom
* (touch), wheel zoom (Ctrl + wheel), click-to-toggle-zoom, rotation, flip and download.
*
* Transforms are applied via CSS custom properties on the root: `--position-x`, `--position-y`, `--scale`,
* `--rotation`, `--flip-x`, `--flip-y`.
*
* [Live Demo](https://www.primevue.dev/gallery/)
*
* @module galleryitem
*
*/
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, CSSProperties, HTMLAttributes, VNode } from 'vue';
export declare type GalleryItemPassThroughOptionType = GalleryItemPassThroughAttributes | ((options: GalleryItemPassThroughMethodOptions) => GalleryItemPassThroughAttributes | string) | string | null | undefined;
/**
* Custom passthrough(pt) option method.
*/
export interface GalleryItemPassThroughMethodOptions {
/**
* Defines instance.
*/
instance: any;
/**
* Defines valid properties.
*/
props: GalleryItemProps;
/**
* 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 GalleryItemProps.pt}
*/
export interface GalleryItemPassThroughOptions {
/**
* Used to pass attributes to the root's DOM element.
*/
root?: GalleryItemPassThroughOptionType;
/**
* Used to manage all lifecycle hooks.
* @see {@link BaseComponent.ComponentHooks}
*/
hooks?: ComponentHooks;
}
/**
* Custom passthrough attributes for each DOM elements.
*/
export interface GalleryItemPassThroughAttributes {
[key: string]: any;
}
/**
* Defines valid properties in GalleryItem component.
*/
export interface GalleryItemProps {
/**
* Scale factor when the item is at its natural (non-zoomed) state.
* @defaultValue 1
*/
normalScale?: number | undefined;
/**
* Maximum scale factor reached when the item is zoomed in.
* @defaultValue 3
*/
zoomedScale?: number | 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.
*/
pt?: PassThrough<GalleryItemPassThroughOptions>;
/**
* Used to configure passthrough(pt) options of the component.
*/
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 GalleryItemA11yAttrs extends HTMLAttributes {
/**
* Function ref that captures the consumer root element so the Gallery can
* measure and drive the active item.
*/
ref: (el: Element | null) => void;
/**
* PrimeVue component identifier.
*/
'data-pc-name': 'galleryitem';
/**
* PrimeVue section identifier within the component.
*/
'data-pc-section': 'root';
/**
* Index of this item in the registered order.
*/
'data-index': number;
/**
* Present (as `""`) while this item is the active one, otherwise `undefined`.
*/
'data-active'?: '' | undefined;
/**
* Present (as `""`) for a short window while the item is animating a rotation, otherwise `undefined`.
*/
'data-rotating'?: '' | undefined;
/**
* Inline style carrying the transform CSS variables.
*/
style: CSSProperties;
/**
* Click handler that toggles zoom in/out at the clicked point.
*/
onClick: (event: MouseEvent) => void;
/**
* Pointer-down handler initiating drag/pinch tracking.
*/
onPointerdown: (event: PointerEvent) => void;
/**
* Pointer-move handler driving drag and pinch updates.
*/
onPointermove: (event: PointerEvent) => void;
/**
* Pointer-up handler finalising the gesture.
*/
onPointerup: (event: PointerEvent) => void;
/**
* Drag-start handler that prevents the browser's native image drag.
*/
onDragstart: (event: DragEvent) => void;
}
/**
* Defines valid slots in GalleryItem component.
*/
export interface GalleryItemSlots {
/**
* Custom content template. Receives `index` and `active` (and consumer-targeted props when `asChild` is enabled).
* @param {Object} scope - default slot's params.
*/
default(scope: {
/**
* Index assigned to this item by the parent Gallery.
*/
index: number;
/**
* Whether this item is the currently active item.
*/
active: boolean;
/**
* Computed class name for the item root (only emitted when `asChild` is enabled).
*/
class?: string | object | Array<string | object>;
/**
* Attributes to spread on the consumer's root element so the parent Gallery
* can detect the active state, drive transforms, intercept input and capture
* the root element reference (only emitted when `asChild` is enabled).
*/
a11yAttrs?: GalleryItemA11yAttrs;
}): VNode[];
}
/**
* Defines valid emits in GalleryItem component.
*/
export interface GalleryItemEmitsOptions {}
export declare type GalleryItemEmits = EmitFn<GalleryItemEmitsOptions>;
/**
* Defines valid public methods exposed by the GalleryItem component instance.
*/
export interface GalleryItemMethods {
/**
* Returns the root DOM element captured by the item, or `null` before mount
* or when rendered with `asChild` and the consumer hasn't attached `a11yAttrs.ref` yet.
*
* @memberof GalleryItem
*/
getEl(): HTMLElement | null;
}
/**
* **PrimeVue - GalleryItem**
*
* _GalleryItem is a helper component for Gallery component._
*
* [Live Demo](https://www.primevue.dev/gallery/)
* --- ---
* 
*
* @group Component
*
*/
declare const GalleryItem: DefineComponent<GalleryItemProps, GalleryItemSlots, GalleryItemEmits, GalleryItemMethods>;
declare module 'vue' {
export interface GlobalComponents {
GalleryItem: DefineComponent<GalleryItemProps, GalleryItemSlots, GalleryItemEmits, GalleryItemMethods>;
}
}
export default GalleryItem;