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

ui-component-react

v1.0.15

Published

`npm install ui-component-react`

Downloads

13

Readme

Install

npm install ui-component-react

yarn add ui-component-react

pnpm add ui-component-react

Description

仿照element-ui的组件,使用react实现。按钮事件onClick,输入空、日期选择、下拉筛选等事件为onChange事件,支持form表单,自定义规则等,格式与element一致,目前只实现部分组件,后续会持续更新。该组件版本较高,需要router的v6版本和react的18版本或者支持useContext、useMemo等语法版本。

Usage

项目案例gitee地址: https://gitee.com/niuhailive/react-component-example.git,clone后install直接运行dev,推荐使用yarn;

import React,{ useState,useRef } from 'react';

import { UiButton,UiDatePicker,UiForm,UiFormItem,UiInput,UiSelect,UiTable,$message,$messageBox } from 'ui-component-react';

import 'ui-component-react/lib/theme-chalk/index.scss';

const App = () => (

const formRef = useRef();

const [ time,setTime ] = useState(new Date());
const [ status,seStatus ] = useState([]);
const [ formModel,setFormModel ] = useState({
    account: '',
    password: ''
});

const header = [  {
        title: '名称',
        key: 'name',
        tooltip: true
    },  {
        title: '状态',
        key: 'status',
        slot: 'status'
    },  {
        title: '地址',
        subHeader:[
            {
                title: '省',
                key: 'economize'
            },  {
                title: '市',
                key: 'market'
            },  {
                title: '县',
                key: 'county',
                subHeader: [
                    {
                        title: '镇,
                        key: 'zhen
                    },
                    {
                        title: '乡下',
                        key: 'xiang'
                    }
                ]
            }
        ]
    },
    {
        title: '操作',
        slot: 'action'
    }
]
const data = [
    {
        name: '名字',
        economize: 'xxx省',
        market: 'xxx市',
        county: 'xxx县',
        zhen: 'xxx镇',
        xiang: 'xxx乡',
    }
]
const options = [
    {
        label: '待使用',
        value: 'wait',
    }
]

function passwordValid(rule, value,callback){
    if(!value){
        callback(new Error('请输入密码`));
    }else if(value.length < 6 && value.length > 18){
        callback(new Error('密码长度为6到18位!`));
    }else {
        callback();
    }
}
const rules = {
    account: [
        { required: true,message: '请输入账号!',trigger: 'blur' }
    ],
    password: [
        { required: true,message: '请输入密码!',trigger: 'blur' },
        { validator: passwordValid,trigger: 'blur' }
    ]
}

function submitForm(){
    formRef.current.validate((valid)=>{
        if(valid){

        }else {
            $message.error('请按要求填写表单!')
        }
    })
};
function goDelete(val){
    $messageBox.confirm('是否删除?','删除',{
        confirmButtonText: '确认',
        cancelButtonText: '取消',
        type: 'warning'
    }).then(()=>{

    }).catch(()=>{
        $message.info('取消删除!')
    })
}

return <>
    <UiDatePicker clearable value={ time } onChange={ setTime }/>
    <UiSelect clearable value={ status } options={ options } onChange={ seStatus }/>
    <UiInput value={ status } options={ options } onChange={ seStatus }/>
    <UiButton type="primary" onClick(()=>submitForm)>PRESS ME</UiButton>
    
    <UiForm ref={ formRef } model={ formModel } rules={ rules } labelPosition='top'>
        <UiFormItem label="账号" prop="account">
            <UiInput value={ formModel.account } onChange={ (e)=>setFormModel({ ...formModel,account: e }) } />
        </UiFormItem>
        <UiFormItem label="密码" prop="password">
            <UiInput value={ formModel.password } onChange={ (e)=>setFormModel({ ...formModel,password: e }) } />
        </UiFormItem>
    </UiForm>
    <UiTable header={ header } data={ data }>
        {
            status: (item)=>{
                return <div>{ item.status }</div>
            },
            action: (item)=>{
                return <div>
                    <UiButton type="danger" size="small" onClick={()=>goDelete(item)}删除</UiButton>
                </div>
            }
        }
    </UiTable>
</UiSelect>

);