UNPKG

@progress/kendo-vue-common

Version:

Kendo UI for Vue Common Utilities package

57 lines (56 loc) 1.63 kB
/** * @license *------------------------------------------------------------------------------------------- * Copyright © 2025 Progress Software Corporation. All rights reserved. * Licensed under commercial license. See LICENSE.md in the package root for more information *------------------------------------------------------------------------------------------- */ import { Keys as e } from "./keys.mjs"; const o = 'input, [tabindex]:not([tabindex="-1"])', r = (s) => { if (s) { const t = s.querySelectorAll(o); if (t.length && t[0].focus) return t[0]; } }, c = (s) => { if (s) { const t = s.querySelectorAll(o); if (t.length && t[t.length - 1].focus) return t[t.length - 1]; } }, i = (s) => { if (s) { const t = s.querySelectorAll(o); t.length && t[0].focus && t[0].focus(); } }, h = (s) => { if (s) { const t = s.querySelectorAll(o); t.length && t[t.length - 1].focus && t[t.length - 1].focus(); } }, a = (s, t) => { let f = !0; if (s.keyCode !== e.enter && s.target === t) return !1; if (s.keyCode === e.enter && s.target === t) f = !0, setTimeout( () => { i(t); }, 1 ); else if (s.keyCode === e.esc) f = !1, t.focus(); else if (s.keyCode === e.tab) { const l = r(t), u = c(t); u && !s.shiftKey && s.target === u && (s.preventDefault(), l.focus()), l && s.shiftKey && s.target === l && (s.preventDefault(), u.focus()); } return f; }; export { r as firstFocusableChild, a as focusContainer, i as focusFirstFocusableChild, h as focusLastFocusableChild, c as lastFocusableChild };