2.2.16 • Published 3 days ago

@ijavad805/react-datepicker v2.2.16

Weekly downloads
-
License
MIT
Repository
github
Last release
3 days ago

react-datepicker Demo Live

alt text

NPM Version NPM Downloads npm bundle size

A cool datepicker and calendar for english and persian you can see some features here :

🌟 If you like this Datepicker, please bookmark it on your github with the star button.

Installation

Use the package manager npm to install @ijavad805/react-datepicker.

npm install @ijavad805/react-datepicker

Usage

import { Datepicker } from '@ijavad805/react-datepicker';
// simple
function AppSimple() {
  return <Datepicker />;
}

// full options
function App() {
  return (
    <Datepicker
      footer={(moment, setValue) => {
        return (
          <>
            <div
              onClick={() => {
                if (setValue) setValue(moment());
              }}
            >
              Today
            </div>
          </>
        );
      }}
      closeWhenSelectADay={true} // boolean
      dayEffects={[
        {
          day: '2022-09-12',
          color: 'red',
          dotColor: 'red',
          title: 'What ever you want',
        },
      ]}
      disabled={false} // disable input
      disabledDate={(day) => day === moment()} // today should be disabled
      format={'YYYY-MM-DD'}
      input={<input placeholder="Select a date" />} // whatever you want
      onOpen={() => {
        console.log('datepicker is open');
      }}
      lang={'en'} // en and fa
      loading={false} // show loading in datepicker if is open
      modeTheme={'dark'} // dark and light
      theme={'blue'} // blue , orange , red , green , yellow
      defaultValue={moment()}
      adjustPosition={'auto'} // auto, right-top, left-top, right-bottom, left-bottom, modal
      onChange={(val: any) => {
        console.log(val.format());
      }}
    />
  );
}

Calendar ( VERSION 1 ) Demo

Calendar Properties

The Calendar props interface provides configuration options for customizing the behavior and appearance of the react-datepicker component. Here's a summary of its properties:

PropertyTypeDescription
lang"en" \| "fa"Language for the calendar. Either "en" for English or "fa" for Farsi (Persian).
theme"blue"Theme for the calendar. Currently, only "blue" is supported.
eventsIEvent[]An array of IEvent objects representing the events to be displayed on the calendar.
onDay(date: string) => { className?: string; }A function to customize the appearance of a day. It takes a date string as input and should return an object with an optional className property to apply custom styles.
disabledDate(date: moment.Moment) => booleanA function that determines whether a date should be disabled. It takes a Moment.js date object as input and should return true to disable the date or false to enable it.
onClickEvent(item: IEvent) => voidA function to handle event click events. It receives an IEvent object as its argument.
onDoubleClickEvent(item: IEvent) => voidA function to handle event double-click events. It receives an IEvent object as its argument.
onDropEvent(item: IEvent) => voidA function to handle event drop events. It receives an IEvent object as its argument, to enable drag and drop functionality, this prop should not be undefined
onDateClick(date: string) => voidA function to handle date click events. It receives a date string as its argument.
onMonthChange(start: string, end: string) => voidA function to handle month change events. It receives two date strings, start and end, indicating the new visible date range on the calendar.
styleReact.CSSPropertiesAdditional CSS styles to apply to the calendar component.
allowClearbooleanallow user to clear the value

These properties allow you to configure and customize the behavior and appearance of the Calendar component in your application.

IEvent Interface

The IEvent interface represents an individual event that can be displayed on the calendar. It provides details about the event. Here's a summary of its properties:

PropertyTypeDescription
idnumberA unique identifier for the event.
titleReact.ReactNode \| stringThe title of the event, which can be either a Component or a string.
dateDateEventThe date of the event, which can be a date string or an object with start and end properties.
styleReact.CSSPropertiesAdditional CSS styles for the event.
classNamestringAdditional CSS class for the event.
dotColorstringColor for a dot associated with the event.
disabledbooleanA flag indicating if the event is disabled.
iconReact.ReactNodeA React node for an icon associated with the event.

These properties allow you to specify the details and appearance of events to be displayed on the calendar.

const App = () => {
  return (
    <Calendar
      lang="en"
      theme="blue"
      events={[
        {
          id: 1, // it should unique
          title: 'Test',
          date: '2023-09-16',
          className: 'test',
          dotColor: '#000',
          disabled: false,
          icon: '$', // also you can use component
          style: {
            // what ever you want
          },
        },
      ]}
      onDropEvent={(item: IEvent) => { // for enabling drag and drop option you should pass this function
        console.log(item);
      }}
      onClickEvent={(item: IEvent) => console.log(item)}
      onDoubleClickEvent={(item: IEvent) => console.log(item)}
      style={{
        height: 600,
      }}
      onDateClick={(date: moment.Moment) => console.log(date)}
    />
  );
};

Report issues

My friend, if you see any bugs, please tell me:

2.2.16

3 days ago

2.2.15

9 days ago

2.2.14

11 days ago

2.2.13

2 months ago

2.2.11

2 months ago

2.2.12

2 months ago

2.2.10

2 months ago

2.2.9

2 months ago

2.2.8

2 months ago

2.2.5

2 months ago

2.2.7

2 months ago

2.2.6

2 months ago

2.2.3

2 months ago

2.2.4

2 months ago

2.2.1

3 months ago

2.2.2

2 months ago

2.2.0

3 months ago

2.1.21

4 months ago

2.1.22

4 months ago

2.1.20

5 months ago

2.1.9

8 months ago

2.1.16

8 months ago

2.1.17

8 months ago

2.1.14

8 months ago

2.1.15

8 months ago

2.1.12

8 months ago

2.1.13

8 months ago

2.1.10

8 months ago

2.1.11

8 months ago

2.1.18

7 months ago

2.1.19

7 months ago

2.1.2

8 months ago

2.1.1

8 months ago

2.1.4

8 months ago

2.1.3

8 months ago

2.1.6

8 months ago

2.1.5

8 months ago

2.1.8

8 months ago

2.1.7

8 months ago

2.1.0

8 months ago

2.0.4

1 year ago

2.0.3

1 year ago

2.0.2

1 year ago

2.0.1

1 year ago

2.0.0

1 year ago

1.2.2

2 years ago

1.2.1

2 years ago

1.2.0

2 years ago

1.1.25

2 years ago

1.1.24

2 years ago

1.1.23

2 years ago

1.1.22

2 years ago

1.1.21

2 years ago

1.1.20

2 years ago

1.1.19

2 years ago

1.1.18

2 years ago

1.1.17

2 years ago

1.1.16

2 years ago

1.1.15

2 years ago

1.1.14

2 years ago

1.1.13

2 years ago

1.1.12

2 years ago

1.1.11

2 years ago

1.1.10

2 years ago

1.1.9

2 years ago

1.1.8

2 years ago

1.1.7

2 years ago

1.1.6

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago

0.0.9

2 years ago

0.0.8

2 years ago