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

pypjs

v0.1.9

Published

A simple, easy-to-use, framework-agnostic payment panel component

Readme

English | 简体中文

pypjs

A simple, easy-to-use, framework-agnostic payment panel component.

Usage

1. Installation

npm install pypjs

Or use other package managers (pnpm, yarn, etc.)

2. Import

ES Module:

import pypjs from 'pypjs'

Script Tag:

<script src="./dist/index.js"></script>

3. Basic Usage

// Open/close panel
pypjs.open(99.99) // Supports number or string
pypjs.close()

// Set amount
pypjs.setAmount(199.0) // Supports number or string

4. Payment Methods

pypjs.setPaymentMethods([
  { id: 1, name: 'WeChat Pay', desc: 'Recommended', icon: '💳' },
  { id: 2, name: 'Alipay', desc: 'Secure & Convenient', icon: '💰' }
], {
  titleField: 'name',
  subtitleField: 'desc',
  iconField: 'icon',
  valueField: 'id'
})

// Two-level grouping
pypjs.setPaymentMethods([
  {
    name: 'Online Payment',
    children: [
      { id: 1, name: 'WeChat Pay', icon: '💳' },
      { id: 2, name: 'Alipay', icon: '💰' }
    ]
  }
], { titleField: 'name', valueField: 'id' })

5. Configuration

pypjs.setConfig({
  allowSwipeToClose: false,
  closeOnOverlayClick: false,
  enablePassword: true,
  passwordLength: 6,
  language: 'zh',
  themeMode: 'auto',
  keyboardMapping: ['!', '@', '#', '$', '%', '^', '&', '*', '(', ')'],
  theme: {
    primaryColor: '#ff4d4f',
    panelBgLight: '#ffffff',
    panelBgDark: '#2d2d2d'
  }
})

6. Events

pypjs.on('confirm', (e) => {
  const { method, amount, password } = e.detail
  console.log('Payment:', method, amount, password)
})

pypjs.on('close', () => {
  console.log('Panel closed')
})

Features

  • i18n: Supports zh, en, ja, ru with partial override
  • Theme: light | dark | auto (follow system), customizable colors and gradients
  • Keyboard Mapping: Map digits 0-9 to custom characters (keyboard displays digits, input uses mapped values)
  • Icon Display: always | never | auto, supports image URL, emoji, or default SVG
  • Amount Alignment: left | center | right with custom fonts

API Reference

Basic Methods

  • pypjs.open(amount?: number | string) - Open payment panel, optionally with amount
  • pypjs.close() - Close payment panel
  • pypjs.setAmount(amount: number | string) - Set payment amount

Payment Methods

  • pypjs.setPaymentMethods(methods?, fieldMapping?) - Set payment methods list
    • methods: Payment methods array (optional)
    • fieldMapping: Optional field mapping configuration
      • titleField: Title field name (default 'title' or 'name')
      • subtitleField: Subtitle field name (default 'subtitle' or 'desc')
      • iconField: Icon field name (default 'icon')
      • valueField: Value field name (default 'value' or 'id')
  • pypjs.getSelectedMethod() - Get currently selected payment method

Configuration

  • pypjs.setConfig(config: PaymentPanelConfig) - Configure all options

Config Options:

  • allowSwipeToClose?: boolean - Allow swipe to close (default true)
  • closeOnOverlayClick?: boolean - Close on overlay click (default true)
  • enablePassword?: boolean - Enable password input (default false)
  • passwordLength?: number - Password length (default 6, range 4-12)
  • headerTitle?: string - Header title (optional, defaults to i18n)
  • amountLabel?: string - Amount label (optional, defaults to i18n)
  • iconDisplay?: 'always' | 'never' | 'auto' - Icon display mode (default 'always')
  • closeThreshold?: number - Close distance threshold in pixels (default 100)
  • closeThresholdPercent?: number - Close distance threshold percentage 0-1 (default 0.3)
  • velocityThreshold?: number - Velocity threshold pixels/ms (default 0.5)
  • allowConfirmWithoutMethods?: boolean - Allow confirm without payment methods (default true)
  • hidePaymentMethods?: boolean - Hide payment methods section (default false)
  • amountAlign?: 'left' | 'center' | 'right' - Amount alignment (default 'left')
  • amountFont?: string - Amount font family
  • textFont?: string - Text font family
  • language?: 'zh' | 'en' | 'ja' | 'ru' - Language setting (default 'en')
  • i18n?: Partial<I18nTexts> - Custom i18n texts (partial override)
  • themeMode?: 'light' | 'dark' | 'auto' - Theme mode (default 'auto')
  • keyboardMapping?: string[] - Keyboard character mapping, array of 10 strings for digits 0-9
  • theme?: ThemeConfig - Theme configuration
    • primaryColor?: string - Primary color (default "#238636")
    • primaryHoverColor?: string - Primary hover color (default "#2ea043")
    • overlayColor?: string - Overlay color (default "rgba(0, 0, 0, 0.5)")
    • panelBgLight?: string - Panel background in light mode (default "#ffffff", supports gradients)
    • panelBgDark?: string - Panel background in dark mode (default "#2d2d2d", supports gradients)
    • textPrimaryLight?: string - Primary text color in light mode (default "#24292f")
    • textPrimaryDark?: string - Primary text color in dark mode (default "#e0e0e0")
    • textSecondaryLight?: string - Secondary text color in light mode (default "#57606a")
    • textSecondaryDark?: string - Secondary text color in dark mode (default "#999999")

Individual Methods

  • pypjs.setHeaderTitle(title?: string) - Set header title
  • pypjs.setAmountLabel(label?: string) - Set amount label
  • pypjs.setCloseThreshold(threshold: number) - Set close threshold (pixels)
  • pypjs.setCloseThresholdPercent(percent: number) - Set close threshold (percentage 0-1)
  • pypjs.setVelocityThreshold(threshold: number) - Set velocity threshold
  • pypjs.setCloseOnOverlayClick(close: boolean) - Set close on overlay click
  • pypjs.setEnablePassword(enable: boolean) - Set enable password input
  • pypjs.setPasswordLength(length: number) - Set password length (4-12)
  • pypjs.setKeyboardMapping(mapping: string[]) - Set keyboard character mapping
  • pypjs.setAllowConfirmWithoutMethods(allow: boolean) - Set allow confirm without methods
  • pypjs.setHidePaymentMethods(hide: boolean) - Set hide payment methods
  • pypjs.setAmountAlign(align: 'left' | 'center' | 'right') - Set amount alignment
  • pypjs.setAmountFont(font: string) - Set amount font
  • pypjs.setTextFont(font: string) - Set text font
  • pypjs.setLanguage(lang: 'zh' | 'en' | 'ja' | 'ru') - Set language
  • pypjs.setI18n(i18n: Partial<I18nTexts>) - Set custom i18n texts
  • pypjs.setThemeMode(mode: 'light' | 'dark' | 'auto') - Set theme mode
  • pypjs.setTheme(theme: ThemeConfig) - Set theme configuration
  • pypjs.getTheme() - Get current theme configuration

Events

  • pypjs.on('confirm', handler) - Listen to payment confirm event
    • Event detail: { method, amount, password, methodData }
  • pypjs.on('close', handler) - Listen to panel close event
  • pypjs.off(event, handler) - Remove event listener
  • pypjs.removeAllListeners(event?) - Remove all event listeners

Browser Support

Modern browsers (Chrome, Firefox, Safari, Edge) and mobile browsers.

License

MIT