@akinon/ui-tag 0.3.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/cjs/index.d.ts +12 -0
- package/dist/cjs/index.d.ts.map +1 -0
- package/dist/cjs/index.js +101 -0
- package/dist/esm/index.d.ts +12 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +97 -0
- package/package.json +45 -0
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { TagProps } from './types';
|
|
3
|
+
export type { TagProps } from './types';
|
|
4
|
+
export declare enum TagStatus {
|
|
5
|
+
Success = "success",
|
|
6
|
+
Info1 = "info-1",
|
|
7
|
+
Info2 = "info-2",
|
|
8
|
+
Info3 = "info-3",
|
|
9
|
+
Error = "error"
|
|
10
|
+
}
|
|
11
|
+
export declare const Tag: ({ children, status, className, ...restTagProps }: TagProps) => React.JSX.Element;
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAExC,YAAY,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAExC,oBAAY,SAAS;IACnB,OAAO,YAAY;IACnB,KAAK,WAAW;IAChB,KAAK,WAAW;IAChB,KAAK,WAAW;IAChB,KAAK,UAAU;CAChB;AAED,eAAO,MAAM,GAAG,qDAKb,QAAQ,sBAwFV,CAAC"}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.Tag = exports.TagStatus = void 0;
|
|
15
|
+
const ui_theme_1 = require("@akinon/ui-theme");
|
|
16
|
+
const cssinjs_1 = require("@ant-design/cssinjs");
|
|
17
|
+
const antd_1 = require("antd");
|
|
18
|
+
const clsx_1 = require("clsx");
|
|
19
|
+
const React = require("react");
|
|
20
|
+
var TagStatus;
|
|
21
|
+
(function (TagStatus) {
|
|
22
|
+
TagStatus["Success"] = "success";
|
|
23
|
+
TagStatus["Info1"] = "info-1";
|
|
24
|
+
TagStatus["Info2"] = "info-2";
|
|
25
|
+
TagStatus["Info3"] = "info-3";
|
|
26
|
+
TagStatus["Error"] = "error";
|
|
27
|
+
})(TagStatus || (exports.TagStatus = TagStatus = {}));
|
|
28
|
+
const Tag = (_a) => {
|
|
29
|
+
var { children, status, className } = _a, restTagProps = __rest(_a, ["children", "status", "className"]);
|
|
30
|
+
const { getPrefixCls, theme } = React.useContext(antd_1.ConfigProvider.ConfigContext);
|
|
31
|
+
const { token, hashId } = (0, ui_theme_1.useToken)();
|
|
32
|
+
const tagToken = token.Tag;
|
|
33
|
+
const useStyle = (0, cssinjs_1.useStyleRegister)({
|
|
34
|
+
token: token,
|
|
35
|
+
path: ['Tag'],
|
|
36
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
37
|
+
theme: theme
|
|
38
|
+
}, () => {
|
|
39
|
+
const prefixCls = `:where(.${hashId}).${getPrefixCls()}-tag`;
|
|
40
|
+
const prefixClsWithoutHash = `.${getPrefixCls()}-tag`;
|
|
41
|
+
return {
|
|
42
|
+
[prefixCls]: {
|
|
43
|
+
borderRadius: tagToken.borderRadius,
|
|
44
|
+
fontSize: tagToken.fontSize,
|
|
45
|
+
fontWeight: tagToken.fontWeight,
|
|
46
|
+
paddingLeft: tagToken.paddingLeft,
|
|
47
|
+
paddingRight: tagToken.paddingRight
|
|
48
|
+
},
|
|
49
|
+
[prefixClsWithoutHash]: {
|
|
50
|
+
svg: {
|
|
51
|
+
fontSize: tagToken.fontSizeClose
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
[`${prefixClsWithoutHash}-borderless`]: {
|
|
55
|
+
border: 'none'
|
|
56
|
+
},
|
|
57
|
+
[`${prefixClsWithoutHash}-${TagStatus.Success}`]: {
|
|
58
|
+
color: tagToken.defaultColorSuccess,
|
|
59
|
+
borderColor: tagToken.defaultBorderColorSuccess,
|
|
60
|
+
backgroundColor: tagToken.defaultBgSuccess,
|
|
61
|
+
svg: {
|
|
62
|
+
color: tagToken.defaultColorSuccess
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
[`${prefixClsWithoutHash}-${TagStatus.Info1}`]: {
|
|
66
|
+
color: tagToken.defaultColorWaiting1,
|
|
67
|
+
borderColor: tagToken.defaultBorderColorWaiting1,
|
|
68
|
+
backgroundColor: tagToken.defaultBgWaiting1,
|
|
69
|
+
svg: {
|
|
70
|
+
color: tagToken.defaultColorWaiting1
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
[`${prefixClsWithoutHash}-${TagStatus.Info2}`]: {
|
|
74
|
+
color: tagToken.defaultColorWaiting2,
|
|
75
|
+
borderColor: tagToken.defaultBorderColorWaiting2,
|
|
76
|
+
backgroundColor: tagToken.defaultBgWaiting2,
|
|
77
|
+
svg: {
|
|
78
|
+
color: tagToken.defaultColorWaiting2
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
[`${prefixClsWithoutHash}-${TagStatus.Info3}`]: {
|
|
82
|
+
color: tagToken.defaultColorWaiting3,
|
|
83
|
+
borderColor: tagToken.defaultBorderColorWaiting3,
|
|
84
|
+
backgroundColor: tagToken.defaultBgWaiting3,
|
|
85
|
+
svg: {
|
|
86
|
+
color: tagToken.defaultColorWaiting3
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
[`${prefixClsWithoutHash}-${TagStatus.Error}`]: {
|
|
90
|
+
color: tagToken.defaultColorFailed,
|
|
91
|
+
borderColor: tagToken.defaultBorderColorFailed,
|
|
92
|
+
backgroundColor: tagToken.defaultBgFailed,
|
|
93
|
+
svg: {
|
|
94
|
+
color: tagToken.defaultColorFailed
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
});
|
|
99
|
+
return useStyle(React.createElement(antd_1.Tag, Object.assign({ className: (0, clsx_1.default)(status && `akinon-tag-${status}`, className) }, restTagProps), children));
|
|
100
|
+
};
|
|
101
|
+
exports.Tag = Tag;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { TagProps } from './types';
|
|
3
|
+
export type { TagProps } from './types';
|
|
4
|
+
export declare enum TagStatus {
|
|
5
|
+
Success = "success",
|
|
6
|
+
Info1 = "info-1",
|
|
7
|
+
Info2 = "info-2",
|
|
8
|
+
Info3 = "info-3",
|
|
9
|
+
Error = "error"
|
|
10
|
+
}
|
|
11
|
+
export declare const Tag: ({ children, status, className, ...restTagProps }: TagProps) => React.JSX.Element;
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAExC,YAAY,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAExC,oBAAY,SAAS;IACnB,OAAO,YAAY;IACnB,KAAK,WAAW;IAChB,KAAK,WAAW;IAChB,KAAK,WAAW;IAChB,KAAK,UAAU;CAChB;AAED,eAAO,MAAM,GAAG,qDAKb,QAAQ,sBAwFV,CAAC"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
import { useToken } from '@akinon/ui-theme';
|
|
13
|
+
import { useStyleRegister } from '@ant-design/cssinjs';
|
|
14
|
+
import { ConfigProvider, Tag as AntTag } from 'antd';
|
|
15
|
+
import clsx from 'clsx';
|
|
16
|
+
import * as React from 'react';
|
|
17
|
+
export var TagStatus;
|
|
18
|
+
(function (TagStatus) {
|
|
19
|
+
TagStatus["Success"] = "success";
|
|
20
|
+
TagStatus["Info1"] = "info-1";
|
|
21
|
+
TagStatus["Info2"] = "info-2";
|
|
22
|
+
TagStatus["Info3"] = "info-3";
|
|
23
|
+
TagStatus["Error"] = "error";
|
|
24
|
+
})(TagStatus || (TagStatus = {}));
|
|
25
|
+
export const Tag = (_a) => {
|
|
26
|
+
var { children, status, className } = _a, restTagProps = __rest(_a, ["children", "status", "className"]);
|
|
27
|
+
const { getPrefixCls, theme } = React.useContext(ConfigProvider.ConfigContext);
|
|
28
|
+
const { token, hashId } = useToken();
|
|
29
|
+
const tagToken = token.Tag;
|
|
30
|
+
const useStyle = useStyleRegister({
|
|
31
|
+
token: token,
|
|
32
|
+
path: ['Tag'],
|
|
33
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
34
|
+
theme: theme
|
|
35
|
+
}, () => {
|
|
36
|
+
const prefixCls = `:where(.${hashId}).${getPrefixCls()}-tag`;
|
|
37
|
+
const prefixClsWithoutHash = `.${getPrefixCls()}-tag`;
|
|
38
|
+
return {
|
|
39
|
+
[prefixCls]: {
|
|
40
|
+
borderRadius: tagToken.borderRadius,
|
|
41
|
+
fontSize: tagToken.fontSize,
|
|
42
|
+
fontWeight: tagToken.fontWeight,
|
|
43
|
+
paddingLeft: tagToken.paddingLeft,
|
|
44
|
+
paddingRight: tagToken.paddingRight
|
|
45
|
+
},
|
|
46
|
+
[prefixClsWithoutHash]: {
|
|
47
|
+
svg: {
|
|
48
|
+
fontSize: tagToken.fontSizeClose
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
[`${prefixClsWithoutHash}-borderless`]: {
|
|
52
|
+
border: 'none'
|
|
53
|
+
},
|
|
54
|
+
[`${prefixClsWithoutHash}-${TagStatus.Success}`]: {
|
|
55
|
+
color: tagToken.defaultColorSuccess,
|
|
56
|
+
borderColor: tagToken.defaultBorderColorSuccess,
|
|
57
|
+
backgroundColor: tagToken.defaultBgSuccess,
|
|
58
|
+
svg: {
|
|
59
|
+
color: tagToken.defaultColorSuccess
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
[`${prefixClsWithoutHash}-${TagStatus.Info1}`]: {
|
|
63
|
+
color: tagToken.defaultColorWaiting1,
|
|
64
|
+
borderColor: tagToken.defaultBorderColorWaiting1,
|
|
65
|
+
backgroundColor: tagToken.defaultBgWaiting1,
|
|
66
|
+
svg: {
|
|
67
|
+
color: tagToken.defaultColorWaiting1
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
[`${prefixClsWithoutHash}-${TagStatus.Info2}`]: {
|
|
71
|
+
color: tagToken.defaultColorWaiting2,
|
|
72
|
+
borderColor: tagToken.defaultBorderColorWaiting2,
|
|
73
|
+
backgroundColor: tagToken.defaultBgWaiting2,
|
|
74
|
+
svg: {
|
|
75
|
+
color: tagToken.defaultColorWaiting2
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
[`${prefixClsWithoutHash}-${TagStatus.Info3}`]: {
|
|
79
|
+
color: tagToken.defaultColorWaiting3,
|
|
80
|
+
borderColor: tagToken.defaultBorderColorWaiting3,
|
|
81
|
+
backgroundColor: tagToken.defaultBgWaiting3,
|
|
82
|
+
svg: {
|
|
83
|
+
color: tagToken.defaultColorWaiting3
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
[`${prefixClsWithoutHash}-${TagStatus.Error}`]: {
|
|
87
|
+
color: tagToken.defaultColorFailed,
|
|
88
|
+
borderColor: tagToken.defaultBorderColorFailed,
|
|
89
|
+
backgroundColor: tagToken.defaultBgFailed,
|
|
90
|
+
svg: {
|
|
91
|
+
color: tagToken.defaultColorFailed
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
});
|
|
96
|
+
return useStyle(React.createElement(AntTag, Object.assign({ className: clsx(status && `akinon-tag-${status}`, className) }, restTagProps), children));
|
|
97
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@akinon/ui-tag",
|
|
3
|
+
"version": "0.3.0",
|
|
4
|
+
"private": false,
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/esm/index.js",
|
|
7
|
+
"module": "dist/esm/index.js",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist"
|
|
10
|
+
],
|
|
11
|
+
"dependencies": {
|
|
12
|
+
"antd": "5.17.0",
|
|
13
|
+
"clsx": "^2.0.0"
|
|
14
|
+
},
|
|
15
|
+
"devDependencies": {
|
|
16
|
+
"clean-package": "2.2.0",
|
|
17
|
+
"copyfiles": "^2.4.1",
|
|
18
|
+
"rimraf": "^5.0.5",
|
|
19
|
+
"typescript": "^5.2.2",
|
|
20
|
+
"@akinon/typescript-config": "0.2.0",
|
|
21
|
+
"@akinon/ui-theme": "0.5.0"
|
|
22
|
+
},
|
|
23
|
+
"peerDependencies": {
|
|
24
|
+
"react": ">=18",
|
|
25
|
+
"react-dom": ">=18"
|
|
26
|
+
},
|
|
27
|
+
"clean-package": "../../../clean-package.config.json",
|
|
28
|
+
"types": "dist/esm/index.d.ts",
|
|
29
|
+
"exports": {
|
|
30
|
+
".": {
|
|
31
|
+
"types": "./dist/esm/index.d.ts",
|
|
32
|
+
"import": "./dist/esm/index.js",
|
|
33
|
+
"require": "./dist/cjs/index.js"
|
|
34
|
+
},
|
|
35
|
+
"./package.json": "./package.json"
|
|
36
|
+
},
|
|
37
|
+
"scripts": {
|
|
38
|
+
"build": "pnpm run build:esm && pnpm run build:commonjs && pnpm run copy:files",
|
|
39
|
+
"build:esm": "tsc --outDir dist/esm",
|
|
40
|
+
"build:commonjs": "tsc --module commonjs --outDir dist/cjs",
|
|
41
|
+
"copy:files": "copyfiles -u 1 src/**/*.css dist/esm && copyfiles -u 1 src/**/*.css dist/cjs",
|
|
42
|
+
"clean": "rimraf dist/",
|
|
43
|
+
"typecheck": "tsc --noEmit"
|
|
44
|
+
}
|
|
45
|
+
}
|