npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@xjur-ui/util

v2.0.0

Published

Biblioteca de utilitários JavaScript/TypeScript para o XJur Design System. Inclui helpers para manipulação de classes CSS, variantes de componentes, e outras funcionalidades comuns.

Readme

@xjur-ui/util

Biblioteca de utilitários JavaScript/TypeScript para o XJur Design System. Inclui helpers para manipulação de classes CSS, variantes de componentes, e outras funcionalidades comuns.

Instalação

npm install @xjur-ui/util

Principais Utilitários

cn() - Merge de Classes CSS

Combina classes CSS de forma inteligente usando tailwind-merge e class-variance-authority:

import { cn } from '@xjur-ui/util'

// Resolve conflitos automáticamente
cn('px-4 py-2', 'px-6') // Resultado: 'px-6 py-2'

// Condicional
cn('base-class', condition && 'conditional-class')

// Com objetos
cn('base', {
  'active': isActive,
  'disabled': isDisabled
})

tv() - Tailwind Variants

Criador de variantes para componentes usando tailwind-variants:

import { tv } from '@xjur-ui/util'

const buttonVariants = tv({
  base: 'font-medium rounded-lg transition-colors',
  variants: {
    variant: {
      primary: 'bg-blue-500 text-white hover:bg-blue-600',
      secondary: 'bg-gray-200 text-gray-900 hover:bg-gray-300',
      outline: 'border border-gray-300 bg-white hover:bg-gray-50'
    },
    size: {
      sm: 'px-3 py-1.5 text-sm',
      md: 'px-4 py-2 text-base',
      lg: 'px-6 py-3 text-lg'
    }
  },
  defaultVariants: {
    variant: 'primary',
    size: 'md'
  }
})

// Uso
const classes = buttonVariants({ 
  variant: 'secondary', 
  size: 'lg' 
})

cva() - Class Variance Authority

Sistema de variantes baseado em class-variance-authority:

import { cva } from '@xjur-ui/util'

const alertVariants = cva(
  // Base classes
  'rounded-lg p-4 border',
  {
    variants: {
      intent: {
        info: 'bg-blue-50 text-blue-900 border-blue-200',
        success: 'bg-green-50 text-green-900 border-green-200',
        warning: 'bg-yellow-50 text-yellow-900 border-yellow-200',
        error: 'bg-red-50 text-red-900 border-red-200'
      },
      size: {
        sm: 'text-sm',
        md: 'text-base',
        lg: 'text-lg'
      }
    },
    defaultVariants: {
      intent: 'info',
      size: 'md'
    }
  }
)

Helpers de Cor

Manipulação de Cores com Polished

import { 
  lighten, 
  darken, 
  rgba, 
  transparentize,
  shade,
  tint 
} from '@xjur-ui/util'

// Clarear cor
const lightBlue = lighten(0.2, '#3b82f6')

// Escurecer cor
const darkBlue = darken(0.1, '#3b82f6')

// Adicionar transparência
const semiTransparent = rgba('#3b82f6', 0.5)
const transparent = transparentize(0.5, '#3b82f6')

// Shades e tints
const darker = shade(0.2, '#3b82f6')
const lighter = tint(0.2, '#3b82f6')

Tipos TypeScript

Este pacote inclui tipos TypeScript completos:

import type { 
  type VariantProps,
  type ClassValue
} from '@xjur-ui/util'

// Para componentes com variantes
type ButtonProps = VariantProps<typeof buttonVariants> & {
  children: React.ReactNode
}

Desenvolvimento

# Instalar dependências
npm install

# Modo desenvolvimento (watch)
npm run dev

# Build de produção
npm run build

Performance

  • Tree-shaking: Importe apenas as funções necessárias
  • Bundle otimizado: ~2KB gzipped
  • Zero dependências runtime extras: Usa apenas as necessárias
  • Tipagem completa: IntelliSense completo no TypeScript

Dependências

  • class-variance-authority: Criação de variantes de componentes
  • tailwind-merge: Merge inteligente de classes Tailwind
  • tailwind-variants: Sistema avançado de variantes
  • polished: Manipulação de cores

Licença

Licenciado sob a Licença MIT.