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

date-picker-react

v1.0.2

Published

A react date picker control

Downloads

3

Readme

date-picker-react

A react date picker control

##Installation npm install date-picker-react

##Demo demo

##Usage

import DatePanel,{SinglePicker,RangePicker} from 'DatePicker';
var Me = React.createClass({
    getInitialState() {
        return { date:new Date()};
    },
    render(){
        return <SinglePicker
            type={'date'}
            value={this.state.date}
            onChange={date=>this.setState({date:date})}
        />
    }
});

dom.render(<Me />, document.getElementById('container'));

##Single Picker Props Name|Type|Description ---|---|--- type|string|'date','week','month','year' value|Date|selected date onChange|Function|callback,用户点击确定按钮时触发, 1 param:the date style|Object|css style to be used on the component verify|Function|用于指定可选日期。具体见下方'verify'小节

##Range Picker Props Name|Type|Description ---|---|--- type|string|'date','week','month','year' from|Date|when the time range starts to|Date|when the time range ends onChange|Function|callback,用户点击确定按钮时触发, 2 param2:from,to(type:date) style|Object|css style to be used on the component verify|Function|用于指定可选日期。具体见下方'verify'小节 onError|Function|callback to handle errors

##DatePanel Props Name|Type|Description ---|---|--- type|string|'date','week','month','year' value|Date|selected date onChange|Function|callback,用户点击任意日期时触发, 1 param:the date style|Object|css style to be used on the component position|string|'from','to','single'。用于指定面板类型,是开始日期还是结束日期还是独立日期 onCancel|Function|callback,当用户点击取消按钮时触发 onConfirm|Function|callback,当用户点击确定按钮时触发 verify|Function|用于指定可选日期。具体见下方'verify'小节

##The 'verify' Function

  • 它用来指定可选日期,如果未被指定,则所有的日期都可选
  • 它会在渲染时被多次调用,每一个可选日期格子被渲染时都会来询问是否可选
  • 下面的样例代码中的控件,将只允许2015-4-14 ~ 2016-6-14日之间的日期被选择。可以加入更复杂的逻辑以支持更复杂的可选时间段。比如额外判定某特定日期也可以被选择。
<SinglePicker
    type={'date'}
    verify={(date,type)=>
                new Date(2015,3,14).getTime()<= date.getTime()
                && date.getTime() <= new Date(2016,5,14).getTime()
            }
    ....
  • 它有两个参数,第一个Date类型,用于判断是否可选
  • 第二个参数string类型,type,即'date','week','month','year'
  • 第二个参数用于帮助判断当前日期是否可用,因为对于像'year'这样的类型,收到的日期将是那年的第一天,而你手里用来比较的日期可能是年内的某一段时间,这样日期就会落在范围外。但实际上该年应该可选。这需要额外的处理才能正确工作。而这些处理需要依赖控件类型。