From c43082f890039bd55071e8c8bdcff7f83ab31fb7 Mon Sep 17 00:00:00 2001 From: Carlos Martins Date: Thu, 22 May 2025 12:30:40 -0600 Subject: [PATCH 01/32] Merge pull request #61170 from Expensify/jsenyitko-search-lhn-suggestions Suggested Search & Filter Revamp From 90420ebeb81bd211c88a9ae4fa7398773ec54e8e Mon Sep 17 00:00:00 2001 From: Carlos Martins Date: Thu, 22 May 2025 12:30:40 -0600 Subject: [PATCH 02/32] Merge pull request #61170 from Expensify/jsenyitko-search-lhn-suggestions Suggested Search & Filter Revamp --- src/CONST.ts | 12 +- src/ROUTES.ts | 1 - src/SCREENS.ts | 1 - src/components/Button/index.tsx | 6 +- .../CalendarPicker/YearPickerModal.tsx | 2 + src/components/EmptyStateComponent/index.tsx | 1 + src/components/EmptyStateComponent/types.ts | 6 +- src/components/MenuItem.tsx | 16 +- src/components/PopoverMenu.tsx | 1 + .../DateSelectPopup/CalendarView.tsx | 73 ++ .../DateSelectPopup/RootView.tsx | 70 ++ .../FilterDropdowns/DateSelectPopup/index.tsx | 74 ++ .../Search/FilterDropdowns/DropdownButton.tsx | 131 ++++ .../FilterDropdowns/MultiSelectPopup.tsx | 110 +++ .../FilterDropdowns/SingleSelectPopup.tsx | 101 +++ .../FilterDropdowns/UserSelectPopup.tsx | 195 ++++++ .../Search/SearchAutocompleteList.tsx | 9 +- src/components/Search/SearchContext.tsx | 12 +- src/components/Search/SearchList.tsx | 2 +- .../SearchPageHeader/SearchFiltersBar.tsx | 393 +++++++++++ .../SearchPageHeader/SearchPageHeader.tsx | 51 +- .../SearchPageHeaderInput.tsx | 8 +- .../SearchPageHeader/SearchStatusBar.tsx | 429 ------------ .../SearchTypeMenuPopover.tsx | 5 +- .../SearchRouter/buildSubstitutionsMap.ts | 5 +- src/components/Search/index.tsx | 11 +- src/components/Search/types.ts | 14 +- .../SelectionList/BaseSelectionList.tsx | 7 +- .../SelectionList/MultiSelectListItem.tsx | 63 ++ .../SelectionList/Search/TaskListItemRow.tsx | 2 +- .../Search/UserSelectionListItem.tsx | 135 ++++ .../SelectionList/SearchTableHeader.tsx | 5 +- .../SelectionList/SingleSelectListItem.tsx | 64 ++ src/components/SelectionList/types.ts | 12 + .../Skeletons/SearchFiltersSkeleton.tsx | 65 ++ .../Skeletons/SearchStatusSkeleton.tsx | 96 --- .../implementation/index.native.tsx | 1 + .../BaseTextInput/implementation/index.tsx | 1 + .../TextInput/TextInputClearButton/index.tsx | 6 +- src/hooks/useSearchTypeMenu.tsx | 110 ++- src/languages/en.ts | 32 + src/languages/es.ts | 32 + src/libs/DateUtils.ts | 9 + .../ModalStackNavigators/index.tsx | 1 - .../linkingConfig/RELATIONS/SEARCH_TO_RHP.ts | 1 - src/libs/Navigation/linkingConfig/config.ts | 1 - src/libs/SearchAutocompleteUtils.ts | 3 +- src/libs/SearchParser/autocompleteParser.js | 648 +++++++++-------- .../SearchParser/autocompleteParser.peggy | 2 + src/libs/SearchParser/baseRules.peggy | 2 + src/libs/SearchParser/searchParser.js | 650 ++++++++++-------- src/libs/SearchParser/searchParser.peggy | 2 + src/libs/SearchQueryUtils.ts | 61 +- src/libs/SearchUIUtils.ts | 320 +++++++-- src/libs/actions/Policy/Policy.ts | 1 + src/pages/Search/AdvancedSearchFilters.tsx | 35 +- src/pages/Search/EmptySearchView.tsx | 71 +- .../SearchFiltersCreatedByPage.tsx | 50 -- .../SearchFiltersExportedPage.tsx | 16 - .../CalendarView.tsx | 80 +++ .../SearchFiltersExportedPage/RootView.tsx | 115 ++++ .../SearchFiltersExportedPage/index.tsx | 104 +++ src/pages/Search/SearchPage.tsx | 10 +- src/pages/Search/SearchPageNarrow.tsx | 13 +- src/pages/Search/SearchTypeMenu.tsx | 129 ++-- src/styles/index.ts | 35 +- src/styles/theme/themes/dark.ts | 1 + src/styles/theme/themes/light.ts | 1 + src/styles/theme/types.ts | 1 + src/styles/utils/index.ts | 19 +- src/types/form/SearchAdvancedFiltersForm.ts | 23 +- tests/ui/components/EmptySearchViewTest.tsx | 4 + tests/unit/Search/SearchUIUtilsTest.ts | 38 +- 73 files changed, 3243 insertions(+), 1573 deletions(-) create mode 100644 src/components/Search/FilterDropdowns/DateSelectPopup/CalendarView.tsx create mode 100644 src/components/Search/FilterDropdowns/DateSelectPopup/RootView.tsx create mode 100644 src/components/Search/FilterDropdowns/DateSelectPopup/index.tsx create mode 100644 src/components/Search/FilterDropdowns/DropdownButton.tsx create mode 100644 src/components/Search/FilterDropdowns/MultiSelectPopup.tsx create mode 100644 src/components/Search/FilterDropdowns/SingleSelectPopup.tsx create mode 100644 src/components/Search/FilterDropdowns/UserSelectPopup.tsx create mode 100644 src/components/Search/SearchPageHeader/SearchFiltersBar.tsx delete mode 100644 src/components/Search/SearchPageHeader/SearchStatusBar.tsx create mode 100644 src/components/SelectionList/MultiSelectListItem.tsx create mode 100644 src/components/SelectionList/Search/UserSelectionListItem.tsx create mode 100644 src/components/SelectionList/SingleSelectListItem.tsx create mode 100644 src/components/Skeletons/SearchFiltersSkeleton.tsx delete mode 100644 src/components/Skeletons/SearchStatusSkeleton.tsx delete mode 100644 src/pages/Search/SearchAdvancedFiltersPage/SearchFiltersCreatedByPage.tsx delete mode 100644 src/pages/Search/SearchAdvancedFiltersPage/SearchFiltersExportedPage.tsx create mode 100644 src/pages/Search/SearchAdvancedFiltersPage/SearchFiltersExportedPage/CalendarView.tsx create mode 100644 src/pages/Search/SearchAdvancedFiltersPage/SearchFiltersExportedPage/RootView.tsx create mode 100644 src/pages/Search/SearchAdvancedFiltersPage/SearchFiltersExportedPage/index.tsx diff --git a/src/CONST.ts b/src/CONST.ts index 871450f669d0..38db3d1772ec 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -416,6 +416,9 @@ const CONST = { horizontal: 12 + variables.navigationTabBarSize, vertical: 72, }, + POPOVER_DROPDOWN_WIDTH: 336, + POPOVER_DROPDOWN_MIN_HEIGHT: 0, + POPOVER_DROPDOWN_MAX_HEIGHT: 476, POPOVER_DATE_WIDTH: 338, POPOVER_DATE_MAX_HEIGHT: 366, POPOVER_DATE_MIN_HEIGHT: 322, @@ -6504,6 +6507,7 @@ const CONST = { }, SEARCH: { + NEVER: 'never', RESULTS_PAGE_SIZE: 50, DATA_TYPES: { EXPENSE: 'expense', @@ -6600,7 +6604,6 @@ const CONST = { TAX_AMOUNT: 'taxAmount', TITLE: 'title', ASSIGNEE: 'assignee', - CREATED_BY: 'createdBy', IN: 'in', }, SYNTAX_OPERATORS: { @@ -6629,6 +6632,8 @@ const CONST = { DESCRIPTION: 'description', FROM: 'from', TO: 'to', + PAYER: 'payer', + EXPORTER: 'exporter', CATEGORY: 'category', TAG: 'tag', TAX_RATE: 'taxRate', @@ -6644,7 +6649,6 @@ const CONST = { POSTED: 'posted', TITLE: 'title', ASSIGNEE: 'assignee', - CREATED_BY: 'createdBy', REIMBURSABLE: 'reimbursable', BILLABLE: 'billable', POLICY_ID: 'policyID', @@ -6670,6 +6674,8 @@ const CONST = { DESCRIPTION: 'description', FROM: 'from', TO: 'to', + PAYER: 'payer', + EXPORTER: 'exporter', CATEGORY: 'category', TAG: 'tag', TAX_RATE: 'tax-rate', @@ -6685,13 +6691,13 @@ const CONST = { POSTED: 'posted', TITLE: 'title', ASSIGNEE: 'assignee', - CREATED_BY: 'created-by', REIMBURSABLE: 'reimbursable', BILLABLE: 'billable', }, DATE_MODIFIERS: { BEFORE: 'Before', AFTER: 'After', + ON: 'On', }, SNAPSHOT_ONYX_KEYS: [ ONYXKEYS.COLLECTION.REPORT, diff --git a/src/ROUTES.ts b/src/ROUTES.ts index 526a16097e2e..4d343d08984f 100644 --- a/src/ROUTES.ts +++ b/src/ROUTES.ts @@ -71,7 +71,6 @@ const ROUTES = { SEARCH_ADVANCED_FILTERS_POSTED: 'search/filters/posted', SEARCH_ADVANCED_FILTERS_TITLE: 'search/filters/title', SEARCH_ADVANCED_FILTERS_ASSIGNEE: 'search/filters/assignee', - SEARCH_ADVANCED_FILTERS_CREATED_BY: 'search/filters/createdBy', SEARCH_ADVANCED_FILTERS_REIMBURSABLE: 'search/filters/reimbursable', SEARCH_ADVANCED_FILTERS_BILLABLE: 'search/filters/billable', SEARCH_ADVANCED_FILTERS_WORKSPACE: 'search/filters/workspace', diff --git a/src/SCREENS.ts b/src/SCREENS.ts index ee3f5aa21550..ae4f6e953d96 100644 --- a/src/SCREENS.ts +++ b/src/SCREENS.ts @@ -63,7 +63,6 @@ const SCREENS = { ADVANCED_FILTERS_TO_RHP: 'Search_Advanced_Filters_To_RHP', ADVANCED_FILTERS_TITLE_RHP: 'Search_Advanced_Filters_Title_RHP', ADVANCED_FILTERS_ASSIGNEE_RHP: 'Search_Advanced_Filters_Assignee_RHP', - ADVANCED_FILTERS_CREATED_BY_RHP: 'Search_Advanced_Filters_Created_By_RHP', ADVANCED_FILTERS_REIMBURSABLE_RHP: 'Search_Advanced_Filters_Reimbursable_RHP', ADVANCED_FILTERS_BILLABLE_RHP: 'Search_Advanced_Filters_Billable_RHP', ADVANCED_FILTERS_WORKSPACE_RHP: 'Search_Advanced_Filters_Workspace_RHP', diff --git a/src/components/Button/index.tsx b/src/components/Button/index.tsx index 34ab3e22f3ec..dd955e8dee94 100644 --- a/src/components/Button/index.tsx +++ b/src/components/Button/index.tsx @@ -294,12 +294,12 @@ function Button( danger && styles.buttonDangerText, !!icon && styles.textAlignLeft, !!secondLineText && styles.noPaddingBottom, - textStyles, isHovered && textHoverStyles, - link && styles.link, - link && isHovered && StyleUtils.getColorStyle(theme.linkHover), link && styles.fontWeightNormal, link && styles.fontSizeLabel, + textStyles, + link && styles.link, + link && isHovered && StyleUtils.getColorStyle(theme.linkHover), ]} dataSet={{[CONST.SELECTION_SCRAPER_HIDDEN_ELEMENT]: true}} > diff --git a/src/components/DatePicker/CalendarPicker/YearPickerModal.tsx b/src/components/DatePicker/CalendarPicker/YearPickerModal.tsx index d912edcf80cf..de3a1e3b725b 100644 --- a/src/components/DatePicker/CalendarPicker/YearPickerModal.tsx +++ b/src/components/DatePicker/CalendarPicker/YearPickerModal.tsx @@ -55,6 +55,8 @@ function YearPickerModal({isVisible, years, currentYear = new Date().getFullYear hideModalContentWhileAnimating useNativeDriver shouldHandleNavigationBack + shouldUseCustomBackdrop + onBackdropPress={onClose} enableEdgeToEdgeBottomSafeAreaPadding > {buttons?.map(({buttonText, buttonAction, success, icon, isDisabled, style}) => ( + + {/* Dropdown overlay */} + + + + + ); +} + +DropdownButton.displayName = 'DropdownButton'; +export type {PopoverComponentProps}; +export default DropdownButton; diff --git a/src/components/Search/FilterDropdowns/MultiSelectPopup.tsx b/src/components/Search/FilterDropdowns/MultiSelectPopup.tsx new file mode 100644 index 000000000000..9b6fad81e9b4 --- /dev/null +++ b/src/components/Search/FilterDropdowns/MultiSelectPopup.tsx @@ -0,0 +1,110 @@ +import React, {useCallback, useMemo, useState} from 'react'; +import {View} from 'react-native'; +import Button from '@components/Button'; +import SelectionList from '@components/SelectionList'; +import MultiSelectListItem from '@components/SelectionList/MultiSelectListItem'; +import type {ListItem} from '@components/SelectionList/types'; +import Text from '@components/Text'; +import useLocalize from '@hooks/useLocalize'; +import useResponsiveLayout from '@hooks/useResponsiveLayout'; +import useThemeStyles from '@hooks/useThemeStyles'; +import type {TranslationPaths} from '@src/languages/types'; + +type MultiSelectItem = { + translation: TranslationPaths; + value: T; +}; + +type MultiSelectPopupProps = { + /** The label to show when in an overlay on mobile */ + label: string; + + /** The list of all items to show up in the list */ + items: Array>; + + /** The currently selected items */ + value: Array>; + + /** Function to call to close the overlay when changes are applied */ + closeOverlay: () => void; + + /** Function to call when changes are applied */ + onChange: (item: Array>) => void; +}; + +function MultiSelectPopup({label, value, items, closeOverlay, onChange}: MultiSelectPopupProps) { + const {translate} = useLocalize(); + const styles = useThemeStyles(); + // eslint-disable-next-line rulesdir/prefer-shouldUseNarrowLayout-instead-of-isSmallScreenWidth + const {isSmallScreenWidth} = useResponsiveLayout(); + const [selectedItems, setSelectedItems] = useState(value); + + const listData: ListItem[] = useMemo(() => { + return items.map((item) => ({ + text: translate(item.translation), + keyForList: item.value, + isSelected: !!selectedItems.find((i) => i.value === item.value), + })); + }, [items, selectedItems, translate]); + + const updateSelectedItems = useCallback( + (item: ListItem) => { + if (item.isSelected) { + setSelectedItems(selectedItems.filter((i) => i.value !== item.keyForList)); + return; + } + + const newItem = items.find((i) => i.value === item.keyForList); + + if (newItem) { + setSelectedItems([...selectedItems, newItem]); + } + }, + [items, selectedItems], + ); + + const applyChanges = useCallback(() => { + onChange(selectedItems); + closeOverlay(); + }, [closeOverlay, onChange, selectedItems]); + + const resetChanges = useCallback(() => { + onChange([]); + closeOverlay(); + }, [closeOverlay, onChange]); + + return ( + + {isSmallScreenWidth && {label}} + + + + + + +