changeset 2078:6d126af2e1cb

Some more HTML5 input types
author Adam Chlipala <adam@chlipala.net>
date Sun, 16 Nov 2014 14:39:38 -0500
parents 3cd2bd4b1de0
children e1879ded8095
files lib/ur/basis.urs src/monoize.sml src/urweb.grm src/urweb.lex tests/html5_forms.ur
diffstat 5 files changed, 46 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/lib/ur/basis.urs	Sun Nov 16 14:16:11 2014 -0500
+++ b/lib/ur/basis.urs	Sun Nov 16 14:39:38 2014 -0500
@@ -969,6 +969,17 @@
 val search : textWidget
 val url_ : textWidget
 val tel : textWidget
+val color : textWidget
+
+val number : formTag float [] ([Value = float, Min = float, Max = float, Step = float, Size = int, Onchange = transaction unit] ++ boxAttrs ++ inputAttrs)
+val range : formTag float [] ([Value = float, Min = float, Max = float, Size = int, Onchange = transaction unit] ++ boxAttrs ++ inputAttrs)
+val date : formTag string [] ([Value = string, Min = string, Max = string, Size = int, Onchange = transaction unit] ++ boxAttrs ++ inputAttrs)
+val datetime : formTag string [] ([Value = string, Min = string, Max = string, Size = int, Onchange = transaction unit] ++ boxAttrs ++ inputAttrs)
+val datetime_local : formTag string [] ([Value = string, Min = string, Max = string, Size = int, Onchange = transaction unit] ++ boxAttrs ++ inputAttrs)
+val month : formTag string [] ([Value = string, Min = string, Max = string, Size = int, Onchange = transaction unit] ++ boxAttrs ++ inputAttrs)
+val week : formTag string [] ([Value = string, Min = string, Max = string, Size = int, Onchange = transaction unit] ++ boxAttrs ++ inputAttrs)
+val timeInput : formTag string [] ([Value = string, Min = string, Max = string, Size = int, Onchange = transaction unit] ++ boxAttrs ++ inputAttrs)
+
 
 
 type file
--- a/src/monoize.sml	Sun Nov 16 14:16:11 2014 -0500
+++ b/src/monoize.sml	Sun Nov 16 14:39:38 2014 -0500
@@ -3667,6 +3667,15 @@
                       | "search" => input "search"
                       | "url_" => input "url"
                       | "tel" => input "tel"
+                      | "color" => input "color"
+                      | "number" => input "number"
+                      | "range" => input "range"
+                      | "date" => input "date"
+                      | "datetime" => input "datetime"
+                      | "datetime_local" => input "datetime-local"
+                      | "month" => input "month"
+                      | "week" => input "week"
+                      | "timeInput" => input "time"
                       | "textarea" =>
 			(case targs of
                              [_, (L.CName name, _)] =>
--- a/src/urweb.grm	Sun Nov 16 14:16:11 2014 -0500
+++ b/src/urweb.grm	Sun Nov 16 14:39:38 2014 -0500
@@ -222,6 +222,7 @@
     case bt of
         "table" => "tabl"
       | "url" => "url_"
+      | "datetime-local" => "datetime_local"
       | _ => bt
 
 datatype prop_kind = Delete | Update
--- a/src/urweb.lex	Sun Nov 16 14:16:11 2014 -0500
+++ b/src/urweb.lex	Sun Nov 16 14:39:38 2014 -0500
@@ -277,19 +277,19 @@
                                    continue ())
                           end);
 
-<INITIAL> "<" {id} "/>"=>(let
+<INITIAL> "<" {xmlid} "/>"=>(let
 			      val tag = String.substring (yytext, 1, size yytext - 3)
 			  in
 			      Tokens.XML_BEGIN_END (tag, yypos, yypos + size yytext)
 			  end);
-<INITIAL> "<" {id} ">"=> (let
+<INITIAL> "<" {xmlid} ">"=> (let
 			      val tag = String.substring (yytext, 1, size yytext - 2)
 			  in
 			      YYBEGIN XML;
 			      xmlTag := tag :: (!xmlTag);
 			      Tokens.XML_BEGIN (tag, yypos, yypos + size yytext)
 			  end);
-<XML> "</" {id} ">"   => (let
+<XML> "</" {xmlid} ">" => (let
 			      val id = String.substring (yytext, 2, size yytext - 3)
 			  in
 			      case !xmlTag of
@@ -304,7 +304,7 @@
 			          Tokens.END_TAG (id, yypos, yypos + size yytext)
 			  end);
 
-<XML> "<" {id}        => (YYBEGIN XMLTAG;
+<XML> "<" {xmlid}     => (YYBEGIN XMLTAG;
 			  Tokens.BEGIN_TAG (String.extract (yytext, 1, NONE),
 					    yypos, yypos + size yytext));
 
--- a/tests/html5_forms.ur	Sun Nov 16 14:16:11 2014 -0500
+++ b/tests/html5_forms.ur	Sun Nov 16 14:39:38 2014 -0500
@@ -6,6 +6,15 @@
   E: {[r.E]}<br/>
   F: {[r.F]}<br/>
   G: {[r.G]}<br/>
+  H: {[r.H]}<br/>
+  I: {[r.I]}<br/>
+  J: {[r.J]}<br/>
+  K: {[r.K]}<br/>
+  L: {[r.L]}<br/>
+  M: {[r.M]}<br/>
+  N: {[r.N]}<br/>
+  O: {[r.O]}<br/>
+  P: {[r.P]}<br/>
 </body></xml>
 
 fun main () =
@@ -19,6 +28,18 @@
         <tel{#F}/>
         <search{#G}/>
 
+        <hr/>
+
+        <color{#H}/>
+        <number{#I} min={17.0} max={32.8} value={20.6} step={2.5}/>
+        <range{#J} min={17.0} max={32.8} value={20.6}/>
+        <date{#K}/>
+        <datetime{#L}/>
+        <datetime-local{#M}/>
+        <month{#N}/>
+        <week{#O}/>
+        <timeInput{#P}/>
+
         <submit action={handler}/>
       </form>
     </body></xml>