tailwind_merge 0.8.1 → 0.9.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 631245d88b1aff92448e4322e4a7f6296e5bcaacecede5b713fe797b088dc130
4
- data.tar.gz: b124e90880aea18b42eb236564df4062336b5d1fe6a8b674f2fa29954b910642
3
+ metadata.gz: 671c8c7c69b02946b8df9ffa5a07211e5a00ad564aefc81927d5653a5b77e9a3
4
+ data.tar.gz: 890d2ed86cb560af7245b40efb9275fc4eefa6b3458dd46170dfc4e41263e5fb
5
5
  SHA512:
6
- metadata.gz: 968b476bdc24e2f7058001f7b4b75838b8c5189a039b54fbcde7c25478ce87fbb0afe9aa47d9d230977997cf2589bb8d03fe2560d8dae6a6345c64b7d771ccbc
7
- data.tar.gz: 80f3e903482e85bc576841b9d29657778572f54da4381e21bd0e55ea8d46efc0e6f4e5a0f4a5f0e1153c924691dd3b7b4793891fcc9a9d90999a1febefb86709
6
+ metadata.gz: 58ddfe25ea801d1a480aebc2c065ee1cf74886b2e2c37a1a1c1ade85d0c88ff11500650152b7e0bb8591736f87493ee99f0e34ae1001244b824c6670e60fbf2f
7
+ data.tar.gz: 181f01df6b0f03e8ec24545c3d2397420c5a8872f3fc0ac7b3522a632b55dd75afdd144f329444dd75fe52cf97e4cca47e5bf0a78301b2c36d7b09e762b04623
data/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ ## [v0.9.0] - 04-11-2023
2
+ ## What's Changed
3
+ * Updates by @gjtorikian in https://github.com/gjtorikian/tailwind_merge/pull/21
4
+
5
+
6
+ **Full Changelog**: https://github.com/gjtorikian/tailwind_merge/compare/v0.8.1...v0.9.0
7
+ ## [v0.8.1] - 19-09-2023
8
+ **Full Changelog**: https://github.com/gjtorikian/tailwind_merge/compare/v0.8.0...v0.8.1
1
9
  ## [v0.8.0] - 19-09-2023
2
10
  ## What's Changed
3
11
  * Add clarifications to README by @borama in https://github.com/gjtorikian/tailwind_merge/pull/17
data/README.md CHANGED
@@ -51,7 +51,7 @@ tailwind-merge overrides conflicting classes and keeps everything else untouched
51
51
 
52
52
  ### Merging behavior
53
53
 
54
- `tailwind_merge` is designed to be predictable and intuitive. It follows a set of rules to determine which class "wins" when there are conflicts. Here is a brief overview of the conflict resolutions which `tailwind_merge` can do.
54
+ `tailwind_merge` is built to be intuitive. It follows a set of rules to determine which class wins when there are conflicts. Here is a brief overview of its conflict resolution.
55
55
 
56
56
  ### Last conflicting class wins
57
57
 
@@ -305,9 +305,9 @@ If you modified one of these theme scales in your Tailwind config, you can add a
305
305
 
306
306
  Here's a brief summary for each validator:
307
307
 
308
- - `IS_LENGTH` checks whether a class part is a number (`3`, `1.5`), a fraction (`3/4`), a arbitrary length (`[3%]`, `[4px]`, `[length:var(--my-var)]`), or one of the strings `px`, `full` or `screen`.
308
+ - `IS_LENGTH` checks whether a class part is a number (`3`, `1.5`), a fraction (`3/4`), or one of the strings `px`, `full` or `screen`.
309
309
  - `IS_ARBITRARY_LENGTH` checks for arbitrary length values (`[3%]`, `[4px]`, `[length:var(--my-var)]`).
310
- - `IS_INTEGER` checks for integer values (`3`) and arbitrary integer values (`[3]`).
310
+ - `IS_INTEGER` checks for integer values (`3`).
311
311
  - `IS_PERCENT` checks for percent values (`12.5%`) which is used for color stop positions.
312
312
  - `IS_ARBITRARY_VALUE` checks whether the class part is enclosed in brackets (`[something]`)
313
313
  - `IS_TSHIRT_SIZE`checks whether class part is a T-shirt size (`sm`, `xl`), optionally with a preceding number (`2xl`).
@@ -66,7 +66,7 @@ module TailwindMerge
66
66
  OVERFLOW = -> { ["auto", "hidden", "clip", "visible", "scroll"] }
