YearPicker

A Panel subclass which allows a year to be selected from a range of 12 displayed years.

The panel can be configured with startYear to specify the first year in the displayed range.

The year indicates and sets the currently selected year.

The select event is fired when a new year is selected.

Year picker
//<code-header>
fiddle.title = 'Year picker';
//</code-header>
const picker = new YearPicker({
    appendTo : targetElement,
    tbar     : {
        items : {
            // Move the title to the centre
            title : {
                weight : 250
            }
        }
    },
    width    : '24em',
    onChange : ({ value }) => {
        Toast.show(`You picked ${value}`);
    }
});

Configs

113

Common

listenersEvents

Other

maxYear: Number

The highest year to allow.

minYear: Number

The lowest year to allow.

The year to show at the start of the widget

The definition of the top toolbar which displays the title and "previous" and "next" buttons.

This contains the following predefined items which may be reconfigured by application code:

  • title A widget which displays the visible year range. Weight 100.
  • previous A button which navigates to the previous block. Weight 200.
  • next A button which navigates to the next block. Weight 300.

These may be reordered:

new YearPicker({
    appendTo : targetElement,
    tbar     : {
        items : {
            // Move title to centre
            title : {
                weight : 250
            }
        }
    },
    width    : '24em'
});

The year to use as the selected year. Defaults to the current year.

yearButtonCount: Number= 12

The number of clickable year buttons to display in the widget.

It may be useful to change this if a non-standard shape or size is used.

columnWidget
defaultFocusContainer
drawerPanel
labelPositionContainer
renditionContainer
rtlRTL
spanWidget

Accessibility

ariaLabelWidget
keyMapKeyMap

Content

bbarPanel
defaultsContainer
footerPanel
headerPanel
itemsContainer
lazyItemsContainer
namedItemsContainer
stripsPanel
textContentContainer
toolsPanel

CSS

bodyClsPanel
borderContainer
clsWidget
colorWidget
htmlClsWidget
itemClsContainer
styleWidget
uiPanel

DOM

adoptWidget
appendToWidget
contentWidget
datasetWidget
htmlWidget
idWidget
tagWidget

Float & align

alignWidget
anchorWidget
centeredWidget
draggableWidget
floatingWidget
xWidget
yWidget

Layout

alignSelfWidget
dockWidget
flexWidget
heightWidget
hiddenWidget
hideWhenEmptyContainer
layoutContainer
layoutStyleContainer
marginWidget
maxHeightWidget
maxWidthWidget
minHeightWidget
minWidthWidget
textAlignWidget
weightWidget
widthWidget

misc

tabBarItemsContainer

Misc

dataFieldWidget
disabledWidget
iconPanel
localeClassLocalizable
localizableLocalizable
maskedWidget
ownerWidget
readOnlyWidget
refWidget
rippleWidget
tabWidget
titlePanel
tooltipWidget

Record

recordContainer

Scrolling

State

stateIdState

Properties

98

Class hierarchy

isYearPicker: Boolean= truereadonly
Identifies an object as an instance of YearPicker class, or subclass thereof.
isYearPicker: Boolean= truereadonlystatic
Identifies an object as an instance of YearPicker class, or subclass thereof.
isContainerContainer
isDelayableDelayable
isEventsEvents
isKeyMapKeyMap
isLocalizableLocalizable
isPanelPanel
isStateState
isToolableToolable
isWidgetWidget

Other

endYear: Numberreadonly

The ending year displayed in the widget.

The starting year displayed in the widget.

value: Number

The currently selected year.

The currently selected year.

$namestaticWidget
columnWidget
firstItemContainer
hasChangesContainer
isValidContainer
itemsContainer
labelPositionContainer
lastItemContainer
renditionContainer
rtlRTL
spanWidget
toolsPanel
typestaticWidget
valuesContainer

Accessibility

keyMapKeyMap

Content

bbarPanel
tbarPanel

CSS

clsWidget

DOM

appendToWidget
contentWidget
datasetWidget
elementWidget
htmlWidget
idWidget
styleWidget

Float & align

xWidget
yWidget

Layout

alignSelfWidget
flexWidget
heightWidget
layoutContainer
layoutStyleContainer
marginWidget
maxHeightWidget
maxWidthWidget
minHeightWidget
minWidthWidget
widthWidget

Lifecycle

configBase

Misc

cellInfoWidget
disabledWidget
localeHelperLocalizable
localeManagerLocalizable
readOnlyWidget
refWidget
tabWidget
titlePanel
tooltipWidget

Record

recordContainer

State

stateState

Visibility

hiddenWidget
isVisibleWidget

Widget hierarchy

ownerWidget
parentWidget
widgetMapContainer

Functions

74

Configuration

applyDefaultsstaticBase

Events

Float & align

alignToWidget
setXYWidget
showByWidget
toFrontWidget

Lifecycle

createstaticWidget
destroystaticBase
initClassstaticWidget

Misc

attachTooltipstaticWidget
fromElementstaticWidget
fromSelectorstaticWidget
getByIdstaticWidget
isOfTypeNamestaticBase
mixinstaticBase
optionalLstaticLocalizable

Other

addContainer
composeWidget
createOnFrameDelayable
disableWidget
enableWidget
focusWidget
getAtContainer
getWidgetByIdContainer
insertContainer
LstaticLocalizable
maskWidget
onEvents
recomposeWidget
relayAllEvents
removeContainer
removeAllContainer
resetValuesContainer
setValuesContainer
triggerEvents
unEvents
unmaskWidget

State

Visibility

hideWidget
showWidget

Widget hierarchy

closestWidget
containsWidget
ownsWidget
queryWidget
queryAllWidget
upWidget

Events

22

Fired when a year is selected.

// Adding a listener using the "on" method
yearPicker.on('select', ({ value, source }) => {

});
ParameterTypeDescription
valueNumber

The previously selected year.

sourceYearPicker

This YearPicker

catchAllEvents
destroyEvents
expandPanel
focusInWidget
focusOutWidget
hideWidget
paintWidget
readOnlyWidget
recomposeWidget
resizeWidget
showWidget

Event handlers

22

Called when a year is selected.

new YearPicker({
    onSelect({ value, source }) {

    }
});
ParameterTypeDescription
valueNumber

The previously selected year.

sourceYearPicker

This YearPicker

onDestroyEvents
onFocusInWidget
onHideWidget
onPaintWidget
onResizeWidget
onShowWidget

Typedefs

7

CSS variables

60
NameDescription
--b-year-picker-gapGap between the years in the year picker, and months in the month picker.
--b-year-picker-paddingPadding inside the year picker and the month picker.
--b-year-picker-title-font-weightFont weight for the title of the year picker and the month picker
--b-year-picker-year-font-weightFont weight for the years in the year picker and the months in the month picker
--b-year-picker-year-colorColor for the years in the year picker and the months in the month picker
Hovered
--b-year-picker-hover-backgroundBackground for the hovered year in the year picker and the hovered month in the month picker
Selected
--b-year-picker-selected-backgroundBackground for the selected year in the year picker and the selected month in the month picker
--b-year-picker-selected-colorColor for the selected year in the year picker and the selected month in the month picker

Inherited