1- import React , { createContext , useContext , useEffect , useMemo , useRef , useState } from "react" ;
1+ import React , { createContext , useContext , useEffect , useMemo , useState } from "react" ;
22import {
33 Avatar ,
44 Button ,
@@ -38,7 +38,6 @@ import {
3838 RiUploadCloudFill ,
3939} from "react-icons/ri" ;
4040import { Link , useNavigate } from "react-router-dom" ;
41- import type { RefInputType } from "@arco-design/web-react/es/Input/interface" ;
4241import Text from "@arco-design/web-react/es/Typography/text" ;
4342import type { DragEndEvent } from "@dnd-kit/core" ;
4443import { closestCenter , DndContext , KeyboardSensor , PointerSensor , useSensor , useSensors } from "@dnd-kit/core" ;
@@ -60,8 +59,7 @@ import { requestEnableScript, pinToTop, scriptClient, synchronizeClient } from "
6059import { getCombinedMeta } from "@App/app/service/service_worker/utils" ;
6160import { parseTags } from "@App/app/repo/metadata" ;
6261import { EnableSwitch , HomeCell , MemoizedAvatar , ScriptSearchField , SourceCell , UpdateTimeCell } from "./components" ;
63- import type { SetSearchRequest } from "./hooks" ;
64- import type { SearchType } from "@App/app/service/service_worker/types" ;
62+ import { SearchFilter } from "./SearchFilter" ;
6563
6664type ListType = ScriptLoading ;
6765
@@ -420,8 +418,6 @@ interface ScriptTableProps {
420418 updateScripts : ( uuids : string [ ] , data : Partial < Script | ScriptLoading > ) => void ;
421419 setUserConfig : ( config : { script : Script ; userConfig : UserConfig ; values : { [ key : string ] : any } } ) => void ;
422420 setCloudScript : ( script : Script ) => void ;
423- searchRequest : { keyword : string ; type : SearchType } ;
424- setSearchRequest : SetSearchRequest ;
425421 handleDelete : ( item : ScriptLoading ) => void ;
426422 handleConfig : (
427423 item : ScriptLoading ,
@@ -440,8 +436,6 @@ export const ScriptTable = ({
440436 updateScripts,
441437 setUserConfig,
442438 setCloudScript,
443- searchRequest,
444- setSearchRequest,
445439 handleDelete,
446440 handleConfig,
447441 handleRunStop,
@@ -451,7 +445,6 @@ export const ScriptTable = ({
451445 const [ action , setAction ] = useState ( "" ) ;
452446 const [ select , setSelect ] = useState < Script [ ] > ( [ ] ) ;
453447 const [ selectColumn , setSelectColumn ] = useState ( 0 ) ;
454- const inputRef = useRef < RefInputType > ( null ) ;
455448 const navigate = useNavigate ( ) ;
456449 const [ savedWidths , setSavedWidths ] = useState < { [ key : string ] : number } | null > ( null ) ;
457450
@@ -494,25 +487,30 @@ export const ScriptTable = ({
494487 dataIndex : "name" ,
495488 sorter : ( a , b ) => a . name . localeCompare ( b . name ) ,
496489 filterIcon : < IconSearch /> ,
497- filterDropdown : ( { confirm } : any ) => {
490+ filterDropdown : ( { filterKeys , setFilterKeys , confirm } : any ) => {
498491 return (
499492 < div className = "arco-table-custom-filter flex flex-row gap-2" >
500493 < ScriptSearchField
501494 t = { t }
502- defaultValue = { searchRequest }
495+ autoFocus
496+ defaultValue = { filterKeys ?. [ 0 ] || { type : "auto" , keyword : "" } }
497+ onChange = { ( req ) => {
498+ setFilterKeys ( [ { type : req . type , keyword : req . keyword } ] ) ;
499+ SearchFilter . requestFilterResult ( req ) ;
500+ } }
503501 onSearch = { ( req ) => {
504- setSearchRequest ( req ) ;
502+ if ( req . bySelect ) return ;
505503 confirm ( ) ;
506504 } }
507- inputRef = { inputRef }
508505 />
509506 </ div >
510507 ) ;
511508 } ,
512- onFilterDropdownVisibleChange : ( visible ) => {
513- if ( visible ) {
514- setTimeout ( ( ) => inputRef . current ! . focus ( ) , 1 ) ;
509+ onFilter : ( value , row ) => {
510+ if ( ! value || ! value . keyword ) {
511+ return true ;
515512 }
513+ return SearchFilter . checkByUUID ( row . uuid ) ;
516514 } ,
517515 className : "max-w-[240px] min-w-[100px]" ,
518516 render : ( col : string , item : ListType ) => < NameCell col = { col } item = { item } /> ,
@@ -620,8 +618,6 @@ export const ScriptTable = ({
620618 t ,
621619 sidebarOpen ,
622620 updateScripts ,
623- searchRequest ,
624- setSearchRequest ,
625621 navigate ,
626622 setSidebarOpen ,
627623 setViewMode ,
0 commit comments