tailwind_merge 0.7.2 → 0.7.4

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: f1d84d9d8ccb31fb4d40b8b3c01bdd4360a629bbb1edb6372c67e2593cec0fb9
4
- data.tar.gz: db09d2ca1a88e1e55dabe545307f94694bb05f38591a889d6cd5d4eea86b82d6
3
+ metadata.gz: 54b29a688c5296c4966181e18f78627825e815b7192815d7c82781f525447033
4
+ data.tar.gz: 03dbc892736e660e17df42121167d8143d3d910e82e76221ad39a2234f198f9d
5
5
  SHA512:
6
- metadata.gz: 67975440de152fe04b60ef762e6c6de724e45a6d3c8cbe922dcd13e9bea4cda1fd0253db2e6731014d1045c341e466d85fdbcfbb1f4657645e0ae3f8082d6a33
7
- data.tar.gz: 5d5e38c0173bb4cc06982aa1a381892c0223fa71709b485945bdf057d3358085714de24929766793a01431dd9da4cd858c7dc7b71c4ae7300a2ac4a0f7061419
6
+ metadata.gz: 646aa7ab4367b068052ffaa5bb3f0064986a5810cd5c21f94294c24f9dd3033c54b8a37cb8a96fc1b9f5926cd6d07fc6289d76057b3260b7fd76d99a215def91
7
+ data.tar.gz: 1a29af4fc0ba6a9069cd56937e57f31abf2b8d70bce3c674bc8f59bdf1eb0862322d66ae216a5c7b4ec772681f9c74e795d99e9214d4426ea8b21c4f37f9aad2
data/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
+ ## [v0.7.3] - 26-06-2023
2
+ null
1
3
  # Changelog
2
4
 
