/** * useGridRowAction * * Composable that provides safe, accessible row click and keyboard activation * handlers for Kendo UI for Vue Grid instances. * * Highlights: * - Guards against triggers when clicking interactive elements (buttons, links, inputs, checkboxes). * - Suppresses activation when the user is highlighting/selecting text inside a cell. * - Restricts mouse actions to primary (left) click. * - Provides keyboard activation (Enter / Space) for focused grid rows. * - Action-agnostic: executes consumer-supplied `onRowAction` callback with `dataItem` and context. */ import type { Ref } from "vue"; import type { GridRowClickEvent } from "../types/kendo"; export interface RowActionCoordinates { clientX: number; clientY: number; pageX: number; pageY: number; screenX: number; screenY: number; } export interface RowActionContext { /** * Data item associated with the activated row. */ dataItem: T; /** * Row index if provided by Kendo event or row DOM attribute. */ rowIndex?: number; /** * Field name if click originated on a specific column cell. */ field?: string; /** * Original native browser event. */ event: Event; /** * Interaction trigger type ('click' | 'keyboard'). */ triggerType: "click" | "keyboard"; /** * Modifier key states during activation. */ ctrlKey: boolean; shiftKey: boolean; metaKey: boolean; altKey: boolean; /** * Pointer coordinates of the activation. Derived from the native mouse event * for clicks, or from the focused row's bounding box for keyboard activation. * `undefined` when neither source is available. */ coordinates?: RowActionCoordinates; } export interface UseGridRowActionOptions { /** * Action callback invoked when a row is clicked or activated via keyboard. */ onRowAction: (dataItem: T, context: RowActionContext) => void; /** * Optional ref to Kendo Grid component instance or array/ref of data items. * Used to resolve the row `dataItem` when row is activated via grid-level `@keydown`. */ gridRef?: Ref; dataItems?: Ref | T[]; /** * Additional CSS selectors inside row cells that should prevent the row action. */ ignoreSelectors?: string[]; /** * Custom predicate function to check if an event target should be ignored. * Return `true` to ignore row action, `false` to proceed. */ shouldIgnoreTarget?: (target: HTMLElement, event: Event) => boolean; /** * Whether to enable Enter/Space keyboard activation on focused grid rows. * Default: true */ enableKeyboardAction?: boolean; } export interface UseGridRowActionReturn { /** * Grid row click handler to bind to Kendo Grid's `@rowclick` event. */ handleRowClick: (event: GridRowClickEvent) => void; /** * Grid keyboard handler to bind to Kendo Grid's `@keydown` event. * Optionally accepts explicit `dataItem` if bound at the row/slot level. */ handleRowKeyDown: (event: KeyboardEvent, explicitDataItem?: T) => void; /** * Helper function to test if a given DOM element is an ignored target. */ isIgnoredTarget: (target: HTMLElement, event?: Event) => boolean; } export declare const useGridRowAction: (options: UseGridRowActionOptions) => UseGridRowActionReturn;