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

phone-display-component

v1.0.0

Published

A web component for displaying phone numbers with toggle visibility - works in Vue, React, Angular, and vanilla JS

Readme

Phone Display Component

一个基于 Lit 的 Web Component,用于显示手机号码,默认隐藏中间4位,点击可切换显示完整号码。

安装

npm install phone-display-component

特性

  • 基于 Web Components 标准,可在任何框架中使用(Vue、React、Angular、原生 JS)
  • 默认隐藏手机号中间4位(如 138****5678)
  • 点击切换显示/隐藏
  • 轻量级,基于 Lit

使用方式

原生 HTML / JavaScript

<!DOCTYPE html>
<html>
<head>
  <script type="module">
    import 'phone-display-component';
  </script>
</head>
<body>
  <phone-display phone="13812345678"></phone-display>
</body>
</html>

Vue 3

<template>
  <phone-display :phone="phoneNumber"></phone-display>
</template>

<script setup>
import 'phone-display-component';

const phoneNumber = '13812345678';
</script>

注意: Vue 需要配置忽略自定义元素:

// vite.config.js
export default defineConfig({
  plugins: [
    vue({
      template: {
        compilerOptions: {
          isCustomElement: (tag) => tag.includes('-')
        }
      }
    })
  ]
})

React

import 'phone-display-component';

function App() {
  return (
    <phone-display phone="13812345678"></phone-display>
  );
}

export default App;

TypeScript 支持 (在项目中添加类型声明):

// global.d.ts
declare global {
  namespace JSX {
    interface IntrinsicElements {
      'phone-display': React.DetailedHTMLProps<
        React.HTMLAttributes<HTMLElement> & { phone?: string },
        HTMLElement
      >;
    }
  }
}

Angular

// app.module.ts
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';

@NgModule({
  schemas: [CUSTOM_ELEMENTS_SCHEMA],
})
export class AppModule { }
// app.component.ts
import 'phone-display-component';

@Component({
  template: `<phone-display [attr.phone]="phoneNumber"></phone-display>`
})
export class AppComponent {
  phoneNumber = '13812345678';
}

API

属性

| 属性 | 类型 | 默认值 | 说明 | |------|------|--------|------| | phone | String | '' | 要显示的手机号码(11位数字) |

本地开发

# 安装依赖
npm install

# 启动开发服务器
npm run dev

发布

npm login
npm publish

License

MIT