Safe Haskell | None |
---|---|
Language | Haskell2010 |
Infrastructure common to a wide variety of widgets. WidgetConfig holds the core inputs needed by most widgets, while HtmlWidget holds the core Dynamics and Events returned by most widgets. Encapsulating widget inputs and outputs this way makes it easier to compose and transform widgets.
- class HasChange a where
- data WidgetConfig t a = WidgetConfig {}
- widgetConfig_setValue :: forall t a. Lens' (WidgetConfig t a) (Event t a)
- widgetConfig_initialValue :: forall t a. Lens' (WidgetConfig t a) a
- widgetConfig_attributes :: forall t a. Lens' (WidgetConfig t a) (Dynamic t (Map String String))
- class IsWidget w where
- constWidget :: Reflex t => a -> w t a
- mapWidget :: MonadWidget t m => (a -> b) -> w t a -> m (w t b)
- combineWidgets :: MonadWidget t m => (a -> b -> c) -> w t a -> w t b -> m (w t c)
- wconcat :: (MonadWidget t m, Foldable f, Monoid a) => f (w t a) -> m (w t a)
- extractWidget :: MonadWidget t m => Dynamic t (w t a) -> m (w t a)
- data Widget0 t a = Widget0 {
- _widget0_value :: Dynamic t a
- _widget0_change :: Event t a
- widget0_value :: forall t a. Lens' (Widget0 t a) (Dynamic t a)
- widget0_change :: forall t a. Lens' (Widget0 t a) (Event t a)
- data HtmlWidget t a = HtmlWidget {
- _hwidget_value :: Dynamic t a
- _hwidget_change :: Event t a
- _hwidget_keypress :: Event t Int
- _hwidget_keydown :: Event t Int
- _hwidget_keyup :: Event t Int
- _hwidget_hasFocus :: Dynamic t Bool
- hwidget_value :: forall t a. Lens' (HtmlWidget t a) (Dynamic t a)
- hwidget_keyup :: forall t a. Lens' (HtmlWidget t a) (Event t Int)
- hwidget_keypress :: forall t a. Lens' (HtmlWidget t a) (Event t Int)
- hwidget_keydown :: forall t a. Lens' (HtmlWidget t a) (Event t Int)
- hwidget_hasFocus :: forall t a. Lens' (HtmlWidget t a) (Dynamic t Bool)
- hwidget_change :: forall t a. Lens' (HtmlWidget t a) (Event t a)
- htmlTo0 :: HtmlWidget t a -> Widget0 t a
- type GWidget t m a = WidgetConfig t a -> m (HtmlWidget t a)
- dateTimeWidget :: MonadWidget t m => GWidget t m (Maybe UTCTime)
- dateWidget :: MonadWidget t m => GWidget t m (Maybe Day)
- htmlCheckbox :: MonadWidget t m => GWidget t m Bool
- htmlTextInput :: MonadWidget t m => String -> GWidget t m String
- htmlTextInput' :: MonadWidget t m => String -> WidgetConfig t String -> m (HTMLInputElement, HtmlWidget t String)
- readableWidget :: (MonadWidget t m, Show a, Readable a) => GWidget t m (Maybe a)
- doubleWidget :: MonadWidget t m => GWidget t m (Maybe Double)
- integerWidget :: MonadWidget t m => GWidget t m (Maybe Integer)
- intWidget :: MonadWidget t m => GWidget t m (Maybe Int)
- htmlDropdown :: (MonadWidget t m, Eq b) => Dynamic t [a] -> (a -> String) -> (a -> b) -> WidgetConfig t b -> m (Widget0 t b)
- htmlDropdownStatic :: (MonadWidget t m, Eq b) => [a] -> (a -> String) -> (a -> b) -> WidgetConfig t b -> m (Widget0 t b)
- blurOrEnter :: Reflex t => HtmlWidget t a -> Event t a
- restrictWidget :: MonadWidget t m => (HtmlWidget t a -> Event t a) -> GWidget t m a -> GWidget t m a
- inputOnEnter :: MonadWidget t m => (WidgetConfig t a -> m (HtmlWidget t a)) -> WidgetConfig t a -> m (Dynamic t a)
- listDropdown :: MonadWidget t m => Dynamic t [a] -> (a -> String) -> Dynamic t (Map String String) -> String -> m (Dynamic t (Maybe a))
Documentation
data WidgetConfig t a Source
Generic config structure common to most widgets. The attributes field may not be used for all widgets, but in that case it can just be ignored. We may want to change this in the future, but it seems like a reasonable start for now.
WidgetConfig | |
|
Reflex t => Functor (WidgetConfig t) Source | |
(Reflex t, Default a) => Default (WidgetConfig t a) Source | |
HasSetValue (WidgetConfig t a) Source | |
HasAttributes (WidgetConfig t a) Source | |
type SetValue (WidgetConfig t a) = Event t a Source | |
type Attrs (WidgetConfig t a) = Dynamic t (Map String String) Source |
widgetConfig_setValue :: forall t a. Lens' (WidgetConfig t a) (Event t a) Source
widgetConfig_initialValue :: forall t a. Lens' (WidgetConfig t a) a Source
widgetConfig_attributes :: forall t a. Lens' (WidgetConfig t a) (Dynamic t (Map String String)) Source
constWidget :: Reflex t => a -> w t a Source
HtmlWidget with a constant value that never fires any events.
mapWidget :: MonadWidget t m => (a -> b) -> w t a -> m (w t b) Source
We can't make a Functor instance until Dynamic gets a Functor instance.
combineWidgets :: MonadWidget t m => (a -> b -> c) -> w t a -> w t b -> m (w t c) Source
wconcat :: (MonadWidget t m, Foldable f, Monoid a) => f (w t a) -> m (w t a) Source
Combines multiple widgets over a Monoid operation.
extractWidget :: MonadWidget t m => Dynamic t (w t a) -> m (w t a) Source
Since widgets contain Dynamics and Events inside them, we can pull Dynamic widgets out of the Dynamic.
A general-purpose widget return value.
Widget0 | |
|
widget0_value :: forall t a. Lens' (Widget0 t a) (Dynamic t a) Source
widget0_change :: forall t a. Lens' (Widget0 t a) (Event t a) Source
data HtmlWidget t a Source
A general-purpose widget return value.
HtmlWidget | |
|
IsWidget HtmlWidget Source | |
HasValue (HtmlWidget t a) Source | |
HasChange (HtmlWidget t a) Source | |
type Value (HtmlWidget t a) = Dynamic t a Source | |
type Change (HtmlWidget t a) = Event t a Source |
hwidget_value :: forall t a. Lens' (HtmlWidget t a) (Dynamic t a) Source
hwidget_keyup :: forall t a. Lens' (HtmlWidget t a) (Event t Int) Source
hwidget_keypress :: forall t a. Lens' (HtmlWidget t a) (Event t Int) Source
hwidget_keydown :: forall t a. Lens' (HtmlWidget t a) (Event t Int) Source
hwidget_hasFocus :: forall t a. Lens' (HtmlWidget t a) (Dynamic t Bool) Source
hwidget_change :: forall t a. Lens' (HtmlWidget t a) (Event t a) Source
htmlTo0 :: HtmlWidget t a -> Widget0 t a Source
type GWidget t m a = WidgetConfig t a -> m (HtmlWidget t a) Source
Generalized form of many widget functions.
dateTimeWidget :: MonadWidget t m => GWidget t m (Maybe UTCTime) Source
Input widget for datetime values.
dateWidget :: MonadWidget t m => GWidget t m (Maybe Day) Source
Input widget for dates.
htmlCheckbox :: MonadWidget t m => GWidget t m Bool Source
HtmlWidget version of reflex-dom's checkbox.
htmlTextInput :: MonadWidget t m => String -> GWidget t m String Source
HtmlWidget version of reflex-dom's textInput.
htmlTextInput' :: MonadWidget t m => String -> WidgetConfig t String -> m (HTMLInputElement, HtmlWidget t String) Source
HtmlWidget version of reflex-dom's textInput that also returns the HTMLInputElement.
readableWidget :: (MonadWidget t m, Show a, Readable a) => GWidget t m (Maybe a) Source
NOTE: You should probably not use this function with string types because the Show instance will quote strings.
doubleWidget :: MonadWidget t m => GWidget t m (Maybe Double) Source
Widget that parses its input to a Double.
integerWidget :: MonadWidget t m => GWidget t m (Maybe Integer) Source
Widget that parses its input to an Integer.
intWidget :: MonadWidget t m => GWidget t m (Maybe Int) Source
Widget that parses its input to an Int.
htmlDropdown :: (MonadWidget t m, Eq b) => Dynamic t [a] -> (a -> String) -> (a -> b) -> WidgetConfig t b -> m (Widget0 t b) Source
Dropdown widget that takes a dynamic list of items and a function generating a String representation of those items.
htmlDropdownStatic :: (MonadWidget t m, Eq b) => [a] -> (a -> String) -> (a -> b) -> WidgetConfig t b -> m (Widget0 t b) Source
Dropdown widget that takes a list of items and a function generating a String representation of those items.
This widget doesn't require your data type to have Read and Show instances like reflex-dom's dropdown function. It does this by using Int indices into your static list of items in the actual rendered dropdown element.
But this comes with a price--it has unexpected behavior under insertions, deletions, and reorderings of the list of options. Because of this, you should probably only use this for static dropdowns where the list of options never changes.
blurOrEnter :: Reflex t => HtmlWidget t a -> Event t a Source
Returns an event that fires when the widget loses focus or enter is pressed.
restrictWidget :: MonadWidget t m => (HtmlWidget t a -> Event t a) -> GWidget t m a -> GWidget t m a Source
Allows you to restrict when a widget fires. For instance,
restrictWidget blurOrEnter
restricts a widget so it only fires on blur
or when enter is pressed.
inputOnEnter :: MonadWidget t m => (WidgetConfig t a -> m (HtmlWidget t a)) -> WidgetConfig t a -> m (Dynamic t a) Source
Like readableWidget but only generates change events on blur or when enter is pressed.