%PDF- <> %âãÏÓ endobj 2 0 obj <> endobj 3 0 obj <>/ExtGState<>/ProcSet[/PDF/Text/ImageB/ImageC/ImageI] >>/Annots[ 28 0 R 29 0 R] /MediaBox[ 0 0 595.5 842.25] /Contents 4 0 R/Group<>/Tabs/S>> endobj ºaâÚÎΞ-ÌE1ÍØÄ÷{òò2ÿ ÛÖ^ÔÀá TÎ{¦?§®¥kuµùÕ5sLOšuY>endobj 2 0 obj<>endobj 2 0 obj<>endobj 2 0 obj<>endobj 2 0 obj<> endobj 2 0 obj<>endobj 2 0 obj<>es 3 0 R>> endobj 2 0 obj<> ox[ 0.000000 0.000000 609.600000 935.600000]/Fi endobj 3 0 obj<> endobj 7 1 obj<>/ProcSet[/PDF/Text/ImageB/ImageC/ImageI]>>/Subtype/Form>> stream
/* eslint-disable react-hooks/exhaustive-deps */ import React from 'react'; import {Select} from 'antd'; export function AntdSelect(props) { let { placeholder, options, value, sort, ...rest } = props; if(!value && value!==0){ value=null; }else if(value+'' && typeof value !== "object"){ value=value+''; } if (typeof options !== "object") { options = []; } if (typeof options[0] !== "object") { let ops = [...options]; options = []; for (let ind in ops) { options.push({ value: ops[ind], label: ops[ind] }); } } if (typeof options[0]?.value === "undefined") { let ops=[...options]; options=[]; ops.forEach(v=>{ options.push({value: v.id, label: v.title || v.name}); }) } options.forEach(v => { v.value += ''; v.label += ''; }) if (sort) { options.sort((a, b) => { return ('' + a.label).localeCompare(b.label); }) } return ( <> <Select style={{ width: '100%' }} placeholder={placeholder || "Select"} options={options} value={(value !== null && typeof value !== "undefined") ? (value) : null} filterOption={ (input, option) => { return option.label.toLowerCase().indexOf(input.toLowerCase()) >= 0 } } {...rest} > </Select> </> ) } /* How to use: <AntdSelect options={[{value:1, label:"Title1"}, {value:2, label:"Title2"}, {value:3, label:"Title3"}]} showSearch allowClear onChange={e=>{ console.log(e) }} /> */