@@ -7,35 +7,30 @@ import type { IBaseWidget } from '@/lib/litegraph/src/types/widgets'
77import SidePanelSearch from ' ../layout/SidePanelSearch.vue'
88import SectionWidgets from ' ./SectionWidgets.vue'
99
10- const props = defineProps <{
10+ const { nodes } = defineProps <{
1111 nodes: LGraphNode []
1212}>()
1313
14- const widgetsSectionDataList = computed (() => {
15- const list: {
16- widgets: { node: LGraphNode ; widget: IBaseWidget }[]
17- node: LGraphNode
18- }[] = []
19- for (const node of props .nodes ) {
20- const shownWidgets: IBaseWidget [] = []
21- for (const widget of node .widgets ?? []) {
22- if (widget .options ?.canvasOnly || widget .options ?.hidden ) continue
23- shownWidgets .push (widget )
24- }
25- list .push ({
26- widgets: shownWidgets ?.map ((widget ) => ({ node , widget })) ?? [],
14+ type NodeWidgetsList = Array <{ node: LGraphNode ; widget: IBaseWidget }>
15+ type NodeWidgetsListList = Array <{
16+ node: LGraphNode
17+ widgets: NodeWidgetsList
18+ }>
19+
20+ const widgetsSectionDataList = computed ((): NodeWidgetsListList => {
21+ return nodes .map ((node ) => {
22+ const { widgets = [] } = node
23+ const shownWidgets = widgets
24+ .filter ((w ) => ! (w .options ?.canvasOnly || w .options ?.hidden ))
25+ .map ((widget ) => ({ node , widget }))
26+ return {
27+ widgets: shownWidgets ,
2728 node
28- })
29- }
30- return list
29+ }
30+ })
3131})
3232
33- const searchedWidgetsSectionDataList = shallowRef <
34- {
35- widgets : { node : LGraphNode ; widget : IBaseWidget }[]
36- node : LGraphNode
37- }[]
38- > ([])
33+ const searchedWidgetsSectionDataList = shallowRef <NodeWidgetsListList >([])
3934
4035/**
4136 * Searches widgets in all selected nodes and returns search results.
@@ -72,8 +67,8 @@ async function searcher(query: string) {
7267 </script >
7368
7469<template >
75- <div class =" p -4 flex gap-2 border-b border-interface-stroke" >
76- <SidePanelSearch :searcher :update-key =" widgetsSectionDataList " />
70+ <div class =" px-4 pb -4 flex gap-2 border-b border-interface-stroke" >
71+ <SidePanelSearch :searcher :update-key =" searchedWidgetsSectionDataList " />
7772 </div >
7873 <SectionWidgets
7974 v-for =" section in searchedWidgetsSectionDataList"
0 commit comments