tailwind_merge 0.11.0 → 0.12.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +19 -0
- data/README.md +1 -1
- data/lib/tailwind_merge/config.rb +6 -8
- data/lib/tailwind_merge/version.rb +1 -1
- data/lib/tailwind_merge.rb +38 -39
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7bd029b3106698874b67142336e597f9369c92664531879ad22eedd0cba6645b
|
4
|
+
data.tar.gz: 5389d8adf19d10d5f4edd08bff8cfd94f23e8ce65f6893400b0a8416de629faa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2236d20be8ac16e9fb1ee61682c00d8cc00a8102a1f12ef6ab2d56bd9829a041feb08e5448ebcf09e7940a43b3d6ca512ce0f381bdd006275302167c245700b1
|
7
|
+
data.tar.gz: aa34f52e7f697c8b1c01d3bead20a4868393f054dfbf9dbb7595d842d3883c26c23e1039dc6b14cd309671b198f6751181465478f246f5b609acf628694de861
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,22 @@
|
|
1
|
+
# [v0.12.2] - 18-08-2024
|
2
|
+
## What's Changed
|
3
|
+
* remove spurious debug statement by @gjtorikian in https://github.com/gjtorikian/tailwind_merge/pull/28
|
4
|
+
* Port over latest updates + bugfixes by @gjtorikian in https://github.com/gjtorikian/tailwind_merge/pull/29
|
5
|
+
|
6
|
+
|
7
|
+
**Full Changelog**: https://github.com/gjtorikian/tailwind_merge/compare/v0.12.0...v0.12.2
|
8
|
+
## [v0.12.0] - 25-04-2024
|
9
|
+
## What's Changed
|
10
|
+
* Add support for mix-blend-plus-darker utility by @gjtorikian in https://github.com/gjtorikian/tailwind_merge/pull/27
|
11
|
+
|
12
|
+
|
13
|
+
**Full Changelog**: https://github.com/gjtorikian/tailwind_merge/compare/v0.11.0...v0.12.0
|
14
|
+
## [v0.11.0] - 26-03-2024
|
15
|
+
## What's Changed
|
16
|
+
* Support accepting an array of strings by @gjtorikian in https://github.com/gjtorikian/tailwind_merge/pull/26
|
17
|
+
|
18
|
+
|
19
|
+
**Full Changelog**: https://github.com/gjtorikian/tailwind_merge/compare/v0.10.2...v0.11.0
|
1
20
|
## [v0.10.2] - 18-03-2024
|
2
21
|
## What's Changed
|
3
22
|
* Support shadow with by @gjtorikian in https://github.com/gjtorikian/tailwind_merge/pull/25
|
data/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Utility function to efficiently merge [Tailwind CSS](https://tailwindcss.com/) classes without style conflicts. Essentially, a Ruby port of [tailwind-merge](https://github.com/dcastil/tailwind-merge).
|
4
4
|
|
5
|
-
Supports Tailwind v3.0 up to v3.
|
5
|
+
Supports Tailwind v3.0 up to v3.4.
|
6
6
|
|
7
7
|
## Installation
|
8
8
|
|
@@ -100,13 +100,11 @@ module TailwindMerge
|
|
100
100
|
"saturation",
|
101
101
|
"color",
|
102
102
|
"luminosity",
|
103
|
-
"plus-lighter",
|
104
103
|
]
|
105
104
|
}
|
106
105
|
ALIGN = -> { ["start", "end", "center", "between", "around", "evenly", "stretch"] }
|
107
106
|
ZERO_AND_EMPTY = -> { ["", "0", IS_ARBITRARY_VALUE] }
|
108
107
|
BREAKS = -> { ["auto", "avoid", "all", "avoid-page", "page", "left", "right", "column"] }
|
109
|
-
NUMBER = -> { [IS_NUMBER, IS_ARBITRARY_NUMBER] }
|
110
108
|
NUMBER_AND_ARBITRARY = -> { [IS_NUMBER, IS_ARBITRARY_VALUE] }
|
111
109
|
|
112
110
|
DEFAULTS = {
|
@@ -116,12 +114,12 @@ module TailwindMerge
|
|
116
114
|
"colors" => [IS_ANY],
|
117
115
|
"spacing" => [IS_LENGTH, IS_ARBITRARY_LENGTH],
|
118
116
|
"blur" => ["none", "", IS_TSHIRT_SIZE, IS_ARBITRARY_VALUE],
|
119
|
-
"brightness" =>
|
117
|
+
"brightness" => NUMBER_AND_ARBITRARY.call,
|
120
118
|
"border-color" => [COLORS],
|
121
119
|
"border-radius" => ["none", "", "full", IS_TSHIRT_SIZE, IS_ARBITRARY_VALUE],
|
122
120
|
"border-spacing" => SPACING_WITH_ARBITRARY.call,
|
123
121
|
"border-width" => LENGTH_WITH_EMPTY_AND_ARBITRARY.call,
|
124
|
-
"contrast" =>
|
122
|
+
"contrast" => NUMBER_AND_ARBITRARY.call,
|
125
123
|
"grayscale" => ZERO_AND_EMPTY.call,
|
126
124
|
"hue-rotate" => NUMBER_AND_ARBITRARY.call,
|
127
125
|
"invert" => ZERO_AND_EMPTY.call,
|
@@ -130,10 +128,10 @@ module TailwindMerge
|
|
130
128
|
"gradient-color-stop-positions" => [IS_PERCENT, IS_ARBITRARY_LENGTH],
|
131
129
|
"inset" => SPACING_WITH_AUTO_AND_ARBITRARY.call,
|
132
130
|
"margin" => SPACING_WITH_AUTO_AND_ARBITRARY.call,
|
133
|
-
"opacity" =>
|
131
|
+
"opacity" => NUMBER_AND_ARBITRARY.call,
|
134
132
|
"padding" => SPACING_WITH_ARBITRARY.call,
|
135
|
-
"saturate" =>
|
136
|
-
"scale" =>
|
133
|
+
"saturate" => NUMBER_AND_ARBITRARY.call,
|
134
|
+
"scale" => NUMBER_AND_ARBITRARY.call,
|
137
135
|
"sepia" => ZERO_AND_EMPTY.call,
|
138
136
|
"skew" => NUMBER_AND_ARBITRARY.call,
|
139
137
|
"space" => SPACING_WITH_ARBITRARY.call,
|
@@ -1230,7 +1228,7 @@ module TailwindMerge
|
|
1230
1228
|
# Mix Blend Mode
|
1231
1229
|
# @see https://tailwindcss.com/docs/mix-blend-mode
|
1232
1230
|
##
|
1233
|
-
"mix-blend" => [{ "mix-blend" => BLEND_MODES.call }],
|
1231
|
+
"mix-blend" => [{ "mix-blend" => BLEND_MODES.call.push("plus-lighter", "plus-darker") }],
|
1234
1232
|
##
|
1235
1233
|
# Background Blend Mode
|
1236
1234
|
# @see https://tailwindcss.com/docs/background-blend-mode
|
data/lib/tailwind_merge.rb
CHANGED
@@ -1,8 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
if ENV.fetch("DEBUG", false)
|
4
|
-
require "amazing_print"
|
5
4
|
require "debug"
|
5
|
+
begin
|
6
|
+
require "amazing_print"
|
7
|
+
rescue LoadError # rubocop:disable Lint/SuppressedException
|
8
|
+
end
|
6
9
|
end
|
7
10
|
|
8
11
|
require "lru_redux"
|
@@ -44,15 +47,24 @@ module TailwindMerge
|
|
44
47
|
end
|
45
48
|
end
|
46
49
|
|
47
|
-
private def merge_class_list(
|
50
|
+
private def merge_class_list(class_list)
|
48
51
|
# Set of class_group_ids in following format:
|
49
52
|
# `{importantModifier}{variantModifiers}{classGroupId}`
|
50
53
|
# @example 'float'
|
51
54
|
# @example 'hover:focus:bg-color'
|
52
55
|
# @example 'md:!pr'
|
53
|
-
class_groups_in_conflict =
|
56
|
+
class_groups_in_conflict = []
|
57
|
+
class_names = class_list.strip.split(SPLIT_CLASSES_REGEX)
|
58
|
+
|
59
|
+
result = ""
|
60
|
+
|
61
|
+
i = class_names.length - 1
|
62
|
+
|
63
|
+
loop do
|
64
|
+
break if i < 0
|
65
|
+
|
66
|
+
original_class_name = class_names[i]
|
54
67
|
|
55
|
-
classes.strip.split(SPLIT_CLASSES_REGEX).map do |original_class_name|
|
56
68
|
modifiers, has_important_modifier, base_class_name, maybe_postfix_modifier_position = split_modifiers(original_class_name, separator: @config[:separator])
|
57
69
|
|
58
70
|
actual_base_class_name = maybe_postfix_modifier_position ? base_class_name[0...maybe_postfix_modifier_position] : base_class_name
|
@@ -60,61 +72,48 @@ module TailwindMerge
|
|
60
72
|
|
61
73
|
unless class_group_id
|
62
74
|
unless maybe_postfix_modifier_position
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
75
|
+
# not a Tailwind class
|
76
|
+
result = original_class_name + (!result.empty? ? " " + result : result)
|
77
|
+
i -= 1
|
78
|
+
next
|
67
79
|
end
|
68
80
|
|
69
81
|
class_group_id = @class_utils.class_group_id(base_class_name)
|
70
82
|
|
71
83
|
unless class_group_id
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
84
|
+
# not a Tailwind class
|
85
|
+
result = original_class_name + (!result.empty? ? " " + result : result)
|
86
|
+
i -= 1
|
87
|
+
next
|
77
88
|
end
|
78
89
|
|
79
90
|
has_postfix_modifier = false
|
80
|
-
|
81
|
-
next {
|
82
|
-
is_tailwind_class: false,
|
83
|
-
original_class_name: original_class_name,
|
84
|
-
}
|
85
91
|
end
|
86
92
|
|
87
93
|
variant_modifier = sort_modifiers(modifiers).join(":")
|
88
94
|
|
89
95
|
modifier_id = has_important_modifier ? "#{variant_modifier}#{IMPORTANT_MODIFIER}" : variant_modifier
|
90
|
-
|
91
|
-
{
|
92
|
-
is_tailwind_class: true,
|
93
|
-
modifier_id: modifier_id,
|
94
|
-
class_group_id: class_group_id,
|
95
|
-
original_class_name: original_class_name,
|
96
|
-
has_postfix_modifier: has_postfix_modifier,
|
97
|
-
}
|
98
|
-
end.reverse # Last class in conflict wins, so filter conflicting classes in reverse order.
|
99
|
-
.select do |parsed|
|
100
|
-
next(true) unless parsed[:is_tailwind_class]
|
101
|
-
|
102
|
-
modifier_id = parsed[:modifier_id]
|
103
|
-
class_group_id = parsed[:class_group_id]
|
104
|
-
has_postfix_modifier = parsed[:has_postfix_modifier]
|
105
|
-
|
106
96
|
class_id = "#{modifier_id}#{class_group_id}"
|
107
97
|
|
108
|
-
|
98
|
+
# Tailwind class omitted due to pre-existing conflict
|
99
|
+
if class_groups_in_conflict.include?(class_id)
|
100
|
+
i -= 1
|
101
|
+
next
|
102
|
+
end
|
109
103
|
|
110
|
-
class_groups_in_conflict.
|
104
|
+
class_groups_in_conflict.push(class_id)
|
111
105
|
|
112
106
|
@class_utils.get_conflicting_class_group_ids(class_group_id, has_postfix_modifier).each do |group|
|
113
|
-
class_groups_in_conflict.
|
107
|
+
class_groups_in_conflict.push("#{modifier_id}#{group}")
|
114
108
|
end
|
115
109
|
|
116
|
-
|
117
|
-
|
110
|
+
# no conflict!
|
111
|
+
result = original_class_name + (!result.empty? ? " " + result : result)
|
112
|
+
|
113
|
+
i -= 1
|
114
|
+
end
|
115
|
+
|
116
|
+
result
|
118
117
|
end
|
119
118
|
end
|
120
119
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tailwind_merge
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.12.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Garen J. Torikian
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-08-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: lru_redux
|