251216_01_ENH : 프로젝트에 FW User 배정 구현 및 테스트 완료
This commit is contained in:
@@ -14,7 +14,9 @@ type KriSelectProps<T> = {
|
||||
/** 현재 선택 값 */
|
||||
value: string
|
||||
/** 값 변경 시 호출 */
|
||||
onChange: (value: string) => void
|
||||
onChange?: (value: string) => void
|
||||
/** 옵션 변경시 호출 */
|
||||
onChangeOption?: (option: T) => void
|
||||
/** placeholder 텍스트 */
|
||||
placeholder?: string
|
||||
/** 기타 클래스 (예: 'w-40') */
|
||||
@@ -31,22 +33,31 @@ export function KriSelect<T>({
|
||||
items,
|
||||
value,
|
||||
onChange,
|
||||
onChangeOption,
|
||||
placeholder,
|
||||
className,
|
||||
getValue,
|
||||
getLabel,
|
||||
useAll = true,
|
||||
}: KriSelectProps<T>) {
|
||||
|
||||
const extractValue = (item: T) =>
|
||||
getValue ? getValue(item) : String(item)
|
||||
getValue ? getValue(item) : String(item);
|
||||
|
||||
const extractLabel = (item: T) =>
|
||||
getLabel ? getLabel(item) : String(item)
|
||||
getLabel ? getLabel(item) : String(item);
|
||||
|
||||
return (
|
||||
<Select
|
||||
value={value}
|
||||
onValueChange={onChange}
|
||||
onValueChange={(v) => {
|
||||
onChange?.(v);
|
||||
|
||||
const selected = items.find((item) => extractValue(item) === v);
|
||||
if(selected) {
|
||||
onChangeOption?.(selected);
|
||||
}
|
||||
}}
|
||||
>
|
||||
<SelectTrigger
|
||||
className={cn(
|
||||
@@ -60,8 +71,9 @@ export function KriSelect<T>({
|
||||
<SelectContent>
|
||||
{ useAll? <SelectItem key="ALL" value="ALL">전체</SelectItem> :null }
|
||||
{items.map((item, idx) => {
|
||||
const v = extractValue(item)
|
||||
const label = extractLabel(item)
|
||||
const v = extractValue(item);
|
||||
const label = extractLabel(item);
|
||||
|
||||
return (
|
||||
<SelectItem key={v ?? idx} value={v}>
|
||||
{label}
|
||||
|
||||
Reference in New Issue
Block a user