summaryrefslogtreecommitdiff
path: root/components/data-table/data-table-global-filter-detail.tsx
diff options
context:
space:
mode:
authordujinkim <dujin.kim@dtsolution.co.kr>2025-08-04 09:36:26 +0000
committerdujinkim <dujin.kim@dtsolution.co.kr>2025-08-04 09:36:26 +0000
commit3e4d15271322397764601dee09441af8a5b3adf5 (patch)
tree2277d5f7154139b5cb155eb0edc0c36752112320 /components/data-table/data-table-global-filter-detail.tsx
parent92eda21e45d902663052575aaa4c4f80bfa2faea (diff)
parent59b5715ebb3e1fd7bd4eb02ce50399715734f865 (diff)
Merge branch 'dujinkim' of https://github.com/DTS-Development/SHI_EVCP into dujinkim
Diffstat (limited to 'components/data-table/data-table-global-filter-detail.tsx')
-rw-r--r--components/data-table/data-table-global-filter-detail.tsx45
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