Files
Jonathan Adeline 38ccc54c2e chore: update Iconoir to 7.12.2 (#7012)
* chore(deps): update Iconoir to 7.12.2

* test: update grid visibility selector for Iconoir 7

* fix: restore open and slashed eye icons

* docs: document Iconoir 7 plugin changes
2026-12-04 15:36:56 +04:00

117 lines
2.6 KiB
Vue

<template>
<div class="header__search">
<a
ref="contextLink"
class="header__filter-link"
:class="{
'active active--primary': headerSearchTerm.length > 0,
}"
@click="onClick()"
>
<i class="header__search-icon iconoir-search"></i>
{{ headerSearchTerm }}
</a>
<a
v-show="headerSearchTerm.length > 0"
class="header__search-clear"
:aria-label="$t('viewSearch.clearSearch')"
@click.stop.prevent="clear"
>
<i class="iconoir-xmark"></i>
</a>
<ViewSearchContext
ref="context"
:view="view"
:fields="fields"
:read-only="readOnly"
:store-prefix="storePrefix"
:always-hide-rows-not-matching-search="alwaysHideRowsNotMatchingSearch"
@refresh="$emit('refresh', $event)"
@search-changed="searchChanged"
></ViewSearchContext>
</div>
</template>
<script>
import ViewSearchContext from '@baserow/modules/database/components/view/ViewSearchContext'
export default {
name: 'ViewSearch',
components: { ViewSearchContext },
props: {
view: {
type: Object,
required: true,
},
fields: {
type: Array,
required: true,
},
readOnly: {
type: Boolean,
required: false,
default: false,
},
storePrefix: {
type: String,
required: false,
default: '',
},
alwaysHideRowsNotMatchingSearch: {
type: Boolean,
required: false,
default: false,
},
},
emits: ['close-modals', 'refresh'],
data: () => {
return {
headerSearchTerm: '',
}
},
watch: {
$props: {
immediate: true,
handler() {
if (!this.storePrefix.length && !this.readOnly) {
throw new Error(
'A storePrefix is required when the search is not read-only.'
)
}
},
},
},
mounted() {
this.$priorityBus.$on(
'start-search',
this.$priorityBus.level.LOW,
this.searchStarted
)
},
beforeUnmount() {
this.$priorityBus.$off('start-search', this.searchStarted)
},
methods: {
onClick() {
this.$refs.context.toggle(this.$refs.contextLink, 'bottom', 'right', 4)
},
searchChanged(newSearch) {
this.headerSearchTerm = newSearch
},
searchStarted({ event }) {
event.preventDefault()
this.$bus.$emit('close-modals')
this.$refs.contextLink.click()
},
clear() {
const ref = this.$refs.context
const context = ref.getRootContext()
if (context.open) {
context.hide()
}
ref.setActiveSearchTerm('')
},
},
}
</script>