Files
SnowLuma/.pnpm-store/v11/files/4d/3f883b4bc6fd7fb1f1ab5f7ecda9c583103b9bec12cfefee7e9f6b5b3e778064d5f7e81a3ca9ae3b8d5ab57018d632b47653eec7b314939c683a445b4842e1
TanTan 2a69b23b47
Dev Build / cleanup (push) Waiting to run
Dev Build / typecheck (push) Waiting to run
docs: 仓库链接指向本镜像仓库
2026-11-13 09:27:07 +08:00

51 lines
1.4 KiB
Plaintext

/**
* The code in this file is copied from https://github.com/lukeed/clsx and modified to suit the needs of tailwind-merge better.
*
* Specifically:
* - Runtime code from https://github.com/lukeed/clsx/blob/v1.2.1/src/index.js
* - TypeScript types from https://github.com/lukeed/clsx/blob/v1.2.1/clsx.d.ts
*
* Original code has MIT license: Copyright (c) Luke Edwards <luke.edwards05@gmail.com> (lukeed.com)
*/
export type ClassNameValue = ClassNameArray | string | null | undefined | 0 | 0n | false
type ClassNameArray = ClassNameValue[]
export const twJoin = (...classLists: ClassNameValue[]): string => {
let index = 0
let argument: ClassNameValue
let resolvedValue: string
let string = ''
while (index < classLists.length) {
if ((argument = classLists[index++])) {
if ((resolvedValue = toValue(argument))) {
string && (string += ' ')
string += resolvedValue
}
}
}
return string
}
const toValue = (mix: ClassNameArray | string): string => {
// Fast path for strings
if (typeof mix === 'string') {
return mix
}
let resolvedValue: string
let string = ''
for (let k = 0; k < mix.length; k++) {
if (mix[k]) {
if ((resolvedValue = toValue(mix[k] as ClassNameArray | string))) {
string && (string += ' ')
string += resolvedValue
}
}
}
return string
}