251201_01_ENH : datatable, autocomplete, user관리 완성

This commit is contained in:
2025-12-02 13:45:35 +09:00
parent 74de3d58f7
commit 310506d9ef
45 changed files with 5313 additions and 368 deletions

View File

@@ -0,0 +1,74 @@
'use client'
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select'
import { cn } from '@/lib/utils'
export type KriSelectItem = {
value: string
label: string
}
type KriSelectProps<T> = {
/** options 배열: string[] 혹은 T[] */
items: T[]
/** 현재 선택 값 */
value: string
/** 값 변경 시 호출 */
onChange: (value: string) => void
/** placeholder 텍스트 */
placeholder?: string
/** 기타 클래스 (예: 'w-40') */
className?: string
/** value를 어떻게 뽑을지 (없으면 String(item)) */
getValue?: (item: T) => string
/** label을 어떻게 뽑을지 (없으면 String(item)) */
getLabel?: (item: T) => string
/** 전체 사용 여부 */
useAll?: boolean
}
export function KriSelect<T>({
items,
value,
onChange,
placeholder,
className,
getValue,
getLabel,
useAll = true,
}: KriSelectProps<T>) {
const extractValue = (item: T) =>
getValue ? getValue(item) : String(item)
const extractLabel = (item: T) =>
getLabel ? getLabel(item) : String(item)
return (
<Select
value={value}
onValueChange={onChange}
>
<SelectTrigger
className={cn(
'w-fit whitespace-nowrap bg-white content-text-lg', // 폰트 사이즈
className
)}
aria-label={placeholder ?? 'select'}
>
<SelectValue placeholder={placeholder} />
</SelectTrigger>
<SelectContent>
{ useAll? <SelectItem key="ALL" value="ALL">전체</SelectItem> :null }
{items.map((item, idx) => {
const v = extractValue(item)
const label = extractLabel(item)
return (
<SelectItem key={v ?? idx} value={v}>
{label}
</SelectItem>
)
})}
</SelectContent>
</Select>
)
}