TypeScript
refactor(web): add SidebarInput (#13028)
Julius Marmingebe80e369394f
diff --git a/apps/web/src/components/settings/SettingsSidebarNav.tsx b/apps/web/src/components/settings/SettingsSidebarNav.tsxindex ffddb278b6c..cb466d3bb9f 100644--- a/apps/web/src/components/settings/SettingsSidebarNav.tsx+++ b/apps/web/src/components/settings/SettingsSidebarNav.tsx@@ -27,7 +27,6 @@ import {import { useLocation, useNavigate } from "@tanstack/react-router";import { Button } from "../ui/button";-import { Input } from "../ui/input";import { Kbd } from "../ui/kbd";import {SidebarContent,@@ -37,6 +36,7 @@ import {SidebarMenuButton,SidebarMenuItem,useSidebar,+ SidebarInput,} from "../ui/sidebar";import { SidebarUtilityMenu } from "../sidebar/SidebarChrome";import { scrollToSettingsTarget } from "./settingsLayout";@@ -237,10 +237,9 @@ export function SettingsSidebarNav({ pathname }: { pathname: string }) {<SidebarGroup className="gap-2 p-[var(--sidebar-content-inset)]"><div className="flex h-8 items-center gap-2 rounded-md px-2 py-1.5 text-sm font-medium text-sidebar-muted-foreground hover:bg-sidebar-row-hover hover:text-sidebar-foreground"><SearchIcon className="size-4 shrink-0 text-sidebar-muted-foreground/80" />- <Input+ <SidebarInputref={searchInputRef}nativeInput- unstyledtype="search"value={query}onChange={(event) => {@@ -259,7 +258,7 @@ export function SettingsSidebarNav({ pathname }: { pathname: string }) {? `settings-search-result-${results[activeResultIndex].id}`: undefined}- className="min-w-0 flex-1 [&_[data-slot=input]]:h-auto [&_[data-slot=input]]:p-0 [&_[data-slot=input]]:leading-normal [&_[data-slot=input]]:text-sm [&_[data-slot=input]]:font-medium [&_[data-slot=input]]:text-sidebar-foreground [&_[data-slot=input]]:placeholder:text-sidebar-muted-foreground"+ className="min-w-0 flex-1"/>{isSearching ? (<Buttondiff --git a/apps/web/src/components/sidebar/SidebarThreadHeader.tsx b/apps/web/src/components/sidebar/SidebarThreadHeader.tsxindex 6f9a686e521..424c50e7f2a 100644--- a/apps/web/src/components/sidebar/SidebarThreadHeader.tsx+++ b/apps/web/src/components/sidebar/SidebarThreadHeader.tsx@@ -21,8 +21,7 @@ import {import { cn } from "~/lib/utils";import { Button } from "../ui/button";-import { Input } from "../ui/input";-import { SidebarMenuButton } from "../ui/sidebar";+import { SidebarInput, SidebarMenuButton } from "../ui/sidebar";import { Tooltip, TooltipPopup, TooltipTrigger } from "../ui/tooltip";export interface SidebarThreadHeaderProps {@@ -85,10 +84,9 @@ export function SidebarThreadHeader({className="flex h-8 min-w-0 flex-1 items-center gap-2 rounded-md px-2 py-1.5 text-sm font-medium text-sidebar-muted-foreground hover:bg-sidebar-row-hover hover:text-sidebar-foreground"><SearchIcon className="size-4 shrink-0 text-[var(--sidebar-icon-color)]" />- <Input+ <SidebarInputref={searchInputRef}nativeInput- unstyledtype="search"value={searchQuery}onChange={(event) => onSearchQueryChange(event.currentTarget.value)}@@ -104,7 +102,7 @@ export function SidebarThreadHeader({? `sidebar-thread-search-result-${activeSearchResultIndex}`: undefined}- className="min-w-0 flex-1 [&_[data-slot=input]]:h-auto [&_[data-slot=input]]:p-0 [&_[data-slot=input]]:leading-normal [&_[data-slot=input]]:text-sm [&_[data-slot=input]]:font-medium [&_[data-slot=input]]:text-sidebar-foreground [&_[data-slot=input]]:placeholder:text-[var(--sidebar-icon-color)]"+ className="min-w-0 flex-1"/>{isSearching ? (<Buttondiff --git a/apps/web/src/components/ui/sidebar.tsx b/apps/web/src/components/ui/sidebar.tsxindex 180985620ba..a131d782ec9 100644--- a/apps/web/src/components/ui/sidebar.tsx+++ b/apps/web/src/components/ui/sidebar.tsx@@ -5,6 +5,7 @@ import { PanelLeftCloseIcon, PanelLeftIcon } from "lucide-react";import * as React from "react";import { cn } from "~/lib/utils";import { Button } from "~/components/ui/button";+import { Input, type InputProps } from "~/components/ui/input";import { ScrollArea } from "~/components/ui/scroll-area";import {Sheet,@@ -530,6 +531,20 @@ function SidebarRail({);}+/** A bare search or rename field that sits in a row of sidebar chrome. */+function SidebarInput({ className, ...props }: Omit<InputProps, "unstyled" | "variant">) {+ return (+ <Input+ className={cn(+ "[&_[data-slot=input]]:h-auto [&_[data-slot=input]]:p-0 [&_[data-slot=input]]:font-medium [&_[data-slot=input]]:text-sidebar-foreground [&_[data-slot=input]]:text-sm [&_[data-slot=input]]:leading-normal [&_[data-slot=input]]:placeholder:text-sidebar-muted-foreground",+ className,+ )}+ unstyled+ {...props}+ />+ );+}+function SidebarInset({ className, ...props }: React.ComponentProps<"main">) {return (<main@@ -770,6 +785,7 @@ function SidebarMenuSubButton({}export {+ SidebarInput,Sidebar,SidebarContent,SidebarFooter,diff --git a/scripts/lint-restyle-ceiling.ts b/scripts/lint-restyle-ceiling.tsindex 349949848cb..35592ebc17f 100644--- a/scripts/lint-restyle-ceiling.ts+++ b/scripts/lint-restyle-ceiling.ts@@ -8,7 +8,7 @@ import * as NodeURL from "node:url";// components/ui exports are migrated to variants (see vite.config.ts). This gate keeps the// count from growing: CI fails when findings exceed the ceiling. Lower the ceiling when you// migrate a file, and delete this script when the rule becomes an error.-export const RESTYLE_CEILING = 1043;+export const RESTYLE_CEILING = 1031;const RULE = "shadcn(no-restyle)";