web-rep-0.12.1.0: representations of a web page
Safe HaskellSafe-Inferred
LanguageGHC2021

Web.Rep.SharedReps

Description

Various SharedRep instances for common html input elements.

Synopsis

Documentation

repInput Source #

Arguments

:: Monad m 
=> (ByteString -> Either ByteString a)

Parser

-> (a -> ByteString)

Printer

-> Input a

Input type

-> a

initial value

-> SharedRep m a 

Create a sharedRep from an Input.

repMessage :: Monad m => (ByteString -> Either ByteString a) -> (a -> ByteString) -> Input a -> a -> a -> SharedRep m a Source #

Like repInput, but does not put a value into the HashMap on instantiation, consumes the value when found in the HashMap, and substitutes a default on lookup failure

sliderI :: (Monad m, Integral a, ToByteString a) => Maybe ByteString -> a -> a -> a -> a -> SharedRep m a Source #

integral slider

For Example, a slider between 0 and 1000 with a step of 10 and a default value of 300 is:

:t sliderI (Just "label") 0 1000 10 300

sliderI (Just "label") 0 1000 10 300 :: (Monad m, ToHtml a, P.Integral a, Show a) => SharedRep m a

slider :: Monad m => Maybe ByteString -> Double -> Double -> Double -> Double -> SharedRep m Double Source #

double slider

For Example, a slider between 0 and 1 with a step of 0.01 and a default value of 0.3 is:

:t slider (Just "label") 0 1 0.01 0.3

slider (Just "label") 0 1 0.01 0.3 :: Monad m => SharedRep m Double

sliderV :: Monad m => Maybe ByteString -> Double -> Double -> Double -> Double -> SharedRep m Double Source #

double slider with shown value

For Example, a slider between 0 and 1 with a step of 0.01 and a default value of 0.3 is:

:t slider (Just "label") 0 1 0.01 0.3

slider (Just "label") 0 1 0.01 0.3 :: Monad m => SharedRep m Double

sliderVI :: (Monad m, Integral a, ToByteString a) => Maybe ByteString -> a -> a -> a -> a -> SharedRep m a Source #

integral slider with shown value

dropdown Source #

Arguments

:: Monad m 
=> (ByteString -> Either ByteString a)

parse an a from ByteString

-> (a -> ByteString)

print an a to ByteString

-> Maybe ByteString

label suggestion

-> [ByteString]

list of dropbox elements (as text)

-> a

initial value

-> SharedRep m a 

dropdown box

dropdownMultiple Source #

Arguments

:: Monad m 
=> Parser ByteString a

parse an a from ByteString

-> (a -> ByteString)

print an a to ByteString

-> Maybe ByteString

label suggestion

-> [ByteString]

list of dropbox elements (as text)

-> [a]

initial value

-> SharedRep m [a] 

dropdown box with multiple selections

dropdownSum :: Monad m => (ByteString -> Either ByteString a) -> (a -> ByteString) -> Maybe ByteString -> [ByteString] -> a -> SharedRep m a Source #

A dropdown box designed to help represent a haskell sum type.

colorPicker :: Monad m => Maybe ByteString -> ByteString -> SharedRep m ByteString Source #

Non-typed hex color input

textbox :: Monad m => Maybe ByteString -> ByteString -> SharedRep m ByteString Source #

textbox classique

:t textbox (Just "label") "some text"

textbox (Just "label") "some text" :: Monad m => SharedRep m ByteString

textarea :: Monad m => Int -> Maybe ByteString -> ByteString -> SharedRep m ByteString Source #

textarea input element, specifying number of rows.

checkbox :: Monad m => Maybe ByteString -> Bool -> SharedRep m Bool Source #

A checkbox input.

toggle :: Monad m => Maybe ByteString -> Bool -> SharedRep m Bool Source #

a toggle button

toggle_ :: Monad m => Maybe ByteString -> Bool -> SharedRep m Bool Source #

a toggle button, with no label

maybeRep :: Monad m => Maybe ByteString -> Bool -> SharedRep m a -> SharedRep m (Maybe a) Source #

Represent a Maybe using a checkbox.

Hides the underlying content on Nothing

accordionList :: Monad m => Maybe ByteString -> ByteString -> Maybe ByteString -> (ByteString -> a -> SharedRep m a) -> [ByteString] -> [a] -> SharedRep m [a] Source #

A (fixed-size) list represented in html as an accordion card A major restriction of the library is that a SharedRepF does not have a Monad instance. In practice, this means that the external representation of lists cannot have a dynamic size.

listMaybeRep :: Monad m => Maybe ByteString -> ByteString -> (ByteString -> Maybe a -> SharedRep m (Maybe a)) -> Int -> [a] -> SharedRep m [Maybe a] Source #

A fixed-sized list of Maybe a's

listRep Source #

Arguments

:: Monad m 
=> Maybe ByteString 
-> ByteString 
-> (Bool -> SharedRep m Bool)

name prefix (should be unique)

-> (a -> SharedRep m a)

Bool Rep

-> Int

a Rep

-> a

maximum length of list

-> [a]

default value for new rows

-> SharedRep m [a]

initial values

A SharedRep of [a]. Due to the applicative nature of the bridge, the size of lists has to be fixed on construction. listRep is a workaround for this, to enable some form of dynamic sizing.

readTextbox :: (Monad m, Read a, ToByteString a) => Maybe ByteString -> a -> SharedRep m (Either ByteString a) Source #

Parse from a textbox

Uses focusout so as not to spam the reader.

defaultListLabels :: Int -> [ByteString] Source #

A sensible default for the accordion row labels for a list

repChoice :: Monad m => Int -> [(ByteString, SharedRep m a)] -> SharedRep m a Source #

Dropdown representation of a multi-element list.

subtype :: ByteString -> ByteString -> [Attr] Source #

subtype Html class.

selectItems :: [ByteString] -> HashMap ByteString a -> [(ByteString, a)] Source #

select test keys from a Map

repItemsSelect :: Monad m => [ByteString] -> [ByteString] -> SharedRep m [ByteString] Source #

rep of multiple items list