1.3.6 • Published 5 years ago

react-advance-jalaali-datepicker-dialog-friendly v1.3.6

Weekly downloads
1
License
MIT
Repository
github
Last release
5 years ago

Advance React Date and Time Picker for jalaali (persian, shamsi) calender

It contains 3 types of jalaali (persian) date pickers, which are range (from, to) date and time pickerو range date picker, date picker and date and time picker.

This module is written using moment-jalali, which is relied on momentjs.

Instalation

Use npm i react-advance-jalaali-datepicker in order to install the module. Yes that's it. There is no extera font or css file to include. It's designed simple to prevent any issue during customization. Customize it in any way you want.

Usage

In order to use this module, import the packege into your react component and use the module as below. The belowing example is the code that is used in the sample usage video below.

demo of react advance jalaali (persian) datepicker

import React from "react";
import {
  DatePicker,
  DateTimePicker,
  DateRangePicker,
  DateTimeRangePicker
} from "react-advance-jalaali-datepicker";
export class Home extends React.component {
  change(unix, formatted) {
    console.log(unix); // returns timestamp of the selected value, for example.
    console.log(formatted); // returns the selected value in the format you've entered, forexample, "تاریخ: 1396/02/24 ساعت: 18:30".
  }
  DatePickerInput(props) {
    return <input className="popo" {...props} />;
  }
  render() {
    return (
      <div className="datePicker">
        <DatePicker
          inputComponent={this.DatePickerInput}
          placeholder="انتخاب تاریخ"
          format="jYYYY/jMM/jDD"
          onChange={this.change}
          id="datePicker"
          preSelected="1396/05/15"
        />
        <DateTimePicker
          placeholder="انتخاب تاریخ و ساعت"
          format="تاریخ: jYYYY/jMM/jDD ساعت: HH:mm"
          id="dateTimePicker"
          onChange={this.changeTimeDate}
          preSelected="تاریخ: 1396/02/24 ساعت: 18:30"
        />
        <DateRangePicker
          placeholderStart="تاریخ شروع"
          placeholderEnd="تاریخ پایان"
          format="jYYYY/jMM/jDD"
          onChangeStart={this.change}
          onChangeEnd={this.changeTimeDate}
          idStart="rangePickerStart"
          idEnd="rangePickerEnd"
        />
        <DateTimeRangePicker
          placeholderStart="تاریخ و ساعت شروع"
          placeholderEnd="تاریخ و ساعت پایان"
          format="تاریخ: jYYYY/jMM/jDD ساعت: HH:mm"
          onChangeStart={this.change}
          onChangeEnd={this.changeTimeDate}
          idStart="rangePickerStart"
          idEnd="rangePickerEnd"
        />
      </div>
    );
  }
}

component types:

nameDescription
DatePickershows a box allowing you pick just a date
DateTimePickershows a box allowing you pick just a date and time
DateRangePickershows a box twice, allowing you pick two dates. The first box allows you to pick the beginnig date and second one lets you pick end date
DateTimeRangePickershows a box twice, allowing you pick two dates and time. The first box allows you to pick the beginnig date and time and second one lets you pick end date and time

Options

Each type has its' own options.

"DatePicker" and "DateTimePicker":

NametypeDescription
placeholderstringPlaceholder of the datepicker input
formatstringFormat of showing date in the input and styled output. Accepts moment-jalali formats (required)
onChangefunctionOn change call of the input (required)
idstringAdds id attribute to the input elment
preSelectedstringPreviously selected date, it should be formatted exactly the same as the format option
customClassstringTo add "className" to the datepicker
inputTextAlignstringTexte align of the date input. default "right"
containerClassstringTo add "className" to the datepicker input container
monthTitleEnablebooleanTo add a title before month controller row
inputComponentJSX elementTo add customized input field to your datepicker
cancelOnBackgroundClickbooleanTo add background, which closes the datepicker on click event. It's customizable with class name "JDBackground"
controllValuebooleanBy stting to true, It will make preselected value control the input value

DateRangePicker:

NametypeDescription
placeholderStart, placeholderEndstringPlaceholder of the datepickers inputs
formatstringFormat of showing date in the input. Applies on both inputs. Accepts moment-jalali formats (required)
onChangeStart, onChangeEndfunctionOn change call of inputs
idStart, idEndstringAdd id attributes to the input elments
customClassStart, customClassEndstringTo add class name to start and end dattepickers
inputTextAlignstringTexte align of the date input. default "right"
containerClassstringTo add "className" to the datepicker input container
monthTitleEnablebooleanto add a title before month controller row
inputComponentJSX elementTo add customized input field to your datepicker
preSelectedStartstringPreviously selected date, it should be formatted exactly the same as the format option
cancelOnBackgroundClickbooleanTo add background, which closes the datepicker on click event. It's customizable with class name "JDBackground"
controllValuebooleanBy stting to true, It will make preselected value control the input value

Current date

You can use current-date class to style today. In the calendar you can find today has additional class of current-date.

Outside control sample

here you can find an example of code to control input from your parent component. This example shows how to reset values by a button.

Highlight specific date

Add format of the date. Add preSelected date with the mentioned format. The day will get "selected" calss. Today is containing "current-date" calss name.

More

More features will be provided.

I'll be glad to help if you faced any issue. Please, report issues here.

License

MIT

1.3.6

5 years ago

1.3.5

5 years ago

1.3.4

5 years ago

1.3.3

5 years ago

1.3.2

5 years ago

1.3.0

5 years ago

1.2.1

5 years ago

1.2.0

5 years ago

1.2.9

5 years ago

1.2.8

5 years ago

1.2.7

5 years ago

1.2.6

5 years ago

1.2.5

5 years ago

1.2.4

5 years ago

1.2.3

5 years ago