1.0.17 • Published 10 months ago

jalaali-react-date-picker v1.0.17

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

NPM

Jalaali React Datepicker

Welcome to our date picker for React applications! This package offers a customizable and localized solution for selecting dates in your projects. With support for the Jalaali calendar system, our date picker allows you to easily implement date selection in your React projects, whether you need to select a single date, or range of dates. Get started now by installing the package and integrating it into your React code.

Version NPM Downloads

Installation

To install jalaali-react-date-picker, you will need to have npm or yarn installed on your system. Once you have one of these package managers set up, you can install jalaali-react-date-picker by running the following command:

  npm install --save jalaali-react-date-picker

or

  yarn add jalaali-react-date-picker

This will install the latest version of jalaali-react-date-picker and add it as a dependency to your project.

Usage/Examples

First, import the necessary styles at top of your application:

import "jalaali-react-date-picker/lib/styles/index.css";

DatePicker

The DatePicker component is a standalone calendar picker that allows the user to select a single date.

import { DatePicker } from "jalaali-react-date-picker";

function App() {
  return <DatePicker />;
}

RangePicker

The RangePicker component is a calendar picker that allows the user to select a range of dates.

import { RangePicker } from "jalaali-react-date-picker";

function App() {
  return <RangePicker />;
}

InputDatePicker

The InputDatePicker component is a calendar picker that is displayed as an input field. The user can select a single date by clicking the input field and selecting a date from the calendar picker.

import { InputDatePicker } from "jalaali-react-date-picker";

function App() {
  return <InputDatePicker />;
}

InputRangePicker

The InputRangePicker component is a calendar picker that is displayed as two input fields. The user can select a range of dates by clicking on either of the input fields and selecting a date from the calendar picker.

import { InputRangePicker } from "jalaali-react-date-picker";

function App() {
  return <InputRangePicker />;
}

Live Demo Examples

To see demo examples, run the following command:

  npm run storybook or yarn storybook

Running Tests

To run tests, run the following command:

  npm run test or yarn test

Features

  • Full support for React and server-side frameworks like Next.js: The package is designed to work seamlessly with these technologies, allowing you to easily incorporate it into your project.

  • Custom date highlighting: With this feature, you can define specific dates and highlight them with any color you choose. This is useful for highlighting important dates, events, or deadlines.

  • Complete style customization: The package allows you to fully customize the styles, including colors and style overrides. This means you can match the calendar to the look and feel of your project.

  • Support for both Gregorian and Jalaali (Shamsi) date formats: The package provides support for both formats, giving you the flexibility to use the one that best fits your needs.

Props

The jalaali-react-date-picker package offers a wide range of customizable props for each of the components. Here is a list of the available props for each component:

DatePicker

PropertyTypeDescription
valueMoment \| nullThe currently selected date.
defaultValueMoment \| nullTo set default value, if value is undefined or null, the date picker will show default value.
onChange(date: Moment \| null, dateString: string) => voidCallback function which will be executed when date changes.
onDayChange(day:number) => voidCallback function which will be executed when day changes.
onMonthChange(month:MonthValue) => voidCallback function which will be executed when month changes.
onYearChange(year:number) => voidCallback function which will be executed when year changes.
formatstring \| (value:Moment) => stringThe format is which the selected date should be displayed. Uses moment.js format strings.
localeLocaleThe locale to be used for localization, while default locale is fa.
disabledDates(current:Moment) => booleanCallback function that can specify the date that cannot be selected
onModeChange(mode:Mode) => voidCallback function which will be executed when calendar mode changes.
panelRender(date:PanelDate,panelNode:React.ReactNode) => React.ReactNodeCallback render function used to render custom node for calendar panel component.
footerRender(current:Date \| null, footerNode:React.ReactNode) => React.ReactNodeCallback render function used to render custom node for footer component.
headerRender(current:Date \| null, headerNode:React.ReactNode) => React.ReactNodeCallback render function used to render custom node for header component.
dayLabelRender(labels:string[],labelNode:React.ReactNode) => React.ReactNodeCallback render function used to render custom for day labels component.
highlightDaysMoment[] \| (date:Moment) => booleanThe highlightDays can be used to determines which dates should be highlighted. it accepts array of moment or a callback function.
highlightWeekendbooleanIf highlightWeekend set to true, its turn weekend days to highlighted. Default is true.
customColorsColorSchemaThe customColors can be used to overrides the default colors.
nextIconReact.ReactNodecustom icon for next month
prevIconReact.ReactNodecustom icon for previous month
superNextIconReact.ReactNodecustom icon for next year
superPrevIconReact.ReactNodecustom icon for previous year
loadingbooleanIf true, renders loading component in calendar instead of caledar panel
loadingIndicatorReact.ReactNodeSet custom loading indicator
styleReact.CSSPropertiesstyles for root element of calendar panel
classNamestringclass for root element of calendar panel

RangePicker

PropertyTypeDescription
value[Moment,Moment] \| nullThe currently selected range date date.
defaultValue[Moment,Moment]To set default value, if value is undefined or null, the range picker will show default value.
onChange(date: [Moment,Moment], dateString: [string,string]) => voidCallback function which will be executed when range dates changes.
onDayChange(days:[number,number]) => voidCallback function which will be executed when days changes.
onMonthChange(month:[MonthValue,MonthValue]) => voidCallback function which will be executed when months changes.
onYearChange(year:[number, number]) => voidCallback function which will be executed when years changes.
formatstring \| (value:[Moment, Moment]) => stringThe format is which the selected range dates should be displayed. Uses moment.js format strings. Default is jYYYY-jMM-jDD
localeLocaleThe locale to be used for localization, while default is fa.
disabledDates(current:Moment) => booleanCallback function that can specify the dates that cannot be selected
onModeChange(mode:Mode) => voidCallback function which will be executed when calendar mode changes.
panelRender(date:[PanelRange, PanelRange],panelNode:React.ReactNode) => React.ReactNodeCallback render function used to render custom node for calendar panel component.
headerRender(current:[Moment, Moment \| null] \| null, headerNode:React.ReactNode) => React.ReactNodeCallback render function used to render custom node for header component.
dayLabelRender(labels:string[],labelNode:React.ReactNode) => React.ReactNodeCallback render function used to render custom for day labels component.
highlightDaysMoment[] \| (date:Moment) => booleanThe highlightDays can be used to determines which dates should be highlighted. it accepts array of moment or a callback function.
highlightWeekendbooleanIf highlightWeekend set to true, its turn weekend days to highlighted. Default is true.
customColorsColorSchemaThe customColors can be used to overrides the default colors.
nextIconReact.ReactNodecustom icon for next month
prevIconReact.ReactNodecustom icon for previous month
superNextIconReact.ReactNodecustom icon for next year
superPrevIconReact.ReactNodecustom icon for previous year
loadingbooleanIf true, renders loading component in calendar instead of caledar panel
loadingIndicatorReact.ReactNodeSet custom loading indicator
styleReact.CSSPropertiesstyles for root element of calendar panel
classNamestringclass for root element of calendar panel

InputDatePicker

PropertyTypeDescription
valueMoment \| nullThe currently selected date.
defaultValueMoment \| nullTo set default value, if value is undefined or null, the date picker will show default value.
openbooleanTo set open the popup calendar.
disabledbooleanTo set disable the popup calendar
errorbooleanIf true, the input will indicate an error
presetsbooleanThe preset range dates for quick selection. Default is true.
renderInput(field: FieldProps) => ReactNodeCustomize date picker input render.
prefixIconReact.ReactNodeInput custom prefix icon.
suffixIconReact.ReactNodeInput custom suffix icon
placementtop \| bottom \| right \| leftThe position where the popup calendar box pops up.
formatstring \| (value:Moment) => stringThe format is which the selected date should be displayed. Uses moment.js format strings. Default is jYYYY-jMM-jDD
localeLocaleThe locale to be used for localization, while default is fa.
getPopupContainerHTMLElement \| (() => HTMLElement) \| stringThe mounted node for popup calendar.
disabledDates(current:Moment) => booleanCallback function that can specify the date that cannot be selected
customColorsColorSchemaThe customColors can be used to overrides the default colors.
onChange(date: Moment \| null, dateString: string) => voidCallback function which will be executed when date changes.
onDayChange(day:number) => voidCallback function which will be executed when day changes.
onMonthChange(month:MonthValue) => voidCallback function which will be executed when month changes.
onYearChange(year:number) => voidCallback function which will be executed when year changes.
onOpenChange(open: boolean) => voidCallback function, can be executed whether the popup calendar is popped up or closed.
pickerPropspicker propsObject containing options for changing the picker itself.
onClear() => voidCallback function, can be executed when the clear icon is clicked.
wrapperClassNamestringclass for wrapper element of inputs.
wrapperStyleReact.CSSPropertiesstyles for wrapper element of inputs.

PickerProps

PropertyTypeDescription
panelRender(date:PanelDate,panelNode:React.ReactNode) => React.ReactNodeCallback render function used to render custom node for calendar panel component.
footerRender(current:Date \| null, footerNode:React.ReactNode) => React.ReactNodeCallback render function used to render custom node for footer component.
headerRender(current:Date \| null, headerNode:React.ReactNode) => React.ReactNodeCallback render function used to render custom node for header component.
dayLabelRender(labels:string[],labelNode:React.ReactNode) => React.ReactNodeCallback render function used to render custom for day labels component.
highlightDaysMoment[] \| (date:Moment) => booleanThe highlightDays can be used to determines which dates should be highlighted. it accepts array of moment or a callback function.
highlightWeekendbooleanIf highlightWeekend set to true, its turn weekend days to highlighted. Default is true.
loadingbooleanIf true, renders loading component in calendar instead of caledar panel
loadingIndicatorReact.ReactNodeSet custom loading indicator
onModeChange(mode:Mode) => voidCallback function which will be executed when calendar mode changes.
styleReact.CSSPropertiesstyles for root element of calendar panel
classNamestringclass for root element of calendar panel

InputRangePicker

PropertyTypeDescription
value[Moment,Moment]The currently selected range date date.
defaultValue[Moment,Moment]To set default value, if value is undefined or null, the range picker will show default value.
openbooleanTo set open the popup calendar.
disabledbooleanTo set disable the popup calendar
errorbooleanIf true, the input will indicate an error
presetsbooleanThe preset range dates for quick selection. Default is true.
placeholder[string,string]The placeholder of date inputs.
prefixIconReact.ReactNodeInput custom prefix icon.
suffixIconReact.ReactNodeInput custom suffix icon
placementtop \| bottom \| right \| leftThe position where the popup calendar box pops up.
getPopupContainerHTMLElement \| (() => HTMLElement) \| stringThe mounted node for popup calendar.
disabledDates(current:Moment) => booleanCallback function that can specify the date that cannot be selected
formatstring \| (value:[Moment, Moment]) => stringThe format is which the selected range dates should be displayed. Uses moment.js format strings. Default is jYYYY-jMM-jDD
localeLocaleThe locale to be used for localization, while default is fa.
responsivedesktop \| mobile \| autoTo set responsive, the range picker component is responsed and optimized to device it runs on. Default set to auto.
separatorReact.ReactNodeSet separator between inputs.
customColorsColorSchemaThe customColors can be used to overrides the default colors.
rangePropsrange propsObject containing options for changing the range picker itself.
onChange(date: [Moment,Moment], dateString: [string,string]) => voidCallback function which will be executed when range dates changes.
onDayChange(days:[number,number]) => voidCallback function which will be executed when days changes.
onMonthChange(month:[MonthValue,MonthValue]) => voidCallback function which will be executed when months changes.
onYearChange(year:[number, number]) => voidCallback function which will be executed when years changes.
onOpenChange(open: boolean) => voidCallback function, can be executed whether the popup calendar is popped up or closed.
onClear() => voidCallback function, can be executed when the clear icon is clicked.
wrapperStyleReact.CSSPropertiesstyles for wrapper element of inputs.
wrapperClassNamestringclass for wrapper element of inputs.

