Bindings

clsx

clsx

clsx.d.mts
export type ClassValue = ClassArray | ClassDictionary | string | number | bigint | null | boolean | undefined;
export type ClassDictionary = Record<string, any>;
export type ClassArray = ClassValue[];

export function clsx(...inputs: ClassValue[]): string;
export default clsx;
clsx.d.ts
declare namespace clsx {
	type ClassValue = ClassArray | ClassDictionary | string | number | bigint | null | boolean | undefined;
	type ClassDictionary = Record<string, any>;
	type ClassArray = ClassValue[];
	function clsx(...inputs: ClassValue[]): string;
}

declare function clsx(...inputs: clsx.ClassValue[]): string;

export = clsx;
package.json
{
  "name": "clsx",
  "version": "2.1.1",
  "repository": "lukeed/clsx",
  "description": "A tiny (239B) utility for constructing className strings conditionally.",
  "module": "dist/clsx.mjs",
  "unpkg": "dist/clsx.min.js",
  "main": "dist/clsx.js",
  "types": "clsx.d.ts",
  "license": "MIT",
  "exports": {
    ".": {
      "import": {
        "types": "./clsx.d.mts",
        "default": "./dist/clsx.mjs"
      },
      "default": {
        "types": "./clsx.d.ts",
        "default": "./dist/clsx.js"
      }
    },
    "./lite": {
      "import": {
        "types": "./clsx.d.mts",
        "default": "./dist/lite.mjs"
      },
      "default": {
        "types": "./clsx.d.ts",
        "default": "./dist/lite.js"
      }
    }
  },
  "author": {
    "name": "Luke Edwards",
    "email": "luke.edwards05@gmail.com",
    "url": "https://lukeed.com"
  },
  "engines": {
    "node": ">=6"
  },
  "scripts": {
    "build": "node bin",
    "test": "uvu -r esm test"
  },
  "files": [
    "*.d.mts",
    "*.d.ts",
    "dist"
  ],
  "keywords": [
    "classes",
    "classname",
    "classnames"
  ],
  "devDependencies": {
    "esm": "3.2.25",
    "terser": "4.8.0",
    "uvu": "0.5.4"
  }
}
mod.scala
package typings.clsx

import typings.std.Record
import org.scalablytyped.runtime.StObject
import scala.scalajs.js
import scala.scalajs.js.annotation.{JSGlobalScope, JSGlobal, JSImport, JSName, JSBracketAccess}

object mod {
  
  inline def apply(inputs: ClassValue*): String = ^.asInstanceOf[js.Dynamic].apply(inputs.asInstanceOf[Seq[js.Any]]*).asInstanceOf[String]
  
  @JSImport("clsx", JSImport.Namespace)
  @js.native
  val ^ : js.Any = js.native
  
  inline def clsx(inputs: ClassValue*): String = ^.asInstanceOf[js.Dynamic].applyDynamic("clsx")(inputs.asInstanceOf[Seq[js.Any]]*).asInstanceOf[String]
  
  type ClassArray = js.Array[ClassValue]
  
  type ClassDictionary = Record[String, Any]
  
  /** 
  NOTE: Rewritten from type alias:
  {{{
  type ClassValue = clsx.clsx.ClassArray | clsx.clsx.ClassDictionary | string | number | bigint | null | boolean | undefined
  }}}
  to avoid circular code involving: 
  - clsx.clsx.ClassArray
  - clsx.clsx.ClassValue
  */
  type ClassValue = js.UndefOr[Any | ClassDictionary | String | Double | js.BigInt | Null | Boolean]
}
clsxRequire.scala
package typings.clsx

import org.scalablytyped.runtime.StObject
import scala.scalajs.js
import scala.scalajs.js.annotation.{JSGlobalScope, JSGlobal, JSImport, JSName, JSBracketAccess}

/* This can be used to `require` the library as a side effect.
  If it is a global library this will make scalajs-bundler include it */
@JSImport("clsx", JSImport.Namespace)
@js.native
object clsxRequire extends StObject

How we provide sjs binding for the clsx package:

For a package, we will have an object mod that contains the imports for the package.

import { clsx } from "clsx"

clsx("foo", "bar", "baz")

will be converted to:

import typings.clsx.mod.clsx

clsx("foo", "bar", "baz")

or import default:

import clsx from "clsx"

clsx("foo", "bar", "baz")

will be converted to:

import typings.clsx.mod

mod("foo", "bar", "baz")

Generate imports

How to generate the imports for a package?

From the type definition, counting the export statements, we can generate the imports for the package in sjs.

On this page