@aloudata/aloudata-design 2.6.2 → 2.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/Tag/index.js CHANGED
@@ -1,2 +1,82 @@
1
- import { Tag } from 'antd';
2
- export default Tag;
1
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
2
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
3
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
4
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
5
+ import React, { useCallback } from 'react';
6
+ import { CloseLightLine } from "../Icon";
7
+ import classNames from 'classnames';
8
+ export default function Tag(props) {
9
+ var _classNames;
10
+ var children = props.children,
11
+ onClick = props.onClick,
12
+ closable = props.closable,
13
+ onClose = props.onClose,
14
+ color = props.color,
15
+ icon = props.icon,
16
+ _props$size = props.size,
17
+ size = _props$size === void 0 ? 'middle' : _props$size,
18
+ status = props.status,
19
+ mode = props.mode,
20
+ disabled = props.disabled,
21
+ className = props.className;
22
+ var tagColor = getColor(color, status);
23
+ var bgColor = mode === 'border' ? '#fff' : convertHexToRGBA(tagColor, mode === 'fill' ? 0.16 : 0.06);
24
+ var onTagClick = useCallback(function (e) {
25
+ if (disabled) {
26
+ return;
27
+ }
28
+ onClick === null || onClick === void 0 ? void 0 : onClick(e);
29
+ }, [disabled, onClick]);
30
+ var onCloseBtnClick = useCallback(function (e) {
31
+ if (disabled) {
32
+ return;
33
+ }
34
+ onClose === null || onClose === void 0 ? void 0 : onClose(e);
35
+ }, [disabled, onClose]);
36
+ return /*#__PURE__*/React.createElement("span", {
37
+ className: classNames(prefixCls('container'), (_classNames = {}, _defineProperty(_classNames, prefixCls('small'), size === 'small'), _defineProperty(_classNames, prefixCls('large'), size === 'large'), _defineProperty(_classNames, prefixCls('clickable'), typeof onClick === 'function'), _defineProperty(_classNames, prefixCls('disabled'), disabled), _classNames), className || ''),
38
+ style: {
39
+ backgroundColor: bgColor,
40
+ color: convertHexToRGBA(tagColor, 1),
41
+ borderColor: mode === 'fill' ? 'transparent' : convertHexToRGBA(tagColor, 0.32)
42
+ },
43
+ onClick: onTagClick
44
+ }, icon && /*#__PURE__*/React.createElement("span", {
45
+ className: prefixCls('icon')
46
+ }, icon), /*#__PURE__*/React.createElement("span", {
47
+ className: prefixCls('content')
48
+ }, children), closable ? /*#__PURE__*/React.createElement("span", {
49
+ className: prefixCls('close-btn'),
50
+ onClick: onCloseBtnClick
51
+ }, /*#__PURE__*/React.createElement(CloseLightLine, {
52
+ color: tagColor,
53
+ size: 16
54
+ })) : null);
55
+ }
56
+ function getColor(color, status) {
57
+ if (color) {
58
+ return color;
59
+ }
60
+ var status2ColorMap = {
61
+ success: '#15803D',
62
+ info: '#126FDD',
63
+ warning: '#A16207',
64
+ error: '#B91C1C',
65
+ default: '#374151'
66
+ };
67
+ if (status) {
68
+ return status2ColorMap[status];
69
+ }
70
+ return status2ColorMap['info'];
71
+ }
72
+ var ALD_PREFIX = 'ald-tag';
73
+ export function prefixCls(className) {
74
+ return "".concat(ALD_PREFIX, "-").concat(className);
75
+ }
76
+ function convertHexToRGBA(hex, opacity) {
77
+ var tempHex = hex.replace('#', '');
78
+ var r = parseInt(tempHex.substring(0, 2), 16);
79
+ var g = parseInt(tempHex.substring(2, 4), 16);
80
+ var b = parseInt(tempHex.substring(4, 6), 16);
81
+ return "rgba(".concat(r, ",").concat(g, ",").concat(b, ",").concat(opacity, ")");
82
+ }
@@ -1 +1,67 @@
1
1
  @import '../../style/index.less';
2
+
3
+ .ald-tag-container {
4
+ display: inline-flex;
5
+ padding: 1px 5px;
6
+ align-items: center;
7
+ column-gap: var(--alias-spacing-50, 4px);
8
+ border-width: 1px;
9
+ border-style: solid;
10
+ border-radius: var(--alias-radius-50, 4px);
11
+ font-size: 14px;
12
+ line-height: 20px;
13
+ max-width: 160px;
14
+ overflow: hidden;
15
+
16
+ &.ald-tag-clickable {
17
+ cursor: pointer;
18
+ }
19
+
20
+ /** 尺寸 **/
21
+ &.ald-tag-small {
22
+ font-size: 12px;
23
+ padding: 1px 3px;
24
+ line-height: 16px;
25
+ border-radius: 2px;
26
+ }
27
+
28
+ &.ald-tag-large {
29
+ font-size: 16px;
30
+ padding: 1px 7px;
31
+ line-height: 24px;
32
+ border-radius: 6px;
33
+ }
34
+
35
+ /** 超长文本截断 **/
36
+ .ald-tag-content {
37
+ overflow: hidden;
38
+ text-overflow: ellipsis;
39
+ white-space: nowrap;
40
+ flex: 1 1 auto;
41
+ }
42
+
43
+ /** 可关闭 **/
44
+ .ald-tag-close-btn {
45
+ display: inline-flex;
46
+ align-items: center;
47
+ cursor: pointer;
48
+ flex: 0 0 auto;
49
+ }
50
+
51
+ /** icon **/
52
+ .ald-tag-icon {
53
+ flex: 0 0 auto;
54
+ display: inline-flex;
55
+ align-items: center;
56
+ }
57
+
58
+ /** 禁用 **/
59
+ &.ald-tag-disabled {
60
+ cursor: initial;
61
+ opacity: 0.4;
62
+
63
+ .ald-tag-close-btn {
64
+ cursor: initial;
65
+ }
66
+ }
67
+ }