UNPKG

@adaptabletools/adaptable-cjs

Version:

Powerful data-agnostic HTML5 AG Grid extension which provides advanced, cutting-edge functionality to meet all DataGrid requirements

30 lines (29 loc) 966 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); const getFocusableChildren_1 = tslib_1.__importDefault(require("./getFocusableChildren")); const emptyObject = {}; exports.default = (node, event, config) => { config = config || emptyObject; const { key, target, shiftKey } = event; if (key != 'Tab') { return; } const focusableChildren = (config.getFocusableChildren || getFocusableChildren_1.default)(node); const last = focusableChildren[focusableChildren.length - 1]; const first = focusableChildren[0]; if (target === first && first && shiftKey) { event.preventDefault(); if (last && last.focus) { last.focus(); } return true; } if (target === last && last && !shiftKey) { event.preventDefault(); if (first && first.focus) { first.focus(); } return true; } };