react-selectrix

我要开发同款
匿名用户2021年11月23日
148阅读

技术信息

授权协议
MIT License

作品详情

ReactSelectrix

Abeautiful,materialized,easytouseadflexibleReactSelectreplacemet

Demo

Checkoutthedemoaduseexampleshere!

Istalligpmi--save-devreact-selectrixDocumetatio

https://github.com/stratos-vetsos/react-selectrix/

ImporttoyourprojectimportSelectrixfrom"react-selectrix";BasicExample<Selectrixmultiple={true}materialize={true}optios={[{key:"javascript",label:"Javascript"},{key:"go",label:"Go"},{key:"ruby",label:"RubyORails"},{key:"php",label:"PHP"}]}oChage={value=>cosole.log(value)}/>PropsNameTypeDefaultValueDescriptiooptiosarray[]Aarrayoftheavailableoptios(Objectswith"key","label"pairsadoptioally"disabled"property).multiplebooleafalseWhethertheSelectsupportsmultiplevalues.searchablebooleatrueWhethertheSelectissearchable.oResultsMessagestrigNoresultsmatchThemessageoftheoresultsmatch.materializebooleatrueWhetherthestyleoftheSelectshouldbeMaterializedordefault.defaultValueboolea/array/strigfalseIfyouhavepreselectedvaluesusethisproperty.Useaarrayofoptiokeysformultipleselectios,orkeyasastrigforsigleselectio.checkBoxesbooleafalseSetthistotrueifyouwattorederCheckboxesisteadoflistitems.heightumber190Theheightofthedropdow.placeHolderIsidebooleafalseIftheplaceholdershouldbeaoptio.placeholderstrigPleaseSelectTheplaceholderoftheSelect.isOpebooleafalseIftheSelectshouldberederedope.arrowbooleatrueWhethertoshowaarrowoSelect'sheader.disabledbooleafalseWhethertheSelectshouldbedisabled.customScrollbarbooleafalseAcustomscrollbar(olyforChrome)stayOpebooleafalseIftheSelectshouldstayopeorot.commaSeperatedbooleafalseIfyouwattheselectedvaluestobeacommaseperatedstrig,turthisto"true".(Availableolywithmultiplepropsetto"true".)sigleLiebooleafalseWheretheselectedvalues(Select'sHeader)shouldbecotaiedtooelie.lifobooleafalseLastIFirstOutMode.Theuser'slastselectio,goesfirst.(Availableolywithmultiplepropsetto"true".)searchIdexbooleatrueEablesearchbybothIdexadValuefieldsselectAllButtobooleafalseWhethera"selectallbutto"shouldbevisibleoSelect'sheader.isDropDowbooleatrueSetthistotrueifyouwattousetheSelectasaDropdow.Wheyouselectaoptio,theSelectcollapsesadtheheadercotiuetohavetheplaceholderasavalue.tagsbooleafalseWhethertosupportcustomtags.customKeysobject/booleafalsePassaobjecttochagethedefaultoptiokeys(key,label).ExampleSytax:{key:"url",label:"title"},tochagethekeyto"url"adthelabelto"title".ajaxboolea/objectfalseWhethertoeableajax.ThelibrarysupportsasychroouscallsthroughfetchAPI.Availabledefaultpropertiesofajaxobject:{url:'',headers:{},debouce:200,fetchOSearch:false,q:"",estedKey:false,searchPrompt:true,miLegth:1}.Youcafiddetailsforalltheajaxobjectproperties,itheextsectioadiourdemopage.oRederOptiofuctio/booleafalseUsethisfuctiotoredercustomoptioitemsoRederSelectiofuctio/booleafalseUsethisfuctiotoredercustomselecteditemsoChagefuctioudefiedUsethiscallbacktocatchSelect'schagetrigger.oOpefuctioudefiedUsethiscallbacktocatchSelect'sopetrigger.oClosefuctioudefiedUsethiscallbacktocatchSelect'sclosetrigger.Ajaxprop-breakdowNameTypeDefaultValueDescriptiourlstrig''TheurlwhichtheSelectgoigtofetchtheavailableoptios.headersobject{}Passayheadersyouwattofetchapi.debouceumber200Thedebouceoftheajaxcallsimillisecods.fetchOSearchbooleafalseWhetheryoudo'twattohavetheoptiosprepopulated,whetheSelectopes,butyouwattoquerythembasedouser'ssearchvalue.qstrig''ThispropertygoesalogsidewithfetchOSearchproperty,settedto"true".DepedigtheRESTAPIprovidigyouwithoptios,youhavetochagethisvalueaccordigly.e.g."&search={q}".Whereveryouusethepseudovariable{q},theuser'ssearchquerywillijectedithefialrequest.estedKeystrig/booleafalseIfyourRESTAPIreturstheactualdataiadeeperlevel,isideaestedkey,let'ssay"articles",setestedKeyto"articles".searchPromptbooleatrueThispropertygoesalogsidewithfetchOSearchpropertyadidicatestheuserhowmaymorecharactersshouldtype,beforetheajaxsearchwillhappe.miLegthumber1ThispropertygoesalogsidewithfetchOSearchpropertyadsearchPromptsettedto"true".Itisthemilegthofcharacterstheusershouldtype,beforetheajaxcallsearchtakesplace.Callbacks-breakdowNameArgumetsDescriptiooChagevalueTheselectedobjectiftheSelectissigleadaarrayofobjectsiftheSelectismultiple.oRederOptiooptio,idexTheoptiowhichisgoigtoberederedadit'scorrespodigidex.oRederSelectioselected,settigs,deselectTheselectedobject,theSelect'ssettigsadacallbackfuctiotousefordeselectio.oOpeN/AoCloseN/AAjaxExample

Maythakstoewsapi.orgfortheirgreatapi.Checkthisexampleiactio,iourdemopage.

<SelectrixcustomKeys={{key:"url",label:"title"}}ajax={{url:"https://ewsapi.org/v2/everythig?q=bitcoi&sortBy=publishedAt&apiKey=9342a9a707ca49c4b2da34e9ea238ea6",estedKey:"articles"}}/>AjaxExamplewithfetchOSearch

Checkthisexampleiactio,iourdemopage.

<Selectrixmultiple={true}stayOpe={true}materialize={true}customKeys={{key:"url",label:"title"}}ajax={{url:"https://ewsapi.org/v2/top-headlies?apiKey=9342a9a707ca49c4b2da34e9ea238ea6",fetchOSearch:true,q:"&q={q}",estedKey:"articles",miLegth:3,debouce:300}}/>TagsExample

Checkthisexampleiactio,iourdemopage.

<Selectrixmultiple={true}materialize={true}tags={true}optios={[{key:"hotdog",label:"HotDog"},{key:"pizza",label:"Pizza"}]}oChage={value=>cosole.log(value)}/>CustomRederExample

Checkthisexampleiactio,iourdemopage.

<Selectrixmultiple={true}materialize={true}optios={[{key:"javascript",label:"Javascript"},{key:"go",label:"Go"},{key:"ruby",label:"RubyORails"},{key:"php",label:"PHP"}]}oRederOptio={oRederOptio}oRederSelectio={oRederSelectio}oChage={value=>cosole.log(value)}/>costoRederOptio=(optio,idex)=>(<spa><iclassName="fafa-laptop"></i>{optio.label}</spa>)costoRederSelectio=(selected,settigs,deselect)=>(<spastyle={{margiRight:10,border:"1pxsolid#eee",paddig:5}}>{selected.label}<istyle={{paddigLeft:5,cursor:"poiter"}}oClick={deselect}className="fafa-widow-close"></i></spa>)Licese

MITLicesed.StratosVetsos.

Cotributios

Cotributiosaremorethawelcome.Rupmistall&&pmstartomasteradyouaregoodtogo!TheCONTRIBUTING.mdisgoigtobepublishedsoo.

功能介绍

React Selectrix A beautiful, materialized, easy to use and flexible React Select replacement Demo...

声明:本文仅代表作者观点,不代表本站立场。如果侵犯到您的合法权益,请联系我们删除侵权资源!如果遇到资源链接失效,请您通过评论或工单的方式通知管理员。未经允许,不得转载,本站所有资源文章禁止商业使用运营!
下载安装【程序员客栈】APP
实时对接需求、及时收发消息、丰富的开放项目需求、随时随地查看项目状态

评论