@@ -14,7 +14,8 @@ interface IQueryTemplateProps {
14
14
}
15
15
16
16
const labels = {
17
- searchPlaceholder : "Search queries..."
17
+ searchPlaceholder : "Search queries" ,
18
+ headerTitle : "Queries"
18
19
}
19
20
const highlightClassName = "pg-highlighted-text" ;
20
21
@@ -78,56 +79,90 @@ const PgQueryTemplate = ({ onClose }: IQueryTemplateProps) => {
78
79
}
79
80
} ;
80
81
82
+ const handleSidebarItemClick = ( categoryId : string ) => {
83
+ const element = document . getElementById ( `category-${ categoryId } ` ) ;
84
+ if ( element ) {
85
+ // For browsers that don't support smooth scrolling
86
+ try {
87
+ element . scrollIntoView ( { behavior : 'smooth' , block : 'start' } ) ;
88
+ } catch ( e ) {
89
+ // Fallback for older browsers
90
+ element . scrollIntoView ( true ) ;
91
+ }
92
+ }
93
+ } ;
94
+
81
95
return < div className = "pg-query-template" >
82
- < div className = "query-search-bar-container" >
83
- < div className = "query-search-bar" >
84
- { /* <i className="fa fa-search"></i> */ }
85
- < ImageIcon imgSrc = "/icons/search.svg" alt = { labels . searchPlaceholder } imgWidth = "1.125rem" imgHeight = "1.125rem" />
86
- < input type = "text" placeholder = { labels . searchPlaceholder } onChange = { handleSearchChange } className = "query-search-input" value = { searchValue } />
87
- { searchValue && < i className = "fa fa-times clear-icon" onClick = { handleClearSearch } > </ i > }
96
+ < div className = "pg-query-template-header" >
97
+ < div className = "pg-query-template-header-title font-medium" >
98
+ { labels . headerTitle }
88
99
</ div >
100
+ < Loader isShow = { isShowLoader } />
89
101
</ div >
90
- < Loader isShow = { isShowLoader } />
91
-
92
- < div className = "query-category-container" >
93
- { filteredTemplateData . map ( ( queryTmpl , index ) => (
94
- < div key = { index } className = "query-category" >
95
- < div className = "query-category-title font-medium" >
96
- < Highlighter
97
- highlightClassName = { highlightClassName }
98
- searchWords = { [ searchValue ] }
99
- autoEscape = { true }
100
- textToHighlight = { queryTmpl . category }
101
- />
102
+ < div className = "pg-query-template-content" >
103
+ < div className = "query-sidebar" >
104
+ < div className = "query-search-bar-container" >
105
+ < div className = "query-search-bar" >
106
+ { /* <i className="fa fa-search"></i> */ }
107
+ < ImageIcon imgSrc = "/icons/search.svg" alt = { labels . searchPlaceholder } imgWidth = "1.125rem" imgHeight = "1.125rem" />
108
+ < input type = "text" placeholder = { labels . searchPlaceholder } onChange = { handleSearchChange } className = "query-search-input" value = { searchValue } />
109
+ { searchValue && < i className = "fa fa-times clear-icon" onClick = { handleClearSearch } > </ i > }
102
110
</ div >
103
- < div className = "query-category-items" >
104
- { queryTmpl . items . map ( ( item , index ) => (
105
- < div key = { index } className = "query-item" onClick = { ( ) => handleQueryItemClick ( item . queryId , queryTmpl . categoryId ) } >
106
- < div className = "query-item-label font-medium" >
107
- < Highlighter
108
- highlightClassName = { highlightClassName }
109
- searchWords = { [ searchValue ] }
110
- autoEscape = { true }
111
- textToHighlight = { item . label }
112
- />
113
- </ div >
114
- < div className = "query-item-description" >
115
- < Highlighter
116
- highlightClassName = { highlightClassName }
117
- searchWords = { [ searchValue ] }
118
- autoEscape = { true }
119
- textToHighlight = { item . description }
120
- />
121
- </ div >
111
+ </ div >
112
+ < div className = "query-sidebar-content" >
113
+ { filteredTemplateData . map ( ( queryTmpl , index ) => (
114
+ < div key = { index } className = "query-sidebar-item" onClick = { ( ) => handleSidebarItemClick ( queryTmpl . categoryId ) } >
115
+ < div className = "query-sidebar-item-label" >
116
+ { queryTmpl . category }
122
117
</ div >
123
- ) ) }
124
- </ div >
118
+ < ImageIcon imgSrc = "/icons/arrow-right-slim-red.svg" alt = { queryTmpl . category } />
119
+ </ div >
120
+
121
+ ) ) }
122
+
125
123
</ div >
126
- ) ) }
124
+ </ div >
125
+ < div className = "query-category-container" >
126
+ { filteredTemplateData . map ( ( queryTmpl , index ) => (
127
+ < div key = { index } className = "query-category" id = { `category-${ queryTmpl . categoryId } ` } >
128
+ < div className = "query-category-title font-medium" >
129
+ < Highlighter
130
+ highlightClassName = { highlightClassName }
131
+ searchWords = { [ searchValue ] }
132
+ autoEscape = { true }
133
+ textToHighlight = { queryTmpl . category }
134
+ />
135
+ </ div >
136
+ < div className = "query-category-items" >
137
+ { queryTmpl . items . map ( ( item , index ) => (
138
+ < div key = { index } className = "query-item" onClick = { ( ) => handleQueryItemClick ( item . queryId , queryTmpl . categoryId ) } >
139
+ < div className = "query-item-label font-medium" >
140
+ < Highlighter
141
+ highlightClassName = { highlightClassName }
142
+ searchWords = { [ searchValue ] }
143
+ autoEscape = { true }
144
+ textToHighlight = { item . label }
145
+ />
146
+ </ div >
147
+ < div className = "query-item-description" >
148
+ < Highlighter
149
+ highlightClassName = { highlightClassName }
150
+ searchWords = { [ searchValue ] }
151
+ autoEscape = { true }
152
+ textToHighlight = { item . description }
153
+ />
154
+ </ div >
155
+ </ div >
156
+ ) ) }
157
+ </ div >
158
+ </ div >
159
+ ) ) }
127
160
128
- { filteredTemplateData . length === 0 && ! isShowLoader && < div className = "query-no-result" > No matching queries found !</ div > }
161
+ { filteredTemplateData . length === 0 && ! isShowLoader && < div className = "query-no-result" > No matching queries found !</ div > }
129
162
163
+ </ div >
130
164
</ div >
165
+
131
166
</ div >
132
167
}
133
168
0 commit comments