UNPKG

ze-react-component-library

Version:
85 lines (66 loc) 2.37 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var _s = require("@antv/s2"); var _react = _interopRequireDefault(require("react")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var __extends = void 0 && (void 0).__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 __()); }; }(); 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(_s.S2Event.ROW_CELL_HOVER, function (event) { _this.showTooltip(event); }); // 列头 hover this.spreadsheet.on(_s.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.default.createElement("div", { style: { padding: 4 } }, content) }); }; return RowColumnHoverTooltipInteraction; }(_s.BaseEvent); var _default = RowColumnHoverTooltipInteraction; exports.default = _default;