selectbox 원복

This commit is contained in:
YangJinSoo94
2025-03-26 17:48:52 +09:00
parent 8346f59f45
commit e781af3209
@@ -4,22 +4,28 @@ import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from ".
/** 차트 기본 스타일 */
interface SelectBox1 {
text:string|number,
text:string,
val:string
}
const SelectBox = React.forwardRef<
HTMLDivElement,
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;
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 ?? "";
return (
<div className={className+" flex items-center"} ref={ref}>
{label && <Label className="w-20 text-base text-gray-600">{label}</Label>}
<Select onValueChange={onSelectValue}>
<SelectTrigger className={selectClass?selectClass:"ml-8 w-3/4 text-base text-gray-600"}>
<Select onValueChange={onSelectValue} value={value}>
<SelectTrigger className={selectClass?selectClass:"flex-1 p-2 border rounded"}>
<SelectValue placeholder={placeHolder} />
</SelectTrigger>
<SelectContent>