@trimble-oss/moduswebcomponents
Version:
Modus Web Components is a modern, accessible UI library built with Stencil JS that provides reusable web components following Trimble's Modus design system. This updated version focuses on improved flexibility, enhanced theming options, comprehensive cust
37 lines (36 loc) • 1.59 kB
TypeScript
export interface IReorderResult<T> {
items: T[];
targetIndex: number;
}
/**
* Reorders a list item by swapping it with the adjacent item in the given direction.
*/
export declare function reorderListItem<T>(items: T[], currentIndex: number, direction: number): IReorderResult<T> | null;
/**
* Reorders a grid item by removing it from the current position
* and inserting it at the target position.
*/
export declare function reorderGridItem<T>(items: T[], currentIndex: number, offset: number): IReorderResult<T> | null;
/**
* Calculates the number of columns in the grid layout
* by comparing offsetTop values of consecutive items.
*/
export declare function getGridColumnCount(el: HTMLElement): number;
/**
* Returns the navigation offset for an arrow key based on the layout.
* Returns null if the key is not applicable for the current layout.
*/
export declare function getNavigationOffset(key: string, layout: 'list' | 'grid', gridColumnCount: number): number | null;
/**
* Returns the valid target index for focus navigation,
* or null if the target is out of bounds.
*/
export declare function getTargetFocusIndex(currentIndex: number, offset: number, totalItems: number): number | null;
/**
* Focuses the app menu item at the given index based on the layout.
*
* In list layout the focus target depends on edit mode: the wrapper row
* (tabIndex 0 in edit mode) or the inner `<li>` rendered by
* modus-wc-menu-item (native tab stop in normal mode).
*/
export declare function focusAppMenuItem(el: HTMLElement, layout: 'list' | 'grid', appIndex: number): void;