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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@tcn/ui-utils

v1.4.0

Published

TCN UI Utils Component Library

Readme

@tcn/ui-utils

A collection of essential utility components, hooks, and functions that provide common functionality needed across React applications.

Overview

@tcn/ui-utils provides a set of reusable utilities that solve common UI patterns and challenges. These utilities are designed to be lightweight, performant, and easy to integrate into any React application.

What's Included

Event Listeners

  • ClickAwayListener: Detects clicks outside of a component, useful for modals, dropdowns, and popovers
  • ScrollAwayListener: Monitors scroll events outside of a component, helpful for scroll-triggered interactions
  • FocusRedirect: Manages focus behavior and redirects focus to appropriate elements

React Hooks

  • useResizeObserver: Efficiently tracks element size changes with configurable triggers
  • useForkRef: Combines multiple refs into a single ref for complex ref scenarios
  • makeContextHook: Utility for creating context hooks with proper typing

Calendar Utilities

  • Calendar Date Management: Helper functions for working with dates in calendar components
  • Month/Year Generators: Utilities for generating calendar month and year data
  • Day/Week Helpers: Functions for working with days of the week and calendar navigation

Utility Functions

  • StyleInjector: Component for dynamically injecting styles into the DOM
  • Default Value: Utility for providing fallback values with type safety

Key Features

  • Performance Optimized: Uses efficient event handling and minimal re-renders
  • TypeScript First: Full type safety with excellent IntelliSense support
  • Accessibility Focused: Built with accessibility best practices in mind
  • Lightweight: Minimal bundle size impact with maximum utility
  • Composable: Utilities can be combined and extended as needed

Common Use Cases

Modal and Dropdown Management

import { ClickAwayListener } from '@tcn/ui-utils';

function Modal({ isOpen, onClose, children }) {
  if (!isOpen) return null;
  
  return (
    <ClickAwayListener onClickAway={onClose}>
      <div className="modal">
        {children}
      </div>
    </ClickAwayListener>
  );
}

Responsive Layouts

import { useResizeObserver } from '@tcn/ui-utils';

function ResponsiveComponent() {
  const [size, setSize] = useState({ width: 0, height: 0 });
  
  const ref = useResizeObserver((width, height) => {
    setSize({ width, height });
  });
  
  return (
    <div ref={ref}>
      Current size: {size.width} x {size.height}
    </div>
  );
}

Calendar Components

import { getMonthsOfYear, getDaysOfWeek } from '@tcn/ui-utils';

// Generate calendar data
const months = getMonthsOfYear();
const weekDays = getDaysOfWeek();

Integration

This package is designed to work seamlessly with other Blackcat UI packages and can be used independently in any React application. It provides the building blocks for:

  • Complex UI Interactions: Event handling for sophisticated user interactions
  • Responsive Design: Size monitoring and responsive behavior
  • Accessibility: Focus management and keyboard navigation
  • Data Management: Calendar utilities and data helpers

When to Use

Choose @tcn/ui-utils when you need:

  • Event handling for clicks outside components
  • Responsive behavior based on element size changes
  • Calendar-related functionality
  • Focus management and accessibility features
  • Utility functions for common UI patterns

Architecture

The utilities are organized into logical groups:

  1. Event Listeners: Components that handle external events
  2. Hooks: Custom React hooks for common functionality
  3. Calendar Utils: Date and calendar-related functions
  4. Helpers: General utility functions and components

License

Apache-2.0