tailwind-variants
Advanced tools
Comparing version 0.0.3 to 0.0.4
import {TVConfig} from "./config"; | ||
import {ClassValue, ClassProp, OmitUndefined} from "./utils"; | ||
import { | ||
ClassValue, | ||
ClassProp, | ||
OmitUndefined, | ||
StringToBoolean, | ||
StringArrayToFunctions, | ||
} from "./utils"; | ||
type TVDefaultSlot = ""; | ||
type TVVariants<S extends string[]> = { | ||
[key: string]: { | ||
[key: string]: {[P in S[number]]?: ClassValue} | ClassValue; | ||
[key: string]: S extends TVDefaultSlot | ||
? ClassValue | ||
: {[P in S[number]]?: ClassValue} | ClassValue; | ||
}; | ||
@@ -12,3 +22,3 @@ }; | ||
{ | ||
[K in keyof V]?: keyof V[K]; | ||
[K in keyof V]?: StringToBoolean<keyof V[K]>; | ||
} & ClassProp<{[K in S[number]]?: ClassValue} | ClassValue> | ||
@@ -18,11 +28,14 @@ >; | ||
type TVDefaultVariants<V extends TVVariants<S>, S extends string[]> = { | ||
[K in keyof V]?: keyof V[K]; | ||
[K in keyof V]?: StringToBoolean<keyof V[K]>; | ||
}; | ||
type TVReturnType<S extends string[]> = S extends string[] | ||
? {[K in S[number]]: (slotProps: ClassProp) => string} | ||
: (slotProps: ClassProp) => string; | ||
type TVProps<V extends TVVariants<S>, S extends string[]> = { | ||
[K in keyof V]?: StringToBoolean<keyof V[K]>; | ||
} & ClassProp; | ||
type TVReturnType<V extends TVVariants<S>, S extends string[]> = ( | ||
props?: TVProps<V, S>, | ||
) => S extends TVDefaultSlot ? string : StringArrayToFunctions<S, ClassProp>; | ||
export declare function tv< | ||
S extends string, | ||
V extends TVVariants<S[]>, | ||
@@ -32,2 +45,3 @@ CV extends TVCompoundVariants<V, S[]>, | ||
C extends TVConfig, | ||
S extends string = TVDefaultSlot, | ||
>( | ||
@@ -42,3 +56,3 @@ options: { | ||
config?: C, | ||
): TVReturnType<S[]>; | ||
): TVReturnType<V, S[]>; | ||
@@ -45,0 +59,0 @@ export type VariantProps<Component extends (...args: any) => any> = Omit< |
@@ -24,1 +24,9 @@ import {CxOptions, CxReturn} from "class-variance-authority"; | ||
export type StringToBoolean<T> = T extends "true" | "false" ? boolean : T; | ||
export type StringArrayToFunctions<T extends string[], Props = {}> = { | ||
[K in T[number]]: (props?: Props) => string; | ||
}; | ||
type Slots = ["trigger", "item", "list"]; | ||
type SlotsReturnType = StringArrayToFunctions<Slots>; |
{ | ||
"name": "tailwind-variants", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"description": "🦄 Tailwindcss first-class variant API", | ||
@@ -5,0 +5,0 @@ "author": "Junior Garcia <jrgarciadev@gmail.com>", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
13172
154