Skip to content
This repository was archived by the owner on Dec 25, 2024. It is now read-only.

Commit 09a17fe

Browse files
committed
feat: add customizable month names
1 parent 6aa7489 commit 09a17fe

File tree

4 files changed

+31
-4
lines changed

4 files changed

+31
-4
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
#changelog
2+
## [2.6.0] - 2024-2-20
3+
### new features
4+
- add `gregorianMonthList` and `jalaliMonthList` prop to easily customize month names.
25
## [2.4.0] - 2023-11-12
36
### new features
47
- add Date to valid type for min & max date restriction input

README.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,11 @@ this component is a simple react component that use [jb-date-input](https://gith
1919

2020
- good typing experience for desktop user
2121

22-
- it use your page font by default.
22+
- it use your page font by default.
2323

24-
- have 3 value type so you can get inputed value in gregorian, jalali or timestamp base on your project need
24+
- customizable month names so you can change it for afghan or any other locals
25+
26+
- have 3 value type so you can get inputted value in gregorian, jalali or timestamp base on your project need
2527

2628
- customizable value format so you can get your value in standard iso format or custom format like `1400/12/08` or `1400_12_08`
2729

@@ -214,6 +216,16 @@ you can change calendar icon base on your own need to doing so you just have to
214216
</div>
215217
</JBDateInput>
216218
```
219+
## Change Month List
220+
221+
you may want to change the default month list for both of Jalali and Gregorian calendars base on your country month labels. here how you can do it:
222+
223+
```jsx
224+
document.querySelector('jb-date-input').setMonthList('GREGORIAN',['1','2','3','4','5','6','7','8','9','10','11','12']);
225+
<JBDateInput jalaliMonthList={['حَمَل','ثَور','جَوزا','سَرَطان','اَسَد','سُنبُله','میزان','عَقرَب','قَوس','جَدْی','دَلو','حوت']}></JBDateInput>
226+
<JBDateInput gregorianMonthList={['1','2','3','4','5','6','7','8','9','10','11','12']}></JBDateInput>
227+
```
228+
217229
### set custom style
218230

219231
in some cases in your project you need to change defualt style of react-component for example you need zero margin or different border-radius and etc.

lib/JBDateInput.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ export type JBDateInputProps = {
4949
calendarDefaultDateView?:{ year:number, month: number, dateType:JBDateInputInputTypes},
5050
usePersianNumber?: boolean,
5151
placeholder?:string | null | undefined,
52+
jalaliMonthList?:string[] | null | undefined,
53+
gregorianMonthList?:string[] | null | undefined,
5254
children?:React.ReactNode | React.ReactNode[],
5355
}
5456

@@ -124,6 +126,16 @@ export const JBDateInput = React.forwardRef((props: JBDateInputProps, ref) => {
124126
element.current.value = props.value;
125127
}
126128
}, [props.value]);
129+
useEffect(() => {
130+
if (element.current && Array.isArray(props.jalaliMonthList)) {
131+
element.current.setMonthList("JALALI",props.jalaliMonthList);
132+
}
133+
}, [props.jalaliMonthList]);
134+
useEffect(() => {
135+
if (element.current && Array.isArray(props.gregorianMonthList)) {
136+
element.current.setMonthList("GREGORIAN",props.gregorianMonthList);
137+
}
138+
}, [props.gregorianMonthList]);
127139
useEffect(() => {
128140
if (element.current && props.placeholder !== undefined) {
129141
element.current.placeholder = props.placeholder;

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"react component",
2020
"react"
2121
],
22-
"version": "2.5.0",
22+
"version": "2.6.0",
2323
"bugs": "https://github.com/javadbat/jb-date-input-react/issues",
2424
"license": "MIT",
2525
"files": [
@@ -37,6 +37,6 @@
3737
"url": "https://github.com/javadbat/jb-date-input-react"
3838
},
3939
"dependencies": {
40-
"jb-date-input": ">=3.12.0"
40+
"jb-date-input": ">=3.13.0"
4141
}
4242
}

0 commit comments

Comments
 (0)