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

@cbm-common/text-input-directive

v0.0.4

Published

Documentación en español para la librería `text-input-directive`.

Readme

text-input-directive

Documentación en español para la librería text-input-directive.

Propósito

La librería exporta la directiva CbmTextInputDirective (standalone) que facilita el control de entradas de texto en formularios, aplicando transformaciones, validaciones en tiempo real y reglas de pegado. Es útil para normalizar el comportamiento de inputs de texto en distintas pantallas.

Qué exporta

  • CbmTextInputDirective — directiva standalone que se aplica a elementos <input> o <textarea>.
  • TCbmTextInputTransform — tipo 'uppercase' | 'lowercase' | 'capitalize'.

Inputs / parámetros

La directiva declara los siguientes inputs (usando la función input() de Angular):

  • maxTextLength?: number — longitud máxima total del texto. Si se supera, se evita la inserción.
  • maxWordLength?: number — longitud máxima permitida por palabra; palabras largas se truncan o se bloquean en pegado.
  • transform?: 'uppercase' | 'lowercase' | 'capitalize' — transformación que se aplica en cada input.
  • pattern?: string | RegExp — expresión regular para validar caracteres permitidos; si la entrada no cumple, se previene la acción.

Comportamiento principal

  • onKeyDown: valida la tecla pulsada contra pattern, controla longitud total y longitud de palabra actual, y permite teclas especiales (Backspace, flechas, Ctrl+C/V/X).
  • onPaste: valida el texto pegado contra pattern, maxTextLength y maxWordLength. Publica mensajes de error usando PubSub.publish('alert', { ... }) cuando la validación falla.
  • onInput: aplica la transform configurada y trunca palabras que exceden maxWordLength.

Ejemplo de uso

En template:

<input
  cbmTextInput
  [maxTextLength]="100"
  [maxWordLength]="20"
  [transform]="'capitalize'"
  [pattern]="'^[A-Za-z0-9 ]*$'"
/>

Notas técnicas

  • La directiva usa PubSub (paquete pubsub-js) para publicar alertas en el evento paste cuando el contenido pegado no cumple las reglas. Asegúrate de tener un manejador global para alert o sustituir esa lógica según tus necesidades.
  • input() es usado para declarar inputs de forma compacta; la directiva lee estos valores en tiempo de ejecución.
  • Se permiten operaciones de portapapeles con Ctrl/C/V/X y navegación con flechas.

Testing

El proyecto incluye una spec base text-input.directive.spec.ts. Ejecuta las pruebas con:

ng test

Contribuciones y mejoras sugeridas

  • Añadir soporte para reglas de validación más complejas (por ejemplo bloqueo por blacklist).
  • Hacer la publicación de alertas configurable (callback o servicio de mensajes en vez de PubSub directo).

Licencia

Consulta la licencia del repositorio principal.