package bonsai
Install
Dune Dependency
Authors
Maintainers
Sources
sha256=1d68aab713659951eba5b85f21d6f9382e0efa8579a02c3be65d9071c6e86303
doc/bonsai.web_ui_auto_generated/Bonsai_web_ui_auto_generated/index.html
Module Bonsai_web_ui_auto_generated
Source
type form_transformer =
Sexp_grammar.grammar Sexp_grammar.with_tag Bonsai_web.Value.t ->
recurse:
(Sexp_grammar.grammar Bonsai_web.Value.t ->
Core.Sexp.t Form.t Bonsai_web.Computation.t) ->
Core.Sexp.t Form.t Bonsai_web.Computation.t
Customizations allow you to use custom logic for leaves of your view/form generation. When a tagged sexp_grammar is encountered, apply_to_tag
will be invoked on the tag's key and value. If apply_to_tag
returns true, then the custom logic will be used in place of the default auto-generated logic.
val view :
(module S with type t = 'a) ->
?customizations:
(Core.Sexp.t Bonsai_web.Value.t ->
Bonsai_web.Vdom.Node.t Bonsai_web.Computation.t)
Customization.t
list ->
'a Bonsai_web.Value.t ->
[ `This_view_may_change_without_notice ] ->
Bonsai_web.Vdom.Node.t Bonsai_web.Computation.t
WARNING: This function produces output which is auto-generated and is subject to large layout changes without notice while the API is being developed. You should not rely on this function if your users will be sad when the output changes.
view
produces a Vdom.Node.t
representing a given 'a Value.t
, based on the sexp grammar for 'a
.
customizations
is a list of customizations to use while generating the view (see above). Customizations are tried in the provided order, using the result of the first matching customization.
val form :
(module S with type t = 'a) ->
?on_set_error:(Core.Sexp.t -> unit Bonsai_web.Effect.t) ->
?customizations:form_transformer Customization.t list ->
?textbox_for_string:unit ->
unit ->
'a Form.t Bonsai_web.Computation.t
form
takes a type 'a
and its sexp grammar and produces a 'a Form.t
.
on_set_error
defaults to Effect.print_s
and allows customization of what happens if Form.set
produces an error while operating on the sexp representation of the type. For types which derive sexp and sexp_grammar, on_set_error
should not be called, but it may for types with hand-rolled grammars or sexp functions.
customizations
is a list of customizations to use while generating the form (see above). Customizations are tried in the provided order, using the result of the first matching customization.
Grammar fields tagged with key Ppx_sexp_conv_lib.Sexp_grammar.doc_comment_tag
will be converted into tooltips. This tag is added automatically to doc comments on types which derive sexp_grammar
with the ~tags_of_doc_comments
option.
If textbox_for_string
is supplied, string inputs will be textboxes rather than textareas (meaning the form can be submitted with Enter when those fields are active, but users will not be able to input multiline strings).
val form' :
?on_set_error:(Core.Sexp.t -> unit Bonsai_web.Effect.t) ->
?customizations:form_transformer Customization.t list ->
?textbox_for_string:unit ->
Sexp_grammar.grammar Bonsai_web.Value.t ->
Core.Sexp.t Form.t Bonsai_web.Computation.t
form'
is similar to form
, but takes an untyped sexp grammar as a value, and produces a Sexp.t Form.t
. This allows you to create a form that depends on a dynamic sexp grammar.
val view_as_vdom :
?on_submit:'a Bonsai_web_ui_form.Submit.t ->
?editable:[ `Yes_always | `Currently_yes | `Currently_no ] ->
'a Form.t ->
Bonsai_web.Vdom.Node.t
view_as_vdom
provides a custom rendering function for the form generated by form
, which is optimized to look good, even with many levels of nesting.