| Conditions | 4 |
| Total Lines | 29 |
| Code Lines | 25 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | import { |
||
| 30 | |||
| 31 | function mapping< |
||
| 32 | Source extends CssModule, |
||
| 33 | Target extends AnyObject, |
||
| 34 | Mapping extends ClassNamesMap<OmitIndexed<GetProps<Target>>, Source> |
||
| 35 | >( |
||
| 36 | source: Source, |
||
| 37 | _: Target, |
||
| 38 | map: Mapping |
||
| 39 | ): {[M in keyof Mapping]: string} { |
||
| 40 | const keys = $keys(map) as (keyof Mapping)[] |
||
| 41 | , classnames = {} as {[M in keyof Mapping]: string} |
||
| 42 | |||
| 43 | for (let i = keys.length; i--;) { |
||
| 44 | const key = keys[i] |
||
| 45 | , val = map[key] |
||
| 46 | |||
| 47 | if (val === undefined) |
||
| 48 | continue |
||
| 49 | |||
| 50 | classnames[key] = typeof val === "function" |
||
| 51 | ? `${val}` |
||
| 52 | : resolver(source, |
||
| 53 | //@ts-expect-error #27 TS doesn't understand that ClassNaming is first of all function |
||
| 54 | val |
||
| 55 | ).join(" ") |
||
| 56 | } |
||
| 57 | |||
| 58 | return classnames |
||
| 59 | } |
||
| 60 |