{-# 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.ComponentVariant
-- 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.ComponentVariant where

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 style configuration of a unique variation of a main
-- component.
--
-- /See:/ 'newComponentVariant' smart constructor.
data ComponentVariant = ComponentVariant'
  { -- | The properties of the component variant that can be overriden when
    -- customizing an instance of the component. You can\'t specify @tags@ as a
    -- valid property for @overrides@.
    ComponentVariant -> Maybe (HashMap Text (HashMap Text Text))
overrides :: Prelude.Maybe (Prelude.HashMap Prelude.Text (Prelude.HashMap Prelude.Text Prelude.Text)),
    -- | The combination of variants that comprise this variant. You can\'t
    -- specify @tags@ as a valid property for @variantValues@.
    ComponentVariant -> Maybe (HashMap Text Text)
variantValues :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text)
  }
  deriving (ComponentVariant -> ComponentVariant -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ComponentVariant -> ComponentVariant -> Bool
$c/= :: ComponentVariant -> ComponentVariant -> Bool
== :: ComponentVariant -> ComponentVariant -> Bool
$c== :: ComponentVariant -> ComponentVariant -> Bool
Prelude.Eq, ReadPrec [ComponentVariant]
ReadPrec ComponentVariant
Int -> ReadS ComponentVariant
ReadS [ComponentVariant]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ComponentVariant]
$creadListPrec :: ReadPrec [ComponentVariant]
readPrec :: ReadPrec ComponentVariant
$creadPrec :: ReadPrec ComponentVariant
readList :: ReadS [ComponentVariant]
$creadList :: ReadS [ComponentVariant]
readsPrec :: Int -> ReadS ComponentVariant
$creadsPrec :: Int -> ReadS ComponentVariant
Prelude.Read, Int -> ComponentVariant -> ShowS
[ComponentVariant] -> ShowS
ComponentVariant -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ComponentVariant] -> ShowS
$cshowList :: [ComponentVariant] -> ShowS
show :: ComponentVariant -> String
$cshow :: ComponentVariant -> String
showsPrec :: Int -> ComponentVariant -> ShowS
$cshowsPrec :: Int -> ComponentVariant -> ShowS
Prelude.Show, forall x. Rep ComponentVariant x -> ComponentVariant
forall x. ComponentVariant -> Rep ComponentVariant x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ComponentVariant x -> ComponentVariant
$cfrom :: forall x. ComponentVariant -> Rep ComponentVariant x
Prelude.Generic)

-- |
-- Create a value of 'ComponentVariant' 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:
--
-- 'overrides', 'componentVariant_overrides' - The properties of the component variant that can be overriden when
-- customizing an instance of the component. You can\'t specify @tags@ as a
-- valid property for @overrides@.
--
-- 'variantValues', 'componentVariant_variantValues' - The combination of variants that comprise this variant. You can\'t
-- specify @tags@ as a valid property for @variantValues@.
newComponentVariant ::
  ComponentVariant
newComponentVariant :: ComponentVariant
newComponentVariant =
  ComponentVariant'
    { $sel:overrides:ComponentVariant' :: Maybe (HashMap Text (HashMap Text Text))
overrides = forall a. Maybe a
Prelude.Nothing,
      $sel:variantValues:ComponentVariant' :: Maybe (HashMap Text Text)
variantValues = forall a. Maybe a
Prelude.Nothing
    }

