Comparing version
@@ -1,33 +0,66 @@ | ||
import { ClassValue } from 'clsx'; | ||
export { ClassValue, clsx } from 'clsx'; | ||
import { ClassValue } from "clsx" | ||
export { ClassValue, clsx } from "clsx" | ||
type ClassKey = "className"; | ||
type ClassProps = Partial<Record<ClassKey, ClassValue>>; | ||
type Flatten<T> = T extends object ? {} & { | ||
[P in keyof T]: T[P]; | ||
} : T; | ||
type OnnoClassValue = string | string[]; | ||
type OnnoClassProps = Record<ClassKey, OnnoClassValue>; | ||
type OnnoClassMap = Record<string, OnnoClassValue>; | ||
type OnnoVariants = Record<string, OnnoClassValue | OnnoClassMap>; | ||
type ClassKey = "className" | ||
type ClassProps = Partial<Record<ClassKey, ClassValue>> | ||
type Flatten<T> = T extends object | ||
? {} & { | ||
[P in keyof T]: T[P] | ||
} | ||
: T | ||
type OnnoClassValue = string | string[] | ||
type OnnoClassProps = Record<ClassKey, OnnoClassValue> | ||
type OnnoClassMap = Record<string, OnnoClassValue> | ||
type OnnoVariants = Record<string, OnnoClassValue | OnnoClassMap> | ||
type OnnoDefaults<T extends OnnoVariants> = { | ||
[K in keyof T]?: T[K] extends OnnoClassMap ? keyof T[K] : boolean; | ||
}; | ||
[K in keyof T]?: T[K] extends OnnoClassMap ? keyof T[K] : boolean | ||
} | ||
type OnnoCompound<T extends OnnoVariants> = { | ||
[K in keyof T]?: T[K] extends OnnoClassMap ? keyof T[K] | Array<keyof T[K]> : boolean; | ||
} & OnnoClassProps; | ||
[K in keyof T]?: T[K] extends OnnoClassMap | ||
? keyof T[K] | Array<keyof T[K]> | ||
: boolean | ||
} & OnnoClassProps | ||
interface OnnoConfig<T extends OnnoVariants> { | ||
baseline?: OnnoClassValue; | ||
compound?: Flatten<OnnoCompound<T>>[]; | ||
defaults?: Flatten<OnnoDefaults<T>>; | ||
variants: T; | ||
baseline?: OnnoClassValue | ||
compound?: Flatten<OnnoCompound<T>>[] | ||
defaults?: Flatten<OnnoDefaults<T>> | ||
variants: T | ||
} | ||
type OnnoOptions<T extends OnnoVariants> = OnnoDefaults<T> & ClassProps; | ||
type OnnoFunction<T extends OnnoVariants> = (options?: Flatten<OnnoOptions<T>>) => string; | ||
type OnnoFactory = <T extends OnnoVariants>(config: OnnoConfig<T>) => OnnoFunction<T>; | ||
type OnnoVariantProps<F extends OnnoFunction<any>> = Omit<Exclude<Parameters<F>[0], undefined>, ClassKey>; | ||
type OnnoProps<F extends OnnoFunction<any>, K extends keyof OnnoVariantProps<F> = never> = Flatten<OnnoVariantProps<F> & Required<Pick<OnnoVariantProps<F>, K>> & ClassProps>; | ||
type OnnoOptions<T extends OnnoVariants> = OnnoDefaults<T> & ClassProps | ||
type OnnoFunction<T extends OnnoVariants> = ( | ||
options?: Flatten<OnnoOptions<T>>, | ||
) => string | ||
type OnnoFactory = <T extends OnnoVariants>( | ||
config: OnnoConfig<T>, | ||
) => OnnoFunction<T> | ||
type OnnoVariantProps<F extends OnnoFunction<any>> = Omit< | ||
Exclude<Parameters<F>[0], undefined>, | ||
ClassKey | ||
> | ||
type OnnoProps< | ||
F extends OnnoFunction<any>, | ||
K extends keyof OnnoVariantProps<F> = never, | ||
> = Flatten< | ||
OnnoVariantProps<F> & Required<Pick<OnnoVariantProps<F>, K>> & ClassProps | ||
> | ||
declare const onno: OnnoFactory; | ||
declare const onno: OnnoFactory | ||
export { ClassKey, ClassProps, Flatten, OnnoClassMap, OnnoClassProps, OnnoClassValue, OnnoCompound, OnnoConfig, OnnoDefaults, OnnoFactory, OnnoFunction, OnnoOptions, OnnoProps, OnnoVariantProps, OnnoVariants, onno }; | ||
export { | ||
ClassKey, | ||
ClassProps, | ||
Flatten, | ||
OnnoClassMap, | ||
OnnoClassProps, | ||
OnnoClassValue, | ||
OnnoCompound, | ||
OnnoConfig, | ||
OnnoDefaults, | ||
OnnoFactory, | ||
OnnoFunction, | ||
OnnoOptions, | ||
OnnoProps, | ||
OnnoVariantProps, | ||
OnnoVariants, | ||
onno, | ||
} |
{ | ||
"name": "onno", | ||
"license": "MIT", | ||
"version": "2.1.2", | ||
"version": "2.2.0", | ||
"homepage": "https://onnojs.com", | ||
@@ -31,5 +31,5 @@ "keywords": [ | ||
"build": "pkgroll", | ||
"lint": "prettier --write .", | ||
"clean": "rm -rf coverage dist", | ||
"lint": "prettier --write --ignore-path .prettierignore .", | ||
"test": "vitest run --coverage", | ||
"clean": "rm -rf coverage dist", | ||
"changelog": "pnpm auto-changelog", | ||
@@ -36,0 +36,0 @@ "prepare": "husky install", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
120
21.21%14698
-0.07%