67
67
  SPACING_WITH_AUTO_AND_ARBITRARY = -> { ["auto", IS_ARBITRARY_VALUE, SPACING] }
68
68
  SPACING_WITH_ARBITRARY = -> { [IS_ARBITRARY_VALUE, SPACING] }
69
- LENGTH_WITH_EMPTY = -> { ["", IS_LENGTH] }
69
+ LENGTH_WITH_EMPTY_AND_ARBITRARY = -> { ["", IS_LENGTH, IS_ARBITRARY_LENGTH] }
70
70
  NUMBER_WITH_AUTO_AND_ARBITRARY = -> { ["auto", IS_NUMBER, IS_ARBITRARY_VALUE] }
71
71
  POSITIONS = -> {
72
72
  [
@@ -114,13 +114,13 @@ module TailwindMerge
114
114
  separator: ":",
115
115
  theme: {
116
116
  "colors" => [IS_ANY],
117
- "spacing" => [IS_LENGTH],
117
+ "spacing" => [IS_LENGTH, IS_ARBITRARY_LENGTH],
118
118
  "blur" => ["none", "", IS_TSHIRT_SIZE, IS_ARBITRARY_VALUE],
119
119
  "brightness" => NUMBER.call,
120
120
  "border-color" => [COLORS],
121
121
  "border-radius" => ["none", "", "full", IS_TSHIRT_SIZE, IS_ARBITRARY_VALUE],
122
122
  "border-spacing" => SPACING_WITH_ARBITRARY.call,
123
- "border-width" => LENGTH_WITH_EMPTY.call,
123
+ "border-width" => LENGTH_WITH_EMPTY_AND_ARBITRARY.call,
124
124
  "contrast" => NUMBER.call,
125
125
  "grayscale" => ZERO_AND_EMPTY.call,
126
126
  "hue-rotate" => NUMBER_AND_ARBITRARY.call,
@@ -322,7 +322,7 @@ module TailwindMerge
322
322
  # Z-Index
323
323
  # @see https://tailwindcss.com/docs/z-index
324
324
  ##
325
- "z" => [{ "z" => ["auto", IS_INTEGER] }],
325
+ "z" => [{ "z" => ["auto", IS_INTEGER, IS_ARBITRARY_VALUE] }],
326
326
  # Flexbox and Grid
327
327
  ##
328
328
  # Flex Basis
@@ -358,7 +358,7 @@ module TailwindMerge
358
358
  # Order
359
359
  # @see https://tailwindcss.com/docs/order
360
360
  ##
361
- "order" => [{ "order" => ["first", "last", "none", IS_INTEGER] }],
361
+ "order" => [{ "order" => ["first", "last", "none", IS_INTEGER, IS_ARBITRARY_VALUE] }],
362
362
  ##
363
363
  # Grid Template Columns
364
364
  # @see https://tailwindcss.com/docs/grid-template-columns
@@ -368,7 +368,7 @@ module TailwindMerge
368
368
  # Grid Column Start / End
369
369
  # @see https://tailwindcss.com/docs/grid-column
370
370
  ##
371
- "col-start-end" => [{ "col" => ["auto", { "span" => ["full", IS_INTEGER] }, IS_ARBITRARY_VALUE] }],
371
+ "col-start-end" => [{ "col" => ["auto", { "span" => ["full", IS_INTEGER, IS_ARBITRARY_VALUE] }, IS_ARBITRARY_VALUE] }],
372
372
 
373
373
  ##
374
374
  # Grid Column Start
@@ -389,7 +389,7 @@ module TailwindMerge
389
389
  # Grid Row Start / End
390
390
  # @see https://tailwindcss.com/docs/grid-row
391
391
  ##
392
- "row-start-end" => [{ "row" => ["auto", { "span" => [IS_INTEGER] }] }],
392
+ "row-start-end" => [{ "row" => ["auto", { "span" => [IS_INTEGER, IS_ARBITRARY_VALUE] }, IS_ARBITRARY_VALUE] }],
393
393
  ##
394
394
  # Grid Row Start
395
395
  # @see https://tailwindcss.com/docs/grid-row
@@ -626,7 +626,7 @@ module TailwindMerge
626
626
  # Min-Height
627
627
  # @see https://tailwindcss.com/docs/min-height
628
628
  ##
629
- "min-h" => [{ "min-h" => ["min", "max", "fit", IS_ARBITRARY_VALUE, IS_LENGTH] }],
629
+ "min-h" => [{ "min-h" => ["min", "max", "fit", IS_LENGTH, IS_ARBITRARY_VALUE] }],
630
630
  ##
631
631
  # Max-Height
632
632
  # @see https://tailwindcss.com/docs/max-height
@@ -730,7 +730,7 @@ module TailwindMerge
730
730
  # @see https://tailwindcss.com/docs/line-height
731
731
  ##
732
732
  "leading" => [
733
- { "leading" => ["none", "tight", "snug", "normal", "relaxed", "loose", IS_ARBITRARY_VALUE, IS_LENGTH] },
733
+ { "leading" => ["none", "tight", "snug", "normal", "relaxed", "loose", IS_LENGTH, IS_ARBITRARY_VALUE] },
734
734
  ],
735
735
  #
736
736
  # List Style Image
@@ -787,12 +787,12 @@ module TailwindMerge
787
787
  # Text Decoration Thickness
788
788
  # @see https://tailwindcss.com/docs/text-decoration-thickness
789
789
  ##
790
- "text-decoration-thickness" => [{ "decoration" => ["auto", "from-font", IS_LENGTH] }],
790
+ "text-decoration-thickness" => [{ "decoration" => ["auto", "from-font", IS_LENGTH, IS_ARBITRARY_LENGTH] }],
791
791
  ##
792
792
  # Text Underline Offset
793
793
  # @see https://tailwindcss.com/docs/text-underline-offset
794
794
  ##
795
- "underline-offset" => [{ "underline-offset" => ["auto", IS_ARBITRARY_VALUE, IS_LENGTH] }],
795
+ "underline-offset" => [{ "underline-offset" => ["auto", IS_LENGTH, IS_ARBITRARY_VALUE] }],
796
796
  ##
797
797
  # Text Decoration Color
798
798
  # @see https://tailwindcss.com/docs/text-decoration-color
@@ -1147,12 +1147,12 @@ module TailwindMerge
1147
1147
  # Outline Offset
1148
1148
  # @see https://tailwindcss.com/docs/outline-offset
1149
1149
  ##
1150
- "outline-offset" => [{ "outline-offset" => [IS_ARBITRARY_VALUE, IS_LENGTH] }],
1150
+ "outline-offset" => [{ "outline-offset" => [IS_LENGTH, IS_ARBITRARY_VALUE] }],
1151
1151
  ##
1152
1152
  # Outline Width
1153
1153
  # @see https://tailwindcss.com/docs/outline-width
1154
1154
  ##
1155
- "outline-w" => [{ "outline" => [IS_LENGTH] }],
1155
+ "outline-w" => [{ "outline" => [IS_LENGTH, IS_ARBITRARY_LENGTH] }],
1156
1156
  ##
1157
1157
  # Outline Color
1158
1158
  # @see https://tailwindcss.com/docs/outline-color
@@ -1162,7 +1162,7 @@ module TailwindMerge
1162
1162
  # Ring Width
1163
1163
  # @see https://tailwindcss.com/docs/ring-width
1164
1164
  ##
1165
- "ring-w" => [{ "ring" => LENGTH_WITH_EMPTY.call }],
1165
+ "ring-w" => [{ "ring" => LENGTH_WITH_EMPTY_AND_ARBITRARY.call }],
1166
1166
  ##
1167
1167
  # Ring Width Inset
1168
1168
  # @see https://tailwindcss.com/docs/ring-width
@@ -1182,7 +1182,7 @@ module TailwindMerge
1182
1182
  # Ring Offset Width
1183
1183
  # @see https://tailwindcss.com/docs/ring-offset-width
1184
1184
  ##
1185
- "ring-offset-w" => [{ "ring-offset" => [IS_LENGTH] }],
1185
+ "ring-offset-w" => [{ "ring-offset" => [IS_LENGTH, IS_ARBITRARY_LENGTH] }],
1186
1186
  ##
1187
1187
  # Ring Offset Color
1188
1188
  # @see https://tailwindcss.com/docs/ring-offset-color
@@ -1695,7 +1695,7 @@ module TailwindMerge
1695
1695
  # Stroke Width
1696
1696
  # @see https://tailwindcss.com/docs/stroke-width
1697
1697
  ##
1698
- "stroke-w" => [{ "stroke" => [IS_LENGTH, IS_ARBITRARY_NUMBER] }],
1698
+ "stroke-w" => [{ "stroke" => [IS_LENGTH, IS_ARBITRARY_LENGTH, IS_ARBITRARY_NUMBER] }],
1699
1699
  ##
1700
1700
  # Stroke
1701
1701
  # @see https://tailwindcss.com/docs/stroke
@@ -1735,6 +1735,7 @@ module TailwindMerge
1735
1735
  "fvn-figure" => ["fvn-normal"],
1736
1736
  "fvn-spacing" => ["fvn-normal"],
1737
1737
  "fvn-fraction" => ["fvn-normal"],
1738
+ "line-clamp" => ["display", "overflow"],
1738
1739
  "rounded" => [
1739
1740
  "rounded-s",
1740
1741
  "rounded-e",
@@ -63,26 +63,13 @@ module TailwindMerge
63
63
  IS_LENGTH = ->(value) {
64
64
  numeric?(value) ||
65
65
  STRING_LENGTHS.include?(value) ||
66
- FRACTION_REGEX.match?(value) ||
67
- IS_ARBITRARY_LENGTH.call(value)
66
+ FRACTION_REGEX.match?(value)
68
67
  }
69
68
 
70
69
  IS_ARBITRARY_LENGTH = ->(value) {
71
70
  arbitrary_value?(value, "length", is_length_only)
72
71
  }
73
72
 
74
- IS_ARBITRARY_SIZE = ->(value) {
75
- arbitrary_value?(value, SIZE_LABELS, is_never)
76
- }
77
-
78
- IS_ARBITRARY_POSITION = ->(value) {
79
- arbitrary_value?(value, "position", is_never)
80
- }
81
-
82
- IS_ARBITRARY_IMAGE = ->(value) {
83
- arbitrary_value?(value, IMAGE_LABELS, is_image)
84
- }
85
-
86
73
  IS_ARBITRARY_NUMBER = ->(value) {
87
74
  arbitrary_value?(value, "number", is_number)
88
75
  }
@@ -91,26 +78,38 @@ module TailwindMerge
91
78
  is_number.call(value)
92
79
  }
93
80
 
94
- IS_PERCENT = ->(value) {
95
- value.end_with?("%") && is_number.call(value[0..-2])
81
+ IS_INTEGER = ->(value) {
82
+ is_integer_only.call(value)
96
83
  }
97
84
 
98
- IS_INTEGER = ->(value) {
99
- is_integer_only.call(value) || arbitrary_value?(value, "number", is_integer_only)
85
+ IS_PERCENT = ->(value) {
86
+ value.end_with?("%") && is_number.call(value[0..-2])
100
87
  }
101
88
 
102
89
  IS_ARBITRARY_VALUE = ->(value) {
103
90
  ARBITRARY_VALUE_REGEX.match(value)
104
91
  }
105
92
 
106
- IS_ANY = ->(_) { return true }
107
-
108
93
  IS_TSHIRT_SIZE = ->(value) {
109
94
  TSHIRT_UNIT_REGEX.match?(value)
110
95
  }
111
96
 
97
+ IS_ARBITRARY_SIZE = ->(value) {
98
+ arbitrary_value?(value, SIZE_LABELS, is_never)
99
+ }
100
+
101
+ IS_ARBITRARY_POSITION = ->(value) {
102
+ arbitrary_value?(value, "position", is_never)
103
+ }
104
+
105
+ IS_ARBITRARY_IMAGE = ->(value) {
106
+ arbitrary_value?(value, IMAGE_LABELS, is_image)
107
+ }
108
+
112
109
  IS_ARBITRARY_SHADOW = ->(value) {
113
110
  arbitrary_value?(value, "", is_shadow)
114
111
  }
112
+
113
+ IS_ANY = ->(_) { return true }
115
114
  end
116
115
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module TailwindMerge
4
- VERSION = "0.8.1"
4
+ VERSION = "0.9.1"
5
5
  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.8.1
4
+ version: 0.9.1
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: 2023-09-19 00:00:00.000000000 Z
11
+ date: 2023-11-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: lru_redux
@@ -99,7 +99,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
99
99
  - !ruby/object:Gem::Version
100
100
  version: '0'
101
101
  requirements: []
102
- rubygems_version: 3.4.19
102
+ rubygems_version: 3.4.22
103
103
  signing_key:
104
104
  specification_version: 4
105
105
  summary: Utility function to efficiently merge Tailwind CSS classes without style