Date Picker

The Date picker provides an easy way to handle date selection.

Example Usage

const url = await webview.datePicker.create({
  ref: 'pickup-date',
  title: 'Choose a pick up date',
  onSelect: {
    eventName: 'pick date',
    paramName: 'date'
  }
})

Properties

PropertyTypeExampleDescriptionRequired
refstringpickup-dateIf provided, the webview will update it's content
titlestringChoose a date...Descriptive titles shown in the topYes
tintstring#FF0000Tint color used for the buttons
button.labelstringChoose dateLabel of the confirmation button
onSelect.eventNamestringDate selectedEvent name to trigger when selection is madeYes
onSelect.paramNamestringpickupDateOptional name to use for the parameter that will contain the selected date

Calendar properties

ParameterTypeDefaultDescription
valuearrayArray with initial selected dates. Each array item represents the selected date
disabledDate RangeAdditional disabled dates. The parameter accepts the so-called Date Range (look below for details)
eventsDate RangeDates with events. It will be marked with an additional "dot" on the calendar day. The parameter accepts so-called Date Range (look below for details)
monthNamesarray['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August' , 'September' , 'October', 'November', 'December']Array with full month names
monthNamesShortarray['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']Array with short month names
dayNamesarray['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']Array with week day names
dayNamesShortarray['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']Array with week day short names
firstDaynumber1First day of the week. By default 1 - Monday
weekendDaysarray[0,6]Array with index number of weekend days, by default it is Saturday and Sunday
dateFormatstringyyyy-mm-ddDefault date format, available expressions:'yyyy' - 4 digits year'yy' - 2 digits year'mm' - 2 digits month number, from 01 to 12'm' - month number, from 1 to 12'MM' - full month name'M' - short month name 'dd' - 2 digits day number, from 01 to 31'd' - day number, from 1 to 31'DD' - full week day name 'D' - short week day name
multiplebooleanfalseEnable to allows select multiple dates/values
rangePickerbooleanfalseEnable to enable range picker. Not compatible with multiple
rangePickerMinDaysnumber1Minimum days that need to be selected when rangePicker enabled
rangePickerMaxDaysnumber0Maximum days allowed to be selected when rangePicker enabled. 0 means no maximum
directionstringhorizontalMonths layout direction, could be 'horizontal' or 'vertical'
minDateDatenullMinimum allowed date
maxDateDatenullMaximum allowed date
weekHeaderbooleantrueEnable week header with short name week days
monthSelectorbooleantrueEnable month selector in toolbar
yearSelectorbooleantrueEnable year picker in toolbar

More details

Date Range

Some of the Calendar parameters (disabled, events) accept a so-called Date Range. It is a simple way to specify and cover all possible date combinations.

It can be array with dates, for example:

...
  // Disable all dates between 1st October 2015 and 31 December 2015
  disabled: {
    from: new Date(2015, 9, 1),
    to: new Date(2015, 11, 31)
  }
  ...

Or array with mixed dates and objects:

...
  events: [
    new Date(2015, 9, 1),
    new Date(2015, 9, 5),
    {
        from: new Date(2015, 9, 10),
        to: new Date(2015, 9, 15)
    },
    {
        from: new Date(2015, 9, 20),
        to: new Date(2015, 9, 31)
    },
    {
        date: new Date(2015, 11, 1),
        color: '#ff0000'
    }
  ]
  ...

Date Events

If you want to indicate that day has few different events, it is possible to indicate this with multiple different color dots. In this case, you need to pass date range as array where each object will have date and color properties

...
  events: [
    new Date(2015, 9, 1),
    new Date(2015, 9, 5),
    {
        from: new Date(2015, 9, 10),
        to: new Date(2015, 9, 15)
    },
    {
        from: new Date(2015, 9, 20),
        to: new Date(2015, 9, 31)
    },
    {
        date: new Date(2015, 11, 1),
        color: '#ff0000'
    },
    // same date but one more color dot will be added
    {
        date: new Date(2015, 11, 1),
        color: '#00ff00'
    },
  ]
  ...