git.iko.soy/typeable/elm-ui
on master help sign in
Input.multiline height:shrink with min/max being respected.
1511221Matthew Griffith
src/Element/Input.elm+40−40
@@ -654,7 +654,7 @@ textHelper : TextInput -> List (Attribute msg) -> Text msg -> Element msg
654textHelper textInput attrs textOptions =
654textHelper textInput attrs textOptions =
655 let
655 let
656 attributes =
656 attributes =
657− Element.width Element.fill :: (defaultTextBoxStyle ++ attrs)
657+ defaultTextBoxStyle ++ attrs
658
658
659 behavior =
659 behavior =
660 [ Internal.Attr (Html.Events.onInput textOptions.onChange) ]
660 [ Internal.Attr (Html.Events.onInput textOptions.onChange) ]
@@ -699,20 +699,15 @@ textHelper textInput attrs textOptions =
699 Internal.Describe _ ->
699 Internal.Describe _ ->
700 found
700 found
701
701
702− Internal.Height val ->
702+ Internal.Height len ->
703 case found.heightContent of
703 case found.heightContent of
704 Nothing ->
704 Nothing ->
705− case val of
705+ { found
706− Internal.Content ->
706+ | heightContent = Just (Internal.isContent len)
707− { found
708− | heightContent = Just val
709− , adjustedAttributes = found.adjustedAttributes
707+ , adjustedAttributes = attr :: found.adjustedAttributes
710− }
708+ }
711−
712− _ ->
713− { found | heightContent = Just val }
714
709
715− Just i ->
710+ _ ->
716 found
711 found
717
712
718 Internal.StyleClass _ (Internal.PaddingStyle _ t r b l) ->
713 Internal.StyleClass _ (Internal.PaddingStyle _ t r b l) ->
@@ -770,35 +765,11 @@ textHelper textInput attrs textOptions =
770 Nothing ->
765 Nothing ->
771 Internal.NoAttribute
766 Internal.NoAttribute
772
767
773− Just Internal.Content ->
768+ Just True ->
774− let
769+ textHeightContent textOptions.text spacing maybePadding
775− newlineCount =
776− String.lines textOptions.text
777− |> List.length
778− |> (\x ->
779− if x < 1 then
780− 1
781−
782− else
783− x
784− )
785−
786− heightValue count =
787− case maybePadding of
788− Nothing ->
789− "calc(" ++ String.fromInt count ++ "em + " ++ String.fromInt ((count - 1) * spacing) ++ "px) !important"
790−
791− Just (Padding t r b l) ->
792− "calc(" ++ String.fromInt count ++ "em + " ++ String.fromInt ((t + b) + ((count - 1) * spacing)) ++ "px) !important"
793− in
794− Internal.StyleClass Flag.height
795− (Internal.Single ("textarea-height-" ++ String.fromInt newlineCount)
796− "height"
797− (heightValue newlineCount)
798− )
799
770
800− Just x ->
771+ Just False ->
801− Internal.Height x
772+ Internal.NoAttribute
802 ]
773 ]
803 ++ adjustedAttributes
774 ++ adjustedAttributes
804 , [ Internal.unstyled (Html.text textOptions.text) ]
775 , [ Internal.unstyled (Html.text textOptions.text) ]
@@ -925,6 +896,34 @@ textHelper textInput attrs textOptions =
925 inputElement
896 inputElement
926
897
927
898
899+textHeightContent textValue spacing maybePadding =
900+ let
901+ newlineCount =
902+ String.lines textValue
903+ |> List.length
904+ |> (\x ->
905+ if x < 1 then
906+ 1
907+
908+ else
909+ x
910+ )
911+
912+ heightValue count =
913+ case maybePadding of
914+ Nothing ->
915+ "calc(" ++ String.fromInt count ++ "em + " ++ String.fromInt ((count - 1) * spacing) ++ "px) !important"
916+
917+ Just (Padding t r b l) ->
918+ "calc(" ++ String.fromInt count ++ "em + " ++ String.fromInt ((t + b) + ((count - 1) * spacing)) ++ "px) !important"
919+ in
920+ Internal.StyleClass Flag.heightTextAreaContent
921+ (Internal.Single ("textarea-height-" ++ String.fromInt newlineCount)
922+ "height"
923+ (heightValue newlineCount)
924+ )
925+
926+
928{-| -}
927{-| -}
929text :
928text :
930 List (Attribute msg)
929 List (Attribute msg)
@@ -1811,6 +1810,7 @@ defaultTextBoxStyle =
1811 , Background.color white
1810 , Background.color white
1812 , Border.width 1
1811 , Border.width 1
1813 , Element.spacing 3
1812 , Element.spacing 3
1813+ , Element.width Element.fill
1814 ]
1814 ]
1815
1815
1816
1816
src/Internal/Flag.elm+60−1
@@ -1,4 +1,59 @@
1−module Internal.Flag exposing (Field(..), Flag(..), active, add, alignBottom, alignRight, behind, bgColor, bgGradient, bgImage, borderColor, borderRound, borderStyle, borderWidth, centerX, centerY, cursor, flag, focus, fontAlignment, fontColor, fontFamily, fontSize, fontWeight, gridPosition, gridTemplate, height, heightBetween, heightContent, heightFill, hover, letterSpacing, merge, moveX, moveY, none, overflow, padding, present, rotate, scale, shadows, spacing, transparency, txtShadows, value, width, widthBetween, widthContent, widthFill, wordSpacing, xAlign, yAlign)
1+module Internal.Flag exposing
2+ ( Field(..)
3+ , Flag(..)
4+ , active
5+ , add
6+ , alignBottom
7+ , alignRight
8+ , behind
9+ , bgColor
10+ , bgGradient
11+ , bgImage
12+ , borderColor
13+ , borderRound
14+ , borderStyle
15+ , borderWidth
16+ , centerX
17+ , centerY
18+ , cursor
19+ , flag
20+ , focus
21+ , fontAlignment
22+ , fontColor
23+ , fontFamily
24+ , fontSize
25+ , fontWeight
26+ , gridPosition
27+ , gridTemplate
28+ , height
29+ , heightBetween
30+ , heightContent
31+ , heightFill
32+ , heightTextAreaContent
33+ , hover
34+ , letterSpacing
35+ , merge
36+ , moveX
37+ , moveY
38+ , none
39+ , overflow
40+ , padding
41+ , present
42+ , rotate
43+ , scale
44+ , shadows
45+ , spacing
46+ , transparency
47+ , txtShadows
48+ , value
49+ , width
50+ , widthBetween
51+ , widthContent
52+ , widthFill
53+ , wordSpacing
54+ , xAlign
55+ , yAlign
56+ )
2
57
3{-| -}
58{-| -}
4
59
@@ -259,3 +314,7 @@ heightBetween =
259
314
260behind =
315behind =
261 flag 46
316 flag 46
317+
318+
319+heightTextAreaContent =
320+ flag 47
src/Internal/Model.elm+135−15
@@ -1,4 +1,117 @@
1−module Internal.Model exposing (Aligned(..), Angle, Attribute(..), Axis(..), Children(..), Color(..), Description(..), Element(..), EmbedStyle(..), FocusStyle, Font(..), Gathered, HAlign(..), HoverSetting(..), LayoutContext(..), Length(..), Location(..), NodeName(..), Option(..), OptionRecord, Padding(..), Property(..), PseudoClass(..), RenderMode(..), Shadow, Spacing(..), Style(..), TransformComponent(..), Transformation(..), VAlign(..), XYZ, addNodeName, addWhen, alignXName, alignYName, asColumn, asEl, asGrid, asParagraph, asRow, asTextColumn, boxShadowName, columnClass, composeTransformation, contextClasses, createElement, defaultOptions, div, element, embedKeyed, embedWith, extractSpacingAndPadding, filter, finalizeNode, floatClass, focusDefaultStyle, formatBoxShadow, formatColor, formatColorClass, formatDropShadow, formatTextShadow, gatherAttrRecursive, get, getHeight, getSpacing, getStyleName, getWidth, gridClass, htmlClass, lengthClassName, map, mapAttr, mapAttrFromStyle, noStyleSheet, onlyStyles, optionsToRecord, paddingName, pageClass, paragraphClass, reduceRecursive, reduceRecursiveCalcName, reduceStyles, reduceStylesRecursive, removeNever, renderFocusStyle, renderFont, renderFontClassName, renderHeight, renderRoot, renderWidth, rootStyle, rowClass, singleClass, skippable, sortedReduce, spacingName, staticRoot, tag, textElement, textElementFill, textShadowName, toHtml, toStyleSheet, toStyleSheetString, transformClass, transformValue, unit, unstyled, untransformed, unwrapDecorations, unwrapDecsHelper)
1+module Internal.Model exposing
2+ ( Aligned(..)
3+ , Angle
4+ , Attribute(..)
5+ , Axis(..)
6+ , Children(..)
7+ , Color(..)
8+ , Description(..)
9+ , Element(..)
10+ , EmbedStyle(..)
11+ , FocusStyle
12+ , Font(..)
13+ , Gathered
14+ , HAlign(..)
15+ , HoverSetting(..)
16+ , LayoutContext(..)
17+ , Length(..)
18+ , Location(..)
19+ , NodeName(..)
20+ , Option(..)
21+ , OptionRecord
22+ , Padding(..)
23+ , Property(..)
24+ , PseudoClass(..)
25+ , RenderMode(..)
26+ , Shadow
27+ , Spacing(..)
28+ , Style(..)
29+ , TransformComponent(..)
30+ , Transformation(..)
31+ , VAlign(..)
32+ , XYZ
33+ , addNodeName
34+ , addWhen
35+ , alignXName
36+ , alignYName
37+ , asColumn
38+ , asEl
39+ , asGrid
40+ , asParagraph
41+ , asRow
42+ , asTextColumn
43+ , boxShadowName
44+ , columnClass
45+ , composeTransformation
46+ , contextClasses
47+ , createElement
48+ , defaultOptions
49+ , div
50+ , element
51+ , embedKeyed
52+ , embedWith
53+ , extractSpacingAndPadding
54+ , filter
55+ , finalizeNode
56+ , floatClass
57+ , focusDefaultStyle
58+ , formatBoxShadow
59+ , formatColor
60+ , formatColorClass
61+ , formatDropShadow
62+ , formatTextShadow
63+ , gatherAttrRecursive
64+ , get
65+ , getHeight
66+ , getSpacing
67+ , getStyleName
68+ , getWidth
69+ , gridClass
70+ , htmlClass
71+ , lengthClassName
72+ , map
73+ , mapAttr
74+ , mapAttrFromStyle
75+ , noStyleSheet
76+ , onlyStyles
77+ , optionsToRecord
78+ , paddingName
79+ , pageClass
80+ , paragraphClass
81+ , reduceRecursive
82+ , reduceRecursiveCalcName
83+ , reduceStyles
84+ , reduceStylesRecursive
85+ , removeNever
86+ , renderFocusStyle
87+ , renderFont
88+ , renderFontClassName
89+ , renderHeight
90+ , renderRoot
91+ , renderWidth
92+ , rootStyle
93+ , rowClass
94+ , singleClass
95+ , skippable
96+ , sortedReduce
97+ , spacingName
98+ , staticRoot
99+ , tag
100+ , textElement
101+ , textElementFill
102+ , textShadowName
103+ , toHtml
104+ , toStyleSheet
105+ , toStyleSheetString
106+ , transformClass
107+ , transformValue
108+ , unit
109+ , unstyled
110+ , untransformed
111+ , unwrapDecorations
112+ , unwrapDecsHelper
113+ , isContent
114+ )
2
115
3{-| -}
116{-| -}
4
117
@@ -1002,50 +1115,42 @@ gatherAttrRecursive classes node has transform styles attrs children elementAttr
1002 case location of
1115 case location of
1003 Above ->
1116 Above ->
1004 String.join " "
1117 String.join " "
1005− [
1006− Internal.Style.classes.nearby
1118+ [ Internal.Style.classes.nearby
1007 , Internal.Style.classes.single
1119 , Internal.Style.classes.single
1008 , Internal.Style.classes.above
1120 , Internal.Style.classes.above
1009 ]
1121 ]
1010
1122
1011 Below ->
1123 Below ->
1012 String.join " "
1124 String.join " "
1013− [
1014− Internal.Style.classes.nearby
1125+ [ Internal.Style.classes.nearby
1015 , Internal.Style.classes.single
1126 , Internal.Style.classes.single
1016 , Internal.Style.classes.below
1127 , Internal.Style.classes.below
1017 ]
1128 ]
1018
1129
1019 OnRight ->
1130 OnRight ->
1020 String.join " "
1131 String.join " "
1021− [
1022− Internal.Style.classes.nearby
1132+ [ Internal.Style.classes.nearby
1023 , Internal.Style.classes.single
1133 , Internal.Style.classes.single
1024 , Internal.Style.classes.onRight
1134 , Internal.Style.classes.onRight
1025 ]
1135 ]
1026
1136
1027 OnLeft ->
1137 OnLeft ->
1028−
1029−
1030 String.join " "
1138 String.join " "
1031− [
1032− Internal.Style.classes.nearby
1139+ [ Internal.Style.classes.nearby
1033 , Internal.Style.classes.single
1140 , Internal.Style.classes.single
1034 , Internal.Style.classes.onLeft
1141 , Internal.Style.classes.onLeft
1035 ]
1142 ]
1036
1143
1037 InFront ->
1144 InFront ->
1038 String.join " "
1145 String.join " "
1039− [
1040− Internal.Style.classes.nearby
1146+ [ Internal.Style.classes.nearby
1041 , Internal.Style.classes.single
1147 , Internal.Style.classes.single
1042 , Internal.Style.classes.inFront
1148 , Internal.Style.classes.inFront
1043 ]
1149 ]
1044
1150
1045 Behind ->
1151 Behind ->
1046 String.join " "
1152 String.join " "
1047− [
1048− Internal.Style.classes.nearby
1153+ [ Internal.Style.classes.nearby
1049 , Internal.Style.classes.single
1154 , Internal.Style.classes.single
1050 , Internal.Style.classes.behind
1155 , Internal.Style.classes.behind
1051 ]
1156 ]
@@ -1648,6 +1753,21 @@ filter attrs =
1648 attrs
1753 attrs
1649
1754
1650
1755
1756+isContent len =
1757+ case len of
1758+ Content ->
1759+ True
1760+
1761+ Max _ l ->
1762+ isContent l
1763+
1764+ Min _ l ->
1765+ isContent l
1766+
1767+ _ ->
1768+ False
1769+
1770+
1651get : List (Attribute aligned msg) -> (Attribute aligned msg -> Bool) -> List (Attribute aligned msg)
1771get : List (Attribute aligned msg) -> (Attribute aligned msg -> Bool) -> List (Attribute aligned msg)
1652get attrs isAttr =
1772get attrs isAttr =
1653 attrs
1773 attrs