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-jalaali-datepicker

v1.1.2

Published

minimal jalaali (persian) datepicker for react

Downloads

17

Readme

minimal Jalaali (Persian) Datepicker for React.

Currently only support single datepicker (not rangepicker or timepicker). those will be added soon! Project is improved version of react-advance-jalaali-datepicker, with new methods, props, events and some custom css. Both use moment-jalaali for jalaali calendar system.

Table of Contents

Installation

first make sure you have Nodejs and npm installed

node -v

and

npm -v

then enter following:

  npm i react-jalaali-datepicker

Usage

this is a simple example of using this module.

//example.js
import React from 'react';
import {Datepicker} from 'react-jalaali-datepicker';
 
export default class Example extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      open : false,
      date : "13970510"
    }
  }
  onChange(selectedDate) {
    console.log(selectedDate);
  }
  render() {
    return (
      <Datepicker
      date={this.state.date}
      onChange={this.onChange}
      className="datepicker-wrapper"
      inputClassName="datepicker-input"
      placeholder="Enter new date"
      dir="auto"
      open={this.state.open}
      />
    );
  }
}

in your index.js:

//index.js
import React from 'react';
import ReactDOM from 'react-dom';
import Example from './example';
import registerServiceWorker from './registerServiceWorker';

ReactDOM.render(<Example />, document.getElementById('root'));
registerServiceWorker();

try by cloning this repo:

  git clone https://github.com/faraadi/react-jalaali-datepicker
  cd react-jalaali-datepicker/example
  npm install
  npm start

Events

currently three events is supported: open, close and change you can provide events handler for these events in two way : 1.using Props

import React from 'react';
import {Datepicker} from 'react-jalaali-datepicker';
export class PropExample extends React.Component {
    openHandler() {
      console.log("it's opened");
      //your code...
    }
    closeHandler() {
      console.log("now is closed");
      //your code...
    }
    changeHandler(date) {
      console.log(`new Date is entered: ${date}`);
      //your code...
    }
    render() {
      return (
        <Datepicker
          onOpen={this.openHandler}
          onClose={this.closeHandler}
          onChange={this.changeHandler}
        />
      );
    }
}

2.assigning ref and using on method

import React from 'react';
import {Datepicker} from 'react-jalaali-datepicker';
export class MethodExample extends React.Component {
    constructor(props) {
        super(props);
        this.datepicker = React.createRef();
    }
    componentDidMount() {
      this.datepicker.current.on("open", function() {
        console.log("opened!");
        // some codes
      });
      this.datepicker.current.on("change", function(date) {
        console.log(date);
        // some codes
      });
      this.datepicker.current.on("close", function() {
        console.log("closed!");
        // some codes
      });
    }
    render() {
      return (
        <Datepicker
          ref={this.datepicker}
        />
      );
    }
}

API

you could use following props and method to interact with datepicker.

i recommend using props way instead of methods.

prop | type | default | description :--- | :---: | :---: | :--- open | boolean | false | a boolean to indicate whether datepicker is open or close date | moment-jalaali | current date | date in 'yyyymmdd' format, example : "13970510" inputValue | any | none | initial input value onChange | function(arg) | none | event handler that called whenever a date is selected. accept the selected date as argument onOpen | function() | none | event Handler that called when user opens datepicker onClose | function() | none | event handler that called when user close datepicker readOnly | boolean | false | html input readonly prop format | string | jYYYY-jMM-jDD | date format to display. defualt format is recommended className | string | none | css class for wrapper inputClassName | string | none |css class for input inputId | string | none | css id for input placeholder | string | none | input placeholder dir | string | none | input text direction, ltr, rtl or auto

call these method using ref.

method | arg | description :--- | :---: | :--- getValue | none | return current value of datepicker in the format of : YYYY/MM/DD setValue | date : string | set the value of datepicker. date argument must be provided without slashes, like date prop. example : "13950510" on | event : string, callBack : function | defines event handler for specified events. can attach multiple callBack for each event. open | none | opens the datepicker close | none | closes the datepicker

More

more feature, such as range picker and time picker will be provided soon.