5
+ ## [v0.7.2](https://github.com/gjtorikian/tailwind_merge/tree/v0.7.2) (2023-06-08)
6
+
7
+ [Full Changelog](https://github.com/gjtorikian/tailwind_merge/compare/v0.7.1.2...v0.7.2)
8
+
9
+ **Merged pull requests:**
10
+
11
+ - Fix basis-auto and basis-full not being merged correctly [\#13](https://github.com/gjtorikian/tailwind_merge/pull/13) ([gjtorikian](https://github.com/gjtorikian))
12
+
3
13
  ## [v0.7.1.2](https://github.com/gjtorikian/tailwind_merge/tree/v0.7.1.2) (2023-06-02)
4
14
 
5
15
  [Full Changelog](https://github.com/gjtorikian/tailwind_merge/compare/v0.7.1.1...v0.7.1.2)
data/README.md CHANGED
@@ -91,6 +91,13 @@ The order of standard modifiers does not matter for tailwind-merge.
91
91
  @merger.merge('grid-cols-[1fr,auto] grid-cols-2') # → 'grid-cols-2'
92
92
  ```
93
93
 
94
+ > **Warning**
95
+ > Labels necessary in ambiguous cases
96
+ >
97
+ > When using arbitrary values in ambiguous classes like `text-[calc(var(--rebecca)-1rem)]` tailwind-merge looks at the arbitrary value for clues to determine what type of class it is. In this case, like in most ambiguous classes, it would try to figure out whether `calc(var(--rebecca)-1rem)` is a length (making it a font-size class) or a color (making it a text-color class). For lengths it takes clues into account like the presence of the `calc()` function or a digit followed by a length unit like `1rem`.
98
+ >
99
+ > But it isn't always possible to figure out the type by looking at the arbitrary value. E.g. in the class `text-[theme(myCustomScale.rebecca)]` tailwind-merge can't know the type of the arbitrary value and will default to a text-color class. To make tailwind-merge understand the correct type of the arbitrary value in those cases, you can use CSS data type labels [which are used by Tailwind CSS to disambiguate classes](https://tailwindcss.com/docs/adding-custom-styles#resolving-ambiguities): `text-[lengt
100
+
94
101
  ### Supports arbitrary properties
95
102
 
96
103
  ```ruby
@@ -101,8 +108,7 @@ The order of standard modifiers does not matter for tailwind-merge.
101
108
  @merger.merge('[padding:1rem] p-8') # → '[padding:1rem] p-8'
102
109
  ```
103
110
 
104
- > **Warning**
105
- > Watch out for using arbitrary properties which could be expressed as Tailwind classes. `tailwind_merge` does not resolve conflicts between arbitrary properties and their matching Tailwind classes to keep the bundle size small.
111
+ > **Warning** > `tailwind_merge` does not resolve conflicts between arbitrary properties and their matching Tailwind classes to keep the bundle size small.
106
112
 
107
113
  ### Supports arbitrary variants
108
114
 
@@ -34,7 +34,7 @@ module TailwindMerge
34
34
 
35
35
  return class_group_from_next_class_part if class_group_from_next_class_part
36
36
 
37
- return nil if class_part_object[:validators].empty?
37
+ return if class_part_object[:validators].empty?
38
38
 
39
39
  class_rest = class_parts.join(CLASS_PART_SEPARATOR)
40
40
 
@@ -64,7 +64,8 @@ module TailwindMerge
64
64
 
65
65
  OVERSCROLL = -> { ["auto", "contain", "none"] }
66
66
  OVERFLOW = -> { ["auto", "hidden", "clip", "visible", "scroll"] }
67
- SPACING_WITH_AUTO = -> { ["auto", SPACING] }
67
+ SPACING_WITH_AUTO_AND_ARBITRARY = -> { ["auto", IS_ARBITRARY_VALUE, SPACING] }
68
+ SPACING_WITH_ARBITRARY = -> { [IS_ARBITRARY_VALUE, SPACING] }
68
69
  LENGTH_WITH_EMPTY = -> { ["", IS_LENGTH] }
69
70
  NUMBER_WITH_AUTO_AND_ARBITRARY = -> { ["auto", IS_NUMBER, IS_ARBITRARY_VALUE] }
70
71
  POSITIONS = -> {
@@ -114,29 +115,29 @@ module TailwindMerge
114
115
  theme: {
115
116
  "colors" => [IS_ANY],
116
117
  "spacing" => [IS_LENGTH],
117
- "blur" => ["none", "", IS_TSHIRT_SIZE, IS_ARBITRARY_LENGTH],
118
+ "blur" => ["none", "", IS_TSHIRT_SIZE, IS_ARBITRARY_VALUE],
118
119
  "brightness" => NUMBER.call,
119
120
  "border-color" => [COLORS],
120
- "border-radius" => ["none", "", "full", IS_TSHIRT_SIZE, IS_ARBITRARY_LENGTH],
121
- "border-spacing" => [SPACING],
121
+ "border-radius" => ["none", "", "full", IS_TSHIRT_SIZE, IS_ARBITRARY_VALUE],
122
+ "border-spacing" => SPACING_WITH_ARBITRARY.call,
122
123
  "border-width" => LENGTH_WITH_EMPTY.call,
123
124
  "contrast" => NUMBER.call,
124
125
  "grayscale" => ZERO_AND_EMPTY.call,
125
126
  "hue-rotate" => NUMBER_AND_ARBITRARY.call,
126
127
  "invert" => ZERO_AND_EMPTY.call,
127
- "gap" => [SPACING],
128
+ "gap" => SPACING_WITH_ARBITRARY.call,
128
129
  "gradient-color-stops" => [COLORS],
129
130
  "gradient-color-stop-positions" => [IS_PERCENT, IS_ARBITRARY_LENGTH],
130
- "inset" => SPACING_WITH_AUTO.call,
131
- "margin" => SPACING_WITH_AUTO.call,
131
+ "inset" => SPACING_WITH_AUTO_AND_ARBITRARY.call,
132
+ "margin" => SPACING_WITH_AUTO_AND_ARBITRARY.call,
132
133
  "opacity" => NUMBER.call,
133
- "padding" => [SPACING],
134
+ "padding" => SPACING_WITH_ARBITRARY.call,
134
135
  "saturate" => NUMBER.call,
135
136
  "scale" => NUMBER.call,
136
137
  "sepia" => ZERO_AND_EMPTY.call,
137
138
  "skew" => NUMBER_AND_ARBITRARY.call,
138
- "space" => [SPACING],
139
- "translate" => [SPACING],
139
+ "space" => SPACING_WITH_ARBITRARY.call,
140
+ "translate" => SPACING_WITH_ARBITRARY.call,
140
141
  },
141
142
  class_groups: { # rubocop:disable Metrics/CollectionLiteralLength
142
143
  # Layout
@@ -327,7 +328,7 @@ module TailwindMerge
327
328
  # Flex Basis
328
329
  # @see https://tailwindcss.com/docs/flex-basis
329
330
  ##
330
- "basis" => [{ "basis" => SPACING_WITH_AUTO.call }],
331
+ "basis" => [{ "basis" => SPACING_WITH_AUTO_AND_ARBITRARY.call }],
331
332
  ##
332
333
  # Flex Direction
333
334
  # @see https://tailwindcss.com/docs/flex-direction
@@ -367,7 +368,8 @@ module TailwindMerge
367
368
  # Grid Column Start / End
368
369
  # @see https://tailwindcss.com/docs/grid-column
369
370
  ##
370
- "col-start-end" => [{ "col" => ["auto", { "span" => [IS_INTEGER, IS_ARBITRARY_VALUE] }] }],
371
+ "col-start-end" => [{ "col" => ["auto", { "span" => ["full", IS_INTEGER] }, IS_ARBITRARY_VALUE] }],
372
+
371
373
  ##
372
374
  # Grid Column Start
373
375
  # @see https://tailwindcss.com/docs/grid-column
@@ -589,12 +591,12 @@ module TailwindMerge
589
591
  # Width
590
592
  # @see https://tailwindcss.com/docs/width
591
593
  ##
592
- "w" => [{ "w" => ["auto", "min", "max", "fit", SPACING] }],
594
+ "w" => [{ "w" => ["auto", "min", "max", "fit", IS_ARBITRARY_VALUE, SPACING] }],
593
595
  ##
594
596
  # Min-Width
595
597
  # @see https://tailwindcss.com/docs/min-width
596
598
  ##
597
- "min-w" => [{ "min-w" => ["min", "max", "fit", IS_LENGTH] }],
599
+ "min-w" => [{ "min-w" => ["min", "max", "fit", IS_ARBITRARY_VALUE, IS_LENGTH] }],
598
600
  ##
599
601
  # Max-Width
600
602
  # @see https://tailwindcss.com/docs/max-width
@@ -611,7 +613,7 @@ module TailwindMerge
611
613
  "prose",
612
614
  { "screen" => [IS_TSHIRT_SIZE] },
613
615
  IS_TSHIRT_SIZE,
614
- IS_ARBITRARY_LENGTH,
616
+ IS_ARBITRARY_VALUE,
615
617
  ],
616
618
  },
617
619
  ],
@@ -619,17 +621,17 @@ module TailwindMerge
619
621
  # Height
620
622
  # @see https://tailwindcss.com/docs/height
621
623
  ##
622
- "h" => [{ "h" => ["auto", "min", "max", "fit", SPACING] }],
624
+ "h" => [{ "h" => [IS_ARBITRARY_VALUE, SPACING, "auto", "min", "max", "fit"] }],
623
625
  ##
624
626
  # Min-Height
625
627
  # @see https://tailwindcss.com/docs/min-height
626
628
  ##
627
- "min-h" => [{ "min-h" => ["min", "max", "fit", IS_LENGTH] }],
629
+ "min-h" => [{ "min-h" => ["min", "max", "fit", IS_ARBITRARY_VALUE, IS_LENGTH] }],
628
630
  ##
629
631
  # Max-Height
630
632
  # @see https://tailwindcss.com/docs/max-height
631
633
  ##
632
- "max-h" => [{ "max-h" => [SPACING, "min", "max", "fit"] }],
634
+ "max-h" => [{ "max-h" => [IS_ARBITRARY_VALUE, SPACING, "min", "max", "fit"] }],
633
635
  # Typography
634
636
  ##
635
637
  # Font Size
@@ -714,7 +716,7 @@ module TailwindMerge
714
716
  "wide",
715
717
  "wider",
716
718
  "widest",
717
- IS_ARBITRARY_LENGTH,
719
+ IS_ARBITRARY_VALUE,
718
720
  ],
719
721
  }, # rubocop:enable Metrics/CollectionLiteralLength
720
722
  ],
@@ -728,7 +730,7 @@ module TailwindMerge
728
730
  # @see https://tailwindcss.com/docs/line-height
729
731
  ##
730
732
  "leading" => [
731
- { "leading" => ["none", "tight", "snug", "normal", "relaxed", "loose", IS_LENGTH] },
733
+ { "leading" => ["none", "tight", "snug", "normal", "relaxed", "loose", IS_ARBITRARY_VALUE, IS_LENGTH] },
732
734
  ],
733
735
  #
734
736
  # List Style Image
@@ -790,7 +792,7 @@ module TailwindMerge
790
792
  # Text Underline Offset
791
793
  # @see https://tailwindcss.com/docs/text-underline-offset
792
794
  ##
793
- "underline-offset" => [{ "underline-offset" => ["auto", IS_LENGTH] }],
795
+ "underline-offset" => [{ "underline-offset" => ["auto", IS_ARBITRARY_VALUE, IS_LENGTH] }],
794
796
  ##
795
797
  # Text Decoration Color
796
798
  # @see https://tailwindcss.com/docs/text-decoration-color
@@ -810,7 +812,7 @@ module TailwindMerge
810
812
  # Text Indent
811
813
  # @see https://tailwindcss.com/docs/text-indent
812
814
  ##
813
- "indent" => [{ "indent" => [SPACING] }],
815
+ "indent" => [{ "indent" => SPACING_WITH_ARBITRARY.call }],
814
816
  ##
815
817
  # Vertical Alignment
816
818
  # @see https://tailwindcss.com/docs/vertical-align
@@ -826,7 +828,7 @@ module TailwindMerge
826
828
  "text-bottom",
827
829
  "sub",
828
830
  "super",
829
- IS_ARBITRARY_LENGTH,
831
+ IS_ARBITRARY_VALUE,
830
832
  ],
831
833
  },
832
834
  ],
@@ -1145,7 +1147,7 @@ module TailwindMerge
1145
1147
  # Outline Offset
1146
1148
  # @see https://tailwindcss.com/docs/outline-offset
1147
1149
  ##
1148
- "outline-offset" => [{ "outline-offset" => [IS_LENGTH] }],
1150
+ "outline-offset" => [{ "outline-offset" => [IS_ARBITRARY_VALUE, IS_LENGTH] }],
1149
1151
  ##
1150
1152
  # Outline Width
1151
1153
  # @see https://tailwindcss.com/docs/outline-width
@@ -1533,92 +1535,92 @@ module TailwindMerge
1533
1535
  # Scroll Margin
1534
1536
  # @see https://tailwindcss.com/docs/scroll-margin
1535
1537
  ##
1536
- "scroll-m" => [{ "scroll-m" => [SPACING] }],
1538
+ "scroll-m" => [{ "scroll-m" => SPACING_WITH_ARBITRARY.call }],
1537
1539
  ##
1538
1540
  # Scroll Margin X
1539
1541
  # @see https://tailwindcss.com/docs/scroll-margin
1540
1542
  ##
1541
- "scroll-mx" => [{ "scroll-mx" => [SPACING] }],
1543
+ "scroll-mx" => [{ "scroll-mx" => SPACING_WITH_ARBITRARY.call }],
1542
1544
  ##
1543
1545
  # Scroll Margin Y
1544
1546
  # @see https://tailwindcss.com/docs/scroll-margin
1545
1547
  ##
1546
- "scroll-my" => [{ "scroll-my" => [SPACING] }],
1548
+ "scroll-my" => [{ "scroll-my" => SPACING_WITH_ARBITRARY.call }],
1547
1549
  #
1548
1550
  # Scroll Margin Start
1549
1551
  # @see https://tailwindcss.com/docs/scroll-margin
1550
1552
  #
1551
- "scroll-ms" => [{ "scroll-ms" => [SPACING] }],
1553
+ "scroll-ms" => [{ "scroll-ms" => SPACING_WITH_ARBITRARY.call }],
1552
1554
  #
1553
1555
  # Scroll Margin End
1554
1556
  # @see https://tailwindcss.com/docs/scroll-margin
1555
1557
  #
1556
- "scroll-me" => [{ "scroll-me" => [SPACING] }],
1558
+ "scroll-me" => [{ "scroll-me" => SPACING_WITH_ARBITRARY.call }],
1557
1559
  ##
1558
1560
  # Scroll Margin Top
1559
1561
  # @see https://tailwindcss.com/docs/scroll-margin
1560
1562
  ##
1561
- "scroll-mt" => [{ "scroll-mt" => [SPACING] }],
1563
+ "scroll-mt" => [{ "scroll-mt" => SPACING_WITH_ARBITRARY.call }],
1562
1564
  ##
1563
1565
  # Scroll Margin Right
1564
1566
  # @see https://tailwindcss.com/docs/scroll-margin
1565
1567
  ##
1566
- "scroll-mr" => [{ "scroll-mr" => [SPACING] }],
1568
+ "scroll-mr" => [{ "scroll-mr" => SPACING_WITH_ARBITRARY.call }],
1567
1569
  ##
1568
1570
  # Scroll Margin Bottom
1569
1571
  # @see https://tailwindcss.com/docs/scroll-margin
1570
1572
  ##
1571
- "scroll-mb" => [{ "scroll-mb" => [SPACING] }],
1573
+ "scroll-mb" => [{ "scroll-mb" => SPACING_WITH_ARBITRARY.call }],
1572
1574
  ##
1573
1575
  # Scroll Margin Left
1574
1576
  # @see https://tailwindcss.com/docs/scroll-margin
1575
1577
  ##
1576
- "scroll-ml" => [{ "scroll-ml" => [SPACING] }],
1578
+ "scroll-ml" => [{ "scroll-ml" => SPACING_WITH_ARBITRARY.call }],
1577
1579
  ##
1578
1580
  # Scroll Padding
