mv-calendar
MvCalendar is a Meveo calendar component (based on lit-element) that renders a datepicker component that can display a simple calendar, a calendar with date range, or a datepicker popup in an input field.
Features
- Renders the calendar using a single component tag
- Renders a simple calendar
- Renders a calendar with date range
- Renders a datepicker popup in an input field
- Written in vanilla javascript
Quick Start
To experiment with the MvCalendar component.
Sample usage
The mv-calendar
has 3 type
variants:
default, dropdown, and range
The default calendar will display a simple calendar on the page.
<mv-calendar
name="singleCalendar"
placeholder="Single Calendar"
inline-input
monday-first
allow-partial
min-year="2010"
max-year="2030"
pattern="MM/DD/YYYY"
pattern-matcher="MDY"
pattern-regex="\\d"
?has-error="${this.hasError}"
.theme="${theme}"
.selected="${this.selectedDate}"
@select-date="${this.changeDate}"
></mv-calendar>
The dropdown calendar will display an input field which pops out a calendar dropdown when focused.
<mv-calendar
name="singleCalendar"
dropdown
placeholder="Dropdown Calendar"
monday-first
allow-partial
min-year="2010"
max-year="2030"
pattern="MM/DD/YYYY"
pattern-matcher="MDY"
pattern-regex="\\d"
?has-error="${this.hasError}"
.theme="${theme}"
.selected="${this.selectedDate}"
@select-date="${this.changeDate}"
></mv-calendar>
The range calendar will display a component with two calendars that allow the user to choose a start and end date range.
<mv-calendar
name="rangeCalendar"
range-calendar
inline-input
.start="${this.start}"
.end="${this.end}"
monday-first
allow-partial
pattern="MM/DD/YYYY"
pattern-matcher="MDY"
pattern-regex="\\d"
.theme="${theme}"
@select-date="${this.changeDate}"
></mv-calendar>
Input values
The selected
attribute's value should have the following details:
{
date,
year,
month,
day
}
The for range
calendars, the start
and end
attributes' values should have the following details:
{
selected: {
date,
year,
month,
day
},
placeholder,
hasError,
minYear,
maxYear,
}
Return values
For single
calendars, the select-date
custom event's detail
has the following values:
const {
detail: {
name,
selected: {
date,
year,
month,
day
},
}
} = event;
For range
calendars, the select-date
custom event's detail
has the following values:
const {
detail: {
name,
selected: {
start: {
date,
year,
month,
day
},
end: {
date,
year,
month,
day
},
}
}
} = event;
You can also check this demo
Acknowledgements