diff options
| author | 0-Zz-ang <s1998319@gmail.com> | 2025-08-04 14:59:15 +0900 |
|---|---|---|
| committer | 0-Zz-ang <s1998319@gmail.com> | 2025-08-04 14:59:15 +0900 |
| commit | 59b5715ebb3e1fd7bd4eb02ce50399715734f865 (patch) | |
| tree | 39ccd16482c1b90b6583ead73384822157254d88 /components/data-table/data-table-global-filter-detail.tsx | |
| parent | f0213de0d2fb5fcb931b3ddaddcbb6581cab5d28 (diff) | |
(박서영) docu-list-rule detail sheet 컴포넌트 추가 및 검색 필터 기능 오류 수정
Diffstat (limited to 'components/data-table/data-table-global-filter-detail.tsx')
| -rw-r--r-- | components/data-table/data-table-global-filter-detail.tsx | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/components/data-table/data-table-global-filter-detail.tsx b/components/data-table/data-table-global-filter-detail.tsx new file mode 100644 index 00000000..1db85bec --- /dev/null +++ b/components/data-table/data-table-global-filter-detail.tsx @@ -0,0 +1,45 @@ +"use client" + +import * as React from "react" +import { Input } from "@/components/ui/input" +import { useDebouncedCallback } from "@/hooks/use-debounced-callback" +import { type Table } from "@tanstack/react-table" + +interface DataTableGlobalFilterDetailProps<TData> { + table: Table<TData> + placeholder?: string + className?: string +} + +/** + * 디테일 시트 전용 글로벌 필터 - URL 상태와 연결되지 않는 독립적인 검색 + */ +export function DataTableGlobalFilterDetail<TData>({ + table, + placeholder = "Search...", + className = "h-8 w-24 sm:w-40" +}: DataTableGlobalFilterDetailProps<TData>) { + const [value, setValue] = React.useState("") + + // Debounced callback that sets the table's global filter + const debouncedSetGlobalFilter = useDebouncedCallback((value: string) => { + table.setGlobalFilter(value) + }, 300) + + // When user types, update local value immediately, + // then call the debounced function to update the table filter + const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => { + const val = e.target.value + setValue(val) + debouncedSetGlobalFilter(val) + } + + return ( + <Input + value={value} + onChange={handleChange} + placeholder={placeholder} + className={className} + /> + ) +}
\ No newline at end of file |
