tailwind-variants 0.0.3 → 0.0.4
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/index.d.ts +23 -9
- package/dist/utils.d.ts +8 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,32 +1,46 @@
|
|
|
1
1
|
import {TVConfig} from "./config";
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
ClassValue,
|
|
4
|
+
ClassProp,
|
|
5
|
+
OmitUndefined,
|
|
6
|
+
StringToBoolean,
|
|
7
|
+
StringArrayToFunctions,
|
|
8
|
+
} from "./utils";
|
|
9
|
+
|
|
10
|
+
type TVDefaultSlot = "";
|
|
3
11
|
|
|
4
12
|
type TVVariants<S extends string[]> = {
|
|
5
13
|
[key: string]: {
|
|
6
|
-
[key: string]:
|
|
14
|
+
[key: string]: S extends TVDefaultSlot
|
|
15
|
+
? ClassValue
|
|
16
|
+
: {[P in S[number]]?: ClassValue} | ClassValue;
|
|
7
17
|
};
|
|
8
18
|
};
|
|
9
19
|
|
|
10
20
|
type TVCompoundVariants<V extends TVVariants<S>, S extends string[]> = Array<
|
|
11
21
|
{
|
|
12
|
-
[K in keyof V]?: keyof V[K]
|
|
22
|
+
[K in keyof V]?: StringToBoolean<keyof V[K]>;
|
|
13
23
|
} & ClassProp<{[K in S[number]]?: ClassValue} | ClassValue>
|
|
14
24
|
>;
|
|
15
25
|
|
|
16
26
|
type TVDefaultVariants<V extends TVVariants<S>, S extends string[]> = {
|
|
17
|
-
[K in keyof V]?: keyof V[K]
|
|
27
|
+
[K in keyof V]?: StringToBoolean<keyof V[K]>;
|
|
18
28
|
};
|
|
19
29
|
|
|
20
|
-
type
|
|
21
|
-
|
|
22
|
-
|
|
30
|
+
type TVProps<V extends TVVariants<S>, S extends string[]> = {
|
|
31
|
+
[K in keyof V]?: StringToBoolean<keyof V[K]>;
|
|
32
|
+
} & ClassProp;
|
|
33
|
+
|
|
34
|
+
type TVReturnType<V extends TVVariants<S>, S extends string[]> = (
|
|
35
|
+
props?: TVProps<V, S>,
|
|
36
|
+
) => S extends TVDefaultSlot ? string : StringArrayToFunctions<S, ClassProp>;
|
|
23
37
|
|
|
24
38
|
export declare function tv<
|
|
25
|
-
S extends string,
|
|
26
39
|
V extends TVVariants<S[]>,
|
|
27
40
|
CV extends TVCompoundVariants<V, S[]>,
|
|
28
41
|
DV extends TVDefaultVariants<V, S[]>,
|
|
29
42
|
C extends TVConfig,
|
|
43
|
+
S extends string = TVDefaultSlot,
|
|
30
44
|
>(
|
|
31
45
|
options: {
|
|
32
46
|
base?: ClassValue;
|
|
@@ -36,7 +50,7 @@ export declare function tv<
|
|
|
36
50
|
defaultVariants?: DV;
|
|
37
51
|
},
|
|
38
52
|
config?: C,
|
|
39
|
-
): TVReturnType<S[]>;
|
|
53
|
+
): TVReturnType<V, S[]>;
|
|
40
54
|
|
|
41
55
|
export type VariantProps<Component extends (...args: any) => any> = Omit<
|
|
42
56
|
OmitUndefined<Parameters<Component>[0]>,
|
package/dist/utils.d.ts
CHANGED
|
@@ -21,3 +21,11 @@ export type ClassProp<V extends unknown = ClassValue> =
|
|
|
21
21
|
|
|
22
22
|
export type OmitUndefined<T> = T extends undefined ? never : T;
|
|
23
23
|
export type StringToBoolean<T> = T extends "true" | "false" ? boolean : T;
|
|
24
|
+
|
|
25
|
+
export type StringArrayToFunctions<T extends string[], Props = {}> = {
|
|
26
|
+
[K in T[number]]: (props?: Props) => string;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
type Slots = ["trigger", "item", "list"];
|
|
30
|
+
|
|
31
|
+
type SlotsReturnType = StringArrayToFunctions<Slots>;
|