Skip to content

Commit c449ae1

Browse files
authored
Merge pull request #17 from slamdata/updates
Update dependencies, fix `accept` parameter for inputs
2 parents 6ba1c7d + bb5b3f5 commit c449ae1

File tree

3 files changed

+34
-3
lines changed

3 files changed

+34
-3
lines changed

bower.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"dependencies": {
1919
"purescript-media-types": "^4.0.0",
2020
"purescript-prelude": "^4.0.0",
21-
"purescript-web-clipboard": "^1.0.0",
22-
"purescript-web-touchevents": "^1.0.0"
21+
"purescript-web-clipboard": "^2.0.0",
22+
"purescript-web-touchevents": "^2.0.0"
2323
}
2424
}

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)