UNPKG

1.99 kBJavaScriptView Raw
1import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
3var _excluded = ["color", "check"];
4import { CheckOutlined } from '@ant-design/icons';
5import { Tooltip } from 'antd';
6import React from 'react';
7import { jsx as _jsx } from "react/jsx-runtime";
8var Tag = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
9 var color = _ref.color,
10 check = _ref.check,
11 rest = _objectWithoutProperties(_ref, _excluded);
12 return /*#__PURE__*/_jsx("div", _objectSpread(_objectSpread({}, rest), {}, {
13 style: {
14 backgroundColor: color
15 },
16 ref: ref,
17 children: check ? /*#__PURE__*/_jsx(CheckOutlined, {}) : ''
18 }));
19});
20var ThemeColor = function ThemeColor(_ref2) {
21 var value = _ref2.value,
22 colorList = _ref2.colorList,
23 onChange = _ref2.onChange,
24 prefixCls = _ref2.prefixCls,
25 formatMessage = _ref2.formatMessage,
26 hashId = _ref2.hashId;
27 if (!colorList || (colorList === null || colorList === void 0 ? void 0 : colorList.length) < 1) {
28 return null;
29 }
30 var baseClassName = "".concat(prefixCls, "-theme-color");
31 return /*#__PURE__*/_jsx("div", {
32 className: "".concat(baseClassName, " ").concat(hashId),
33 children: colorList === null || colorList === void 0 ? void 0 : colorList.map(function (_ref3) {
34 var key = _ref3.key,
35 color = _ref3.color,
36 title = _ref3.title;
37 if (!key) return null;
38 return /*#__PURE__*/_jsx(Tooltip, {
39 title: title !== null && title !== void 0 ? title : formatMessage({
40 id: "app.setting.themecolor.".concat(key)
41 }),
42 children: /*#__PURE__*/_jsx(Tag, {
43 className: "".concat(baseClassName, "-block ").concat(hashId),
44 color: color,
45 check: value === color,
46 onClick: function onClick() {
47 return onChange && onChange(color);
48 }
49 })
50 }, color);
51 })
52 });
53};
54export { ThemeColor };
\No newline at end of file