UNPKG

@progress/kendo-angular-pager

Version:
40 lines (39 loc) 1.78 kB
/**----------------------------------------------------------------------------------------- * Copyright © 2025 Progress Software Corporation. All rights reserved. * Licensed under commercial license. See LICENSE.md in the project root for more information *-------------------------------------------------------------------------------------------*/ import { Subject } from "rxjs"; import { focusableSelector, getAllFocusableChildren } from "../util"; import { isFocusable } from "@progress/kendo-angular-common"; /** * @hidden */ export class PagerNavigationService { isNavigable = true; innerNavigationChange = new Subject(); toggleInnerNavigation(value) { this.innerNavigationChange.next(value); } keepFocusWithinComponent(wrapper, target, event) { const [firstFocusable, lastFocusable] = this.getFirstAndLastFocusable(wrapper); const tabAfterLastFocusable = !event.shiftKey && target === lastFocusable; const shiftTabAfterFirstFocusable = event.shiftKey && target === firstFocusable; if (tabAfterLastFocusable) { event.preventDefault(); firstFocusable.focus(); } if (shiftTabAfterFirstFocusable) { event.preventDefault(); lastFocusable.focus(); } } getFirstAndLastFocusable(wrapper) { const all = getAllFocusableChildren(wrapper); const firstFocusable = all.length > 0 ? all[0] : wrapper; const lastFocusable = all.length > 0 ? all[all.length - 1] : wrapper; return [ isFocusable(firstFocusable) ? firstFocusable : firstFocusable.querySelector(focusableSelector), isFocusable(lastFocusable) ? lastFocusable : lastFocusable.querySelector(focusableSelector) ]; } }