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

@jae-o/hooks-module

v1.0.4

Published

hooks module

Readme

🧩 hooks module

React 프로젝트에서 결제 폼을 만들 때 사용할 수 있는 커스텀 훅 모음입니다.
카드 번호, 유효기간, CVC 등 다양한 입력 필드에 대해 유효성 검사와 상태 관리 기능을 함께 제공합니다.

✨ Features

  • 카드 정보 입력 필드별 상태유효성 검증 일괄 관리
  • 카드 브랜드(VISA, MasterCard 등) 자동 감지
  • 타입 안전한 TypeScript 기반
  • skipValidation 옵션 제공으로 유연한 상태 업데이트 가능

📦 Installation

npm i @jae-o/hooks-module

🧪 제공 훅 목록

  • useCardNumbers: 카드 번호 입력 (3~4칸) 상태 및 검증
  • useExpiryDate: 유효기간 (MM/YY) 입력 및 검증
  • useCVC: 카드 CVC 입력 및 검증

사용 예시: useCardNumbers

import { useCardNumbers } from '@jae-o/hooks-module';

function CardInputForm() {
  const { cardNumbers, validationResults, cardBrand, handleCardNumbersChange } =
    useCardNumbers([
      { name: 'part1', length: 4 },
      { name: 'part2', length: 4 },
      { name: 'part3', length: 4 },
      { name: 'part4', length: 4 },
    ]);

  return (
    <div>
      {(['part1', 'part2', 'part3', 'part4'] as const).map((key) => (
        <input
          key={key}
          value={cardNumbers[key]}
          onChange={(e) => handleCardNumbersChange(key, e.target.value)}
        />
      ))}
      <p>Detected Brand: {cardBrand}</p>
      <p>Error: {validationResults.part1.errorMessage}</p>
    </div>
  );
}

📘 API Reference

useCardNumbers

  • 카드 번호 입력 필드(3~4칸)의 상태와 유효성 검사, 카드 브랜드 감지를 지원합니다.

| 반환값 | 타입 | 설명 | | ------------------------------ | ------------------------------------------------------------------------------------------------------------- | ------------------------------- | | cardNumbers | Record<필드이름, string> | 입력된 카드 번호 값들 | | validationResults | Record<필드이름, { isValid: boolean; errorMessage: string }> | 각 필드별 유효성 검사 결과 | | cardBrand | 'VISA' \| 'MASTERCARD' \| 'AMEX' \| 'DINERS' \| 'UNIONPAY' \| 'UNKNOWN' | 카드 브랜드 감지 결과 | | handleCardNumbersChange | ({ key, value, options }: { key: 필드이름; value: string; options?: { skipValidation?: boolean } }) => void | 입력 변경 핸들러 | | getCardNumberValidationError | (key: 필드이름, value: string) => 에러타입 \| null | 카드 번호 조각 유효성 검사 함수 |

옵션 설명

  • skipValidation: true로 설정 시 유효성 오류가 있어도 값을 강제로 업데이트합니다. (자동완성, 서버 데이터 주입 시 유용)

useExpiryDate

  • 카드 유효기간(MM/YY) 입력을 관리하고, 만료 여부도 검증합니다.

| 반환값 | 타입 | 설명 | | ------------------------------ | ----------------------------------------------- | ------------------------ | | expiryDate | { month: string; year: string } | 월/연도 입력 값 | | validationResults | Record<'month' \| 'year', ValidationResult> | 각 필드 유효성 결과 | | handleExpiryDateChange | (key, value, options?) => void | 월 또는 연도 변경 핸들러 | | getExpiryDateValidationError | (key, value) => 에러타입 \| null | 포맷 검증 함수 | | getExpiryDateExpiredError | (key, value, otherFields) => 에러타입 \| null | 만료 여부 검증 함수 |

useCVC

  • 카드 CVC 입력 필드를 관리합니다.

| 반환값 | 타입 | 설명 | | ----------------------- | -------------------------------------------- | ------------------ | | CVC | string | 입력된 CVC 값 | | validationResult | { isValid: boolean; errorMessage: string } | 유효성 검사 결과 | | handleCVCChange | (value, options?) => void | CVC 값 변경 핸들러 | | getCVCValidationError | (value) => 에러타입 \| null | 포맷 검증 함수 |