Handle the `DEFAULT` case for `matchVariant` (#635)
* handle the `DEFAULT` case * Prettier Co-authored-by: Brad Cornes <hello@bradley.dev>master
parent
a12e3ae686
commit
3f9762e003
|
@ -216,7 +216,10 @@ export function completionsFromClassList(
|
|||
.filter((value) => !existingVariants.includes(`${variant.name}-${value}`))
|
||||
.map((value) =>
|
||||
variantItem({
|
||||
label: `${variant.name}${variant.hasDash ? '-' : ''}${value}${sep}`,
|
||||
label:
|
||||
value === 'DEFAULT'
|
||||
? `${variant.name}${sep}`
|
||||
: `${variant.name}${variant.hasDash ? '-' : ''}${value}${sep}`,
|
||||
detail: variant.selectors({ value }).join(', '),
|
||||
})
|
||||
)
|
||||
|
@ -845,7 +848,9 @@ function provideVariantsDirectiveCompletions(
|
|||
|
||||
let possibleVariants = state.variants.flatMap((variant) => {
|
||||
if (variant.values.length) {
|
||||
return variant.values.map((value) => `${variant.name}${variant.hasDash ? '-' : ''}${value}`)
|
||||
return variant.values.map((value) =>
|
||||
value === 'DEFAULT' ? variant.name : `${variant.name}${variant.hasDash ? '-' : ''}${value}`
|
||||
)
|
||||
}
|
||||
return [variant.name]
|
||||
})
|
||||
|
|
|
@ -34,7 +34,9 @@ export function getInvalidVariantDiagnostics(
|
|||
|
||||
let possibleVariants = state.variants.flatMap((variant) => {
|
||||
if (variant.values.length) {
|
||||
return variant.values.map((value) => `${variant.name}${variant.hasDash ? '-' : ''}${value}`)
|
||||
return variant.values.map((value) =>
|
||||
value === 'DEFAULT' ? variant.name : `${variant.name}${variant.hasDash ? '-' : ''}${value}`
|
||||
)
|
||||
}
|
||||
return [variant.name]
|
||||
})
|
||||
|
|
|
@ -7,7 +7,9 @@ export function getVariantsFromClassName(
|
|||
): { variants: string[]; offset: number } {
|
||||
let allVariants = state.variants.flatMap((variant) => {
|
||||
if (variant.values.length) {
|
||||
return variant.values.map((value) => `${variant.name}${variant.hasDash ? '-' : ''}${value}`)
|
||||
return variant.values.map((value) =>
|
||||
value === 'DEFAULT' ? variant.name : `${variant.name}${variant.hasDash ? '-' : ''}${value}`
|
||||
)
|
||||
}
|
||||
return [variant.name]
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue