@progress/kendo-react-common
Version:
React Common package delivers common utilities that can be used with the KendoReact UI components. KendoReact Common Utilities package
9 lines (8 loc) • 1.71 kB
JavaScript
/**
* @license
*-------------------------------------------------------------------------------------------
* Copyright © 2025 Progress Software Corporation. All rights reserved.
* Licensed under commercial license. See LICENSE.md in the package root for more information
*-------------------------------------------------------------------------------------------
*/
;Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("./keys.js"),l=require("./constants/main.js"),a=(s,o=l.FOCUSABLE_ELEMENTS)=>s.querySelectorAll(o.join(",")),r=(s,o=l.FOCUSABLE_ELEMENTS)=>{if(s){const t=a(s,o);if(t.length&&t[0].focus)return t[0]}},c=(s,o=l.FOCUSABLE_ELEMENTS)=>{if(s){const t=a(s,o);if(t.length&&t[t.length-1].focus)return t[t.length-1]}},u=(s,o)=>{if(s){const t=r(s,o);t&&t.focus()}},b=(s,o)=>{if(s){const t=c(s,o);t&&t.focus()}},n=(s,o,t)=>{if(!(!o||s.keyCode!==f.Keys.tab)&&o){const e=r(o,t),i=c(o,t);e&&i&&!s.shiftKey&&s.target===i&&(s.preventDefault(),e.focus()),e&&i&&s.shiftKey&&s.target===e&&(s.preventDefault(),i.focus()),e||s.preventDefault()}},C=(s,o,t,e)=>{let i=!0;if(s.keyCode!==f.Keys.enter&&s.target===o){t&&t(!1);return}s.keyCode===f.Keys.enter&&s.target===o?(i=!0,setTimeout(()=>{u(o,e)},1)):s.keyCode===f.Keys.esc?(i=!1,o.focus()):n(s,o,e),t&&t(i)},d=(s,o)=>{const t=a(s,o);t&&t.forEach(e=>{e.tabIndex=0})},h=(s,o)=>{const t=a(s,o);t&&t.forEach(e=>{e.tabIndex=-1})};exports.applyTrappedFocus=C;exports.disableNavigatableContainer=h;exports.enableNavigatableContainer=d;exports.firstFocusableChild=r;exports.focusFirstFocusableChild=u;exports.focusLastFocusableChild=b;exports.focusableChildren=a;exports.keepFocusInContainer=n;exports.lastFocusableChild=c;