From 8c8c248ef76303dbbc2b81a0227568cacd107f60 Mon Sep 17 00:00:00 2001 From: Joel Jeremy Marquez Date: Tue, 10 Sep 2024 13:09:32 -0700 Subject: [PATCH] [React Aria Button] Filter buttons (#3401) * vrt * Fix account menu test * Fix payee icons and category notes * vrt * vrt * Fix notes button * VRT * VRT * React Aria Button - All except filters and autocomplete * Fix typecheck errors * Fix typecheck error * Update * Fix typecheck error * Fix border * VRT * Revert MobileForms and TransactionEdit * VRT * VRT * Revert VRT * React Aria Button - Filter buttons * Release notes * Revert CoverModal and TransferModal --- .../filters/CompactFiltersButton.tsx | 6 +-- .../components/filters/FilterExpression.tsx | 10 ++-- .../src/components/filters/FiltersButton.tsx | 9 ++-- .../src/components/filters/FiltersMenu.jsx | 50 +++++++++---------- .../src/components/filters/NameFilter.tsx | 21 ++++---- .../src/components/filters/OpButton.tsx | 36 +++++++------ .../filters/SavedFilterMenuButton.tsx | 6 +-- upcoming-release-notes/3401.md | 6 +++ 8 files changed, 75 insertions(+), 69 deletions(-) create mode 100644 upcoming-release-notes/3401.md diff --git a/packages/desktop-client/src/components/filters/CompactFiltersButton.tsx b/packages/desktop-client/src/components/filters/CompactFiltersButton.tsx index 7da1dc8fa7d..a50c3162fc2 100644 --- a/packages/desktop-client/src/components/filters/CompactFiltersButton.tsx +++ b/packages/desktop-client/src/components/filters/CompactFiltersButton.tsx @@ -1,11 +1,11 @@ import React from 'react'; import { SvgFilter } from '../../icons/v1'; -import { Button } from '../common/Button'; +import { Button } from '../common/Button2'; -export function CompactFiltersButton({ onClick }: { onClick: () => void }) { +export function CompactFiltersButton({ onPress }: { onPress: () => void }) { return ( - ); diff --git a/packages/desktop-client/src/components/filters/FilterExpression.tsx b/packages/desktop-client/src/components/filters/FilterExpression.tsx index 34df7694a76..11062c175ef 100644 --- a/packages/desktop-client/src/components/filters/FilterExpression.tsx +++ b/packages/desktop-client/src/components/filters/FilterExpression.tsx @@ -7,7 +7,7 @@ import { type RuleConditionEntity } from 'loot-core/src/types/models'; import { SvgDelete } from '../../icons/v0'; import { type CSSProperties, theme } from '../../style'; -import { Button } from '../common/Button'; +import { Button } from '../common/Button2'; import { Popover } from '../common/Popover'; import { Text } from '../common/Text'; import { View } from '../common/View'; @@ -59,9 +59,9 @@ export function FilterExpression({ > - ); diff --git a/packages/desktop-client/src/components/filters/FiltersMenu.jsx b/packages/desktop-client/src/components/filters/FiltersMenu.jsx index 8baacffe99e..30642fb7d81 100644 --- a/packages/desktop-client/src/components/filters/FiltersMenu.jsx +++ b/packages/desktop-client/src/components/filters/FiltersMenu.jsx @@ -1,4 +1,5 @@ import React, { useState, useRef, useEffect, useReducer } from 'react'; +import { Form } from 'react-aria-components'; import { useHotkeys } from 'react-hotkeys-hook'; import { Trans, useTranslation } from 'react-i18next'; @@ -24,7 +25,7 @@ import { titleFirst } from 'loot-core/src/shared/util'; import { useDateFormat } from '../../hooks/useDateFormat'; import { styles, theme } from '../../style'; -import { Button } from '../common/Button'; +import { Button } from '../common/Button2'; import { Menu } from '../common/Menu'; import { Popover } from '../common/Popover'; import { Select } from '../common/Select'; @@ -141,8 +142,8 @@ function ConfigureField({ { + isSelected={value === true} + onPress={() => { dispatch({ type: 'set-op', op: 'is' }); dispatch({ type: 'set-value', value: true }); }} @@ -150,8 +151,8 @@ function ConfigureField({ { + isSelected={value === false} + onPress={() => { dispatch({ type: 'set-op', op: 'is' }); dispatch({ type: 'set-value', value: false }); }} @@ -169,8 +170,8 @@ function ConfigureField({ dispatch({ type: 'set-op', op: currOp })} + isSelected={currOp === op} + onPress={() => dispatch({ type: 'set-op', op: currOp })} /> ))} @@ -184,8 +185,8 @@ function ConfigureField({ dispatch({ type: 'set-op', op: currOp })} + isSelected={currOp === op} + onPress={() => dispatch({ type: 'set-op', op: currOp })} /> ))} @@ -193,7 +194,17 @@ function ConfigureField({ )} -
+ { + e.preventDefault(); + onApply({ + field, + op, + value, + options: subfieldToOptions(field, subfield), + }); + }} + > {type !== 'boolean' && ( - - + ); } @@ -347,10 +347,10 @@ export function FilterButton({ onApply, compact, hover, exclude }) { > {compact ? ( dispatch({ type: 'select-field' })} + onPress={() => dispatch({ type: 'select-field' })} /> ) : ( - dispatch({ type: 'select-field' })} /> + dispatch({ type: 'select-field' })} /> )} diff --git a/packages/desktop-client/src/components/filters/NameFilter.tsx b/packages/desktop-client/src/components/filters/NameFilter.tsx index b8ad19ac0fa..77fb85132ac 100644 --- a/packages/desktop-client/src/components/filters/NameFilter.tsx +++ b/packages/desktop-client/src/components/filters/NameFilter.tsx @@ -1,8 +1,9 @@ import React, { useRef, useEffect } from 'react'; +import { Form } from 'react-aria-components'; import { useTranslation } from 'react-i18next'; import { theme } from '../../style'; -import { Button } from '../common/Button'; +import { Button } from '../common/Button2'; import { Input } from '../common/Input'; import { Stack } from '../common/Stack'; import { Text } from '../common/Text'; @@ -35,7 +36,12 @@ export function NameFilter({ return ( <> {menuItem !== 'update-filter' && ( -
+ { + e.preventDefault(); + onAddUpdate(); + }} + > - -
+ )} {err && ( diff --git a/packages/desktop-client/src/components/filters/OpButton.tsx b/packages/desktop-client/src/components/filters/OpButton.tsx index f061cb0c81a..606149badc4 100644 --- a/packages/desktop-client/src/components/filters/OpButton.tsx +++ b/packages/desktop-client/src/components/filters/OpButton.tsx @@ -1,34 +1,38 @@ import React from 'react'; +import { css } from 'glamor'; + import { friendlyOp } from 'loot-core/src/shared/rules'; import { type CSSProperties, theme } from '../../style'; -import { Button } from '../common/Button'; +import { Button } from '../common/Button2'; type OpButtonProps = { op: string; - selected: boolean; - onClick: () => void; + isSelected: boolean; + onPress: () => void; style?: CSSProperties; }; -export function OpButton({ op, selected, style, onClick }: OpButtonProps) { +export function OpButton({ op, isSelected, style, onPress }: OpButtonProps) { return ( diff --git a/packages/desktop-client/src/components/filters/SavedFilterMenuButton.tsx b/packages/desktop-client/src/components/filters/SavedFilterMenuButton.tsx index 3d4b3d701c0..bd42f61ead6 100644 --- a/packages/desktop-client/src/components/filters/SavedFilterMenuButton.tsx +++ b/packages/desktop-client/src/components/filters/SavedFilterMenuButton.tsx @@ -6,7 +6,7 @@ import { type TransactionFilterEntity } from 'loot-core/types/models'; import { type RuleConditionEntity } from 'loot-core/types/models/rule'; import { SvgExpandArrow } from '../../icons/v0'; -import { Button } from '../common/Button'; +import { Button } from '../common/Button2'; import { Popover } from '../common/Popover'; import { Text } from '../common/Text'; import { View } from '../common/View'; @@ -163,9 +163,9 @@ export function SavedFilterMenuButton({ {conditions.length > 0 && (