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

react-pickers

v0.1.1

Published

datapicker and citypicker base on MUI of picker

Downloads

17

Readme

react-picker

datapicker and citypicker base on MUI of picker

Installation

Using npm:

$ npm install --save react-pickers

Then with a module bundler like webpack that supports either CommonJS or ES2015 modules, use as you would anything else:


// using an ES6 transpiler, like babel
import { DatePicker, CityPicker } from 'react-pickers'

// not using an ES6 transpiler
var DatePicker = require('react-pickers').DatePicker
var CityPicker = require('react-pickers').CityPicker

What's it look like?

import React, { Component } from 'react';
import { render } from 'react-dom';

import 'react-pickers/lib/css/picker.css'
import { CityPicker, DatePicker } from 'react-picker'


import city2 from '../lib/city-data'
import city3 from '../lib/city-data-3'

class App extends Component{

    state = {
        showCityPicker: false,
        showCity2Picker:false,
        showCity3Picker:false,
        showDatePicker:false,
        showDatePicker2:false,
        singleData : [{
			value: 'ywj',
			text: '董事长 叶文洁'
		}, {
			value: 'aaa',
			text: '总经理 艾AA'
		}, {
			value: 'lj',
			text: '罗辑'
		}, {
			value: 'ymt',
			text: '云天明'
		}, {
			value: 'shq',
			text: '史强'
		}, {
			value: 'zhbh',
			text: '章北海'
		}, {
			value: 'zhy',
			text: '庄颜'
		}, {
			value: 'gyf',
			text: '关一帆'
		}, {
			value: 'zhz',
			text: '智子'
		}, {
			value: 'gezh',
			text: '歌者'
		}],
        city2: city2,
        city3: city3
    }

    showCityPicker(){
        this.setState({showCityPicker: true })
    }

    showCity2Picker(){
        this.setState({showCity2Picker: true })
    }

    showCity3Picker(){
        this.setState({showCity3Picker: true })
    }

    ok(){
        this.setState({showCityPicker: false })
    }

    cl(){
        this.setState({showCityPicker: false })
    }


    ok2(){
        this.setState({showCity2Picker: false })
    }

    cl2(){
        this.setState({showCity2Picker: false })
    }

    ok3(){
        this.setState({showCity3Picker: false })
    }

    cl3(){
        this.setState({showCity3Picker: false })
    }

    ok4(){
        this.setState({showDatePicker: false })
    }

    cl4(){
        this.setState({showDatePicker: false })
    }

    ok5(){
        this.setState({showDatePicker2: false })
    }

    cl5(){
        this.setState({showDatePicker2: false })
    }

    getData(ret){
        console.log(ret);
    }

    getData2(ret){
        console.log("你选择的城市是:" + ret[0].text + " " + ret[1].text);
    }

    getData3(ret){
        console.log("你选择的城市是:" + (ret[0] || {}).text + " " + (ret[1] || {}).text + " " + (ret[2] || {}).text);
    }

    getData4(ret){
        console.log('选择结果: ' + ret);
    }

    getData5(ret){
        console.log('选择结果: ' + ret);
    }

    selectDate(){
        this.setState({showDatePicker: true })
    }

    selectDate2(){
        this.setState({showDatePicker2: true })
    }

    render(){
        return (
            <div>
                <h5 className="mui-content-padded">普通示例</h5>
                <button id='showUserPicker' className="mui-btn mui-btn-block" type='button' onClick={ this::this.showCityPicker  }>一级选择示例 ...</button>
                <CityPicker visible={ this.state.showCityPicker } setData={this.state.singleData} getData={ this::this.getData } confirm={ this::this.ok } cancel={ this::this.cl } />
                <h5 className="mui-content-padded">级联示例</h5>
				<button id='showCityPicker' className="mui-btn mui-btn-block" type='button' onClick={ this::this.showCity2Picker  }>二级联动示例 ...</button>
                <CityPicker visible={ this.state.showCity2Picker } layer='2' setData={this.state.city2} getData={ this::this.getData2 } confirm={ this::this.ok2 } cancel={ this::this.cl2 } />
                <div style={{ marginTop: '30px'}}></div>
                <button id='showCityPicker3' className="mui-btn mui-btn-block" type='button' onClick={ this::this.showCity3Picker  }>三级联动示例 ...</button>
                <CityPicker visible={ this.state.showCity3Picker } layer='3' setData={this.state.city3} getData={ this::this.getData3 } confirm={ this::this.ok3 } cancel={ this::this.cl3 } />
                <div className="mui-content-padded">
    				<h5 className="mui-content-padded">常规示例</h5>
    				<button id='demo1' className="btn mui-btn mui-btn-block" onClick={ this::this.selectDate }>选择日期时间 ...</button>
                    <DatePicker visible={ this.state.showDatePicker }  getData={ this::this.getData4 } confirm={ this::this.ok4 } cancel={ this::this.cl4 } />
    				<h5 className="mui-content-padded">设定年份区间</h5>
    				<button id='demo2' className="btn mui-btn mui-btn-block" onClick={ this::this.selectDate2 }>选择日期 ...</button>
                    <DatePicker visible={ this.state.showDatePicker2 } options={{"type":"date","beginYear":2014,"endYear":2016}}  getData={ this::this.getData5 } confirm={ this::this.ok5 } cancel={ this::this.cl5 } />
    			</div>
            </div>
        )
    }
}


render(
    <App />,
    document.querySelector('#root')
)

See more in the mui-picker

example


npm install

cd example

node server.js