tailwind-merge
Advanced tools
Comparing version 2.5.1 to 2.5.2-dev.0a98923c58279779d59c38c03f5ddd385a764751
{ | ||
"name": "tailwind-merge", | ||
"version": "2.5.1", | ||
"version": "2.5.2-dev.0a98923c58279779d59c38c03f5ddd385a764751", | ||
"description": "Merge Tailwind CSS classes without style conflicts", | ||
@@ -54,4 +54,5 @@ "keywords": [ | ||
"build": "rollup --config scripts/rollup.config.mjs", | ||
"test": "jest test --config scripts/jest.config.mjs --coverage", | ||
"test:watch": "jest test --config scripts/jest.config.mjs --watch", | ||
"bench": "vitest bench --config scripts/vitest.config.mts", | ||
"test": "vitest --config scripts/vitest.config.mts --coverage", | ||
"test:watch": "vitest --config scripts/vitest.config.mts", | ||
"test:exports": "node scripts/test-built-package-exports.cjs && node scripts/test-built-package-exports.mjs", | ||
@@ -66,24 +67,23 @@ "lint": "eslint --max-warnings 0 '**'", | ||
"@babel/core": "^7.25.2", | ||
"@babel/preset-env": "^7.25.3", | ||
"@babel/preset-env": "^7.25.4", | ||
"@codspeed/vitest-plugin": "^3.1.1", | ||
"@rollup/plugin-babel": "^6.0.4", | ||
"@rollup/plugin-node-resolve": "^15.2.3", | ||
"@rollup/plugin-typescript": "^11.1.6", | ||
"@types/jest": "^29.5.12", | ||
"@typescript-eslint/eslint-plugin": "^8.0.1", | ||
"@typescript-eslint/parser": "^8.0.1", | ||
"@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", | ||
"babel-plugin-annotate-pure-calls": "^0.4.0", | ||
"babel-plugin-polyfill-regenerator": "^0.6.2", | ||
"eslint": "^8.57.0", | ||
"eslint-plugin-import": "^2.29.1", | ||
"eslint-plugin-jest": "^28.6.0", | ||
"eslint": "^9.11.1", | ||
"eslint-plugin-import": "^2.31.0", | ||
"globby": "^11.1.0", | ||
"jest": "^29.7.0", | ||
"prettier": "^3.3.3", | ||
"rollup": "^4.19.1", | ||
"rollup-plugin-delete": "^2.0.0", | ||
"rollup": "^4.22.5", | ||
"rollup-plugin-delete": "^2.1.0", | ||
"rollup-plugin-dts": "^6.1.1", | ||
"ts-jest": "^29.2.3", | ||
"tslib": "^2.6.3", | ||
"typescript": "^5.5.4", | ||
"zx": "^8.1.4" | ||
"tslib": "^2.7.0", | ||
"typescript": "^5.6.2", | ||
"typescript-eslint": "^8.8.0", | ||
"vitest": "^2.1.1", | ||
"zx": "^8.1.8" | ||
}, | ||
@@ -90,0 +90,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.1/assets/logo.svg" alt="tailwind-merge" height="150px" /> | ||
<img src="https://github.com/dcastil/tailwind-merge/raw/0a98923c58279779d59c38c03f5ddd385a764751/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.1/docs/what-is-it-for.md) | ||
- [When and how to use it](https://github.com/dcastil/tailwind-merge/tree/v2.5.1/docs/when-and-how-to-use-it.md) | ||
- [Features](https://github.com/dcastil/tailwind-merge/tree/v2.5.1/docs/features.md) | ||
- [Limitations](https://github.com/dcastil/tailwind-merge/tree/v2.5.1/docs/limitations.md) | ||
- [Configuration](https://github.com/dcastil/tailwind-merge/tree/v2.5.1/docs/configuration.md) | ||
- [Recipes](https://github.com/dcastil/tailwind-merge/tree/v2.5.1/docs/recipes.md) | ||
- [API reference](https://github.com/dcastil/tailwind-merge/tree/v2.5.1/docs/api-reference.md) | ||
- [Writing plugins](https://github.com/dcastil/tailwind-merge/tree/v2.5.1/docs/writing-plugins.md) | ||
- [Versioning](https://github.com/dcastil/tailwind-merge/tree/v2.5.1/docs/versioning.md) | ||
- [Contributing](https://github.com/dcastil/tailwind-merge/tree/v2.5.1/docs/contributing.md) | ||
- [Similar packages](https://github.com/dcastil/tailwind-merge/tree/v2.5.1/docs/similar-packages.md) | ||
- [What is it for](https://github.com/dcastil/tailwind-merge/tree/0a98923c58279779d59c38c03f5ddd385a764751/docs/what-is-it-for.md) | ||
- [When and how to use it](https://github.com/dcastil/tailwind-merge/tree/0a98923c58279779d59c38c03f5ddd385a764751/docs/when-and-how-to-use-it.md) | ||
- [Features](https://github.com/dcastil/tailwind-merge/tree/0a98923c58279779d59c38c03f5ddd385a764751/docs/features.md) | ||
- [Limitations](https://github.com/dcastil/tailwind-merge/tree/0a98923c58279779d59c38c03f5ddd385a764751/docs/limitations.md) | ||
- [Configuration](https://github.com/dcastil/tailwind-merge/tree/0a98923c58279779d59c38c03f5ddd385a764751/docs/configuration.md) | ||
- [Recipes](https://github.com/dcastil/tailwind-merge/tree/0a98923c58279779d59c38c03f5ddd385a764751/docs/recipes.md) | ||
- [API reference](https://github.com/dcastil/tailwind-merge/tree/0a98923c58279779d59c38c03f5ddd385a764751/docs/api-reference.md) | ||
- [Writing plugins](https://github.com/dcastil/tailwind-merge/tree/0a98923c58279779d59c38c03f5ddd385a764751/docs/writing-plugins.md) | ||
- [Versioning](https://github.com/dcastil/tailwind-merge/tree/0a98923c58279779d59c38c03f5ddd385a764751/docs/versioning.md) | ||
- [Contributing](https://github.com/dcastil/tailwind-merge/tree/0a98923c58279779d59c38c03f5ddd385a764751/docs/contributing.md) | ||
- [Similar packages](https://github.com/dcastil/tailwind-merge/tree/0a98923c58279779d59c38c03f5ddd385a764751/docs/similar-packages.md) |
import { ConfigUtils } from './config-utils' | ||
import { IMPORTANT_MODIFIER, sortModifiers } from './parse-class-name' | ||
const SPLIT_CLASSES_REGEX = /\s+/ | ||
export const mergeClassList = (classList: string, configUtils: ConfigUtils) => { | ||
@@ -15,20 +17,9 @@ const { parseClassName, getClassGroupId, getConflictingClassGroupIds } = configUtils | ||
const classGroupsInConflict: string[] = [] | ||
const classNames = classList.trim().split(SPLIT_CLASSES_REGEX) | ||
let result = '' | ||
let index = classList.length - 1 | ||
while (index >= 0) { | ||
while (classList[index] === ' ') { | ||
index -= 1 | ||
} | ||
for (let index = classNames.length - 1; index >= 0; index -= 1) { | ||
const originalClassName = classNames[index]! | ||
if (index < 0) { | ||
break | ||
} | ||
const nextIndex = classList.lastIndexOf(' ', index) | ||
const originalClassName = classList.slice(nextIndex + 1, index + 1) | ||
index = nextIndex | ||
const { modifiers, hasImportantModifier, baseClassName, maybePostfixModifierPosition } = | ||
@@ -46,2 +37,3 @@ parseClassName(originalClassName) | ||
if (!hasPostfixModifier) { | ||
// Not a Tailwind class | ||
result = originalClassName + (result.length > 0 ? ' ' + result : result) | ||
@@ -54,2 +46,3 @@ continue | ||
if (!classGroupId) { | ||
// Not a Tailwind class | ||
result = originalClassName + (result.length > 0 ? ' ' + result : result) | ||
@@ -71,2 +64,3 @@ continue | ||
if (classGroupsInConflict.includes(classId)) { | ||
// Tailwind class omitted due to conflict | ||
continue | ||
@@ -83,2 +77,3 @@ } | ||
// Tailwind class not in conflict | ||
result = originalClassName + (result.length > 0 ? ' ' + result : result) | ||
@@ -85,0 +80,0 @@ } |
@@ -213,4 +213,6 @@ export interface Config<ClassGroupIds extends string, ThemeGroupIds extends string> | ||
| 'border-color-b' | ||
| 'border-color-e' | ||
| 'border-color-l' | ||
| 'border-color-r' | ||
| 'border-color-s' | ||
| 'border-color-t' | ||
@@ -217,0 +219,0 @@ | 'border-color-x' |
Sorry, the diff of this file is too big to display
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
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
Sorry, the diff of this file is too big to display
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
712654
22
15596
1