Skip to content

Commit

Permalink
Lib: Dialog element support (#1257)
Browse files Browse the repository at this point in the history
* Support for dialogElement

* Added cancel and close events

---------

Co-authored-by: Hugo Heuzard <[email protected]>
  • Loading branch information
2 people authored and OlivierNicole committed Sep 3, 2024
1 parent fb964b6 commit 5a0a119
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 2 deletions.
2 changes: 1 addition & 1 deletion dune-project
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@
(js_of_ocaml-ppx (= :version))
(react (>= 1.2.1))
(reactiveData (>= 0.2))
(tyxml (>= 4.3))
(tyxml (>= 4.6))
(num :with-test)
(ppx_expect (and (>= v0.14.2) :with-test))
(ppxlib (and (>= 0.22.0) :with-test))
Expand Down
2 changes: 1 addition & 1 deletion js_of_ocaml-tyxml.opam
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ depends: [
"js_of_ocaml-ppx" {= version}
"react" {>= "1.2.1"}
"reactiveData" {>= "0.2"}
"tyxml" {>= "4.3"}
"tyxml" {>= "4.6"}
"num" {with-test}
"ppx_expect" {>= "v0.14.2" & with-test}
"ppxlib" {>= "0.22.0" & with-test}
Expand Down
27 changes: 27 additions & 0 deletions lib/js_of_ocaml/dom_html.ml
Original file line number Diff line number Diff line change
Expand Up @@ -773,8 +773,12 @@ let invoke_handler = Dom.invoke_handler
module Event = struct
type 'a typ = 'a Dom.Event.typ

let cancel = Dom.Event.make "cancel"

let click = Dom.Event.make "click"

let close = Dom.Event.make "close"

let copy = Dom.Event.make "copy"

let cut = Dom.Event.make "cut"
Expand Down Expand Up @@ -1292,6 +1296,26 @@ class type dListElement = element

class type liElement = element

class type dialogElement = object
inherit element

method close : unit meth

method close_returnValue : js_string t -> unit meth

method open_ : bool t prop

method returnValue : js_string t prop

method show : unit meth

method showModal : unit meth

method oncancel : ('self t, event t) event_listener prop

method onclose : ('self t, event t) event_listener prop
end

class type divElement = element

class type paragraphElement = element
Expand Down Expand Up @@ -2527,6 +2551,8 @@ let createDl doc : dListElement t = unsafeCreateElement doc "dl"

let createLi doc : liElement t = unsafeCreateElement doc "li"

let createDialog doc : dialogElement t = unsafeCreateElement doc "dialog"

let createDiv doc : divElement t = unsafeCreateElement doc "div"

let createEmbed doc : embedElement t = unsafeCreateElement doc "embed"
Expand Down Expand Up @@ -3350,6 +3376,7 @@ type taggedElement =
| Col of tableColElement t
| Colgroup of tableColElement t
| Del of modElement t
| Dialog of dialogElement t
| Div of divElement t
| Dl of dListElement t
| Embed of embedElement t
Expand Down
27 changes: 27 additions & 0 deletions lib/js_of_ocaml/dom_html.mli
Original file line number Diff line number Diff line change
Expand Up @@ -1114,6 +1114,26 @@ class type dListElement = element

class type liElement = element

class type dialogElement = object
inherit element

method close : unit meth

method close_returnValue : js_string t -> unit meth

method open_ : bool t prop

method returnValue : js_string t prop

method show : unit meth

method showModal : unit meth

method oncancel : ('self t, event t) event_listener prop

method onclose : ('self t, event t) event_listener prop
end

class type divElement = element

class type paragraphElement = element
Expand Down Expand Up @@ -2284,8 +2304,12 @@ val eventRelatedTarget : #mouseEvent t -> element t opt
module Event : sig
type 'a typ = 'a Dom.Event.typ

val cancel : event t typ

val click : mouseEvent t typ

val close : event t typ

val copy : clipboardEvent t typ

val cut : clipboardEvent t typ
Expand Down Expand Up @@ -2760,6 +2784,8 @@ val createDl : document t -> dListElement t

val createLi : document t -> liElement t

val createDialog : document t -> dialogElement t

val createDiv : document t -> divElement t

val createEmbed : document t -> embedElement t
Expand Down Expand Up @@ -2906,6 +2932,7 @@ type taggedElement =
| Col of tableColElement t
| Colgroup of tableColElement t
| Del of modElement t
| Dialog of dialogElement t
| Div of divElement t
| Dl of dListElement t
| Embed of embedElement t
Expand Down
4 changes: 4 additions & 0 deletions lib/tyxml/tyxml_cast.ml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ end) : Tyxml_cast_sigs.TO with type 'a elt = 'a C.elt = struct

let of_li elt = rebuild_node "of_li" elt

let of_dialog elt = rebuild_node "of_dialog" elt

let of_div elt = rebuild_node "of_div" elt

let of_p elt = rebuild_node "of_p" elt
Expand Down Expand Up @@ -309,6 +311,8 @@ end) : Tyxml_cast_sigs.OF with type 'a elt = 'a C.elt = struct

let of_li elt = rebuild_node "of_li" elt

let of_dialog elt = rebuild_node "of_dialog" elt

let of_div elt = rebuild_node "of_div" elt

let of_paragraph elt = rebuild_node "of_paragraph" elt
Expand Down
4 changes: 4 additions & 0 deletions lib/tyxml/tyxml_cast_sigs.ml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ module type OF = sig

val of_li : Dom_html.liElement Js.t -> [> Html_types.li ] elt

val of_dialog : Dom_html.dialogElement Js.t -> [> Html_types.dialog ] elt

val of_div : Dom_html.divElement Js.t -> [> Html_types.div ] elt

val of_paragraph : Dom_html.paragraphElement Js.t -> [> Html_types.p ] elt
Expand Down Expand Up @@ -180,6 +182,8 @@ module type TO = sig

val of_li : [< Html_types.li ] elt -> Dom_html.liElement Js.t

val of_dialog : [< Html_types.dialog ] elt -> Dom_html.dialogElement Js.t

val of_div : [< Html_types.div ] elt -> Dom_html.divElement Js.t

val of_p : [< Html_types.p ] elt -> Dom_html.paragraphElement Js.t
Expand Down
4 changes: 4 additions & 0 deletions lib/tyxml/tyxml_cast_sigs.mli
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ module type OF = sig

val of_li : Dom_html.liElement Js.t -> [> Html_types.li ] elt

val of_dialog : Dom_html.dialogElement Js.t -> [> Html_types.dialog ] elt

val of_div : Dom_html.divElement Js.t -> [> Html_types.div ] elt

val of_paragraph : Dom_html.paragraphElement Js.t -> [> Html_types.p ] elt
Expand Down Expand Up @@ -179,6 +181,8 @@ module type TO = sig

val of_li : [< Html_types.li ] elt -> Dom_html.liElement Js.t

val of_dialog : [< Html_types.dialog ] elt -> Dom_html.dialogElement Js.t

val of_div : [< Html_types.div ] elt -> Dom_html.divElement Js.t

val of_p : [< Html_types.p ] elt -> Dom_html.paragraphElement Js.t
Expand Down

0 comments on commit 5a0a119

Please sign in to comment.