@@ -20,11 +20,12 @@ module DatePicker
2020 , previousMonth
2121 , nextMonth
2222 , receiveDate
23+ , setDate
2324 )
2425
2526{- | A customisable DatePicker that easily allows you to select a range of dates
2627
27- @docs DatePicker, Msg, Config, defaultConfig, initCalendar, showCalendar, update, Selection
28+ @docs DatePicker, Msg, Config, defaultConfig, initCalendar, showCalendar, update, Selection, receiveDate
2829
2930
3031# Getter Functions
@@ -36,9 +37,20 @@ These functions allow you to access data from the DatePicker model.
3637
3738# API Functions
3839
39- These functions allow us to perform updates to the datepicker model
40+ These functions allow us to perform updates to the datepicker model. Just pass the datepicker as the last argument.
41+ For example:
4042
41- @docs clearDates, toggleCalendar, cancelDates, previousMonth, nextMonth, receiveDate
43+ ```Elm
44+ newDatepicker = DatePicker.setDate date datepicker
45+ ```
46+
47+ Or
48+
49+ ```Elm
50+ newDatePicker = DatePicker.clearDates datepicker
51+ ```
52+
53+ @docs clearDates, toggleCalendar, cancelDates, previousMonth, nextMonth, setDate
4254
4355-}
4456
@@ -557,3 +569,10 @@ nextMonth =
557569receiveDate : Cmd Msg
558570receiveDate =
559571 Task . perform ReceiveDate Date . now
572+
573+
574+ {- | Manually set the selected date
575+ -}
576+ setDate : Date -> DatePicker -> DatePicker
577+ setDate date =
578+ update ( SelectDate ( Just date))
0 commit comments