@@ -4,7 +4,7 @@ import { repeat } from "lit/directives/repeat.js";
44import { classMap } from "lit/directives/class-map.js" ;
55
66// Import Internal Dependencies
7- import { currentLang } from "../../common/utils.js" ;
7+ import * as utils from "../../common/utils.js" ;
88import {
99 FLAG_LIST ,
1010 SIZE_PRESETS ,
@@ -23,10 +23,29 @@ const kListTitleKeys = {
2323} ;
2424
2525/**
26- * @param {{ linker: Map, queries: Array, inputValue: string, onAdd: Function, onRemove: Function } } props
26+ * @returns {Record<string, string> }
27+ */
28+ function getSearchCommandI18n ( ) {
29+ return /** @type {Record<string, string> } */ ( /** @type {unknown } */ ( utils . getI18n ( ) . search_command ) ) ;
30+ }
31+
32+ /**
33+ * @typedef {import("@nodesecure/vis-network").LinkerEntry } LinkerEntry
34+ * @typedef {{ filter: string, value: string } } SearchQuery
35+ * @typedef {{ display: string, value: string, hint?: string } } HelperValue
36+ */
37+
38+ /**
39+ * @param {{
40+ * linker: Map<number, LinkerEntry>,
41+ * queries: SearchQuery[],
42+ * inputValue: string,
43+ * onAdd: (filter: string, value: string) => void,
44+ * onRemove: (filter: string, value: string) => void
45+ * }} props
2746 */
2847export function renderFlagPanel ( { linker, queries, inputValue, onAdd, onRemove } ) {
29- const i18n = window . i18n [ currentLang ( ) ] . search_command ;
48+ const i18n = getSearchCommandI18n ( ) ;
3049 const flagCounts = getFlagCounts ( linker ) ;
3150 const activeFlags = new Set (
3251 queries
@@ -65,10 +84,10 @@ export function renderFlagPanel({ linker, queries, inputValue, onAdd, onRemove }
6584}
6685
6786/**
68- * @param {{ activeFilter: string, onAdd: Function } } props
87+ * @param {{ activeFilter: string, onAdd: (filter: string, value: string) => void } } props
6988 */
7089export function renderRangePanel ( { activeFilter, onAdd } ) {
71- const i18n = window . i18n [ currentLang ( ) ] . search_command ;
90+ const i18n = getSearchCommandI18n ( ) ;
7291 const isSizeFilter = activeFilter === "size" ;
7392 const presets = isSizeFilter ? SIZE_PRESETS : VERSION_PRESETS ;
7493 const title = isSizeFilter ? i18n . section_size : i18n . section_version ;
@@ -93,12 +112,19 @@ export function renderRangePanel({ activeFilter, onAdd }) {
93112}
94113
95114/**
96- * @param {{ linker: Map, activeFilter: string, helpers: Array, selectedIndex: number, onAdd: Function } } props
115+ * @param {{
116+ * linker: Map<number, LinkerEntry>,
117+ * activeFilter: string,
118+ * helpers: HelperValue[],
119+ * selectedIndex: number,
120+ * onAdd: (filter: string, value: string) => void
121+ * }} props
97122 */
98123export function renderListPanel ( { linker, activeFilter, helpers, selectedIndex, onAdd } ) {
99- const i18n = window . i18n [ currentLang ( ) ] . search_command ;
124+ const i18n = getSearchCommandI18n ( ) ;
100125 const counts = getFilterValueCounts ( linker , activeFilter ) ;
101- const title = i18n [ kListTitleKeys [ activeFilter ] ] ?? activeFilter ;
126+ const titleI18nKey = /** @type {Record<string, string> } */ ( kListTitleKeys ) [ activeFilter ] ;
127+ const title = i18n [ titleI18nKey ] ?? activeFilter ;
102128
103129 return html `
104130 < div class ="section ">
@@ -117,10 +143,10 @@ export function renderListPanel({ linker, activeFilter, helpers, selectedIndex,
117143}
118144
119145/**
120- * @param {{ helpers: Array , selectedIndex: number, onSelect: Function } } props
146+ * @param {{ helpers: HelperValue[] , selectedIndex: number, onSelect: (helper: HelperValue) => void } } props
121147 */
122148export function renderFilterList ( { helpers, selectedIndex, onSelect } ) {
123- const i18n = window . i18n [ currentLang ( ) ] . search_command ;
149+ const i18n = getSearchCommandI18n ( ) ;
124150
125151 return html `
126152 < div class ="section ">
@@ -138,10 +164,13 @@ export function renderFilterList({ helpers, selectedIndex, onSelect }) {
138164}
139165
140166/**
141- * @param {{ presets: Array, onApply: Function } } props
167+ * @param {{
168+ * presets: { id: string, filter: string, value: string }[],
169+ * onApply: (preset: { id: string, filter: string, value: string }) => void
170+ * }} props
142171 */
143172export function renderPresets ( { presets, onApply } ) {
144- const i18n = window . i18n [ currentLang ( ) ] . search_command ;
173+ const i18n = getSearchCommandI18n ( ) ;
145174
146175 return html `
147176 < div class ="section ">
@@ -161,10 +190,13 @@ export function renderPresets({ presets, onApply }) {
161190}
162191
163192/**
164- * @param {{ actions: Array<{ id: string, label: string, kbd: string|null }>, onExecute: Function } } props
193+ * @param {{
194+ * actions: { id: string, label: string, kbd: string|null }[],
195+ * onExecute: (action: { id: string, label: string, kbd: string|null }) => void
196+ * }} props
165197 */
166198export function renderActions ( { actions, onExecute } ) {
167- const i18n = window . i18n [ currentLang ( ) ] . search_command ;
199+ const i18n = getSearchCommandI18n ( ) ;
168200
169201 return html `
170202 < div class ="section ">
@@ -214,14 +246,19 @@ export function renderIgnorePanel({ title, items, ignored, onToggle }) {
214246}
215247
216248/**
217- * @param {{ results: Array, selectedIndex: number, helperCount: number, onFocus: Function } } props
249+ * @param {{
250+ * results: { id: string, flags: string, name: string, version: string }[],
251+ * selectedIndex: number,
252+ * helperCount: number,
253+ * onFocus: (id: string) => void
254+ * }} props
218255 */
219256export function renderResults ( { results, selectedIndex, helperCount, onFocus } ) {
220257 if ( results . length === 0 ) {
221258 return nothing ;
222259 }
223260
224- const i18n = window . i18n [ currentLang ( ) ] . search_command ;
261+ const i18n = getSearchCommandI18n ( ) ;
225262
226263 return html `
227264 < div class ="section ">
0 commit comments