select, search_iinput_select 초기화가 될수 있도록 파라미터 수정
This commit is contained in:
@@ -11,19 +11,23 @@ export type SelectDataType = {
|
||||
* @param label - string label
|
||||
* @param selectData - SelectDataType[] 선택 데이터
|
||||
* @param onSelectValue - (val:string)=>void 선택 값 콜백
|
||||
* @param textValue - string 입력 값
|
||||
* @param setText - (val:string)=>void 입력 값 설정 콜백
|
||||
* @param selectValue - string select 선택 값
|
||||
* @param refs - React.forwardRef<HTMLInputElement> | null 입력값 ref
|
||||
* @returns React.FC
|
||||
*/
|
||||
const SearchInputSelect = React.forwardRef<HTMLInputElement, {className:string, label:string, selectData: SelectDataType[], onSelectValue:(val:string)=>void, textValue:string, setText:(val:string)=>void}>(({className, label, selectData, onSelectValue, textValue, setText}, ref) => {
|
||||
const SearchInputSelect = React.forwardRef<HTMLInputElement, {className:string, label:string, selectData: SelectDataType[], onSelectValue:(val:string)=>void, textValue:string, setText:(val:string)=>void, selectValue:string}>(({className, label, selectData, onSelectValue, textValue, setText, selectValue}, ref) => {
|
||||
const changeText=(e:React.ChangeEvent<HTMLInputElement>)=>{
|
||||
if(e?.target?.value) setText(e.target.value)
|
||||
}
|
||||
|
||||
return (
|
||||
<div className={className+" flex items-center"} >
|
||||
{label && <Label className="m-4 text-2xl w-1/4">{label}</Label>}
|
||||
<div className="flex w-full items-center">
|
||||
<Input className="w-2/3 text-lg" value={textValue} onChange={changeText} />
|
||||
<Select onValueChange={onSelectValue}>
|
||||
<Select onValueChange={onSelectValue} value={selectValue}>
|
||||
<SelectTrigger className="ml-2 w-1/3 text-lg" >
|
||||
<SelectValue placeholder={selectData?.[0]?.text ?? ""} />
|
||||
</SelectTrigger>
|
||||
@@ -38,4 +42,4 @@ const SearchInputSelect = React.forwardRef<HTMLInputElement, {className:string,
|
||||
</div>
|
||||
)
|
||||
});
|
||||
export { SearchInputSelect };
|
||||
export { SearchInputSelect };
|
||||
@@ -8,17 +8,23 @@ interface SelectBox1 {
|
||||
val:string
|
||||
}
|
||||
|
||||
|
||||
const SelectBox = React.forwardRef<
|
||||
HTMLDivElement,
|
||||
React.HTMLAttributes<HTMLDivElement> & {label:string, selectClass:string|undefined, className:string, selectArray:SelectBox1[], onSelectValue:(val:string)=>void}
|
||||
>(({ label, className, selectClass, selectArray, onSelectValue }, ref)=>{
|
||||
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="m-4 text-2xl w-1/4">{label}</Label>}
|
||||
<Select onValueChange={onSelectValue}>
|
||||
<Select onValueChange={onSelectValue} value={value}>
|
||||
<SelectTrigger className={selectClass?selectClass:"ml-8 w-3/4 text-2xl"}>
|
||||
<SelectValue placeholder={placeHolder} />
|
||||
</SelectTrigger>
|
||||
|
||||
Reference in New Issue
Block a user