21 Commits

Author SHA1 Message Date
Ankan Bag
c10ba4e9ba
Fix fractional values not being parsed properly inside arbitrary properties (#9705)
* remove redundant closing bracket in regex pattern

* test fractional spacing values in theme function

* add test that ensures arbitrary properties are separate

* update changelog

Co-authored-by: Robin Malfait <malfait.robin@gmail.com>
2022-11-03 11:10:33 +01:00
Robin Malfait
4338849ff4
Prepare for container queries setup (#9526)
* setup for container queries

* remove container query implementation itself

This will be moved to its own plugin.

* update changelog

Co-authored-by: Jordan Pittman <jordan@cryptica.me>
2022-10-12 12:24:46 +02:00
Jordan Pittman
5191ec1c00
Fix usage of special-character prefixes (#8772)
* Fix import

* Support arbitrary prefixes

* Add test

* Update changelog
2022-07-04 14:42:27 -04:00
Jordan Pittman
c5e7857362
Detect arbitrary variants with quotes (#8687)
* Refactor

* Support variants with quotes in them

We have to have two regexes here because this is actually ambiguous in the general case. The regex that generally handles `[&[foo='bar']]` would incorrectly match `['bar':'baz']` for instance. So, instead we’ll use multiple regexes and match both!

* Update changelog
2022-06-20 09:56:40 -04:00
Adam Wathan
22eaad17c3
Fix "Maximum call stack size exceeded" bug (#8636)
* Fix potential call stack size issue

* Update defaultExtractor.js

* add test to verify "Maximum call stack size exceeded" is fixed

* update changelog

Co-authored-by: Robin Malfait <malfait.robin@gmail.com>
2022-06-14 14:17:40 +02:00
Jordan Pittman
a9c7e52a59
Fix extraction of multi-word utilities with arbitrary values and quotes (#8604)
* Fix extraction of multi-word utilityies with arbitrary values and quotes

* Update  changelog

* Fix changelog entry

This wasn’t in 3.1.2 oops
2022-06-12 10:10:10 -04:00
Robin Malfait
d32728b433
Ensure \ is a valid arbitrary variant token (#8576)
* `\` are valid arbitrary variant tokens

We use `\` for escaping `.` or `_` so they should be part of the
arbitrary variant regex.

* update changelog
2022-06-10 10:51:16 +02:00
Jordan Pittman
0664aae901
Fix class detection in markdown code fences and slim templates (#8569)
* Fix detection of classes in markdown code fences

* Fix candidate detection in `.slim` templates

* Update changelog
2022-06-09 16:53:02 -04:00
Robin Malfait
9a5db88e54
Fix candidate extractor regression (#8558)
* fix regression

This is a regression where `%>utility<%` didn't properly abstract
`utility`

* update changelog
2022-06-09 18:22:20 +02:00
Jordan Pittman
b0e1f47b94 Be more direct about variant group extractions
Also adds a previously failing but now passing test case
2022-05-23 15:29:29 -04:00
Robin Malfait
68ff4ba500
Experimental support for variant grouping (#8405)
* WIP

* use correct separator

* run all tests

* Fix regex

* add a few more tests

* name the experimental feature flag `variantGrouping`

* update changelog

* rename test file `variant-grouping`

Co-authored-by: Jordan Pittman <jordan@cryptica.me>
2022-05-23 17:45:23 +02:00
Robin Malfait
fc25299aa6
Add matchVariant API (#8310)
* update regex extractor

* implement `matchVariant` API

* add `matchVariant` test

* add `values` option to the `matchVariant` API

* move `matchVariant` tests to own file

* update changelog
2022-05-17 18:08:42 +02:00
Robin Malfait
be51739337
Arbitrary variants (#8299)
* register arbitrary variants

With the new `addVariant` API, we have a beautiful way of creating new
variants.

You can use it as:
```js
addVariant('children', '& > *')
```

Now you can use the `children:` variant. The API uses a `&` as a
reference for the candidate, which means that:
```html
children:pl-4
```

Will result in:
```css
.children\:pl-4 > * { .. }
```

Notice that the `&` was replaced by `.children\:pl-4`.

We can leverage this API to implement arbitrary variants, this means
that you can write those `&>*` (Notice that we don't have spaces) inside
a variant directly. An example of this can be:
```html
<ul class="[&>*]:underline">
  <li>A</li>
  <li>B</li>
  <li>C</li>
</ul>
```
Which generates the following css:
```css
.\[\&\>\*\]\:underline > * {
  text-decoration-line: underline;
}
```

Now all the children of the `ul` will have an `underline`. The selector
itself is a bit crazy since it contains the candidate which is the
selector itself, it is just escaped.

* add tests for arbitrary variants

This still requires some work to the `defaultExtractor` to make sure it
all works with existing code.

* update changelog

* Fix candidate detection for arbitrary variants

* Refactor

* Add support for at rules

* Add test for attribute selectors

* Fix test

* Add attribute selector support

* Split top-level comma parsing into a generalized splitting routine

We can now split on any character at the top level with any nesting. We don’t balance brackets directly here but this is probably “enough”

* Split variants by separator at the top-level only

This means that the separator has to be ouside of balanced brackets

* Fix extraction when using custom variant separators

* Support custom separators when top-level splitting variants

* Add a second multi-character separator test

* Split tests for at-rule and at-rule with selector changes

* Add nested at-rule tests

* Fix space-less at-rule parsing in addVariant

* Add test for using with `@apply`

Co-authored-by: Jordan Pittman <jordan@cryptica.me>
Co-authored-by: Adam Wathan <adam.wathan@gmail.com>
2022-05-08 12:24:59 -04:00
Jordan Pittman
d676086a75
Rewrite default class extractor (#8204)
* Rewrite default extractor

* Eliminate lookbehind assertions in expand apply at rules

* Update changelog
2022-05-04 16:08:25 -04:00
Samuel Alev
bc46d0e0bc
Fix extraction from template literal/function with array (#7481)
* fix: allow extraction from template literal with array

* fix: support extraction from array in function

* test: add more tests for function and template

* test: add test for dynamic classes

* test: add dynamic class test in js

* test: add dynamic class test in js single quote

* Cleanup a bit

* Update changelog

Co-authored-by: Jordan Pittman <jordan@cryptica.me>
2022-03-01 14:23:06 -05:00
Jordan Pittman
db475be6dd
Support arbitrary values + calc + theme with quotes (#7462)
* Support arbitrary values + calc + theme with quotes

* Update changelog
2022-02-14 15:44:27 -05:00
Robin Malfait
3149738035
Properly detect theme() value usage in arbitrary properties (#6854)
* properly detect theme value in arbitrary properties

* update changelog
2022-01-03 13:12:43 +01:00
Robin Malfait
b341813d3f
Ensure we can use < and > characters in modifiers (#6851)
* ensure we can use "special" characters in modifiers

Fixes: #6778

* update changelog
2022-01-03 11:17:58 +01:00
Adam Wathan
da7396cf77 Sketching out more specific tests for our default extractor 2021-12-24 12:56:53 -05:00
Robin Malfait
9e03a6800b
Improve jsx interpolation candidate matching (#6593)
* ensure that strangely used jsx with interpolation gets detected

Co-authored-by: Luke Warlow <projects@warlow.dev>
Co-authored-by: Jordan Pittman <jordan@cryptica.me>

* update changelog

Co-authored-by: Luke Warlow <projects@warlow.dev>
Co-authored-by: Jordan Pittman <jordan@cryptica.me>
2021-12-17 17:32:50 +01:00
Jordan Pittman
27c67fef43
Properly extract classes with arbitrary values in arrays and classes followed by escaped quotes (#6590)
Co-authored-by: Robin Malfait <malfait.robin@gmail.com>
2021-12-17 10:15:36 -05:00