diff --git a/src/myfasthtml/controls/HierarchicalCanvasGraph.py b/src/myfasthtml/controls/HierarchicalCanvasGraph.py
index aaa31b2..6fe8d7f 100644
--- a/src/myfasthtml/controls/HierarchicalCanvasGraph.py
+++ b/src/myfasthtml/controls/HierarchicalCanvasGraph.py
@@ -153,43 +153,6 @@ class HierarchicalCanvasGraph(MultipleInstance):
"""
return self._state
- # def get_selected_id(self) -> Optional[str]:
- # """Get the currently selected node ID.
- #
- # Returns:
- # str or None: The selected node ID, or None if no selection
- # """
- # return self._state.ns_selected_id
- #
- # def set_collapsed(self, node_ids: set):
- # """Set the collapsed state of nodes.
- #
- # Args:
- # node_ids: Set of node IDs to mark as collapsed
- # """
- # self._state.collapsed = list(node_ids)
- # logger.debug(f"set_collapsed: {len(node_ids)} nodes collapsed")
- #
- # def toggle_node(self, node_id: str):
- # """Toggle the collapsed state of a node.
- #
- # Args:
- # node_id: The ID of the node to toggle
- #
- # Returns:
- # self: For chaining
- # """
- # collapsed_set = set(self._state.collapsed)
- # if node_id in collapsed_set:
- # collapsed_set.remove(node_id)
- # logger.debug(f"toggle_node: expanded {node_id}")
- # else:
- # collapsed_set.add(node_id)
- # logger.debug(f"toggle_node: collapsed {node_id}")
- #
- # self._state.collapsed = list(collapsed_set)
- # return self
-
def handle_update_view_state(self, transform: Optional[dict] = None, layout_mode: Optional[str] = None):
"""Internal handler to update view state from client.
diff --git a/src/myfasthtml/controls/helpers.py b/src/myfasthtml/controls/helpers.py
index 90308a6..41e65ae 100644
--- a/src/myfasthtml/controls/helpers.py
+++ b/src/myfasthtml/controls/helpers.py
@@ -1,6 +1,7 @@
import pandas as pd
from fasthtml.components import *
+from myfasthtml.controls.IconsHelper import IconsHelper
from myfasthtml.core.bindings import Binding
from myfasthtml.core.commands import Command, CommandTemplate
from myfasthtml.core.constants import ColumnType
@@ -48,7 +49,7 @@ class mk:
)
@staticmethod
- def icon(icon,
+ def icon(icon=None,
size=20,
can_select=True,
can_hover=False,
@@ -83,12 +84,14 @@ class mk:
'flex items-center justify-center',
cls,
kwargs)
+ icon_to_use = icon or (command.icon if command else IconsHelper.get("QuestionMark"))
+ tooltip = tooltip or (command.description if command else None)
if tooltip:
merged_cls = merge_classes(merged_cls, "mf-tooltip")
kwargs["data-tooltip"] = tooltip
- return mk.mk(Div(icon, cls=merged_cls, **kwargs), command=command, binding=binding)
+ return mk.mk(Div(icon_to_use, cls=merged_cls, **kwargs), command=command, binding=binding)
@staticmethod
def label(text: str,