1579
1581
  # @see https://tailwindcss.com/docs/scroll-padding
1580
1582
  ##
1581
- "scroll-p" => [{ "scroll-p" => [SPACING] }],
1583
+ "scroll-p" => [{ "scroll-p" => SPACING_WITH_ARBITRARY.call }],
1582
1584
  ##
1583
1585
  # Scroll Padding X
1584
1586
  # @see https://tailwindcss.com/docs/scroll-padding
1585
1587
  ##
1586
- "scroll-px" => [{ "scroll-px" => [SPACING] }],
1588
+ "scroll-px" => [{ "scroll-px" => SPACING_WITH_ARBITRARY.call }],
1587
1589
  ##
1588
1590
  # Scroll Padding Y
1589
1591
  # @see https://tailwindcss.com/docs/scroll-padding
1590
1592
  ##
1591
- "scroll-py" => [{ "scroll-py" => [SPACING] }],
1593
+ "scroll-py" => [{ "scroll-py" => SPACING_WITH_ARBITRARY.call }],
1592
1594
  #
1593
1595
  # Scroll Padding Start
1594
1596
  # @see https://tailwindcss.com/docs/scroll-padding
1595
1597
  #
1596
- "scroll-ps" => [{ "scroll-ps" => [SPACING] }],
1598
+ "scroll-ps" => [{ "scroll-ps" => SPACING_WITH_ARBITRARY.call }],
1597
1599
  #
1598
1600
  # Scroll Padding End
1599
1601
  # @see https://tailwindcss.com/docs/scroll-padding
1600
1602
  #
1601
- "scroll-pe" => [{ "scroll-pe" => [SPACING] }],
1603
+ "scroll-pe" => [{ "scroll-pe" => SPACING_WITH_ARBITRARY.call }],
1602
1604
  ##
1603
1605
  # Scroll Padding Top
1604
1606
  # @see https://tailwindcss.com/docs/scroll-padding
1605
1607
  ##
1606
- "scroll-pt" => [{ "scroll-pt" => [SPACING] }],
1608
+ "scroll-pt" => [{ "scroll-pt" => SPACING_WITH_ARBITRARY.call }],
1607
1609
  ##
1608
1610
  # Scroll Padding Right
1609
1611
  # @see https://tailwindcss.com/docs/scroll-padding
1610
1612
  ##
1611
- "scroll-pr" => [{ "scroll-pr" => [SPACING] }],
1613
+ "scroll-pr" => [{ "scroll-pr" => SPACING_WITH_ARBITRARY.call }],
1612
1614
  ##
1613
1615
  # Scroll Padding Bottom
1614
1616
  # @see https://tailwindcss.com/docs/scroll-padding
1615
1617
  ##
1616
- "scroll-pb" => [{ "scroll-pb" => [SPACING] }],
1618
+ "scroll-pb" => [{ "scroll-pb" => SPACING_WITH_ARBITRARY.call }],
1617
1619
  ##
1618
1620
  # Scroll Padding Left
1619
1621
  # @see https://tailwindcss.com/docs/scroll-padding
1620
1622
  ##
1621
- "scroll-pl" => [{ "scroll-pl" => [SPACING] }],
1623
+ "scroll-pl" => [{ "scroll-pl" => SPACING_WITH_ARBITRARY.call }],
1622
1624
  ##
1623
1625
  # Scroll Snap Align
1624
1626
  # @see https://tailwindcss.com/docs/scroll-snap-align
@@ -27,7 +27,7 @@ module TailwindMerge
27
27
 
28
28
  ARBITRARY_VALUE_REGEX = /^\[(?:([a-z-]+):)?(.+)\]$/i
29
29
  FRACTION_REGEX = %r{^\d+/\d+$}
30
- LENGTH_UNIT_REGEX = /\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|^0$/
30
+ LENGTH_UNIT_REGEX = /\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/
31
31
  TSHIRT_UNIT_REGEX = /^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/
32
32
  # Shadow always begins with x and y offset separated by underscore
33
33
  SHADOW_REGEX = /^-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module TailwindMerge
4
- VERSION = "0.7.2"
4
+ VERSION = "0.7.4"
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.7.2
4
+ version: 0.7.4
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-06-08 00:00:00.000000000 Z
11
+ date: 2023-07-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: lru_redux
@@ -100,7 +100,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
100
100
  - !ruby/object:Gem::Version
101
101
  version: '0'
102
102
  requirements: []
103
- rubygems_version: 3.4.13
103
+ rubygems_version: 3.4.15
104
104
  signing_key:
105
105
  specification_version: 4
106
106
  summary: Utility function to efficiently merge Tailwind CSS classes without style