tailwind-ctp-intellisense/packages/tailwindcss-language-service/src/util/getClassNameDecls.ts

21 lines
531 B
TypeScript
Raw Normal View History

2020-06-11 17:07:20 +00:00
import { State } from './state'
import { getClassNameParts } from './getClassNameAtPosition'
import removeMeta from './removeMeta'
import dlv from 'dlv'
2020-06-11 17:07:20 +00:00
export function getClassNameDecls(
state: State,
className: string
): Record<string, string> | Record<string, string>[] | null {
const parts = getClassNameParts(state, className)
if (!parts) return null
2020-11-19 17:34:59 +00:00
const info = dlv(state.classNames.classNames, [...parts, '__info'])
2020-06-11 17:07:20 +00:00
if (Array.isArray(info)) {
return info.map(removeMeta)
}
return removeMeta(info)
}