package bonsai

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type
module Form = Bonsai_web_ui_form
module type S = sig ... end
module Customization : sig ... end

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.

OCaml

Innovation. Community. Security.