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

@ng-shangjc/utils

v0.0.5-beta

Published

<p align="center"> <a href="https://juliancallejas.github.io/ng-shangjc-docs"> <img src="https://res.cloudinary.com/dphleqb5t/image/upload/v1772819746/shangjc/shangjc-64-bg-dark_kwzs81.svg" width="307" alt="Shangjc" /> </a> </p>

Readme

@ng-shangjc/utils

A comprehensive utility library for Angular Shangjc Components that provides essential tools for building modern UI components with Tailwind CSS.

Official Documentation

🚀 Features

  • Class Name Utility (cn) - Smart Tailwind CSS class merging with conflict resolution
  • Portal Host Directive - Angular directive for managing portal elements
  • Animation Styles - Pre-built CSS animations for smooth transitions

📦 Installation

npm install @ng-shangjc/utils

Peer Dependencies

This package requires the following peer dependencies:

npm install @angular/common @angular/core clsx tailwind-merge

Compatible Angular versions: ^17.0.0 || ^18.0.0 || ^19.0.0 || ^20.0.0 || ^21.0.0

🔧 Usage

Class Name Utility (cn)

The cn function combines clsx and tailwind-merge to provide intelligent class merging that respects Tailwind CSS specificity rules.

import { cn } from '@ng-shangjc/utils';

// Basic usage
const classes = cn('text-red-500', 'bg-blue-500');

// With conditional classes
const isActive = true;
const isDisabled = false;
const classes = cn(
  'base-class',
  isActive && 'text-blue-500',
  isDisabled ? 'opacity-50' : 'opacity-100'
);

// Handles class conflicts automatically
const classes = cn('text-red-500', 'text-blue-500'); // Result: 'text-blue-500'

Portal Host Directive

The portalHost directive allows you to render elements outside their normal DOM hierarchy, useful for modals, tooltips, and overlays.

import { Component } from '@angular/core';

@Component({
  selector: 'app-example',
  template: `
    <div portalHost class="modal-content">
      <!-- This content will be moved to document.body -->
      <h2>Modal Content</h2>
      <p>This is rendered outside the normal DOM flow</p>
    </div>
  `
})
export class ExampleComponent {}

Features:

  • Automatically moves the element to document.body on initialization
  • Handles Escape key events to prevent unwanted behavior
  • Cleans up the element when the directive is destroyed

Animation Styles

Import the CSS animation files to use pre-built animations:

/* In your global styles or component styles */
@import '@ng-shangjc/utils/styles/fade-scale-in.css';
@import '@ng-shangjc/utils/styles/fade-in.css';
@import '@ng-shangjc/utils/styles/fade-out.css';
@import '@ng-shangjc/utils/styles/collapse.css';
@import '@ng-shangjc/utils/styles/expand.css';

Available Animations

  • fade-scale-in - Fade in with scale effect (0 to 1)
  • fade-in - Simple fade in animation
  • fade-out - Simple fade out animation
  • collapse - Collapse animation
  • expand - Expand animation

🎯 API Reference

cn(...inputs: ClassValue[]): string

Merges class names using clsx and tailwind-merge.

Parameters:

  • inputs - Variable number of class values (strings, objects, arrays)

Returns:

  • Merged class name string with conflicts resolved

portalHost Directive

Selector: [portalHost]

Properties:

  • element: HTMLElement - Reference to the native DOM element

Lifecycle Hooks:

  • ngAfterViewInit() - Moves element to document.body and sets up event handlers
  • ngOnDestroy() - Removes element from DOM

🏗️ Development

This package is built with Angular's library format using ng-packagr.

Building

npm run build

Testing

npm run test

📄 License

This package is part of the ng-shadcn project. See the main project license for details.

🤝 Contributing

Contributions are welcome! Please read our contributing guidelines before submitting pull requests.

📝 Changelog

0.0.1

  • Initial release
  • Added cn utility function
  • Added portalHost directive
  • Added basic animation styles

Part of ng-shangjc component libraryDocumentation