{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.AmplifyUiBuilder.Types.SectionalElement
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.AmplifyUiBuilder.Types.SectionalElement where

import Amazonka.AmplifyUiBuilder.Types.FieldPosition
import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude

-- | Stores the configuration information for a visual helper element for a
-- form. A sectional element can be a header, a text block, or a divider.
-- These elements are static and not associated with any data.
--
-- /See:/ 'newSectionalElement' smart constructor.
data SectionalElement = SectionalElement'
  { -- | Specifies the size of the font for a @Heading@ sectional element. Valid
    -- values are @1 | 2 | 3 | 4 | 5 | 6@.
    SectionalElement -> Maybe Int
level :: Prelude.Maybe Prelude.Int,
    -- | Specifies the orientation for a @Divider@ sectional element. Valid
    -- values are @horizontal@ or @vertical@.
    SectionalElement -> Maybe Text
orientation :: Prelude.Maybe Prelude.Text,
    -- | Specifies the position of the text in a field for a @Text@ sectional
    -- element.
    SectionalElement -> Maybe FieldPosition
position :: Prelude.Maybe FieldPosition,
    -- | The text for a @Text@ sectional element.
    SectionalElement -> Maybe Text
text :: Prelude.Maybe Prelude.Text,
    -- | The type of sectional element. Valid values are @Heading@, @Text@, and
    -- @Divider@.
    SectionalElement -> Text
type' :: Prelude.Text
  }
  deriving (SectionalElement -> SectionalElement -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SectionalElement -> SectionalElement -> Bool
$c/= :: SectionalElement -> SectionalElement -> Bool
== :: SectionalElement -> SectionalElement -> Bool
$c== :: SectionalElement -> SectionalElement -> Bool
Prelude.Eq, ReadPrec [SectionalElement]
ReadPrec SectionalElement
Int -> ReadS SectionalElement
ReadS [SectionalElement]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SectionalElement]
$creadListPrec :: ReadPrec [SectionalElement]
readPrec :: ReadPrec SectionalElement
$creadPrec :: ReadPrec SectionalElement
readList :: ReadS [SectionalElement]
$creadList :: ReadS [SectionalElement]
readsPrec :: Int -> ReadS SectionalElement
$creadsPrec :: Int -> ReadS SectionalElement
Prelude.Read, Int -> SectionalElement -> ShowS
[SectionalElement] -> ShowS
SectionalElement -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SectionalElement] -> ShowS
$cshowList :: [SectionalElement] -> ShowS
show :: SectionalElement -> String
$cshow :: SectionalElement -> String
showsPrec :: Int -> SectionalElement -> ShowS
$cshowsPrec :: Int -> SectionalElement -> ShowS
Prelude.Show, forall x. Rep SectionalElement x -> SectionalElement
forall x. SectionalElement -> Rep SectionalElement x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SectionalElement x -> SectionalElement
$cfrom :: forall x. SectionalElement -> Rep SectionalElement x
Prelude.Generic)

-- |
-- Create a value of 'SectionalElement' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'level', 'sectionalElement_level' - Specifies the size of the font for a @Heading@ sectional element. Valid
-- values are @1 | 2 | 3 | 4 | 5 | 6@.
--
-- 'orientation', 'sectionalElement_orientation' - Specifies the orientation for a @Divider@ sectional element. Valid
-- values are @horizontal@ or @vertical@.
--
-- 'position', 'sectionalElement_position' - Specifies the position of the text in a field for a @Text@ sectional
-- element.
--
-- 'text', 'sectionalElement_text' - The text for a @Text@ sectional element.
--
-- 'type'', 'sectionalElement_type' - The type of sectional element. Valid values are @Heading@, @Text@, and
-- @Divider@.
newSectionalElement ::
  -- | 'type''
  Prelude.Text ->
  SectionalElement
newSectionalElement :: Text -> SectionalElement
newSectionalElement Text
pType_ =
  SectionalElement'
    { $sel:level:SectionalElement' :: Maybe Int
level = forall a. Maybe a
Prelude.Nothing,
      $sel:orientation:SectionalElement' :: Maybe Text
orientation = forall a. Maybe a
Prelude.Nothing,
      $sel:position:SectionalElement' :: Maybe FieldPosition
position = forall a. Maybe a
Prelude.Nothing,
      $sel:text:SectionalElement' :: Maybe Text
text = forall a. Maybe a
Prelude.Nothing,
      $sel:type':SectionalElement' :: Text
type' = Text
pType_
    }

-- | Specifies the size of the font for a @Heading@ sectional element. Valid
-- values are @1 | 2 | 3 | 4 | 5 | 6@.
sectionalElement_level :: Lens.Lens' SectionalElement (Prelude.Maybe Prelude.Int)
sectionalElement_level :: Lens' SectionalElement (Maybe Int)
sectionalElement_level = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SectionalElement' {Maybe Int
level :: Maybe Int
$sel:level:SectionalElement' :: SectionalElement -> Maybe Int
level} -> Maybe Int
level) (\s :: SectionalElement
s@SectionalElement' {} Maybe Int
a -> SectionalElement
s {$sel:level:SectionalElement' :: Maybe Int
level = Maybe Int
a} :: SectionalElement)

