Module Skyline_tree_v1Source

Sourcemodule Layout : sig ... end
Sourcemodule Decoration : sig ... end
Sourcemodule Path : sig ... end
Sourceval component : ?collapsed: (Path.Set.t Bonsai_web.Bonsai.t * (Path.t -> unit Bonsai_web.Effect.t) Bonsai_web.Bonsai.t) -> ?layout:Layout.t Bonsai_web.Bonsai.t -> ?merge_empty_paths:bool -> ?compare_path:(Path.t -> Path.t -> int) -> ?compare:('a -> 'a -> int) -> ?filter:string Bonsai_web.Bonsai.t -> ?to_item_text:(Path.t -> 'a -> string) -> ?on_click: (Path.t -> 'a option -> unit Bonsai_web.Effect.t option) Bonsai_web.Bonsai.t -> ?disabled:(Path.t -> 'a option -> bool) Bonsai_web.Bonsai.t -> ?on_contextmenu: (Path.t -> 'a option -> unit Skyline_context_menu_v1.t Bonsai_web.Effect.t) Bonsai_web.Bonsai.t -> ?highlight:Path.t Bonsai_web.Bonsai.t -> ?decoration:(Path.t -> 'a option -> Decoration.t) -> ?alternating_row_background:bool -> ?disable_keyboard_navigation:bool -> ?has_external_children:(Path.t -> 'a -> bool) -> ?segment: (Path.t Bonsai_web.Bonsai.t -> Path.Segment.t Bonsai_web.Bonsai.t -> Bonsai_web.Bonsai.graph @ local -> Bonsai_web.Vdom.Node.t Bonsai_web.Bonsai.t) -> ?item: (Path.t Bonsai_web.Bonsai.t -> Path.Segment.t Bonsai_web.Bonsai.t -> 'a Bonsai_web.Bonsai.t -> Bonsai_web.Bonsai.graph @ local -> Bonsai_web.Vdom.Node.t Bonsai_web.Bonsai.t) -> 'a Path.Map.t Bonsai_web.Bonsai.t -> Bonsai_web.Bonsai.graph @ local -> Bonsai_web.Vdom.Node.t Bonsai_web.Bonsai.t

A tree view that renders a map of items keyed by / separated paths.

Options to configure the tree views behaviour

  • The default layout renders the items arranged as a tree, which children indented under their parents. There is also an alternative list layout.
  • If filter is provided, items in the tree are filtered and search-ranked by the full path, including non-leaf path segments. Also see to_item_text to override leaf node text content for filtering.
  • By default, items are sorted based on their path. Custom compare and compare_path arguments can be used to override the sort behaviour. Branches with items are sorted according to compare, and if a branch does not have an associated item (or if compare is not provided) the branch is sorted according to compare_path.

By default, compare_path is Path.compare.

  • on_click and on_contextmenu handlers can also be provided to trigger actions when the tree items are interacted with by the user. If no on_click action is provided, or on_click resolves to None, the default action collapses child elements in the tree when a parent is clicked.
  • disabled disables row interactions. Disabled rows do not run on_click, on_contextmenu, cannot be collapsed or uncollapsed, cannot take focus, and are skipped by keyboard navigation. Disabled styling is left up to item.

Options to configure the tree view visually

  • merge_empty_paths controls if the tree view combines consecutive parents which only have one child into a single row.
  • If highlight is provided, the item at the given path will be highlighted in the rendered tree.
  • segment and item can be used to change the apperance of row contents are rendered. The default simply renders the path segment for the given row in the tree using Path.Segment.component.

item is used to render rows in the tree that correspond to a given element in the map.

  • to_item_text overrides the text content of the leaf nodes (items) for filtering and for the default display (via Path.Segment.component), but *not* comparison. Supports matching substring highlighting nicely when filtering. Can be used instead of ~item if you only want to tweak display text

segment is used to render rows in the tree that don't have a corresponding map element i.e. rows that only exist to structure the tree.

  • has_external_children indicates that an item has children not present in the map. Items for which has_external_children path item returns true are rendered as collapsible parent nodes (with a caret) even if they have no children in the map. This is only consulted for items that have no children in the map; items that already have children are always rendered as parents regardless. This is useful when children are loaded lazily or filtered server-side. Note that external children can't be considered in search-based fuzzy filtering and ordering.