1
This commit is contained in:
+20
@@ -0,0 +1,20 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = useHoverState;
|
||||
var _context = require("@rc-component/context");
|
||||
var _TableContext = _interopRequireDefault(require("../context/TableContext"));
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
/** Check if cell is in hover range */
|
||||
function inHoverRange(cellStartRow, cellRowSpan, startRow, endRow) {
|
||||
const cellEndRow = cellStartRow + cellRowSpan - 1;
|
||||
return cellStartRow <= endRow && cellEndRow >= startRow;
|
||||
}
|
||||
function useHoverState(rowIndex, rowSpan) {
|
||||
return (0, _context.useContext)(_TableContext.default, ctx => {
|
||||
const hovering = inHoverRange(rowIndex, rowSpan || 1, ctx.hoverStartRow, ctx.hoverEndRow);
|
||||
return [hovering, ctx.onHover];
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user