| Copyright | (c) 2018 Francisco Vallarino |
|---|---|
| License | BSD-3-Clause (see the LICENSE file) |
| Maintainer | fjvallarino@gmail.com |
| Stability | experimental |
| Portability | non-portable |
| Safe Haskell | Safe-Inferred |
| Language | Haskell2010 |
Monomer.Widgets.Singles.DateField
Contents
Description
Input field for dates types with support for valid ranges, different formats and separators.
dateField dateLens
With configuration options:
dateField_ dateLens [dateFormatMMDDYYYY, dateFormatDelimiter '-']
Supports the Day type of the time
library, but other types can be supported by implementing DayConverter.
Maybe is also supported.
Handles mouse wheel and shift + vertical drag to increase/decrease days.
Synopsis
- data DateFieldCfg s e a
- data DateFieldFormat
- type FormattableDate a = (Eq a, Ord a, Show a, DateTextConverter a, Typeable a)
- class (Eq a, Ord a, Show a, Typeable a) => DayConverter a where
- convertFromDay :: Day -> a
- convertToDay :: a -> Maybe Day
- class DateTextConverter a where
- dateAcceptText :: DateFieldFormat -> Char -> Maybe a -> Maybe a -> Text -> (Bool, Bool, Maybe a)
- dateFromText :: DateFieldFormat -> Char -> Text -> Maybe a
- dateToText :: DateFieldFormat -> Char -> a -> Text
- dateFromDay :: Day -> a
- dateToDay :: a -> Maybe Day
- dateFormatDelimiter :: Char -> DateFieldCfg s e a
- dateFormatDDMMYYYY :: DateFieldCfg s e a
- dateFormatMMDDYYYY :: DateFieldCfg s e a
- dateFormatYYYYMMDD :: DateFieldCfg s e a
- dateField :: (FormattableDate a, WidgetEvent e) => ALens' s a -> WidgetNode s e
- dateField_ :: (FormattableDate a, WidgetEvent e) => ALens' s a -> [DateFieldCfg s e a] -> WidgetNode s e
- dateFieldV :: (FormattableDate a, WidgetEvent e) => a -> (a -> e) -> WidgetNode s e
- dateFieldV_ :: (FormattableDate a, WidgetEvent e) => a -> (a -> e) -> [DateFieldCfg s e a] -> WidgetNode s e
- dateFieldD_ :: (FormattableDate a, WidgetEvent e) => WidgetData s a -> [DateFieldCfg s e a] -> WidgetNode s e
Configuration
data DateFieldCfg s e a Source #
Configuration options for dateField:
caretWidth: the width of the caret.caretMs: the blink period of the caret.validInput: field indicating if the current input is valid. Useful to show warnings in the UI, or disable buttons if needed.resizeOnChange: Whether input causesResizeWidgetsrequests.selectOnFocus: Whether all input should be selected when focus is received.readOnly: Whether to prevent the user changing the input text.minValue: Minimum valid date.maxValue: Maximum valid date.wheelRate: The rate at which wheel movement affects the date.dragRate: The rate at which drag movement affects the date.onFocus: event to raise when focus is received.onFocusReq:WidgetRequestto generate when focus is received.onBlur: event to raise when focus is lost.onBlurReq:WidgetRequestto generate when focus is lost.onChange: event to raise when the value changes.onChangeReq:WidgetRequestto generate when the value changes.dateFormatDelimiter: which text delimiter to separate year, month and day.dateFormatDDMMYYYY: using the current delimiter, accept DDMMYYYY.dateFormatMMDDYYYY: using the current delimiter, accept MMDDYYYY.dateFormatYYYYMMDD: using the current delimiter, accept YYYYMMDD.
Instances
data DateFieldFormat Source #
Available formats for dateField.
Instances
| Show DateFieldFormat Source # | |
Defined in Monomer.Widgets.Singles.DateField Methods showsPrec :: Int -> DateFieldFormat -> ShowS # show :: DateFieldFormat -> String # showList :: [DateFieldFormat] -> ShowS # | |
| Eq DateFieldFormat Source # | |
Defined in Monomer.Widgets.Singles.DateField Methods (==) :: DateFieldFormat -> DateFieldFormat -> Bool # (/=) :: DateFieldFormat -> DateFieldFormat -> Bool # | |
type FormattableDate a = (Eq a, Ord a, Show a, DateTextConverter a, Typeable a) Source #
Constraints for date types accepted by dateField.
class (Eq a, Ord a, Show a, Typeable a) => DayConverter a where Source #
Converter to and form the Day type of the time library. To use types other than Day of said library, this typeclass needs to be implemented. -
Instances
| DayConverter Day Source # | |
Defined in Monomer.Widgets.Singles.DateField | |
class DateTextConverter a where Source #
Converts a Day instance to and from Text. Implementing this typeclass
is not necessary for instances of DayConverter.
Methods
dateAcceptText :: DateFieldFormat -> Char -> Maybe a -> Maybe a -> Text -> (Bool, Bool, Maybe a) Source #
dateFromText :: DateFieldFormat -> Char -> Text -> Maybe a Source #
dateToText :: DateFieldFormat -> Char -> a -> Text Source #
dateFromDay :: Day -> a Source #
Instances
| DayConverter a => DateTextConverter a Source # | |
Defined in Monomer.Widgets.Singles.DateField Methods dateAcceptText :: DateFieldFormat -> Char -> Maybe a -> Maybe a -> Text -> (Bool, Bool, Maybe a) Source # dateFromText :: DateFieldFormat -> Char -> Text -> Maybe a Source # dateToText :: DateFieldFormat -> Char -> a -> Text Source # dateFromDay :: Day -> a Source # | |
| (DayConverter a, DateTextConverter a) => DateTextConverter (Maybe a) Source # | |
Defined in Monomer.Widgets.Singles.DateField Methods dateAcceptText :: DateFieldFormat -> Char -> Maybe (Maybe a) -> Maybe (Maybe a) -> Text -> (Bool, Bool, Maybe (Maybe a)) Source # dateFromText :: DateFieldFormat -> Char -> Text -> Maybe (Maybe a) Source # dateToText :: DateFieldFormat -> Char -> Maybe a -> Text Source # dateFromDay :: Day -> Maybe a Source # | |
dateFormatDelimiter :: Char -> DateFieldCfg s e a Source #
Which character should be used to delimit dates.
dateFormatDDMMYYYY :: DateFieldCfg s e a Source #
Date format DDMMYYYY, using the appropriate delimiter.
dateFormatMMDDYYYY :: DateFieldCfg s e a Source #
Date format MMDDYYYY, using the appropriate delimiter.
dateFormatYYYYMMDD :: DateFieldCfg s e a Source #
Date format YYYYMMDD, using the appropriate delimiter.
Constructors
Arguments
| :: (FormattableDate a, WidgetEvent e) | |
| => ALens' s a | The lens into the model. |
| -> WidgetNode s e | The created date field. |
Creates a date field using the given lens.
Arguments
| :: (FormattableDate a, WidgetEvent e) | |
| => ALens' s a | The lens into the model. |
| -> [DateFieldCfg s e a] | The config options. |
| -> WidgetNode s e | The created date field. |
Creates a date field using the given lens. Accepts config.
Arguments
| :: (FormattableDate a, WidgetEvent e) | |
| => a | The current value. |
| -> (a -> e) | The event to raise on change. |
| -> WidgetNode s e | The created date field. |
Creates a date field using the given value and onChange event handler.
Arguments
| :: (FormattableDate a, WidgetEvent e) | |
| => a | The current value. |
| -> (a -> e) | The event to raise on change. |
| -> [DateFieldCfg s e a] | The config options. |
| -> WidgetNode s e | The created date field. |
Creates a date field using the given value and onChange event handler.
Accepts config.
Arguments
| :: (FormattableDate a, WidgetEvent e) | |
| => WidgetData s a | The |
| -> [DateFieldCfg s e a] | The config options. |
| -> WidgetNode s e | The created date field. |
Creates a date field providing a WidgetData instance and config.