-----------------------------------------------------------------------------
{-# LANGUAGE OverloadedStrings #-}
-----------------------------------------------------------------------------
-- |
-- Module      :  Miso.Native.X.Element.Input.Property
-- Copyright   :  (C) 2016-2026 David M. Johnson
-- License     :  BSD3-style (see the file LICENSE)
-- Maintainer  :  David M. Johnson <code@dmj.io>
-- Stability   :  experimental
-- Portability :  non-portable
----------------------------------------------------------------------------
module Miso.Native.X.Element.Input.Property
  ( -- *** Property
    androidFullscreenMode_
  , confirmType_
  , disabled_
  , inputFilter_
  , iosAutoCorrect_
  , iosSpellCheck_
  , maxlength_
  , placeholder_
  , readonly_
  , showSoftInputOnFocus_
  , type_
    -- *** Types
  , InputType (..)
  , ConfirmType (..)
  ) where
-----------------------------------------------------------------------------
import           Miso.JSON (ToJSON(..))
import           Miso.String (MisoString)
import           Miso.Types (Attribute)
import           Miso.Property
-----------------------------------------------------------------------------
-- | The content type of an \<input\>, used by 'type_'.
data InputType
  = InputNumber
  | InputText
  | InputDigit
  | InputPassword
  | InputTel
  | InputEmail
  deriving (Int -> InputType -> ShowS
[InputType] -> ShowS
InputType -> String
(Int -> InputType -> ShowS)
-> (InputType -> String)
-> ([InputType] -> ShowS)
-> Show InputType
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> InputType -> ShowS
showsPrec :: Int -> InputType -> ShowS
$cshow :: InputType -> String
show :: InputType -> String
$cshowList :: [InputType] -> ShowS
showList :: [InputType] -> ShowS
Show, InputType -> InputType -> Bool
(InputType -> InputType -> Bool)
-> (InputType -> InputType -> Bool) -> Eq InputType
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: InputType -> InputType -> Bool
== :: InputType -> InputType -> Bool
$c/= :: InputType -> InputType -> Bool
/= :: InputType -> InputType -> Bool
Eq)
-----------------------------------------------------------------------------
instance ToJSON InputType where
  toJSON :: InputType -> Value
toJSON InputType
InputNumber   = Value
"number"
  toJSON InputType
InputText     = Value
"text"
  toJSON InputType
InputDigit    = Value
"digit"
  toJSON InputType
InputPassword = Value
"password"
  toJSON InputType
InputTel      = Value
"tel"
  toJSON InputType
InputEmail    = Value
"email"
-----------------------------------------------------------------------------
-- | The confirm button type of an \<input\>, used by 'confirmType_'.
data ConfirmType
  = ConfirmSearch
  | ConfirmSend
  | ConfirmGo
  | ConfirmDone
  | ConfirmNext
  deriving (Int -> ConfirmType -> ShowS
[ConfirmType] -> ShowS
ConfirmType -> String
(Int -> ConfirmType -> ShowS)
-> (ConfirmType -> String)
-> ([ConfirmType] -> ShowS)
-> Show ConfirmType
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ConfirmType -> ShowS
showsPrec :: Int -> ConfirmType -> ShowS
$cshow :: ConfirmType -> String
show :: ConfirmType -> String
$cshowList :: [ConfirmType] -> ShowS
showList :: [ConfirmType] -> ShowS
Show, ConfirmType -> ConfirmType -> Bool
(ConfirmType -> ConfirmType -> Bool)
-> (ConfirmType -> ConfirmType -> Bool) -> Eq ConfirmType
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ConfirmType -> ConfirmType -> Bool
== :: ConfirmType -> ConfirmType -> Bool
$c/= :: ConfirmType -> ConfirmType -> Bool
/= :: ConfirmType -> ConfirmType -> Bool
Eq)
-----------------------------------------------------------------------------
instance ToJSON ConfirmType where
  toJSON :: ConfirmType -> Value
toJSON ConfirmType
ConfirmSearch = Value
"search"
  toJSON ConfirmType
ConfirmSend   = Value
"send"
  toJSON ConfirmType
ConfirmGo     = Value
"go"
  toJSON ConfirmType
ConfirmDone   = Value
"done"
  toJSON ConfirmType
ConfirmNext   = Value
"next"
-----------------------------------------------------------------------------
-- | https://lynxjs.org/api/elements/built-in/input.html#android-fullscreen-mode
--
-- Whether to enter the full-screen input mode when in landscape screen.
--
-- > androidFullscreenMode_ False
--
-- Default Value: 'True'
--
androidFullscreenMode_ :: Bool -> Attribute model action
androidFullscreenMode_ :: forall model action. Bool -> Attribute model action
androidFullscreenMode_ = MisoString -> Bool -> Attribute model action
forall model action. MisoString -> Bool -> Attribute model action
boolProp MisoString
"android-fullscreen-mode"
-----------------------------------------------------------------------------
-- | https://lynxjs.org/api/elements/built-in/input.html#confirm-type
--
-- Specifies the confirm button type.
--
-- > confirmType_ ConfirmDone
--
-- Default Value: 'ConfirmSend'
--
confirmType_ :: ConfirmType -> Attribute model action
confirmType_ :: forall model action. ConfirmType -> Attribute model action
confirmType_ = MisoString -> ConfirmType -> Attribute model action
forall a model action.
ToJSON a =>
MisoString -> a -> Attribute model action
prop MisoString
"confirm-type"
-----------------------------------------------------------------------------
-- | https://lynxjs.org/api/elements/built-in/input.html#disabled
--
-- Controls whether interaction is enabled.
--
-- > disabled_ True
--
-- Default Value: 'False'
--
disabled_ :: Bool -> Attribute model action
disabled_ :: forall model action. Bool -> Attribute model action
disabled_ = MisoString -> Bool -> Attribute model action
forall model action. MisoString -> Bool -> Attribute model action
boolProp MisoString
"disabled"
-----------------------------------------------------------------------------
-- | https://lynxjs.org/api/elements/built-in/input.html#input-filter
--
-- Filters the input content in the form of a regular expression.
--
-- > inputFilter_ "[0-9]"
--
inputFilter_ :: MisoString -> Attribute model action
inputFilter_ :: forall model action. MisoString -> Attribute model action
inputFilter_ = MisoString -> MisoString -> Attribute model action
forall model action.
MisoString -> MisoString -> Attribute model action
textProp MisoString
"input-filter"
-----------------------------------------------------------------------------
-- | https://lynxjs.org/api/elements/built-in/input.html#ios-auto-correct
--
-- Enables auto-correction on iOS.
--
-- > iosAutoCorrect_ False
--
-- Default Value: 'True'
--
iosAutoCorrect_ :: Bool -> Attribute model action
iosAutoCorrect_ :: forall model action. Bool -> Attribute model action
iosAutoCorrect_ = MisoString -> Bool -> Attribute model action
forall model action. MisoString -> Bool -> Attribute model action
boolProp MisoString
"ios-auto-correct"
-----------------------------------------------------------------------------
-- | https://lynxjs.org/api/elements/built-in/input.html#ios-spell-check
--
-- Enables spell-checking on iOS.
--
-- > iosSpellCheck_ False
--
-- Default Value: 'True'
--
iosSpellCheck_ :: Bool -> Attribute model action
iosSpellCheck_ :: forall model action. Bool -> Attribute model action
iosSpellCheck_ = MisoString -> Bool -> Attribute model action
forall model action. MisoString -> Bool -> Attribute model action
boolProp MisoString
"ios-spell-check"
-----------------------------------------------------------------------------
-- | https://lynxjs.org/api/elements/built-in/input.html#maxlength
--
-- Maximum input length allowed.
--
-- > maxlength_ 32
--
-- Default Value: 140
--
maxlength_ :: Int -> Attribute model action
maxlength_ :: forall model action. Int -> Attribute model action
maxlength_ = MisoString -> Int -> Attribute model action
forall model action. MisoString -> Int -> Attribute model action
intProp MisoString
"maxlength"
-----------------------------------------------------------------------------
-- | https://lynxjs.org/api/elements/built-in/input.html#placeholder
--
-- Placeholder text display.
--
-- > placeholder_ "Enter your name"
--
placeholder_ :: MisoString -> Attribute model action
placeholder_ :: forall model action. MisoString -> Attribute model action
placeholder_ = MisoString -> MisoString -> Attribute model action
forall model action.
MisoString -> MisoString -> Attribute model action
textProp MisoString
"placeholder"
-----------------------------------------------------------------------------
-- | https://lynxjs.org/api/elements/built-in/input.html#readonly
--
-- Makes the input read-only.
--
-- > readonly_ True
--
-- Default Value: 'False'
--
readonly_ :: Bool -> Attribute model action
readonly_ :: forall model action. Bool -> Attribute model action
readonly_ = MisoString -> Bool -> Attribute model action
forall model action. MisoString -> Bool -> Attribute model action
boolProp MisoString
"readonly"
-----------------------------------------------------------------------------
-- | https://lynxjs.org/api/elements/built-in/input.html#show-soft-input-on-focus
--
-- Show soft input keyboard while focused.
--
-- > showSoftInputOnFocus_ False
--
-- Default Value: 'True'
--
showSoftInputOnFocus_ :: Bool -> Attribute model action
showSoftInputOnFocus_ :: forall model action. Bool -> Attribute model action
showSoftInputOnFocus_ = MisoString -> Bool -> Attribute model action
forall model action. MisoString -> Bool -> Attribute model action
boolProp MisoString
"show-soft-input-on-focus"
-----------------------------------------------------------------------------
-- | https://lynxjs.org/api/elements/built-in/input.html#type
--
-- Input content type.
--
-- > type_ InputPassword
--
-- Default Value: 'InputText'
--
type_ :: InputType -> Attribute model action
type_ :: forall model action. InputType -> Attribute model action
type_ = MisoString -> InputType -> Attribute model action
forall a model action.
ToJSON a =>
MisoString -> a -> Attribute model action
prop MisoString
"type"
-----------------------------------------------------------------------------