Home

tailwind-ctp-intellisense @6ecb0011cfb7ac1e5e234acfd49459fb6ca2783e - refs - log -
-
https://git.jolheiser.com/tailwind-ctp-intellisense.git
Tailwind intellisense + Catppuccin
tailwind-ctp-intellisense / packages / tailwindcss-language-service / src / util / getClassNameMeta.ts
- raw
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import { State, ClassNameMeta } from './state'
import { getClassNameParts } from './getClassNameAtPosition'
import dlv from 'dlv'

export function getClassNameMeta(
  state: State,
  classNameOrParts: string | string[]
): ClassNameMeta | ClassNameMeta[] {
  const parts = Array.isArray(classNameOrParts)
    ? classNameOrParts
    : getClassNameParts(state, classNameOrParts)
  if (!parts) return null
  const info = dlv(state.classNames.classNames, [...parts, '__info'])

  if (Array.isArray(info)) {
    return info.map((i) => ({
      source: i.__source,
      pseudo: i.__pseudo,
      scope: i.__scope,
      context: i.__context,
    }))
  }

  return {
    source: info.__source,
    pseudo: info.__pseudo,
    scope: info.__scope,
    context: info.__context,
  }
}