260722_01_ENH: 버그 수정 및 개선 사항 수정

This commit is contained in:
2026-07-22 16:53:00 +09:00
parent d8b565276d
commit 2dd5b88c6f
67 changed files with 1925 additions and 736 deletions

View File

@@ -1,5 +1,6 @@
'use client'
import * as React from 'react'
import type { CSSProperties } from 'react'
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select'
import { cn } from '@/lib/utils'
@@ -9,6 +10,10 @@ export type KriSelectItem = {
label: string
}
export type KriSelectRef = {
focus: () => void
}
export type KriSelectProps<T> = {
items: T[]
value: string
@@ -24,6 +29,7 @@ export type KriSelectProps<T> = {
getLabel?: (item: T) => string
useAll?: boolean
disabled?: boolean
'aria-invalid'?: boolean
}
const HEIGHT_CLASS_VALUE: Record<string, CSSProperties['height']> = {
@@ -34,22 +40,34 @@ const HEIGHT_CLASS_VALUE: Record<string, CSSProperties['height']> = {
'h-10': '2.5rem',
}
export function KriSelect<T>({
items,
value,
onChange,
onChangeOption,
placeholder,
className,
heightClassName,
triggerTextClassName,
contentClassName,
itemClassName,
getValue,
getLabel,
useAll = true,
disabled,
}: KriSelectProps<T>) {
function KriSelectInner<T>(
{
items,
value,
onChange,
onChangeOption,
placeholder,
className,
heightClassName,
triggerTextClassName,
contentClassName,
itemClassName,
getValue,
getLabel,
useAll = true,
disabled,
'aria-invalid': ariaInvalid,
}: KriSelectProps<T>,
forwardedRef: React.ForwardedRef<KriSelectRef>,
) {
const triggerRef = React.useRef<HTMLButtonElement>(null)
React.useImperativeHandle(
forwardedRef,
() => ({
focus: () => triggerRef.current?.focus(),
}),
[],
)
const extractValue = (item: T) => (getValue ? getValue(item) : String(item))
const extractLabel = (item: T) => (getLabel ? getLabel(item) : String(item))
const triggerStyle: CSSProperties | undefined = heightClassName
@@ -70,9 +88,11 @@ export function KriSelect<T>({
}}
>
<SelectTrigger
ref={triggerRef}
className={cn('w-fit whitespace-nowrap bg-white', triggerTextClassName, heightClassName, className)}
style={triggerStyle}
aria-label={placeholder ?? 'select'}
aria-invalid={ariaInvalid}
>
<SelectValue placeholder={placeholder} />
</SelectTrigger>
@@ -96,3 +116,7 @@ export function KriSelect<T>({
</Select>
)
}
export const KriSelect = React.forwardRef(KriSelectInner) as <T = unknown>(
props: KriSelectProps<T> & { ref?: React.ForwardedRef<KriSelectRef> },
) => React.ReactElement