2.0.11 • Published 3 days ago

react-anpicker v2.0.11

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

react-anpicker

react-anpicker is a free and light component in react for date picker mostly based on Intl and predefined function for converting dates

  • type script
  • rtl/ltr
  • other calendars

demo image

Installation

react-anpicker requires react "^18.2.0", react-dome "^18.2.0" to run.

run this command:

npm i react-anpicker

add css to your project

import "react-anpicker/dist/styles.css";

Usage

import { AnPicker } from 'react-anpicker';
...
    const [date, setDate] = useState(null);
    const handleChange = (date: Date | null, localDate: string | null) => { }
    <AnPicker value={date} onChange={handleChange} />
...

Props

  • showTodayBottom: boolean- today button be visible or not
  • value::string includes year/month/day
  • onChange: (string, gregorianDate?: number, number, number) => void- a function that fires after change with valid date and gives you value
  • showTodayBottom: boolean- today button be visible or not
  • inputControl: ReactElemt- for passing an custom input from other libraries
  • showSidebar: boolean: show sidebar beside picker section
  • popupTargetId: by defaylt date picker appears as a last child of body, in case like using it in a modal, you can specify wrapper for it.
  • locale: :
    {
       title:string-calander title in sidebar
       name: string-locale from Intl like "en-US" or "fa-IR" ,...
       startOfWeek: number-if your week not starts with monday, you can specifing it(sunday=-1,tusday=1);
       rtl: boolean;
       todayButtonText: string,
       daysOfEachMonth: (year: number, month: number) => number-a functio that return number of days in each month
       numberConverter: (number: string) => number- get number in other languages in convert them to eng number;
       convertToDate: (localYear: number, localMonth: number, localDay: number) => [number, number, number]- a function that takes local date and retrun eq in gregorian date;
    }
an object that needs to be set if you use another locale, default is been configed for "fa-Ir"

##### gregorian config example

![gregorian image](https://github.com/kingofday/react-anpicker/blob/master/src/assets/gregorian.png)

for this calander use locale like below:

{ rtl: false, convertToDate: (y, m, d) => y, m, d, daysOfEachMonth: (y, m) => { switch (m) { case 1: case 3: case 5: case 6: case 7: case 8: case 10: case 12: return 31; case 2: let isKabise = false; if (y % 400 === 0) isKabise = true; else if (y % 100 === 0) isKabise = false; else if (y % 4 === 0) isKabise = true; return isKabise ? 29 : 28; default: return 30; }

}, name: "en-US", numberConverter: (n) => parseInt(n), startOfWeek:0, title:"Gregorian", todayButtonText:"today" }

2.0.11

3 days ago

2.0.10

4 days ago

2.0.9

17 days ago

2.0.8

1 month ago

2.0.7

2 months ago

2.0.3

3 months ago

2.0.5

3 months ago

2.0.6

3 months ago

2.0.2

3 months ago

2.0.1

3 months ago

2.0.0

3 months ago

1.4.5

5 months ago

1.4.4

5 months ago

1.4.3

5 months ago

1.4.2

5 months ago

1.4.1

5 months ago

1.4.0

5 months ago

1.3.5

9 months ago

1.3.4

1 year ago

1.3.3

1 year ago

1.3.2

1 year ago

1.3.1

1 year ago

1.3.0

1 year ago

1.2.9

1 year ago

1.2.8

1 year ago

1.2.7

1 year ago

1.2.6

1 year ago

1.2.5

1 year ago

1.2.4

1 year ago

1.2.3

1 year ago

1.2.2

2 years ago

1.2.1

2 years ago

1.2.0

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago

0.1.0

2 years ago