UNPKG

802 BJavaScriptView Raw
1"use strict";
2
3var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4Object.defineProperty(exports, "__esModule", {
5 value: true
6});
7exports.default = useHoverState;
8var _context = require("@rc-component/context");
9var _TableContext = _interopRequireDefault(require("../context/TableContext"));
10/** Check if cell is in hover range */
11function inHoverRange(cellStartRow, cellRowSpan, startRow, endRow) {
12 var cellEndRow = cellStartRow + cellRowSpan - 1;
13 return cellStartRow <= endRow && cellEndRow >= startRow;
14}
15function useHoverState(rowIndex, rowSpan) {
16 return (0, _context.useContext)(_TableContext.default, function (ctx) {
17 var hovering = inHoverRange(rowIndex, rowSpan || 1, ctx.hoverStartRow, ctx.hoverEndRow);
18 return [hovering, ctx.onHover];
19 });
20}
\No newline at end of file