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

@saberlayer/avatar-upload

v1.1.0

Published

A React avatar upload component with image crop feature based on Ant Design

Readme

@saberlayer/avatar-upload

一个基于 Ant Design 的头像上传组件,支持图片裁剪功能。

更新日志

v1.1.0

  • 优化文件结构,统一构建输出到 dist 目录
  • 简化包体积,移除冗余文件
  • 保持对 CommonJS、ES Module 和 UMD 的完整支持
  • 优化 TypeScript 类型声明文件位置

安装

npm install @saberlayer/avatar-upload
# 或
yarn add @saberlayer/avatar-upload

使用方法

支持多种导入方式:

ES Modules

import { AvatarUpload } from '@saberlayer/avatar-upload';
import '@saberlayer/avatar-upload/dist/index.css';

CommonJS

const { AvatarUpload } = require('@saberlayer/avatar-upload');
require('@saberlayer/avatar-upload/dist/index.css');

UMD

<link rel="stylesheet" href="https://unpkg.com/@saberlayer/avatar-upload/dist/index.css" />
<script src="https://unpkg.com/@saberlayer/avatar-upload/dist/index.umd.js"></script>

使用示例

import React from 'react';
import { AvatarUpload } from '@saberlayer/avatar-upload';
import '@saberlayer/avatar-upload/dist/index.css';

const App = () => {
  const handleChange = (url) => {
    console.log('头像地址:', url);
  };

  return (
    <AvatarUpload
      value="https://example.com/avatar.jpg"
      onChange={handleChange}
      maxSize={2} // 最大文件大小,单位MB,默认2MB
    />
  );
};

export default App;

API

| 参数 | 说明 | 类型 | 默认值 | | --- | --- | --- | --- | | value | 头像URL | string | - | | onChange | 头像变化时的回调函数 | (url: string) => void | - | | maxSize | 最大文件大小,单位MB | number | 2 |

特性

  • 支持图片上传
  • 支持图片裁剪
  • 支持预览
  • 支持文件大小限制
  • 支持 JPG/PNG 格式
  • 美观的 UI 界面
  • 支持 TypeScript
  • 支持 Tree Shaking
  • 支持多种模块规范(ES Module/CommonJS/UMD)

开发

# 安装依赖
npm install

# 开发模式
npm run dev

# 构建
npm run build

License

MIT

目录结构

dist/
  ├── index.cjs.js      # CommonJS 版本
  ├── index.cjs.js.map
  ├── index.esm.js      # ES Module 版本
  ├── index.esm.js.map
  ├── index.umd.js      # UMD 版本
  ├── index.umd.js.map
  ├── index.d.ts        # TypeScript 类型声明
  └── index.css         # 样式文件