CalendarPanel
A Panel which displays a month of date cells.
This is a base class for UI widgets like DatePicker which need to display a calendar layout.
Configs
134
Configs
134Common
Other
By default, when navigating through time, the next time block will be animated in from the appropriate direction.
Configure this as false to disable this.
A function (or the name of a function) which creates content in, and may mutate a day cell element.
| Parameter | Type | Description |
|---|---|---|
renderData | Object | |
renderData.cell | HTMLElement | The cell element. |
renderData.date | Date | The date for the cell |
renderData.day | Number | The day for the cell ( |
renderData.rowIndex | Number[] | The row index, 0 to month row count (6 if sixWeeks is |
renderData.row | HTMLElement | The row element encapsulating the week which the cell is a part of |
renderData.source | CalendarPanel | The widget being rendered |
renderData.cellIndex | Number[] | The cell index in the whole panel. May be from |
renderData.columnIndex | Number[] | The column index, |
renderData.visibleColumnIndex | Number[] | The visible column index taking hidden non working days into account |
The date which this CalendarPanel encapsulates.
The DateHelper format string to format the day names in the header row above the calendar cells.
The class name to add to disabled calendar cells.
Either an array of Date objects which are to be disabled (or date strings), or
a function (or the name of a function), which, when passed a Date returns true if the
date is disabled. Disabled dates cannot be interacted with.
| Parameter | Type | Description |
|---|---|---|
date | Date | Date to check |
Returns true if the provided date is disabled
Configure as true to render non working days as disabledDates.
Note, that by default, non working days are read from the locale, and are normally Saturday and Sunday. But they can be set to other days than weekend days.
Configure this as true to disable pointer interaction with cells which are outside the range of the current month.
Configure as true to render Saturdays and Sundays as disabledDates.
A function (or the name of a function) which creates content in, and may mutate a day header element.
The cell element may be mutated, or an HTML string or DomConfig object may be returned.
| Parameter | Type | Description |
|---|---|---|
cell | HTMLElement | The header element |
columnIndex | Number | The day column. Will be in the range |
weekDay | Number | The canonical day number where Monday is |
Configure this as true to hide cells which are outside the range of the current month.
By default, day cells flex to share available Panel width equally.
Set this config if the available width is too small, and the cell width needs to be larger to show events.
Setting this config causes the month grid to become scrollable in the X axis.
By default, week rows flex to share available Panel height equally.
Set this config if the available height is too small, and the cell height needs to be larger to show events.
Setting this config causes the month grid to become scrollable in the Y axis.
May be specified as a number in which case it will be taken to mean pixels, or a length in standard CSS units.
A Month Month utility object which encapsulates this Panel's month and provides contextual information and navigation services.
The class name to add to calendar cells which are nonWorkingDays.
Non-working days as an object where keys are day indices, 0-6 (Sunday-Saturday), and the value is true.
Defaults to nonWorkingDays.
The class name to add to calendar cells which are in the previous or next month.
Configure as true to render past dates in a lighter text color.
Configure as true to show a week number column at the start of the calendar block.
Configure as true to always show a six-week calendar.
A config object to create a tooltip which will show on hover of a date cell including disabled, weekend, and "other month" cells.
It is the developer's responsibility to hook the beforeshow event to either veto the show by returning
false or provide contextual content for the date.
The tip instance will be primed with a date property.
The class name to add to the calendar cell which contains today's date.
The header text for the week number column, if shown.
The class name to add to calendar cells which are weekend dates.
A function (or the name of a function) which creates content in, and may mutate the week cell element at the start of a week row.
weekRenderer(wekkCell, week) {
// week[0] is the year
// week[1] is the week number
cell.innerText = week[1];
}
The cell element may be mutated, or an HTML string or DomConfig object may be returned.
| Parameter | Type | Description |
|---|---|---|
weekCell | HTMLElement | The header element |
week | Number[] | An array containing |
The week start day, 0 meaning Sunday, 6 meaning Saturday. Defaults to weekStartDay.
Content
CSS
DOM
Float & align
Layout
misc
Misc
Scrolling
Properties
102
Properties
102Class hierarchy
Other
By default, when navigating through time, the next time block will be animated in from the appropriate direction.
Configure this as false to disable this.
Gets or sets the date that orientates the panel to display a particular month. Changing this causes the content to be refreshed.
The end date of this view. Note that in terms of full days, this is exclusive, ie: 2020-01-012 to 2020-01-08 is seven days. The end is 00:00:00 on the 8th.
Note that this may not be the last date of this panel's current month.
Configure as true to render past dates in a lighter text color.
Configure as true to show a week number column at the start of the calendar block.
The date of the first day cell in this panel. Note that this may not be the first of this panel's current month.
The number of rows displayed in this month. If sixWeeks is not set, this may be from 4 to 6.
The header text for the week number column, if shown.
CSS
DOM
Layout
Misc
State
Widget hierarchy
Functions
78
Functions
78Other
Returns the cell associated with the passed date.
To exclude dates which are outside of the panel's current month, pass the strict parameter as true
| Parameter | Type | Description |
|---|---|---|
date | Date | String | The date to find the element for or a key in the format |
strict | Boolean | Only return the element if this view owns the date. |
The cell for the passed date if it exists
Refreshes the UI after changing a config that would affect the UI.
The date which this CalendarPanel encapsulates. Setting this causes the content to be refreshed.
Set to 0 for Sunday (the default), 1 for Monday etc.
Set to null to use the default value from DateHelper.
Configuration
Events
Misc
Widget hierarchy
Events
26
Events
26Fires before this CalendarPanel refreshes in response to changes in its month.
// Adding a listener using the "on" method
calendarPanel.on('beforeRefresh', ({ source }) => {
});| Parameter | Type | Description |
|---|---|---|
source | DatePicker | This DatePicker. |
Fired when a date cell is clicked.
// Adding a listener using the "on" method
calendarPanel.on('cellClick', ({ cell, date, week, domEvent }) => {
});| Parameter | Type | Description |
|---|---|---|
cell | HTMLElement | The clicked cell element. |
date | Date | The date represented by the cell. |
week | Number[] | The week array |
domEvent | Event | The original DOM event. |
Fires when the date of this CalendarPanel is set.
// Adding a listener using the "on" method
calendarPanel.on('dateChange', ({ value, oldValue, changes, changes.d, changes.w, changes.m, changes.y }) => {
});| Parameter | Type | Description |
|---|---|---|
value | Date | The new date. |
oldValue | Date | The old date. |
changes | Object | An object which contains properties which indicate what part of the date changed. |
changes.d | Boolean | True if the date changed in any way. |
changes.w | Boolean | True if the week changed (including same week in a different year). |
changes.m | Boolean | True if the month changed (including same month in a different year). |
changes.y | Boolean | True if the year changed. |
Fires when this CalendarPanel refreshes.
// Adding a listener using the "on" method
calendarPanel.on('refresh', ({ }) => {
});Fired when a week number cell is clicked.
// Adding a listener using the "on" method
calendarPanel.on('weekCellClick', ({ date, week, domEvent }) => {
});| Parameter | Type | Description |
|---|---|---|
date | Date | The start date of the week. |
week | Number[] | The week array |
domEvent | Event | The original DOM event. |
Event handlers
26
Event handlers
26Called before this CalendarPanel refreshes in response to changes in its month.
new CalendarPanel({
onBeforeRefresh({ source }) {
}
});| Parameter | Type | Description |
|---|---|---|
source | DatePicker | This DatePicker. |
Called when a date cell is clicked.
new CalendarPanel({
onCellClick({ cell, date, week, domEvent }) {
}
});| Parameter | Type | Description |
|---|---|---|
cell | HTMLElement | The clicked cell element. |
date | Date | The date represented by the cell. |
week | Number[] | The week array |
domEvent | Event | The original DOM event. |
Called when the date of this CalendarPanel is set.
new CalendarPanel({
onDateChange({ value, oldValue, changes }) {
}
});| Parameter | Type | Description |
|---|---|---|
value | Date | The new date. |
oldValue | Date | The old date. |
changes | Object | An object which contains properties which indicate what part of the date changed. |
changes.d | Boolean | True if the date changed in any way. |
changes.w | Boolean | True if the week changed (including same week in a different year). |
changes.m | Boolean | True if the month changed (including same month in a different year). |
changes.y | Boolean | True if the year changed. |
Called when a week number cell is clicked.
new CalendarPanel({
onWeekCellClick({ date, week, domEvent }) {
}
});| Parameter | Type | Description |
|---|---|---|
date | Date | The start date of the week. |
week | Number[] | The week array |
domEvent | Event | The original DOM event. |
Typedefs
7
Typedefs
7CSS variables
69
CSS variables
69| Name | Description |
|---|---|
--b-calendar-panel-day-font-size | Font-size used for day name letters and week numbers |
--b-calendar-panel-day-header-font-weight | Font-weight used for day name letters |
--b-calendar-panel-week-width | Width of the week number column |
--b-calendar-panel-week-number-display | Display property for the week number column |
--b-calendar-panel-cell-display | Display property for date cells |
--b-calendar-panel-cell-padding | Date cell padding |
--b-calendar-panel-cell-font-size | Date cell font size |
--b-calendar-panel-cell-background | Date cell background |
--b-calendar-panel-cell-font-weight | Date cell font-weight |
--b-calendar-panel-disabled-cell-opacity | Disabled date cell opacity |
--b-calendar-panel-non-working-cell-display | Non-working day & date cell display |
--b-calendar-panel-gap | Gap between day and date cells (must have a unit for calculations to work) |
--b-calendar-panel-day-color | Color used for day name letters |
--b-calendar-panel-color | Date cell color |
--b-calendar-panel-other-month-color | Other month (last dates of the month before, first dates of the month after) cell color |
--b-calendar-panel-weeks-gap | Gap between weeks. Also used as block padding for the weeks container to give even spacing |
--b-calendar-panel-week-number-color | The color of text in week number cells |