🔍 Add support for external search state in SearchBar component
This commit is contained in:
@@ -80,12 +80,19 @@ const props = defineProps({
|
|||||||
disabled: {
|
disabled: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false
|
default: false
|
||||||
|
},
|
||||||
|
searchState: {
|
||||||
|
type: Object,
|
||||||
|
default: null
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const fileLines = toRef(props, 'fileLines');
|
const fileLines = toRef(props, 'fileLines');
|
||||||
const displayLines = toRef(props, 'displayLines');
|
const displayLines = toRef(props, 'displayLines');
|
||||||
|
|
||||||
|
const internalSearchState = useGamemasterSearch(fileLines, displayLines);
|
||||||
|
const activeSearchState = computed(() => props.searchState || internalSearchState);
|
||||||
|
|
||||||
const {
|
const {
|
||||||
searchQuery,
|
searchQuery,
|
||||||
searchResults,
|
searchResults,
|
||||||
@@ -100,7 +107,7 @@ const {
|
|||||||
currentResultLineNumber,
|
currentResultLineNumber,
|
||||||
resultCountDisplay,
|
resultCountDisplay,
|
||||||
hasSearchResults
|
hasSearchResults
|
||||||
} = useGamemasterSearch(fileLines, displayLines);
|
} = activeSearchState.value;
|
||||||
|
|
||||||
const isDisabled = computed(
|
const isDisabled = computed(
|
||||||
() => props.disabled || fileLines.value.length === 0
|
() => props.disabled || fileLines.value.length === 0
|
||||||
|
|||||||
Reference in New Issue
Block a user