Skip to content

Commit

Permalink
feat: create useSearch composable + custom filter on CategorySelector
Browse files Browse the repository at this point in the history
  • Loading branch information
wazolab authored and frodrigo committed Mar 7, 2024
1 parent faabf9a commit e1b1ca3
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 0 deletions.
16 changes: 16 additions & 0 deletions components/PoisList/CategorySelector.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
VListItemTitle,
} from 'vuetify/components/VList'
import { localeIncludes } from 'locale-includes'
import { defineNuxtComponent } from '#app'
import TeritorioIcon from '~/components/UI/TeritorioIcon.vue'
import type { ApiMenuCategory, MenuItem } from '~/lib/apiMenu'
Expand Down Expand Up @@ -42,6 +43,14 @@ export default defineNuxtComponent({
},
},
setup() {
const { locale } = useI18n()
return {
locale,
}
},
computed: {
menuEntries(): Array<{ value: number, title: string, category: ApiMenuCategory['category'] } | undefined> {
const locales = this.$i18n.locales
Expand Down Expand Up @@ -79,6 +88,12 @@ export default defineNuxtComponent({
.sort((a, b) => a && b ? a.title.localeCompare(b.title, localeCompareOptions) : -1)
},
},
methods: {
customFilter(item: string, query: string) {
return localeIncludes(item, query, { locales: this.locale, sensitivity: 'base' })
},
},
})
</script>

Expand All @@ -93,6 +108,7 @@ export default defineNuxtComponent({
variant="solo"
rounded
hide-details="auto"
:custom-filter="customFilter"
@update:model-value="$emit('categoryChange', $event)"
>
<template #prepend-inner>
Expand Down
1 change: 1 addition & 0 deletions declarations.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ declare module '*.svg?raw'
declare module 'vue-mobile-detection'
declare module 'vue-matomo'
declare module 'vue-cookie-accept-decline'
declare module 'locale-includes'
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"date-fns": "^2.30.0",
"fast-copy": "^3.0.1",
"fast-equals": "^5.0.1",
"locale-includes": "^1.0.6",
"lodash.debounce": "^4.0.8",
"lodash.throttle": "^4.1.1",
"lodash.uniq": "^4.5.0",
Expand Down
8 changes: 8 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3181,6 +3181,7 @@ __metadata:
json-loader: ^0.5.7
lint-staged: ^15.2.0
loader-utils: ^3.2.1
locale-includes: ^1.0.6
lodash.debounce: ^4.0.8
lodash.get: ^4.4.2
lodash.throttle: ^4.1.1
Expand Down Expand Up @@ -10292,6 +10293,13 @@ __metadata:
languageName: node
linkType: hard

"locale-includes@npm:^1.0.6":
version: 1.0.6
resolution: "locale-includes@npm:1.0.6"
checksum: 817d49df2f4cbb336f5768937110613b6e29b99071f15093faa1b46035819e4b0d4dbb27edf67fc86e262f52ab81109bbb668a4dd3506e217366280f135147c9
languageName: node
linkType: hard

"localforage@npm:^1.8.1":
version: 1.10.0
resolution: "localforage@npm:1.10.0"
Expand Down

0 comments on commit e1b1ca3

Please sign in to comment.