# @realmodule/antd-jalali

> A wrapper for ant-design datepicker and calendar to support Jalali calendar type with dayjs. - تاریخ شمسی (جالی)

Latest version **0.1.5** (published 2024-03-08) · MIT license · 0 weekly downloads

## Install

```sh
npm install @realmodule/antd-jalali
pnpm add @realmodule/antd-jalali
yarn add @realmodule/antd-jalali
bun add @realmodule/antd-jalali
```

## Health

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

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

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.5 |
| Published | 2024-03-08 |
| First published | 2024-01-28 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 15 |
| Unpacked size | 126.1 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Mahmoud Nouraei |
| Maintainers | mnouraei |
| Keywords | ant, datepicker, calendar, jalali, persian, shamsi, dayjs, khorshidi |

## Links

- npm: https://www.npmjs.com/package/@realmodule/antd-jalali
- Repository: https://github.com/mnouraei/real-antd-jalali
- Issues: https://github.com/mnouraei/real-antd-jalali/issues
- npm.io page: https://npm.io/package/@realmodule/antd-jalali

## Dependencies (15)

- [antd](https://npm.io/package/antd.md) ^5.15.1
- [dayjs](https://npm.io/package/dayjs.md) ^1.11.10
- [react](https://npm.io/package/react.md) ^18.2.0
- [esbuild](https://npm.io/package/esbuild.md) ^0.20.1
- [react-dom](https://npm.io/package/react-dom.md) ^18.2.0
- [typescript](https://npm.io/package/typescript.md) ^4.9.5
- [web-vitals](https://npm.io/package/web-vitals.md) ^3.5.2
- [@types/jest](https://npm.io/package/@types/jest.md) ^29.5.12
- [@types/node](https://npm.io/package/@types/node.md) ^20.11.25
- [@types/react](https://npm.io/package/@types/react.md) ^18.2.64
- [react-scripts](https://npm.io/package/react-scripts.md) ^3.0.1
- [@types/react-dom](https://npm.io/package/@types/react-dom.md) ^18.2.21
- [@testing-library/react](https://npm.io/package/@testing-library/react.md) ^14.2.1
- [@testing-library/jest-dom](https://npm.io/package/@testing-library/jest-dom.md) ^6.4.2
- [@testing-library/user-event](https://npm.io/package/@testing-library/user-event.md) ^14.5.2

## Alternatives

- [@js-joda/timezone](https://npm.io/package/@js-joda/timezone.md) — 383.4K weekly downloads
- [chartjs-adapter-moment](https://npm.io/package/chartjs-adapter-moment.md) — 210.8K weekly downloads
- [strftime](https://npm.io/package/strftime.md) — 171.2K weekly downloads
- [vue-flatpickr-component](https://npm.io/package/vue-flatpickr-component.md) — 115.8K weekly downloads
- [timepicker](https://npm.io/package/timepicker.md) — 51.0K weekly downloads

## Recent versions

- 0.1.5 (latest) — 2024-03-08
- 0.1.4 — 2024-03-08
- 0.1.3 — 2024-01-31
- 0.1.2 — 2024-01-31
- 0.1.1 — 2024-01-31
- 0.1.0 — 2024-01-28

## README

[![npm (scoped with tag)](https://img.shields.io/npm/v/%40realmodule%2Fantd-jalali/latest.svg?style=flat-square)](https://www.npmjs.com/package/@realmodule/antd-jalali)
[![npm](https://img.shields.io/npm/dt/%40realmodule%2Fantd-jalali)](https://www.npmjs.com/package/@realmodule/antd-jalali)

# Ant-Design Jalali DatePicker
A wrapper for ant-design date picker and calendar to support Jalali calendar type with [Day.js](https://github.com/iamkun/dayjs) 


تقویم شمسی انت دیزاین

This package is developed for the following versions

"antd": "^5.15.1"

"react": "^18.2.0"

[Original version](https://github.com/saeedrahimi/antd-jalali)

## Demo
[https://mnouraei.github.io/real-antd-jalali/](https://mnouraei.github.io/real-antd-jalali/)



## Installation
```
npm i @realmodule/antd-jalali
```

## Usage

```ts
import React from "react";
import ReactDOM from "react-dom";
import {DatePicker,JalaliLocaleListener,jalaliPlugin} from "@realmodule/antd-jalali";
import {  ConfigProvider } from "antd";
import dayjs from "dayjs";
import fa_IR from "antd/lib/locale/fa_IR";
import en_US from "antd/lib/locale/en_US";

dayjs.extend(jalaliPlugin);
dayjs.calendar('jalali');
ReactDOM.render(
    <div className="App">
        Gregorian: <DatePicker />
        <br />
        <br />
        <ConfigProvider locale={fa_IR}  direction="rtl">
          <JalaliLocaleListener/>
           Jalali: <DatePickerJalali />
           Jalali RangePicker: <DatePickerJalali.RangePicker />
           <br />
           <br />
           <Calendar />
        </ConfigProvider>
    </div>,
  document.getElementById("root")
);
```
### How to set value  

```jsx
import dayjs from 'dayjs'
import { DatePicker as DatePickerJalali, Calendar as CalendarJalali, useJalaliLocaleListener } from "@realmodule/antd-jalali";

// You should call this hook in child component of <ConfigProvider>
// You can also use component helper for this hook <JalaliLocaleListener> 
useJalaliLocaleListener();

// If you want to all new instanses of dayjs use jalali calendar (no matter what is the locale), 
// you can set default calendar for dayjs and remove useJalaliLocaleListener hook.
dayjs.calendar('jalali');

const date = dayjs("1399-01-01", {jalali:true});

<DatePickerJalali defaultValue={date}/>
<CalendarJalali  value={date}/>
```
also you can create a jalali date without changing default calendar

```js
const date = dayjs()
const jalaliDate = date.calendar('jalali')
```

---
_Source: https://npm.io/package/@realmodule/antd-jalali · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
