HoopsTypesTreeElement

class wvc.HoopsTypesTreeElement()

Provides a specialized tree component for displaying model type hierarchies with lazy loading and selection.

This component relies on TypesTreeAdapter and hoops-tree for its functionality. The tree nodes are lazy loaded for better performance and memory consumption, especially during initial loading. Expansion and selection are handled automatically by the underlying hoops-tree component.

The component has no reactive properties but provides methods and getters/setters to interact with the tree state. To set the model, assign it to the model property and it will update automatically.

Constructors

wvc.HoopsTypesTreeElement.constructor()
HoopsTypesTreeElement(): HoopsTypesTreeElement

Returns: HoopsTypesTreeElement

Properties

wvc.HoopsTypesTreeElement.styles

static

styles: CSSResult[]

Array of styles to apply to the element. The styles should be defined using the ? tag function, via constructible stylesheets, or imported from native CSS module scripts.

Note on Content Security Policy:

Element styles are implemented with <style> tags when the browser doesn’t support adopted StyleSheets. To use such <style> tags with the style-src CSP directive, the style-src value must either include ‘unsafe-inline’ or nonce-<base64-value> with <base64-value> replaced be a server-generated nonce.

To provide a nonce to use on generated <style> elements, set window.litNonce to a server-generated nonce in your page’s HTML, before loading application code:

<script>
  // Generated and unique per request:
  window.litNonce = 'a1b2c3d4';
</script>

Accessors

wvc.HoopsTypesTreeElement.model()
get model(): (undefined | IModel)

Gets or sets the IModel interface that represents the Model being displayed.

This is syntactic sugar to access the TypesTreeAdapter’s model property. If the TypesTreeAdapter is not set, getter returns undefined. Reassigning the model will trigger a tree reset and update automatically.

Note: Trying to set the model while the TypesTreeAdapter is not available will throw an error. This should not happen in normal use cases since the TypesTreeAdapter is added at initialization.

Returns: (undefined | IModel)

The model instance or undefined if not available
set model(model: (undefined | IModel)): void

Parameters

model: (undefined | IModel)

Returns: void

wvc.HoopsTypesTreeElement.selected()
get selected(): number[]

Gets or sets the selected nodes in the tree.

This is a syntactic sugar to access the underlying Tree’s selected property. If the Tree element is not set, getter returns an empty array. Reassigning the selected array will trigger a reactive update.

Note: Trying to set selected nodes while the tree element is not available will throw an error. This should not happen in normal use cases since the tree is added at initialization.

Returns: number[]

Array of selected node IDs
set selected(value: number[]): void

Parameters

value: number[]

Returns: void

wvc.HoopsTypesTreeElement.treeElement()
get treeElement(): (undefined | Tree)

Gets the underlying Tree element.

Returns: (undefined | Tree)

The tree element instance or undefined if not available
wvc.HoopsTypesTreeElement.typesTreeAdapter()
get typesTreeAdapter(): (undefined | TypesTreeAdapter)

Gets or sets the TypesTreeAdapter that manages tree data and operations.

This provides syntactic sugar to access the underlying tree’s context adapter. If the Tree element is not set, getter returns undefined. Reassigning the TypesTreeAdapter will trigger a reactive update.

Note: Trying to set the TypesTreeAdapter while the tree element is not available will throw an error. This should not happen in normal use cases since the tree is added at initialization.

Returns: (undefined | TypesTreeAdapter)

The TypesTreeAdapter instance or undefined if not available
set typesTreeAdapter(value: TypesTreeAdapter): void

Parameters

value: TypesTreeAdapter

Returns: void

Methods

wvc.HoopsTypesTreeElement.getNodeData()
getNodeData(nodeId: number): T

Retrieves custom data attached to a specific node.

This allows users to attach reactive data to tree nodes. If the TypesTreeAdapter does not exist, it will throw an Error. Otherwise it will return the stored data for the specified node, if any.

Parameters

nodeId: number

The ID of the node to get data for

Returns: T

The custom data stored for the node
wvc.HoopsTypesTreeElement.selectNodes()
selectNodes(nodeIds: number[], selected: boolean): void

Selects or deselects nodes in the tree.

Parameters

nodeIds: number[]

Array of node IDs to select or deselect

selected: boolean

Whether to select (true) or deselect (false) the nodes

Returns: void

wvc.HoopsTypesTreeElement.setNodeData()
setNodeData(nodeId: number, data: unknown): void

Sets custom data for a specific node, replacing any existing data.

If the node already has a value, it will be erased and replaced with the new data. Setting node data will trigger a reactive update of the tree component.

Parameters

nodeId: number

The ID of the node to set data for

data: unknown

The data to store for the node

Returns: void

wvc.HoopsTypesTreeElement.updateNodeData()
updateNodeData(nodeId: number, data: unknown): void

Merges custom data into a node’s existing data instead of replacing it.

If the node does not have existing data, the new data is added to the context. The merge behavior depends on data types:

  • If both existing and new data are arrays: new data is appended to the existing array
  • If both are objects: objects are merged using Object.assign, with new data taking precedence
  • Otherwise: equivalent to calling setNodeData (replaces existing data)

Updating node data will trigger a reactive update of the tree component.

Parameters

nodeId: number

The ID of the node to update data for

data: unknown

The data to merge with existing node data

Returns: void

wvc.HoopsTypesTreeElement.updateVisibility()
updateVisibility(_shownBodyIds: number[], _hiddenBodyIds: number[]): void

Updates the visibility state of all nodes in the tree.

This method refreshes the visibility for all node elements by:

  • For individual model nodes: retrieving visibility from the model’s getBranchVisibility method
  • For type nodes: using stored visibility data from nodesData or defaulting to ‘Shown’

Note: The parameters are currently unused in the implementation but maintained for API compatibility.

Parameters

_shownBodyIds: number[]

Array of node IDs to mark as visible (currently unused)

_hiddenBodyIds: number[]

Array of node IDs to mark as hidden (currently unused)

Returns: void

wvc.HoopsTypesTreeElement.render()
render(): unknown

Renders the component template.

Returns: unknown

The HTML template for the component