UNPKG

@progress/kendo-vue-common

Version:

Kendo UI for Vue Common Utilities package

62 lines (61 loc) 1.86 kB
/** * @license *------------------------------------------------------------------------------------------- * Copyright © 2026 Progress Software Corporation. All rights reserved. * Licensed under commercial license. See LICENSE.md in the package root for more information *------------------------------------------------------------------------------------------- */ import { Keys as r } from "./keys.mjs"; import { FOCUSABLE_ELEMENTS as u } from "./constants/main.mjs"; const c = (t, s = u) => t.querySelectorAll(s.join(",")), a = (t, s = u) => { if (t) { const f = c(t, s); if (f.length && f[0].focus) return f[0]; } }, n = (t, s = u) => { if (t) { const f = c(t, s); if (f.length && f[f.length - 1].focus) return f[f.length - 1]; } }, l = (t, s) => { if (t) { const f = a(t, s); f && f.focus(); } }, h = (t, s, f) => { if (!(!s || t.keyCode !== r.tab) && s) { const o = a(s, f), i = n(s, f); o && i && !t.shiftKey && t.target === i && (t.preventDefault(), o.focus()), o && i && t.shiftKey && t.target === o && (t.preventDefault(), i.focus()), o || t.preventDefault(); } }, d = (t, s, f, o) => { let i = !0; if (t.keyCode !== r.enter && t.target === s) { f && f(!1); return; } t.keyCode === r.enter && t.target === s ? setTimeout(() => { l(s, o); }, 1) : t.keyCode === r.esc ? s.focus() : h(t, s, o), f && f(i); }, g = (t, s) => { const f = c(t, s); f == null || f.forEach((o) => { o.tabIndex = 0; }); }, b = (t, s) => { const f = c(t, s); f == null || f.forEach((o) => { o.tabIndex = -1; }); }; export { d as applyTrappedFocus, b as disableNavigatableContainer, g as enableNavigatableContainer, a as firstFocusableChild, l as focusFirstFocusableChild, c as focusableChildren, h as keepFocusInContainer, n as lastFocusableChild };