-- | Specifies the orientation for a @Divider@ sectional element. Valid
-- values are @horizontal@ or @vertical@.
sectionalElement_orientation :: Lens.Lens' SectionalElement (Prelude.Maybe Prelude.Text)
sectionalElement_orientation :: Lens' SectionalElement (Maybe Text)
sectionalElement_orientation = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SectionalElement' {Maybe Text
orientation :: Maybe Text
$sel:orientation:SectionalElement' :: SectionalElement -> Maybe Text
orientation} -> Maybe Text
orientation) (\s :: SectionalElement
s@SectionalElement' {} Maybe Text
a -> SectionalElement
s {$sel:orientation:SectionalElement' :: Maybe Text
orientation = Maybe Text
a} :: SectionalElement)

-- | Specifies the position of the text in a field for a @Text@ sectional
-- element.
sectionalElement_position :: Lens.Lens' SectionalElement (Prelude.Maybe FieldPosition)
sectionalElement_position :: Lens' SectionalElement (Maybe FieldPosition)
sectionalElement_position = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SectionalElement' {Maybe FieldPosition
position :: Maybe FieldPosition
$sel:position:SectionalElement' :: SectionalElement -> Maybe FieldPosition
position} -> Maybe FieldPosition
position) (\s :: SectionalElement
s@SectionalElement' {} Maybe FieldPosition
a -> SectionalElement
s {$sel:position:SectionalElement' :: Maybe FieldPosition
position = Maybe FieldPosition
a} :: SectionalElement)

-- | The text for a @Text@ sectional element.
sectionalElement_text :: Lens.Lens' SectionalElement (Prelude.Maybe Prelude.Text)
sectionalElement_text :: Lens' SectionalElement (Maybe Text)
sectionalElement_text = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SectionalElement' {Maybe Text
text :: Maybe Text
$sel:text:SectionalElement' :: SectionalElement -> Maybe Text
text} -> Maybe Text
text) (\s :: SectionalElement
s@SectionalElement' {} Maybe Text
a -> SectionalElement
s {$sel:text:SectionalElement' :: Maybe Text
text = Maybe Text
a} :: SectionalElement)

-- | The type of sectional element. Valid values are @Heading@, @Text@, and
-- @Divider@.
sectionalElement_type :: Lens.Lens' SectionalElement Prelude.Text
sectionalElement_type :: Lens' SectionalElement Text
sectionalElement_type = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SectionalElement' {Text
type' :: Text
$sel:type':SectionalElement' :: SectionalElement -> Text
type'} -> Text
type') (\s :: SectionalElement
s@SectionalElement' {} Text
a -> SectionalElement
s {$sel:type':SectionalElement' :: Text
type' = Text
a} :: SectionalElement)

instance Data.FromJSON SectionalElement where
  parseJSON :: Value -> Parser SectionalElement
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"SectionalElement"
      ( \Object
x ->
          Maybe Int
-> Maybe Text
-> Maybe FieldPosition
-> Maybe Text
-> Text
-> SectionalElement
SectionalElement'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"level")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"orientation")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"position")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"text")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"type")
      )

instance Prelude.Hashable SectionalElement where
  hashWithSalt :: Int -> SectionalElement -> Int
hashWithSalt Int
_salt SectionalElement' {Maybe Int
Maybe Text
Maybe FieldPosition
Text
type' :: Text
text :: Maybe Text
position :: Maybe FieldPosition
orientation :: Maybe Text
level :: Maybe Int
$sel:type':SectionalElement' :: SectionalElement -> Text
$sel:text:SectionalElement' :: SectionalElement -> Maybe Text
$sel:position:SectionalElement' :: SectionalElement -> Maybe FieldPosition
$sel:orientation:SectionalElement' :: SectionalElement -> Maybe Text
$sel:level:SectionalElement' :: SectionalElement -> Maybe Int
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
level
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
orientation
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe FieldPosition
position
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
text
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
type'

instance Prelude.NFData SectionalElement where
  rnf :: SectionalElement -> ()
rnf SectionalElement' {Maybe Int
Maybe Text
Maybe FieldPosition
Text
type' :: Text
text :: Maybe Text
position :: Maybe FieldPosition
orientation :: Maybe Text
level :: Maybe Int
$sel:type':SectionalElement' :: SectionalElement -> Text
$sel:text:SectionalElement' :: SectionalElement -> Maybe Text
$sel:position:SectionalElement' :: SectionalElement -> Maybe FieldPosition
$sel:orientation:SectionalElement' :: SectionalElement -> Maybe Text
$sel:level:SectionalElement' :: SectionalElement -> Maybe Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
level
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
orientation
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe FieldPosition
position
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
text
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
type'

instance Data.ToJSON SectionalElement where
  toJSON :: SectionalElement -> Value
toJSON SectionalElement' {Maybe Int
Maybe Text
Maybe FieldPosition
Text
type' :: Text
text :: Maybe Text
position :: Maybe FieldPosition
orientation :: Maybe Text
level :: Maybe Int
$sel:type':SectionalElement' :: SectionalElement -> Text
$sel:text:SectionalElement' :: SectionalElement -> Maybe Text
$sel:position:SectionalElement' :: SectionalElement -> Maybe FieldPosition
$sel:orientation:SectionalElement' :: SectionalElement -> Maybe Text
$sel:level:SectionalElement' :: SectionalElement -> Maybe Int
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"level" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Int
level,
            (Key
"orientation" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
orientation,
            (Key
"position" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe FieldPosition
position,
            (Key
"text" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
text,
            forall a. a -> Maybe a
Prelude.Just (Key
"type" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
type')
          ]
      )