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 🙏

© 2024 – Pkg Stats / Ryan Hefner

cat-react-tool

v0.4.0

Published

react版,日常开发插件,包括Alert、Toast、Image等

Downloads

39

Readme

react-tool 组件库

工具列表

Demo (组件不包括UI样式)

Button 按钮

<Button
    className={ 'my-btn br1' }
    onClick={ this.onClick }
    disabled={ false }
>我是一个按钮</Button>

属性 | 说明 | 类型 | 默认值 ---- | ----- | ------ | ------ disabled? | 是否禁止点击 | boolean | 无 onClick? | 点击触发 | () => void | 无 className? | 样式名 | string | 无 style? | style | React.CSSProperties | 无 type? | html的type | string | 无


Toast 提示

Toast({
    duration: 3000,
    text: '我是一个3秒的toast',
})

属性 | 说明 | 类型 | 默认值 ---- | ----- | ------ | ------ text | 提示文字 | string | 无 duration? | 持续时间 | number | 3000


Alert 弹出窗口

Alert({
    subtitle: '我是副标题',
    title: '我是一个alert',
})

属性 | 说明 | 类型 | 默认值 ---- | ----- | ------ | ------ title | 提示标题 | string | 无 subtitle? | 提示内容 | string | 无 noDefault? | 设置没有取消按钮 | boolean | false noPrimary? | 设置没有确定按钮 | boolean | false default? | 点击取消时调用 | () => void | 无 primary? | 点击确定时调用 | () => void | 无


Loading 加载动画

<Loading
   loading={ true }
/>

属性 | 说明 | 类型 | 默认值 ---- | ----- | ------ | ------ loading | loading状态 | boolean | false text? | 文字内容 | string | 加载中


Image 图片

<Image
   className={ 'my-image' }
   src={ 'https://img7.kcimg.cn/uploads/c7/4c/c74cd79689721906d4a5831031a5c8e4.jpg' }
   alt={ '图片' }
/>

属性 | 说明 | 类型 | 默认值 ---- | ----- | ------ | ------ src | 显示图片地址 | string | 无 alt? | 图片文案 | string | 无 className? | 样式名称 | string | 无 defaultSrc? | 默认图片地址 | string | 无 onSuccess? | 成功加载的回调 | () => void | 无 onError? | 错误加载的回调 | (e: any) => void | 无


Select 选择器

// 数据
let data = [{
    value: 0,
    text: '选项1',
    children: [{
        value: 0,
        text: '选项1-1',
    },{
        value: 1,
        text: '选项1-2',
    }]
},{
    value: 1,
    text: '选项2',
    children: [{
        value: 0,
        text: '选项2-1',
    },{
        value: 1,
        text: '选项2-2',
    }]
}]
<Select
    data={ data }
    onConfirm={ this.onConfirm }
    name={ 'username' }
    className={ 'my-select' }
    placeholder={ '请选择名称' }
    length={ 2 }
    error={ '请选择名称' }
/>

举例: 时间选择器城市选择器

// 接口
interface Value {
    text: string;
    value: string | number;
    children?: Value[] | undefined;
}

属性 | 说明 | 类型 | 默认值 ---- | ----- | ------ | ------ data | 选择器数据 | Value[] | [] name | select的name属性 | string | 无 onChange? | 选择器改变后触发 | (item: Value[]) => void | 无 onConfirm? | 确认按钮触发 | (item: Value[]) => void | 无 placeholder? | 未选择默认文案 | string | 请选择 defaultValue? | 默认选项 | Value | 无 className? | 样式名称 | string | 无 length? | 选择器数量 | number | 1 type? | 选择器类型,可选 'date' | string | 无 error? | 错误提示,配合form表单使用,如果设置此项,在form中表示必填 | string | 无


Input 输入框

<Input
   type={ 'password' }
   maxLength={ 10 }
   name={ 'password' }
   className={ 'my-input' }
   placeholder={ '请输入密码' }
   error={ '请输入密码' }
/>

属性 | 说明 | 类型 | 默认值 ---- | ----- | ------ | ------ name | input的name属性 | string | 无 type? | input的type属性,若设置为 textarea 则为 textarea元素,mobile 自动设置长度11位验证,调用数字键盘 | string | 无 maxLength? | input的maxLength属性 | number | 无 className? | 样式名 | string | 无 style? | style | React.CSSProperties | 无 placeholder? | 默认文案 | string | 无 onInput | oninput事件 | (e) => void | 无 onChange | onchange事件 | (e) => void | 无 error? | 错误提示,配合form表单使用,如果设置此项,在form中表示必填 | string | 无


Form 表单

<Form submit={ this.submit } toast={ Toast }>
   <Input
       type={ 'password' }
       maxLength={ 10 }
       name={ 'password' }
       className={ 'my-input' }
       placeholder={ '请输入密码' }
       error={ '请输入密码' }
   />
   <Date
       begin={ 2008 }
       end={ 2019 }
       onConfirm={ this.onConfirm }
       name={ 'time' }
       className={ 'my-select' }
       placeholder={ '请选择时间' }
       error={ '请选择时间' }
   />
   <Input
       type={ 'textarea' }
       maxLength={ 100 }
       name={ 'textarea' }
       className={ 'my-textarea' }
       placeholder={ '请输入文字' }
       error={ '请输入文字' }
   />
   <Button type={ 'submit' } className={ 'my-btn br1' }>提交</Button>
</Form>

属性 | 说明 | 类型 | 默认值 ---- | ----- | ------ | ------ submit? | 提交表单 返回表单内input、select、textarea等原生html元素的json对象,例:{password: 123, textarea: 666} | (json:object) => void | 无 toast? | 提示器 | any | 无 rules? | 表单字段校验 | object | 无


Tool 工具

Rem.set(750); 设置html font-size 以设计稿750为基准 1rem == 100px
Rem.get(750); 返回 以750为基准的像素值
@Mounted 装饰器,用于装饰react组件,可以防止组件卸载后调用setState 导致报错的问题
@readonly 装饰器,用于设置属性只读,不可被修改