@@ -2,48 +2,48 @@ import type { CSSObject, Rule, RuleContext } from '@unocss/core'
22import type { Theme } from '../theme'
33import { colorResolver , defineProperty , h } from '../utils'
44import { borderStyles } from './border'
5- import { notLastChildSelector } from './spacing'
5+ import { notLastChildSelectorVariant } from './spacing'
66
77export const divides : Rule < Theme > [ ] = [
88// color & opacity
99 [ / ^ d i v i d e - ( .+ ) $ / , function * ( match , ctx ) {
1010 const result = colorResolver ( 'border-color' , 'divide' ) ( match , ctx )
1111 if ( result ) {
1212 yield {
13- [ ctx . symbols . selector ] : notLastChildSelector ,
13+ [ ctx . symbols . variants ] : [ notLastChildSelectorVariant ( match [ 0 ] ) ] ,
1414 ...result [ 0 ] as CSSObject ,
1515 }
1616 yield result [ 1 ]
1717 }
1818 } , { autocomplete : 'divide-$colors' } ] ,
19- [ / ^ d i v i d e - o p (?: a c i t y ) ? - ? ( .+ ) $ / , function * ( [ , opacity ] , { symbols } ) {
19+ [ / ^ d i v i d e - o p (?: a c i t y ) ? - ? ( .+ ) $ / , function * ( [ match , opacity ] , { symbols } ) {
2020 yield {
21- [ symbols . selector ] : notLastChildSelector ,
21+ [ symbols . variants ] : [ notLastChildSelectorVariant ( match ) ] ,
2222 '--un-divide-opacity' : h . bracket . percent ( opacity ) ,
2323 }
2424 } , { autocomplete : [ 'divide-(op|opacity)' , 'divide-(op|opacity)-<percent>' ] } ] ,
2525
2626 // divides
2727 [ / ^ d i v i d e - ? ( [ x y ] ) $ / , handlerDivide , { autocomplete : [ 'divide-(x|y)' , 'divide-(x|y)-reverse' ] } ] ,
2828 [ / ^ d i v i d e - ? ( [ x y ] ) - ? ( .+ ) $ / , handlerDivide ] ,
29- [ / ^ d i v i d e - ? ( [ x y ] ) - r e v e r s e $ / , function * ( [ , d ] : string [ ] , { symbols } : RuleContext < Theme > ) {
29+ [ / ^ d i v i d e - ? ( [ x y ] ) - r e v e r s e $ / , function * ( [ m , d ] : string [ ] , { symbols } : RuleContext < Theme > ) {
3030 yield {
31- [ symbols . selector ] : notLastChildSelector ,
31+ [ symbols . variants ] : [ notLastChildSelectorVariant ( m ) ] ,
3232 [ `--un-divide-${ d } -reverse` ] : '1' ,
3333 }
3434 yield defineProperty ( `--un-divide-${ d } -reverse` , { initialValue : 0 } )
3535 } ] ,
3636
3737 // styles
38- [ new RegExp ( `^divide-(${ borderStyles . join ( '|' ) } )$` ) , function * ( [ , style ] : string [ ] , { symbols } : RuleContext < Theme > ) {
38+ [ new RegExp ( `^divide-(${ borderStyles . join ( '|' ) } )$` ) , function * ( [ match , style ] : string [ ] , { symbols } : RuleContext < Theme > ) {
3939 yield {
40- [ symbols . selector ] : notLastChildSelector ,
40+ [ symbols . variants ] : [ notLastChildSelectorVariant ( match ) ] ,
4141 'border-style' : style ,
4242 }
4343 } , { autocomplete : borderStyles . map ( i => `divide-${ i } ` ) } ] ,
4444]
4545
46- function * handlerDivide ( [ , d , s ] : string [ ] , { symbols } : RuleContext < Theme > ) {
46+ function * handlerDivide ( [ m , d , s ] : string [ ] , { symbols } : RuleContext < Theme > ) {
4747 let v = h . bracket . cssvar . px ( s || '1' )
4848 if ( v != null ) {
4949 if ( v === '0' )
@@ -65,7 +65,7 @@ function* handlerDivide([, d, s]: string[], { symbols }: RuleContext<Theme>) {
6565
6666 if ( results ) {
6767 yield {
68- [ symbols . selector ] : notLastChildSelector ,
68+ [ symbols . variants ] : [ notLastChildSelectorVariant ( m ) ] ,
6969 [ `--un-divide-${ d } -reverse` ] : 0 ,
7070 ...Object . fromEntries ( results . flat ( ) ) ,
7171 }
0 commit comments