1 | "use strict";
|
2 |
|
3 | var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
4 | Object.defineProperty(exports, "__esModule", {
|
5 | value: true
|
6 | });
|
7 | exports.default = useHoverState;
|
8 | var _context = require("@rc-component/context");
|
9 | var _TableContext = _interopRequireDefault(require("../context/TableContext"));
|
10 |
|
11 | function inHoverRange(cellStartRow, cellRowSpan, startRow, endRow) {
|
12 | var cellEndRow = cellStartRow + cellRowSpan - 1;
|
13 | return cellStartRow <= endRow && cellEndRow >= startRow;
|
14 | }
|
15 | function 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 |