New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

tailwind-merge

Package Overview
Dependencies
Maintainers
1
Versions
327
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tailwind-merge - npm Package Compare versions

Comparing version 2.5.5 to 2.6.0-dev.1a92c358e0ecc910296be7fce6635ad6f685be87

34

package.json
{
"name": "tailwind-merge",
"version": "2.5.5",
"version": "2.6.0-dev.1a92c358e0ecc910296be7fce6635ad6f685be87",
"description": "Merge Tailwind CSS classes without style conflicts",

@@ -65,24 +65,24 @@ "keywords": [

"devDependencies": {
"@babel/core": "^7.25.2",
"@babel/preset-env": "^7.25.4",
"@codspeed/vitest-plugin": "^3.1.1",
"@babel/core": "^7.26.0",
"@babel/preset-env": "^7.26.0",
"@codspeed/vitest-plugin": "^4.0.0",
"@rollup/plugin-babel": "^6.0.4",
"@rollup/plugin-node-resolve": "^15.3.0",
"@rollup/plugin-typescript": "^12.1.0",
"@vitest/coverage-v8": "^2.1.1",
"@vitest/eslint-plugin": "^1.1.5",
"@rollup/plugin-node-resolve": "^16.0.0",
"@rollup/plugin-typescript": "^12.1.1",
"@vitest/coverage-v8": "^2.1.8",
"@vitest/eslint-plugin": "^1.1.14",
"babel-plugin-annotate-pure-calls": "^0.4.0",
"babel-plugin-polyfill-regenerator": "^0.6.2",
"eslint": "^9.11.1",
"babel-plugin-polyfill-regenerator": "^0.6.3",
"eslint": "^9.16.0",
"eslint-plugin-import": "^2.31.0",
"globby": "^11.1.0",
"prettier": "^3.3.3",
"rollup": "^4.22.5",
"prettier": "^3.4.2",
"rollup": "^4.28.1",
"rollup-plugin-delete": "^2.1.0",
"rollup-plugin-dts": "^6.1.1",
"tslib": "^2.7.0",
"typescript": "^5.6.2",
"typescript-eslint": "^8.8.0",
"vitest": "^2.1.1",
"zx": "^8.1.8"
"tslib": "^2.8.1",
"typescript": "^5.7.2",
"typescript-eslint": "^8.17.0",
"vitest": "^2.1.8",
"zx": "^8.2.4"
},

@@ -89,0 +89,0 @@ "publishConfig": {

@@ -6,3 +6,3 @@ <!-- This file is autogenerated. If you want to change this content, please do the changes in `./docs/README.md` instead. -->

<a href="https://github.com/dcastil/tailwind-merge">
<img src="https://github.com/dcastil/tailwind-merge/raw/v2.5.5/assets/logo.svg" alt="tailwind-merge" height="150px" />
<img src="https://github.com/dcastil/tailwind-merge/raw/1a92c358e0ecc910296be7fce6635ad6f685be87/assets/logo.svg" alt="tailwind-merge" height="150px" />
</a>

@@ -29,12 +29,12 @@ </div>

- [What is it for](https://github.com/dcastil/tailwind-merge/tree/v2.5.5/docs/what-is-it-for.md)
- [When and how to use it](https://github.com/dcastil/tailwind-merge/tree/v2.5.5/docs/when-and-how-to-use-it.md)
- [Features](https://github.com/dcastil/tailwind-merge/tree/v2.5.5/docs/features.md)
- [Limitations](https://github.com/dcastil/tailwind-merge/tree/v2.5.5/docs/limitations.md)
- [Configuration](https://github.com/dcastil/tailwind-merge/tree/v2.5.5/docs/configuration.md)
- [Recipes](https://github.com/dcastil/tailwind-merge/tree/v2.5.5/docs/recipes.md)
- [API reference](https://github.com/dcastil/tailwind-merge/tree/v2.5.5/docs/api-reference.md)
- [Writing plugins](https://github.com/dcastil/tailwind-merge/tree/v2.5.5/docs/writing-plugins.md)
- [Versioning](https://github.com/dcastil/tailwind-merge/tree/v2.5.5/docs/versioning.md)
- [Contributing](https://github.com/dcastil/tailwind-merge/tree/v2.5.5/docs/contributing.md)
- [Similar packages](https://github.com/dcastil/tailwind-merge/tree/v2.5.5/docs/similar-packages.md)
- [What is it for](https://github.com/dcastil/tailwind-merge/tree/1a92c358e0ecc910296be7fce6635ad6f685be87/docs/what-is-it-for.md)
- [When and how to use it](https://github.com/dcastil/tailwind-merge/tree/1a92c358e0ecc910296be7fce6635ad6f685be87/docs/when-and-how-to-use-it.md)
- [Features](https://github.com/dcastil/tailwind-merge/tree/1a92c358e0ecc910296be7fce6635ad6f685be87/docs/features.md)
- [Limitations](https://github.com/dcastil/tailwind-merge/tree/1a92c358e0ecc910296be7fce6635ad6f685be87/docs/limitations.md)
- [Configuration](https://github.com/dcastil/tailwind-merge/tree/1a92c358e0ecc910296be7fce6635ad6f685be87/docs/configuration.md)
- [Recipes](https://github.com/dcastil/tailwind-merge/tree/1a92c358e0ecc910296be7fce6635ad6f685be87/docs/recipes.md)
- [API reference](https://github.com/dcastil/tailwind-merge/tree/1a92c358e0ecc910296be7fce6635ad6f685be87/docs/api-reference.md)
- [Writing plugins](https://github.com/dcastil/tailwind-merge/tree/1a92c358e0ecc910296be7fce6635ad6f685be87/docs/writing-plugins.md)
- [Versioning](https://github.com/dcastil/tailwind-merge/tree/1a92c358e0ecc910296be7fce6635ad6f685be87/docs/versioning.md)
- [Contributing](https://github.com/dcastil/tailwind-merge/tree/1a92c358e0ecc910296be7fce6635ad6f685be87/docs/contributing.md)
- [Similar packages](https://github.com/dcastil/tailwind-merge/tree/1a92c358e0ecc910296be7fce6635ad6f685be87/docs/similar-packages.md)

@@ -11,2 +11,3 @@ export { createTailwindMerge } from './lib/create-tailwind-merge'

type Config,
type ConfigExtension,
type DefaultClassGroupIds,

@@ -13,0 +14,0 @@ type DefaultThemeGroupIds,

import {
AnyClassGroupIds,
AnyConfig,
AnyThemeGroupIds,
ClassGroup,
ClassValidator,
Config,
GenericClassGroupIds,
GenericConfig,
GenericThemeGroupIds,
ThemeGetter,

@@ -15,7 +15,7 @@ ThemeObject,

validators: ClassValidatorObject[]
classGroupId?: GenericClassGroupIds
classGroupId?: AnyClassGroupIds
}
interface ClassValidatorObject {
classGroupId: GenericClassGroupIds
classGroupId: AnyClassGroupIds
validator: ClassValidator

@@ -26,3 +26,3 @@ }

export const createClassGroupUtils = (config: GenericConfig) => {
export const createClassGroupUtils = (config: AnyConfig) => {
const classMap = createClassMap(config)

@@ -43,3 +43,3 @@ const { conflictingClassGroups, conflictingClassGroupModifiers } = config

const getConflictingClassGroupIds = (
classGroupId: GenericClassGroupIds,
classGroupId: AnyClassGroupIds,
hasPostfixModifier: boolean,

@@ -65,3 +65,3 @@ ) => {

classPartObject: ClassPartObject,
): GenericClassGroupIds | undefined => {
): AnyClassGroupIds | undefined => {
if (classParts.length === 0) {

@@ -110,3 +110,3 @@ return classPartObject.classGroupId

*/
export const createClassMap = (config: Config<GenericClassGroupIds, GenericThemeGroupIds>) => {
export const createClassMap = (config: Config<AnyClassGroupIds, AnyThemeGroupIds>) => {
const { theme, prefix } = config

@@ -131,6 +131,6 @@ const classMap: ClassPartObject = {

const processClassesRecursively = (
classGroup: ClassGroup<GenericThemeGroupIds>,
classGroup: ClassGroup<AnyThemeGroupIds>,
classPartObject: ClassPartObject,
classGroupId: GenericClassGroupIds,
theme: ThemeObject<GenericThemeGroupIds>,
classGroupId: AnyClassGroupIds,
theme: ThemeObject<AnyThemeGroupIds>,
) => {

@@ -196,5 +196,5 @@ classGroup.forEach((classDefinition) => {

const getPrefixedClassGroupEntries = (
classGroupEntries: Array<[classGroupId: string, classGroup: ClassGroup<GenericThemeGroupIds>]>,
classGroupEntries: Array<[classGroupId: string, classGroup: ClassGroup<AnyThemeGroupIds>]>,
prefix: string | undefined,
): Array<[classGroupId: string, classGroup: ClassGroup<GenericThemeGroupIds>]> => {
): Array<[classGroupId: string, classGroup: ClassGroup<AnyThemeGroupIds>]> => {
if (!prefix) {

@@ -201,0 +201,0 @@ return classGroupEntries

import { createClassGroupUtils } from './class-group-utils'
import { createLruCache } from './lru-cache'
import { createParseClassName } from './parse-class-name'
import { GenericConfig } from './types'
import { AnyConfig } from './types'
export type ConfigUtils = ReturnType<typeof createConfigUtils>
export const createConfigUtils = (config: GenericConfig) => ({
export const createConfigUtils = (config: AnyConfig) => ({
cache: createLruCache<string, string>(config.cacheSize),

@@ -10,0 +10,0 @@ parseClassName: createParseClassName(config),

import { createConfigUtils } from './config-utils'
import { mergeClassList } from './merge-classlist'
import { ClassNameValue, twJoin } from './tw-join'
import { GenericConfig } from './types'
import { AnyConfig } from './types'
type CreateConfigFirst = () => GenericConfig
type CreateConfigSubsequent = (config: GenericConfig) => GenericConfig
type CreateConfigFirst = () => AnyConfig
type CreateConfigSubsequent = (config: AnyConfig) => AnyConfig
type TailwindMerge = (...classLists: ClassNameValue[]) => string

@@ -23,3 +23,3 @@ type ConfigUtils = ReturnType<typeof createConfigUtils>

(previousConfig, createConfigCurrent) => createConfigCurrent(previousConfig),
createConfigFirst() as GenericConfig,
createConfigFirst() as AnyConfig,
)

@@ -26,0 +26,0 @@

import { createTailwindMerge } from './create-tailwind-merge'
import { getDefaultConfig } from './default-config'
import { mergeConfigs } from './merge-configs'
import { ConfigExtension, DefaultClassGroupIds, DefaultThemeGroupIds, GenericConfig } from './types'
import { AnyConfig, ConfigExtension, DefaultClassGroupIds, DefaultThemeGroupIds } from './types'
type CreateConfigSubsequent = (config: GenericConfig) => GenericConfig
type CreateConfigSubsequent = (config: AnyConfig) => AnyConfig

@@ -8,0 +8,0 @@ export const extendTailwindMerge = <

@@ -1,2 +0,2 @@

import { ConfigExtension, GenericConfig } from './types'
import { AnyConfig, ConfigExtension } from './types'

@@ -8,3 +8,3 @@ /**

export const mergeConfigs = <ClassGroupIds extends string, ThemeGroupIds extends string = never>(
baseConfig: GenericConfig,
baseConfig: AnyConfig,
{

@@ -11,0 +11,0 @@ cacheSize,

@@ -1,6 +0,6 @@

import { GenericConfig } from './types'
import { AnyConfig } from './types'
export const IMPORTANT_MODIFIER = '!'
export const createParseClassName = (config: GenericConfig) => {
export const createParseClassName = (config: AnyConfig) => {
const { separator, experimentalParseClassName } = config

@@ -7,0 +7,0 @@ const isSeparatorSingleCharacter = separator.length === 1

@@ -0,6 +1,12 @@

/**
* Type the tailwind-merge configuration adheres to.
*/
export interface Config<ClassGroupIds extends string, ThemeGroupIds extends string>
extends ConfigStatic,
ConfigGroups<ClassGroupIds, ThemeGroupIds> {}
extends ConfigStaticPart,
ConfigGroupsPart<ClassGroupIds, ThemeGroupIds> {}
interface ConfigStatic {
/**
* The static part of the tailwind-merge configuration. When merging multiple configurations, the properties of this interface are always overridden.
*/
interface ConfigStaticPart {
/**

@@ -78,3 +84,6 @@ * Integer indicating size of LRU cache used for memoizing results.

interface ConfigGroups<ClassGroupIds extends string, ThemeGroupIds extends string> {
/**
* The dynamic part of the tailwind-merge configuration. When merging multiple configurations, the user can choose to either override or extend the properties of this interface.
*/
interface ConfigGroupsPart<ClassGroupIds extends string, ThemeGroupIds extends string> {
/**

@@ -113,6 +122,9 @@ * Theme scales used in classGroups.

/**
* Type of the configuration object that can be passed to `extendTailwindMerge`.
*/
export interface ConfigExtension<ClassGroupIds extends string, ThemeGroupIds extends string>
extends Partial<ConfigStatic> {
override?: PartialPartial<ConfigGroups<ClassGroupIds, ThemeGroupIds>>
extend?: PartialPartial<ConfigGroups<ClassGroupIds, ThemeGroupIds>>
extends Partial<ConfigStaticPart> {
override?: PartialPartial<ConfigGroupsPart<ClassGroupIds, ThemeGroupIds>>
extend?: PartialPartial<ConfigGroupsPart<ClassGroupIds, ThemeGroupIds>>
}

@@ -136,3 +148,3 @@

export interface ThemeGetter {
(theme: ThemeObject<GenericThemeGroupIds>): ClassGroup<GenericClassGroupIds>
(theme: ThemeObject<AnyThemeGroupIds>): ClassGroup<AnyClassGroupIds>
isThemeGetter: true

@@ -145,6 +157,12 @@ }

// Hack from https://stackoverflow.com/questions/56687668/a-way-to-disable-type-argument-inference-in-generics/56688073#56688073
/**
* Hack from https://stackoverflow.com/questions/56687668/a-way-to-disable-type-argument-inference-in-generics/56688073#56688073
*
* Could be replaced with NoInfer utility type from TypeScript (https://www.typescriptlang.org/docs/handbook/utility-types.html#noinfertype), but that is only supported in TypeScript 5.4 or higher, so I should wait some time before using it.
*/
export type NoInfer<T> = [T][T extends any ? 0 : never]
/**
* Theme group IDs included in the default configuration of tailwind-merge.
*
* If you want to use a scale that is not supported in the `ThemeObject` type,

@@ -183,2 +201,5 @@ * consider using `classGroups` instead of `theme`.

/**
* Class group IDs included in the default configuration of tailwind-merge.
*/
export type DefaultClassGroupIds =

@@ -466,5 +487,8 @@ | 'accent'

export type GenericClassGroupIds = string
export type GenericThemeGroupIds = string
export type AnyClassGroupIds = string
export type AnyThemeGroupIds = string
export type GenericConfig = Config<GenericClassGroupIds, GenericThemeGroupIds>
/**
* type of the tailwind-merge configuration that allows for any possible configuration.
*/
export type AnyConfig = Config<AnyClassGroupIds, AnyThemeGroupIds>

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc