Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

jalaali-react-date-picker

Package Overview
Dependencies
Maintainers
2
Versions
82
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jalaali-react-date-picker

This package is a date picker component for React that supports the Jalaali (Iranian/Shamsi/Persian) calendar system. It provides an easy-to-use interface for selecting a date in the Jalaali calendar and is fully customizable with options for setting the

  • 1.0.3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
284
decreased by-18.62%
Maintainers
2
Weekly downloads
 
Created
Source

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 />;
}

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) => voidThe 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]) => voidThe 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) => voidThe 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.
formatstring | (value:[Moment, Moment]) => voidThe 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

Keywords

FAQs

Package last updated on 11 Jan 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc