selectBox default value 추가

This commit is contained in:
leedj312
2025-03-26 16:56:55 +09:00
parent a147d972b8
commit c966581a99
@@ -4,28 +4,22 @@ import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from ".
/** 차트 기본 스타일 */
interface SelectBox1 {
text:string,
text:string|number,
val:string
}
const SelectBox = React.forwardRef<
HTMLDivElement,
React.HTMLAttributes<HTMLDivElement> & {
label:string,
selectClass:string|undefined,
className:string,
selectArray:SelectBox1[],
onSelectValue:(val:string)=>void,
value?: string
}
>(({ label, className, selectClass, selectArray, onSelectValue, value }, ref)=>{
const placeHolder = selectArray?.[0]?.text ?? "";
React.HTMLAttributes<HTMLDivElement> & {label:string, selectClass:string|undefined, className:string, selectArray:SelectBox1[], onSelectValue:(val:string)=>void , defaultValue:string|number|undefined }
>(({ label, className, selectClass, selectArray, onSelectValue, defaultValue }, ref)=>{
const placeHolder = defaultValue ? selectArray.find(item => defaultValue === item.val)?.text : selectArray?.[0]?.text;
return (
<div className={className+" flex items-center"} ref={ref}>
{label && <Label className="w-20 text-base text-gray-600">{label}</Label>}
<Select onValueChange={onSelectValue} value={value}>
<SelectTrigger className={selectClass?selectClass:"flex-1 p-2 border rounded"}>
{label && <Label className="m-4 text-2xl w-1/4">{label}</Label>}
<Select onValueChange={onSelectValue}>
<SelectTrigger className={selectClass?selectClass:"ml-8 w-3/4 text-2xl"}>
<SelectValue placeholder={placeHolder} />
</SelectTrigger>
<SelectContent>