From 59b5715ebb3e1fd7bd4eb02ce50399715734f865 Mon Sep 17 00:00:00 2001 From: 0-Zz-ang Date: Mon, 4 Aug 2025 14:59:15 +0900 Subject: (박서영) docu-list-rule detail sheet 컴포넌트 추가 및 검색 필터 기능 오류 수정 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../data-table/data-table-global-filter-detail.tsx | 45 ++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 components/data-table/data-table-global-filter-detail.tsx (limited to 'components/data-table/data-table-global-filter-detail.tsx') 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 { + table: Table + placeholder?: string + className?: string +} + +/** + * 디테일 시트 전용 글로벌 필터 - URL 상태와 연결되지 않는 독립적인 검색 + */ +export function DataTableGlobalFilterDetail({ + table, + placeholder = "Search...", + className = "h-8 w-24 sm:w-40" +}: DataTableGlobalFilterDetailProps) { + 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) => { + const val = e.target.value + setValue(val) + debouncedSetGlobalFilter(val) + } + + return ( + + ) +} \ No newline at end of file -- cgit v1.2.3