UNPKG

ze-react-component-library

Version:
74 lines (59 loc) 2.1 kB
var __extends = this && this.__extends || function () { var _extendStatics = function extendStatics(d, b) { _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; } || function (d, b) { for (var p in b) { if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; } }; return _extendStatics(d, b); }; return function (d, b) { if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); _extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; }(); import { BaseEvent, S2Event } from "@antv/s2"; import React from "react"; var RowColumnHoverTooltipInteraction = /** @class */ function (_super) { __extends(RowColumnHoverTooltipInteraction, _super); function RowColumnHoverTooltipInteraction() { return _super !== null && _super.apply(this, arguments) || this; } RowColumnHoverTooltipInteraction.prototype.bindEvents = function () { var _this = this; // 行头 hover this.spreadsheet.on(S2Event.ROW_CELL_HOVER, function (event) { _this.showTooltip(event); }); // 列头 hover this.spreadsheet.on(S2Event.COL_CELL_HOVER, function (event) { _this.showTooltip(event); }); }; RowColumnHoverTooltipInteraction.prototype.showTooltip = function (event) { var cell = this.spreadsheet.getCell(event.target); var meta = cell === null || cell === void 0 ? void 0 : cell.getMeta(); var content = (meta === null || meta === void 0 ? void 0 : meta.value) || "custom"; this.spreadsheet.showTooltip({ position: { x: event.clientX, y: event.clientY }, content: /*#__PURE__*/React.createElement("div", { style: { padding: 4 } }, content) }); }; return RowColumnHoverTooltipInteraction; }(BaseEvent); export default RowColumnHoverTooltipInteraction;