@@ -669,304 +669,150 @@ type alias Text msg =
673− = Padding Int Int Int Int
676−inheritablePlaceholderAttributes attr =
678− Internal.StyleClass _ (Internal.PaddingStyle _ _ _ _ _) ->
681− Internal.StyleClass _ (Internal.BorderWidth _ _ _ _ _) ->
684− Internal.StyleClass _ (Internal.Transform _) ->
696− attribute::width/height fill
697− attribtue::alignment
699− attribute::fontsize/family/lineheight
701− attribute::nearby(placeholder)
702− attribute::width/height fill
710− special height for height-content
712− attribute::lineHeight
717textHelper : TextInput -> List (Attribute msg) -> Text msg -> Element msg
673textHelper : TextInput -> List (Attribute msg) -> Text msg -> Element msg
718textHelper textInput attrs textOptions =
674textHelper textInput attrs textOptions =
720− attributes =
676+ withDefaults =
721 defaultTextBoxStyle ++ attrs
677 defaultTextBoxStyle ++ attrs
723− behavior =
679+ redistributed =
724− [ Internal.Attr (Html.Events.onInput textOptions.onChange) ]
680+ redistribute withDefaults
727− List.filter inheritablePlaceholderAttributes attributes
729− noNearbys =
682+ moveUpToCompensateForPadding =
730− List.filter (not << forNearby) attributes
683+ calcMoveToCompensateForPadding withDefaults
732− forNearby attr =
685+ onlySpacing attr =
733 case attr of
686 case attr of
734− Internal.Nearby _ _ ->
687+ Internal.StyleClass _ (Internal.SpacingStyle _ _ _) ->
740− ( inputNode, inputAttrs, inputChildren ) =
693+ bottomPadding attr =
695+ Internal.StyleClass cls (Internal.PaddingStyle pad t r b l) ->
697+ (Element.paddingEach
741 case textInput.type_ of
709 case textInput.type_ of
742 TextInputNode inputType ->
710 TextInputNode inputType ->
744− , [ Internal.Attr (Html.Attributes.type_ inputType)
745− , value textOptions.text
746− , spellcheck textInput.spellchecked
747− , Internal.htmlClass classes.inputText
748− , case textInput.autofill of
750− Internal.NoAttribute
759 TextArea ->
713 TextArea ->
761− { maybePadding, heightContent, maybeSpacing, adjustedAttributes, maybeBorder } =
762− (value textOptions.text :: attributes)
766− Internal.Describe _ ->
769− Internal.Height len ->
770− case found.heightContent of
773− | heightContent = Just (Internal.isContent len)
774− , adjustedAttributes = attr :: found.adjustedAttributes
780− Internal.StyleClass _ (Internal.BorderWidth _ t r b l) ->
781− case found.maybeBorder of
784− | maybeBorder = Just (Padding t r b l)
785− , adjustedAttributes = attr :: found.adjustedAttributes
791− Internal.StyleClass _ (Internal.PaddingStyle _ t r b l) ->
792− case found.maybePadding of
795− | maybePadding = Just (Padding t r b l)
797− -- Skip storing padding because it's being customized later
798− , adjustedAttributes = found.adjustedAttributes
804− Internal.StyleClass _ (Internal.SpacingStyle _ x y) ->
805− case found.maybeSpacing of
808− | maybeSpacing = Just y
809− , adjustedAttributes = attr :: found.adjustedAttributes
816− { found | adjustedAttributes = attr :: found.adjustedAttributes }
818− { maybePadding = Nothing
819− , heightContent = Nothing
820− , maybeBorder = Nothing
821− , maybeSpacing = Nothing
822− , adjustedAttributes = []
825− -- NOTE: This is where default text spacing is set
827− Maybe.withDefault 5 maybeSpacing
714+ Maybe.withDefault False redistributed.heightContent
830− , [ spellcheck textInput.spellchecked
831− , Internal.htmlClass classes.inputMultiline
832− , Maybe.map autofill textInput.autofill
833− |> Maybe.withDefault Internal.NoAttribute
834− , case maybePadding of
836− Internal.NoAttribute
838− Just (Padding t r b l) ->
840− { top = max 0 (t - (spacing // 2))
841− , bottom = max 0 (b - (spacing // 2))
845− , case heightContent of
847− Internal.NoAttribute
850− textHeightContent textOptions.text spacing maybePadding maybeBorder
853− Internal.NoAttribute
855− ++ adjustedAttributes
856− , [ Internal.unstyled (Html.text textOptions.text) ]
859− heightFillFromChild =
860− Internal.get attributes <|
863− Internal.Height (Internal.Fill _) ->
869− attributesFromChild =
870− Internal.get attributes <|
873− Internal.Width (Internal.Fill _) ->
876− Internal.Height (Internal.Fill _) ->
879− Internal.AlignX _ ->
882− Internal.AlignY _ ->
885− Internal.StyleClass _ (Internal.SpacingStyle _ _ _) ->
888− Internal.StyleClass _ (Internal.FontSize _) ->
891− Internal.StyleClass _ (Internal.FontFamily _ _) ->
898− Internal.get attributes <|
901− Internal.Nearby _ _ ->
908− Internal.get attributes <|
911− Internal.StyleClass _ (Internal.PaddingStyle _ _ _ _ _) ->
917 inputElement =
716 inputElement =
918 Internal.element
717 Internal.element
919 Internal.asEl
718 Internal.asEl
920− Internal.div
719+ (case textInput.type_ of
921− (Element.width Element.fill
720+ TextInputNode inputType ->
922− :: List.concat
721+ Internal.NodeName "input"
924− , heightFillFromChild
723+ TextArea ->
925− , case textOptions.placeholder of
724+ Internal.NodeName "textarea"
929− Just (Placeholder placeholderAttrs placeholderEl) ->
934− ++ [ Font.color charcoal
935− , Internal.htmlClass (classes.noTextSelection ++ " " ++ classes.passPointerEvents)
936− , Border.color (Element.rgba 0 0 0 0)
937− , Background.color (Element.rgba 0 0 0 0)
938− , Element.height Element.fill
939− , Element.width Element.fill
941− (if textOptions.text == "" then
726+ ([ value textOptions.text
942− 1
727+ , Internal.Attr (Html.Events.onInput textOptions.onChange)
943−
728+ , Internal.htmlClass "focusable"
944− else
729+ , hiddenLabelAttribute textOptions.label
945− 0
730+ , spellcheck textInput.spellchecked
946− )
731+ , Maybe.map autofill textInput.autofill
732+ |> Maybe.withDefault Internal.NoAttribute
948− ++ placeholderAttrs
734+ ++ (case textInput.type_ of
949− )
735+ TextInputNode inputType ->
950− placeholderEl
736+ [ Internal.Attr (Html.Attributes.type_ inputType)
951− )
737+ , Internal.htmlClass classes.inputText
742+ , Element.height Element.fill
743+ , Internal.htmlClass classes.inputMultiline
745+ , moveUpToCompensateForPadding
748+ ++ redistributed.input
955− (Internal.Unkeyed
750+ (Internal.Unkeyed [])
753+ -- if heightContent then
754+ case textInput.type_ of
756+ -- textarea with height-content means that
757+ -- the input element is rendered `inFront` and transparently.
758+ -- Then the input text is rendered as the actual element.
956− [ Internal.element
759+ Internal.element
957 Internal.asEl
760 Internal.asEl
958− (Internal.NodeName inputNode)
761+ Internal.div
762+ ([ Element.width Element.fill
763+ , Element.height (Element.px 100)
764+ , Element.scrollbarY
766+ ++ redistributed.parent
770+ Internal.asParagraph
772+ (Element.width Element.fill
773+ :: Element.height Element.fill
774+ :: Element.inFront inputElement
775+ :: Internal.htmlClass classes.inputMultiline
959− (List.concat
776+ :: List.concat
960− [ [ focusDefault attrs
777+ [ if heightContent then
961− , hiddenLabelAttribute textOptions.label
778+ List.filter onlySpacing redistributed.parent
779+ -- redistributed.parent
782+ List.filter onlySpacing redistributed.parent
783+ ++ List.filterMap bottomPadding redistributed.parent
784+ , case textOptions.placeholder of
964− , behavior
788+ Just place ->
789+ [ renderPlaceholder place redistributed.cover (textOptions.text == "")
794+ [ Internal.unstyled (Html.text textOptions.text) ]
799+ TextInputNode inputType ->
803+ (Element.width Element.fill
805+ [ redistributed.parent
806+ , case textOptions.placeholder of
811+ [ renderPlaceholder place redistributed.cover (textOptions.text == "")
967− (Internal.Unkeyed inputChildren)
815+ (Internal.Unkeyed [ inputElement ])
971 applyLabel
817 applyLabel
972 (Internal.Class Flag.cursor classes.cursorText
818 (Internal.Class Flag.cursor classes.cursorText
@@ -978,45 +824,201 @@ textHelper textInput attrs textOptions =
980 :: Region.announce
826 :: Region.announce
981− :: attributesFromChild
827+ :: redistributed.fullParent
983 textOptions.label
829 textOptions.label
984− inputElement
830+ wrappedInput
833+renderPlaceholder (Placeholder placeholderAttrs placeholderEl) forPlaceholder on =
838+ ++ [ Font.color charcoal
839+ , Internal.htmlClass (classes.noTextSelection ++ " " ++ classes.passPointerEvents)
840+ , Border.color (Element.rgba 0 0 0 0)
841+ , Background.color (Element.rgba 0 0 0 0)
842+ , Element.height Element.fill
843+ , Element.width Element.fill
987−textHeightContent textValue spacing maybePadding maybeBorder =
858+{-| Because textareas are now shadowed, where they're rendered twice,
859+we to move the literal text area up because spacing is based on line height.
861+calcMoveToCompensateForPadding : List (Attribute msg) -> Attribute msg
862+calcMoveToCompensateForPadding attrs =
989− newlineCount =
864+ gatherSpacing attr found =
990− String.lines textValue
865+ case attr of
991− |> List.length
866+ Internal.StyleClass _ (Internal.SpacingStyle _ x y) ->
992− |> (\x ->
867+ case found of
993− if x < 1 then
868+ Nothing ->
1000− topBottom (Padding t _ b _) =
874+ _ ->
877+ case List.foldr gatherSpacing Nothing attrs of
879+ Internal.NoAttribute
1003− additionalSpacing =
881+ Just vSpace ->
1004− ((newlineCount - 1) * spacing)
882+ Element.moveUp (toFloat vSpace / 2)
1005− + Maybe.withDefault 0 (Maybe.map topBottom maybePadding)
1006− + Maybe.withDefault 0 (Maybe.map topBottom maybeBorder)
1008− heightValue count =
884+
1009− "calc("
885+{-| Given the list of attributes provided to `Input.multiline` or `Input.text`,
1010− ++ String.fromInt count
886+
1011− ++ "em + "
887+redistribute them to the parent, the input, or the cover.
1012− ++ String.fromInt additionalSpacing
888+
1013− ++ "px) !important"
889+ - fullParent -> Wrapper around label and input
1014− in
890+ - parent -> wrapper around input
891+ - cover -> things like placeholders or text areas which are layered on top of input.
892+ - input -> actual input element
896+ List (Attribute msg)
898+ { parent : List (Attribute msg)
899+ , fullParent : List (Attribute msg)
900+ , input : List (Attribute msg)
901+ , cover : List (Attribute msg)
902+ , heightContent : Maybe Bool
905+ List.foldl redistributeOver { fullParent = [], parent = [], input = [], cover = [], heightContent = Nothing } attrs
907+ { parent = List.reverse redist.parent
908+ , fullParent = List.reverse redist.fullParent
909+ , input = List.reverse redist.input
910+ , cover = List.reverse redist.cover
911+ , heightContent = redist.heightContent
916+redistributeOver attr els =
918+ Internal.Nearby _ _ ->
919+ { els | parent = attr :: els.parent }
921+ Internal.Width (Internal.Fill _) ->
922+ { els | fullParent = attr :: els.fullParent }
925+ { els | parent = attr :: els.parent }
927+ Internal.Height h ->
931+ | parent = attr :: els.parent
939+ | parent = attr :: els.parent
945+ Internal.AlignX _ ->
946+ { els | fullParent = attr :: els.fullParent }
948+ Internal.AlignY _ ->
949+ { els | fullParent = attr :: els.fullParent }
951+ Internal.StyleClass _ (Internal.SpacingStyle _ _ _) ->
953+ | fullParent = attr :: els.fullParent
954+ , parent = attr :: els.parent
955+ , input = attr :: els.input
958+ Internal.StyleClass _ (Internal.PaddingStyle _ _ _ _ _) ->
960+ | parent = attr :: els.parent
963+ Internal.StyleClass _ (Internal.BorderWidth _ _ _ _ _) ->
965+ | parent = attr :: els.parent
966+ , cover = attr :: els.cover
969+ Internal.StyleClass _ (Internal.Transform _) ->
971+ | parent = attr :: els.parent
972+ , cover = attr :: els.cover
975+ Internal.StyleClass _ (Internal.FontSize _) ->
976+ { els | fullParent = attr :: els.fullParent }
978+ Internal.StyleClass _ (Internal.FontFamily _ _) ->
979+ { els | fullParent = attr :: els.fullParent }
981+ Internal.StyleClass _ _ ->
982+ { els | parent = attr :: els.parent }
984+ Internal.NoAttribute ->
988+ { els | input = attr :: els.input }
990+ Internal.Describe _ ->
991+ { els | input = attr :: els.input }
993+ Internal.Class _ _ ->
994+ { els | parent = attr :: els.parent }
996+ Internal.TransformComponent _ _ ->
997+ { els | input = attr :: els.input }
1000+orElse thing maybe =
1009+inheritablePlaceholderAttributes attr =
1015− Internal.StyleClass Flag.heightTextAreaContent
1011+ Internal.StyleClass _ (Internal.PaddingStyle _ _ _ _ _) ->
1016− (Internal.Single ("textarea-height-" ++ String.fromInt newlineCount)
1012+ True
1018− (heightValue newlineCount)
1014+ Internal.StyleClass _ (Internal.BorderWidth _ _ _ _ _) ->
1017+ Internal.StyleClass _ (Internal.Transform _) ->