[TS] Fix TreeExplorerNode types (#3163)

This commit is contained in:
Chenlei Hu
2025-03-20 11:47:04 -04:00
committed by GitHub
parent c34cc301f1
commit b162963593
3 changed files with 14 additions and 9 deletions

View File

@@ -136,14 +136,13 @@ const renderedRoot = computed<TreeExplorerNode<ModelOrFolder>>(() => {
}
return 'pi pi-folder'
},
// @ts-expect-error fixme ts strict error
getBadgeText() {
// Return null to apply default badge text
// Return undefined to apply default badge text
// Return empty string to hide badge
if (!folder) {
return null
return
}
return folder.state === ResourceState.Loaded ? null : ''
return folder.state === ResourceState.Loaded ? undefined : ''
},
children,
draggable: node.leaf,

View File

@@ -117,7 +117,6 @@ const renderedRoot = computed<TreeExplorerNode<ComfyNodeDefImpl>>(() => {
// @ts-expect-error fixme ts strict error
leaf: node.leaf,
data: node.data,
// @ts-expect-error fixme ts strict error
getIcon() {
if (this.leaf) {
return 'pi pi-circle-fill'

View File

@@ -8,10 +8,17 @@ export interface TreeExplorerNode<T = any> {
data?: T
children?: TreeExplorerNode<T>[]
icon?: string
/** Function to override what icon to use for the node */
getIcon?: (this: TreeExplorerNode<T>) => string
/** Function to override what text to use for the leaf-count badge on a folder node */
getBadgeText?: (this: TreeExplorerNode<T>) => string
/**
* Function to override what icon to use for the node.
* Return undefined to fallback to {@link icon} property.
*/
getIcon?: (this: TreeExplorerNode<T>) => string | undefined
/**
* Function to override what text to use for the leaf-count badge on a folder node.
* Return undefined to fallback to default badge text, which is the subtree's leaf count.
* Return empty string to hide the badge.
*/
getBadgeText?: (this: TreeExplorerNode<T>) => string | undefined
/** Function to handle renaming the node */
handleRename?: (
this: TreeExplorerNode<T>,