xcn 0.1.2-alpha.0 → 0.1.3
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/README.md +1 -1
- package/index.d.ts +5 -6
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# xcn
|
|
2
2
|
|
|
3
|
-
[&label=版本号&labelColor=rgb(73,73,228)&color=rgb(0,0,0)>)](https://www.npmjs.com/package/xcn) [&label=版本号&labelColor=rgb(73,73,228)&color=rgb(0,0,0)>)](https://www.npmjs.com/package/xcn) [?logo=github>)](https://github.com/earthnutDev/xcn/issues)
|
|
4
4
|
|
|
5
5
|
xcn = mix + class name
|
|
6
6
|
|
package/index.d.ts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* 参数的数据类型
|
|
3
3
|
*/
|
|
4
|
-
type
|
|
4
|
+
export type EnClassNameItem = null | number | string | boolean | undefined | (() => string) | (() => EnClassNameItem[]) | EnClassNameItem[] | Record<string, boolean | undefined>;
|
|
5
5
|
/**
|
|
6
6
|
* 使用 infer 判断出当前的数据类型
|
|
7
7
|
*
|
|
8
8
|
* 字符串为具体的字符串值而非 string
|
|
9
9
|
*/
|
|
10
|
-
type
|
|
10
|
+
export type EnTypeofClassNameItem<T> = T extends null | boolean | undefined ? '' : T extends readonly [unknown, infer U] ? EnTypeofClassNameItem<U> | '' : T extends readonly [unknown, infer U, infer V] ? EnTypeofClassNameItem<U> | EnTypeofClassNameItem<V> : T extends Record<string, boolean | undefined> ? keyof T | '' : T extends () => string ? string : T;
|
|
11
11
|
/**
|
|
12
12
|
* 递归判断当前返回的数据类型
|
|
13
13
|
*/
|
|
14
|
-
type
|
|
14
|
+
export type EnXcn<T> = T extends [infer U, ...infer V] ? `${U & string} ${EnXcn<V>}` : '';
|
|
15
15
|
/**
|
|
16
16
|
*
|
|
17
17
|
* 合并 class
|
|
@@ -19,7 +19,6 @@ type XCN<T> = T extends [infer U, ...infer V] ? `${U & string} ${XCN<V>}` : '';
|
|
|
19
19
|
* merge class name
|
|
20
20
|
*
|
|
21
21
|
*/
|
|
22
|
-
export declare function xcn<T extends
|
|
23
|
-
[K in keyof T]:
|
|
22
|
+
export declare function xcn<T extends EnClassNameItem[]>(...classNameList: T): EnXcn<{
|
|
23
|
+
[K in keyof T]: EnTypeofClassNameItem<T[K]>;
|
|
24
24
|
}>;
|
|
25
|
-
export {};
|
package/package.json
CHANGED
|
@@ -4,11 +4,11 @@
|
|
|
4
4
|
"types": "index.d.ts",
|
|
5
5
|
"name": "xcn",
|
|
6
6
|
"type": "module",
|
|
7
|
-
"version": "0.1.
|
|
7
|
+
"version": "0.1.3",
|
|
8
8
|
"description": "一个用于字符串拼接的小工具,常用于 class name 的拼接",
|
|
9
9
|
"license": "ISC",
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"a-type-of-js": "^1.0.
|
|
11
|
+
"a-type-of-js": "^1.0.7"
|
|
12
12
|
},
|
|
13
13
|
"publishConfig": {
|
|
14
14
|
"access": "public",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"xcn",
|
|
52
52
|
"mix-cn"
|
|
53
53
|
],
|
|
54
|
-
"homepage": "https://earthnut.dev/xcn",
|
|
54
|
+
"homepage": "https://earthnut.dev/npm/xcn",
|
|
55
55
|
"bugs": {
|
|
56
56
|
"url": "https://github.com/earthnutDev/xcn/issues",
|
|
57
57
|
"email": "earthnut.dev@outlook.com"
|