mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-18 09:12:18 +00:00
The shell passes the ground picker to the click bridge, so the UI shell no longer pulls in the annotation and search stack. Context's new modules are owned by the packages that import them and formatted with the rest. Co-authored-by: Manjunath Paparaju <[email protected]>
32 lines
1.0 KiB
JavaScript
32 lines
1.0 KiB
JavaScript
import { computed, ref } from 'vue';
|
|
|
|
// The Context panel's own search: one field in its header that narrows what
|
|
// the panel is showing (the selected item's details, and every list of what
|
|
// is nearby or in view) to what holds the typed text.
|
|
|
|
/** Whether the search field is showing. */
|
|
export const contextSearchOpen = ref(false);
|
|
/** The text as typed. */
|
|
export const contextSearchText = ref('');
|
|
/** The text to match against: trimmed, lower case, '' when not searching. */
|
|
export const contextNeedle = computed(() =>
|
|
contextSearchOpen.value ? contextSearchText.value.trim().toLowerCase() : '',
|
|
);
|
|
|
|
/** Whether any of the given strings holds the searched text (true when not searching). */
|
|
export function matchesContextSearch(...parts) {
|
|
const needle = contextNeedle.value;
|
|
if (!needle) return true;
|
|
return parts.some(
|
|
(part) =>
|
|
part !== null &&
|
|
part !== undefined &&
|
|
String(part).toLowerCase().includes(needle),
|
|
);
|
|
}
|
|
|
|
export function closeContextSearch() {
|
|
contextSearchOpen.value = false;
|
|
contextSearchText.value = '';
|
|
}
|