tailwind-merge
Advanced tools
Comparing version 2.5.1 to 2.5.2-dev.a72f2f474fbba41c9940d3c9737cd3ad431d68da
{ | ||
"name": "tailwind-merge", | ||
"version": "2.5.1", | ||
"version": "2.5.2-dev.a72f2f474fbba41c9940d3c9737cd3ad431d68da", | ||
"description": "Merge Tailwind CSS classes without style conflicts", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -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/a72f2f474fbba41c9940d3c9737cd3ad431d68da/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/a72f2f474fbba41c9940d3c9737cd3ad431d68da/docs/what-is-it-for.md) | ||
- [When and how to use it](https://github.com/dcastil/tailwind-merge/tree/a72f2f474fbba41c9940d3c9737cd3ad431d68da/docs/when-and-how-to-use-it.md) | ||
- [Features](https://github.com/dcastil/tailwind-merge/tree/a72f2f474fbba41c9940d3c9737cd3ad431d68da/docs/features.md) | ||
- [Limitations](https://github.com/dcastil/tailwind-merge/tree/a72f2f474fbba41c9940d3c9737cd3ad431d68da/docs/limitations.md) | ||
- [Configuration](https://github.com/dcastil/tailwind-merge/tree/a72f2f474fbba41c9940d3c9737cd3ad431d68da/docs/configuration.md) | ||
- [Recipes](https://github.com/dcastil/tailwind-merge/tree/a72f2f474fbba41c9940d3c9737cd3ad431d68da/docs/recipes.md) | ||
- [API reference](https://github.com/dcastil/tailwind-merge/tree/a72f2f474fbba41c9940d3c9737cd3ad431d68da/docs/api-reference.md) | ||
- [Writing plugins](https://github.com/dcastil/tailwind-merge/tree/a72f2f474fbba41c9940d3c9737cd3ad431d68da/docs/writing-plugins.md) | ||
- [Versioning](https://github.com/dcastil/tailwind-merge/tree/a72f2f474fbba41c9940d3c9737cd3ad431d68da/docs/versioning.md) | ||
- [Contributing](https://github.com/dcastil/tailwind-merge/tree/a72f2f474fbba41c9940d3c9737cd3ad431d68da/docs/contributing.md) | ||
- [Similar packages](https://github.com/dcastil/tailwind-merge/tree/a72f2f474fbba41c9940d3c9737cd3ad431d68da/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 @@ } |
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
709166
15512
1