import type { VariantFunction } from '@unocss/core' ; import type { Theme } from '@unocss/preset-mini' ; import { handler as h , parseColor } from '@unocss/preset-mini/utils' ; export const placeholderModifier = ( input , { theme } ) => { const m = input . match ( /^(.*)\b(placeholder-)(.+)$/ ) ; if ( m ) { const [ , pre = '' , p , body ] = m ; if ( hasColorValue ( body , theme ) || hasOpacityValue ( body ) ) { return { matcher : `${ pre }placeholder-$ ${ p }${ body }` , } ; } } } ; function hasColorValue ( body , theme ) { return ! ! parseColor ( body , theme ) ?. color ; } function hasOpacityValue ( body ) { const match = body . match ( /^op(?:acity)?-?(.+)$/ ) ; if ( match && match [ 1 ] != null ) return h . bracket . percent ( match [ 1 ] ) != null ; return false ; }