UNPKG

1.72 kBJavaScriptView Raw
1import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2import { CheckOutlined } from '@ant-design/icons';
3import { Tooltip } from 'antd';
4import classNames from 'classnames';
5import { useMemo } from 'react';
6var BlockCheckbox = function BlockCheckbox(_ref) {
7 var value = _ref.value,
8 configType = _ref.configType,
9 onChange = _ref.onChange,
10 list = _ref.list,
11 prefixCls = _ref.prefixCls,
12 hashId = _ref.hashId;
13 var baseClassName = "".concat(prefixCls, "-block-checkbox");
14 var dom = useMemo(function () {
15 var domList = (list || []).map(function (item) {
16 return _jsx(Tooltip, {
17 title: item.title,
18 children: _jsxs("div", {
19 className: classNames(hashId, "".concat(baseClassName, "-item"), "".concat(baseClassName, "-item-").concat(item.key), "".concat(baseClassName, "-").concat(configType, "-item")),
20 onClick: function onClick() {
21 return onChange(item.key);
22 },
23 children: [_jsx(CheckOutlined, {
24 className: "".concat(baseClassName, "-selectIcon ").concat(hashId),
25 style: {
26 display: value === item.key ? 'block' : 'none'
27 }
28 }), (item === null || item === void 0 ? void 0 : item.icon) ? _jsx("div", {
29 className: "".concat(baseClassName, "-icon ").concat(hashId),
30 children: item.icon
31 }) : null]
32 })
33 }, item.key);
34 });
35 return domList;
36 // eslint-disable-next-line react-hooks/exhaustive-deps
37 }, [value, list === null || list === void 0 ? void 0 : list.length, onChange]);
38 return _jsx("div", {
39 className: classNames(baseClassName, hashId),
40 children: dom
41 });
42};
43export { BlockCheckbox };
\No newline at end of file