UNPKG

@qn-pandora/pandora-visualization

Version:

Pandora 通用可视化库

146 lines (145 loc) 6.82 kB
"use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (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) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; var __values = (this && this.__values) || function(o) { var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; if (m) return m.call(o); if (o && typeof o.length === "number") return { next: function () { if (o && i >= o.length) o = void 0; return { value: o && o[i++], done: !o }; } }; throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); }; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); var React = __importStar(require("react")); var classnames_1 = __importDefault(require("classnames")); var mobx_react_1 = require("mobx-react"); var mobx_1 = require("mobx"); var icons_1 = require("@ant-design/icons"); var antd_1 = require("antd"); var bind_1 = __importDefault(require("../../../utils/bind")); var language_1 = require("../../../services/language"); var style = __importStar(require("./style.mless")); /** * 资源列表页面表格中操作列表 */ var OptionList = /** @class */ (function (_super) { __extends(OptionList, _super); function OptionList() { var _this = _super !== null && _super.apply(this, arguments) || this; _this.visible = false; return _this; } OptionList.prototype.setVisible = function (visible) { this.visible = visible; }; OptionList.prototype.handleItemClick = function (option) { if (option.disabled || !option.onClick) { return; } this.setVisible(false); option.onClick(option.source); }; OptionList.prototype.render = function () { var e_1, _a; var _this = this; var _b = this.props, className = _b.className, options = _b.options, getPopupContainer = _b.getPopupContainer, children = _b.children; var items = []; var _loop_1 = function (option) { var _a; var key = option.key, text = option.text, title = option.title, disabled = option.disabled, hidden = option.hidden; if (hidden) { return "continue"; } var itemClass = classnames_1.default(style.item, (_a = {}, _a[style.disabled] = disabled, _a)); var itemNode = (React.createElement("div", { key: key || text, className: itemClass, onClick: function () { return _this.handleItemClick(option); } }, language_1.formatString(text))); if (title) { items.push(React.createElement(antd_1.Tooltip, { title: language_1.formatString(title), getPopupContainer: getPopupContainer, placement: "left" }, itemNode)); } else { items.push(itemNode); } }; try { for (var options_1 = __values(options), options_1_1 = options_1.next(); !options_1_1.done; options_1_1 = options_1.next()) { var option = options_1_1.value; _loop_1(option); } } catch (e_1_1) { e_1 = { error: e_1_1 }; } finally { try { if (options_1_1 && !options_1_1.done && (_a = options_1.return)) _a.call(options_1); } finally { if (e_1) throw e_1.error; } } var content = (React.createElement("div", { className: classnames_1.default(className, style.list) }, items)); return (React.createElement(antd_1.Popover, { placement: "bottom", getPopupContainer: getPopupContainer, trigger: "click", open: this.visible, overlayClassName: style.popover, onOpenChange: this.setVisible, content: content }, children || React.createElement(icons_1.EllipsisOutlined, { className: style.icon }))); }; __decorate([ mobx_1.observable, __metadata("design:type", Boolean) ], OptionList.prototype, "visible", void 0); __decorate([ bind_1.default, mobx_1.action, __metadata("design:type", Function), __metadata("design:paramtypes", [Boolean]), __metadata("design:returntype", void 0) ], OptionList.prototype, "setVisible", null); __decorate([ bind_1.default, __metadata("design:type", Function), __metadata("design:paramtypes", [Object]), __metadata("design:returntype", void 0) ], OptionList.prototype, "handleItemClick", null); OptionList = __decorate([ mobx_react_1.observer ], OptionList); return OptionList; }(React.Component)); exports.default = OptionList;