RangeProps

PropertyTypeDescription
panelRender(date:PanelDate,panelNode:React.ReactNode) => React.ReactNodeCallback render function used to render custom node for calendar panel component.
headerRender(current:Date \| null, headerNode:React.ReactNode) => React.ReactNodeCallback render function used to render custom node for header component.
dayLabelRender(labels:string[],labelNode:React.ReactNode) => React.ReactNodeCallback render function used to render custom for day labels component.
highlightDaysMoment[] \| (date:Moment) => booleanThe highlightDays can be used to determines which dates should be highlighted. it accepts array of moment or a callback function.
highlightWeekendbooleanIf highlightWeekend set to true, its turn weekend days to highlighted. Default is true.
loadingbooleanIf true, renders loading component in calendar instead of caledar panel
loadingIndicatorReact.ReactNodeSet custom loading indicator
onModeChange(mode:Mode) => voidCallback function which will be executed when calendar mode changes.
styleReact.CSSPropertiesstyles for root element of calendar panel
classNamestringclass for root element of calendar panel

Authors

This authors section lists the names and github profiles of the individuals who have contributed to the project. It is a good way to acknowledge the work and efforts of the people involved in the project, and can also make it easier for users to contact the authors if they have questions or want to contribute to the project.

Dependencies

moment.js - A powerful and flexible JavaScript library for manipulating dates and times. We use Moment.js to handle date formatting and manipulation in our project.

License

MIT

1.0.17

10 months ago

1.0.16

10 months ago

1.0.15

11 months ago

1.0.14

11 months ago

1.0.13

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago

1.0.9

1 year ago

1.0.8

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

0.1.41

1 year ago

0.1.42

1 year ago

0.1.43

1 year ago

0.1.44

1 year ago

0.1.45

1 year ago

0.1.46

1 year ago

0.1.47

1 year ago

0.1.40

1 year ago

0.1.38

1 year ago

0.1.39

1 year ago

0.1.30

1 year ago

0.1.31

1 year ago

0.1.32

1 year ago

0.1.33

1 year ago

0.1.34

1 year ago

0.1.35

1 year ago

0.1.36

1 year ago

0.1.37

1 year ago

0.1.27

1 year ago

0.1.28

1 year ago

0.1.29

1 year ago

1.0.11

1 year ago

1.0.10

1 year ago

1.0.12

1 year ago

0.1.26

1 year ago

0.1.25

1 year ago

0.1.24

1 year ago

0.1.23

1 year ago

0.1.22

1 year ago

0.1.21

1 year ago

0.1.20

1 year ago

0.1.19

1 year ago

0.1.18

1 year ago

0.1.17

1 year ago

0.1.16

1 year ago

0.1.15

1 year ago

0.1.14

1 year ago

0.1.13

1 year ago

0.1.12

1 year ago

0.1.11

1 year ago

0.1.10

1 year ago

0.1.9

1 year ago

0.1.8

1 year ago

0.1.7

1 year ago

0.1.6

1 year ago

0.1.5

1 year ago

0.1.4

1 year ago

0.1.3

1 year ago

0.1.2

1 year ago

0.1.1

1 year ago

0.1.0

1 year ago

0.0.99

1 year ago

0.0.98

1 year ago

0.0.97

1 year ago

0.0.96

1 year ago

0.0.93

1 year ago

0.0.91

1 year ago

0.0.9

1 year ago

0.0.8

1 year ago

0.0.7

1 year ago

0.0.6

1 year ago

0.0.5

1 year ago

0.0.4

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago