tntd 2.1.0 → 2.2.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/es/ellipsis/index.less +4 -0
- package/es/index.js +2 -1
- package/es/index.js.map +1 -1
- package/es/label/index.js +1 -0
- package/es/label/index.js.map +1 -0
- package/es/label/label.js +140 -0
- package/es/label/label.js.map +1 -0
- package/es/{tag/tag.less → label/label.less} +9 -7
- package/es/label/label.test.js +12 -0
- package/es/label/label.test.js.map +1 -0
- package/es/tag/index.js +1 -139
- package/es/tag/index.js.map +1 -1
- package/lib/ellipsis/index.less +4 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +7 -0
- package/lib/index.js.map +1 -1
- package/lib/label/index.d.ts +2 -0
- package/lib/label/index.d.ts.map +1 -0
- package/lib/{status → label}/index.js +4 -4
- package/lib/label/index.js.map +1 -0
- package/lib/label/label.d.ts +52 -0
- package/lib/label/label.d.ts.map +1 -0
- package/lib/label/label.js +150 -0
- package/lib/label/label.js.map +1 -0
- package/lib/{tag/tag.less → label/label.less} +9 -7
- package/lib/label/label.test.d.ts +2 -0
- package/lib/label/label.test.d.ts.map +1 -0
- package/lib/label/label.test.js +14 -0
- package/lib/label/label.test.js.map +1 -0
- package/lib/tag/index.d.ts +1 -50
- package/lib/tag/index.d.ts.map +1 -1
- package/lib/tag/index.js +4 -145
- package/lib/tag/index.js.map +1 -1
- package/package.json +3 -4
- package/themes/default/variables.less +2 -2
- package/codemod/__testfixtures__/v1-to-v2-react.input.js +0 -24
- package/codemod/__testfixtures__/v1-to-v2-react.output.js +0 -23
- package/codemod/__testfixtures__/v1-to-v2.input.js +0 -2
- package/codemod/__testfixtures__/v1-to-v2.output.js +0 -2
- package/codemod/__tests__/v1-to-v2-test.js +0 -4
- package/codemod/v1-to-v2.js +0 -96
- package/es/array-input/style/index.js +0 -1
- package/es/array-input/style/index.js.map +0 -1
- package/es/auth-context/style/index.js +0 -1
- package/es/auth-context/style/index.js.map +0 -1
- package/es/development-login/style/index.js +0 -1
- package/es/development-login/style/index.js.map +0 -1
- package/es/ellipsis/style/index.js +0 -1
- package/es/ellipsis/style/index.js.map +0 -1
- package/es/empty/render-empty.js +0 -22
- package/es/empty/render-empty.js.map +0 -1
- package/es/empty/style/index.js +0 -2
- package/es/empty/style/index.js.map +0 -1
- package/es/handle/style/index.js +0 -1
- package/es/handle/style/index.js.map +0 -1
- package/es/icon-list/style/index.js +0 -1
- package/es/icon-list/style/index.js.map +0 -1
- package/es/img/style/index.js +0 -1
- package/es/img/style/index.js.map +0 -1
- package/es/loading-button/style/index.js +0 -1
- package/es/loading-button/style/index.js.map +0 -1
- package/es/page/style/index.js +0 -1
- package/es/page/style/index.js.map +0 -1
- package/es/query-form/style/index.js +0 -1
- package/es/query-form/style/index.js.map +0 -1
- package/es/query-list-scene/style/index.js +0 -1
- package/es/query-list-scene/style/index.js.map +0 -1
- package/es/render-empty/style/index.js +0 -1
- package/es/render-empty/style/index.js.map +0 -1
- package/es/status/index.js +0 -1
- package/es/status/index.js.map +0 -1
- package/es/status/status.js +0 -5
- package/es/status/status.js.map +0 -1
- package/es/table/style/index.js +0 -2
- package/es/table/style/index.js.map +0 -1
- package/es/title/style/index.js +0 -1
- package/es/title/style/index.js.map +0 -1
- package/es/tntd-icon/style/index.js +0 -1
- package/es/tntd-icon/style/index.js.map +0 -1
- package/es/tntd-layout/style/index.js +0 -1
- package/es/tntd-layout/style/index.js.map +0 -1
- package/es/tntd-modal/style/index.js +0 -1
- package/es/tntd-modal/style/index.js.map +0 -1
- package/es/tntd-select/style/index.js +0 -1
- package/es/tntd-select/style/index.js.map +0 -1
- package/lib/array-input/style/index.d.ts +0 -1
- package/lib/array-input/style/index.d.ts.map +0 -1
- package/lib/array-input/style/index.js +0 -1
- package/lib/array-input/style/index.js.map +0 -1
- package/lib/auth-context/style/index.d.ts +0 -1
- package/lib/auth-context/style/index.d.ts.map +0 -1
- package/lib/auth-context/style/index.js +0 -1
- package/lib/auth-context/style/index.js.map +0 -1
- package/lib/development-login/style/index.d.ts +0 -1
- package/lib/development-login/style/index.d.ts.map +0 -1
- package/lib/development-login/style/index.js +0 -1
- package/lib/development-login/style/index.js.map +0 -1
- package/lib/ellipsis/style/index.d.ts +0 -1
- package/lib/ellipsis/style/index.d.ts.map +0 -1
- package/lib/ellipsis/style/index.js +0 -1
- package/lib/ellipsis/style/index.js.map +0 -1
- package/lib/empty/render-empty.d.ts +0 -3
- package/lib/empty/render-empty.d.ts.map +0 -1
- package/lib/empty/render-empty.js +0 -32
- package/lib/empty/render-empty.js.map +0 -1
- package/lib/empty/style/index.d.ts +0 -3
- package/lib/empty/style/index.d.ts.map +0 -1
- package/lib/empty/style/index.js +0 -4
- package/lib/empty/style/index.js.map +0 -1
- package/lib/handle/style/index.d.ts +0 -1
- package/lib/handle/style/index.d.ts.map +0 -1
- package/lib/handle/style/index.js +0 -1
- package/lib/handle/style/index.js.map +0 -1
- package/lib/icon-list/style/index.d.ts +0 -3
- package/lib/icon-list/style/index.d.ts.map +0 -1
- package/lib/icon-list/style/index.js +0 -8
- package/lib/icon-list/style/index.js.map +0 -1
- package/lib/img/style/index.d.ts +0 -1
- package/lib/img/style/index.d.ts.map +0 -1
- package/lib/img/style/index.js +0 -1
- package/lib/img/style/index.js.map +0 -1
- package/lib/loading-button/style/index.d.ts +0 -1
- package/lib/loading-button/style/index.d.ts.map +0 -1
- package/lib/loading-button/style/index.js +0 -1
- package/lib/loading-button/style/index.js.map +0 -1
- package/lib/page/style/index.d.ts +0 -1
- package/lib/page/style/index.d.ts.map +0 -1
- package/lib/page/style/index.js +0 -1
- package/lib/page/style/index.js.map +0 -1
- package/lib/query-form/style/index.d.ts +0 -1
- package/lib/query-form/style/index.d.ts.map +0 -1
- package/lib/query-form/style/index.js +0 -1
- package/lib/query-form/style/index.js.map +0 -1
- package/lib/query-list-scene/style/index.d.ts +0 -1
- package/lib/query-list-scene/style/index.d.ts.map +0 -1
- package/lib/query-list-scene/style/index.js +0 -1
- package/lib/query-list-scene/style/index.js.map +0 -1
- package/lib/render-empty/style/index.d.ts +0 -2
- package/lib/render-empty/style/index.d.ts.map +0 -1
- package/lib/render-empty/style/index.js +0 -3
- package/lib/render-empty/style/index.js.map +0 -1
- package/lib/status/index.d.ts +0 -2
- package/lib/status/index.d.ts.map +0 -1
- package/lib/status/index.js.map +0 -1
- package/lib/status/status.d.ts +0 -6
- package/lib/status/status.d.ts.map +0 -1
- package/lib/status/status.js +0 -13
- package/lib/status/status.js.map +0 -1
- package/lib/table/style/index.d.ts +0 -3
- package/lib/table/style/index.d.ts.map +0 -1
- package/lib/table/style/index.js +0 -4
- package/lib/table/style/index.js.map +0 -1
- package/lib/title/style/index.d.ts +0 -1
- package/lib/title/style/index.d.ts.map +0 -1
- package/lib/title/style/index.js +0 -1
- package/lib/title/style/index.js.map +0 -1
- package/lib/tntd-icon/style/index.d.ts +0 -1
- package/lib/tntd-icon/style/index.d.ts.map +0 -1
- package/lib/tntd-icon/style/index.js +0 -1
- package/lib/tntd-icon/style/index.js.map +0 -1
- package/lib/tntd-layout/style/index.d.ts +0 -1
- package/lib/tntd-layout/style/index.d.ts.map +0 -1
- package/lib/tntd-layout/style/index.js +0 -1
- package/lib/tntd-layout/style/index.js.map +0 -1
- package/lib/tntd-modal/style/index.d.ts +0 -1
- package/lib/tntd-modal/style/index.d.ts.map +0 -1
- package/lib/tntd-modal/style/index.js +0 -1
- package/lib/tntd-modal/style/index.js.map +0 -1
- package/lib/tntd-select/style/index.d.ts +0 -1
- package/lib/tntd-select/style/index.d.ts.map +0 -1
- package/lib/tntd-select/style/index.js +0 -1
- package/lib/tntd-select/style/index.js.map +0 -1
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import type { TagProps as AntdTagProps } from 'antd/lib/tag';
|
|
3
|
+
import './label.less';
|
|
4
|
+
export declare enum LabelColors {
|
|
5
|
+
cyan = "cyan",
|
|
6
|
+
green = "green",
|
|
7
|
+
iris = "iris",
|
|
8
|
+
blue = "blue",
|
|
9
|
+
lavender = "lavender",
|
|
10
|
+
orange = "orange",
|
|
11
|
+
golden = "golden",
|
|
12
|
+
red = "red",
|
|
13
|
+
grey = "grey"
|
|
14
|
+
}
|
|
15
|
+
export interface LabelProps extends AntdTagProps {
|
|
16
|
+
/**
|
|
17
|
+
* 类型
|
|
18
|
+
*/
|
|
19
|
+
type?: 'dot' | 'filled' | 'outline' | 'rounded';
|
|
20
|
+
/**
|
|
21
|
+
* 颜色
|
|
22
|
+
*/
|
|
23
|
+
color?: LabelColors | string;
|
|
24
|
+
/**
|
|
25
|
+
* 文字是否同色
|
|
26
|
+
*/
|
|
27
|
+
textColorSame?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* 图标
|
|
30
|
+
*/
|
|
31
|
+
icon?: ReactNode;
|
|
32
|
+
/**
|
|
33
|
+
* 图标位置
|
|
34
|
+
*/
|
|
35
|
+
iconPosition?: 'prefix' | 'suffix';
|
|
36
|
+
/**
|
|
37
|
+
* 省略配置
|
|
38
|
+
*/
|
|
39
|
+
ellipsisOptions?: {
|
|
40
|
+
Popover?: boolean;
|
|
41
|
+
emptyText?: string;
|
|
42
|
+
widthLimit?: number | string;
|
|
43
|
+
lines?: number;
|
|
44
|
+
[key: string]: unknown;
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
export declare const Label: {
|
|
48
|
+
({ className, children, type, color, icon, style, textColorSame, iconPosition, ellipsisOptions, ...props }: LabelProps): JSX.Element;
|
|
49
|
+
CheckableLabel: typeof import("antd/lib/tag/CheckableTag").default;
|
|
50
|
+
};
|
|
51
|
+
export default Label;
|
|
52
|
+
//# sourceMappingURL=label.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"label.d.ts","sourceRoot":"","sources":["../../src/label/label.tsx"],"names":[],"mappings":"AACA,OAAc,EAAE,SAAS,EAAW,MAAM,OAAO,CAAA;AAIjD,OAAO,KAAK,EAAE,QAAQ,IAAI,YAAY,EAAE,MAAM,aAAa,CAAA;AAK3D,OAAO,cAAc,CAAA;AAErB,oBAAY,WAAW;IACrB,IAAI,SAAS;IACb,KAAK,UAAU;IACf,IAAI,SAAS;IACb,IAAI,SAAS;IACb,QAAQ,aAAa;IACrB,MAAM,WAAW;IACjB,MAAM,WAAW;IACjB,GAAG,QAAQ;IACX,IAAI,SAAS;CACd;AAcD,MAAM,WAAW,UAAW,SAAQ,YAAY;IAC9C;;OAEG;IACH,IAAI,CAAC,EAAE,KAAK,GAAG,QAAQ,GAAG,SAAS,GAAG,SAAS,CAAA;IAC/C;;OAEG;IACH,KAAK,CAAC,EAAE,WAAW,GAAG,MAAM,CAAA;IAC5B;;OAEG;IACH,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB;;OAEG;IACH,IAAI,CAAC,EAAE,SAAS,CAAA;IAChB;;OAEG;IACH,YAAY,CAAC,EAAE,QAAQ,GAAG,QAAQ,CAAA;IAClC;;OAEG;IACH,eAAe,CAAC,EAAE;QAChB,OAAO,CAAC,EAAE,OAAO,CAAA;QACjB,SAAS,CAAC,EAAE,MAAM,CAAA;QAClB,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;QAC5B,KAAK,CAAC,EAAE,MAAM,CAAA;QACd,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;KACvB,CAAA;CACF;AA8CD,eAAO,MAAM,KAAK;gHAWf,UAAU;;CA0EZ,CAAA;AAID,eAAe,KAAK,CAAA"}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports["default"] = exports.LabelColors = exports.Label = void 0;
|
|
7
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
+
var _colorAlpha = _interopRequireDefault(require("color-alpha"));
|
|
10
|
+
var _configProvider = require("antd/lib/config-provider");
|
|
11
|
+
var _tag = _interopRequireDefault(require("antd/lib/tag"));
|
|
12
|
+
var _ellipsis = _interopRequireDefault(require("../ellipsis"));
|
|
13
|
+
require("./label.less");
|
|
14
|
+
var _colors;
|
|
15
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
16
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
17
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
18
|
+
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); }
|
|
19
|
+
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; }
|
|
20
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
21
|
+
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); }
|
|
22
|
+
var __rest = void 0 && (void 0).__rest || function (s, e) {
|
|
23
|
+
var t = {};
|
|
24
|
+
for (var p in s) {
|
|
25
|
+
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
|
26
|
+
}
|
|
27
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
28
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
|
|
29
|
+
}
|
|
30
|
+
return t;
|
|
31
|
+
};
|
|
32
|
+
var LabelColors;
|
|
33
|
+
exports.LabelColors = LabelColors;
|
|
34
|
+
(function (LabelColors) {
|
|
35
|
+
LabelColors["cyan"] = "cyan";
|
|
36
|
+
LabelColors["green"] = "green";
|
|
37
|
+
LabelColors["iris"] = "iris";
|
|
38
|
+
LabelColors["blue"] = "blue";
|
|
39
|
+
LabelColors["lavender"] = "lavender";
|
|
40
|
+
LabelColors["orange"] = "orange";
|
|
41
|
+
LabelColors["golden"] = "golden";
|
|
42
|
+
LabelColors["red"] = "red";
|
|
43
|
+
LabelColors["grey"] = "grey";
|
|
44
|
+
})(LabelColors || (exports.LabelColors = LabelColors = {}));
|
|
45
|
+
var colors = (_colors = {}, _defineProperty(_colors, LabelColors.cyan, '#1e9493'), _defineProperty(_colors, LabelColors.green, '#07c790'), _defineProperty(_colors, LabelColors.iris, '#5e47d3'), _defineProperty(_colors, LabelColors.blue, '#126bfb'), _defineProperty(_colors, LabelColors.lavender, '#945fb9'), _defineProperty(_colors, LabelColors.orange, '#ed7b20'), _defineProperty(_colors, LabelColors.golden, '#de8a02'), _defineProperty(_colors, LabelColors.red, '#d96156'), _defineProperty(_colors, LabelColors.grey, '#5e6e90'), _colors);
|
|
46
|
+
/**
|
|
47
|
+
* 计算标签样式
|
|
48
|
+
*
|
|
49
|
+
* @param type
|
|
50
|
+
* @param preset
|
|
51
|
+
* @param textColorSame
|
|
52
|
+
*/
|
|
53
|
+
var computeTagStyle = function computeTagStyle(type, color, textColorSame) {
|
|
54
|
+
if (!color) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
switch (type) {
|
|
58
|
+
case 'dot':
|
|
59
|
+
if (textColorSame) {
|
|
60
|
+
return {
|
|
61
|
+
color: color
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
return;
|
|
65
|
+
case 'filled':
|
|
66
|
+
return {
|
|
67
|
+
color: '#fff',
|
|
68
|
+
backgroundColor: color
|
|
69
|
+
};
|
|
70
|
+
case 'rounded':
|
|
71
|
+
return {
|
|
72
|
+
color: color,
|
|
73
|
+
backgroundColor: (0, _colorAlpha["default"])(color, 0.1)
|
|
74
|
+
};
|
|
75
|
+
case 'outline':
|
|
76
|
+
return {
|
|
77
|
+
color: color,
|
|
78
|
+
borderColor: (0, _colorAlpha["default"])(color, 0.4),
|
|
79
|
+
backgroundColor: (0, _colorAlpha["default"])(color, 0.1)
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
var Label = function Label(_a) {
|
|
84
|
+
var className = _a.className,
|
|
85
|
+
children = _a.children,
|
|
86
|
+
type = _a.type,
|
|
87
|
+
color = _a.color,
|
|
88
|
+
icon = _a.icon,
|
|
89
|
+
style = _a.style,
|
|
90
|
+
_a$textColorSame = _a.textColorSame,
|
|
91
|
+
textColorSame = _a$textColorSame === void 0 ? icon != null : _a$textColorSame,
|
|
92
|
+
_a$iconPosition = _a.iconPosition,
|
|
93
|
+
iconPosition = _a$iconPosition === void 0 ? 'prefix' : _a$iconPosition,
|
|
94
|
+
ellipsisOptions = _a.ellipsisOptions,
|
|
95
|
+
props = __rest(_a, ["className", "children", "type", "color", "icon", "style", "textColorSame", "iconPosition", "ellipsisOptions"]);
|
|
96
|
+
var normalizeType = (0, _react.useMemo)(function () {
|
|
97
|
+
if (icon) {
|
|
98
|
+
return 'dot';
|
|
99
|
+
}
|
|
100
|
+
return type;
|
|
101
|
+
}, [icon, type]);
|
|
102
|
+
var computedColor = (0, _react.useMemo)(function () {
|
|
103
|
+
return colors[color] || color;
|
|
104
|
+
}, [color]);
|
|
105
|
+
var tagStyle = (0, _react.useMemo)(function () {
|
|
106
|
+
return computeTagStyle(normalizeType, computedColor, textColorSame);
|
|
107
|
+
}, [normalizeType, computedColor, textColorSame]);
|
|
108
|
+
var hasIcon = (0, _react.useMemo)(function () {
|
|
109
|
+
return icon != null;
|
|
110
|
+
}, [icon]);
|
|
111
|
+
return _react["default"].createElement(_configProvider.ConfigConsumer, null, function (_ref) {
|
|
112
|
+
var _classNames;
|
|
113
|
+
var getPrefixCls = _ref.getPrefixCls;
|
|
114
|
+
var prefixCls = getPrefixCls('label');
|
|
115
|
+
var displayEllipsisOptions = function () {
|
|
116
|
+
var options = Object.assign({}, ellipsisOptions);
|
|
117
|
+
var iconElement = _react["default"].createElement("span", {
|
|
118
|
+
className: "".concat(prefixCls, "-icon"),
|
|
119
|
+
style: {
|
|
120
|
+
color: computedColor
|
|
121
|
+
}
|
|
122
|
+
}, icon);
|
|
123
|
+
if (iconPosition === 'prefix') {
|
|
124
|
+
options.prefix = iconElement;
|
|
125
|
+
}
|
|
126
|
+
if (iconPosition === 'suffix') {
|
|
127
|
+
options.suffix = iconElement;
|
|
128
|
+
}
|
|
129
|
+
if (options.Popover === true) {
|
|
130
|
+
options.content = children;
|
|
131
|
+
} else {
|
|
132
|
+
options.title = children;
|
|
133
|
+
}
|
|
134
|
+
return options;
|
|
135
|
+
}();
|
|
136
|
+
return _react["default"].createElement(_tag["default"], Object.assign({}, props, {
|
|
137
|
+
className: (0, _classnames["default"])(className, prefixCls, (_classNames = {}, _defineProperty(_classNames, "".concat(prefixCls, "-dot"), normalizeType === 'dot'), _defineProperty(_classNames, "".concat(prefixCls, "-outline"), normalizeType === 'outline'), _defineProperty(_classNames, "".concat(prefixCls, "-filled"), normalizeType === 'filled'), _defineProperty(_classNames, "".concat(prefixCls, "-rounded"), normalizeType === 'rounded'), _classNames)),
|
|
138
|
+
style: Object.assign(Object.assign({}, style), tagStyle)
|
|
139
|
+
}), normalizeType === 'dot' && icon == null && _react["default"].createElement("span", {
|
|
140
|
+
className: "".concat(prefixCls, "-dot-symbol"),
|
|
141
|
+
style: {
|
|
142
|
+
backgroundColor: computedColor
|
|
143
|
+
}
|
|
144
|
+
}), hasIcon ? _react["default"].createElement(_ellipsis["default"], Object.assign({}, displayEllipsisOptions), children) : children);
|
|
145
|
+
});
|
|
146
|
+
};
|
|
147
|
+
exports.Label = Label;
|
|
148
|
+
Label.CheckableLabel = _tag["default"].CheckableTag;
|
|
149
|
+
var _default = Label;
|
|
150
|
+
exports["default"] = _default;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"label.js","sourceRoot":"","sources":["../../src/label/label.tsx"],"names":[],"mappings":"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","sourcesContent":["import classNames from 'classnames'\nimport React, { ReactNode, useMemo } from 'react'\nimport alpha from 'color-alpha'\n\nimport { ConfigConsumer } from 'antd/lib/config-provider'\nimport type { TagProps as AntdTagProps } from 'antd/lib/tag'\nimport AntdTag from 'antd/lib/tag'\nimport type { CSSProperties } from 'react'\nimport Ellipsis from '../ellipsis'\n\nimport './label.less'\n\nexport enum LabelColors {\n cyan = 'cyan',\n green = 'green',\n iris = 'iris',\n blue = 'blue',\n lavender = 'lavender',\n orange = 'orange',\n golden = 'golden',\n red = 'red',\n grey = 'grey',\n}\n\nconst colors = {\n [LabelColors.cyan]: '#1e9493',\n [LabelColors.green]: '#07c790',\n [LabelColors.iris]: '#5e47d3',\n [LabelColors.blue]: '#126bfb',\n [LabelColors.lavender]: '#945fb9',\n [LabelColors.orange]: '#ed7b20',\n [LabelColors.golden]: '#de8a02',\n [LabelColors.red]: '#d96156',\n [LabelColors.grey]: '#5e6e90',\n}\n\nexport interface LabelProps extends AntdTagProps {\n /**\n * 类型\n */\n type?: 'dot' | 'filled' | 'outline' | 'rounded'\n /**\n * 颜色\n */\n color?: LabelColors | string\n /**\n * 文字是否同色\n */\n textColorSame?: boolean\n /**\n * 图标\n */\n icon?: ReactNode\n /**\n * 图标位置\n */\n iconPosition?: 'prefix' | 'suffix'\n /**\n * 省略配置\n */\n ellipsisOptions?: {\n Popover?: boolean\n emptyText?: string\n widthLimit?: number | string\n lines?: number\n [key: string]: unknown\n }\n}\n\n/**\n * 计算标签样式\n *\n * @param type\n * @param preset\n * @param textColorSame\n */\nconst computeTagStyle = (\n type: LabelProps['type'],\n color?: string,\n textColorSame?: boolean\n): CSSProperties | undefined => {\n if (!color) {\n return\n }\n\n switch (type) {\n case 'dot':\n if (textColorSame) {\n return {\n color,\n }\n }\n\n return\n case 'filled':\n return {\n color: '#fff',\n backgroundColor: color,\n }\n case 'rounded':\n return {\n color,\n backgroundColor: alpha(color, 0.1),\n }\n case 'outline':\n return {\n color,\n borderColor: alpha(color, 0.4),\n backgroundColor: alpha(color, 0.1),\n }\n }\n}\n\nexport const Label = ({\n className,\n children,\n type,\n color,\n icon,\n style,\n textColorSame = icon != null,\n iconPosition = 'prefix',\n ellipsisOptions,\n ...props\n}: LabelProps) => {\n const normalizeType = useMemo(() => {\n if (icon) {\n return 'dot'\n }\n\n return type\n }, [icon, type])\n const computedColor = useMemo(() => colors[color as LabelColors] || color, [color])\n const tagStyle = useMemo(\n () => computeTagStyle(normalizeType, computedColor, textColorSame),\n [normalizeType, computedColor, textColorSame]\n )\n const hasIcon = useMemo(() => icon != null, [icon])\n\n return (\n <ConfigConsumer>\n {({ getPrefixCls }) => {\n const prefixCls = getPrefixCls('label')\n const displayEllipsisOptions = (() => {\n const options = {\n ...ellipsisOptions,\n }\n const iconElement = (\n <span className={`${prefixCls}-icon`} style={{ color: computedColor }}>\n {icon}\n </span>\n )\n\n if (iconPosition === 'prefix') {\n options.prefix = iconElement\n }\n\n if (iconPosition === 'suffix') {\n options.suffix = iconElement\n }\n\n if (options.Popover === true) {\n options.content = children\n } else {\n options.title = children\n }\n\n return options\n })()\n\n return (\n <AntdTag\n {...props}\n className={classNames(className, prefixCls, {\n [`${prefixCls}-dot`]: normalizeType === 'dot',\n [`${prefixCls}-outline`]: normalizeType === 'outline',\n [`${prefixCls}-filled`]: normalizeType === 'filled',\n [`${prefixCls}-rounded`]: normalizeType === 'rounded',\n })}\n style={{\n ...style,\n ...tagStyle,\n }}\n >\n {normalizeType === 'dot' && icon == null && (\n <span\n className={`${prefixCls}-dot-symbol`}\n style={{\n backgroundColor: computedColor,\n }}\n />\n )}\n {hasIcon ? <Ellipsis {...displayEllipsisOptions}>{children}</Ellipsis> : children}\n </AntdTag>\n )\n }}\n </ConfigConsumer>\n )\n}\n\nLabel.CheckableLabel = AntdTag.CheckableTag\n\nexport default Label\n"]}
|
|
@@ -1,36 +1,38 @@
|
|
|
1
|
-
@
|
|
1
|
+
@label-prefix-cls: ~'@{ant-prefix}-label';
|
|
2
2
|
|
|
3
|
-
.@{
|
|
3
|
+
.@{label-prefix-cls} {
|
|
4
4
|
border: 1px solid transparent;
|
|
5
5
|
line-height: 22px;
|
|
6
6
|
min-width: 44px;
|
|
7
7
|
padding: 0 8px;
|
|
8
8
|
border-radius: 1px;
|
|
9
9
|
text-align: center;
|
|
10
|
+
font-size: @font-size-base;
|
|
11
|
+
background-color: rgba(94, 112, 146, 0.1);
|
|
10
12
|
|
|
11
|
-
&.@{
|
|
13
|
+
&.@{label-prefix-cls}-checkable {
|
|
12
14
|
cursor: pointer;
|
|
13
15
|
}
|
|
14
16
|
|
|
15
|
-
&.@{
|
|
17
|
+
&.@{label-prefix-cls}-rounded {
|
|
16
18
|
padding: 0 12px;
|
|
17
19
|
border-radius: 12px;
|
|
18
20
|
}
|
|
19
21
|
|
|
20
|
-
&.@{
|
|
22
|
+
&.@{label-prefix-cls}-dot {
|
|
21
23
|
display: inline-flex;
|
|
22
24
|
align-items: center;
|
|
23
25
|
background-color: transparent;
|
|
24
26
|
padding: 0;
|
|
25
27
|
}
|
|
26
28
|
|
|
27
|
-
.@{
|
|
29
|
+
.@{label-prefix-cls}-icon {
|
|
28
30
|
display: inline-flex;
|
|
29
31
|
align-items: center;
|
|
30
32
|
margin-right: 4px;
|
|
31
33
|
}
|
|
32
34
|
|
|
33
|
-
.@{
|
|
35
|
+
.@{label-prefix-cls}-dot-symbol {
|
|
34
36
|
content: '';
|
|
35
37
|
display: inline-block;
|
|
36
38
|
width: 6px;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"label.test.d.ts","sourceRoot":"","sources":["../../src/label/label.test.tsx"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _react = _interopRequireDefault(require("react"));
|
|
4
|
+
var _react2 = require("@testing-library/react");
|
|
5
|
+
var _label = require("./label");
|
|
6
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
7
|
+
describe('Label component', function () {
|
|
8
|
+
it('renders the component', function () {
|
|
9
|
+
var _render = (0, _react2.render)(_react["default"].createElement(_label.Label, null)),
|
|
10
|
+
getByText = _render.getByText;
|
|
11
|
+
var component = getByText('Component');
|
|
12
|
+
expect(component).toBeDefined();
|
|
13
|
+
});
|
|
14
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"label.test.js","sourceRoot":"","sources":["../../src/label/label.test.tsx"],"names":[],"mappings":";;;;;AAAA,kDAAyB;AACzB,kDAA+C;AAE/C,mCAA+B;AAE/B,QAAQ,CAAC,iBAAiB,EAAE,GAAG,EAAE;IAC/B,EAAE,CAAC,uBAAuB,EAAE,GAAG,EAAE;QAC/B,MAAM,EAAE,SAAS,EAAE,GAAG,IAAA,cAAM,EAAC,8BAAC,aAAK,OAAG,CAAC,CAAA;QACvC,MAAM,SAAS,GAAG,SAAS,CAAC,WAAW,CAAC,CAAA;QAExC,MAAM,CAAC,SAAS,CAAC,CAAC,WAAW,EAAE,CAAA;IACjC,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA","sourcesContent":["import React from 'react'\nimport { render } from '@testing-library/react'\n\nimport { Label } from './label'\n\ndescribe('Label component', () => {\n it('renders the component', () => {\n const { getByText } = render(<Label />)\n const component = getByText('Component')\n\n expect(component).toBeDefined()\n })\n})\n"]}
|
package/lib/tag/index.d.ts
CHANGED
|
@@ -1,54 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import type { TagProps as AntdTagProps } from 'antd/lib/tag';
|
|
1
|
+
import Tag from 'antd/lib/tag';
|
|
3
2
|
import 'antd/lib/tag/style';
|
|
4
|
-
import './tag.less';
|
|
5
3
|
export * from 'antd/lib/tag';
|
|
6
|
-
export declare enum TagPalettes {
|
|
7
|
-
cyan = "cyan",
|
|
8
|
-
green = "green",
|
|
9
|
-
iris = "iris",
|
|
10
|
-
blue = "blue",
|
|
11
|
-
lavender = "lavender",
|
|
12
|
-
orange = "orange",
|
|
13
|
-
golden = "golden",
|
|
14
|
-
red = "red",
|
|
15
|
-
grey = "grey"
|
|
16
|
-
}
|
|
17
|
-
export interface TagProps extends AntdTagProps {
|
|
18
|
-
/**
|
|
19
|
-
* 类型
|
|
20
|
-
*/
|
|
21
|
-
type?: 'dot' | 'filled' | 'outline' | 'rounded';
|
|
22
|
-
/**
|
|
23
|
-
* 颜色
|
|
24
|
-
*/
|
|
25
|
-
palette?: TagPalettes | string;
|
|
26
|
-
/**
|
|
27
|
-
* 文字是否同色
|
|
28
|
-
*/
|
|
29
|
-
textColorSame?: boolean;
|
|
30
|
-
/**
|
|
31
|
-
* 图标
|
|
32
|
-
*/
|
|
33
|
-
icon?: ReactNode;
|
|
34
|
-
/**
|
|
35
|
-
* 图标位置
|
|
36
|
-
*/
|
|
37
|
-
iconPosition?: 'prefix' | 'suffix';
|
|
38
|
-
/**
|
|
39
|
-
* 省略配置
|
|
40
|
-
*/
|
|
41
|
-
ellipsisOptions?: {
|
|
42
|
-
Popover?: boolean;
|
|
43
|
-
emptyText?: string;
|
|
44
|
-
widthLimit?: number | string;
|
|
45
|
-
lines?: number;
|
|
46
|
-
[key: string]: unknown;
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
export declare const Tag: {
|
|
50
|
-
({ className, children, type, palette, icon, style, textColorSame, iconPosition, ellipsisOptions, ...props }: TagProps): JSX.Element;
|
|
51
|
-
CheckableTag: typeof import("antd/lib/tag/CheckableTag").default;
|
|
52
|
-
};
|
|
53
4
|
export default Tag;
|
|
54
5
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/tag/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tag/index.
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tag/index.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,aAAa,CAAA;AAE7B,OAAO,mBAAmB,CAAA;AAE1B,cAAc,aAAa,CAAA;AAE3B,eAAe,GAAG,CAAA"}
|
package/lib/tag/index.js
CHANGED
|
@@ -1,17 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
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); }
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
6
|
-
var _exportNames = {
|
|
7
|
-
|
|
8
|
-
Tag: true
|
|
9
|
-
};
|
|
10
|
-
exports["default"] = exports.TagPalettes = exports.Tag = void 0;
|
|
11
|
-
var _classnames = _interopRequireDefault(require("classnames"));
|
|
12
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
13
|
-
var _colorAlpha = _interopRequireDefault(require("color-alpha"));
|
|
14
|
-
var _configProvider = require("antd/lib/config-provider");
|
|
7
|
+
var _exportNames = {};
|
|
8
|
+
exports["default"] = void 0;
|
|
15
9
|
var _tag = _interopRequireWildcard(require("antd/lib/tag"));
|
|
16
10
|
Object.keys(_tag).forEach(function (key) {
|
|
17
11
|
if (key === "default" || key === "__esModule") return;
|
|
@@ -25,142 +19,7 @@ Object.keys(_tag).forEach(function (key) {
|
|
|
25
19
|
});
|
|
26
20
|
});
|
|
27
21
|
require("antd/lib/tag/style");
|
|
28
|
-
require("./tag.less");
|
|
29
|
-
var _ellipsis = _interopRequireDefault(require("../ellipsis"));
|
|
30
|
-
var _palettes;
|
|
31
22
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
32
23
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
33
|
-
|
|
34
|
-
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); }
|
|
35
|
-
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; }
|
|
36
|
-
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
37
|
-
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); }
|
|
38
|
-
var __rest = void 0 && (void 0).__rest || function (s, e) {
|
|
39
|
-
var t = {};
|
|
40
|
-
for (var p in s) {
|
|
41
|
-
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
|
42
|
-
}
|
|
43
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
44
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
|
|
45
|
-
}
|
|
46
|
-
return t;
|
|
47
|
-
};
|
|
48
|
-
var TagPalettes;
|
|
49
|
-
exports.TagPalettes = TagPalettes;
|
|
50
|
-
(function (TagPalettes) {
|
|
51
|
-
TagPalettes["cyan"] = "cyan";
|
|
52
|
-
TagPalettes["green"] = "green";
|
|
53
|
-
TagPalettes["iris"] = "iris";
|
|
54
|
-
TagPalettes["blue"] = "blue";
|
|
55
|
-
TagPalettes["lavender"] = "lavender";
|
|
56
|
-
TagPalettes["orange"] = "orange";
|
|
57
|
-
TagPalettes["golden"] = "golden";
|
|
58
|
-
TagPalettes["red"] = "red";
|
|
59
|
-
TagPalettes["grey"] = "grey";
|
|
60
|
-
})(TagPalettes || (exports.TagPalettes = TagPalettes = {}));
|
|
61
|
-
var palettes = (_palettes = {}, _defineProperty(_palettes, TagPalettes.cyan, '#1e9493'), _defineProperty(_palettes, TagPalettes.green, '#07c790'), _defineProperty(_palettes, TagPalettes.iris, '#5e47d3'), _defineProperty(_palettes, TagPalettes.blue, '#126bfb'), _defineProperty(_palettes, TagPalettes.lavender, '#945fb9'), _defineProperty(_palettes, TagPalettes.orange, '#ed7b20'), _defineProperty(_palettes, TagPalettes.golden, '#de8a02'), _defineProperty(_palettes, TagPalettes.red, '#d96156'), _defineProperty(_palettes, TagPalettes.grey, '#5e6e90'), _palettes);
|
|
62
|
-
/**
|
|
63
|
-
* 计算标签样式
|
|
64
|
-
*
|
|
65
|
-
* @param type
|
|
66
|
-
* @param preset
|
|
67
|
-
* @param textColorSame
|
|
68
|
-
*/
|
|
69
|
-
var computeTagStyle = function computeTagStyle(type, color, textColorSame) {
|
|
70
|
-
if (!color) {
|
|
71
|
-
return;
|
|
72
|
-
}
|
|
73
|
-
switch (type) {
|
|
74
|
-
case 'dot':
|
|
75
|
-
if (textColorSame) {
|
|
76
|
-
return {
|
|
77
|
-
color: color
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
return;
|
|
81
|
-
case 'filled':
|
|
82
|
-
return {
|
|
83
|
-
color: '#fff',
|
|
84
|
-
backgroundColor: color
|
|
85
|
-
};
|
|
86
|
-
case 'rounded':
|
|
87
|
-
return {
|
|
88
|
-
color: color,
|
|
89
|
-
backgroundColor: (0, _colorAlpha["default"])(color, 0.1)
|
|
90
|
-
};
|
|
91
|
-
case 'outline':
|
|
92
|
-
return {
|
|
93
|
-
color: color,
|
|
94
|
-
borderColor: (0, _colorAlpha["default"])(color, 0.4),
|
|
95
|
-
backgroundColor: (0, _colorAlpha["default"])(color, 0.1)
|
|
96
|
-
};
|
|
97
|
-
}
|
|
98
|
-
};
|
|
99
|
-
var Tag = function Tag(_a) {
|
|
100
|
-
var className = _a.className,
|
|
101
|
-
children = _a.children,
|
|
102
|
-
type = _a.type,
|
|
103
|
-
palette = _a.palette,
|
|
104
|
-
icon = _a.icon,
|
|
105
|
-
style = _a.style,
|
|
106
|
-
_a$textColorSame = _a.textColorSame,
|
|
107
|
-
textColorSame = _a$textColorSame === void 0 ? icon != null : _a$textColorSame,
|
|
108
|
-
_a$iconPosition = _a.iconPosition,
|
|
109
|
-
iconPosition = _a$iconPosition === void 0 ? 'prefix' : _a$iconPosition,
|
|
110
|
-
ellipsisOptions = _a.ellipsisOptions,
|
|
111
|
-
props = __rest(_a, ["className", "children", "type", "palette", "icon", "style", "textColorSame", "iconPosition", "ellipsisOptions"]);
|
|
112
|
-
var normalizeType = (0, _react.useMemo)(function () {
|
|
113
|
-
if (icon) {
|
|
114
|
-
return 'dot';
|
|
115
|
-
}
|
|
116
|
-
return type;
|
|
117
|
-
}, [icon, type]);
|
|
118
|
-
var color = (0, _react.useMemo)(function () {
|
|
119
|
-
return palettes[palette] || palette;
|
|
120
|
-
}, [palette]);
|
|
121
|
-
var tagStyle = (0, _react.useMemo)(function () {
|
|
122
|
-
return computeTagStyle(normalizeType, color, textColorSame);
|
|
123
|
-
}, [color, textColorSame, normalizeType]);
|
|
124
|
-
var hasIcon = (0, _react.useMemo)(function () {
|
|
125
|
-
return icon != null;
|
|
126
|
-
}, [icon]);
|
|
127
|
-
return _react["default"].createElement(_configProvider.ConfigConsumer, null, function (_ref) {
|
|
128
|
-
var _classNames;
|
|
129
|
-
var getPrefixCls = _ref.getPrefixCls;
|
|
130
|
-
var prefixCls = getPrefixCls('tag');
|
|
131
|
-
var displayEllipsisOptions = function () {
|
|
132
|
-
var options = Object.assign({}, ellipsisOptions);
|
|
133
|
-
var iconElement = _react["default"].createElement("span", {
|
|
134
|
-
className: "".concat(prefixCls, "-icon"),
|
|
135
|
-
style: {
|
|
136
|
-
color: color
|
|
137
|
-
}
|
|
138
|
-
}, icon);
|
|
139
|
-
if (iconPosition === 'prefix') {
|
|
140
|
-
options.prefix = iconElement;
|
|
141
|
-
}
|
|
142
|
-
if (iconPosition === 'suffix') {
|
|
143
|
-
options.suffix = iconElement;
|
|
144
|
-
}
|
|
145
|
-
if (options.Popover === true) {
|
|
146
|
-
options.content = children;
|
|
147
|
-
} else {
|
|
148
|
-
options.title = children;
|
|
149
|
-
}
|
|
150
|
-
return options;
|
|
151
|
-
}();
|
|
152
|
-
return _react["default"].createElement(_tag["default"], Object.assign({}, props, {
|
|
153
|
-
className: (0, _classnames["default"])(className, (_classNames = {}, _defineProperty(_classNames, "".concat(prefixCls, "-dot"), normalizeType === 'dot'), _defineProperty(_classNames, "".concat(prefixCls, "-outline"), normalizeType === 'outline'), _defineProperty(_classNames, "".concat(prefixCls, "-filled"), normalizeType === 'filled'), _defineProperty(_classNames, "".concat(prefixCls, "-rounded"), normalizeType === 'rounded'), _classNames)),
|
|
154
|
-
style: Object.assign(Object.assign({}, style), tagStyle)
|
|
155
|
-
}), normalizeType === 'dot' && icon == null && _react["default"].createElement("span", {
|
|
156
|
-
className: "".concat(prefixCls, "-dot-symbol"),
|
|
157
|
-
style: {
|
|
158
|
-
backgroundColor: color
|
|
159
|
-
}
|
|
160
|
-
}), hasIcon ? _react["default"].createElement(_ellipsis["default"], Object.assign({}, displayEllipsisOptions), children) : children);
|
|
161
|
-
});
|
|
162
|
-
};
|
|
163
|
-
exports.Tag = Tag;
|
|
164
|
-
Tag.CheckableTag = _tag["default"].CheckableTag;
|
|
165
|
-
var _default = Tag;
|
|
24
|
+
var _default = _tag["default"];
|
|
166
25
|
exports["default"] = _default;
|
package/lib/tag/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/tag/index.
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/tag/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AAAA,sDAA6B;AAE7B,6BAA0B;AAE1B,8CAA2B;AAE3B,kBAAe,aAAG,CAAA","sourcesContent":["import Tag from 'antd/lib/tag'\n\nimport 'antd/lib/tag/style'\n\nexport * from 'antd/lib/tag'\n\nexport default Tag\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tntd",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.2.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@icon-park/react": "^1.3.5",
|
|
@@ -65,7 +65,6 @@
|
|
|
65
65
|
"files": [
|
|
66
66
|
"lib",
|
|
67
67
|
"es",
|
|
68
|
-
"codemod",
|
|
69
68
|
"themes"
|
|
70
69
|
],
|
|
71
70
|
"main": "lib/index.js",
|
|
@@ -82,7 +81,7 @@
|
|
|
82
81
|
"_phase:build": "heft build --clean",
|
|
83
82
|
"_phase:test": "heft test --no-build",
|
|
84
83
|
"svgr": "npx svgr ./svg --out-dir ./src/svg-components",
|
|
85
|
-
"test": "
|
|
86
|
-
"test:watch": "
|
|
84
|
+
"test": "heft test",
|
|
85
|
+
"test:watch": "heft test --watch --clean"
|
|
87
86
|
}
|
|
88
87
|
}
|
|
@@ -405,9 +405,9 @@
|
|
|
405
405
|
|
|
406
406
|
// Tag
|
|
407
407
|
// --
|
|
408
|
-
@tag-default-bg:
|
|
408
|
+
@tag-default-bg: @background-color-light;
|
|
409
409
|
@tag-default-color: @text-color;
|
|
410
|
-
@tag-font-size: @font-size-
|
|
410
|
+
@tag-font-size: @font-size-sm;
|
|
411
411
|
|
|
412
412
|
// TimePicker
|
|
413
413
|
// ---
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { Affix } from "antd";
|
|
2
|
-
import { Layout } from "tntd";
|
|
3
|
-
|
|
4
|
-
export default class App {
|
|
5
|
-
render() {
|
|
6
|
-
const { HeaderNavs, HeaderActionItem } = Layout;
|
|
7
|
-
|
|
8
|
-
return (
|
|
9
|
-
<Layout>
|
|
10
|
-
<Affix />
|
|
11
|
-
</Layout>
|
|
12
|
-
);
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export class App2 {
|
|
17
|
-
render() {
|
|
18
|
-
const Layout = Affix;
|
|
19
|
-
|
|
20
|
-
return (
|
|
21
|
-
<Layout />
|
|
22
|
-
);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { Affix, TntdLayout } from "tntd";
|
|
2
|
-
|
|
3
|
-
export default class App {
|
|
4
|
-
render() {
|
|
5
|
-
const { HeaderNavs, HeaderActionItem } = TntdLayout;
|
|
6
|
-
|
|
7
|
-
return (
|
|
8
|
-
<TntdLayout>
|
|
9
|
-
<Affix />
|
|
10
|
-
</TntdLayout>
|
|
11
|
-
);
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export class App2 {
|
|
16
|
-
render() {
|
|
17
|
-
const Layout = Affix;
|
|
18
|
-
|
|
19
|
-
return (
|
|
20
|
-
<Layout />
|
|
21
|
-
);
|
|
22
|
-
}
|
|
23
|
-
}
|