mirror of
https://github.com/fsolla/teqo.git
synced 2026-12-02 21:23:05 +00:00
B137 — restore searchOnlyListOmnibox from main (CI merge ref)
This commit is contained in:
parent
d25d719ed9
commit
6c6a742cb4
1 changed files with 33 additions and 1 deletions
|
|
@ -2,7 +2,11 @@
|
||||||
* Degenerate omnibox for lists that only expose free-text search (B128:
|
* Degenerate omnibox for lists that only expose free-text search (B128:
|
||||||
* organizações). Pure / client-safe.
|
* organizações). Pure / client-safe.
|
||||||
*/
|
*/
|
||||||
import { type CampaignListOmniboxChip } from '@/lib/campaignListOmnibox'
|
import {
|
||||||
|
filterOmniboxSuggestionSeeds,
|
||||||
|
type CampaignListOmniboxChip,
|
||||||
|
type CampaignListOmniboxSuggestion,
|
||||||
|
} from '@/lib/campaignListOmnibox'
|
||||||
|
|
||||||
export type SearchOnlyListState = {
|
export type SearchOnlyListState = {
|
||||||
q?: string
|
q?: string
|
||||||
|
|
@ -19,6 +23,9 @@ export const buildSearchOnlyOmniboxChips = (
|
||||||
state: SearchOnlyListState,
|
state: SearchOnlyListState,
|
||||||
): CampaignListOmniboxChip[] => (state.q ? [{ id: 'q', label: chipLabel('Busca', state.q) }] : [])
|
): CampaignListOmniboxChip[] => (state.q ? [{ id: 'q', label: chipLabel('Busca', state.q) }] : [])
|
||||||
|
|
||||||
|
export const buildSearchOnlyOmniboxSuggestions = (query: string): CampaignListOmniboxSuggestion[] =>
|
||||||
|
filterOmniboxSuggestionSeeds([], query)
|
||||||
|
|
||||||
export const applySearchOnlyOmniboxSuggestion = <T extends SearchOnlyListState>({
|
export const applySearchOnlyOmniboxSuggestion = <T extends SearchOnlyListState>({
|
||||||
state,
|
state,
|
||||||
suggestionId,
|
suggestionId,
|
||||||
|
|
@ -34,3 +41,28 @@ export const applySearchOnlyOmniboxSuggestion = <T extends SearchOnlyListState>(
|
||||||
}
|
}
|
||||||
return { kind: 'url', state }
|
return { kind: 'url', state }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const removeSearchOnlyOmniboxChip = <T extends SearchOnlyListState>({
|
||||||
|
state,
|
||||||
|
chipId,
|
||||||
|
withPageReset,
|
||||||
|
}: {
|
||||||
|
state: T
|
||||||
|
chipId: string
|
||||||
|
withPageReset: (next: T) => T
|
||||||
|
}): SearchOnlyOmniboxAction<T> => {
|
||||||
|
if (chipId === 'q') {
|
||||||
|
return { kind: 'url', state: withPageReset({ ...state, q: undefined }) }
|
||||||
|
}
|
||||||
|
return { kind: 'url', state }
|
||||||
|
}
|
||||||
|
|
||||||
|
export const clearSearchOnlyOmnibox = <T extends SearchOnlyListState>({
|
||||||
|
cleared,
|
||||||
|
}: {
|
||||||
|
state: T
|
||||||
|
cleared: T
|
||||||
|
}): SearchOnlyOmniboxAction<T> => ({
|
||||||
|
kind: 'clear',
|
||||||
|
state: cleared,
|
||||||
|
})
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue