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-jg-date-picker

v1.0.21

Published

React Jalali and gregorian date and range picker

Downloads

7

Readme

React JG Date Picker

Single and Range Date Selector component built to be functional in jalali and gregorian at the same time.

Usage

$ npm install react-jg-date-picker
# OR
$ yarn add react-jg-date-picker
// Date and range import
import {JGDatePicker , JGRangePicker} from 'react-jg-date-picker';

Dont forger to import the css file

// Date and range import
import 'react-jg-date-picker/css/App.css';

Jalali and Gregorian calender

Default calendar is jalali based on moment-jalaali, in both date and range componante there is a button to switch between jalali and gregorian calender based on moment. Also this package used the greate work of react-jdate-picker as its calender core.

For example for Jalali calendar you need to do something like this:

Example

import {JGDatePicker , JGRangePicker} from 'react-jg-date-picker';
import 'react-jg-date-picker/css/App.css';
import moment from 'moment';


class Main extends Component {

    constructor(props) {
        super(props);

        this.state = {
            locale: 'fa',
            selectedDate: moment(),
            fromDate: moment(),
            toDate: moment(),
        };
    }

    selectDate = (date) => {
        this.setState({ selectedDate: date });
    };

    selectRange = (fromDate, toDate) => {
        this.setState({ fromDate, toDate });
    };

    removeDate = () => {
        this.setState({ selectedDate: null });
    };

    removeDates = () => {
        this.setState({ fromDate: null , toDate: null});
    };

    changeTheLocale(){
        let { locale } = this.state;
        if (locale === 'fa') {
            this.setState({locale: 'en'})
        } else {
            this.setState({locale: 'fa'})
        }
    };

    render() {
        let { locale , selectedDate , fromDate , toDate} = this.state;
        return (
            <div className="App">

                <div>

                    <JGDatePicker
                        locale={locale}
                        usePersianDigits={false}
                        doubleMonth={false}
                        isSelected={selectedDate}
                        changeLocale={this.changeTheLocale.bind(this)}
                        selectDate={this.selectDate.bind(this)}
                        removeDate={this.removeDate.bind(this)}
                    />

                    <hr/>

                    <JGRangePicker
                        locale={locale}
                        usePersianDigits={false}
                        doubleMonth={true}
                        fromDate={fromDate}
                        toDate={toDate}
                        changeLocale={this.changeTheLocale.bind(this)}
                        selectRange={this.selectRange.bind(this)}
                        removeDate={this.removeDates.bind(this)}
                    />

                </div>
            </div>
        );
    }
}

export default Main;

You can also pass null values to default states.