package bonsai

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type
include module type of struct include Bonsai_web_ui_form_view end
type editable = [
  1. | `Yes_always
  2. | `Currently_yes
  3. | `Currently_no
]
type button_location = [
  1. | `Before
  2. | `After
]
type submission_options = Bonsai_web_ui_form_view.submission_options = {
  1. on_submit : unit Ui_effect.t option;
  2. handle_enter : bool;
  3. button_text : string option;
  4. button_attr : Virtual_dom.Vdom.Attr.t;
  5. button_location : button_location;
}
type context = Bonsai_web_ui_form_view.context = {
  1. tooltip : Virtual_dom.Vdom.Node.t option;
  2. error : Core.Error.t option;
  3. label : Virtual_dom.Vdom.Node.t option;
}
val sexp_of_context : context -> Sexplib0.Sexp.t
type append_item = Bonsai_web_ui_form_view.append_item =
  1. | Append_info of {
    1. append : unit Virtual_dom.Vdom.Effect.t;
    2. text : string option;
    }
  2. | Append_view of Virtual_dom.Vdom.Node.t
val sexp_of_append_item : append_item -> Sexplib0.Sexp.t
type remove_item = Bonsai_web_ui_form_view.remove_item =
  1. | Remove_info of {
    1. remove : unit Virtual_dom.Vdom.Effect.t;
    2. element_label : (delete_button:Virtual_dom.Vdom.Node.t -> int -> Virtual_dom.Vdom.Node.t) option;
    }
  2. | Remove_view of Virtual_dom.Vdom.Node.t
val sexp_of_remove_item : remove_item -> Sexplib0.Sexp.t
type t = Bonsai_web_ui_form_view.t = {
  1. context : context;
  2. view : view;
}
and view = Bonsai_web_ui_form_view.view =
  1. | Empty
  2. | Collapsible of collapsible
  3. | Raw of raw
  4. | Record of field list
  5. | Variant of variant
  6. | List of list_view
  7. | Tuple of t list
  8. | Option of option_view
and raw = Bonsai_web_ui_form_view.raw = {
  1. id : string;
  2. raw_view : context -> editable:editable -> Virtual_dom.Vdom.Node.t;
}
and collapsible = Bonsai_web_ui_form_view.collapsible = {
  1. collapse_label : Virtual_dom.Vdom.Node.t;
  2. state : collapsed_state;
}
and collapsed_state = Bonsai_web_ui_form_view.collapsed_state =
  1. | Collapsed of t option
  2. | Expanded of t
and option_status = Bonsai_web_ui_form_view.option_status =
  1. | Currently_some of t
  2. | Currently_none of t option
and list_view = Bonsai_web_ui_form_view.list_view = {
  1. list_items : list_item list;
  2. append_item : append_item;
  3. legacy_button_position : [ `Inline | `Indented ];
}
and list_item = Bonsai_web_ui_form_view.list_item = {
  1. item_view : t;
  2. remove_item : remove_item;
}
and variant = Bonsai_web_ui_form_view.variant = {
  1. clause_selector : Virtual_dom.Vdom.Node.t;
  2. selected_clause : clause option;
}
and clause = Bonsai_web_ui_form_view.clause = {
  1. clause_name : string;
  2. clause_view : t;
}
and field = Bonsai_web_ui_form_view.field = {
  1. field_name : string;
  2. field_view : t;
}
val sexp_of_t : t -> Sexplib0.Sexp.t
val sexp_of_view : view -> Sexplib0.Sexp.t
val sexp_of_raw : raw -> Sexplib0.Sexp.t
val sexp_of_collapsible : collapsible -> Sexplib0.Sexp.t
val sexp_of_collapsed_state : collapsed_state -> Sexplib0.Sexp.t
val sexp_of_option_view : option_view -> Sexplib0.Sexp.t
val sexp_of_option_status : option_status -> Sexplib0.Sexp.t
val sexp_of_list_view : list_view -> Sexplib0.Sexp.t
val sexp_of_list_item : list_item -> Sexplib0.Sexp.t
val sexp_of_variant : variant -> Sexplib0.Sexp.t
val sexp_of_clause : clause -> Sexplib0.Sexp.t
val sexp_of_field : field -> Sexplib0.Sexp.t
val of_vdom' : id:string -> (context -> editable:editable -> Virtual_dom.Vdom.Node.t) -> t

of_vdom' is like of_vdom, but allows access to some extra metadata that is stored in the form's view.

val tuple : t list -> t

tuple combines a list of t into a single one.

val record : field list -> t

record combines a list of fields (field names and their corresponding views) into a view representing a record with those fields.

val variant : clause_selector:Virtual_dom.Vdom.Node.t -> selected_clause:clause option -> t

variant takes a selector for selecting which variant case, as well as an optional selected_clause which contains the name of the currently selected clause and the t representing that clause's arguments.

val option : toggle:Virtual_dom.Vdom.Node.t -> status:option_status -> t

option takes a toggle for switching between None and Some _, as well as a status for the form. status can be:

  • Currently_some view if toggle is set to Some _ and view represents the form for the type in the option.
  • Currently_none None if the toggle is set to None and we shouldn't show any view for the None case
  • Currently_none (Some view) if the toggle is set to None and we want to display view when the toggle is set to None (e.g. displaying a greyed out textbox)
val collapsible : label:Virtual_dom.Vdom.Node.t -> state:collapsed_state -> t

collapsible represents a collapsible subform. The supplied label can be used to toggle open/closed the collapsible t.

collapsible_state can be:

  • Collapsed None if the view is collapsed and we shouldn't render any subform
  • Collapsed (Some view) if the view is collapsed but we want to render a subform in this case (e.g. displaying ... in a code editor when folded)
  • Expanded view if the view is expanded and view is the subform to show
val list_item : view:t -> remove_item:remove_item -> list_item

list_item represents a single form in an extendable list.

remove_item can either be:

  • Remove_info { remove; element_label } in which case the rendering function will decide how to render a remove button for this item with remove being scheduled on click and element_label being called to generate the label for this element.
  • Remove_view view in which case view will be used as the remove button
val list : append_item:append_item -> legacy_button_position:[ `Inline | `Indented ] -> list_item list -> t

list represents a form for an extendable list.

append_item can either be:

  • Append_info { append; text } in which case the rendering function will decide how to render an append button with append being scheduled on click and text being the text for the button
  • Append_view view in which case view will be used as the append button
val with_fieldset : currently_editable:bool -> Virtual_dom.Vdom.Node.t -> Virtual_dom.Vdom.Node.t
val empty : t
val suggest_error : Core.Error.t -> t -> t
val suggest_label' : Bonsai_web.Vdom.Node.t -> t -> t
val suggest_label : string -> t -> t
val set_label : Bonsai_web.Vdom.Node.t -> t -> t
val set_tooltip : Bonsai_web.Vdom.Node.t -> t -> t
val of_vdom : id:string -> Bonsai_web.Vdom.Node.t -> t
val to_vdom : ?theme:Bonsai_web.View.Theme.t -> ?on_submit:submission_options -> ?editable:editable -> t -> Bonsai_web.Vdom.Node.t
val to_vdom_plain : ?theme:Bonsai_web.View.Theme.t -> ?editable:editable -> t -> Bonsai_web.Vdom.Node.t list
val sexp_to_pretty_string : ('a -> Core.Sexp.t) -> 'a -> string
module Expert : sig ... end
OCaml

Innovation. Community. Security.