@visa/nova-angular
Version:
Visa Product Design System Nova Angular library
172 lines (171 loc) • 10.3 kB
TypeScript
/**
* Copyright (c) 2025 Visa, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
**/
import { EventEmitter, QueryList, RendererFactory2 } from '@angular/core';
import { Router } from '@angular/router';
import { AppReadyService } from './_utilities/services/app-stable-check.service';
import { ButtonDirective } from './button/button.directive';
import { CheckboxDirective } from './checkbox/checkbox.directive';
import { LinkDirective } from './link/link.directive';
import { ListboxItemComponent } from './listbox-item/listbox-item.component';
import { TabItemDirective } from './tab-item/tab-item.directive';
import * as i0 from "@angular/core";
/**
* This service manages navigation states within the application, ensuring smooth transitions and a consistent user experience. <br />
* It’s primarily used internally by the library but can also be leveraged directly for custom implementations.
*/
export declare class NovaLibService {
private router;
private rendererFactory;
private appReadyService;
constructor(router: Router, rendererFactory: RendererFactory2, appReadyService: AppReadyService);
/** @ignore */
private _idService;
/** @ignore */
private renderer;
/**
* The getUUID generates a random ID.
* @deprecated Please use the equivalent method from our unique ID generator instead.
* @param name Optional string to start the ID.
* @returns string
*/
getUUID(name?: string): string;
/**
* The check UUID method verifies that the given ID has not already been generated by the getUUID method. <br />
* @deprecated Please use the equivalent method from our unique ID generator instead.
* @param uuid String ID to check.
* @param name Optional string to start the ID.
* @returns uuid
*/
checkUUID(uuid: string, name?: string): string;
/**
* Emits new url on initial page load and page navigation; use alongside <code>getCurrentRoute</code>.
*/
routeChange: EventEmitter<string>;
/**
* The getCurrentRoute method can be used to retrieve the current route or to get updated URLs when routes change by subscribing to the <code>routeChange</code> event.
* @returns router.url as string
*/
getCurrentRoute(): string;
/**
* The addArrowKeyNavigation method adds arrow key navigation to an array of elements of type <code>ButtonDirective</code>, <code>ListboxItemComponent</code>, <code>or CheckboxDirective</code>.
* @param itemsArray Array of items to add arrow key navigation to.
* @param arrowDirections Optionally specify which arrow key directions to use for navigation.
* @param removeTabNavigation Optionally remove tab navigation from an array you're adding arrow navigation to.
*/
addArrowKeyNavigation(itemsArray: ButtonDirective[] | ListboxItemComponent[] | CheckboxDirective[], removeTabNavigation?: boolean, arrowDirections?: 'both' | 'horizontal' | 'vertical'): void;
/**
* The removeTabNavigation method removes tab navigation for an array of elements of type ButtonDirective, ListboxItemComponent, or CheckboxDirective. <br />
* When this functionality is added, it will disable tabbing between these specified elements.
* @param itemsArray Array of items to remove tab navigation from.
*/
removeTabNavigation(itemsArray: ButtonDirective[] | ListboxItemComponent[] | CheckboxDirective[]): void;
/**
* This method resets navigation behaviors for an array of elements of type <code>ButtonDirective</code>, <code>ListboxItemComponent</code>, or <code>CheckboxDirective</code>. <br />
* It removes any tabindex or event listeners added by <code>addArrowKeyNavigation</code> or <code>removeTabNavigation</code>.
* @param itemsArray Array of items to reset navigation behaviors for.
*/
resetNavigationBehaviors(itemsArray: ButtonDirective[] | ListboxItemComponent[] | CheckboxDirective[]): void;
/**
* The findStartingFocus method finds the item to start navigation on. <br />
* The starting focusable item is either the first item or the currently selected item.
* @param itemsArray Array of items to find starting focus for.
*/
findStartingFocus(itemsArray: ButtonDirective[] | ListboxItemComponent[] | CheckboxDirective[]): void;
/**
* The nextEnabledItem method finds the next item in the array that is not disabled. <br />
* When this functionality is added, it will automatically skip over disabled items to locate the next enabled one.
* @param items Array of items to search for next enabled item.
* @param currentIndex Index to start searching from.
* @returns Index of next item that is not disabled.
*/
nextEnabledItem(items: ButtonDirective[] | ListboxItemComponent[] | CheckboxDirective[], currentIndex?: number): number;
/**
* The lastEnabledItem method retrieves the last item in an array that is not disabled.
* @param items Array of items to search for last enabled item.
* @returns Index of most last item that is not disabled.
*/
lastEnabledItem(items: ButtonDirective[] | ListboxItemComponent[] | CheckboxDirective[]): number;
/**
* The firstEnabledItem methods retrieves the first item in array that is not disabled.
* @param items Array of items to search for first enabled item.
* @returns Index of first item that is not disabled.
*/
firstEnabledItem(items: ButtonDirective[] | ListboxItemComponent[] | CheckboxDirective[]): number;
/**
* The previousEnabledItem method finds the previous item in the array that is not disabled. <br />
* When this functionality is added, it will automatically skip over disabled items to locate the previous enabled one.
* @param items Array of items to search for previous enabled item.
* @param currentIndex Index to start reverse searching from.
* @returns Index of first previous item that is not disabled.
*/
previousEnabledItem(items: ButtonDirective[] | ListboxItemComponent[] | CheckboxDirective[], currentIndex?: number): number;
/**
* The addAutomaticActivation method enables automatic tab activation for the specified tab or listbox list. <br />
* When this functionality is added, focusing on an item will also select and activate it.
* @param items Array of items to add automatic activation to.
*/
addAutomaticActivation(items: TabItemDirective[] | ListboxItemComponent[]): void;
/** @ignore */
_currentLink: HTMLElement | null;
/**
* The setAriaCurrent method sets the aria-current="true" attribute on the element with the specified ID.
* @param id ID of element to set aria-current="true" on.
*/
setAriaCurrent(id: string): void;
/**
* The handleAriaCurrent method handles the aria-current value on click for a list of links.
* @param links List of links to add aria-current functionality to.
*/
handleAriaCurrent(links: LinkDirective[] | QueryList<LinkDirective>): void;
/**
* The selectItems method selects items from start_index to end_index in a list of tab or listbox items. By default, it selects all items if no indices are specified.
* @param items Array of listbox items that you want to manipulate.
* @param start Index of the first item you want to manipulate.
* @param end Index of the last item you want to manipulate.
* @param prop The property name you want to set to true (ie. active, highlighted, etc.). Defaults to 'active'.
*/
selectItems(items: TabItemDirective[] | ListboxItemComponent[], start?: number, end?: number, prop?: keyof TabItemDirective | keyof ListboxItemComponent): void;
/**
* The selectItem method selects an item from a list of tab or listbox items.
* @param items List of items that contains the item you want to manipulate.
* @param index Index of the item you want to manipulate.
* @param prop The property name you want to set to true (ie. active, highlighted, etc.). Defaults to 'active'.
*/
selectItem(items: TabItemDirective[] | ListboxItemComponent[], index: number, prop?: keyof TabItemDirective | keyof ListboxItemComponent): void;
/**
* The deselectItems method deselect items out of a list of tab or listbox items.
* @param items List of items that contains the items you want to manipulate.
* @param index Optional index of the item you want to manipulate.
* @param prop The property name you want to set to false (ie. active, highlighted, etc.). Defaults to 'active'.
*/
deselectItems(items: TabItemDirective[] | ListboxItemComponent[], index?: number, prop?: keyof TabItemDirective | keyof ListboxItemComponent): void;
/**
* The deselectItem method deselects a specific item from a list of tab or listbox items.
* @param items List of items that contains the items you want to manipulate.
* @param index Index of the item you want to manipulate.
* @param prop The property name you want to set to false (ie. active, highlighted, etc.). Defaults to 'active'.
*/
deselectItem(items: ListboxItemComponent[], index: number, prop?: keyof ListboxItemComponent): void;
/**
* The detectAllItemsSelected method checks whether all items in a given list of tab or listbox items are selected.
* @param items List of items that contains the items you want to check.
* @returns true if all items are selected, false if not.
*/
detectAllItemsSelected(items: ListboxItemComponent[]): boolean | undefined;
static ɵfac: i0.ɵɵFactoryDeclaration<NovaLibService, never>;
static ɵprov: i0.ɵɵInjectableDeclaration<NovaLibService>;
}