{-# 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.FormButton
-- 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.FormButton 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

-- | Describes the configuration for a button UI element that is a part of a
-- form.
--
-- /See:/ 'newFormButton' smart constructor.
data FormButton = FormButton'
  { -- | Describes the button\'s properties.
    FormButton -> Maybe Text
children :: Prelude.Maybe Prelude.Text,
    -- | Specifies whether the button is visible on the form.
    FormButton -> Maybe Bool
excluded :: Prelude.Maybe Prelude.Bool,
    -- | The position of the button.
    FormButton -> Maybe FieldPosition
position :: Prelude.Maybe FieldPosition
  }
  deriving (FormButton -> FormButton -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FormButton -> FormButton -> Bool
$c/= :: FormButton -> FormButton -> Bool
== :: FormButton -> FormButton -> Bool
$c== :: FormButton -> FormButton -> Bool
Prelude.Eq, ReadPrec [FormButton]
ReadPrec FormButton
Int -> ReadS FormButton
ReadS [FormButton]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [FormButton]
$creadListPrec :: ReadPrec [FormButton]
readPrec :: ReadPrec FormButton
$creadPrec :: ReadPrec FormButton
readList :: ReadS [FormButton]
$creadList :: ReadS [FormButton]
readsPrec :: Int -> ReadS FormButton
$creadsPrec :: Int -> ReadS FormButton
Prelude.Read, Int -> FormButton -> ShowS
[FormButton] -> ShowS
FormButton -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [FormButton] -> ShowS
$cshowList :: [FormButton] -> ShowS
show :: FormButton -> String
$cshow :: FormButton -> String
showsPrec :: Int -> FormButton -> ShowS
$cshowsPrec :: Int -> FormButton -> ShowS
Prelude.Show, forall x. Rep FormButton x -> FormButton
forall x. FormButton -> Rep FormButton x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep FormButton x -> FormButton
$cfrom :: forall x. FormButton -> Rep FormButton x
Prelude.Generic)

-- |
-- Create a value of 'FormButton' 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:
--
-- 'children', 'formButton_children' - Describes the button\'s properties.
--
-- 'excluded', 'formButton_excluded' - Specifies whether the button is visible on the form.
--
-- 'position', 'formButton_position' - The position of the button.
newFormButton ::
  FormButton
newFormButton :: FormButton
newFormButton =
  FormButton'
    { $sel:children:FormButton' :: Maybe Text
children = forall a. Maybe a
Prelude.Nothing,
      $sel:excluded:FormButton' :: Maybe Bool
excluded = forall a. Maybe a
Prelude.Nothing,
      $sel:position:FormButton' :: Maybe FieldPosition
position = forall a. Maybe a
Prelude.Nothing
    }

-- | Describes the button\'s properties.
formButton_children :: Lens.Lens' FormButton (Prelude.Maybe Prelude.Text)
formButton_children :: Lens' FormButton (Maybe Text)
formButton_children = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FormButton' {Maybe Text
children :: Maybe Text
$sel:children:FormButton' :: FormButton -> Maybe Text
children} -> Maybe Text
children) (\s :: FormButton
s@FormButton' {} Maybe Text
a -> FormButton
s {$sel:children:FormButton' :: Maybe Text
children = Maybe Text
a} :: FormButton)

-- | Specifies whether the button is visible on the form.
formButton_excluded :: Lens.Lens' FormButton (Prelude.Maybe Prelude.Bool)
formButton_excluded :: Lens' FormButton (Maybe Bool)
formButton_excluded = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FormButton' {Maybe Bool
excluded :: Maybe Bool
$sel:excluded:FormButton' :: FormButton -> Maybe Bool
excluded} -> Maybe Bool
excluded) (\s :: FormButton
s@FormButton' {} Maybe Bool
a -> FormButton
s {$sel:excluded:FormButton' :: Maybe Bool
excluded = Maybe Bool
a} :: FormButton)

-- | The position of the button.
formButton_position :: Lens.Lens' FormButton (Prelude.Maybe FieldPosition)
formButton_position :: Lens' FormButton (Maybe FieldPosition)
formButton_position = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FormButton' {Maybe FieldPosition
position :: Maybe FieldPosition
$sel:position:FormButton' :: FormButton -> Maybe FieldPosition
position} -> Maybe FieldPosition
position) (\s :: FormButton
s@FormButton' {} Maybe FieldPosition
a -> FormButton
s {$sel:position:FormButton' :: Maybe FieldPosition
position = Maybe FieldPosition
a} :: FormButton)

instance Data.FromJSON FormButton where
  parseJSON :: Value -> Parser FormButton
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"FormButton"
      ( \Object
x ->
          Maybe Text -> Maybe Bool -> Maybe FieldPosition -> FormButton
FormButton'
            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
"children")
            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
"excluded")
            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")
      )

instance Prelude.Hashable FormButton where
  hashWithSalt :: Int -> FormButton -> Int
hashWithSalt Int
_salt FormButton' {Maybe Bool
Maybe Text
Maybe FieldPosition
position :: Maybe FieldPosition
excluded :: Maybe Bool
children :: Maybe Text
$sel:position:FormButton' :: FormButton -> Maybe FieldPosition
$sel:excluded:FormButton' :: FormButton -> Maybe Bool
$sel:children:FormButton' :: FormButton -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
children
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
excluded
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe FieldPosition
position

instance Prelude.NFData FormButton where
  rnf :: FormButton -> ()
rnf FormButton' {Maybe Bool
Maybe Text
Maybe FieldPosition
position :: Maybe FieldPosition
excluded :: Maybe Bool
children :: Maybe Text
$sel:position:FormButton' :: FormButton -> Maybe FieldPosition
$sel:excluded:FormButton' :: FormButton -> Maybe Bool
$sel:children:FormButton' :: FormButton -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
children
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
excluded
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe FieldPosition
position

instance Data.ToJSON FormButton where
  toJSON :: FormButton -> Value
toJSON FormButton' {Maybe Bool
Maybe Text
Maybe FieldPosition
position :: Maybe FieldPosition
excluded :: Maybe Bool
children :: Maybe Text
$sel:position:FormButton' :: FormButton -> Maybe FieldPosition
$sel:excluded:FormButton' :: FormButton -> Maybe Bool
$sel:children:FormButton' :: FormButton -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"children" 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
children,
            (Key
"excluded" 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 Bool
excluded,
            (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
          ]
      )