-- | The properties of the component variant that can be overriden when
-- customizing an instance of the component. You can\'t specify @tags@ as a
-- valid property for @overrides@.
componentVariant_overrides :: Lens.Lens' ComponentVariant (Prelude.Maybe (Prelude.HashMap Prelude.Text (Prelude.HashMap Prelude.Text Prelude.Text)))
componentVariant_overrides :: Lens' ComponentVariant (Maybe (HashMap Text (HashMap Text Text)))
componentVariant_overrides = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ComponentVariant' {Maybe (HashMap Text (HashMap Text Text))
overrides :: Maybe (HashMap Text (HashMap Text Text))
$sel:overrides:ComponentVariant' :: ComponentVariant -> Maybe (HashMap Text (HashMap Text Text))
overrides} -> Maybe (HashMap Text (HashMap Text Text))
overrides) (\s :: ComponentVariant
s@ComponentVariant' {} Maybe (HashMap Text (HashMap Text Text))
a -> ComponentVariant
s {$sel:overrides:ComponentVariant' :: Maybe (HashMap Text (HashMap Text Text))
overrides = Maybe (HashMap Text (HashMap Text Text))
a} :: ComponentVariant) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The combination of variants that comprise this variant. You can\'t
-- specify @tags@ as a valid property for @variantValues@.
componentVariant_variantValues :: Lens.Lens' ComponentVariant (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
componentVariant_variantValues :: Lens' ComponentVariant (Maybe (HashMap Text Text))
componentVariant_variantValues = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ComponentVariant' {Maybe (HashMap Text Text)
variantValues :: Maybe (HashMap Text Text)
$sel:variantValues:ComponentVariant' :: ComponentVariant -> Maybe (HashMap Text Text)
variantValues} -> Maybe (HashMap Text Text)
variantValues) (\s :: ComponentVariant
s@ComponentVariant' {} Maybe (HashMap Text Text)
a -> ComponentVariant
s {$sel:variantValues:ComponentVariant' :: Maybe (HashMap Text Text)
variantValues = Maybe (HashMap Text Text)
a} :: ComponentVariant) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Data.FromJSON ComponentVariant where
  parseJSON :: Value -> Parser ComponentVariant
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ComponentVariant"
      ( \Object
x ->
          Maybe (HashMap Text (HashMap Text Text))
-> Maybe (HashMap Text Text) -> ComponentVariant
ComponentVariant'
            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
"overrides" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
            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
"variantValues" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable ComponentVariant where
  hashWithSalt :: Int -> ComponentVariant -> Int
hashWithSalt Int
_salt ComponentVariant' {Maybe (HashMap Text Text)
Maybe (HashMap Text (HashMap Text Text))
variantValues :: Maybe (HashMap Text Text)
overrides :: Maybe (HashMap Text (HashMap Text Text))
$sel:variantValues:ComponentVariant' :: ComponentVariant -> Maybe (HashMap Text Text)
$sel:overrides:ComponentVariant' :: ComponentVariant -> Maybe (HashMap Text (HashMap Text Text))
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (HashMap Text (HashMap Text Text))
overrides
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (HashMap Text Text)
variantValues

instance Prelude.NFData ComponentVariant where
  rnf :: ComponentVariant -> ()
rnf ComponentVariant' {Maybe (HashMap Text Text)
Maybe (HashMap Text (HashMap Text Text))
variantValues :: Maybe (HashMap Text Text)
overrides :: Maybe (HashMap Text (HashMap Text Text))
$sel:variantValues:ComponentVariant' :: ComponentVariant -> Maybe (HashMap Text Text)
$sel:overrides:ComponentVariant' :: ComponentVariant -> Maybe (HashMap Text (HashMap Text Text))
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe (HashMap Text (HashMap Text Text))
overrides
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (HashMap Text Text)
variantValues

instance Data.ToJSON ComponentVariant where
  toJSON :: ComponentVariant -> Value
toJSON ComponentVariant' {Maybe (HashMap Text Text)
Maybe (HashMap Text (HashMap Text Text))
variantValues :: Maybe (HashMap Text Text)
overrides :: Maybe (HashMap Text (HashMap Text Text))
$sel:variantValues:ComponentVariant' :: ComponentVariant -> Maybe (HashMap Text Text)
$sel:overrides:ComponentVariant' :: ComponentVariant -> Maybe (HashMap Text (HashMap Text Text))
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"overrides" 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 (HashMap Text (HashMap Text Text))
overrides,
            (Key
"variantValues" 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 (HashMap Text Text)
variantValues
          ]
      )