UNPKG

@visa/nova-angular

Version:

Visa Product Design System Nova Angular library

114 lines (113 loc) 6.15 kB
/** * 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 { RendererFactory2 } from '@angular/core'; import { AppReadyService } from '../_utilities/services/app-stable-check.service'; import { ListboxItemComponent } from '../listbox-item/listbox-item.component'; import { NovaLibService } from '../nova-lib.service'; import { ListboxDirective } from './listbox.directive'; import * as i0 from "@angular/core"; /** * Service used to create listbox behavior. Some functions are used within listbox component, others are optional additions. */ export declare class ListboxService { private rendererFactory; private novaLibService; private appReadyService; constructor(rendererFactory: RendererFactory2, novaLibService: NovaLibService, appReadyService: AppReadyService); /** @ignore */ private renderer; /** @ignore */ listbox: ListboxDirective; /** * The setUpListbox method configures the listbox with the expected keyboard behaviors and sets the aria-activedescendant attribute. <br> * This method is called by default within <code>ListboxDirective</code>. * @param listbox Listbox to set up. */ setUpListbox(listbox: ListboxDirective): void; /** * The listenForActiveIndex method sets the <code>aria-activedescendant</code> attribute of the listbox to the ID of the active listbox item and is called by default within <code>setUpListbox</code>. * @param listbox Listbox to listen to for active index. */ listenForActiveIndex(listbox: ListboxDirective): void; /** * The scrollItemIntoView method scrolls given item to top of listbox. <br> * It’s called by default in <code>ListBoxDirective</code> unless <code>customScrollControl</code> is present. <br> * This method can also call to scroll to a custom index. By default it will scroll to the first active item, but you can provide a specific item if desired. * @param listbox Listbox to scroll. * @param indexToScrollTo Optional specific index to scroll to top (othwerwise, scrolls to first active item). */ scrollItemIntoView(listbox: ListboxDirective, indexToScrollTo?: number): void; /** * Select all items between currently focused item and closest selected item. * @param items List of items that contains the items you want to select. * @param index Index of the focused item. */ selectFromCloserSelectedToFocused(items: ListboxItemComponent[], index: number): void; /** * The addShortcuts method adds keyboard shortcuts to the listbox and is called by default within <code>setUpListbox</code>. * @param listbox Listbox to add shortcuts to. */ addShortcuts(listbox: ListboxDirective): void; /** * The handleKeyup method handles item selection on keyup events for the listbox and is called by default within <code>addShortcuts</code>. * @param event Keyup event * @param listbox Listbox to handle keyup event for. */ handleKeyUp(event: KeyboardEvent, listbox: ListboxDirective): void; /** * The handleKeydown handles keydown events for the listbox and is called by default within <code>addShortcuts</code>. * @param event Keydown event * @param listbox Listbox to handle keyup event for. */ handleKeyDown(event: KeyboardEvent, listbox: ListboxDirective): void; /** * The updateFocusItem method is activated by Meta + Shift + Home/End and selects all items between the focused item and the first or last item, then sets focus to the first or last item. <br> * This method is called by default within <code>handleKeyDown</code>. * @param event Keyboard event * @param listbox Listbox to update focus item for. */ updateFocusItem(event: KeyboardEvent, listbox: ListboxDirective): void; /** * The searchKeyword method handles keys A-Z, a-z, and 0-9, moving the focus to the next item with a name starting with the typed character. <br> * In the case of rapid succession, it moves the focus to the next item whose name matches the sequence of characters typed. <br /> * This method is called by default within <code>handleKeyDown</code>. * @param event Keyboard event * @param listbox Listbox to search for items in. */ searchKeyword(event: KeyboardEvent, listbox: ListboxDirective): void; /** * The selectAll method is activated by the Meta + A keys and selects or deselects all items in the listbox. <br> * This method is called by default within <code>handleKeyDown</code>. * @param listbox Listbox to select all items in. */ selectAll(listbox: ListboxDirective): void; /** * The selectFromCloserSelectedToFocused method selects all items between the currently focused item and the closest selected item. <br> * This method is called by default within <code>handleKeyDown</code>. * @param index Index of the focused item. */ selectContiguousItems(listbox: ListboxDirective): void; /** * The toggleSelectedState method is activated by Shift + ↑/↓ and moves the focus to, and toggles the selected state of, the next or previous option. <br> * This method is called by default within <code>handleKeyDown</code>. * @param event Keyboard event * @param listbox Listbox to toggle selected state for. */ toggleSelectedState(event: KeyboardEvent, listbox: ListboxDirective): void; static ɵfac: i0.ɵɵFactoryDeclaration<ListboxService, never>; static ɵprov: i0.ɵɵInjectableDeclaration<ListboxService>; }