UNPKG

devextreme

Version:

JavaScript/TypeScript Component Suite for Responsive Web Development

68 lines (66 loc) 4.34 kB
/** * DevExtreme (cjs/__internal/grids/grid_core/keyboard_navigation/utils.js) * Version: 25.2.7 * Build date: Tue May 05 2026 * * Copyright (c) 2012 - 2026 Developer Express Inc. ALL RIGHTS RESERVED * Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/ */ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.shouldPreventScroll = exports.isNotFocusedRow = exports.isMobile = exports.isGroupRow = exports.isGroupFooterRow = exports.isFixedColumnIndexOffsetRequired = exports.isElementDefined = exports.isEditorCell = exports.isEditRow = exports.isEditForm = exports.isDetailRow = exports.isDataRow = exports.isCellInHeaderRow = exports.isAdaptiveItem = exports.getNextColumnIndex = exports.getInteractiveElements = exports.getInteractiveElement = void 0; var _devices = _interopRequireDefault(require("../../../../core/devices")); var _type = require("../../../../core/utils/type"); var _const = require("../editing/const"); var _const2 = require("./const"); function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e } } const DATAGRID_GROUP_FOOTER_CLASS = "dx-datagrid-group-footer"; const isGroupRow = $row => !!(null !== $row && void 0 !== $row && $row.hasClass(_const2.GROUP_ROW_CLASS)); exports.isGroupRow = isGroupRow; const isGroupFooterRow = $row => null === $row || void 0 === $row ? void 0 : $row.hasClass("dx-datagrid-group-footer"); exports.isGroupFooterRow = isGroupFooterRow; const isDetailRow = $row => null === $row || void 0 === $row ? void 0 : $row.hasClass(_const2.MASTER_DETAIL_ROW_CLASS); exports.isDetailRow = isDetailRow; const isAdaptiveItem = $element => null === $element || void 0 === $element ? void 0 : $element.hasClass(_const2.ADAPTIVE_ITEM_TEXT_CLASS); exports.isAdaptiveItem = isAdaptiveItem; const isEditRow = $row => null === $row || void 0 === $row ? void 0 : $row.hasClass(_const.EDIT_ROW); exports.isEditRow = isEditRow; const isEditForm = $row => (null === $row || void 0 === $row ? void 0 : $row.hasClass(_const2.MASTER_DETAIL_ROW_CLASS)) && $row.hasClass(_const2.EDIT_FORM_CLASS); exports.isEditForm = isEditForm; const isDataRow = $row => !!(null !== $row && void 0 !== $row && $row.hasClass(_const2.DATA_ROW_CLASS)); exports.isDataRow = isDataRow; const isNotFocusedRow = $row => !$row || $row.hasClass(_const2.FREESPACE_ROW_CLASS) || $row.hasClass(_const2.VIRTUAL_ROW_CLASS); exports.isNotFocusedRow = isNotFocusedRow; const isEditorCell = (that, $cell) => !that.isRowEditMode() && $cell && !$cell.hasClass(_const2.COMMAND_SELECT_CLASS) && $cell.hasClass(_const.EDITOR_CELL_CLASS); exports.isEditorCell = isEditorCell; const isElementDefined = $element => (0, _type.isDefined)($element) && $element.length > 0; exports.isElementDefined = isElementDefined; const isMobile = () => "desktop" !== _devices.default.current().deviceType; exports.isMobile = isMobile; const isCellInHeaderRow = $cell => !!$cell.parent(`.${_const2.HEADER_ROW_CLASS}`).length; exports.isCellInHeaderRow = isCellInHeaderRow; const isFixedColumnIndexOffsetRequired = (that, column) => { const rtlEnabled = that.option("rtlEnabled"); if (rtlEnabled) { return !("right" === column.fixedPosition || (0, _type.isDefined)(column.command) && !(0, _type.isDefined)(column.fixedPosition)) } return !(!(0, _type.isDefined)(column.fixedPosition) || "left" === column.fixedPosition) }; exports.isFixedColumnIndexOffsetRequired = isFixedColumnIndexOffsetRequired; const shouldPreventScroll = that => that._isVirtualScrolling() ? that.option("focusedRowIndex") === that.getRowIndex() : false; exports.shouldPreventScroll = shouldPreventScroll; const getInteractiveElements = $cell => $cell.find(_const2.INTERACTIVE_ELEMENTS_SELECTOR).filter(":visible"); exports.getInteractiveElements = getInteractiveElements; const getInteractiveElement = ($cell, isLast) => { const $focusedElement = getInteractiveElements($cell); return isLast ? $focusedElement.last() : $focusedElement.first() }; exports.getInteractiveElement = getInteractiveElement; const getNextColumnIndex = (direction, columnIndex) => "next" === direction || "nextInRow" === direction ? columnIndex + 1 : columnIndex - 1; exports.getNextColumnIndex = getNextColumnIndex;