1- export type { ClassNames } from "./defs"
21import type { Falsy , ToggleMap , ClassValue , ClassNamer , ClassNamed } from "./defs"
32import { emptize , stringifyClassNamed , truthyKeys } from "./utils"
43
54export default classNamingCtx
65
76function classNamingCtx < ClassKeys extends string > ( ctx : ClassNamer < ClassKeys > ) {
87 emptize ( ctx . classNames )
8+
99 const { classNames, className} = ctx
10+
1011 return function classNamer /*<ClassKeys extends string>*/ (
1112 // this: ClassNamer<ClassKeys>,
1213 //TODO (typeof className extends string ? true : never)
@@ -18,13 +19,15 @@ function classNamingCtx<ClassKeys extends string>(ctx: ClassNamer<ClassKeys>) {
1819 ) : ClassNamed {
1920 // const {className, classNames} = this
2021 const withPropagation = arg0 === true
21- //@ts -expect-error
2222 , allowed : ClassKeys [ ] = truthyKeys ( arg0 === true ? false : arg0 )
2323 //@ts -expect-error
2424 . concat ( truthyKeys ( arg1 ) )
2525 //@ts -expect-error
2626 . concat ( args )
27- . filter ( Boolean )
27+ . filter < ClassKeys > (
28+ //@ts -expect-error
29+ Boolean
30+ )
2831
2932 for ( let i = allowed . length ; i -- ; ) {
3033 const key = allowed [ i ]
@@ -37,8 +40,7 @@ function classNamingCtx<ClassKeys extends string>(ctx: ClassNamer<ClassKeys>) {
3740
3841 const allowedString = allowed . join ( " " )
3942 , propagated = withPropagation && className || ""
40-
41- return stringifyClassNamed ( {
43+ , $return = {
4244 className : `${
4345 propagated
4446 } ${
@@ -48,7 +50,11 @@ function classNamingCtx<ClassKeys extends string>(ctx: ClassNamer<ClassKeys>) {
4850 } ${
4951 allowedString
5052 } `
51- } )
53+ }
54+
55+ stringifyClassNamed ( $return )
56+
57+ return $return
5258 }
5359}
5460
0 commit comments