@@ -27,6 +27,8 @@ const emit = defineEmits<{
2727 ' toggleKeyword' : [keyword : string ]
2828}>()
2929
30+ const { t } = useI18n ()
31+
3032const isExpanded = shallowRef (false )
3133const showAllKeywords = shallowRef (false )
3234
@@ -55,62 +57,77 @@ const hasMoreKeywords = computed(() => {
5557})
5658
5759// i18n mappings for filter options
58- const scopeLabelKeys = {
59- name: ' filters.scope_name' ,
60- description: ' filters.scope_description' ,
61- keywords: ' filters.scope_keywords' ,
62- all: ' filters.scope_all' ,
63- } as const
64-
65- const scopeDescriptionKeys = {
66- name: ' filters.scope_name_description' ,
67- description: ' filters.scope_description_description' ,
68- keywords: ' filters.scope_keywords_description' ,
69- all: ' filters.scope_all_description' ,
70- } as const
71-
72- const downloadRangeLabelKeys = {
73- ' any' : ' filters.download_range.any' ,
74- ' lt100' : ' filters.download_range.lt100' ,
75- ' 100-1k' : ' filters.download_range.100_1k' ,
76- ' 1k-10k' : ' filters.download_range.1k_10k' ,
77- ' 10k-100k' : ' filters.download_range.10k_100k' ,
78- ' gt100k' : ' filters.download_range.gt100k' ,
79- } as const
80-
81- const updatedWithinLabelKeys = {
82- any: ' filters.updated.any' ,
83- week: ' filters.updated.week' ,
84- month: ' filters.updated.month' ,
85- quarter: ' filters.updated.quarter' ,
86- year: ' filters.updated.year' ,
87- } as const
88-
89- const securityLabelKeys = {
90- all: ' filters.security_options.all' ,
91- secure: ' filters.security_options.secure' ,
92- warnings: ' filters.security_options.insecure' ,
93- } as const
60+ const scopeLabelKeys = computed (
61+ () =>
62+ ({
63+ name: t (' filters.scope_name' ),
64+ description: t (' filters.scope_description' ),
65+ keywords: t (' filters.scope_keywords' ),
66+ all: t (' filters.scope_all' ),
67+ }) as const ,
68+ )
69+
70+ const scopeDescriptionKeys = computed (
71+ () =>
72+ ({
73+ name: t (' filters.scope_name_description' ),
74+ description: t (' filters.scope_description_description' ),
75+ keywords: t (' filters.scope_keywords_description' ),
76+ all: t (' filters.scope_all_description' ),
77+ }) as const ,
78+ )
79+
80+ const downloadRangeLabelKeys = computed (
81+ () =>
82+ ({
83+ ' any' : t (' filters.download_range.any' ),
84+ ' lt100' : t (' filters.download_range.lt100' ),
85+ ' 100-1k' : t (' filters.download_range.100_1k' ),
86+ ' 1k-10k' : t (' filters.download_range.1k_10k' ),
87+ ' 10k-100k' : t (' filters.download_range.10k_100k' ),
88+ ' gt100k' : t (' filters.download_range.gt100k' ),
89+ }) as const ,
90+ )
91+
92+ const updatedWithinLabelKeys = computed (
93+ () =>
94+ ({
95+ any: t (' filters.updated.any' ),
96+ week: t (' filters.updated.week' ),
97+ month: t (' filters.updated.month' ),
98+ quarter: t (' filters.updated.quarter' ),
99+ year: t (' filters.updated.year' ),
100+ }) as const ,
101+ )
102+
103+ const securityLabelKeys = computed (
104+ () =>
105+ ({
106+ all: t (' filters.security_options.all' ),
107+ secure: t (' filters.security_options.secure' ),
108+ warnings: t (' filters.security_options.insecure' ),
109+ }) as const ,
110+ )
94111
95112// Type-safe accessor functions
96113function getScopeLabelKey(value : SearchScope ): string {
97- return scopeLabelKeys [value ]
114+ return scopeLabelKeys . value [value ]
98115}
99116
100117function getScopeDescriptionKey(value : SearchScope ): string {
101- return scopeDescriptionKeys [value ]
118+ return scopeDescriptionKeys . value [value ]
102119}
103120
104121function getDownloadRangeLabelKey(value : DownloadRange ): string {
105- return downloadRangeLabelKeys [value ]
122+ return downloadRangeLabelKeys . value [value ]
106123}
107124
108125function getUpdatedWithinLabelKey(value : UpdatedWithin ): string {
109- return updatedWithinLabelKeys [value ]
126+ return updatedWithinLabelKeys . value [value ]
110127}
111128
112129function getSecurityLabelKey(value : SecurityFilter ): string {
113- return securityLabelKeys [value ]
130+ return securityLabelKeys . value [value ]
114131}
115132
116133function handleTextInput(event : Event ) {
@@ -215,10 +232,10 @@ const hasActiveFilters = computed(() => !!filterSummary.value)
215232 : 'text-fg-muted hover:text-fg'
216233 "
217234 :aria-pressed =" filters.searchScope === scope"
218- :title =" $t( getScopeDescriptionKey(scope) )"
235+ :title =" getScopeDescriptionKey(scope)"
219236 @click =" emit('update:searchScope', scope)"
220237 >
221- {{ $t( getScopeLabelKey(scope) ) }}
238+ {{ getScopeLabelKey(scope) }}
222239 </button >
223240 </div >
224241 </div >
@@ -251,7 +268,7 @@ const hasActiveFilters = computed(() => !!filterSummary.value)
251268 @update:modelValue =" emit('update:downloadRange', $event as DownloadRange)"
252269 name =" range"
253270 >
254- {{ $t( getDownloadRangeLabelKey(range.value) ) }}
271+ {{ getDownloadRangeLabelKey(range.value) }}
255272 </TagRadioButton >
256273 </div >
257274 </fieldset >
@@ -274,7 +291,7 @@ const hasActiveFilters = computed(() => !!filterSummary.value)
274291 name =" updatedWithin"
275292 @update:modelValue =" emit('update:updatedWithin', $event as UpdatedWithin)"
276293 >
277- {{ $t( getUpdatedWithinLabelKey(option.value) ) }}
294+ {{ getUpdatedWithinLabelKey(option.value) }}
278295 </TagRadioButton >
279296 </div >
280297 </fieldset >
@@ -296,7 +313,7 @@ const hasActiveFilters = computed(() => !!filterSummary.value)
296313 :value =" security"
297314 name =" security"
298315 >
299- {{ $t( getSecurityLabelKey(security) ) }}
316+ {{ getSecurityLabelKey(security) }}
300317 </TagRadioButton >
301318 </div >
302319 </fieldset >
0 commit comments