tailwind_merge 0.10.1 → 0.11.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: eb9ce33e9e3b1376a95325263d7e3091edbc8ee077f0d3fb023b8e9494345f99
4
- data.tar.gz: c1548d94345b50b51074dc54534357d5415ce8feebd2666162840a06a7f6c29b
3
+ metadata.gz: 9215c8da9ac6f18a5a552237e0f553b4dc055ca0fabd78821602517ebcf802c4
4
+ data.tar.gz: 382be551f40940cb23ca1983bc0040ca7f809339086988c394e4a555872f5446
5
5
  SHA512:
6
- metadata.gz: 3af858c685680c51fb0b53eed278b12f42005be6d776aa9795a0757cee0dad204523fc7524f95958843588150356c8e9066f577ccf30a47ea31640b3c0f3d40e
7
- data.tar.gz: 12dba99eb0c963292e860378faf0bb57d60a8ad9f4231e7965b26dc3c60ed32f7704554d0b616548108450418c69c18b526f7d69000bcdcf3768b44413f067d0
6
+ metadata.gz: 9b0f002423acb683795d68040b049a2504f458bd4b4f7eee1818f85ca81c52daaf9eff09ac8a1ee3bf0af5596e9a1ef5f31c84f8ef1d2e208533d1daf581c906
7
+ data.tar.gz: 1b6ff1b9efe0ee53ca77fe433ebfbf217172a84aebd914986b25dbee6e125c9eaf3923cc43f2d0633f75acc41ca12ea58d2381ea387187d605f85b94f67907c1
data/CHANGELOG.md CHANGED
@@ -1,3 +1,15 @@
1
+ ## [v0.10.2] - 18-03-2024
2
+ ## What's Changed
3
+ * Support shadow with by @gjtorikian in https://github.com/gjtorikian/tailwind_merge/pull/25
4
+
5
+
6
+ **Full Changelog**: https://github.com/gjtorikian/tailwind_merge/compare/v0.10.1...v0.10.2
7
+ ## [v0.10.1] - 30-01-2024
8
+ ## What's Changed
9
+ * Fix stroke-color being incorrectly detected as stroke-width by @gjtorikian in https://github.com/gjtorikian/tailwind_merge/pull/24
10
+
11
+
12
+ **Full Changelog**: https://github.com/gjtorikian/tailwind_merge/compare/v0.10.0...v0.10.1
1
13
  ## [v0.10.0] - 23-12-2023
2
14
  ## What's Changed
3
15
  * Support Tailwind 3.4 by @gjtorikian in https://github.com/gjtorikian/tailwind_merge/pull/23
data/README.md CHANGED
@@ -14,6 +14,8 @@ If bundler is not being used to manage dependencies, install the gem by executin
14
14
 
15
15
  $ gem install tailwind_merge
16
16
 
17
+ To use it, pass in a single string:
18
+
17
19
  ```ruby
18
20
  require "tailwind_merge"
19
21
 
@@ -21,6 +23,15 @@ TailwindMerge::Merger.new.merge("px-2 py-1 bg-red hover:bg-dark-red p-3 bg-[#B91
21
23
  # → 'hover:bg-dark-red p-3 bg-[#B91C1C]'
22
24
  ```
23
25
 
26
+ Or, an array of strings:
27
+
28
+ ```ruby
29
+ require "tailwind_merge"
30
+
31
+ TailwindMerge::Merger.new.merge(["px-2 py-1", "bg-red hover:bg-dark-red", "p-3 bg-[#B91C1C]"])
32
+ # → 'hover:bg-dark-red p-3 bg-[#B91C1C]'
33
+ ```
34
+
24
35
  ## What's it for?
25
36
 
26
37
  If you use Tailwind with a component-based UI renderer (like [ViewComponent](https://viewcomponent.org) or [Ariadne](https://github.com/yettoapp/ariadne)), you're probably familiar with the situation that you want to change some styles of an existing component:
@@ -315,7 +326,7 @@ Here's a brief summary for each validator:
315
326
  - `IS_ARBITRARY_POSITION` checks whether class part is an arbitrary value which starts with `position:` (`[position:200px_100px]`) which is necessary for background-position classNames.
316
327
  - `IS_ARBITRARY_IMAGE` checks whether class part is an arbitrary value which is an iamge, e.g. by starting with `image:`, `url:`, `linear-gradient(` or `url(` (`[url('/path-to-image.png')]`, `image:var(--maybe-an-image-at-runtime)]`) which is necessary for background-image classNames.
317
328
  - `IS_ARBITRARY_NUMBER` checks whether class part is an arbitrary value which starts with `number:` or is a number (`[number:var(--value)]`, `[450]`) which is necessary for font-weight classNames.
318
- - `IS_ARBITRARY_SHADOW` checks whether class part is an arbitrary value which starts with the same pattern as a shadow value (`[0_35px_60px_-15px_rgba(0,0,0,0.3)]`), namely with two lengths separated by a underscore.
329
+ - `IS_ARBITRARY_SHADOW` checks whether class part is an arbitrary value which starts with the same pattern as a shadow value (`[0_35px_60px_-15px_rgba(0,0,0,0.3)]`), namely with two lengths separated by a underscore, optionally prepended by `inset`.
319
330
  - `IS_ANY` always returns true. Be careful with this validator as it might match unwanted classes. I use it primarily to match colors or when it's certain there are no other class groups in a namespace.
320
331
 
321
332
  ## Performance
@@ -32,8 +32,8 @@ module TailwindMerge
32
32
  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$/
33
33
  TSHIRT_UNIT_REGEX = /^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/
34
34
  COLOR_FUNCTION_REGEX = /^(rgba?|hsla?|hwb|(ok)?(lab|lch))\(.+\)$/
35
- # Shadow always begins with x and y offset separated by underscore
36
- SHADOW_REGEX = /^-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/
35
+ # Shadow always begins with x and y offset separated by underscore optionally prepended by inset
36
+ SHADOW_REGEX = /^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/
37
37
  IMAGE_REGEX = /^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/
38
38
 
39
39
  SIZE_LABELS = Set.new(["length", "size", "percentage"]).freeze
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module TailwindMerge
4
- VERSION = "0.10.1"
4
+ VERSION = "0.11.0"
5
5
  end
@@ -35,6 +35,10 @@ module TailwindMerge
35
35
  end
36
36
 
37
37
  def merge(classes)
38
+ if classes.is_a?(Array)
39
+ classes = classes.compact.join(" ")
40
+ end
41
+
38
42
  @cache.getset(classes) do
39
43
  merge_class_list(classes)
40
44
  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.10.1
4
+ version: 0.11.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: 2024-01-30 00:00:00.000000000 Z
11
+ date: 2024-03-26 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.5.5
102
+ rubygems_version: 3.4.6
103
103
  signing_key:
104
104
  specification_version: 4
105
105
  summary: Utility function to efficiently merge Tailwind CSS classes without style