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

@dailyboxes/box-react-img-upload

v1.0.13

Published

React image upload and crop component built with Ant Design and antd-img-crop

Downloads

1,843

Readme

@dailyboxes/box-react-img-upload

此仓库是个人项目使用,如要使用,请下载后根据自己的需求进行更改。

基于 reactantdantd-img-crop 的 Web 图片上传裁剪组件。

组件特性:

  • 支持图片裁剪
  • 支持限制上传图片格式
  • 返回裁剪后图片的 base64
  • 返回原始文件后缀 suffix
  • 支持受控回显

Install

npm install @dailyboxes/box-react-img-upload react react-dom antd antd-img-crop

Usage

import React, { useState } from 'react';
import { BoxReactImgUpload, ImgUploadResult } from '@dailyboxes/box-react-img-upload';

export default function Demo() {
  const [image, setImage] = useState('');

  const handleChange = (result: ImgUploadResult | ImgUploadResult[]) => {
    if (Array.isArray(result)) {
      return;
    }

    setImage(result.base64);
    console.log(result.base64, result.suffix);
  };

  return (
    <BoxReactImgUpload
      value={image}
      width={160}
      height={160}
      acceptedTypes={['image/png', 'image/jpeg', 'image/webp']}
      cropProps={{
        aspect: 1,
        rotationSlider: true,
        aspectSlider: true,
      }}
      onChange={handleChange}
    />
  );
}

Multiple Upload Without Crop

<BoxReactImgUpload
  enableCrop={false}
  multiple
  maxCount={3}
  onChange={(result) => {
    if (Array.isArray(result)) {
      console.log(result);
    }
  }}
/>

Disable Internal Preview

<BoxReactImgUpload
  showPreviewImage={false}
  onChange={(result) => {
    console.log(result.base64, result.suffix);
  }}
/>

Exports

import {
  BoxReactImgUpload,
  ImageCropUpload,
  DEFAULT_ACCEPTED_IMAGE_TYPES,
} from '@dailyboxes/box-react-img-upload';

Props

| Name | Type | Default | Description | | --- | --- | --- | --- | | value | string | undefined | 回显图片地址或 base64 | | onChange | (result: ImgUploadResult \| ImgUploadResult[]) => void | undefined | 单图模式返回对象,多图模式返回数组 | | onRemove | (file?: UploadFile) => void | undefined | 删除图片时触发 | | acceptedTypes | readonly string[] | 内置常见图片格式 | 允许上传的 MIME 类型 | | tips | string | '上传图片' | 上传提示文案 | | width | number \| string | 120 | 组件宽度 | | height | number \| string | 120 | 组件高度 | | disabled | boolean | false | 是否禁用 | | showPreviewImage | boolean | true | 是否在组件内部回显已上传图片 | | enableCrop | boolean | true | 是否开启裁剪,关闭后走普通上传 | | multiple | boolean | false | 非裁剪模式下是否允许多选 | | maxCount | number | 1 | 非裁剪模式下最多可选择的图片数量 | | cropProps | Omit<ImgCropProps, 'children'> | undefined | antd-img-crop 参数透传 |

其余属性会透传到 antdUpload 组件。

Return Type

type ImgUploadResult = {
  base64: string;
  suffix: string;
  file: File;
};

组件版本依赖

  • react: 18.x.x
  • react-dom: 18.x.x
  • @types/react: 18.x.x
  • @types/react-dom: 18.x.x