Skip to content

Commit bb5b3f5

Browse files
committed
Fix accept parameter for inputs
1 parent 0913047 commit bb5b3f5

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

src/DOM/HTML/Indexed.purs

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import DOM.HTML.Indexed.ButtonType (ButtonType)
44
import DOM.HTML.Indexed.CrossOriginValue (CrossOriginValue)
55
import DOM.HTML.Indexed.DirValue (DirValue)
66
import DOM.HTML.Indexed.FormMethod (FormMethod)
7+
import DOM.HTML.Indexed.InputAcceptType (InputAcceptType)
78
import DOM.HTML.Indexed.InputType (InputType)
89
import DOM.HTML.Indexed.KindValue (KindValue)
910
import DOM.HTML.Indexed.MenuType (MenuType)
@@ -338,7 +339,7 @@ type HTMLimg = Interactive
338339
)
339340

340341
type HTMLinput = Interactive
341-
( accept :: MediaType
342+
( accept :: InputAcceptType
342343
, autocomplete :: OnOff
343344
, autofocus :: Boolean
344345
, checked :: Boolean
+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
module DOM.HTML.Indexed.InputAcceptType where
2+
3+
import Prelude
4+
5+
import Data.MediaType (MediaType(..))
6+
import Data.String as String
7+
8+
newtype InputAcceptType = InputAcceptType (Array InputAcceptTypeAtom)
9+
10+
instance semigroupInputAcceptType :: Semigroup InputAcceptType where
11+
append (InputAcceptType a) (InputAcceptType b) = InputAcceptType (a <> b)
12+
13+
mediaType :: MediaType -> InputAcceptType
14+
mediaType mt = InputAcceptType [AcceptMediaType mt]
15+
16+
extension :: String -> InputAcceptType
17+
extension ext = InputAcceptType [AcceptFileExtension ext]
18+
19+
data InputAcceptTypeAtom
20+
= AcceptMediaType MediaType
21+
| AcceptFileExtension String
22+
23+
renderInputAcceptType :: InputAcceptType -> String
24+
renderInputAcceptType (InputAcceptType atoms) =
25+
String.joinWith "," (map renderInputAcceptTypeAtom atoms)
26+
27+
renderInputAcceptTypeAtom :: InputAcceptTypeAtom -> String
28+
renderInputAcceptTypeAtom = case _ of
29+
AcceptMediaType (MediaType mt) -> mt
30+
AcceptFileExtension ext -> ext

0 commit comments

Comments
 (0)