UNPKG

zent

Version:

一套前端设计语言和基于React的实现

60 lines (59 loc) 2.99 kB
import { __assign, __extends, __spreadArray } from "tslib"; import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime"; import { Component } from 'react'; import cn from 'classnames'; import Icon from '../../../icon'; var BaseTab = (function (_super) { __extends(BaseTab, _super); function BaseTab() { var _this = _super !== null && _super.apply(this, arguments) || this; _this.onDel = function (e) { e.stopPropagation(); var _a = _this.props, onDelete = _a.onDelete, id = _a.id; onDelete && onDelete(id); }; _this.onClick = function () { var _a = _this.props, onSelected = _a.onSelected, id = _a.id, actived = _a.actived, disabled = _a.disabled; if (!actived && !disabled) { onSelected && onSelected(id); } }; _this.onClickFixed = function (e) { e.stopPropagation(); var _a = _this.props, _b = _a.fixedIds, fixedIds = _b === void 0 ? [] : _b, onFixedChange = _a.onFixedChange, id = _a.id; var ids = _this.isFixed ? fixedIds.filter(function (key) { return key !== id; }) : __spreadArray(__spreadArray([], fixedIds), [id]); onFixedChange === null || onFixedChange === void 0 ? void 0 : onFixedChange(ids); }; return _this; } Object.defineProperty(BaseTab.prototype, "tabsCls", { get: function () { var _a; var _b = this.props, actived = _b.actived, disabled = _b.disabled; return cn('zent-tabs-tab', "zent-tabs-tab-type__" + this.typeName, (_a = {}, _a['zent-tabs-tab__actived'] = actived, _a['zent-tabs-tab__disabled'] = disabled, _a)); }, enumerable: false, configurable: true }); Object.defineProperty(BaseTab.prototype, "isFixed", { get: function () { var _a = this.props, id = _a.id, _b = _a.fixedIds, fixedIds = _b === void 0 ? [] : _b; return fixedIds.includes(id); }, enumerable: false, configurable: true }); BaseTab.prototype.renderDelOperater = function () { var _a = this.props, candel = _a.candel, canFixed = _a.canFixed; return candel ? (_jsxs("div", __assign({ className: cn('zent-tabs-tab__actions', { 'zent-tabs-tab-actions--fixed': this.isFixed, }), "data-zv": '10.0.17' }, { children: [!this.isFixed && (_jsx("span", __assign({ className: "zent-tabs-tab__actions__delete", onClick: this.onDel, "data-zv": '10.0.17' }, { children: "\u2715" }), void 0)), canFixed && (_jsx("span", __assign({ className: "zent-tabs-tab__actions__fixed", onClick: this.onClickFixed, "data-zv": '10.0.17' }, { children: this.isFixed ? _jsx(Icon, { type: "pin" }, void 0) : _jsx(Icon, { type: "pin-o" }, void 0) }), void 0))] }), void 0)) : null; }; return BaseTab; }(Component)); export default BaseTab;