# my-react-datapicker

> Simple datapicker library

Latest version **1.1.4** (published 2023-03-17) · MIT license · 0 weekly downloads

## Install

```sh
npm install my-react-datapicker
pnpm add my-react-datapicker
yarn add my-react-datapicker
bun add my-react-datapicker
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.4 |
| Published | 2023-03-17 |
| First published | 2023-02-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 19 |
| Unpacked size | 75.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Michel YAM |
| Maintainers | nazeto |
| Keywords | react, typescript, datapicker, react-component |

## Links

- npm: https://www.npmjs.com/package/my-react-datapicker
- Repository: https://github.com/MichelYam/my-react-datapicker
- Homepage: https://github.com/MichelYam/my-react-datapicker#readme
- Issues: https://github.com/MichelYam/my-react-datapicker/issues
- npm.io page: https://npm.io/package/my-react-datapicker

## Dependencies (19)

- [react](https://npm.io/package/react.md) ^18.2.0
- [typedoc](https://npm.io/package/typedoc.md) ^0.23.25
- [copyfiles](https://npm.io/package/copyfiles.md) ^2.4.1
- [react-dom](https://npm.io/package/react-dom.md) ^18.2.0
- [prop-types](https://npm.io/package/prop-types.md) ^15.8.1
- [typescript](https://npm.io/package/typescript.md) ^4.9.5
- [web-vitals](https://npm.io/package/web-vitals.md) ^2.1.4
- [@types/jest](https://npm.io/package/@types/jest.md) ^27.5.2
- [@types/node](https://npm.io/package/@types/node.md) ^16.18.12
- [@types/react](https://npm.io/package/@types/react.md) ^18.0.27
- [@mui/material](https://npm.io/package/@mui/material.md) ^5.11.7
- [react-scripts](https://npm.io/package/react-scripts.md) 5.0.1
- [@emotion/react](https://npm.io/package/@emotion/react.md) ^11.10.5
- [@emotion/styled](https://npm.io/package/@emotion/styled.md) ^11.10.5
- [@types/react-dom](https://npm.io/package/@types/react-dom.md) ^18.0.10
- [@mui/icons-material](https://npm.io/package/@mui/icons-material.md) ^5.11.0
- [@testing-library/react](https://npm.io/package/@testing-library/react.md) ^13.4.0
- [@testing-library/jest-dom](https://npm.io/package/@testing-library/jest-dom.md) ^5.16.5
- [@testing-library/user-event](https://npm.io/package/@testing-library/user-event.md) ^13.5.0

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 1.1.4 (latest) — 2023-03-17
- 1.1.1 — 2023-03-17
- 1.1.0 — 2023-03-17
- 1.0.11 — 2023-03-04
- 1.0.10 — 2023-03-02
- 1.0.9 — 2023-02-21
- 1.0.8 — 2023-02-20
- 1.0.7 — 2023-02-17
- 1.0.6 — 2023-02-17
- 1.0.5 — 2023-02-17
- 1.0.4 — 2023-02-14
- 1.0.3 — 2023-02-10
- 1.0.2 — 2023-02-10

## README

# simple dataPicker library of React components created using `create-react-app`

## Installation

The package can be installed via [npm](https://github.com/npm/cli):

```text
npm install my-react-datepicker --save
```

...or using yarn:

```text
yarn add my-react-datepicker --save
```

## Node usage

- ``selectedDate`` (string): variable controlling the display of the date selected
- ``onChange`` (function): action triggered when changing date

### optional

- ``customHeader`` (object): custom header of datapicker
- ``format`` (string): customize date format
- ``inputId`` (string): customize id
- ``monthsList`` (array): array of months
- ``yearsList`` (array): array of years

Here is a simple example, with report data injected directly as an object:

```tsx
import React, { useState } from 'react';
import DatePicker from "my-react-datepicker";
const App = () => {
  const [value, setValue] = useState("")
  return (
      <Datapicker
        selectedDate={startDate} 
        onChange={setStartDate} //when day is clicked
      />
    )
}
```

## Configuration

## Examples

easy to use

``` tsx
 const [value, setValue] = useState("")
  const months = [
    "January",
    "February",
    "March",
    "April",
    "May",
    "June",
    "July",
    "August",
    "September",
    "October",
    "November",
    "December",
  ]
    const years = range(1990, getYear(new Date()) + 1, 1);
  <Datapicker
    dataFormat='DD/MM/YYYY'
    selectedDate={startDate}
    onChange={(value: any) => setValue(value)}
    monthsList={months}
    yearsList={years}
    />
```

You can customize dataPicker header with you own styles like:

```tsx
 const [value, setValue] = useState("")
  const months = [
    "January",
    "February",
    "March",
    "April",
    "May",
    "June",
    "July",
    "August",
    "September",
    "October",
    "November",
    "December",
  ]
    const years = range(1990, getYear(new Date()) + 1, 1);
  return (
       <Datapicker selectedDate={startDate} onChange={setStartDate}
        customHeader={({
          currentMonth,
          currentYear,
          changeMonth,
          changeYear,
          prev,
          next,
        }) => (
          <div>
            <button onClick={prev}>
              {"<"}
            </button>
            <select
              value={months[currentMonth as unknown as number]}
              onChange={({ target: { value } }) =>
                changeMonth(months.indexOf(value))
              }
            >
              {months.map((option) => (
                <option key={option} value={option}>
                  {option}
                </option>
              ))}
            </select>
            <select
              value={currentYear}
              onChange={({ target: { value } }: any) => changeYear(value)}
            >
              {years.map((option) => (
                <option key={option} value={option}>
                  {option}
                </option>
              ))}
            </select>
            <button onClick={next} >
              {">"}
            </button>
          </div>
        )}
      />
    )
```

---
_Source: https://npm.io/package/my-react-datapicker · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
