Skip to content

Commit

Permalink
Code Cleanup, upgrade React and Antd
Browse files Browse the repository at this point in the history
  • Loading branch information
saeedrahimi committed Mar 4, 2022
1 parent c4a5ebb commit e015af5
Show file tree
Hide file tree
Showing 28 changed files with 5,911 additions and 11,376 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ npm-debug.log*
yarn-debug.log*
yarn-error.log*

/dist
/es
/lib
/src/dist
/build
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ npm i antd-jalali
import React from "react";
import ReactDOM from "react-dom";
import { DatePicker, ConfigProvider } from "antd";
import { DatePicker as DatePickerJalali, Calendar } from "antd-jalali";
import { DatePicker as DatePickerJalali, Calendar, JalaliLocaleListener } from "antd-jalali";
import fa_IR from "antd/lib/locale/fa_IR";
import en_US from "antd/lib/locale/en_US";
import "antd/dist/antd.css";
Expand All @@ -34,6 +34,7 @@ ReactDOM.render(
<br />
<br />
<ConfigProvider locale={fa_IR} direction="rtl">
<JalaliLocaleListener/>
Jalali: <DatePickerJalali />
Jalali RangePicker: <DatePickerJalali.RangePicker />
<br />
Expand All @@ -49,9 +50,16 @@ You should pass dayjs object with [jalali calendar](https://github.com/alibaba-a

```jsx
import dayjs from 'dayjs'
import { DatePicker as DatePickerJalali, Calendar as CalendarJalali, useJalaliLocaleListener } from "antd-jalali";

// If you want to all new instanses of dayjs use jalali calendar, you can set default calendar
// 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}/>
Expand Down
1 change: 1 addition & 0 deletions antd-jalali.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export { default as DatePicker } from "./date-picker";
export { default as Calendar } from "./calendar";
export { default as TimePicker } from './time-picker';
export { ConfigListener } from './jalali';
//# sourceMappingURL=index.d.ts.map
41 changes: 41 additions & 0 deletions esbuild.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
const esbuild = require('esbuild');
const { existsSync, mkdirSync, writeFileSync} = require('fs');
const {join} = require('path');

const lib = join(process.cwd(), 'lib');

if (!existsSync(lib)) {
mkdirSync(lib);
}


esbuild
.build({
entryPoints: ['src/index.ts'],
outdir: 'lib/esm',
bundle: true,
sourcemap: true,
minify: true,
splitting: true,
format: 'esm',
target: ['esnext'],
external: ['antd','react','dayjs','jalaliday','rc-picker'],
})
.catch(() => process.exit(1));

esbuild
.build({
entryPoints: ['src/index.ts'],
outfile: 'lib/cjs/index.cjs.js',
bundle: true,
sourcemap: true,
minify: true,
platform: 'node',
target: ['node16'],
external: ['antd','react','dayjs','jalaliday','rc-picker'],
})
.catch(() => process.exit(1));

writeFileSync(join(lib, 'index.js'), "export * from './esm/index.js';");

writeFileSync(join(lib, 'index.cjs.js'), "module.exports = require('./cjs/index.cjs.js');");
7 changes: 0 additions & 7 deletions lib/date-picker/DatePicker.tsx

This file was deleted.

3 changes: 0 additions & 3 deletions lib/index.ts

This file was deleted.

1 change: 0 additions & 1 deletion lib/jalali/index.ts

This file was deleted.

Loading

0 comments on commit e015af5

Please sign in to comment.