-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* AutoComplete clean-up * notes * lint fix * fix tests * review fix * type
- Loading branch information
Showing
9 changed files
with
95 additions
and
146 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
packages/desktop-client/src/components/autocomplete/FilterAutocomplete.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import React, { type ComponentProps } from 'react'; | ||
|
||
import { useFilters } from 'loot-core/src/client/data-hooks/filters'; | ||
import { type TransactionFilterEntity } from 'loot-core/types/models/transaction-filter'; | ||
|
||
import { Autocomplete } from './Autocomplete'; | ||
import { FilterList } from './FilterList'; | ||
|
||
export function FilterAutocomplete({ | ||
embedded, | ||
...props | ||
}: { | ||
embedded?: boolean; | ||
} & ComponentProps<typeof Autocomplete<TransactionFilterEntity>>) { | ||
const filters = useFilters() || []; | ||
|
||
return ( | ||
<Autocomplete | ||
strict={true} | ||
highlightFirst={true} | ||
embedded={embedded} | ||
suggestions={filters} | ||
renderItems={(items, getItemProps, highlightedIndex) => ( | ||
<FilterList | ||
items={items} | ||
getItemProps={getItemProps} | ||
highlightedIndex={highlightedIndex} | ||
embedded={embedded} | ||
/> | ||
)} | ||
{...props} | ||
/> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
packages/desktop-client/src/components/autocomplete/ItemHeader.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import React from 'react'; | ||
|
||
import { theme } from '../../style/theme'; | ||
import { type CSSProperties } from '../../style/types'; | ||
|
||
export type ItemHeaderProps = { | ||
title: string; | ||
style?: CSSProperties; | ||
type?: string; | ||
}; | ||
|
||
export function ItemHeader({ title, style, type, ...props }: ItemHeaderProps) { | ||
return ( | ||
<div | ||
style={{ | ||
color: theme.menuAutoCompleteTextHeader, | ||
padding: '4px 9px', | ||
...style, | ||
}} | ||
data-testid={`${title}-${type}-item-group`} | ||
{...props} | ||
> | ||
{title} | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
category: Maintenance | ||
authors: [carkom] | ||
--- | ||
|
||
Organizing and splitting filters Autocomplete. Splitting out headers function that was duplicated in all autocomplete elements. |