tailwind_merge 0.8.0 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e5402fe57c8b5f28ac07847bc17a04c6b5cd1ba9ad62ce945920759a95aece31
4
- data.tar.gz: 0ef6aad523beb48f559b70e6e88662e0db9df8269152d2ccdcb5d08b5f96801b
3
+ metadata.gz: 7d905f5929fbbcbe4a1b9b1f23360ca7d1e74fc388ad652c4a4e31b4bcb6443f
4
+ data.tar.gz: 4e8958d9d569b65a6426a3c1bf261fccc70e887f7ff9c776d3c2b14d30711221
5
5
  SHA512:
6
- metadata.gz: 568f47ffb9084553b5efc2b37dadcfdf1da552f698340f94bbbd6695618836213d4906b820370e55418350176d2d47c6f63dea5c5957efd34987b0a5ccb2cd4f
7
- data.tar.gz: f4656fe96ddfed6d74308733575503b33a69cecd9ff261cded4e60978e7a9927652afbd09a2ad0b02ea8988c6540730bc63cbec1edb4f782b5e14d04d4cbebe7
6
+ metadata.gz: 81befe07862ea9726ab174d4a5cc95c276166b35580250a495313ec670a49ffdf920d9143a05167578cf695f4a5b3b765783669e63c67339cd7c3e09ba9ee488
7
+ data.tar.gz: 29a9d62e4ed4ed10baed3fddf1feb66090008a6a5713733bb1cffb504c3942632a276138913c985a7a734b0be1e07ea3460556bc9cb9206321ad0ceab8612f2b
data/CHANGELOG.md CHANGED
@@ -1,3 +1,17 @@
1
+ ## [v0.8.1] - 19-09-2023
2
+ **Full Changelog**: https://github.com/gjtorikian/tailwind_merge/compare/v0.8.0...v0.8.1
3
+ ## [v0.8.0] - 19-09-2023
4
+ ## What's Changed
5
+ * Add clarifications to README by @borama in https://github.com/gjtorikian/tailwind_merge/pull/17
6
+ * Bump actions/checkout from 3 to 4 by @dependabot in https://github.com/gjtorikian/tailwind_merge/pull/18
7
+ * Update What's it for example in README by @borama in https://github.com/gjtorikian/tailwind_merge/pull/19
8
+ * Swap to using IMAGE, not URL by @gjtorikian in https://github.com/gjtorikian/tailwind_merge/pull/20
9
+
10
+ ## New Contributors
11
+ * @borama made their first contribution in https://github.com/gjtorikian/tailwind_merge/pull/17
12
+ * @dependabot made their first contribution in https://github.com/gjtorikian/tailwind_merge/pull/18
13
+
14
+ **Full Changelog**: https://github.com/gjtorikian/tailwind_merge/compare/v0.7.4...v0.8.0
1
15
  ## [v0.7.4] - 03-07-2023
2
16
  null
3
17
  ## [v0.7.3] - 26-06-2023
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
@@ -1647,16 +1647,33 @@ module TailwindMerge
1647
1647
  ##
1648
1648
  "touch" => [
1649
1649
  {
1650
- "touch" => [
1651
- "auto",
1652
- "none",
1653
- "pinch-zoom",
1654
- "manipulation",
1655
- { "pan" => ["x", "left", "right", "y", "up", "down"] },
1656
- ],
1650
+ "touch" => ["auto", "none", "manipulation"],
1651
+ },
1652
+ ],
1653
+ ##
1654
+ # Touch Action X
1655
+ # @see https://tailwindcss.com/docs/touch-action
1656
+ ##
1657
+ "touch-x" => [
1658
+ {
1659
+ "touch-pan" => ["x", "left", "right"],
1657
1660
  },
1658
1661
  ],
1659
1662
  ##
1663
+ # Touch Action Y
1664
+ # @see https://tailwindcss.com/docs/touch-action
1665
+ ##
1666
+ "touch-y" => [
1667
+ {
1668
+ "touch-pan" => ["y", "up", "down"],
1669
+ },
1670
+ ],
1671
+ ##
1672
+ # Touch Action Pinch Zoom
1673
+ # @see https://tailwindcss.com/docs/touch-action
1674
+ ##
1675
+ "touch-pz" => ["touch-pinch-zoom"],
1676
+ ##
1660
1677
  # User Select
1661
1678
  # @see https://tailwindcss.com/docs/user-select
1662
1679
  ##
@@ -1678,7 +1695,7 @@ module TailwindMerge
1678
1695
  # Stroke Width
1679
1696
  # @see https://tailwindcss.com/docs/stroke-width
1680
1697
  ##
1681
- "stroke-w" => [{ "stroke" => [IS_LENGTH, IS_ARBITRARY_NUMBER] }],
1698
+ "stroke-w" => [{ "stroke" => [IS_LENGTH, IS_ARBITRARY_LENGTH, IS_ARBITRARY_NUMBER] }],
1682
1699
  ##
1683
1700
  # Stroke
1684
1701
  # @see https://tailwindcss.com/docs/stroke
@@ -1783,6 +1800,10 @@ module TailwindMerge
1783
1800
  ],
1784
1801
  "scroll-px" => ["scroll-pr", "scroll-pl"],
1785
1802
  "scroll-py" => ["scroll-pt", "scroll-pb"],
1803
+ "touch" => ["touch-x", "touch-y", "touch-pz"],
1804
+ "touch-x" => ["touch"],
1805
+ "touch-y" => ["touch"],
1806
+ "touch-pz" => ["touch"],
1786
1807
  },
1787
1808
  conflicting_class_group_modifiers: {
1788
1809
  "font-size": ["leading"],
@@ -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.0"
4
+ VERSION = "0.9.0"
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.0
4
+ version: 0.9.0
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-04 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.21
103
103
  signing_key:
104
104
  specification_version: 4
105
105
  summary: Utility function to efficiently merge Tailwind CSS classes without style