@@ -4732,7 +4732,10 @@ export function createCssUtility(node: AtRule) {
4732
4732
4733
4733
return ( designSystem : DesignSystem ) => {
4734
4734
let valueThemeKeys = new Set < `--${string } `> ( )
4735
+ let valueLiterals = new Set < string > ( )
4736
+
4735
4737
let modifierThemeKeys = new Set < `--${string } `> ( )
4738
+ let modifierLiterals = new Set < string > ( )
4736
4739
4737
4740
// Pre-process the AST to make it easier to work with.
4738
4741
//
@@ -4784,9 +4787,25 @@ export function createCssUtility(node: AtRule) {
4784
4787
}
4785
4788
fn . nodes = ValueParser . parse ( args . join ( ',' ) )
4786
4789
4787
- // Track the theme keys for suggestions
4790
+ // Track information for suggestions
4788
4791
for ( let node of fn . nodes ) {
4789
- if ( node . kind === 'word' && node . value [ 0 ] === '-' && node . value [ 1 ] === '-' ) {
4792
+ // Track literal values
4793
+ if (
4794
+ node . kind === 'word' &&
4795
+ ( node . value [ 0 ] === '"' || node . value [ 0 ] === "'" ) &&
4796
+ node . value [ 0 ] === node . value [ node . value . length - 1 ]
4797
+ ) {
4798
+ let value = node . value . slice ( 1 , - 1 )
4799
+
4800
+ if ( fn . value === '--value' ) {
4801
+ valueLiterals . add ( value )
4802
+ } else if ( fn . value === '--modifier' ) {
4803
+ modifierLiterals . add ( value )
4804
+ }
4805
+ }
4806
+
4807
+ // Track theme keys
4808
+ else if ( node . kind === 'word' && node . value [ 0 ] === '-' && node . value [ 1 ] === '-' ) {
4790
4809
let value = node . value . replace ( / - \* .* $ / g, '' ) as `--${string } `
4791
4810
4792
4811
if ( fn . value === '--value' ) {
@@ -4930,16 +4949,23 @@ export function createCssUtility(node: AtRule) {
4930
4949
} )
4931
4950
4932
4951
designSystem . utilities . suggest ( name . slice ( 0 , - 2 ) , ( ) => {
4933
- return [
4934
- {
4935
- values : designSystem . theme
4936
- . keysInNamespaces ( valueThemeKeys )
4937
- . map ( ( x ) => x . replaceAll ( '_' , '.' ) ) ,
4938
- modifiers : designSystem . theme
4939
- . keysInNamespaces ( modifierThemeKeys )
4940
- . map ( ( x ) => x . replaceAll ( '_' , '.' ) ) ,
4941
- } ,
4942
- ] satisfies SuggestionGroup [ ]
4952
+ let values = [ ]
4953
+ for ( let value of valueLiterals ) {
4954
+ values . push ( value )
4955
+ }
4956
+ for ( let value of designSystem . theme . keysInNamespaces ( valueThemeKeys ) ) {
4957
+ values . push ( value . replaceAll ( '_' , '.' ) )
4958
+ }
4959
+
4960
+ let modifiers = [ ]
4961
+ for ( let modifier of modifierLiterals ) {
4962
+ modifiers . push ( modifier )
4963
+ }
4964
+ for ( let value of designSystem . theme . keysInNamespaces ( modifierThemeKeys ) ) {
4965
+ modifiers . push ( value . replaceAll ( '_' , '.' ) )
4966
+ }
4967
+
4968
+ return [ { values, modifiers } ] satisfies SuggestionGroup [ ]
4943
4969
} )
4944
4970
}
4945
4971
}
0 commit comments