aboutsummaryrefslogtreecommitdiffstats
path: root/apps/web/components/dashboard/search/SearchInput.tsx
diff options
context:
space:
mode:
authorMohamed Bassem <me@mbassem.com>2024-12-31 13:17:56 +0200
committerGitHub <noreply@github.com>2024-12-31 13:17:56 +0200
commitcbaf9e6034aa09911fca967b7af6cad11f154b3e (patch)
tree6995d9d60d9ae5181af78e6577f8d7b724d7a971 /apps/web/components/dashboard/search/SearchInput.tsx
parentf476fca758bb039f9605488b61ba35fc097d6cfc (diff)
downloadkarakeep-cbaf9e6034aa09911fca967b7af6cad11f154b3e.tar.zst
feat: Introduce advanced search capabilities (#753)
* feat: Implement search filtering in the backend * feat: Implement search language parser * rename matcher name * Add ability to interleve text * More fixes * be more tolerable to parsing errors * Add a search query explainer widget * Handle date parsing gracefully * Fix the lockfile * Encode query search param * Fix table body error * Fix error when writing quotes
Diffstat (limited to 'apps/web/components/dashboard/search/SearchInput.tsx')
-rw-r--r--apps/web/components/dashboard/search/SearchInput.tsx27
1 files changed, 18 insertions, 9 deletions
diff --git a/apps/web/components/dashboard/search/SearchInput.tsx b/apps/web/components/dashboard/search/SearchInput.tsx
index 55f304e3..8ed2ea3c 100644
--- a/apps/web/components/dashboard/search/SearchInput.tsx
+++ b/apps/web/components/dashboard/search/SearchInput.tsx
@@ -4,6 +4,9 @@ import React, { useEffect, useImperativeHandle, useRef } from "react";
import { Input } from "@/components/ui/input";
import { useDoBookmarkSearch } from "@/lib/hooks/bookmark-search";
import { useTranslation } from "@/lib/i18n/client";
+import { cn } from "@/lib/utils";
+
+import QueryExplainerTooltip from "./QueryExplainerTooltip";
function useFocusSearchOnKeyPress(
inputRef: React.RefObject<HTMLInputElement>,
@@ -47,7 +50,8 @@ const SearchInput = React.forwardRef<
React.HTMLAttributes<HTMLInputElement> & { loading?: boolean }
>(({ className, ...props }, ref) => {
const { t } = useTranslation();
- const { debounceSearch, searchQuery, isInSearchPage } = useDoBookmarkSearch();
+ const { debounceSearch, searchQuery, parsedSearchQuery, isInSearchPage } =
+ useDoBookmarkSearch();
const [value, setValue] = React.useState(searchQuery);
@@ -67,14 +71,19 @@ const SearchInput = React.forwardRef<
}, [isInSearchPage]);
return (
- <Input
- ref={inputRef}
- value={value}
- onChange={onChange}
- placeholder={t("common.search")}
- className={className}
- {...props}
- />
+ <div className={cn("relative flex-1", className)}>
+ <QueryExplainerTooltip
+ className="-translate-1/2 absolute right-1.5 top-2 p-0.5"
+ parsedSearchQuery={parsedSearchQuery}
+ />
+ <Input
+ ref={inputRef}
+ value={value}
+ onChange={onChange}
+ placeholder={t("common.search")}
+ {...props}
+ />
+ </div>
);
});
SearchInput.displayName = "SearchInput";