Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dialog element support #1257

Merged
merged 5 commits into from
Feb 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## Features/Changes
* Compiler: only flush the necessary env for closures (#1568)
* Library: dialog element support

## Bug fixes
* Compiler: fix --enable=vardecl
Expand Down
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 @@ -770,8 +770,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 @@ -1289,6 +1293,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 @@ -2537,6 +2561,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 @@ -3360,6 +3386,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 @@ -2297,8 +2317,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 @@ -2773,6 +2797,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 @@ -2919,6 +2945,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
Loading