devextreme
Version:
JavaScript/TypeScript Component Suite for Responsive Web Development
56 lines (55 loc) • 3.17 kB
JavaScript
/**
* DevExtreme (esm/__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/
*/
import devices from "../../../../core/devices";
import {
isDefined
} from "../../../../core/utils/type";
import {
EDIT_ROW,
EDITOR_CELL_CLASS
} from "../editing/const";
import {
ADAPTIVE_ITEM_TEXT_CLASS,
COMMAND_SELECT_CLASS,
DATA_ROW_CLASS,
EDIT_FORM_CLASS,
FREESPACE_ROW_CLASS,
GROUP_ROW_CLASS,
HEADER_ROW_CLASS,
INTERACTIVE_ELEMENTS_SELECTOR,
MASTER_DETAIL_ROW_CLASS,
VIRTUAL_ROW_CLASS
} from "./const";
const DATAGRID_GROUP_FOOTER_CLASS = "dx-datagrid-group-footer";
export const isGroupRow = $row => !!(null !== $row && void 0 !== $row && $row.hasClass(GROUP_ROW_CLASS));
export const isGroupFooterRow = $row => null === $row || void 0 === $row ? void 0 : $row.hasClass("dx-datagrid-group-footer");
export const isDetailRow = $row => null === $row || void 0 === $row ? void 0 : $row.hasClass(MASTER_DETAIL_ROW_CLASS);
export const isAdaptiveItem = $element => null === $element || void 0 === $element ? void 0 : $element.hasClass(ADAPTIVE_ITEM_TEXT_CLASS);
export const isEditRow = $row => null === $row || void 0 === $row ? void 0 : $row.hasClass(EDIT_ROW);
export const isEditForm = $row => (null === $row || void 0 === $row ? void 0 : $row.hasClass(MASTER_DETAIL_ROW_CLASS)) && $row.hasClass(EDIT_FORM_CLASS);
export const isDataRow = $row => !!(null !== $row && void 0 !== $row && $row.hasClass(DATA_ROW_CLASS));
export const isNotFocusedRow = $row => !$row || $row.hasClass(FREESPACE_ROW_CLASS) || $row.hasClass(VIRTUAL_ROW_CLASS);
export const isEditorCell = (that, $cell) => !that.isRowEditMode() && $cell && !$cell.hasClass(COMMAND_SELECT_CLASS) && $cell.hasClass(EDITOR_CELL_CLASS);
export const isElementDefined = $element => isDefined($element) && $element.length > 0;
export const isMobile = () => "desktop" !== devices.current().deviceType;
export const isCellInHeaderRow = $cell => !!$cell.parent(`.${HEADER_ROW_CLASS}`).length;
export const isFixedColumnIndexOffsetRequired = (that, column) => {
const rtlEnabled = that.option("rtlEnabled");
if (rtlEnabled) {
return !("right" === column.fixedPosition || isDefined(column.command) && !isDefined(column.fixedPosition))
}
return !(!isDefined(column.fixedPosition) || "left" === column.fixedPosition)
};
export const shouldPreventScroll = that => that._isVirtualScrolling() ? that.option("focusedRowIndex") === that.getRowIndex() : false;
export const getInteractiveElements = $cell => $cell.find(INTERACTIVE_ELEMENTS_SELECTOR).filter(":visible");
export const getInteractiveElement = ($cell, isLast) => {
const $focusedElement = getInteractiveElements($cell);
return isLast ? $focusedElement.last() : $focusedElement.first()
};
export const getNextColumnIndex = (direction, columnIndex) => "next" === direction || "nextInRow" === direction ? columnIndex + 1 : columnIndex - 1;