<commit_before>{-# LANGUAGE OverloadedStrings #-}
module TodoComponents where

import Data.Typeable (Typeable)
import Data.Maybe (fromMaybe)

import React.Flux

import qualified React.Flux.Rn.Components as Rn
import qualified React.Flux.Rn.Events as RnE
import qualified React.Flux.Rn.Style as RnS


data TextInputArgs = TextInputArgs {
      tiaPlaceholder :: String
    , tiaOnSave :: String -> [SomeStoreAction]
    , tiaOnCancel :: [SomeStoreAction]
    , tiaValue :: Maybe String
} deriving (Typeable)

todoTextInput :: [PropertyOrHandler (StatefulViewEventHandler String)] -> String -> ReactView TextInputArgs
todoTextInput styles state = defineStatefulView "todo text input" state $ \curText args ->
    Rn.textInput
        [ "placeholder" @= tiaPlaceholder args
        , "value"       @= curText
        , "autoFocus"   @= True
        , "blurOnSubmit" @= True
        , RnS.style $ [ RnS.flex 1
                      , RnS.height 45
                      , RnS.margin 8
                      , RnS.marginLeft 0
                      , RnS.fontFamily "HelveticaNeue"
                      , RnS.fontSize 22
                      , RnS.fontWeight RnS.W300
                      , RnS.color "#4d4d4d"
                      ] ++ styles

        , RnE.onSubmitEditing $ \_ -> (tiaOnSave args $ state, Just "")
        , RnE.onChangeText $ \txt -> \_ -> ([], Just txt)
        , RnE.onBlur $ \_ -> (tiaOnCancel args, tiaValue args)
        ] mempty

todoTextInput_ :: [PropertyOrHandler (StatefulViewEventHandler String)] -> TextInputArgs -> ReactElementM eventHandler ()
todoTextInput_ styles args = view (todoTextInput styles (fromMaybe "" $ tiaValue args)) args mempty<commit_msg>whoops, a bug!<commit_after>{-# LANGUAGE OverloadedStrings #-}
module TodoComponents where

import Data.Typeable (Typeable)
import Data.Maybe (fromMaybe)

import React.Flux

import qualified React.Flux.Rn.Components as Rn
import qualified React.Flux.Rn.Events as RnE
import qualified React.Flux.Rn.Style as RnS


data TextInputArgs = TextInputArgs {
      tiaPlaceholder :: String
    , tiaOnSave :: String -> [SomeStoreAction]
    , tiaOnCancel :: [SomeStoreAction]
    , tiaValue :: Maybe String
} deriving (Typeable)

todoTextInput :: [PropertyOrHandler (StatefulViewEventHandler String)] -> String -> ReactView TextInputArgs
todoTextInput styles state = defineStatefulView "todo text input" state $ \curText args ->
    Rn.textInput
        [ "placeholder" @= tiaPlaceholder args
        , "value"       @= curText
        , "autoFocus"   @= True
        , "blurOnSubmit" @= True
        , RnS.style $ [ RnS.flex 1
                      , RnS.height 45
                      , RnS.margin 8
                      , RnS.marginLeft 0
                      , RnS.fontFamily "HelveticaNeue"
                      , RnS.fontSize 22
                      , RnS.fontWeight RnS.W300
                      , RnS.color "#4d4d4d"
                      ] ++ styles

        , RnE.onSubmitEditing $ \txt -> (tiaOnSave args $ txt, Just "")
        , RnE.onChangeText $ \txt -> \_ -> ([], Just txt)
        , RnE.onBlur $ \_ -> (tiaOnCancel args, tiaValue args)
        ] mempty

todoTextInput_ :: [PropertyOrHandler (StatefulViewEventHandler String)] -> TextInputArgs -> ReactElementM eventHandler ()
todoTextInput_ styles args = view (todoTextInput styles (fromMaybe "" $ tiaValue args)) args mempty
{'fraction_non_alphanumeric': 0.10068107787977496, 'fraction_numerical': 0.007699141249629849, 'mean_word_length': 2.2891918208373903, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7620933', 'n_tokens_mistral': 1072, 'n_tokens_neox': 1032, 'n_words': 246}