Home / Function/ removeEmptyArgumentsFromCnCall() — ui Function Reference

removeEmptyArgumentsFromCnCall() — ui Function Reference

Architecture documentation for the removeEmptyArgumentsFromCnCall() function in transform-style-map.ts from the ui codebase.

Entity Profile

Dependency Diagram

graph TD
  450ad62f_60de_6074_bd15_6596ccfbec62["removeEmptyArgumentsFromCnCall()"]
  cef4e429_7112_fef5_ae0b_a838a57ccf71["transform-style-map.ts"]
  450ad62f_60de_6074_bd15_6596ccfbec62 -->|defined in| cef4e429_7112_fef5_ae0b_a838a57ccf71
  b485ec68_aafc_76e7_2137_6da415f1d2ec["cleanCnClassesFromAttribute()"]
  b485ec68_aafc_76e7_2137_6da415f1d2ec -->|calls| 450ad62f_60de_6074_bd15_6596ccfbec62
  470d33e5_1a8c_ef52_d881_58cf2d3d50a3["applyClassesToElement()"]
  470d33e5_1a8c_ef52_d881_58cf2d3d50a3 -->|calls| 450ad62f_60de_6074_bd15_6596ccfbec62
  202d5e0e_dd42_da00_b903_9227d5b955fe["cleanCnClassesFromCnCall()"]
  202d5e0e_dd42_da00_b903_9227d5b955fe -->|calls| 450ad62f_60de_6074_bd15_6596ccfbec62
  b7873427_1a10_b3fd_c967_d6be1f464ff6["applyClassesToCnCall()"]
  b7873427_1a10_b3fd_c967_d6be1f464ff6 -->|calls| 450ad62f_60de_6074_bd15_6596ccfbec62
  1e57bbcb_bd35_08f0_4331_f460319d4a4a["isCnCall()"]
  450ad62f_60de_6074_bd15_6596ccfbec62 -->|calls| 1e57bbcb_bd35_08f0_4331_f460319d4a4a
  19d51d29_43e2_13c5_a0b3_791f6900bbaa["isStringLiteralLike()"]
  450ad62f_60de_6074_bd15_6596ccfbec62 -->|calls| 19d51d29_43e2_13c5_a0b3_791f6900bbaa
  style 450ad62f_60de_6074_bd15_6596ccfbec62 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/shadcn/src/styles/transform-style-map.ts lines 293–316

function removeEmptyArgumentsFromCnCall(callExpression: CallExpression) {
  if (!isCnCall(callExpression)) {
    return
  }

  const args = callExpression.getArguments()
  const nonEmptyArgs = args.filter((arg) => {
    if (isStringLiteralLike(arg)) {
      const text = arg.getLiteralText().trim()
      return text !== ""
    }
    return true
  })

  if (nonEmptyArgs.length !== args.length) {
    const argTexts = nonEmptyArgs.map((arg) => arg.getText())
    const parent = callExpression.getParent()
    if (parent && Node.isJsxExpression(parent)) {
      parent.replaceWithText(`{cn(${argTexts.join(", ")})}`)
    } else {
      callExpression.replaceWithText(`cn(${argTexts.join(", ")})`)
    }
  }
}

Subdomains

Frequently Asked Questions

What does removeEmptyArgumentsFromCnCall() do?
removeEmptyArgumentsFromCnCall() is a function in the ui codebase, defined in packages/shadcn/src/styles/transform-style-map.ts.
Where is removeEmptyArgumentsFromCnCall() defined?
removeEmptyArgumentsFromCnCall() is defined in packages/shadcn/src/styles/transform-style-map.ts at line 293.
What does removeEmptyArgumentsFromCnCall() call?
removeEmptyArgumentsFromCnCall() calls 2 function(s): isCnCall, isStringLiteralLike.
What calls removeEmptyArgumentsFromCnCall()?
removeEmptyArgumentsFromCnCall() is called by 4 function(s): applyClassesToCnCall, applyClassesToElement, cleanCnClassesFromAttribute, cleanCnClassesFromCnCall.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free