1 | import _extends from "@babel/runtime/helpers/esm/extends";
|
2 | import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
3 | import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
4 | var __rest = this && this.__rest || function (s, e) {
|
5 | var t = {};
|
6 | for (var p in s) {
|
7 | if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
8 | }
|
9 | if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
10 | if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
|
11 | }
|
12 | return t;
|
13 | };
|
14 | import classNames from 'classnames';
|
15 | import * as React from 'react';
|
16 | import { ConfigContext } from '../config-provider';
|
17 | import useStyle from './style';
|
18 | var CheckableTag = function CheckableTag(_a) {
|
19 | var _classNames;
|
20 | var customizePrefixCls = _a.prefixCls,
|
21 | className = _a.className,
|
22 | checked = _a.checked,
|
23 | onChange = _a.onChange,
|
24 | onClick = _a.onClick,
|
25 | restProps = __rest(_a, ["prefixCls", "className", "checked", "onChange", "onClick"]);
|
26 | var _React$useContext = React.useContext(ConfigContext),
|
27 | getPrefixCls = _React$useContext.getPrefixCls;
|
28 | var handleClick = function handleClick(e) {
|
29 | onChange === null || onChange === void 0 ? void 0 : onChange(!checked);
|
30 | onClick === null || onClick === void 0 ? void 0 : onClick(e);
|
31 | };
|
32 | var prefixCls = getPrefixCls('tag', customizePrefixCls);
|
33 |
|
34 | var _useStyle = useStyle(prefixCls),
|
35 | _useStyle2 = _slicedToArray(_useStyle, 2),
|
36 | wrapSSR = _useStyle2[0],
|
37 | hashId = _useStyle2[1];
|
38 | var cls = classNames(prefixCls, (_classNames = {}, _defineProperty(_classNames, prefixCls + "-checkable", true), _defineProperty(_classNames, prefixCls + "-checkable-checked", checked), _classNames), className, hashId);
|
39 | return wrapSSR( React.createElement("span", _extends({}, restProps, {
|
40 | className: cls,
|
41 | onClick: handleClick
|
42 | })));
|
43 | };
|
44 | export default CheckableTag; |
\ | No newline at end of file |