260714_01_ENH: 테스트 서버에서 기동 후 중간 테스트를 위한 커밋
This commit is contained in:
@@ -9,7 +9,7 @@ export type KriSelectItem = {
|
||||
label: string
|
||||
}
|
||||
|
||||
type KriSelectProps<T> = {
|
||||
export type KriSelectProps<T> = {
|
||||
items: T[]
|
||||
value: string
|
||||
onChange?: (value: string) => void
|
||||
@@ -23,6 +23,7 @@ type KriSelectProps<T> = {
|
||||
getValue?: (item: T) => string
|
||||
getLabel?: (item: T) => string
|
||||
useAll?: boolean
|
||||
disabled?: boolean
|
||||
}
|
||||
|
||||
const HEIGHT_CLASS_VALUE: Record<string, CSSProperties['height']> = {
|
||||
@@ -41,12 +42,13 @@ export function KriSelect<T>({
|
||||
placeholder,
|
||||
className,
|
||||
heightClassName,
|
||||
triggerTextClassName = 'text-lg',
|
||||
triggerTextClassName,
|
||||
contentClassName,
|
||||
itemClassName,
|
||||
getValue,
|
||||
getLabel,
|
||||
useAll = true,
|
||||
disabled,
|
||||
}: KriSelectProps<T>) {
|
||||
const extractValue = (item: T) => (getValue ? getValue(item) : String(item))
|
||||
const extractLabel = (item: T) => (getLabel ? getLabel(item) : String(item))
|
||||
@@ -57,10 +59,11 @@ export function KriSelect<T>({
|
||||
return (
|
||||
<Select
|
||||
value={value}
|
||||
onValueChange={(v) => {
|
||||
onChange?.(v)
|
||||
disabled={disabled}
|
||||
onValueChange={(selectedValue) => {
|
||||
onChange?.(selectedValue)
|
||||
|
||||
const selected = items.find((item) => extractValue(item) === v)
|
||||
const selected = items.find((item) => extractValue(item) === selectedValue)
|
||||
if (selected) {
|
||||
onChangeOption?.(selected)
|
||||
}
|
||||
@@ -75,16 +78,16 @@ export function KriSelect<T>({
|
||||
</SelectTrigger>
|
||||
<SelectContent className={contentClassName}>
|
||||
{useAll ? (
|
||||
<SelectItem key="ALL" value="ALL" className={itemClassName}>
|
||||
<SelectItem value="ALL" className={itemClassName}>
|
||||
전체
|
||||
</SelectItem>
|
||||
) : null}
|
||||
{items.map((item, idx) => {
|
||||
const v = extractValue(item)
|
||||
{items.map((item, index) => {
|
||||
const itemValue = extractValue(item)
|
||||
const label = extractLabel(item)
|
||||
|
||||
return (
|
||||
<SelectItem key={v ?? idx} value={v} className={itemClassName}>
|
||||
<SelectItem key={itemValue || index} value={itemValue} className={itemClassName}>
|
||||
{label}
|
||||
</SelectItem>
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user