{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE InstanceSigs, UndecidableInstances, AllowAmbiguousTypes, ScopedTypeVariables, IncoherentInstances #-}
module IHP.View.Types
( FormField (..)
, SubmitButton (..)
, FormContext (..)
, InputType (..)
, CSSFramework (..)
, BreadcrumbsView(..)
, PaginationView(..)
, HtmlWithContext
, Layout
)
where
import IHP.Prelude hiding (div)
import qualified Text.Blaze.Html5 as Blaze
import IHP.FlashMessages.Types
import IHP.ModelSupport (Violation)
import IHP.Breadcrumb.Types
import IHP.Pagination.Types
type HtmlWithContext context = (?context :: context) => Blaze.Html
type Layout = Blaze.Html -> Blaze.Html
data FormField = FormField
{ FormField -> InputType
fieldType :: !InputType
, FormField -> Text
fieldName :: !Text
, FormField -> Text
fieldLabel :: !Text
, FormField -> Text
fieldValue :: !Text
, FormField -> Text
fieldInputId :: !Text
, FormField -> Maybe Violation
validatorResult :: !(Maybe Violation)
, FormField -> [(Text, Text)]
additionalAttributes :: [(Text, Text)]
, FormField -> Text
fieldClass :: !Text
, FormField -> Text
labelClass :: !Text
, FormField -> Bool
disabled :: !Bool
, FormField -> Bool
disableLabel :: !Bool
, FormField -> Bool
disableGroup :: !Bool
, FormField -> Bool
disableValidationResult :: !Bool
, FormField -> CSSFramework
cssFramework :: CSSFramework
, FormField -> Text
helpText :: !Text
, FormField -> Text
placeholder :: !Text
, FormField -> Bool
required :: Bool
, FormField -> Bool
autofocus :: Bool
}
data SubmitButton = SubmitButton
{ SubmitButton -> Html
label :: Blaze.Html
, SubmitButton -> Text
buttonClass :: Text
, SubmitButton -> Bool
buttonDisabled :: Bool
, SubmitButton -> CSSFramework
cssFramework :: CSSFramework
}
data FormContext model = FormContext
{ forall model. FormContext model -> model
model :: model
, forall model. FormContext model -> Text
formAction :: !Text
, forall model. FormContext model -> Text
formMethod :: !Text
, forall model. FormContext model -> CSSFramework
cssFramework :: !CSSFramework
, forall model. FormContext model -> Text
formClass :: !Text
, forall model. FormContext model -> Text
formId :: !Text
, forall model. FormContext model -> Bool
disableJavascriptSubmission :: !Bool
, forall model. FormContext model -> [(Text, Text)]
customFormAttributes :: ![(Text, Text)]
, forall model. FormContext model -> Text
fieldNamePrefix :: !Text
}
instance SetField "model" (FormContext record) record where setField :: record -> FormContext record -> FormContext record
setField record
value FormContext record
record = FormContext record
record { model = value }
instance SetField "formAction" (FormContext record) Text where setField :: Text -> FormContext record -> FormContext record
setField Text
value FormContext record
record = FormContext record
record { formAction = value }
instance SetField "formMethod" (FormContext record) Text where setField :: Text -> FormContext record -> FormContext record
setField Text
value FormContext record
record = FormContext record
record { formMethod = value }
instance SetField "cssFramework" (FormContext record) CSSFramework where setField :: CSSFramework -> FormContext record -> FormContext record
setField CSSFramework
value FormContext record
record = FormContext record
record { cssFramework = value }
instance SetField "formClass" (FormContext record) Text where setField :: Text -> FormContext record -> FormContext record
setField Text
value FormContext record
record = FormContext record
record { formClass = value }
instance SetField "formId" (FormContext record) Text where setField :: Text -> FormContext record -> FormContext record
setField Text
value FormContext record
record = FormContext record
record { formId = value }
instance SetField "disableJavascriptSubmission" (FormContext record) Bool where setField :: Bool -> FormContext record -> FormContext record
setField Bool
value FormContext record
record = FormContext record
record { disableJavascriptSubmission = value }
instance SetField "customFormAttributes" (FormContext record) [(Text, Text)] where setField :: [(Text, Text)] -> FormContext record -> FormContext record
setField [(Text, Text)]
value FormContext record
record = FormContext record
record { customFormAttributes = value }
data InputType
= TextInput
| NumberInput
| UrlInput
| CheckboxInput
| ColorInput
| EmailInput
| HiddenInput
| TextareaInput
| DateInput
| DateTimeInput
| PasswordInput
| SelectInput { InputType -> [(Text, Text)]
options :: ![(Text, Text)] }
| RadioInput { options :: ![(Text, Text)] }
| FileInput
data BreadcrumbsView = BreadcrumbsView { BreadcrumbsView -> Html
breadcrumbItems :: !Blaze.Html }
data =
{ PaginationView -> CSSFramework
cssFramework :: !CSSFramework
, :: !Pagination
, PaginationView -> Int -> ByteString
pageUrl :: Int -> ByteString
, PaginationView -> Html
linkPrevious :: !Blaze.Html
, PaginationView -> Html
linkNext :: !Blaze.Html
, PaginationView -> Html
pageDotDotItems :: !Blaze.Html
, PaginationView -> Html
itemsPerPageSelector :: !Blaze.Html
}
data CSSFramework = CSSFramework
{ CSSFramework -> CSSFramework -> FlashMessage -> Html
styledFlashMessage :: CSSFramework -> FlashMessage -> Blaze.Html
, CSSFramework -> CSSFramework -> [FlashMessage] -> Html
styledFlashMessages :: CSSFramework -> [FlashMessage] -> Blaze.Html
, CSSFramework -> CSSFramework -> FormField -> Html
styledFormField :: CSSFramework -> FormField -> Blaze.Html
, CSSFramework -> CSSFramework -> Text -> FormField -> Html -> Html
styledTextFormField :: CSSFramework -> Text -> FormField -> Blaze.Html -> Blaze.Html
, CSSFramework -> CSSFramework -> FormField -> Html -> Html
styledTextareaFormField :: CSSFramework -> FormField -> Blaze.Html -> Blaze.Html
, CSSFramework -> CSSFramework -> FormField -> Html -> Html
styledCheckboxFormField :: CSSFramework -> FormField -> Blaze.Html -> Blaze.Html
, CSSFramework -> CSSFramework -> FormField -> Html -> Html
styledSelectFormField :: CSSFramework -> FormField -> Blaze.Html -> Blaze.Html
, CSSFramework -> CSSFramework -> FormField -> Html -> Html
styledRadioFormField :: CSSFramework -> FormField -> Blaze.Html -> Blaze.Html
, CSSFramework -> CSSFramework -> Text -> Html -> Html
styledFormGroup :: CSSFramework -> Text -> Blaze.Html -> Blaze.Html
, CSSFramework -> CSSFramework -> SubmitButton -> Html
styledSubmitButton :: CSSFramework -> SubmitButton -> Blaze.Html
, CSSFramework -> Text
styledSubmitButtonClass :: Text
, CSSFramework -> CSSFramework -> FormField -> Html
styledFormFieldHelp :: CSSFramework -> FormField -> Blaze.Html
, CSSFramework -> CSSFramework -> FormField -> Text
styledInputClass :: CSSFramework -> FormField -> Text
, CSSFramework -> CSSFramework -> FormField -> Text
styledInputInvalidClass :: CSSFramework -> FormField -> Text
, CSSFramework -> Text
styledFormGroupClass :: Text
, CSSFramework -> CSSFramework -> FormField -> Html
styledValidationResult :: CSSFramework -> FormField -> Blaze.Html
, CSSFramework -> Text
styledValidationResultClass :: Text
, :: CSSFramework -> PaginationView -> Blaze.Html
, :: CSSFramework -> Pagination -> ByteString -> Blaze.Html
, :: CSSFramework -> Pagination -> ByteString -> Blaze.Html
, :: CSSFramework -> Pagination -> ByteString -> Int -> Blaze.Html
, :: CSSFramework -> Pagination -> Blaze.Html
, :: CSSFramework -> Pagination -> (Int -> ByteString) -> Blaze.Html
, CSSFramework
-> CSSFramework -> [BreadcrumbItem] -> BreadcrumbsView -> Html
styledBreadcrumb :: CSSFramework -> [BreadcrumbItem] -> BreadcrumbsView -> Blaze.Html
, CSSFramework
-> CSSFramework
-> [BreadcrumbItem]
-> BreadcrumbItem
-> Bool
-> Html
styledBreadcrumbItem :: CSSFramework -> [BreadcrumbItem]-> BreadcrumbItem -> Bool -> Blaze.Html
}