package bonsai
Install
Dune Dependency
Authors
Maintainers
Sources
sha256=1d68aab713659951eba5b85f21d6f9382e0efa8579a02c3be65d9071c6e86303
doc/bonsai.web_ui_form/Bonsai_web_ui_form/View/index.html
Module Bonsai_web_ui_form.View
Source
include module type of struct include Bonsai_web_ui_form_view end
type context = Bonsai_web_ui_form_view.context = {
tooltip : Virtual_dom.Vdom.Node.t option;
error : Core.Error.t option;
label : Virtual_dom.Vdom.Node.t option;
}
type append_item = Bonsai_web_ui_form_view.append_item =
| Append_info of {
append : unit Virtual_dom.Vdom.Effect.t;
text : string option;
}
| Append_view of Virtual_dom.Vdom.Node.t
type remove_item = Bonsai_web_ui_form_view.remove_item =
| Remove_info of {
remove : unit Virtual_dom.Vdom.Effect.t;
element_label : (delete_button:Virtual_dom.Vdom.Node.t -> int -> Virtual_dom.Vdom.Node.t) option;
}
| Remove_view of Virtual_dom.Vdom.Node.t
and view = Bonsai_web_ui_form_view.view =
| Empty
| Collapsible of collapsible
| Raw of raw
| Record of field list
| Variant of variant
| List of list_view
| Tuple of t list
| Option of option_view
and raw = Bonsai_web_ui_form_view.raw = {
id : string;
raw_view : context -> editable:editable -> Virtual_dom.Vdom.Node.t;
}
and collapsible = Bonsai_web_ui_form_view.collapsible = {
collapse_label : Virtual_dom.Vdom.Node.t;
state : collapsed_state;
}
and option_view = Bonsai_web_ui_form_view.option_view = {
toggle : Virtual_dom.Vdom.Node.t;
status : option_status;
}
and list_view = Bonsai_web_ui_form_view.list_view = {
list_items : list_item list;
append_item : append_item;
}
and list_item = Bonsai_web_ui_form_view.list_item = {
item_view : t;
remove_item : remove_item;
}
and variant = Bonsai_web_ui_form_view.variant = {
clause_selector : Virtual_dom.Vdom.Node.t;
selected_clause : clause option;
}
of_vdom'
is like of_vdom
, but allows access to some extra metadata that is stored in the form's view.
record
combines a list of fields (field names and their corresponding views) into a view representing a record with those fields.
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.
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 toSome _
andview
represents the form for the type in the option.Currently_none None
if the toggle is set toNone
and we shouldn't show any view for theNone
caseCurrently_none (Some view)
if the toggle is set toNone
and we want to displayview
when the toggle is set toNone
(e.g. displaying a greyed out textbox)
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 subformCollapsed (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 andview
is the subform to show
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 withremove
being scheduled on click andelement_label
being called to generate the label for this element.Remove_view view
in which caseview
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 withappend
being scheduled on click andtext
being the text for the buttonAppend_view view
in which caseview
will be used as the append button
val with_fieldset :
currently_editable:bool ->
Virtual_dom.Vdom.Node.t ->
Virtual_dom.Vdom.Node.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