UNPKG

3.03 kBJavaScriptView Raw
1import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2import _createClass from "@babel/runtime/helpers/createClass";
3import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
4import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
5import _inherits from "@babel/runtime/helpers/inherits";
6import React from 'react';
7import Circle from '@beisen-phoenix/icon/lib/circle';
8import ToolTip from '@beisen-phoenix/tooltip';
9import { $M4, $M5 } from '@beisen-phoenix/style-token';
10import utils from '@beisen-phoenix/common-utils';
11var classes = utils.BEMClass('select');
12import './index.css';
13
14var Tags =
15/*#__PURE__*/
16function (_React$PureComponent) {
17 _inherits(Tags, _React$PureComponent);
18
19 function Tags() {
20 var _getPrototypeOf2;
21
22 var _this;
23
24 _classCallCheck(this, Tags);
25
26 for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
27 args[_key] = arguments[_key];
28 }
29
30 _this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(Tags)).call.apply(_getPrototypeOf2, [this].concat(args)));
31 _this.tagSpanRef = React.createRef();
32 _this.state = {
33 hover: false
34 };
35
36 _this.onMouseEnter = function () {
37 _this.setState({
38 hover: true
39 });
40 };
41
42 _this.onMouseLeave = function () {
43 _this.setState({
44 hover: false
45 });
46 };
47
48 return _this;
49 }
50
51 _createClass(Tags, [{
52 key: "render",
53 value: function render() {
54 var _this$props = this.props,
55 _onClick = _this$props.onClick,
56 item = _this$props.item,
57 selectDisabled = _this$props.selectDisabled,
58 size = _this$props.size;
59 var hover = this.state.hover;
60 var itemDisabled = item.disabled,
61 label = item.label;
62 var TempCommponent = React.createElement("span", {
63 ref: this.tagSpanRef,
64 className: classes({
65 element: "tag",
66 modifiers: {
67 safari: utils.Browser.SAFARI
68 }
69 })
70 }, label);
71 return React.createElement("li", {
72 className: classes({
73 element: "tagItem",
74 modifiers: {
75 itemDisabled: itemDisabled,
76 selectDisabled: selectDisabled,
77 small: size === 'small'
78 }
79 })
80 }, React.createElement(ToolTip, {
81 title: label,
82 showOverflowTooltip: true
83 }, TempCommponent), selectDisabled || itemDisabled ? null : React.createElement("span", {
84 className: classes({
85 element: "tagIcon"
86 })
87 }, React.createElement(Circle, {
88 color: hover && !selectDisabled ? $M4 : $M5,
89 onClick: function onClick(e) {
90 _onClick && !selectDisabled && _onClick(item);
91 "";
92 e.stopPropagation && e.stopPropagation();
93 },
94 onMouseEnter: this.onMouseEnter,
95 onMouseLeave: this.onMouseLeave
96 })));
97 }
98 }]);
99
100 return Tags;
101}(React.PureComponent);
102
103export { Tags as default };
\No newline at end of file