Skip to content

Commit 12c6435

Browse files
committed
feat: add setMonthList method to customize month names
1 parent 9c9a55d commit 12c6435

File tree

4 files changed

+18
-5
lines changed

4 files changed

+18
-5
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+
## [3.13.0] - 2024-2-19
3+
### new features
4+
- add `setMonthList` method to easily customize month names.
25
## [3.12.0] - 2024-2-7
36
### new features
47
- change `inputType` and `valuetype` from enum to pure string so it easily be used in other ts files without extra dep

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,13 @@ you can change calendar icon base on your own need to doing so you just have to
258258
</div>
259259
</jb-date-input>
260260
```
261+
## Change Month List
262+
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:
263+
```js
264+
document.querySelector('jb-date-input').setMonthList('JALALI',['حَمَل','ثَور','جَوزا','سَرَطان','اَسَد','سُنبُله','میزان','عَقرَب','قَوس','جَدْی','دَلو','حوت']);
265+
document.querySelector('jb-date-input').setMonthList('GREGORIAN',['1','2','3','4','5','6','7','8','9','10','11','12']);
266+
```
267+
261268
## set custom style
262269

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

lib/JBDateInput.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,10 @@ export class JBDateInputWebComponent extends HTMLElement {
5656
this.#setDateValue(value);
5757
this.#updateInputTextFromValue();
5858
}
59-
#updateFormAssossicatedValue():void{
59+
setMonthList(inputType:InputType, monthName:string[]){
60+
this.elements.calendar.setMonthList(inputType,monthName);
61+
}
62+
#updateFormAssociatedValue():void{
6063
//in html form we need to get date input value in native way this function update and set value of the input so form can get it when needed
6164
if (this.internals_ && typeof this.internals_.setFormValue == "function") {
6265
this.internals_.setFormValue(this.value);
@@ -665,7 +668,7 @@ export class JBDateInputWebComponent extends HTMLElement {
665668
}else if(value instanceof Date){
666669
this.#setDateValueFromDate(value);
667670
}
668-
this.#updateFormAssossicatedValue();
671+
this.#updateFormAssociatedValue();
669672
}
670673
setValueObjNull() {
671674
// mean we reset calendar value and set it to null
@@ -744,7 +747,7 @@ export class JBDateInputWebComponent extends HTMLElement {
744747
const result: JBDateInputValueObject = this.#dateFactory.getDateValueObjectBaseOnInputType(year, month, day, prevYear, prevMonth);
745748
this.#valueObject = result;
746749
this.updateCalendarView();
747-
this.#updateFormAssossicatedValue();
750+
this.#updateFormAssociatedValue();
748751
}
749752
#updateInputTextFromValue() {
750753
const { year, month, day } = this.inputType == InputTypes.jalali ? this.#valueObject.jalali : this.#valueObject.gregorian;

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"jalali web-component",
2929
"jalali web component"
3030
],
31-
"version": "3.12.0",
31+
"version": "3.13.0",
3232
"bugs": "https://github.com/javadbat/jb-date-input/issues",
3333
"license": "MIT",
3434
"files": [
@@ -54,6 +54,6 @@
5454
"dependencies": {
5555
"date-fns": "^2.28.0",
5656
"date-fns-jalali": "^2.28.0-0",
57-
"jb-calendar": "^4.0.4"
57+
"jb-calendar": "^4.1.1"
5858
}
5959
}

0 commit comments

Comments
 (0)