diff --git a/packages/desktop-client/e2e/accounts.mobile.test.ts-snapshots/Mobile-Accounts-opens-individual-account-page-and-checks-that-filtering-is-working-6-chromium-linux.png b/packages/desktop-client/e2e/accounts.mobile.test.ts-snapshots/Mobile-Accounts-opens-individual-account-page-and-checks-that-filtering-is-working-6-chromium-linux.png index ab1453e1c4..9c7f2aa26e 100644 Binary files a/packages/desktop-client/e2e/accounts.mobile.test.ts-snapshots/Mobile-Accounts-opens-individual-account-page-and-checks-that-filtering-is-working-6-chromium-linux.png and b/packages/desktop-client/e2e/accounts.mobile.test.ts-snapshots/Mobile-Accounts-opens-individual-account-page-and-checks-that-filtering-is-working-6-chromium-linux.png differ diff --git a/packages/desktop-client/e2e/accounts.mobile.test.ts-snapshots/Mobile-Accounts-opens-individual-account-page-and-checks-that-filtering-is-working-9-chromium-linux.png b/packages/desktop-client/e2e/accounts.mobile.test.ts-snapshots/Mobile-Accounts-opens-individual-account-page-and-checks-that-filtering-is-working-9-chromium-linux.png index 1d66868a71..2aebe5ab9a 100644 Binary files a/packages/desktop-client/e2e/accounts.mobile.test.ts-snapshots/Mobile-Accounts-opens-individual-account-page-and-checks-that-filtering-is-working-9-chromium-linux.png and b/packages/desktop-client/e2e/accounts.mobile.test.ts-snapshots/Mobile-Accounts-opens-individual-account-page-and-checks-that-filtering-is-working-9-chromium-linux.png differ diff --git a/packages/desktop-client/src/components/common/InputWithContent.tsx b/packages/desktop-client/src/components/common/InputWithContent.tsx deleted file mode 100644 index e1ffc8ffc4..0000000000 --- a/packages/desktop-client/src/components/common/InputWithContent.tsx +++ /dev/null @@ -1,69 +0,0 @@ -import { useState, type ComponentProps, type ReactNode } from 'react'; - -import { Input, defaultInputStyle } from '@actual-app/components/input'; -import { type CSSProperties } from '@actual-app/components/styles'; -import { theme } from '@actual-app/components/theme'; -import { View } from '@actual-app/components/view'; - -type InputWithContentProps = ComponentProps & { - leftContent?: ReactNode; - rightContent?: ReactNode; - inputStyle?: CSSProperties; - focusStyle?: CSSProperties; - style?: CSSProperties; - getStyle?: (focused: boolean) => CSSProperties; - focused?: boolean; -}; -export function InputWithContent({ - leftContent, - rightContent, - inputStyle, - focusStyle, - style, - getStyle, - ...props -}: InputWithContentProps) { - const [focused, setFocused] = useState(props.focused ?? false); - - return ( - - {leftContent} - { - setFocused(true); - props.onFocus?.(e); - }} - onBlur={e => { - setFocused(false); - props.onBlur?.(e); - }} - /> - {rightContent} - - ); -} diff --git a/packages/desktop-client/src/components/common/Search.tsx b/packages/desktop-client/src/components/common/Search.tsx index 6a90f74d0e..e56ef5c78a 100644 --- a/packages/desktop-client/src/components/common/Search.tsx +++ b/packages/desktop-client/src/components/common/Search.tsx @@ -1,21 +1,22 @@ -import { type Ref } from 'react'; +import { useState, type Ref } from 'react'; import { useTranslation } from 'react-i18next'; import { Button } from '@actual-app/components/button'; +import { SvgRemove, SvgSearchAlternate } from '@actual-app/components/icons/v2'; +import { defaultInputStyle, Input } from '@actual-app/components/input'; +import { type CSSProperties } from '@actual-app/components/styles'; +import { theme } from '@actual-app/components/theme'; import { View } from '@actual-app/components/view'; -import { SvgRemove, SvgSearchAlternate } from '../../icons/v2'; -import { theme } from '../../style'; - -import { InputWithContent } from './InputWithContent'; - type SearchProps = { inputRef?: Ref; value: string; onChange: (value: string) => void; placeholder: string; isInModal?: boolean; - width?: number; + width?: number | '100%'; + height?: number; + inputStyle?: CSSProperties; }; export function Search({ @@ -25,69 +26,99 @@ export function Search({ placeholder, isInModal = false, width = 250, + height, + inputStyle = {}, }: SearchProps) { const { t } = useTranslation(); + + const [focused, setFocused] = useState(false); + + const clearButtonPadding = ((height ?? 24) - 8) / 2; + return ( - - } - rightContent={ - value && ( - - - - ) - } - inputStyle={{ - '::placeholder': { - color: theme.formInputTextPlaceholder, - transition: 'color .25s', - }, - ':focus': isInModal - ? {} - : { - '::placeholder': { - color: theme.formInputTextPlaceholderSelected, + > + + + { + if (e.key === 'Escape') onChange(''); + }} + onChangeValue={onChange} + style={{ + width: '100%', + '::placeholder': { + color: theme.formInputTextPlaceholder, + transition: 'color .25s', + }, + ':focus': isInModal + ? {} + : { + '::placeholder': { + color: theme.formInputTextPlaceholderSelected, + }, }, - }, - }} - value={value} - placeholder={placeholder} - onKeyDown={e => { - if (e.key === 'Escape') onChange(''); - }} - onChangeValue={value => onChange(value)} - /> + flex: 1, + '&, &:focus, &:hover': { + border: 0, + backgroundColor: 'transparent', + boxShadow: 'none', + color: 'inherit', + }, + }} + onFocus={() => { + setFocused(true); + }} + onBlur={() => { + setFocused(false); + }} + /> + + {value && ( + + + + )} + ); } diff --git a/packages/desktop-client/src/components/mobile/transactions/TransactionListWithBalances.tsx b/packages/desktop-client/src/components/mobile/transactions/TransactionListWithBalances.tsx index 4dde239df0..206dbd6a8b 100644 --- a/packages/desktop-client/src/components/mobile/transactions/TransactionListWithBalances.tsx +++ b/packages/desktop-client/src/components/mobile/transactions/TransactionListWithBalances.tsx @@ -3,15 +3,14 @@ import { useTranslation } from 'react-i18next'; import { Label } from '@actual-app/components/label'; import { styles } from '@actual-app/components/styles'; +import { theme } from '@actual-app/components/theme'; import { View } from '@actual-app/components/view'; import { type AccountEntity } from 'loot-core/types/models'; import { type TransactionEntity } from 'loot-core/types/models/transaction'; import { SelectedProvider, useSelected } from '../../../hooks/useSelected'; -import { SvgSearchAlternate } from '../../../icons/v2'; -import { theme } from '../../../style'; -import { InputWithContent } from '../../common/InputWithContent'; +import { Search } from '../../common/Search'; import type { Binding, SheetNames, SheetFields } from '../../spreadsheet'; import { CellValue, CellValueText } from '../../spreadsheet/CellValue'; import { useSheetValue } from '../../spreadsheet/useSheetValue'; @@ -40,30 +39,18 @@ function TransactionSearchInput({ width: '100%', }} > - - } + { + onChange={text => { setText(text); onSearch(text); }} placeholder={placeholder} - style={{ + width="100%" + height={styles.mobileMinHeight} + inputStyle={{ backgroundColor: theme.tableBackground, - border: `1px solid ${theme.formInputBorder}`, - flex: 1, - height: styles.mobileMinHeight, + borderColor: theme.formInputBorder, }} /> diff --git a/packages/desktop-client/src/components/util/AmountInput.tsx b/packages/desktop-client/src/components/util/AmountInput.tsx index 8bf2582c2b..738c662c00 100644 --- a/packages/desktop-client/src/components/util/AmountInput.tsx +++ b/packages/desktop-client/src/components/util/AmountInput.tsx @@ -12,6 +12,7 @@ import { useTranslation } from 'react-i18next'; import { Button } from '@actual-app/components/button'; import { SvgAdd, SvgSubtract } from '@actual-app/components/icons/v1'; +import { defaultInputStyle, Input } from '@actual-app/components/input'; import { theme } from '@actual-app/components/theme'; import { View } from '@actual-app/components/view'; @@ -20,7 +21,6 @@ import { amountToInteger, appendDecimals } from 'loot-core/shared/util'; import { useMergedRefs } from '../../hooks/useMergedRefs'; import { useSyncedPref } from '../../hooks/useSyncedPref'; -import { InputWithContent } from '../common/InputWithContent'; import { useFormat } from '../spreadsheet/useFormat'; type AmountInputProps = { @@ -61,6 +61,8 @@ export function AmountInput({ initialValue === 0 ? zeroSign : initialValue > 0 ? '+' : '-', ); + const [isFocused, setIsFocused] = useState(focused ?? false); + const initialValueAbsolute = format(Math.abs(initialValue || 0), 'financial'); const [value, setValue] = useState(initialValueAbsolute); useEffect(() => setValue(initialValueAbsolute), [initialValueAbsolute]); @@ -115,42 +117,70 @@ export function AmountInput({ } return ( - - {symbol === '-' && ( - - )} - {symbol === '+' && ( - - )} - - } - value={value} - disabled={disabled} - style={{ flex: 1, alignItems: 'stretch', ...style }} - inputStyle={inputStyle} - onKeyUp={e => { - if (e.key === 'Enter') { - const amount = getAmount(); - fireUpdate(amount); - } + + > + + + { + setIsFocused(true); + onFocus?.(e); + }} + onBlur={e => { + setIsFocused(false); + onInputAmountBlur(e); + }} + onKeyUp={e => { + if (e.key === 'Enter') { + const amount = getAmount(); + fireUpdate(amount); + } + }} + onEnter={onEnter} + onChangeValue={onInputTextChange} + /> + ); } diff --git a/upcoming-release-notes/4566.md b/upcoming-release-notes/4566.md new file mode 100644 index 0000000000..3987ed9600 --- /dev/null +++ b/upcoming-release-notes/4566.md @@ -0,0 +1,6 @@ +--- +category: Maintenance +authors: [MatissJanis] +--- + +Removing `InputWithContent` generic component - including some of its functionality in the consumers.