MCPcopy
hub / github.com/Tencent/omi / classNames

Function classNames

packages/omi/src/class.ts:16–42  ·  view source on GitHub ↗
(...args: ArgumentArray)

Source from the content-addressed store, hash-verified

14type Argument = Value | Mapping | ArgumentArray | ReadonlyArgumentArray
15
16export function classNames(...args: ArgumentArray): string {
17 const classes: (string | number)[] = []
18
19 for (let i = 0; i < args.length; i++) {
20 const arg: Argument = args[i]
21 if (!arg) continue
22
23 const argType = typeof arg
24
25 if (argType === 'string' || argType === 'number') {
26 classes.push(arg as string | number)
27 } else if (Array.isArray(arg) && arg.length) {
28 const inner = classNames(...arg)
29 if (inner) {
30 classes.push(inner)
31 }
32 } else if (argType === 'object') {
33 for (const key in arg as Mapping) {
34 if (hasOwn.call(arg, key) && (arg as Mapping)[key]) {
35 classes.push(key)
36 }
37 }
38 }
39 }
40
41 return classes.join(' ')
42}
43
44type PropsMapping = {
45 class?: Argument

Callers 15

ComponentLayoutFunction · 0.90
renderMethod · 0.90
renderMethod · 0.90
AdminLayoutFunction · 0.90
renderNavbarItemChildMethod · 0.90
renderMethod · 0.90
renderChildMethod · 0.90
renderMethod · 0.90
renderMethod · 0.90
renderMethod · 0.90
renderMethod · 0.90
renderMethod · 0.90

Calls 1

pushMethod · 0.45

Tested by

no test coverage detected