vant.cjs.js 423 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142
  1. "use strict";
  2. Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
  3. const use = require("@vant/use");
  4. const vue = require("vue");
  5. const popperjs = require("@vant/popperjs");
  6. const isDef = (val) => val !== void 0 && val !== null;
  7. const isFunction = (val) => typeof val === "function";
  8. const isObject = (val) => val !== null && typeof val === "object";
  9. const isPromise = (val) => isObject(val) && isFunction(val.then) && isFunction(val.catch);
  10. const isDate = (val) => Object.prototype.toString.call(val) === "[object Date]" && !Number.isNaN(val.getTime());
  11. function isMobile(value) {
  12. value = value.replace(/[^-|\d]/g, "");
  13. return /^((\+86)|(86))?(1)\d{10}$/.test(value) || /^0[0-9-]{10,13}$/.test(value);
  14. }
  15. const isNumeric = (val) => typeof val === "number" || /^\d+(\.\d+)?$/.test(val);
  16. const isIOS$1 = () => inBrowser ? /ios|iphone|ipad|ipod/.test(navigator.userAgent.toLowerCase()) : false;
  17. function noop() {
  18. }
  19. const extend = Object.assign;
  20. const inBrowser = typeof window !== "undefined";
  21. function get(object, path) {
  22. const keys = path.split(".");
  23. let result = object;
  24. keys.forEach((key) => {
  25. var _a;
  26. result = isObject(result) ? (_a = result[key]) != null ? _a : "" : "";
  27. });
  28. return result;
  29. }
  30. function pick(obj, keys, ignoreUndefined) {
  31. return keys.reduce((ret, key) => {
  32. if (!ignoreUndefined || obj[key] !== void 0) {
  33. ret[key] = obj[key];
  34. }
  35. return ret;
  36. }, {});
  37. }
  38. const toArray = (item) => Array.isArray(item) ? item : [item];
  39. const unknownProp = null;
  40. const numericProp = [Number, String];
  41. const truthProp = {
  42. type: Boolean,
  43. default: true
  44. };
  45. const makeRequiredProp = (type) => ({
  46. type,
  47. required: true
  48. });
  49. const makeArrayProp = () => ({
  50. type: Array,
  51. default: () => []
  52. });
  53. const makeNumberProp = (defaultVal) => ({
  54. type: Number,
  55. default: defaultVal
  56. });
  57. const makeNumericProp = (defaultVal) => ({
  58. type: numericProp,
  59. default: defaultVal
  60. });
  61. const makeStringProp = (defaultVal) => ({
  62. type: String,
  63. default: defaultVal
  64. });
  65. function getScrollTop(el) {
  66. const top = "scrollTop" in el ? el.scrollTop : el.pageYOffset;
  67. return Math.max(top, 0);
  68. }
  69. function setScrollTop(el, value) {
  70. if ("scrollTop" in el) {
  71. el.scrollTop = value;
  72. } else {
  73. el.scrollTo(el.scrollX, value);
  74. }
  75. }
  76. function getRootScrollTop() {
  77. return window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0;
  78. }
  79. function setRootScrollTop(value) {
  80. setScrollTop(window, value);
  81. setScrollTop(document.body, value);
  82. }
  83. function getElementTop(el, scroller) {
  84. if (el === window) {
  85. return 0;
  86. }
  87. const scrollTop = scroller ? getScrollTop(scroller) : getRootScrollTop();
  88. return use.useRect(el).top + scrollTop;
  89. }
  90. const isIOS = isIOS$1();
  91. function resetScroll() {
  92. if (isIOS) {
  93. setRootScrollTop(getRootScrollTop());
  94. }
  95. }
  96. const stopPropagation = (event) => event.stopPropagation();
  97. function preventDefault(event, isStopPropagation) {
  98. if (typeof event.cancelable !== "boolean" || event.cancelable) {
  99. event.preventDefault();
  100. }
  101. if (isStopPropagation) {
  102. stopPropagation(event);
  103. }
  104. }
  105. function isHidden(elementRef) {
  106. const el = vue.unref(elementRef);
  107. if (!el) {
  108. return false;
  109. }
  110. const style = window.getComputedStyle(el);
  111. const hidden = style.display === "none";
  112. const parentHidden = el.offsetParent === null && style.position !== "fixed";
  113. return hidden || parentHidden;
  114. }
  115. const { width: windowWidth, height: windowHeight } = use.useWindowSize();
  116. function addUnit(value) {
  117. if (isDef(value)) {
  118. return isNumeric(value) ? `${value}px` : String(value);
  119. }
  120. return void 0;
  121. }
  122. function getSizeStyle(originSize) {
  123. if (isDef(originSize)) {
  124. if (Array.isArray(originSize)) {
  125. return {
  126. width: addUnit(originSize[0]),
  127. height: addUnit(originSize[1])
  128. };
  129. }
  130. const size = addUnit(originSize);
  131. return {
  132. width: size,
  133. height: size
  134. };
  135. }
  136. }
  137. function getZIndexStyle(zIndex) {
  138. const style = {};
  139. if (zIndex !== void 0) {
  140. style.zIndex = +zIndex;
  141. }
  142. return style;
  143. }
  144. let rootFontSize;
  145. function getRootFontSize() {
  146. if (!rootFontSize) {
  147. const doc = document.documentElement;
  148. const fontSize = doc.style.fontSize || window.getComputedStyle(doc).fontSize;
  149. rootFontSize = parseFloat(fontSize);
  150. }
  151. return rootFontSize;
  152. }
  153. function convertRem(value) {
  154. value = value.replace(/rem/g, "");
  155. return +value * getRootFontSize();
  156. }
  157. function convertVw(value) {
  158. value = value.replace(/vw/g, "");
  159. return +value * windowWidth.value / 100;
  160. }
  161. function convertVh(value) {
  162. value = value.replace(/vh/g, "");
  163. return +value * windowHeight.value / 100;
  164. }
  165. function unitToPx(value) {
  166. if (typeof value === "number") {
  167. return value;
  168. }
  169. if (inBrowser) {
  170. if (value.includes("rem")) {
  171. return convertRem(value);
  172. }
  173. if (value.includes("vw")) {
  174. return convertVw(value);
  175. }
  176. if (value.includes("vh")) {
  177. return convertVh(value);
  178. }
  179. }
  180. return parseFloat(value);
  181. }
  182. const camelizeRE = /-(\w)/g;
  183. const camelize = (str) => str.replace(camelizeRE, (_, c) => c.toUpperCase());
  184. const kebabCase = (str) => str.replace(/([A-Z])/g, "-$1").toLowerCase().replace(/^-/, "");
  185. function padZero(num, targetLength = 2) {
  186. let str = num + "";
  187. while (str.length < targetLength) {
  188. str = "0" + str;
  189. }
  190. return str;
  191. }
  192. const clamp = (num, min, max) => Math.min(Math.max(num, min), max);
  193. function trimExtraChar(value, char, regExp) {
  194. const index = value.indexOf(char);
  195. if (index === -1) {
  196. return value;
  197. }
  198. if (char === "-" && index !== 0) {
  199. return value.slice(0, index);
  200. }
  201. return value.slice(0, index + 1) + value.slice(index).replace(regExp, "");
  202. }
  203. function formatNumber(value, allowDot = true, allowMinus = true) {
  204. if (allowDot) {
  205. value = trimExtraChar(value, ".", /\./g);
  206. } else {
  207. value = value.split(".")[0];
  208. }
  209. if (allowMinus) {
  210. value = trimExtraChar(value, "-", /-/g);
  211. } else {
  212. value = value.replace(/-/, "");
  213. }
  214. const regExp = allowDot ? /[^-0-9.]/g : /[^-0-9]/g;
  215. return value.replace(regExp, "");
  216. }
  217. function addNumber(num1, num2) {
  218. const cardinal = 10 ** 10;
  219. return Math.round((num1 + num2) * cardinal) / cardinal;
  220. }
  221. const { hasOwnProperty } = Object.prototype;
  222. function assignKey(to, from, key) {
  223. const val = from[key];
  224. if (!isDef(val)) {
  225. return;
  226. }
  227. if (!hasOwnProperty.call(to, key) || !isObject(val)) {
  228. to[key] = val;
  229. } else {
  230. to[key] = deepAssign(Object(to[key]), val);
  231. }
  232. }
  233. function deepAssign(to, from) {
  234. Object.keys(from).forEach((key) => {
  235. assignKey(to, from, key);
  236. });
  237. return to;
  238. }
  239. var stdin_default$1E = {
  240. name: "\u59D3\u540D",
  241. tel: "\u7535\u8BDD",
  242. save: "\u4FDD\u5B58",
  243. confirm: "\u786E\u8BA4",
  244. cancel: "\u53D6\u6D88",
  245. delete: "\u5220\u9664",
  246. loading: "\u52A0\u8F7D\u4E2D...",
  247. noCoupon: "\u6682\u65E0\u4F18\u60E0\u5238",
  248. nameEmpty: "\u8BF7\u586B\u5199\u59D3\u540D",
  249. addContact: "\u6DFB\u52A0\u8054\u7CFB\u4EBA",
  250. telInvalid: "\u8BF7\u586B\u5199\u6B63\u786E\u7684\u7535\u8BDD",
  251. vanCalendar: {
  252. end: "\u7ED3\u675F",
  253. start: "\u5F00\u59CB",
  254. title: "\u65E5\u671F\u9009\u62E9",
  255. weekdays: ["\u65E5", "\u4E00", "\u4E8C", "\u4E09", "\u56DB", "\u4E94", "\u516D"],
  256. monthTitle: (year, month) => `${year}\u5E74${month}\u6708`,
  257. rangePrompt: (maxRange) => `\u6700\u591A\u9009\u62E9 ${maxRange} \u5929`
  258. },
  259. vanCascader: {
  260. select: "\u8BF7\u9009\u62E9"
  261. },
  262. vanPagination: {
  263. prev: "\u4E0A\u4E00\u9875",
  264. next: "\u4E0B\u4E00\u9875"
  265. },
  266. vanPullRefresh: {
  267. pulling: "\u4E0B\u62C9\u5373\u53EF\u5237\u65B0...",
  268. loosing: "\u91CA\u653E\u5373\u53EF\u5237\u65B0..."
  269. },
  270. vanSubmitBar: {
  271. label: "\u5408\u8BA1:"
  272. },
  273. vanCoupon: {
  274. unlimited: "\u65E0\u95E8\u69DB",
  275. discount: (discount) => `${discount}\u6298`,
  276. condition: (condition) => `\u6EE1${condition}\u5143\u53EF\u7528`
  277. },
  278. vanCouponCell: {
  279. title: "\u4F18\u60E0\u5238",
  280. count: (count) => `${count}\u5F20\u53EF\u7528`
  281. },
  282. vanCouponList: {
  283. exchange: "\u5151\u6362",
  284. close: "\u4E0D\u4F7F\u7528",
  285. enable: "\u53EF\u7528",
  286. disabled: "\u4E0D\u53EF\u7528",
  287. placeholder: "\u8F93\u5165\u4F18\u60E0\u7801"
  288. },
  289. vanAddressEdit: {
  290. area: "\u5730\u533A",
  291. postal: "\u90AE\u653F\u7F16\u7801",
  292. areaEmpty: "\u8BF7\u9009\u62E9\u5730\u533A",
  293. addressEmpty: "\u8BF7\u586B\u5199\u8BE6\u7EC6\u5730\u5740",
  294. postalEmpty: "\u90AE\u653F\u7F16\u7801\u4E0D\u6B63\u786E",
  295. addressDetail: "\u8BE6\u7EC6\u5730\u5740",
  296. defaultAddress: "\u8BBE\u4E3A\u9ED8\u8BA4\u6536\u8D27\u5730\u5740"
  297. },
  298. vanAddressList: {
  299. add: "\u65B0\u589E\u5730\u5740"
  300. }
  301. };
  302. const lang = vue.ref("zh-CN");
  303. const messages = vue.reactive({
  304. "zh-CN": stdin_default$1E
  305. });
  306. const Locale = {
  307. messages() {
  308. return messages[lang.value];
  309. },
  310. use(newLang, newMessages) {
  311. lang.value = newLang;
  312. this.add({ [newLang]: newMessages });
  313. },
  314. add(newMessages = {}) {
  315. deepAssign(messages, newMessages);
  316. }
  317. };
  318. var stdin_default$1D = Locale;
  319. function createTranslate(name2) {
  320. const prefix = camelize(name2) + ".";
  321. return (path, ...args) => {
  322. const messages2 = stdin_default$1D.messages();
  323. const message = get(messages2, prefix + path) || get(messages2, path);
  324. return isFunction(message) ? message(...args) : message;
  325. };
  326. }
  327. function genBem(name2, mods) {
  328. if (!mods) {
  329. return "";
  330. }
  331. if (typeof mods === "string") {
  332. return ` ${name2}--${mods}`;
  333. }
  334. if (Array.isArray(mods)) {
  335. return mods.reduce(
  336. (ret, item) => ret + genBem(name2, item),
  337. ""
  338. );
  339. }
  340. return Object.keys(mods).reduce(
  341. (ret, key) => ret + (mods[key] ? genBem(name2, key) : ""),
  342. ""
  343. );
  344. }
  345. function createBEM(name2) {
  346. return (el, mods) => {
  347. if (el && typeof el !== "string") {
  348. mods = el;
  349. el = "";
  350. }
  351. el = el ? `${name2}__${el}` : name2;
  352. return `${el}${genBem(el, mods)}`;
  353. };
  354. }
  355. function createNamespace(name2) {
  356. const prefixedName = `van-${name2}`;
  357. return [
  358. prefixedName,
  359. createBEM(prefixedName),
  360. createTranslate(prefixedName)
  361. ];
  362. }
  363. const BORDER = "van-hairline";
  364. const BORDER_TOP = `${BORDER}--top`;
  365. const BORDER_LEFT = `${BORDER}--left`;
  366. const BORDER_BOTTOM = `${BORDER}--bottom`;
  367. const BORDER_SURROUND = `${BORDER}--surround`;
  368. const BORDER_TOP_BOTTOM = `${BORDER}--top-bottom`;
  369. const BORDER_UNSET_TOP_BOTTOM = `${BORDER}-unset--top-bottom`;
  370. const HAPTICS_FEEDBACK = "van-haptics-feedback";
  371. const FORM_KEY = Symbol("van-form");
  372. function callInterceptor(interceptor, {
  373. args = [],
  374. done,
  375. canceled
  376. }) {
  377. if (interceptor) {
  378. const returnVal = interceptor.apply(null, args);
  379. if (isPromise(returnVal)) {
  380. returnVal.then((value) => {
  381. if (value) {
  382. done();
  383. } else if (canceled) {
  384. canceled();
  385. }
  386. }).catch(noop);
  387. } else if (returnVal) {
  388. done();
  389. } else if (canceled) {
  390. canceled();
  391. }
  392. } else {
  393. done();
  394. }
  395. }
  396. function withInstall(options) {
  397. options.install = (app) => {
  398. const { name: name2 } = options;
  399. if (name2) {
  400. app.component(name2, options);
  401. app.component(camelize(`-${name2}`), options);
  402. }
  403. };
  404. return options;
  405. }
  406. const POPUP_TOGGLE_KEY = Symbol();
  407. function onPopupReopen(callback) {
  408. const popupToggleStatus = vue.inject(POPUP_TOGGLE_KEY, null);
  409. if (popupToggleStatus) {
  410. vue.watch(popupToggleStatus, (show) => {
  411. if (show) {
  412. callback();
  413. }
  414. });
  415. }
  416. }
  417. const useHeight = (element, withSafeArea) => {
  418. const height = vue.ref();
  419. const setHeight = () => {
  420. height.value = use.useRect(element).height;
  421. };
  422. vue.onMounted(() => {
  423. vue.nextTick(setHeight);
  424. if (withSafeArea) {
  425. for (let i = 1; i <= 3; i++) {
  426. setTimeout(setHeight, 100 * i);
  427. }
  428. }
  429. });
  430. onPopupReopen(() => vue.nextTick(setHeight));
  431. return height;
  432. };
  433. function usePlaceholder(contentRef, bem2) {
  434. const height = useHeight(contentRef, true);
  435. return (renderContent) => vue.createVNode("div", {
  436. "class": bem2("placeholder"),
  437. "style": {
  438. height: height.value ? `${height.value}px` : void 0
  439. }
  440. }, [renderContent()]);
  441. }
  442. const [name$1v, bem$1r] = createNamespace("action-bar");
  443. const ACTION_BAR_KEY = Symbol(name$1v);
  444. const actionBarProps = {
  445. placeholder: Boolean,
  446. safeAreaInsetBottom: truthProp
  447. };
  448. var stdin_default$1C = vue.defineComponent({
  449. name: name$1v,
  450. props: actionBarProps,
  451. setup(props, {
  452. slots
  453. }) {
  454. const root = vue.ref();
  455. const renderPlaceholder = usePlaceholder(root, bem$1r);
  456. const {
  457. linkChildren
  458. } = use.useChildren(ACTION_BAR_KEY);
  459. linkChildren();
  460. const renderActionBar = () => {
  461. var _a;
  462. return vue.createVNode("div", {
  463. "ref": root,
  464. "class": [bem$1r(), {
  465. "van-safe-area-bottom": props.safeAreaInsetBottom
  466. }]
  467. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
  468. };
  469. return () => {
  470. if (props.placeholder) {
  471. return renderPlaceholder(renderActionBar);
  472. }
  473. return renderActionBar();
  474. };
  475. }
  476. });
  477. const ActionBar = withInstall(stdin_default$1C);
  478. function useExpose(apis) {
  479. const instance2 = vue.getCurrentInstance();
  480. if (instance2) {
  481. extend(instance2.proxy, apis);
  482. }
  483. }
  484. const routeProps = {
  485. to: [String, Object],
  486. url: String,
  487. replace: Boolean
  488. };
  489. function route({
  490. to,
  491. url,
  492. replace,
  493. $router: router
  494. }) {
  495. if (to && router) {
  496. router[replace ? "replace" : "push"](to);
  497. } else if (url) {
  498. replace ? location.replace(url) : location.href = url;
  499. }
  500. }
  501. function useRoute() {
  502. const vm = vue.getCurrentInstance().proxy;
  503. return () => route(vm);
  504. }
  505. const [name$1u, bem$1q] = createNamespace("badge");
  506. const badgeProps = {
  507. dot: Boolean,
  508. max: numericProp,
  509. tag: makeStringProp("div"),
  510. color: String,
  511. offset: Array,
  512. content: numericProp,
  513. showZero: truthProp,
  514. position: makeStringProp("top-right")
  515. };
  516. var stdin_default$1B = vue.defineComponent({
  517. name: name$1u,
  518. props: badgeProps,
  519. setup(props, {
  520. slots
  521. }) {
  522. const hasContent = () => {
  523. if (slots.content) {
  524. return true;
  525. }
  526. const {
  527. content,
  528. showZero
  529. } = props;
  530. return isDef(content) && content !== "" && (showZero || content !== 0 && content !== "0");
  531. };
  532. const renderContent = () => {
  533. const {
  534. dot,
  535. max,
  536. content
  537. } = props;
  538. if (!dot && hasContent()) {
  539. if (slots.content) {
  540. return slots.content();
  541. }
  542. if (isDef(max) && isNumeric(content) && +content > max) {
  543. return `${max}+`;
  544. }
  545. return content;
  546. }
  547. };
  548. const style = vue.computed(() => {
  549. const style2 = {
  550. background: props.color
  551. };
  552. if (props.offset) {
  553. const [x, y] = props.offset;
  554. if (slots.default) {
  555. style2.top = addUnit(y);
  556. if (typeof x === "number") {
  557. style2.right = addUnit(-x);
  558. } else {
  559. style2.right = x.startsWith("-") ? x.replace("-", "") : `-${x}`;
  560. }
  561. } else {
  562. style2.marginTop = addUnit(y);
  563. style2.marginLeft = addUnit(x);
  564. }
  565. }
  566. return style2;
  567. });
  568. const renderBadge = () => {
  569. if (hasContent() || props.dot) {
  570. return vue.createVNode("div", {
  571. "class": bem$1q([props.position, {
  572. dot: props.dot,
  573. fixed: !!slots.default
  574. }]),
  575. "style": style.value
  576. }, [renderContent()]);
  577. }
  578. };
  579. return () => {
  580. if (slots.default) {
  581. const {
  582. tag
  583. } = props;
  584. return vue.createVNode(tag, {
  585. "class": bem$1q("wrapper")
  586. }, {
  587. default: () => [slots.default(), renderBadge()]
  588. });
  589. }
  590. return renderBadge();
  591. };
  592. }
  593. });
  594. const Badge = withInstall(stdin_default$1B);
  595. let globalZIndex = 2e3;
  596. const useGlobalZIndex = () => ++globalZIndex;
  597. const setGlobalZIndex = (val) => {
  598. globalZIndex = val;
  599. };
  600. const [name$1t, bem$1p] = createNamespace("config-provider");
  601. const CONFIG_PROVIDER_KEY = Symbol(name$1t);
  602. const configProviderProps = {
  603. tag: makeStringProp("div"),
  604. zIndex: Number,
  605. themeVars: Object,
  606. iconPrefix: String
  607. };
  608. function mapThemeVarsToCSSVars(themeVars) {
  609. const cssVars = {};
  610. Object.keys(themeVars).forEach((key) => {
  611. cssVars[`--van-${kebabCase(key)}`] = themeVars[key];
  612. });
  613. return cssVars;
  614. }
  615. var stdin_default$1A = vue.defineComponent({
  616. name: name$1t,
  617. props: configProviderProps,
  618. setup(props, {
  619. slots
  620. }) {
  621. const style = vue.computed(() => {
  622. if (props.themeVars) {
  623. return mapThemeVarsToCSSVars(props.themeVars);
  624. }
  625. });
  626. vue.provide(CONFIG_PROVIDER_KEY, props);
  627. vue.watchEffect(() => {
  628. if (props.zIndex !== void 0) {
  629. setGlobalZIndex(props.zIndex);
  630. }
  631. });
  632. return () => vue.createVNode(props.tag, {
  633. "class": bem$1p(),
  634. "style": style.value
  635. }, {
  636. default: () => {
  637. var _a;
  638. return [(_a = slots.default) == null ? void 0 : _a.call(slots)];
  639. }
  640. });
  641. }
  642. });
  643. const [name$1s, bem$1o] = createNamespace("icon");
  644. const isImage = (name2) => name2 == null ? void 0 : name2.includes("/");
  645. const iconProps = {
  646. dot: Boolean,
  647. tag: makeStringProp("i"),
  648. name: String,
  649. size: numericProp,
  650. badge: numericProp,
  651. color: String,
  652. badgeProps: Object,
  653. classPrefix: String
  654. };
  655. var stdin_default$1z = vue.defineComponent({
  656. name: name$1s,
  657. props: iconProps,
  658. setup(props, {
  659. slots
  660. }) {
  661. const config = vue.inject(CONFIG_PROVIDER_KEY, null);
  662. const classPrefix = vue.computed(() => props.classPrefix || (config == null ? void 0 : config.iconPrefix) || bem$1o());
  663. return () => {
  664. const {
  665. tag,
  666. dot,
  667. name: name2,
  668. size,
  669. badge,
  670. color
  671. } = props;
  672. const isImageIcon = isImage(name2);
  673. return vue.createVNode(Badge, vue.mergeProps({
  674. "dot": dot,
  675. "tag": tag,
  676. "class": [classPrefix.value, isImageIcon ? "" : `${classPrefix.value}-${name2}`],
  677. "style": {
  678. color,
  679. fontSize: addUnit(size)
  680. },
  681. "content": badge
  682. }, props.badgeProps), {
  683. default: () => {
  684. var _a;
  685. return [(_a = slots.default) == null ? void 0 : _a.call(slots), isImageIcon && vue.createVNode("img", {
  686. "class": bem$1o("image"),
  687. "src": name2
  688. }, null)];
  689. }
  690. });
  691. };
  692. }
  693. });
  694. const Icon = withInstall(stdin_default$1z);
  695. const [name$1r, bem$1n] = createNamespace("loading");
  696. const SpinIcon = Array(12).fill(null).map((_, index) => vue.createVNode("i", {
  697. "class": bem$1n("line", String(index + 1))
  698. }, null));
  699. const CircularIcon = vue.createVNode("svg", {
  700. "class": bem$1n("circular"),
  701. "viewBox": "25 25 50 50"
  702. }, [vue.createVNode("circle", {
  703. "cx": "50",
  704. "cy": "50",
  705. "r": "20",
  706. "fill": "none"
  707. }, null)]);
  708. const loadingProps = {
  709. size: numericProp,
  710. type: makeStringProp("circular"),
  711. color: String,
  712. vertical: Boolean,
  713. textSize: numericProp,
  714. textColor: String
  715. };
  716. var stdin_default$1y = vue.defineComponent({
  717. name: name$1r,
  718. props: loadingProps,
  719. setup(props, {
  720. slots
  721. }) {
  722. const spinnerStyle = vue.computed(() => extend({
  723. color: props.color
  724. }, getSizeStyle(props.size)));
  725. const renderText = () => {
  726. var _a;
  727. if (slots.default) {
  728. return vue.createVNode("span", {
  729. "class": bem$1n("text"),
  730. "style": {
  731. fontSize: addUnit(props.textSize),
  732. color: (_a = props.textColor) != null ? _a : props.color
  733. }
  734. }, [slots.default()]);
  735. }
  736. };
  737. return () => {
  738. const {
  739. type,
  740. vertical
  741. } = props;
  742. return vue.createVNode("div", {
  743. "class": bem$1n([type, {
  744. vertical
  745. }]),
  746. "aria-live": "polite",
  747. "aria-busy": true
  748. }, [vue.createVNode("span", {
  749. "class": bem$1n("spinner", type),
  750. "style": spinnerStyle.value
  751. }, [type === "spinner" ? SpinIcon : CircularIcon]), renderText()]);
  752. };
  753. }
  754. });
  755. const Loading = withInstall(stdin_default$1y);
  756. const [name$1q, bem$1m] = createNamespace("button");
  757. const buttonProps = extend({}, routeProps, {
  758. tag: makeStringProp("button"),
  759. text: String,
  760. icon: String,
  761. type: makeStringProp("default"),
  762. size: makeStringProp("normal"),
  763. color: String,
  764. block: Boolean,
  765. plain: Boolean,
  766. round: Boolean,
  767. square: Boolean,
  768. loading: Boolean,
  769. hairline: Boolean,
  770. disabled: Boolean,
  771. iconPrefix: String,
  772. nativeType: makeStringProp("button"),
  773. loadingSize: numericProp,
  774. loadingText: String,
  775. loadingType: String,
  776. iconPosition: makeStringProp("left")
  777. });
  778. var stdin_default$1x = vue.defineComponent({
  779. name: name$1q,
  780. props: buttonProps,
  781. emits: ["click"],
  782. setup(props, {
  783. emit,
  784. slots
  785. }) {
  786. const route2 = useRoute();
  787. const renderLoadingIcon = () => {
  788. if (slots.loading) {
  789. return slots.loading();
  790. }
  791. return vue.createVNode(Loading, {
  792. "size": props.loadingSize,
  793. "type": props.loadingType,
  794. "class": bem$1m("loading")
  795. }, null);
  796. };
  797. const renderIcon = () => {
  798. if (props.loading) {
  799. return renderLoadingIcon();
  800. }
  801. if (slots.icon) {
  802. return vue.createVNode("div", {
  803. "class": bem$1m("icon")
  804. }, [slots.icon()]);
  805. }
  806. if (props.icon) {
  807. return vue.createVNode(Icon, {
  808. "name": props.icon,
  809. "class": bem$1m("icon"),
  810. "classPrefix": props.iconPrefix
  811. }, null);
  812. }
  813. };
  814. const renderText = () => {
  815. let text;
  816. if (props.loading) {
  817. text = props.loadingText;
  818. } else {
  819. text = slots.default ? slots.default() : props.text;
  820. }
  821. if (text) {
  822. return vue.createVNode("span", {
  823. "class": bem$1m("text")
  824. }, [text]);
  825. }
  826. };
  827. const getStyle = () => {
  828. const {
  829. color,
  830. plain
  831. } = props;
  832. if (color) {
  833. const style = {
  834. color: plain ? color : "white"
  835. };
  836. if (!plain) {
  837. style.background = color;
  838. }
  839. if (color.includes("gradient")) {
  840. style.border = 0;
  841. } else {
  842. style.borderColor = color;
  843. }
  844. return style;
  845. }
  846. };
  847. const onClick = (event) => {
  848. if (props.loading) {
  849. preventDefault(event);
  850. } else if (!props.disabled) {
  851. emit("click", event);
  852. route2();
  853. }
  854. };
  855. return () => {
  856. const {
  857. tag,
  858. type,
  859. size,
  860. block,
  861. round,
  862. plain,
  863. square,
  864. loading,
  865. disabled,
  866. hairline,
  867. nativeType,
  868. iconPosition
  869. } = props;
  870. const classes = [bem$1m([type, size, {
  871. plain,
  872. block,
  873. round,
  874. square,
  875. loading,
  876. disabled,
  877. hairline
  878. }]), {
  879. [BORDER_SURROUND]: hairline
  880. }];
  881. return vue.createVNode(tag, {
  882. "type": nativeType,
  883. "class": classes,
  884. "style": getStyle(),
  885. "disabled": disabled,
  886. "onClick": onClick
  887. }, {
  888. default: () => [vue.createVNode("div", {
  889. "class": bem$1m("content")
  890. }, [iconPosition === "left" && renderIcon(), renderText(), iconPosition === "right" && renderIcon()])]
  891. });
  892. };
  893. }
  894. });
  895. const Button = withInstall(stdin_default$1x);
  896. const [name$1p, bem$1l] = createNamespace("action-bar-button");
  897. const actionBarButtonProps = extend({}, routeProps, {
  898. type: String,
  899. text: String,
  900. icon: String,
  901. color: String,
  902. loading: Boolean,
  903. disabled: Boolean
  904. });
  905. var stdin_default$1w = vue.defineComponent({
  906. name: name$1p,
  907. props: actionBarButtonProps,
  908. setup(props, {
  909. slots
  910. }) {
  911. const route2 = useRoute();
  912. const {
  913. parent,
  914. index
  915. } = use.useParent(ACTION_BAR_KEY);
  916. const isFirst = vue.computed(() => {
  917. if (parent) {
  918. const prev = parent.children[index.value - 1];
  919. return !(prev && "isButton" in prev);
  920. }
  921. });
  922. const isLast = vue.computed(() => {
  923. if (parent) {
  924. const next = parent.children[index.value + 1];
  925. return !(next && "isButton" in next);
  926. }
  927. });
  928. useExpose({
  929. isButton: true
  930. });
  931. return () => {
  932. const {
  933. type,
  934. icon,
  935. text,
  936. color,
  937. loading,
  938. disabled
  939. } = props;
  940. return vue.createVNode(Button, {
  941. "class": bem$1l([type, {
  942. last: isLast.value,
  943. first: isFirst.value
  944. }]),
  945. "size": "large",
  946. "type": type,
  947. "icon": icon,
  948. "color": color,
  949. "loading": loading,
  950. "disabled": disabled,
  951. "onClick": route2
  952. }, {
  953. default: () => [slots.default ? slots.default() : text]
  954. });
  955. };
  956. }
  957. });
  958. const ActionBarButton = withInstall(stdin_default$1w);
  959. const [name$1o, bem$1k] = createNamespace("action-bar-icon");
  960. const actionBarIconProps = extend({}, routeProps, {
  961. dot: Boolean,
  962. text: String,
  963. icon: String,
  964. color: String,
  965. badge: numericProp,
  966. iconClass: unknownProp,
  967. badgeProps: Object,
  968. iconPrefix: String
  969. });
  970. var stdin_default$1v = vue.defineComponent({
  971. name: name$1o,
  972. props: actionBarIconProps,
  973. setup(props, {
  974. slots
  975. }) {
  976. const route2 = useRoute();
  977. use.useParent(ACTION_BAR_KEY);
  978. const renderIcon = () => {
  979. const {
  980. dot,
  981. badge,
  982. icon,
  983. color,
  984. iconClass,
  985. badgeProps: badgeProps2,
  986. iconPrefix
  987. } = props;
  988. if (slots.icon) {
  989. return vue.createVNode(Badge, vue.mergeProps({
  990. "dot": dot,
  991. "class": bem$1k("icon"),
  992. "content": badge
  993. }, badgeProps2), {
  994. default: slots.icon
  995. });
  996. }
  997. return vue.createVNode(Icon, {
  998. "tag": "div",
  999. "dot": dot,
  1000. "name": icon,
  1001. "badge": badge,
  1002. "color": color,
  1003. "class": [bem$1k("icon"), iconClass],
  1004. "badgeProps": badgeProps2,
  1005. "classPrefix": iconPrefix
  1006. }, null);
  1007. };
  1008. return () => vue.createVNode("div", {
  1009. "role": "button",
  1010. "class": bem$1k(),
  1011. "tabindex": 0,
  1012. "onClick": route2
  1013. }, [renderIcon(), slots.default ? slots.default() : props.text]);
  1014. }
  1015. });
  1016. const ActionBarIcon = withInstall(stdin_default$1v);
  1017. const popupSharedProps = {
  1018. show: Boolean,
  1019. zIndex: numericProp,
  1020. overlay: truthProp,
  1021. duration: numericProp,
  1022. teleport: [String, Object],
  1023. lockScroll: truthProp,
  1024. lazyRender: truthProp,
  1025. beforeClose: Function,
  1026. overlayStyle: Object,
  1027. overlayClass: unknownProp,
  1028. transitionAppear: Boolean,
  1029. closeOnClickOverlay: truthProp
  1030. };
  1031. const popupSharedPropKeys = Object.keys(
  1032. popupSharedProps
  1033. );
  1034. function getDirection(x, y) {
  1035. if (x > y) {
  1036. return "horizontal";
  1037. }
  1038. if (y > x) {
  1039. return "vertical";
  1040. }
  1041. return "";
  1042. }
  1043. function useTouch() {
  1044. const startX = vue.ref(0);
  1045. const startY = vue.ref(0);
  1046. const deltaX = vue.ref(0);
  1047. const deltaY = vue.ref(0);
  1048. const offsetX = vue.ref(0);
  1049. const offsetY = vue.ref(0);
  1050. const direction = vue.ref("");
  1051. const isVertical = () => direction.value === "vertical";
  1052. const isHorizontal = () => direction.value === "horizontal";
  1053. const reset = () => {
  1054. deltaX.value = 0;
  1055. deltaY.value = 0;
  1056. offsetX.value = 0;
  1057. offsetY.value = 0;
  1058. direction.value = "";
  1059. };
  1060. const start = (event) => {
  1061. reset();
  1062. startX.value = event.touches[0].clientX;
  1063. startY.value = event.touches[0].clientY;
  1064. };
  1065. const move = (event) => {
  1066. const touch = event.touches[0];
  1067. deltaX.value = (touch.clientX < 0 ? 0 : touch.clientX) - startX.value;
  1068. deltaY.value = touch.clientY - startY.value;
  1069. offsetX.value = Math.abs(deltaX.value);
  1070. offsetY.value = Math.abs(deltaY.value);
  1071. const LOCK_DIRECTION_DISTANCE = 10;
  1072. if (!direction.value || offsetX.value < LOCK_DIRECTION_DISTANCE && offsetY.value < LOCK_DIRECTION_DISTANCE) {
  1073. direction.value = getDirection(offsetX.value, offsetY.value);
  1074. }
  1075. };
  1076. return {
  1077. move,
  1078. start,
  1079. reset,
  1080. startX,
  1081. startY,
  1082. deltaX,
  1083. deltaY,
  1084. offsetX,
  1085. offsetY,
  1086. direction,
  1087. isVertical,
  1088. isHorizontal
  1089. };
  1090. }
  1091. let totalLockCount = 0;
  1092. const BODY_LOCK_CLASS = "van-overflow-hidden";
  1093. function useLockScroll(rootRef, shouldLock) {
  1094. const touch = useTouch();
  1095. const DIRECTION_UP = "01";
  1096. const DIRECTION_DOWN = "10";
  1097. const onTouchMove = (event) => {
  1098. touch.move(event);
  1099. const direction = touch.deltaY.value > 0 ? DIRECTION_DOWN : DIRECTION_UP;
  1100. const el = use.getScrollParent(
  1101. event.target,
  1102. rootRef.value
  1103. );
  1104. const { scrollHeight, offsetHeight, scrollTop } = el;
  1105. let status = "11";
  1106. if (scrollTop === 0) {
  1107. status = offsetHeight >= scrollHeight ? "00" : "01";
  1108. } else if (scrollTop + offsetHeight >= scrollHeight) {
  1109. status = "10";
  1110. }
  1111. if (status !== "11" && touch.isVertical() && !(parseInt(status, 2) & parseInt(direction, 2))) {
  1112. preventDefault(event, true);
  1113. }
  1114. };
  1115. const lock = () => {
  1116. document.addEventListener("touchstart", touch.start);
  1117. document.addEventListener("touchmove", onTouchMove, { passive: false });
  1118. if (!totalLockCount) {
  1119. document.body.classList.add(BODY_LOCK_CLASS);
  1120. }
  1121. totalLockCount++;
  1122. };
  1123. const unlock = () => {
  1124. if (totalLockCount) {
  1125. document.removeEventListener("touchstart", touch.start);
  1126. document.removeEventListener("touchmove", onTouchMove);
  1127. totalLockCount--;
  1128. if (!totalLockCount) {
  1129. document.body.classList.remove(BODY_LOCK_CLASS);
  1130. }
  1131. }
  1132. };
  1133. const init = () => shouldLock() && lock();
  1134. const destroy = () => shouldLock() && unlock();
  1135. use.onMountedOrActivated(init);
  1136. vue.onDeactivated(destroy);
  1137. vue.onBeforeUnmount(destroy);
  1138. vue.watch(shouldLock, (value) => {
  1139. value ? lock() : unlock();
  1140. });
  1141. }
  1142. function useLazyRender(show) {
  1143. const inited = vue.ref(false);
  1144. vue.watch(
  1145. show,
  1146. (value) => {
  1147. if (value) {
  1148. inited.value = value;
  1149. }
  1150. },
  1151. { immediate: true }
  1152. );
  1153. return (render) => () => inited.value ? render() : null;
  1154. }
  1155. const [name$1n, bem$1j] = createNamespace("overlay");
  1156. const overlayProps = {
  1157. show: Boolean,
  1158. zIndex: numericProp,
  1159. duration: numericProp,
  1160. className: unknownProp,
  1161. lockScroll: truthProp,
  1162. lazyRender: truthProp,
  1163. customStyle: Object
  1164. };
  1165. var stdin_default$1u = vue.defineComponent({
  1166. name: name$1n,
  1167. props: overlayProps,
  1168. setup(props, {
  1169. slots
  1170. }) {
  1171. const root = vue.ref();
  1172. const lazyRender = useLazyRender(() => props.show || !props.lazyRender);
  1173. const onTouchMove = (event) => {
  1174. if (props.lockScroll) {
  1175. preventDefault(event, true);
  1176. }
  1177. };
  1178. const renderOverlay = lazyRender(() => {
  1179. var _a;
  1180. const style = extend(getZIndexStyle(props.zIndex), props.customStyle);
  1181. if (isDef(props.duration)) {
  1182. style.animationDuration = `${props.duration}s`;
  1183. }
  1184. return vue.withDirectives(vue.createVNode("div", {
  1185. "ref": root,
  1186. "style": style,
  1187. "class": [bem$1j(), props.className]
  1188. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]), [[vue.vShow, props.show]]);
  1189. });
  1190. use.useEventListener("touchmove", onTouchMove, {
  1191. target: root
  1192. });
  1193. return () => vue.createVNode(vue.Transition, {
  1194. "name": "van-fade",
  1195. "appear": true
  1196. }, {
  1197. default: renderOverlay
  1198. });
  1199. }
  1200. });
  1201. const Overlay = withInstall(stdin_default$1u);
  1202. const popupProps$2 = extend({}, popupSharedProps, {
  1203. round: Boolean,
  1204. position: makeStringProp("center"),
  1205. closeIcon: makeStringProp("cross"),
  1206. closeable: Boolean,
  1207. transition: String,
  1208. iconPrefix: String,
  1209. closeOnPopstate: Boolean,
  1210. closeIconPosition: makeStringProp("top-right"),
  1211. safeAreaInsetTop: Boolean,
  1212. safeAreaInsetBottom: Boolean
  1213. });
  1214. const [name$1m, bem$1i] = createNamespace("popup");
  1215. var stdin_default$1t = vue.defineComponent({
  1216. name: name$1m,
  1217. inheritAttrs: false,
  1218. props: popupProps$2,
  1219. emits: ["open", "close", "opened", "closed", "keydown", "update:show", "click-overlay", "click-close-icon"],
  1220. setup(props, {
  1221. emit,
  1222. attrs,
  1223. slots
  1224. }) {
  1225. let opened;
  1226. let shouldReopen;
  1227. const zIndex = vue.ref();
  1228. const popupRef = vue.ref();
  1229. const lazyRender = useLazyRender(() => props.show || !props.lazyRender);
  1230. const style = vue.computed(() => {
  1231. const style2 = {
  1232. zIndex: zIndex.value
  1233. };
  1234. if (isDef(props.duration)) {
  1235. const key = props.position === "center" ? "animationDuration" : "transitionDuration";
  1236. style2[key] = `${props.duration}s`;
  1237. }
  1238. return style2;
  1239. });
  1240. const open = () => {
  1241. if (!opened) {
  1242. opened = true;
  1243. zIndex.value = props.zIndex !== void 0 ? +props.zIndex : useGlobalZIndex();
  1244. emit("open");
  1245. }
  1246. };
  1247. const close = () => {
  1248. if (opened) {
  1249. callInterceptor(props.beforeClose, {
  1250. done() {
  1251. opened = false;
  1252. emit("close");
  1253. emit("update:show", false);
  1254. }
  1255. });
  1256. }
  1257. };
  1258. const onClickOverlay = (event) => {
  1259. emit("click-overlay", event);
  1260. if (props.closeOnClickOverlay) {
  1261. close();
  1262. }
  1263. };
  1264. const renderOverlay = () => {
  1265. if (props.overlay) {
  1266. return vue.createVNode(Overlay, {
  1267. "show": props.show,
  1268. "class": props.overlayClass,
  1269. "zIndex": zIndex.value,
  1270. "duration": props.duration,
  1271. "customStyle": props.overlayStyle,
  1272. "role": props.closeOnClickOverlay ? "button" : void 0,
  1273. "tabindex": props.closeOnClickOverlay ? 0 : void 0,
  1274. "onClick": onClickOverlay
  1275. }, {
  1276. default: slots["overlay-content"]
  1277. });
  1278. }
  1279. };
  1280. const onClickCloseIcon = (event) => {
  1281. emit("click-close-icon", event);
  1282. close();
  1283. };
  1284. const renderCloseIcon = () => {
  1285. if (props.closeable) {
  1286. return vue.createVNode(Icon, {
  1287. "role": "button",
  1288. "tabindex": 0,
  1289. "name": props.closeIcon,
  1290. "class": [bem$1i("close-icon", props.closeIconPosition), HAPTICS_FEEDBACK],
  1291. "classPrefix": props.iconPrefix,
  1292. "onClick": onClickCloseIcon
  1293. }, null);
  1294. }
  1295. };
  1296. const onOpened = () => emit("opened");
  1297. const onClosed = () => emit("closed");
  1298. const onKeydown = (event) => emit("keydown", event);
  1299. const renderPopup = lazyRender(() => {
  1300. var _a;
  1301. const {
  1302. round,
  1303. position,
  1304. safeAreaInsetTop,
  1305. safeAreaInsetBottom
  1306. } = props;
  1307. return vue.withDirectives(vue.createVNode("div", vue.mergeProps({
  1308. "ref": popupRef,
  1309. "style": style.value,
  1310. "role": "dialog",
  1311. "tabindex": 0,
  1312. "class": [bem$1i({
  1313. round,
  1314. [position]: position
  1315. }), {
  1316. "van-safe-area-top": safeAreaInsetTop,
  1317. "van-safe-area-bottom": safeAreaInsetBottom
  1318. }],
  1319. "onKeydown": onKeydown
  1320. }, attrs), [(_a = slots.default) == null ? void 0 : _a.call(slots), renderCloseIcon()]), [[vue.vShow, props.show]]);
  1321. });
  1322. const renderTransition = () => {
  1323. const {
  1324. position,
  1325. transition,
  1326. transitionAppear
  1327. } = props;
  1328. const name2 = position === "center" ? "van-fade" : `van-popup-slide-${position}`;
  1329. return vue.createVNode(vue.Transition, {
  1330. "name": transition || name2,
  1331. "appear": transitionAppear,
  1332. "onAfterEnter": onOpened,
  1333. "onAfterLeave": onClosed
  1334. }, {
  1335. default: renderPopup
  1336. });
  1337. };
  1338. vue.watch(() => props.show, (show) => {
  1339. if (show && !opened) {
  1340. open();
  1341. if (attrs.tabindex === 0) {
  1342. vue.nextTick(() => {
  1343. var _a;
  1344. (_a = popupRef.value) == null ? void 0 : _a.focus();
  1345. });
  1346. }
  1347. }
  1348. if (!show && opened) {
  1349. opened = false;
  1350. emit("close");
  1351. }
  1352. });
  1353. useExpose({
  1354. popupRef
  1355. });
  1356. useLockScroll(popupRef, () => props.show && props.lockScroll);
  1357. use.useEventListener("popstate", () => {
  1358. if (props.closeOnPopstate) {
  1359. close();
  1360. shouldReopen = false;
  1361. }
  1362. });
  1363. vue.onMounted(() => {
  1364. if (props.show) {
  1365. open();
  1366. }
  1367. });
  1368. vue.onActivated(() => {
  1369. if (shouldReopen) {
  1370. emit("update:show", true);
  1371. shouldReopen = false;
  1372. }
  1373. });
  1374. vue.onDeactivated(() => {
  1375. if (props.show && props.teleport) {
  1376. close();
  1377. shouldReopen = true;
  1378. }
  1379. });
  1380. vue.provide(POPUP_TOGGLE_KEY, () => props.show);
  1381. return () => {
  1382. if (props.teleport) {
  1383. return vue.createVNode(vue.Teleport, {
  1384. "to": props.teleport
  1385. }, {
  1386. default: () => [renderOverlay(), renderTransition()]
  1387. });
  1388. }
  1389. return vue.createVNode(vue.Fragment, null, [renderOverlay(), renderTransition()]);
  1390. };
  1391. }
  1392. });
  1393. const Popup = withInstall(stdin_default$1t);
  1394. const [name$1l, bem$1h] = createNamespace("action-sheet");
  1395. const actionSheetProps = extend({}, popupSharedProps, {
  1396. title: String,
  1397. round: truthProp,
  1398. actions: makeArrayProp(),
  1399. closeIcon: makeStringProp("cross"),
  1400. closeable: truthProp,
  1401. cancelText: String,
  1402. description: String,
  1403. closeOnPopstate: truthProp,
  1404. closeOnClickAction: Boolean,
  1405. safeAreaInsetBottom: truthProp
  1406. });
  1407. const popupInheritKeys$2 = [...popupSharedPropKeys, "round", "closeOnPopstate", "safeAreaInsetBottom"];
  1408. var stdin_default$1s = vue.defineComponent({
  1409. name: name$1l,
  1410. props: actionSheetProps,
  1411. emits: ["select", "cancel", "update:show"],
  1412. setup(props, {
  1413. slots,
  1414. emit
  1415. }) {
  1416. const updateShow = (show) => emit("update:show", show);
  1417. const onCancel = () => {
  1418. updateShow(false);
  1419. emit("cancel");
  1420. };
  1421. const renderHeader = () => {
  1422. if (props.title) {
  1423. return vue.createVNode("div", {
  1424. "class": bem$1h("header")
  1425. }, [props.title, props.closeable && vue.createVNode(Icon, {
  1426. "name": props.closeIcon,
  1427. "class": [bem$1h("close"), HAPTICS_FEEDBACK],
  1428. "onClick": onCancel
  1429. }, null)]);
  1430. }
  1431. };
  1432. const renderCancel = () => {
  1433. if (slots.cancel || props.cancelText) {
  1434. return [vue.createVNode("div", {
  1435. "class": bem$1h("gap")
  1436. }, null), vue.createVNode("button", {
  1437. "type": "button",
  1438. "class": bem$1h("cancel"),
  1439. "onClick": onCancel
  1440. }, [slots.cancel ? slots.cancel() : props.cancelText])];
  1441. }
  1442. };
  1443. const renderActionContent = (action, index) => {
  1444. if (action.loading) {
  1445. return vue.createVNode(Loading, {
  1446. "class": bem$1h("loading-icon")
  1447. }, null);
  1448. }
  1449. if (slots.action) {
  1450. return slots.action({
  1451. action,
  1452. index
  1453. });
  1454. }
  1455. return [vue.createVNode("span", {
  1456. "class": bem$1h("name")
  1457. }, [action.name]), action.subname && vue.createVNode("div", {
  1458. "class": bem$1h("subname")
  1459. }, [action.subname])];
  1460. };
  1461. const renderAction = (action, index) => {
  1462. const {
  1463. color,
  1464. loading,
  1465. callback,
  1466. disabled,
  1467. className
  1468. } = action;
  1469. const onClick = () => {
  1470. if (disabled || loading) {
  1471. return;
  1472. }
  1473. if (callback) {
  1474. callback(action);
  1475. }
  1476. if (props.closeOnClickAction) {
  1477. updateShow(false);
  1478. }
  1479. vue.nextTick(() => emit("select", action, index));
  1480. };
  1481. return vue.createVNode("button", {
  1482. "type": "button",
  1483. "style": {
  1484. color
  1485. },
  1486. "class": [bem$1h("item", {
  1487. loading,
  1488. disabled
  1489. }), className],
  1490. "onClick": onClick
  1491. }, [renderActionContent(action, index)]);
  1492. };
  1493. const renderDescription = () => {
  1494. if (props.description || slots.description) {
  1495. const content = slots.description ? slots.description() : props.description;
  1496. return vue.createVNode("div", {
  1497. "class": bem$1h("description")
  1498. }, [content]);
  1499. }
  1500. };
  1501. return () => vue.createVNode(Popup, vue.mergeProps({
  1502. "class": bem$1h(),
  1503. "position": "bottom",
  1504. "onUpdate:show": updateShow
  1505. }, pick(props, popupInheritKeys$2)), {
  1506. default: () => {
  1507. var _a;
  1508. return [renderHeader(), renderDescription(), vue.createVNode("div", {
  1509. "class": bem$1h("content")
  1510. }, [props.actions.map(renderAction), (_a = slots.default) == null ? void 0 : _a.call(slots)]), renderCancel()];
  1511. }
  1512. });
  1513. }
  1514. });
  1515. const ActionSheet = withInstall(stdin_default$1s);
  1516. function deepClone(obj) {
  1517. if (!isDef(obj)) {
  1518. return obj;
  1519. }
  1520. if (Array.isArray(obj)) {
  1521. return obj.map((item) => deepClone(item));
  1522. }
  1523. if (isObject(obj)) {
  1524. const to = {};
  1525. Object.keys(obj).forEach((key) => {
  1526. to[key] = deepClone(obj[key]);
  1527. });
  1528. return to;
  1529. }
  1530. return obj;
  1531. }
  1532. const DEFAULT_DURATION = 200;
  1533. const MOMENTUM_LIMIT_TIME = 300;
  1534. const MOMENTUM_LIMIT_DISTANCE = 15;
  1535. const [name$1k, bem$1g] = createNamespace("picker-column");
  1536. function getElementTranslateY(element) {
  1537. const {
  1538. transform
  1539. } = window.getComputedStyle(element);
  1540. const translateY = transform.slice(7, transform.length - 1).split(", ")[5];
  1541. return Number(translateY);
  1542. }
  1543. const PICKER_KEY = Symbol(name$1k);
  1544. const isOptionDisabled = (option) => isObject(option) && option.disabled;
  1545. var stdin_default$1r = vue.defineComponent({
  1546. name: name$1k,
  1547. props: {
  1548. textKey: makeRequiredProp(String),
  1549. readonly: Boolean,
  1550. allowHtml: Boolean,
  1551. className: unknownProp,
  1552. itemHeight: makeRequiredProp(Number),
  1553. defaultIndex: makeNumberProp(0),
  1554. swipeDuration: makeRequiredProp(numericProp),
  1555. initialOptions: makeArrayProp(),
  1556. visibleItemCount: makeRequiredProp(numericProp)
  1557. },
  1558. emits: ["change"],
  1559. setup(props, {
  1560. emit,
  1561. slots
  1562. }) {
  1563. let moving;
  1564. let startOffset;
  1565. let touchStartTime;
  1566. let momentumOffset;
  1567. let transitionEndTrigger;
  1568. const root = vue.ref();
  1569. const wrapper = vue.ref();
  1570. const state = vue.reactive({
  1571. index: props.defaultIndex,
  1572. offset: 0,
  1573. duration: 0,
  1574. options: deepClone(props.initialOptions)
  1575. });
  1576. const touch = useTouch();
  1577. const count = () => state.options.length;
  1578. const baseOffset = () => props.itemHeight * (+props.visibleItemCount - 1) / 2;
  1579. const adjustIndex = (index) => {
  1580. index = clamp(index, 0, count());
  1581. for (let i = index; i < count(); i++) {
  1582. if (!isOptionDisabled(state.options[i]))
  1583. return i;
  1584. }
  1585. for (let i = index - 1; i >= 0; i--) {
  1586. if (!isOptionDisabled(state.options[i]))
  1587. return i;
  1588. }
  1589. };
  1590. const setIndex = (index, emitChange) => {
  1591. index = adjustIndex(index) || 0;
  1592. const offset = -index * props.itemHeight;
  1593. const trigger = () => {
  1594. if (index !== state.index) {
  1595. state.index = index;
  1596. if (emitChange) {
  1597. emit("change", index);
  1598. }
  1599. }
  1600. };
  1601. if (moving && offset !== state.offset) {
  1602. transitionEndTrigger = trigger;
  1603. } else {
  1604. trigger();
  1605. }
  1606. state.offset = offset;
  1607. };
  1608. const setOptions = (options) => {
  1609. if (JSON.stringify(options) !== JSON.stringify(state.options)) {
  1610. state.options = deepClone(options);
  1611. setIndex(props.defaultIndex);
  1612. }
  1613. };
  1614. const onClickItem = (index) => {
  1615. if (moving || props.readonly) {
  1616. return;
  1617. }
  1618. transitionEndTrigger = null;
  1619. state.duration = DEFAULT_DURATION;
  1620. setIndex(index, true);
  1621. };
  1622. const getOptionText = (option) => {
  1623. if (isObject(option) && props.textKey in option) {
  1624. return option[props.textKey];
  1625. }
  1626. return option;
  1627. };
  1628. const getIndexByOffset = (offset) => clamp(Math.round(-offset / props.itemHeight), 0, count() - 1);
  1629. const momentum = (distance, duration) => {
  1630. const speed = Math.abs(distance / duration);
  1631. distance = state.offset + speed / 3e-3 * (distance < 0 ? -1 : 1);
  1632. const index = getIndexByOffset(distance);
  1633. state.duration = +props.swipeDuration;
  1634. setIndex(index, true);
  1635. };
  1636. const stopMomentum = () => {
  1637. moving = false;
  1638. state.duration = 0;
  1639. if (transitionEndTrigger) {
  1640. transitionEndTrigger();
  1641. transitionEndTrigger = null;
  1642. }
  1643. };
  1644. const onTouchStart = (event) => {
  1645. if (props.readonly) {
  1646. return;
  1647. }
  1648. touch.start(event);
  1649. if (moving) {
  1650. const translateY = getElementTranslateY(wrapper.value);
  1651. state.offset = Math.min(0, translateY - baseOffset());
  1652. startOffset = state.offset;
  1653. } else {
  1654. startOffset = state.offset;
  1655. }
  1656. state.duration = 0;
  1657. touchStartTime = Date.now();
  1658. momentumOffset = startOffset;
  1659. transitionEndTrigger = null;
  1660. };
  1661. const onTouchMove = (event) => {
  1662. if (props.readonly) {
  1663. return;
  1664. }
  1665. touch.move(event);
  1666. if (touch.isVertical()) {
  1667. moving = true;
  1668. preventDefault(event, true);
  1669. }
  1670. state.offset = clamp(startOffset + touch.deltaY.value, -(count() * props.itemHeight), props.itemHeight);
  1671. const now = Date.now();
  1672. if (now - touchStartTime > MOMENTUM_LIMIT_TIME) {
  1673. touchStartTime = now;
  1674. momentumOffset = state.offset;
  1675. }
  1676. };
  1677. const onTouchEnd = () => {
  1678. if (props.readonly) {
  1679. return;
  1680. }
  1681. const distance = state.offset - momentumOffset;
  1682. const duration = Date.now() - touchStartTime;
  1683. const allowMomentum = duration < MOMENTUM_LIMIT_TIME && Math.abs(distance) > MOMENTUM_LIMIT_DISTANCE;
  1684. if (allowMomentum) {
  1685. momentum(distance, duration);
  1686. return;
  1687. }
  1688. const index = getIndexByOffset(state.offset);
  1689. state.duration = DEFAULT_DURATION;
  1690. setIndex(index, true);
  1691. setTimeout(() => {
  1692. moving = false;
  1693. }, 0);
  1694. };
  1695. const renderOptions = () => {
  1696. const optionStyle = {
  1697. height: `${props.itemHeight}px`
  1698. };
  1699. return state.options.map((option, index) => {
  1700. const text = getOptionText(option);
  1701. const disabled = isOptionDisabled(option);
  1702. const data = {
  1703. role: "button",
  1704. style: optionStyle,
  1705. tabindex: disabled ? -1 : 0,
  1706. class: bem$1g("item", {
  1707. disabled,
  1708. selected: index === state.index
  1709. }),
  1710. onClick: () => onClickItem(index)
  1711. };
  1712. const childData = {
  1713. class: "van-ellipsis",
  1714. [props.allowHtml ? "innerHTML" : "textContent"]: text
  1715. };
  1716. return vue.createVNode("li", data, [slots.option ? slots.option(option) : vue.createVNode("div", childData, null)]);
  1717. });
  1718. };
  1719. const setValue = (value) => {
  1720. const {
  1721. options
  1722. } = state;
  1723. for (let i = 0; i < options.length; i++) {
  1724. if (getOptionText(options[i]) === value) {
  1725. return setIndex(i);
  1726. }
  1727. }
  1728. };
  1729. const getValue = () => state.options[state.index];
  1730. const hasOptions = () => state.options.length;
  1731. setIndex(state.index);
  1732. use.useParent(PICKER_KEY);
  1733. useExpose({
  1734. state,
  1735. setIndex,
  1736. getValue,
  1737. setValue,
  1738. setOptions,
  1739. hasOptions,
  1740. stopMomentum
  1741. });
  1742. vue.watch(() => props.initialOptions, setOptions);
  1743. vue.watch(() => props.defaultIndex, (value) => setIndex(value));
  1744. use.useEventListener("touchmove", onTouchMove, {
  1745. target: root
  1746. });
  1747. return () => vue.createVNode("div", {
  1748. "ref": root,
  1749. "class": [bem$1g(), props.className],
  1750. "onTouchstartPassive": onTouchStart,
  1751. "onTouchend": onTouchEnd,
  1752. "onTouchcancel": onTouchEnd
  1753. }, [vue.createVNode("ul", {
  1754. "ref": wrapper,
  1755. "style": {
  1756. transform: `translate3d(0, ${state.offset + baseOffset()}px, 0)`,
  1757. transitionDuration: `${state.duration}ms`,
  1758. transitionProperty: state.duration ? "all" : "none"
  1759. },
  1760. "class": bem$1g("wrapper"),
  1761. "onTransitionend": stopMomentum
  1762. }, [renderOptions()])]);
  1763. }
  1764. });
  1765. const [name$1j, bem$1f, t$j] = createNamespace("picker");
  1766. const pickerSharedProps = {
  1767. title: String,
  1768. loading: Boolean,
  1769. readonly: Boolean,
  1770. allowHtml: Boolean,
  1771. itemHeight: makeNumericProp(44),
  1772. showToolbar: truthProp,
  1773. swipeDuration: makeNumericProp(1e3),
  1774. visibleItemCount: makeNumericProp(6),
  1775. cancelButtonText: String,
  1776. confirmButtonText: String
  1777. };
  1778. const pickerProps = extend({}, pickerSharedProps, {
  1779. columns: makeArrayProp(),
  1780. valueKey: String,
  1781. defaultIndex: makeNumericProp(0),
  1782. toolbarPosition: makeStringProp("top"),
  1783. columnsFieldNames: Object
  1784. });
  1785. var stdin_default$1q = vue.defineComponent({
  1786. name: name$1j,
  1787. props: pickerProps,
  1788. emits: ["confirm", "cancel", "change"],
  1789. setup(props, {
  1790. emit,
  1791. slots
  1792. }) {
  1793. if (process.env.NODE_ENV !== "production") {
  1794. if (slots.default) {
  1795. console.warn('[Vant] Picker: "default" slot is deprecated, please use "toolbar" slot instead.');
  1796. }
  1797. if (props.valueKey) {
  1798. console.warn('[Vant] Picker: "valueKey" prop is deprecated, please use "columnsFieldNames" prop instead.');
  1799. }
  1800. }
  1801. const hasOptions = vue.ref(false);
  1802. const columnsRef = vue.ref();
  1803. const formattedColumns = vue.ref([]);
  1804. const columnsFieldNames = vue.computed(() => {
  1805. const {
  1806. columnsFieldNames: columnsFieldNames2
  1807. } = props;
  1808. return {
  1809. text: (columnsFieldNames2 == null ? void 0 : columnsFieldNames2.text) || props.valueKey || "text",
  1810. values: (columnsFieldNames2 == null ? void 0 : columnsFieldNames2.values) || "values",
  1811. children: (columnsFieldNames2 == null ? void 0 : columnsFieldNames2.children) || "children"
  1812. };
  1813. });
  1814. const {
  1815. children,
  1816. linkChildren
  1817. } = use.useChildren(PICKER_KEY);
  1818. linkChildren();
  1819. const itemHeight = vue.computed(() => unitToPx(props.itemHeight));
  1820. const dataType = vue.computed(() => {
  1821. const firstColumn = props.columns[0];
  1822. if (typeof firstColumn === "object") {
  1823. if (columnsFieldNames.value.children in firstColumn) {
  1824. return "cascade";
  1825. }
  1826. if (columnsFieldNames.value.values in firstColumn) {
  1827. return "object";
  1828. }
  1829. }
  1830. return "plain";
  1831. });
  1832. const formatCascade = () => {
  1833. var _a;
  1834. const formatted = [];
  1835. let cursor = {
  1836. [columnsFieldNames.value.children]: props.columns
  1837. };
  1838. while (cursor && cursor[columnsFieldNames.value.children]) {
  1839. const children2 = cursor[columnsFieldNames.value.children];
  1840. let defaultIndex = (_a = cursor.defaultIndex) != null ? _a : +props.defaultIndex;
  1841. while (children2[defaultIndex] && children2[defaultIndex].disabled) {
  1842. if (defaultIndex < children2.length - 1) {
  1843. defaultIndex++;
  1844. } else {
  1845. defaultIndex = 0;
  1846. break;
  1847. }
  1848. }
  1849. formatted.push({
  1850. [columnsFieldNames.value.values]: cursor[columnsFieldNames.value.children],
  1851. className: cursor.className,
  1852. defaultIndex
  1853. });
  1854. cursor = children2[defaultIndex];
  1855. }
  1856. formattedColumns.value = formatted;
  1857. };
  1858. const format2 = () => {
  1859. const {
  1860. columns
  1861. } = props;
  1862. if (dataType.value === "plain") {
  1863. formattedColumns.value = [{
  1864. [columnsFieldNames.value.values]: columns
  1865. }];
  1866. } else if (dataType.value === "cascade") {
  1867. formatCascade();
  1868. } else {
  1869. formattedColumns.value = columns;
  1870. }
  1871. hasOptions.value = formattedColumns.value.some((item) => item[columnsFieldNames.value.values] && item[columnsFieldNames.value.values].length !== 0) || children.some((item) => item.hasOptions);
  1872. };
  1873. const getIndexes = () => children.map((child) => child.state.index);
  1874. const setColumnValues = (index, options) => {
  1875. const column = children[index];
  1876. if (column) {
  1877. column.setOptions(options);
  1878. hasOptions.value = true;
  1879. }
  1880. };
  1881. const onCascadeChange = (columnIndex) => {
  1882. let cursor = {
  1883. [columnsFieldNames.value.children]: props.columns
  1884. };
  1885. const indexes = getIndexes();
  1886. for (let i = 0; i <= columnIndex; i++) {
  1887. cursor = cursor[columnsFieldNames.value.children][indexes[i]];
  1888. }
  1889. while (cursor && cursor[columnsFieldNames.value.children]) {
  1890. columnIndex++;
  1891. setColumnValues(columnIndex, cursor[columnsFieldNames.value.children]);
  1892. cursor = cursor[columnsFieldNames.value.children][cursor.defaultIndex || 0];
  1893. }
  1894. };
  1895. const getChild = (index) => children[index];
  1896. const getColumnValue = (index) => {
  1897. const column = getChild(index);
  1898. if (column) {
  1899. return column.getValue();
  1900. }
  1901. };
  1902. const setColumnValue = (index, value) => {
  1903. const column = getChild(index);
  1904. if (column) {
  1905. column.setValue(value);
  1906. if (dataType.value === "cascade") {
  1907. onCascadeChange(index);
  1908. }
  1909. }
  1910. };
  1911. const getColumnIndex = (index) => {
  1912. const column = getChild(index);
  1913. if (column) {
  1914. return column.state.index;
  1915. }
  1916. };
  1917. const setColumnIndex = (columnIndex, optionIndex) => {
  1918. const column = getChild(columnIndex);
  1919. if (column) {
  1920. column.setIndex(optionIndex);
  1921. if (dataType.value === "cascade") {
  1922. onCascadeChange(columnIndex);
  1923. }
  1924. }
  1925. };
  1926. const getColumnValues = (index) => {
  1927. const column = getChild(index);
  1928. if (column) {
  1929. return column.state.options;
  1930. }
  1931. };
  1932. const getValues = () => children.map((child) => child.getValue());
  1933. const setValues = (values) => {
  1934. values.forEach((value, index) => {
  1935. setColumnValue(index, value);
  1936. });
  1937. };
  1938. const setIndexes = (indexes) => {
  1939. indexes.forEach((optionIndex, columnIndex) => {
  1940. setColumnIndex(columnIndex, optionIndex);
  1941. });
  1942. };
  1943. const emitAction = (event) => {
  1944. if (dataType.value === "plain") {
  1945. emit(event, getColumnValue(0), getColumnIndex(0));
  1946. } else {
  1947. emit(event, getValues(), getIndexes());
  1948. }
  1949. };
  1950. const onChange = (columnIndex) => {
  1951. if (dataType.value === "cascade") {
  1952. onCascadeChange(columnIndex);
  1953. }
  1954. if (dataType.value === "plain") {
  1955. emit("change", getColumnValue(0), getColumnIndex(0));
  1956. } else {
  1957. emit("change", getValues(), columnIndex);
  1958. }
  1959. };
  1960. const confirm = () => {
  1961. children.forEach((child) => child.stopMomentum());
  1962. emitAction("confirm");
  1963. };
  1964. const cancel = () => emitAction("cancel");
  1965. const renderTitle = () => {
  1966. if (slots.title) {
  1967. return slots.title();
  1968. }
  1969. if (props.title) {
  1970. return vue.createVNode("div", {
  1971. "class": [bem$1f("title"), "van-ellipsis"]
  1972. }, [props.title]);
  1973. }
  1974. };
  1975. const renderCancel = () => {
  1976. const text = props.cancelButtonText || t$j("cancel");
  1977. return vue.createVNode("button", {
  1978. "type": "button",
  1979. "class": [bem$1f("cancel"), HAPTICS_FEEDBACK],
  1980. "onClick": cancel
  1981. }, [slots.cancel ? slots.cancel() : text]);
  1982. };
  1983. const renderConfirm = () => {
  1984. const text = props.confirmButtonText || t$j("confirm");
  1985. return vue.createVNode("button", {
  1986. "type": "button",
  1987. "class": [bem$1f("confirm"), HAPTICS_FEEDBACK],
  1988. "onClick": confirm
  1989. }, [slots.confirm ? slots.confirm() : text]);
  1990. };
  1991. const renderToolbar = () => {
  1992. if (props.showToolbar) {
  1993. const slot = slots.toolbar || slots.default;
  1994. return vue.createVNode("div", {
  1995. "class": bem$1f("toolbar")
  1996. }, [slot ? slot() : [renderCancel(), renderTitle(), renderConfirm()]]);
  1997. }
  1998. };
  1999. const renderColumnItems = () => formattedColumns.value.map((item, columnIndex) => {
  2000. var _a;
  2001. return vue.createVNode(stdin_default$1r, {
  2002. "textKey": columnsFieldNames.value.text,
  2003. "readonly": props.readonly,
  2004. "allowHtml": props.allowHtml,
  2005. "className": item.className,
  2006. "itemHeight": itemHeight.value,
  2007. "defaultIndex": (_a = item.defaultIndex) != null ? _a : +props.defaultIndex,
  2008. "swipeDuration": props.swipeDuration,
  2009. "initialOptions": item[columnsFieldNames.value.values],
  2010. "visibleItemCount": props.visibleItemCount,
  2011. "onChange": () => onChange(columnIndex)
  2012. }, {
  2013. option: slots.option
  2014. });
  2015. });
  2016. const renderMask = (wrapHeight) => {
  2017. if (hasOptions.value) {
  2018. const frameStyle = {
  2019. height: `${itemHeight.value}px`
  2020. };
  2021. const maskStyle = {
  2022. backgroundSize: `100% ${(wrapHeight - itemHeight.value) / 2}px`
  2023. };
  2024. return [vue.createVNode("div", {
  2025. "class": bem$1f("mask"),
  2026. "style": maskStyle
  2027. }, null), vue.createVNode("div", {
  2028. "class": [BORDER_UNSET_TOP_BOTTOM, bem$1f("frame")],
  2029. "style": frameStyle
  2030. }, null)];
  2031. }
  2032. };
  2033. const renderColumns = () => {
  2034. const wrapHeight = itemHeight.value * +props.visibleItemCount;
  2035. const columnsStyle = {
  2036. height: `${wrapHeight}px`
  2037. };
  2038. return vue.createVNode("div", {
  2039. "ref": columnsRef,
  2040. "class": bem$1f("columns"),
  2041. "style": columnsStyle
  2042. }, [renderColumnItems(), renderMask(wrapHeight)]);
  2043. };
  2044. vue.watch(() => props.columns, format2, {
  2045. immediate: true
  2046. });
  2047. use.useEventListener("touchmove", preventDefault, {
  2048. target: columnsRef
  2049. });
  2050. useExpose({
  2051. confirm,
  2052. getValues,
  2053. setValues,
  2054. getIndexes,
  2055. setIndexes,
  2056. getColumnIndex,
  2057. setColumnIndex,
  2058. getColumnValue,
  2059. setColumnValue,
  2060. getColumnValues,
  2061. setColumnValues
  2062. });
  2063. return () => {
  2064. var _a, _b;
  2065. return vue.createVNode("div", {
  2066. "class": bem$1f()
  2067. }, [props.toolbarPosition === "top" ? renderToolbar() : null, props.loading ? vue.createVNode(Loading, {
  2068. "class": bem$1f("loading")
  2069. }, null) : null, (_a = slots["columns-top"]) == null ? void 0 : _a.call(slots), renderColumns(), (_b = slots["columns-bottom"]) == null ? void 0 : _b.call(slots), props.toolbarPosition === "bottom" ? renderToolbar() : null]);
  2070. };
  2071. }
  2072. });
  2073. const Picker = withInstall(stdin_default$1q);
  2074. const [name$1i, bem$1e] = createNamespace("area");
  2075. const EMPTY_CODE = "000000";
  2076. const INHERIT_SLOTS = ["title", "cancel", "confirm", "toolbar", "columns-top", "columns-bottom"];
  2077. const INHERIT_PROPS = ["title", "loading", "readonly", "itemHeight", "swipeDuration", "visibleItemCount", "cancelButtonText", "confirmButtonText"];
  2078. const isOverseaCode = (code) => code[0] === "9";
  2079. const areaProps = extend({}, pickerSharedProps, {
  2080. value: String,
  2081. columnsNum: makeNumericProp(3),
  2082. columnsPlaceholder: makeArrayProp(),
  2083. areaList: {
  2084. type: Object,
  2085. default: () => ({})
  2086. },
  2087. isOverseaCode: {
  2088. type: Function,
  2089. default: isOverseaCode
  2090. }
  2091. });
  2092. var stdin_default$1p = vue.defineComponent({
  2093. name: name$1i,
  2094. props: areaProps,
  2095. emits: ["change", "confirm", "cancel"],
  2096. setup(props, {
  2097. emit,
  2098. slots
  2099. }) {
  2100. const pickerRef = vue.ref();
  2101. const state = vue.reactive({
  2102. code: props.value,
  2103. columns: [{
  2104. values: []
  2105. }, {
  2106. values: []
  2107. }, {
  2108. values: []
  2109. }]
  2110. });
  2111. const areaList = vue.computed(() => {
  2112. const {
  2113. areaList: areaList2
  2114. } = props;
  2115. return {
  2116. province: areaList2.province_list || {},
  2117. city: areaList2.city_list || {},
  2118. county: areaList2.county_list || {}
  2119. };
  2120. });
  2121. const placeholderMap = vue.computed(() => {
  2122. const {
  2123. columnsPlaceholder
  2124. } = props;
  2125. return {
  2126. province: columnsPlaceholder[0] || "",
  2127. city: columnsPlaceholder[1] || "",
  2128. county: columnsPlaceholder[2] || ""
  2129. };
  2130. });
  2131. const getDefaultCode = () => {
  2132. if (props.columnsPlaceholder.length) {
  2133. return EMPTY_CODE;
  2134. }
  2135. const {
  2136. county,
  2137. city
  2138. } = areaList.value;
  2139. const countyCodes = Object.keys(county);
  2140. if (countyCodes[0]) {
  2141. return countyCodes[0];
  2142. }
  2143. const cityCodes = Object.keys(city);
  2144. if (cityCodes[0]) {
  2145. return cityCodes[0];
  2146. }
  2147. return "";
  2148. };
  2149. const getColumnValues = (type, code) => {
  2150. let column = [];
  2151. if (type !== "province" && !code) {
  2152. return column;
  2153. }
  2154. const list = areaList.value[type];
  2155. column = Object.keys(list).map((listCode) => ({
  2156. code: listCode,
  2157. name: list[listCode]
  2158. }));
  2159. if (code) {
  2160. if (type === "city" && props.isOverseaCode(code)) {
  2161. code = "9";
  2162. }
  2163. column = column.filter((item) => item.code.indexOf(code) === 0);
  2164. }
  2165. if (placeholderMap.value[type] && column.length) {
  2166. let codeFill = "";
  2167. if (type === "city") {
  2168. codeFill = EMPTY_CODE.slice(2, 4);
  2169. } else if (type === "county") {
  2170. codeFill = EMPTY_CODE.slice(4, 6);
  2171. }
  2172. column.unshift({
  2173. code: code + codeFill,
  2174. name: placeholderMap.value[type]
  2175. });
  2176. }
  2177. return column;
  2178. };
  2179. const getIndex = (type, code) => {
  2180. let compareNum = code.length;
  2181. if (type === "province") {
  2182. compareNum = props.isOverseaCode(code) ? 1 : 2;
  2183. }
  2184. if (type === "city") {
  2185. compareNum = 4;
  2186. }
  2187. code = code.slice(0, compareNum);
  2188. const list = getColumnValues(type, compareNum > 2 ? code.slice(0, compareNum - 2) : "");
  2189. for (let i = 0; i < list.length; i++) {
  2190. if (list[i].code.slice(0, compareNum) === code) {
  2191. return i;
  2192. }
  2193. }
  2194. return 0;
  2195. };
  2196. const setValues = () => {
  2197. const picker = pickerRef.value;
  2198. if (!picker) {
  2199. return;
  2200. }
  2201. let code = state.code || getDefaultCode();
  2202. const province = getColumnValues("province");
  2203. const city = getColumnValues("city", code.slice(0, 2));
  2204. picker.setColumnValues(0, province);
  2205. picker.setColumnValues(1, city);
  2206. if (city.length && code.slice(2, 4) === "00" && !props.isOverseaCode(code)) {
  2207. [{
  2208. code
  2209. }] = city;
  2210. }
  2211. picker.setColumnValues(2, getColumnValues("county", code.slice(0, 4)));
  2212. picker.setIndexes([getIndex("province", code), getIndex("city", code), getIndex("county", code)]);
  2213. };
  2214. const parseValues = (values) => values.map((value, index) => {
  2215. if (value) {
  2216. value = deepClone(value);
  2217. if (!value.code || value.name === props.columnsPlaceholder[index]) {
  2218. value.code = "";
  2219. value.name = "";
  2220. }
  2221. }
  2222. return value;
  2223. });
  2224. const getValues = () => {
  2225. if (pickerRef.value) {
  2226. const values = pickerRef.value.getValues().filter(Boolean);
  2227. return parseValues(values);
  2228. }
  2229. return [];
  2230. };
  2231. const getArea = () => {
  2232. const values = getValues();
  2233. const area = {
  2234. code: "",
  2235. country: "",
  2236. province: "",
  2237. city: "",
  2238. county: ""
  2239. };
  2240. if (!values.length) {
  2241. return area;
  2242. }
  2243. const names = values.map((item) => item.name);
  2244. const validValues = values.filter((value) => value.code);
  2245. area.code = validValues.length ? validValues[validValues.length - 1].code : "";
  2246. if (props.isOverseaCode(area.code)) {
  2247. area.country = names[1] || "";
  2248. area.province = names[2] || "";
  2249. } else {
  2250. area.province = names[0] || "";
  2251. area.city = names[1] || "";
  2252. area.county = names[2] || "";
  2253. }
  2254. return area;
  2255. };
  2256. const reset = (newCode = "") => {
  2257. state.code = newCode;
  2258. setValues();
  2259. };
  2260. const onChange = (values, index) => {
  2261. state.code = values[index].code;
  2262. setValues();
  2263. if (pickerRef.value) {
  2264. const parsedValues = parseValues(pickerRef.value.getValues());
  2265. emit("change", parsedValues, index);
  2266. }
  2267. };
  2268. const onConfirm = (values, index) => {
  2269. setValues();
  2270. emit("confirm", parseValues(values), index);
  2271. };
  2272. const onCancel = (...args) => emit("cancel", ...args);
  2273. vue.onMounted(setValues);
  2274. vue.watch(() => props.value, (value) => {
  2275. state.code = value;
  2276. setValues();
  2277. });
  2278. vue.watch(() => props.areaList, setValues, {
  2279. deep: true
  2280. });
  2281. vue.watch(() => props.columnsNum, () => {
  2282. vue.nextTick(setValues);
  2283. });
  2284. useExpose({
  2285. reset,
  2286. getArea,
  2287. getValues
  2288. });
  2289. return () => {
  2290. const columns = state.columns.slice(0, +props.columnsNum);
  2291. return vue.createVNode(Picker, vue.mergeProps({
  2292. "ref": pickerRef,
  2293. "class": bem$1e(),
  2294. "columns": columns,
  2295. "columnsFieldNames": {
  2296. text: "name"
  2297. },
  2298. "onChange": onChange,
  2299. "onCancel": onCancel,
  2300. "onConfirm": onConfirm
  2301. }, pick(props, INHERIT_PROPS)), pick(slots, INHERIT_SLOTS));
  2302. };
  2303. }
  2304. });
  2305. const Area = withInstall(stdin_default$1p);
  2306. const [name$1h, bem$1d] = createNamespace("cell");
  2307. const cellSharedProps = {
  2308. icon: String,
  2309. size: String,
  2310. title: numericProp,
  2311. value: numericProp,
  2312. label: numericProp,
  2313. center: Boolean,
  2314. isLink: Boolean,
  2315. border: truthProp,
  2316. required: Boolean,
  2317. iconPrefix: String,
  2318. valueClass: unknownProp,
  2319. labelClass: unknownProp,
  2320. titleClass: unknownProp,
  2321. titleStyle: null,
  2322. arrowDirection: String,
  2323. clickable: {
  2324. type: Boolean,
  2325. default: null
  2326. }
  2327. };
  2328. const cellProps = extend({}, cellSharedProps, routeProps);
  2329. var stdin_default$1o = vue.defineComponent({
  2330. name: name$1h,
  2331. props: cellProps,
  2332. setup(props, {
  2333. slots
  2334. }) {
  2335. const route2 = useRoute();
  2336. const renderLabel = () => {
  2337. const showLabel = slots.label || isDef(props.label);
  2338. if (showLabel) {
  2339. return vue.createVNode("div", {
  2340. "class": [bem$1d("label"), props.labelClass]
  2341. }, [slots.label ? slots.label() : props.label]);
  2342. }
  2343. };
  2344. const renderTitle = () => {
  2345. if (slots.title || isDef(props.title)) {
  2346. return vue.createVNode("div", {
  2347. "class": [bem$1d("title"), props.titleClass],
  2348. "style": props.titleStyle
  2349. }, [slots.title ? slots.title() : vue.createVNode("span", null, [props.title]), renderLabel()]);
  2350. }
  2351. };
  2352. const renderValue = () => {
  2353. const slot = slots.value || slots.default;
  2354. const hasValue = slot || isDef(props.value);
  2355. if (hasValue) {
  2356. const hasTitle = slots.title || isDef(props.title);
  2357. return vue.createVNode("div", {
  2358. "class": [bem$1d("value", {
  2359. alone: !hasTitle
  2360. }), props.valueClass]
  2361. }, [slot ? slot() : vue.createVNode("span", null, [props.value])]);
  2362. }
  2363. };
  2364. const renderLeftIcon = () => {
  2365. if (slots.icon) {
  2366. return slots.icon();
  2367. }
  2368. if (props.icon) {
  2369. return vue.createVNode(Icon, {
  2370. "name": props.icon,
  2371. "class": bem$1d("left-icon"),
  2372. "classPrefix": props.iconPrefix
  2373. }, null);
  2374. }
  2375. };
  2376. const renderRightIcon = () => {
  2377. if (slots["right-icon"]) {
  2378. return slots["right-icon"]();
  2379. }
  2380. if (props.isLink) {
  2381. const name2 = props.arrowDirection ? `arrow-${props.arrowDirection}` : "arrow";
  2382. return vue.createVNode(Icon, {
  2383. "name": name2,
  2384. "class": bem$1d("right-icon")
  2385. }, null);
  2386. }
  2387. };
  2388. return () => {
  2389. var _a, _b;
  2390. const {
  2391. size,
  2392. center,
  2393. border,
  2394. isLink,
  2395. required
  2396. } = props;
  2397. const clickable = (_a = props.clickable) != null ? _a : isLink;
  2398. const classes = {
  2399. center,
  2400. required,
  2401. clickable,
  2402. borderless: !border
  2403. };
  2404. if (size) {
  2405. classes[size] = !!size;
  2406. }
  2407. return vue.createVNode("div", {
  2408. "class": bem$1d(classes),
  2409. "role": clickable ? "button" : void 0,
  2410. "tabindex": clickable ? 0 : void 0,
  2411. "onClick": route2
  2412. }, [renderLeftIcon(), renderTitle(), renderValue(), renderRightIcon(), (_b = slots.extra) == null ? void 0 : _b.call(slots)]);
  2413. };
  2414. }
  2415. });
  2416. const Cell = withInstall(stdin_default$1o);
  2417. const [name$1g, bem$1c] = createNamespace("form");
  2418. const formProps = {
  2419. colon: Boolean,
  2420. disabled: Boolean,
  2421. readonly: Boolean,
  2422. showError: Boolean,
  2423. labelWidth: numericProp,
  2424. labelAlign: String,
  2425. inputAlign: String,
  2426. scrollToError: Boolean,
  2427. validateFirst: Boolean,
  2428. submitOnEnter: truthProp,
  2429. showErrorMessage: truthProp,
  2430. errorMessageAlign: String,
  2431. validateTrigger: {
  2432. type: [String, Array],
  2433. default: "onBlur"
  2434. }
  2435. };
  2436. var stdin_default$1n = vue.defineComponent({
  2437. name: name$1g,
  2438. props: formProps,
  2439. emits: ["submit", "failed"],
  2440. setup(props, {
  2441. emit,
  2442. slots
  2443. }) {
  2444. const {
  2445. children,
  2446. linkChildren
  2447. } = use.useChildren(FORM_KEY);
  2448. const getFieldsByNames = (names) => {
  2449. if (names) {
  2450. return children.filter((field) => names.includes(field.name));
  2451. }
  2452. return children;
  2453. };
  2454. const validateSeq = (names) => new Promise((resolve, reject) => {
  2455. const errors = [];
  2456. const fields = getFieldsByNames(names);
  2457. fields.reduce((promise, field) => promise.then(() => {
  2458. if (!errors.length) {
  2459. return field.validate().then((error) => {
  2460. if (error) {
  2461. errors.push(error);
  2462. }
  2463. });
  2464. }
  2465. }), Promise.resolve()).then(() => {
  2466. if (errors.length) {
  2467. reject(errors);
  2468. } else {
  2469. resolve();
  2470. }
  2471. });
  2472. });
  2473. const validateAll = (names) => new Promise((resolve, reject) => {
  2474. const fields = getFieldsByNames(names);
  2475. Promise.all(fields.map((item) => item.validate())).then((errors) => {
  2476. errors = errors.filter(Boolean);
  2477. if (errors.length) {
  2478. reject(errors);
  2479. } else {
  2480. resolve();
  2481. }
  2482. });
  2483. });
  2484. const validateField = (name2) => {
  2485. const matched = children.find((item) => item.name === name2);
  2486. if (matched) {
  2487. return new Promise((resolve, reject) => {
  2488. matched.validate().then((error) => {
  2489. if (error) {
  2490. reject(error);
  2491. } else {
  2492. resolve();
  2493. }
  2494. });
  2495. });
  2496. }
  2497. return Promise.reject();
  2498. };
  2499. const validate = (name2) => {
  2500. if (typeof name2 === "string") {
  2501. return validateField(name2);
  2502. }
  2503. return props.validateFirst ? validateSeq(name2) : validateAll(name2);
  2504. };
  2505. const resetValidation = (name2) => {
  2506. if (typeof name2 === "string") {
  2507. name2 = [name2];
  2508. }
  2509. const fields = getFieldsByNames(name2);
  2510. fields.forEach((item) => {
  2511. item.resetValidation();
  2512. });
  2513. };
  2514. const getValidationStatus = () => children.reduce((form, field) => {
  2515. form[field.name] = field.getValidationStatus();
  2516. return form;
  2517. }, {});
  2518. const scrollToField = (name2, options) => {
  2519. children.some((item) => {
  2520. if (item.name === name2) {
  2521. item.$el.scrollIntoView(options);
  2522. return true;
  2523. }
  2524. return false;
  2525. });
  2526. };
  2527. const getValues = () => children.reduce((form, field) => {
  2528. form[field.name] = field.formValue.value;
  2529. return form;
  2530. }, {});
  2531. const submit = () => {
  2532. const values = getValues();
  2533. validate().then(() => emit("submit", values)).catch((errors) => {
  2534. emit("failed", {
  2535. values,
  2536. errors
  2537. });
  2538. if (props.scrollToError && errors[0].name) {
  2539. scrollToField(errors[0].name);
  2540. }
  2541. });
  2542. };
  2543. const onSubmit = (event) => {
  2544. preventDefault(event);
  2545. submit();
  2546. };
  2547. linkChildren({
  2548. props
  2549. });
  2550. useExpose({
  2551. submit,
  2552. validate,
  2553. getValues,
  2554. scrollToField,
  2555. resetValidation,
  2556. getValidationStatus
  2557. });
  2558. return () => {
  2559. var _a;
  2560. return vue.createVNode("form", {
  2561. "class": bem$1c(),
  2562. "onSubmit": onSubmit
  2563. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
  2564. };
  2565. }
  2566. });
  2567. const Form = withInstall(stdin_default$1n);
  2568. function isEmptyValue(value) {
  2569. if (Array.isArray(value)) {
  2570. return !value.length;
  2571. }
  2572. if (value === 0) {
  2573. return false;
  2574. }
  2575. return !value;
  2576. }
  2577. function runSyncRule(value, rule) {
  2578. if (isEmptyValue(value)) {
  2579. if (rule.required) {
  2580. return false;
  2581. }
  2582. if (rule.validateEmpty === false) {
  2583. return true;
  2584. }
  2585. }
  2586. if (rule.pattern && !rule.pattern.test(String(value))) {
  2587. return false;
  2588. }
  2589. return true;
  2590. }
  2591. function runRuleValidator(value, rule) {
  2592. return new Promise((resolve) => {
  2593. const returnVal = rule.validator(value, rule);
  2594. if (isPromise(returnVal)) {
  2595. returnVal.then(resolve);
  2596. return;
  2597. }
  2598. resolve(returnVal);
  2599. });
  2600. }
  2601. function getRuleMessage(value, rule) {
  2602. const { message } = rule;
  2603. if (isFunction(message)) {
  2604. return message(value, rule);
  2605. }
  2606. return message || "";
  2607. }
  2608. function startComposing({ target }) {
  2609. target.composing = true;
  2610. }
  2611. function endComposing({ target }) {
  2612. if (target.composing) {
  2613. target.composing = false;
  2614. target.dispatchEvent(new Event("input"));
  2615. }
  2616. }
  2617. function resizeTextarea(input, autosize) {
  2618. const scrollTop = getRootScrollTop();
  2619. input.style.height = "auto";
  2620. let height = input.scrollHeight;
  2621. if (isObject(autosize)) {
  2622. const { maxHeight, minHeight } = autosize;
  2623. if (maxHeight !== void 0) {
  2624. height = Math.min(height, maxHeight);
  2625. }
  2626. if (minHeight !== void 0) {
  2627. height = Math.max(height, minHeight);
  2628. }
  2629. }
  2630. if (height) {
  2631. input.style.height = `${height}px`;
  2632. setRootScrollTop(scrollTop);
  2633. }
  2634. }
  2635. function mapInputType(type) {
  2636. if (type === "number") {
  2637. return {
  2638. type: "text",
  2639. inputmode: "decimal"
  2640. };
  2641. }
  2642. if (type === "digit") {
  2643. return {
  2644. type: "tel",
  2645. inputmode: "numeric"
  2646. };
  2647. }
  2648. return { type };
  2649. }
  2650. function getStringLength(str) {
  2651. return [...str].length;
  2652. }
  2653. function cutString(str, maxlength) {
  2654. return [...str].slice(0, maxlength).join("");
  2655. }
  2656. let current = 0;
  2657. function useId() {
  2658. const vm = vue.getCurrentInstance();
  2659. const { name: name2 = "unknown" } = (vm == null ? void 0 : vm.type) || {};
  2660. if (process.env.NODE_ENV === "test") {
  2661. return name2;
  2662. }
  2663. return `${name2}-${++current}`;
  2664. }
  2665. const [name$1f, bem$1b] = createNamespace("field");
  2666. const fieldSharedProps = {
  2667. id: String,
  2668. name: String,
  2669. leftIcon: String,
  2670. rightIcon: String,
  2671. autofocus: Boolean,
  2672. clearable: Boolean,
  2673. maxlength: numericProp,
  2674. formatter: Function,
  2675. clearIcon: makeStringProp("clear"),
  2676. modelValue: makeNumericProp(""),
  2677. inputAlign: String,
  2678. placeholder: String,
  2679. autocomplete: String,
  2680. errorMessage: String,
  2681. enterkeyhint: String,
  2682. clearTrigger: makeStringProp("focus"),
  2683. formatTrigger: makeStringProp("onChange"),
  2684. error: {
  2685. type: Boolean,
  2686. default: null
  2687. },
  2688. disabled: {
  2689. type: Boolean,
  2690. default: null
  2691. },
  2692. readonly: {
  2693. type: Boolean,
  2694. default: null
  2695. }
  2696. };
  2697. const fieldProps = extend({}, cellSharedProps, fieldSharedProps, {
  2698. rows: numericProp,
  2699. type: makeStringProp("text"),
  2700. rules: Array,
  2701. autosize: [Boolean, Object],
  2702. labelWidth: numericProp,
  2703. labelClass: unknownProp,
  2704. labelAlign: String,
  2705. showWordLimit: Boolean,
  2706. errorMessageAlign: String,
  2707. colon: {
  2708. type: Boolean,
  2709. default: null
  2710. }
  2711. });
  2712. var stdin_default$1m = vue.defineComponent({
  2713. name: name$1f,
  2714. props: fieldProps,
  2715. emits: ["blur", "focus", "clear", "keypress", "click-input", "end-validate", "start-validate", "click-left-icon", "click-right-icon", "update:modelValue"],
  2716. setup(props, {
  2717. emit,
  2718. slots
  2719. }) {
  2720. const id = useId();
  2721. const state = vue.reactive({
  2722. status: "unvalidated",
  2723. focused: false,
  2724. validateMessage: ""
  2725. });
  2726. const inputRef = vue.ref();
  2727. const clearIconRef = vue.ref();
  2728. const customValue = vue.ref();
  2729. const {
  2730. parent: form
  2731. } = use.useParent(FORM_KEY);
  2732. const getModelValue = () => {
  2733. var _a;
  2734. return String((_a = props.modelValue) != null ? _a : "");
  2735. };
  2736. const getProp = (key) => {
  2737. if (isDef(props[key])) {
  2738. return props[key];
  2739. }
  2740. if (form && isDef(form.props[key])) {
  2741. return form.props[key];
  2742. }
  2743. };
  2744. const showClear = vue.computed(() => {
  2745. const readonly = getProp("readonly");
  2746. if (props.clearable && !readonly) {
  2747. const hasValue = getModelValue() !== "";
  2748. const trigger = props.clearTrigger === "always" || props.clearTrigger === "focus" && state.focused;
  2749. return hasValue && trigger;
  2750. }
  2751. return false;
  2752. });
  2753. const formValue = vue.computed(() => {
  2754. if (customValue.value && slots.input) {
  2755. return customValue.value();
  2756. }
  2757. return props.modelValue;
  2758. });
  2759. const runRules = (rules) => rules.reduce((promise, rule) => promise.then(() => {
  2760. if (state.status === "failed") {
  2761. return;
  2762. }
  2763. let {
  2764. value
  2765. } = formValue;
  2766. if (rule.formatter) {
  2767. value = rule.formatter(value, rule);
  2768. }
  2769. if (!runSyncRule(value, rule)) {
  2770. state.status = "failed";
  2771. state.validateMessage = getRuleMessage(value, rule);
  2772. return;
  2773. }
  2774. if (rule.validator) {
  2775. if (isEmptyValue(value) && rule.validateEmpty === false) {
  2776. return;
  2777. }
  2778. return runRuleValidator(value, rule).then((result) => {
  2779. if (result && typeof result === "string") {
  2780. state.status = "failed";
  2781. state.validateMessage = result;
  2782. } else if (result === false) {
  2783. state.status = "failed";
  2784. state.validateMessage = getRuleMessage(value, rule);
  2785. }
  2786. });
  2787. }
  2788. }), Promise.resolve());
  2789. const resetValidation = () => {
  2790. state.status = "unvalidated";
  2791. state.validateMessage = "";
  2792. };
  2793. const endValidate = () => emit("end-validate", {
  2794. status: state.status
  2795. });
  2796. const validate = (rules = props.rules) => new Promise((resolve) => {
  2797. resetValidation();
  2798. if (rules) {
  2799. emit("start-validate");
  2800. runRules(rules).then(() => {
  2801. if (state.status === "failed") {
  2802. resolve({
  2803. name: props.name,
  2804. message: state.validateMessage
  2805. });
  2806. endValidate();
  2807. } else {
  2808. state.status = "passed";
  2809. resolve();
  2810. endValidate();
  2811. }
  2812. });
  2813. } else {
  2814. resolve();
  2815. }
  2816. });
  2817. const validateWithTrigger = (trigger) => {
  2818. if (form && props.rules) {
  2819. const {
  2820. validateTrigger
  2821. } = form.props;
  2822. const defaultTrigger = toArray(validateTrigger).includes(trigger);
  2823. const rules = props.rules.filter((rule) => {
  2824. if (rule.trigger) {
  2825. return toArray(rule.trigger).includes(trigger);
  2826. }
  2827. return defaultTrigger;
  2828. });
  2829. if (rules.length) {
  2830. validate(rules);
  2831. }
  2832. }
  2833. };
  2834. const limitValueLength = (value) => {
  2835. const {
  2836. maxlength
  2837. } = props;
  2838. if (isDef(maxlength) && getStringLength(value) > maxlength) {
  2839. const modelValue = getModelValue();
  2840. if (modelValue && getStringLength(modelValue) === +maxlength) {
  2841. return modelValue;
  2842. }
  2843. return cutString(value, +maxlength);
  2844. }
  2845. return value;
  2846. };
  2847. const updateValue = (value, trigger = "onChange") => {
  2848. value = limitValueLength(value);
  2849. if (props.type === "number" || props.type === "digit") {
  2850. const isNumber = props.type === "number";
  2851. value = formatNumber(value, isNumber, isNumber);
  2852. }
  2853. if (props.formatter && trigger === props.formatTrigger) {
  2854. value = props.formatter(value);
  2855. }
  2856. if (inputRef.value && inputRef.value.value !== value) {
  2857. inputRef.value.value = value;
  2858. }
  2859. if (value !== props.modelValue) {
  2860. emit("update:modelValue", value);
  2861. }
  2862. };
  2863. const onInput = (event) => {
  2864. if (!event.target.composing) {
  2865. updateValue(event.target.value);
  2866. }
  2867. };
  2868. const blur = () => {
  2869. var _a;
  2870. return (_a = inputRef.value) == null ? void 0 : _a.blur();
  2871. };
  2872. const focus = () => {
  2873. var _a;
  2874. return (_a = inputRef.value) == null ? void 0 : _a.focus();
  2875. };
  2876. const adjustTextareaSize = () => {
  2877. const input = inputRef.value;
  2878. if (props.type === "textarea" && props.autosize && input) {
  2879. resizeTextarea(input, props.autosize);
  2880. }
  2881. };
  2882. const onFocus = (event) => {
  2883. state.focused = true;
  2884. emit("focus", event);
  2885. vue.nextTick(adjustTextareaSize);
  2886. if (getProp("readonly")) {
  2887. blur();
  2888. }
  2889. };
  2890. const onBlur = (event) => {
  2891. if (getProp("readonly")) {
  2892. return;
  2893. }
  2894. state.focused = false;
  2895. updateValue(getModelValue(), "onBlur");
  2896. emit("blur", event);
  2897. validateWithTrigger("onBlur");
  2898. vue.nextTick(adjustTextareaSize);
  2899. resetScroll();
  2900. };
  2901. const onClickInput = (event) => emit("click-input", event);
  2902. const onClickLeftIcon = (event) => emit("click-left-icon", event);
  2903. const onClickRightIcon = (event) => emit("click-right-icon", event);
  2904. const onClear = (event) => {
  2905. preventDefault(event);
  2906. emit("update:modelValue", "");
  2907. emit("clear", event);
  2908. };
  2909. const showError = vue.computed(() => {
  2910. if (typeof props.error === "boolean") {
  2911. return props.error;
  2912. }
  2913. if (form && form.props.showError && state.status === "failed") {
  2914. return true;
  2915. }
  2916. });
  2917. const labelStyle = vue.computed(() => {
  2918. const labelWidth = getProp("labelWidth");
  2919. if (labelWidth) {
  2920. return {
  2921. width: addUnit(labelWidth)
  2922. };
  2923. }
  2924. });
  2925. const onKeypress = (event) => {
  2926. const ENTER_CODE = 13;
  2927. if (event.keyCode === ENTER_CODE) {
  2928. const submitOnEnter = form && form.props.submitOnEnter;
  2929. if (!submitOnEnter && props.type !== "textarea") {
  2930. preventDefault(event);
  2931. }
  2932. if (props.type === "search") {
  2933. blur();
  2934. }
  2935. }
  2936. emit("keypress", event);
  2937. };
  2938. const getInputId = () => props.id || `${id}-input`;
  2939. const getValidationStatus = () => state.status;
  2940. const renderInput = () => {
  2941. const controlClass = bem$1b("control", [getProp("inputAlign"), {
  2942. error: showError.value,
  2943. custom: !!slots.input,
  2944. "min-height": props.type === "textarea" && !props.autosize
  2945. }]);
  2946. if (slots.input) {
  2947. return vue.createVNode("div", {
  2948. "class": controlClass,
  2949. "onClick": onClickInput
  2950. }, [slots.input()]);
  2951. }
  2952. const inputAttrs = {
  2953. id: getInputId(),
  2954. ref: inputRef,
  2955. name: props.name,
  2956. rows: props.rows !== void 0 ? +props.rows : void 0,
  2957. class: controlClass,
  2958. disabled: getProp("disabled"),
  2959. readonly: getProp("readonly"),
  2960. autofocus: props.autofocus,
  2961. placeholder: props.placeholder,
  2962. autocomplete: props.autocomplete,
  2963. enterkeyhint: props.enterkeyhint,
  2964. "aria-labelledby": props.label ? `${id}-label` : void 0,
  2965. onBlur,
  2966. onFocus,
  2967. onInput,
  2968. onClick: onClickInput,
  2969. onChange: endComposing,
  2970. onKeypress,
  2971. onCompositionend: endComposing,
  2972. onCompositionstart: startComposing
  2973. };
  2974. if (props.type === "textarea") {
  2975. return vue.createVNode("textarea", inputAttrs, null);
  2976. }
  2977. return vue.createVNode("input", vue.mergeProps(mapInputType(props.type), inputAttrs), null);
  2978. };
  2979. const renderLeftIcon = () => {
  2980. const leftIconSlot = slots["left-icon"];
  2981. if (props.leftIcon || leftIconSlot) {
  2982. return vue.createVNode("div", {
  2983. "class": bem$1b("left-icon"),
  2984. "onClick": onClickLeftIcon
  2985. }, [leftIconSlot ? leftIconSlot() : vue.createVNode(Icon, {
  2986. "name": props.leftIcon,
  2987. "classPrefix": props.iconPrefix
  2988. }, null)]);
  2989. }
  2990. };
  2991. const renderRightIcon = () => {
  2992. const rightIconSlot = slots["right-icon"];
  2993. if (props.rightIcon || rightIconSlot) {
  2994. return vue.createVNode("div", {
  2995. "class": bem$1b("right-icon"),
  2996. "onClick": onClickRightIcon
  2997. }, [rightIconSlot ? rightIconSlot() : vue.createVNode(Icon, {
  2998. "name": props.rightIcon,
  2999. "classPrefix": props.iconPrefix
  3000. }, null)]);
  3001. }
  3002. };
  3003. const renderWordLimit = () => {
  3004. if (props.showWordLimit && props.maxlength) {
  3005. const count = getStringLength(getModelValue());
  3006. return vue.createVNode("div", {
  3007. "class": bem$1b("word-limit")
  3008. }, [vue.createVNode("span", {
  3009. "class": bem$1b("word-num")
  3010. }, [count]), vue.createTextVNode("/"), props.maxlength]);
  3011. }
  3012. };
  3013. const renderMessage = () => {
  3014. if (form && form.props.showErrorMessage === false) {
  3015. return;
  3016. }
  3017. const message = props.errorMessage || state.validateMessage;
  3018. if (message) {
  3019. const slot = slots["error-message"];
  3020. const errorMessageAlign = getProp("errorMessageAlign");
  3021. return vue.createVNode("div", {
  3022. "class": bem$1b("error-message", errorMessageAlign)
  3023. }, [slot ? slot({
  3024. message
  3025. }) : message]);
  3026. }
  3027. };
  3028. const renderLabel = () => {
  3029. const colon = getProp("colon") ? ":" : "";
  3030. if (slots.label) {
  3031. return [slots.label(), colon];
  3032. }
  3033. if (props.label) {
  3034. return vue.createVNode("label", {
  3035. "id": `${id}-label`,
  3036. "for": getInputId()
  3037. }, [props.label + colon]);
  3038. }
  3039. };
  3040. const renderFieldBody = () => [vue.createVNode("div", {
  3041. "class": bem$1b("body")
  3042. }, [renderInput(), showClear.value && vue.createVNode(Icon, {
  3043. "ref": clearIconRef,
  3044. "name": props.clearIcon,
  3045. "class": bem$1b("clear")
  3046. }, null), renderRightIcon(), slots.button && vue.createVNode("div", {
  3047. "class": bem$1b("button")
  3048. }, [slots.button()])]), renderWordLimit(), renderMessage()];
  3049. useExpose({
  3050. blur,
  3051. focus,
  3052. validate,
  3053. formValue,
  3054. resetValidation,
  3055. getValidationStatus
  3056. });
  3057. vue.provide(use.CUSTOM_FIELD_INJECTION_KEY, {
  3058. customValue,
  3059. resetValidation,
  3060. validateWithTrigger
  3061. });
  3062. vue.watch(() => props.modelValue, () => {
  3063. updateValue(getModelValue());
  3064. resetValidation();
  3065. validateWithTrigger("onChange");
  3066. vue.nextTick(adjustTextareaSize);
  3067. });
  3068. vue.onMounted(() => {
  3069. updateValue(getModelValue(), props.formatTrigger);
  3070. vue.nextTick(adjustTextareaSize);
  3071. });
  3072. use.useEventListener("touchstart", onClear, {
  3073. target: vue.computed(() => {
  3074. var _a;
  3075. return (_a = clearIconRef.value) == null ? void 0 : _a.$el;
  3076. })
  3077. });
  3078. return () => {
  3079. const disabled = getProp("disabled");
  3080. const labelAlign = getProp("labelAlign");
  3081. const Label = renderLabel();
  3082. const LeftIcon = renderLeftIcon();
  3083. return vue.createVNode(Cell, {
  3084. "size": props.size,
  3085. "icon": props.leftIcon,
  3086. "class": bem$1b({
  3087. error: showError.value,
  3088. disabled,
  3089. [`label-${labelAlign}`]: labelAlign
  3090. }),
  3091. "center": props.center,
  3092. "border": props.border,
  3093. "isLink": props.isLink,
  3094. "clickable": props.clickable,
  3095. "titleStyle": labelStyle.value,
  3096. "valueClass": bem$1b("value"),
  3097. "titleClass": [bem$1b("label", [labelAlign, {
  3098. required: props.required
  3099. }]), props.labelClass],
  3100. "arrowDirection": props.arrowDirection
  3101. }, {
  3102. icon: LeftIcon ? () => LeftIcon : null,
  3103. title: Label ? () => Label : null,
  3104. value: renderFieldBody,
  3105. extra: slots.extra
  3106. });
  3107. };
  3108. }
  3109. });
  3110. const Field = withInstall(stdin_default$1m);
  3111. function usePopupState() {
  3112. const state = vue.reactive({
  3113. show: false
  3114. });
  3115. const toggle = (show) => {
  3116. state.show = show;
  3117. };
  3118. const open = (props) => {
  3119. extend(state, props, { transitionAppear: true });
  3120. toggle(true);
  3121. };
  3122. const close = () => toggle(false);
  3123. useExpose({ open, close, toggle });
  3124. return {
  3125. open,
  3126. close,
  3127. state,
  3128. toggle
  3129. };
  3130. }
  3131. function mountComponent(RootComponent) {
  3132. const app = vue.createApp(RootComponent);
  3133. const root = document.createElement("div");
  3134. document.body.appendChild(root);
  3135. return {
  3136. instance: app.mount(root),
  3137. unmount() {
  3138. app.unmount();
  3139. document.body.removeChild(root);
  3140. }
  3141. };
  3142. }
  3143. let lockCount = 0;
  3144. function lockClick(lock) {
  3145. if (lock) {
  3146. if (!lockCount) {
  3147. document.body.classList.add("van-toast--unclickable");
  3148. }
  3149. lockCount++;
  3150. } else if (lockCount) {
  3151. lockCount--;
  3152. if (!lockCount) {
  3153. document.body.classList.remove("van-toast--unclickable");
  3154. }
  3155. }
  3156. }
  3157. const [name$1e, bem$1a] = createNamespace("toast");
  3158. const popupInheritProps = ["show", "overlay", "teleport", "transition", "overlayClass", "overlayStyle", "closeOnClickOverlay"];
  3159. const toastProps = {
  3160. icon: String,
  3161. show: Boolean,
  3162. type: makeStringProp("text"),
  3163. overlay: Boolean,
  3164. message: numericProp,
  3165. iconSize: numericProp,
  3166. duration: makeNumberProp(2e3),
  3167. position: makeStringProp("middle"),
  3168. teleport: [String, Object],
  3169. className: unknownProp,
  3170. iconPrefix: String,
  3171. transition: makeStringProp("van-fade"),
  3172. loadingType: String,
  3173. forbidClick: Boolean,
  3174. overlayClass: unknownProp,
  3175. overlayStyle: Object,
  3176. closeOnClick: Boolean,
  3177. closeOnClickOverlay: Boolean
  3178. };
  3179. var stdin_default$1l = vue.defineComponent({
  3180. name: name$1e,
  3181. props: toastProps,
  3182. emits: ["update:show"],
  3183. setup(props, {
  3184. emit
  3185. }) {
  3186. let timer2;
  3187. let clickable = false;
  3188. const toggleClickable = () => {
  3189. const newValue = props.show && props.forbidClick;
  3190. if (clickable !== newValue) {
  3191. clickable = newValue;
  3192. lockClick(clickable);
  3193. }
  3194. };
  3195. const updateShow = (show) => emit("update:show", show);
  3196. const onClick = () => {
  3197. if (props.closeOnClick) {
  3198. updateShow(false);
  3199. }
  3200. };
  3201. const clearTimer = () => clearTimeout(timer2);
  3202. const renderIcon = () => {
  3203. const {
  3204. icon,
  3205. type,
  3206. iconSize,
  3207. iconPrefix,
  3208. loadingType
  3209. } = props;
  3210. const hasIcon = icon || type === "success" || type === "fail";
  3211. if (hasIcon) {
  3212. return vue.createVNode(Icon, {
  3213. "name": icon || type,
  3214. "size": iconSize,
  3215. "class": bem$1a("icon"),
  3216. "classPrefix": iconPrefix
  3217. }, null);
  3218. }
  3219. if (type === "loading") {
  3220. return vue.createVNode(Loading, {
  3221. "class": bem$1a("loading"),
  3222. "size": iconSize,
  3223. "type": loadingType
  3224. }, null);
  3225. }
  3226. };
  3227. const renderMessage = () => {
  3228. const {
  3229. type,
  3230. message
  3231. } = props;
  3232. if (isDef(message) && message !== "") {
  3233. return type === "html" ? vue.createVNode("div", {
  3234. "key": 0,
  3235. "class": bem$1a("text"),
  3236. "innerHTML": String(message)
  3237. }, null) : vue.createVNode("div", {
  3238. "class": bem$1a("text")
  3239. }, [message]);
  3240. }
  3241. };
  3242. vue.watch(() => [props.show, props.forbidClick], toggleClickable);
  3243. vue.watch(() => [props.show, props.type, props.message, props.duration], () => {
  3244. clearTimer();
  3245. if (props.show && props.duration > 0) {
  3246. timer2 = setTimeout(() => {
  3247. updateShow(false);
  3248. }, props.duration);
  3249. }
  3250. });
  3251. vue.onMounted(toggleClickable);
  3252. vue.onUnmounted(toggleClickable);
  3253. return () => vue.createVNode(Popup, vue.mergeProps({
  3254. "class": [bem$1a([props.position, {
  3255. [props.type]: !props.icon
  3256. }]), props.className],
  3257. "lockScroll": false,
  3258. "onClick": onClick,
  3259. "onClosed": clearTimer,
  3260. "onUpdate:show": updateShow
  3261. }, pick(props, popupInheritProps)), {
  3262. default: () => [renderIcon(), renderMessage()]
  3263. });
  3264. }
  3265. });
  3266. const defaultOptions$1 = {
  3267. icon: "",
  3268. type: "text",
  3269. message: "",
  3270. className: "",
  3271. overlay: false,
  3272. onClose: void 0,
  3273. onOpened: void 0,
  3274. duration: 2e3,
  3275. teleport: "body",
  3276. iconSize: void 0,
  3277. iconPrefix: void 0,
  3278. position: "middle",
  3279. transition: "van-fade",
  3280. forbidClick: false,
  3281. loadingType: void 0,
  3282. overlayClass: "",
  3283. overlayStyle: void 0,
  3284. closeOnClick: false,
  3285. closeOnClickOverlay: false
  3286. };
  3287. let queue = [];
  3288. let allowMultiple = false;
  3289. let currentOptions = extend({}, defaultOptions$1);
  3290. const defaultOptionsMap = /* @__PURE__ */ new Map();
  3291. function parseOptions$1(message) {
  3292. if (isObject(message)) {
  3293. return message;
  3294. }
  3295. return {
  3296. message
  3297. };
  3298. }
  3299. function createInstance() {
  3300. const {
  3301. instance: instance2,
  3302. unmount
  3303. } = mountComponent({
  3304. setup() {
  3305. const message = vue.ref("");
  3306. const {
  3307. open,
  3308. state,
  3309. close,
  3310. toggle
  3311. } = usePopupState();
  3312. const onClosed = () => {
  3313. if (allowMultiple) {
  3314. queue = queue.filter((item) => item !== instance2);
  3315. unmount();
  3316. }
  3317. };
  3318. const render = () => {
  3319. const attrs = {
  3320. onClosed,
  3321. "onUpdate:show": toggle
  3322. };
  3323. return vue.createVNode(stdin_default$1l, vue.mergeProps(state, attrs), null);
  3324. };
  3325. vue.watch(message, (val) => {
  3326. state.message = val;
  3327. });
  3328. vue.getCurrentInstance().render = render;
  3329. return {
  3330. open,
  3331. clear: close,
  3332. message
  3333. };
  3334. }
  3335. });
  3336. return instance2;
  3337. }
  3338. function getInstance() {
  3339. if (!queue.length || allowMultiple) {
  3340. const instance2 = createInstance();
  3341. queue.push(instance2);
  3342. }
  3343. return queue[queue.length - 1];
  3344. }
  3345. function Toast(options = {}) {
  3346. if (!inBrowser) {
  3347. return {};
  3348. }
  3349. const toast = getInstance();
  3350. const parsedOptions = parseOptions$1(options);
  3351. toast.open(extend({}, currentOptions, defaultOptionsMap.get(parsedOptions.type || currentOptions.type), parsedOptions));
  3352. return toast;
  3353. }
  3354. const createMethod = (type) => (options) => Toast(extend({
  3355. type
  3356. }, parseOptions$1(options)));
  3357. Toast.loading = createMethod("loading");
  3358. Toast.success = createMethod("success");
  3359. Toast.fail = createMethod("fail");
  3360. Toast.clear = (all) => {
  3361. var _a;
  3362. if (queue.length) {
  3363. if (all) {
  3364. queue.forEach((toast) => {
  3365. toast.clear();
  3366. });
  3367. queue = [];
  3368. } else if (!allowMultiple) {
  3369. queue[0].clear();
  3370. } else {
  3371. (_a = queue.shift()) == null ? void 0 : _a.clear();
  3372. }
  3373. }
  3374. };
  3375. function setDefaultOptions(type, options) {
  3376. if (typeof type === "string") {
  3377. defaultOptionsMap.set(type, options);
  3378. } else {
  3379. extend(currentOptions, type);
  3380. }
  3381. }
  3382. Toast.setDefaultOptions = setDefaultOptions;
  3383. Toast.resetDefaultOptions = (type) => {
  3384. if (typeof type === "string") {
  3385. defaultOptionsMap.delete(type);
  3386. } else {
  3387. currentOptions = extend({}, defaultOptions$1);
  3388. defaultOptionsMap.clear();
  3389. }
  3390. };
  3391. Toast.allowMultiple = (value = true) => {
  3392. allowMultiple = value;
  3393. };
  3394. Toast.install = (app) => {
  3395. app.use(withInstall(stdin_default$1l));
  3396. app.config.globalProperties.$toast = Toast;
  3397. };
  3398. const [name$1d, bem$19] = createNamespace("switch");
  3399. const switchProps = {
  3400. size: numericProp,
  3401. loading: Boolean,
  3402. disabled: Boolean,
  3403. modelValue: unknownProp,
  3404. activeColor: String,
  3405. inactiveColor: String,
  3406. activeValue: {
  3407. type: unknownProp,
  3408. default: true
  3409. },
  3410. inactiveValue: {
  3411. type: unknownProp,
  3412. default: false
  3413. }
  3414. };
  3415. var stdin_default$1k = vue.defineComponent({
  3416. name: name$1d,
  3417. props: switchProps,
  3418. emits: ["change", "update:modelValue"],
  3419. setup(props, {
  3420. emit,
  3421. slots
  3422. }) {
  3423. const isChecked = () => props.modelValue === props.activeValue;
  3424. const onClick = () => {
  3425. if (!props.disabled && !props.loading) {
  3426. const newValue = isChecked() ? props.inactiveValue : props.activeValue;
  3427. emit("update:modelValue", newValue);
  3428. emit("change", newValue);
  3429. }
  3430. };
  3431. const renderLoading = () => {
  3432. if (props.loading) {
  3433. const color = isChecked() ? props.activeColor : props.inactiveColor;
  3434. return vue.createVNode(Loading, {
  3435. "class": bem$19("loading"),
  3436. "color": color
  3437. }, null);
  3438. }
  3439. if (slots.node) {
  3440. return slots.node();
  3441. }
  3442. };
  3443. use.useCustomFieldValue(() => props.modelValue);
  3444. return () => {
  3445. var _a;
  3446. const {
  3447. size,
  3448. loading,
  3449. disabled,
  3450. activeColor,
  3451. inactiveColor
  3452. } = props;
  3453. const checked = isChecked();
  3454. const style = {
  3455. fontSize: addUnit(size),
  3456. backgroundColor: checked ? activeColor : inactiveColor
  3457. };
  3458. return vue.createVNode("div", {
  3459. "role": "switch",
  3460. "class": bem$19({
  3461. on: checked,
  3462. loading,
  3463. disabled
  3464. }),
  3465. "style": style,
  3466. "tabindex": disabled ? void 0 : 0,
  3467. "aria-checked": checked,
  3468. "onClick": onClick
  3469. }, [vue.createVNode("div", {
  3470. "class": bem$19("node")
  3471. }, [renderLoading()]), (_a = slots.background) == null ? void 0 : _a.call(slots)]);
  3472. };
  3473. }
  3474. });
  3475. const Switch = withInstall(stdin_default$1k);
  3476. const [name$1c, bem$18] = createNamespace("address-edit-detail");
  3477. const t$i = createNamespace("address-edit")[2];
  3478. var stdin_default$1j = vue.defineComponent({
  3479. name: name$1c,
  3480. props: {
  3481. show: Boolean,
  3482. rows: numericProp,
  3483. value: String,
  3484. rules: Array,
  3485. focused: Boolean,
  3486. maxlength: numericProp,
  3487. searchResult: Array,
  3488. showSearchResult: Boolean
  3489. },
  3490. emits: ["blur", "focus", "input", "select-search"],
  3491. setup(props, {
  3492. emit
  3493. }) {
  3494. const field = vue.ref();
  3495. const showSearchResult = () => props.focused && props.searchResult && props.showSearchResult;
  3496. const onSelect = (express) => {
  3497. emit("select-search", express);
  3498. emit("input", `${express.address || ""} ${express.name || ""}`.trim());
  3499. };
  3500. const renderSearchTitle = (express) => {
  3501. if (express.name) {
  3502. const text = express.name.replace(props.value, `<span class=${bem$18("keyword")}>${props.value}</span>`);
  3503. return vue.createVNode("div", {
  3504. "innerHTML": text
  3505. }, null);
  3506. }
  3507. };
  3508. const renderSearchResult = () => {
  3509. if (!showSearchResult()) {
  3510. return;
  3511. }
  3512. const {
  3513. searchResult
  3514. } = props;
  3515. return searchResult.map((express) => vue.createVNode(Cell, {
  3516. "clickable": true,
  3517. "key": express.name + express.address,
  3518. "icon": "location-o",
  3519. "label": express.address,
  3520. "class": bem$18("search-item"),
  3521. "border": false,
  3522. "onClick": () => onSelect(express)
  3523. }, {
  3524. title: () => renderSearchTitle(express)
  3525. }));
  3526. };
  3527. const onBlur = (event) => emit("blur", event);
  3528. const onFocus = (event) => emit("focus", event);
  3529. const onInput = (value) => emit("input", value);
  3530. return () => {
  3531. if (props.show) {
  3532. return vue.createVNode(vue.Fragment, null, [vue.createVNode(Field, {
  3533. "autosize": true,
  3534. "clearable": true,
  3535. "ref": field,
  3536. "class": bem$18(),
  3537. "rows": props.rows,
  3538. "type": "textarea",
  3539. "rules": props.rules,
  3540. "label": t$i("addressDetail"),
  3541. "border": !showSearchResult(),
  3542. "maxlength": props.maxlength,
  3543. "modelValue": props.value,
  3544. "placeholder": t$i("addressDetail"),
  3545. "onBlur": onBlur,
  3546. "onFocus": onFocus,
  3547. "onUpdate:modelValue": onInput
  3548. }, null), renderSearchResult()]);
  3549. }
  3550. };
  3551. }
  3552. });
  3553. const [name$1b, bem$17, t$h] = createNamespace("address-edit");
  3554. const DEFAULT_DATA = {
  3555. name: "",
  3556. tel: "",
  3557. city: "",
  3558. county: "",
  3559. country: "",
  3560. province: "",
  3561. areaCode: "",
  3562. isDefault: false,
  3563. postalCode: "",
  3564. addressDetail: ""
  3565. };
  3566. const isPostal = (value) => /^\d{6}$/.test(value);
  3567. const addressEditProps = {
  3568. areaList: Object,
  3569. isSaving: Boolean,
  3570. isDeleting: Boolean,
  3571. validator: Function,
  3572. showArea: truthProp,
  3573. showDetail: truthProp,
  3574. showDelete: Boolean,
  3575. showPostal: Boolean,
  3576. disableArea: Boolean,
  3577. searchResult: Array,
  3578. telMaxlength: numericProp,
  3579. showSetDefault: Boolean,
  3580. saveButtonText: String,
  3581. areaPlaceholder: String,
  3582. deleteButtonText: String,
  3583. showSearchResult: Boolean,
  3584. detailRows: makeNumericProp(1),
  3585. detailMaxlength: makeNumericProp(200),
  3586. areaColumnsPlaceholder: makeArrayProp(),
  3587. addressInfo: {
  3588. type: Object,
  3589. default: () => extend({}, DEFAULT_DATA)
  3590. },
  3591. telValidator: {
  3592. type: Function,
  3593. default: isMobile
  3594. },
  3595. postalValidator: {
  3596. type: Function,
  3597. default: isPostal
  3598. }
  3599. };
  3600. var stdin_default$1i = vue.defineComponent({
  3601. name: name$1b,
  3602. props: addressEditProps,
  3603. emits: ["save", "focus", "delete", "click-area", "change-area", "change-detail", "select-search", "change-default"],
  3604. setup(props, {
  3605. emit,
  3606. slots
  3607. }) {
  3608. const areaRef = vue.ref();
  3609. const data = vue.reactive({});
  3610. const showAreaPopup = vue.ref(false);
  3611. const detailFocused = vue.ref(false);
  3612. const areaListLoaded = vue.computed(() => isObject(props.areaList) && Object.keys(props.areaList).length);
  3613. const areaText = vue.computed(() => {
  3614. const {
  3615. country,
  3616. province,
  3617. city,
  3618. county,
  3619. areaCode
  3620. } = data;
  3621. if (areaCode) {
  3622. const arr = [country, province, city, county];
  3623. if (province && province === city) {
  3624. arr.splice(1, 1);
  3625. }
  3626. return arr.filter(Boolean).join("/");
  3627. }
  3628. return "";
  3629. });
  3630. const hideBottomFields = vue.computed(() => {
  3631. var _a;
  3632. return ((_a = props.searchResult) == null ? void 0 : _a.length) && detailFocused.value;
  3633. });
  3634. const assignAreaValues = () => {
  3635. if (areaRef.value) {
  3636. const detail = areaRef.value.getArea();
  3637. detail.areaCode = detail.code;
  3638. delete detail.code;
  3639. extend(data, detail);
  3640. }
  3641. };
  3642. const onFocus = (key) => {
  3643. detailFocused.value = key === "addressDetail";
  3644. emit("focus", key);
  3645. };
  3646. const rules = vue.computed(() => {
  3647. const {
  3648. validator,
  3649. telValidator,
  3650. postalValidator
  3651. } = props;
  3652. const makeRule = (name2, emptyMessage) => ({
  3653. validator: (value) => {
  3654. if (validator) {
  3655. const message = validator(name2, value);
  3656. if (message) {
  3657. return message;
  3658. }
  3659. }
  3660. if (!value) {
  3661. return emptyMessage;
  3662. }
  3663. return true;
  3664. }
  3665. });
  3666. return {
  3667. name: [makeRule("name", t$h("nameEmpty"))],
  3668. tel: [makeRule("tel", t$h("telInvalid")), {
  3669. validator: telValidator,
  3670. message: t$h("telInvalid")
  3671. }],
  3672. areaCode: [makeRule("areaCode", t$h("areaEmpty"))],
  3673. addressDetail: [makeRule("addressDetail", t$h("addressEmpty"))],
  3674. postalCode: [makeRule("addressDetail", t$h("postalEmpty")), {
  3675. validator: postalValidator,
  3676. message: t$h("postalEmpty")
  3677. }]
  3678. };
  3679. });
  3680. const onSave = () => emit("save", data);
  3681. const onChangeDetail = (val) => {
  3682. data.addressDetail = val;
  3683. emit("change-detail", val);
  3684. };
  3685. const onAreaConfirm = (values) => {
  3686. values = values.filter(Boolean);
  3687. if (values.some((value) => !value.code)) {
  3688. Toast(t$h("areaEmpty"));
  3689. } else {
  3690. showAreaPopup.value = false;
  3691. assignAreaValues();
  3692. emit("change-area", values);
  3693. }
  3694. };
  3695. const onDelete = () => emit("delete", data);
  3696. const getArea = () => {
  3697. var _a;
  3698. return ((_a = areaRef.value) == null ? void 0 : _a.getValues()) || [];
  3699. };
  3700. const setAreaCode = (code) => {
  3701. data.areaCode = code || "";
  3702. if (code) {
  3703. vue.nextTick(assignAreaValues);
  3704. }
  3705. };
  3706. const onDetailBlur = () => {
  3707. setTimeout(() => {
  3708. detailFocused.value = false;
  3709. });
  3710. };
  3711. const setAddressDetail = (value) => {
  3712. data.addressDetail = value;
  3713. };
  3714. const renderSetDefaultCell = () => {
  3715. if (props.showSetDefault) {
  3716. const slots2 = {
  3717. "right-icon": () => vue.createVNode(Switch, {
  3718. "modelValue": data.isDefault,
  3719. "onUpdate:modelValue": ($event) => data.isDefault = $event,
  3720. "size": "24",
  3721. "onChange": (event) => emit("change-default", event)
  3722. }, null)
  3723. };
  3724. return vue.withDirectives(vue.createVNode(Cell, {
  3725. "center": true,
  3726. "title": t$h("defaultAddress"),
  3727. "class": bem$17("default")
  3728. }, slots2), [[vue.vShow, !hideBottomFields.value]]);
  3729. }
  3730. };
  3731. useExpose({
  3732. getArea,
  3733. setAreaCode,
  3734. setAddressDetail
  3735. });
  3736. vue.watch(() => props.areaList, () => setAreaCode(data.areaCode));
  3737. vue.watch(() => props.addressInfo, (value) => {
  3738. extend(data, DEFAULT_DATA, value);
  3739. setAreaCode(value.areaCode);
  3740. }, {
  3741. deep: true,
  3742. immediate: true
  3743. });
  3744. return () => {
  3745. const {
  3746. disableArea
  3747. } = props;
  3748. return vue.createVNode(Form, {
  3749. "class": bem$17(),
  3750. "onSubmit": onSave
  3751. }, {
  3752. default: () => {
  3753. var _a;
  3754. return [vue.createVNode("div", {
  3755. "class": bem$17("fields")
  3756. }, [vue.createVNode(Field, {
  3757. "modelValue": data.name,
  3758. "onUpdate:modelValue": ($event) => data.name = $event,
  3759. "clearable": true,
  3760. "label": t$h("name"),
  3761. "rules": rules.value.name,
  3762. "placeholder": t$h("name"),
  3763. "onFocus": () => onFocus("name")
  3764. }, null), vue.createVNode(Field, {
  3765. "modelValue": data.tel,
  3766. "onUpdate:modelValue": ($event) => data.tel = $event,
  3767. "clearable": true,
  3768. "type": "tel",
  3769. "label": t$h("tel"),
  3770. "rules": rules.value.tel,
  3771. "maxlength": props.telMaxlength,
  3772. "placeholder": t$h("tel"),
  3773. "onFocus": () => onFocus("tel")
  3774. }, null), vue.withDirectives(vue.createVNode(Field, {
  3775. "readonly": true,
  3776. "label": t$h("area"),
  3777. "is-link": !disableArea,
  3778. "modelValue": areaText.value,
  3779. "rules": rules.value.areaCode,
  3780. "placeholder": props.areaPlaceholder || t$h("area"),
  3781. "onFocus": () => onFocus("areaCode"),
  3782. "onClick": () => {
  3783. emit("click-area");
  3784. showAreaPopup.value = !disableArea;
  3785. }
  3786. }, null), [[vue.vShow, props.showArea]]), vue.createVNode(stdin_default$1j, {
  3787. "show": props.showDetail,
  3788. "rows": props.detailRows,
  3789. "rules": rules.value.addressDetail,
  3790. "value": data.addressDetail,
  3791. "focused": detailFocused.value,
  3792. "maxlength": props.detailMaxlength,
  3793. "searchResult": props.searchResult,
  3794. "showSearchResult": props.showSearchResult,
  3795. "onBlur": onDetailBlur,
  3796. "onFocus": () => onFocus("addressDetail"),
  3797. "onInput": onChangeDetail,
  3798. "onSelect-search": (event) => emit("select-search", event)
  3799. }, null), props.showPostal && vue.withDirectives(vue.createVNode(Field, {
  3800. "modelValue": data.postalCode,
  3801. "onUpdate:modelValue": ($event) => data.postalCode = $event,
  3802. "type": "tel",
  3803. "rules": rules.value.postalCode,
  3804. "label": t$h("postal"),
  3805. "maxlength": "6",
  3806. "placeholder": t$h("postal"),
  3807. "onFocus": () => onFocus("postalCode")
  3808. }, null), [[vue.vShow, !hideBottomFields.value]]), (_a = slots.default) == null ? void 0 : _a.call(slots)]), renderSetDefaultCell(), vue.withDirectives(vue.createVNode("div", {
  3809. "class": bem$17("buttons")
  3810. }, [vue.createVNode(Button, {
  3811. "block": true,
  3812. "round": true,
  3813. "type": "danger",
  3814. "text": props.saveButtonText || t$h("save"),
  3815. "class": bem$17("button"),
  3816. "loading": props.isSaving,
  3817. "nativeType": "submit"
  3818. }, null), props.showDelete && vue.createVNode(Button, {
  3819. "block": true,
  3820. "round": true,
  3821. "class": bem$17("button"),
  3822. "loading": props.isDeleting,
  3823. "text": props.deleteButtonText || t$h("delete"),
  3824. "onClick": onDelete
  3825. }, null)]), [[vue.vShow, !hideBottomFields.value]]), vue.createVNode(Popup, {
  3826. "show": showAreaPopup.value,
  3827. "onUpdate:show": ($event) => showAreaPopup.value = $event,
  3828. "round": true,
  3829. "teleport": "body",
  3830. "position": "bottom",
  3831. "lazyRender": false
  3832. }, {
  3833. default: () => [vue.createVNode(Area, {
  3834. "ref": areaRef,
  3835. "value": data.areaCode,
  3836. "loading": !areaListLoaded.value,
  3837. "areaList": props.areaList,
  3838. "columnsPlaceholder": props.areaColumnsPlaceholder,
  3839. "onConfirm": onAreaConfirm,
  3840. "onCancel": () => {
  3841. showAreaPopup.value = false;
  3842. }
  3843. }, null)]
  3844. })];
  3845. }
  3846. });
  3847. };
  3848. }
  3849. });
  3850. const AddressEdit = withInstall(stdin_default$1i);
  3851. const [name$1a, bem$16] = createNamespace("radio-group");
  3852. const radioGroupProps = {
  3853. disabled: Boolean,
  3854. iconSize: numericProp,
  3855. direction: String,
  3856. modelValue: unknownProp,
  3857. checkedColor: String
  3858. };
  3859. const RADIO_KEY = Symbol(name$1a);
  3860. var stdin_default$1h = vue.defineComponent({
  3861. name: name$1a,
  3862. props: radioGroupProps,
  3863. emits: ["change", "update:modelValue"],
  3864. setup(props, {
  3865. emit,
  3866. slots
  3867. }) {
  3868. const {
  3869. linkChildren
  3870. } = use.useChildren(RADIO_KEY);
  3871. const updateValue = (value) => emit("update:modelValue", value);
  3872. vue.watch(() => props.modelValue, (value) => emit("change", value));
  3873. linkChildren({
  3874. props,
  3875. updateValue
  3876. });
  3877. use.useCustomFieldValue(() => props.modelValue);
  3878. return () => {
  3879. var _a;
  3880. return vue.createVNode("div", {
  3881. "class": bem$16([props.direction]),
  3882. "role": "radiogroup"
  3883. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
  3884. };
  3885. }
  3886. });
  3887. const RadioGroup = withInstall(stdin_default$1h);
  3888. const [name$19, bem$15] = createNamespace("tag");
  3889. const tagProps = {
  3890. size: String,
  3891. mark: Boolean,
  3892. show: truthProp,
  3893. type: makeStringProp("default"),
  3894. color: String,
  3895. plain: Boolean,
  3896. round: Boolean,
  3897. textColor: String,
  3898. closeable: Boolean
  3899. };
  3900. var stdin_default$1g = vue.defineComponent({
  3901. name: name$19,
  3902. props: tagProps,
  3903. emits: ["close"],
  3904. setup(props, {
  3905. slots,
  3906. emit
  3907. }) {
  3908. const onClose = (event) => {
  3909. event.stopPropagation();
  3910. emit("close", event);
  3911. };
  3912. const getStyle = () => {
  3913. if (props.plain) {
  3914. return {
  3915. color: props.textColor || props.color,
  3916. borderColor: props.color
  3917. };
  3918. }
  3919. return {
  3920. color: props.textColor,
  3921. background: props.color
  3922. };
  3923. };
  3924. const renderTag = () => {
  3925. var _a;
  3926. const {
  3927. type,
  3928. mark,
  3929. plain,
  3930. round,
  3931. size,
  3932. closeable
  3933. } = props;
  3934. const classes = {
  3935. mark,
  3936. plain,
  3937. round
  3938. };
  3939. if (size) {
  3940. classes[size] = size;
  3941. }
  3942. const CloseIcon = closeable && vue.createVNode(Icon, {
  3943. "name": "cross",
  3944. "class": [bem$15("close"), HAPTICS_FEEDBACK],
  3945. "onClick": onClose
  3946. }, null);
  3947. return vue.createVNode("span", {
  3948. "style": getStyle(),
  3949. "class": bem$15([classes, type])
  3950. }, [(_a = slots.default) == null ? void 0 : _a.call(slots), CloseIcon]);
  3951. };
  3952. return () => vue.createVNode(vue.Transition, {
  3953. "name": props.closeable ? "van-fade" : void 0
  3954. }, {
  3955. default: () => [props.show ? renderTag() : null]
  3956. });
  3957. }
  3958. });
  3959. const Tag = withInstall(stdin_default$1g);
  3960. const checkerProps = {
  3961. name: unknownProp,
  3962. shape: makeStringProp("round"),
  3963. disabled: Boolean,
  3964. iconSize: numericProp,
  3965. modelValue: unknownProp,
  3966. checkedColor: String,
  3967. labelPosition: String,
  3968. labelDisabled: Boolean
  3969. };
  3970. var stdin_default$1f = vue.defineComponent({
  3971. props: extend({}, checkerProps, {
  3972. bem: makeRequiredProp(Function),
  3973. role: String,
  3974. parent: Object,
  3975. checked: Boolean,
  3976. bindGroup: truthProp
  3977. }),
  3978. emits: ["click", "toggle"],
  3979. setup(props, {
  3980. emit,
  3981. slots
  3982. }) {
  3983. const iconRef = vue.ref();
  3984. const getParentProp = (name2) => {
  3985. if (props.parent && props.bindGroup) {
  3986. return props.parent.props[name2];
  3987. }
  3988. };
  3989. const disabled = vue.computed(() => getParentProp("disabled") || props.disabled);
  3990. const direction = vue.computed(() => getParentProp("direction"));
  3991. const iconStyle = vue.computed(() => {
  3992. const checkedColor = props.checkedColor || getParentProp("checkedColor");
  3993. if (checkedColor && props.checked && !disabled.value) {
  3994. return {
  3995. borderColor: checkedColor,
  3996. backgroundColor: checkedColor
  3997. };
  3998. }
  3999. });
  4000. const onClick = (event) => {
  4001. const {
  4002. target
  4003. } = event;
  4004. const icon = iconRef.value;
  4005. const iconClicked = icon === target || (icon == null ? void 0 : icon.contains(target));
  4006. if (!disabled.value && (iconClicked || !props.labelDisabled)) {
  4007. emit("toggle");
  4008. }
  4009. emit("click", event);
  4010. };
  4011. const renderIcon = () => {
  4012. const {
  4013. bem: bem2,
  4014. shape,
  4015. checked
  4016. } = props;
  4017. const iconSize = props.iconSize || getParentProp("iconSize");
  4018. return vue.createVNode("div", {
  4019. "ref": iconRef,
  4020. "class": bem2("icon", [shape, {
  4021. disabled: disabled.value,
  4022. checked
  4023. }]),
  4024. "style": {
  4025. fontSize: addUnit(iconSize)
  4026. }
  4027. }, [slots.icon ? slots.icon({
  4028. checked,
  4029. disabled: disabled.value
  4030. }) : vue.createVNode(Icon, {
  4031. "name": "success",
  4032. "style": iconStyle.value
  4033. }, null)]);
  4034. };
  4035. const renderLabel = () => {
  4036. if (slots.default) {
  4037. return vue.createVNode("span", {
  4038. "class": props.bem("label", [props.labelPosition, {
  4039. disabled: disabled.value
  4040. }])
  4041. }, [slots.default()]);
  4042. }
  4043. };
  4044. return () => {
  4045. const nodes = props.labelPosition === "left" ? [renderLabel(), renderIcon()] : [renderIcon(), renderLabel()];
  4046. return vue.createVNode("div", {
  4047. "role": props.role,
  4048. "class": props.bem([{
  4049. disabled: disabled.value,
  4050. "label-disabled": props.labelDisabled
  4051. }, direction.value]),
  4052. "tabindex": disabled.value ? void 0 : 0,
  4053. "aria-checked": props.checked,
  4054. "onClick": onClick
  4055. }, [nodes]);
  4056. };
  4057. }
  4058. });
  4059. const [name$18, bem$14] = createNamespace("radio");
  4060. var stdin_default$1e = vue.defineComponent({
  4061. name: name$18,
  4062. props: checkerProps,
  4063. emits: ["update:modelValue"],
  4064. setup(props, {
  4065. emit,
  4066. slots
  4067. }) {
  4068. const {
  4069. parent
  4070. } = use.useParent(RADIO_KEY);
  4071. const checked = () => {
  4072. const value = parent ? parent.props.modelValue : props.modelValue;
  4073. return value === props.name;
  4074. };
  4075. const toggle = () => {
  4076. if (parent) {
  4077. parent.updateValue(props.name);
  4078. } else {
  4079. emit("update:modelValue", props.name);
  4080. }
  4081. };
  4082. return () => vue.createVNode(stdin_default$1f, vue.mergeProps({
  4083. "bem": bem$14,
  4084. "role": "radio",
  4085. "parent": parent,
  4086. "checked": checked(),
  4087. "onToggle": toggle
  4088. }, props), pick(slots, ["default", "icon"]));
  4089. }
  4090. });
  4091. const Radio = withInstall(stdin_default$1e);
  4092. const [name$17, bem$13] = createNamespace("address-item");
  4093. var stdin_default$1d = vue.defineComponent({
  4094. name: name$17,
  4095. props: {
  4096. address: makeRequiredProp(Object),
  4097. disabled: Boolean,
  4098. switchable: Boolean,
  4099. defaultTagText: String
  4100. },
  4101. emits: ["edit", "click", "select"],
  4102. setup(props, {
  4103. slots,
  4104. emit
  4105. }) {
  4106. const onClick = () => {
  4107. if (props.switchable) {
  4108. emit("select");
  4109. }
  4110. emit("click");
  4111. };
  4112. const renderRightIcon = () => vue.createVNode(Icon, {
  4113. "name": "edit",
  4114. "class": bem$13("edit"),
  4115. "onClick": (event) => {
  4116. event.stopPropagation();
  4117. emit("edit");
  4118. emit("click");
  4119. }
  4120. }, null);
  4121. const renderTag = () => {
  4122. if (slots.tag) {
  4123. return slots.tag(props.address);
  4124. }
  4125. if (props.address.isDefault && props.defaultTagText) {
  4126. return vue.createVNode(Tag, {
  4127. "type": "danger",
  4128. "round": true,
  4129. "class": bem$13("tag")
  4130. }, {
  4131. default: () => [props.defaultTagText]
  4132. });
  4133. }
  4134. };
  4135. const renderContent = () => {
  4136. const {
  4137. address,
  4138. disabled,
  4139. switchable
  4140. } = props;
  4141. const Info = [vue.createVNode("div", {
  4142. "class": bem$13("name")
  4143. }, [`${address.name} ${address.tel}`, renderTag()]), vue.createVNode("div", {
  4144. "class": bem$13("address")
  4145. }, [address.address])];
  4146. if (switchable && !disabled) {
  4147. return vue.createVNode(Radio, {
  4148. "name": address.id,
  4149. "iconSize": 18
  4150. }, {
  4151. default: () => [Info]
  4152. });
  4153. }
  4154. return Info;
  4155. };
  4156. return () => {
  4157. var _a;
  4158. const {
  4159. disabled
  4160. } = props;
  4161. return vue.createVNode("div", {
  4162. "class": bem$13({
  4163. disabled
  4164. }),
  4165. "onClick": onClick
  4166. }, [vue.createVNode(Cell, {
  4167. "border": false,
  4168. "valueClass": bem$13("value")
  4169. }, {
  4170. value: renderContent,
  4171. "right-icon": renderRightIcon
  4172. }), (_a = slots.bottom) == null ? void 0 : _a.call(slots, extend({}, props.address, {
  4173. disabled
  4174. }))]);
  4175. };
  4176. }
  4177. });
  4178. const [name$16, bem$12, t$g] = createNamespace("address-list");
  4179. const addressListProps = {
  4180. list: makeArrayProp(),
  4181. modelValue: numericProp,
  4182. switchable: truthProp,
  4183. disabledText: String,
  4184. disabledList: makeArrayProp(),
  4185. addButtonText: String,
  4186. defaultTagText: String
  4187. };
  4188. var stdin_default$1c = vue.defineComponent({
  4189. name: name$16,
  4190. props: addressListProps,
  4191. emits: ["add", "edit", "select", "click-item", "edit-disabled", "select-disabled", "update:modelValue"],
  4192. setup(props, {
  4193. slots,
  4194. emit
  4195. }) {
  4196. const renderItem = (item, index, disabled) => {
  4197. const onEdit = () => emit(disabled ? "edit-disabled" : "edit", item, index);
  4198. const onClick = () => emit("click-item", item, index);
  4199. const onSelect = () => {
  4200. emit(disabled ? "select-disabled" : "select", item, index);
  4201. if (!disabled) {
  4202. emit("update:modelValue", item.id);
  4203. }
  4204. };
  4205. return vue.createVNode(stdin_default$1d, {
  4206. "key": item.id,
  4207. "address": item,
  4208. "disabled": disabled,
  4209. "switchable": props.switchable,
  4210. "defaultTagText": props.defaultTagText,
  4211. "onEdit": onEdit,
  4212. "onClick": onClick,
  4213. "onSelect": onSelect
  4214. }, {
  4215. bottom: slots["item-bottom"],
  4216. tag: slots.tag
  4217. });
  4218. };
  4219. const renderList = (list, disabled) => {
  4220. if (list) {
  4221. return list.map((item, index) => renderItem(item, index, disabled));
  4222. }
  4223. };
  4224. const renderBottom = () => vue.createVNode("div", {
  4225. "class": [bem$12("bottom"), "van-safe-area-bottom"]
  4226. }, [vue.createVNode(Button, {
  4227. "round": true,
  4228. "block": true,
  4229. "type": "danger",
  4230. "text": props.addButtonText || t$g("add"),
  4231. "class": bem$12("add"),
  4232. "onClick": () => emit("add")
  4233. }, null)]);
  4234. return () => {
  4235. var _a, _b;
  4236. const List2 = renderList(props.list);
  4237. const DisabledList = renderList(props.disabledList, true);
  4238. const DisabledText = props.disabledText && vue.createVNode("div", {
  4239. "class": bem$12("disabled-text")
  4240. }, [props.disabledText]);
  4241. return vue.createVNode("div", {
  4242. "class": bem$12()
  4243. }, [(_a = slots.top) == null ? void 0 : _a.call(slots), vue.createVNode(RadioGroup, {
  4244. "modelValue": props.modelValue
  4245. }, {
  4246. default: () => [List2]
  4247. }), DisabledText, DisabledList, (_b = slots.default) == null ? void 0 : _b.call(slots), renderBottom()]);
  4248. };
  4249. }
  4250. });
  4251. const AddressList = withInstall(stdin_default$1c);
  4252. const [name$15, bem$11, t$f] = createNamespace("calendar");
  4253. const formatMonthTitle = (date) => t$f("monthTitle", date.getFullYear(), date.getMonth() + 1);
  4254. function compareMonth(date1, date2) {
  4255. const year1 = date1.getFullYear();
  4256. const year2 = date2.getFullYear();
  4257. if (year1 === year2) {
  4258. const month1 = date1.getMonth();
  4259. const month2 = date2.getMonth();
  4260. return month1 === month2 ? 0 : month1 > month2 ? 1 : -1;
  4261. }
  4262. return year1 > year2 ? 1 : -1;
  4263. }
  4264. function compareDay(day1, day2) {
  4265. const compareMonthResult = compareMonth(day1, day2);
  4266. if (compareMonthResult === 0) {
  4267. const date1 = day1.getDate();
  4268. const date2 = day2.getDate();
  4269. return date1 === date2 ? 0 : date1 > date2 ? 1 : -1;
  4270. }
  4271. return compareMonthResult;
  4272. }
  4273. const cloneDate = (date) => new Date(date);
  4274. const cloneDates = (dates) => Array.isArray(dates) ? dates.map(cloneDate) : cloneDate(dates);
  4275. function getDayByOffset(date, offset) {
  4276. const cloned = cloneDate(date);
  4277. cloned.setDate(cloned.getDate() + offset);
  4278. return cloned;
  4279. }
  4280. const getPrevDay = (date) => getDayByOffset(date, -1);
  4281. const getNextDay = (date) => getDayByOffset(date, 1);
  4282. const getToday = () => {
  4283. const today = new Date();
  4284. today.setHours(0, 0, 0, 0);
  4285. return today;
  4286. };
  4287. function calcDateNum(date) {
  4288. const day1 = date[0].getTime();
  4289. const day2 = date[1].getTime();
  4290. return (day2 - day1) / (1e3 * 60 * 60 * 24) + 1;
  4291. }
  4292. function useRefs() {
  4293. const refs = vue.ref([]);
  4294. const cache = [];
  4295. vue.onBeforeUpdate(() => {
  4296. refs.value = [];
  4297. });
  4298. const setRefs = (index) => {
  4299. if (!cache[index]) {
  4300. cache[index] = (el) => {
  4301. refs.value[index] = el;
  4302. };
  4303. }
  4304. return cache[index];
  4305. };
  4306. return [refs, setRefs];
  4307. }
  4308. const sharedProps = extend({}, pickerSharedProps, {
  4309. filter: Function,
  4310. columnsOrder: Array,
  4311. formatter: {
  4312. type: Function,
  4313. default: (type, value) => value
  4314. }
  4315. });
  4316. const pickerInheritKeys = Object.keys(pickerSharedProps);
  4317. function times(n, iteratee) {
  4318. if (n < 0) {
  4319. return [];
  4320. }
  4321. const result = Array(n);
  4322. let index = -1;
  4323. while (++index < n) {
  4324. result[index] = iteratee(index);
  4325. }
  4326. return result;
  4327. }
  4328. function getTrueValue(value) {
  4329. if (!value) {
  4330. return 0;
  4331. }
  4332. while (Number.isNaN(parseInt(value, 10))) {
  4333. if (value.length > 1) {
  4334. value = value.slice(1);
  4335. } else {
  4336. return 0;
  4337. }
  4338. }
  4339. return parseInt(value, 10);
  4340. }
  4341. const getMonthEndDay = (year, month) => 32 - new Date(year, month - 1, 32).getDate();
  4342. const proxyPickerMethods = (picker, callback) => {
  4343. const methods = [
  4344. "setValues",
  4345. "setIndexes",
  4346. "setColumnIndex",
  4347. "setColumnValue"
  4348. ];
  4349. return new Proxy(picker, {
  4350. get: (target, prop) => {
  4351. if (methods.includes(prop)) {
  4352. return (...args) => {
  4353. target[prop](...args);
  4354. callback();
  4355. };
  4356. }
  4357. return target[prop];
  4358. }
  4359. });
  4360. };
  4361. const [name$14] = createNamespace("calendar-day");
  4362. var stdin_default$1b = vue.defineComponent({
  4363. name: name$14,
  4364. props: {
  4365. item: makeRequiredProp(Object),
  4366. color: String,
  4367. index: Number,
  4368. offset: makeNumberProp(0),
  4369. rowHeight: String
  4370. },
  4371. emits: ["click"],
  4372. setup(props, {
  4373. emit,
  4374. slots
  4375. }) {
  4376. const style = vue.computed(() => {
  4377. var _a;
  4378. const {
  4379. item,
  4380. index,
  4381. color,
  4382. offset,
  4383. rowHeight
  4384. } = props;
  4385. const style2 = {
  4386. height: rowHeight
  4387. };
  4388. if (item.type === "placeholder") {
  4389. style2.width = "100%";
  4390. return style2;
  4391. }
  4392. if (index === 0) {
  4393. style2.marginLeft = `${100 * offset / 7}%`;
  4394. }
  4395. if (color) {
  4396. switch (item.type) {
  4397. case "end":
  4398. case "start":
  4399. case "start-end":
  4400. case "multiple-middle":
  4401. case "multiple-selected":
  4402. style2.background = color;
  4403. break;
  4404. case "middle":
  4405. style2.color = color;
  4406. break;
  4407. }
  4408. }
  4409. if (offset + (((_a = item.date) == null ? void 0 : _a.getDate()) || 1) > 28) {
  4410. style2.marginBottom = 0;
  4411. }
  4412. return style2;
  4413. });
  4414. const onClick = () => {
  4415. if (props.item.type !== "disabled") {
  4416. emit("click", props.item);
  4417. }
  4418. };
  4419. const renderTopInfo = () => {
  4420. const {
  4421. topInfo
  4422. } = props.item;
  4423. if (topInfo || slots["top-info"]) {
  4424. return vue.createVNode("div", {
  4425. "class": bem$11("top-info")
  4426. }, [slots["top-info"] ? slots["top-info"](props.item) : topInfo]);
  4427. }
  4428. };
  4429. const renderBottomInfo = () => {
  4430. const {
  4431. bottomInfo
  4432. } = props.item;
  4433. if (bottomInfo || slots["bottom-info"]) {
  4434. return vue.createVNode("div", {
  4435. "class": bem$11("bottom-info")
  4436. }, [slots["bottom-info"] ? slots["bottom-info"](props.item) : bottomInfo]);
  4437. }
  4438. };
  4439. const renderContent = () => {
  4440. const {
  4441. item,
  4442. color,
  4443. rowHeight
  4444. } = props;
  4445. const {
  4446. type,
  4447. text
  4448. } = item;
  4449. const Nodes = [renderTopInfo(), text, renderBottomInfo()];
  4450. if (type === "selected") {
  4451. return vue.createVNode("div", {
  4452. "class": bem$11("selected-day"),
  4453. "style": {
  4454. width: rowHeight,
  4455. height: rowHeight,
  4456. background: color
  4457. }
  4458. }, [Nodes]);
  4459. }
  4460. return Nodes;
  4461. };
  4462. return () => {
  4463. const {
  4464. type,
  4465. className
  4466. } = props.item;
  4467. if (type === "placeholder") {
  4468. return vue.createVNode("div", {
  4469. "class": bem$11("day"),
  4470. "style": style.value
  4471. }, null);
  4472. }
  4473. return vue.createVNode("div", {
  4474. "role": "gridcell",
  4475. "style": style.value,
  4476. "class": [bem$11("day", type), className],
  4477. "tabindex": type === "disabled" ? void 0 : -1,
  4478. "onClick": onClick
  4479. }, [renderContent()]);
  4480. };
  4481. }
  4482. });
  4483. const [name$13] = createNamespace("calendar-month");
  4484. const calendarMonthProps = {
  4485. date: makeRequiredProp(Date),
  4486. type: String,
  4487. color: String,
  4488. minDate: makeRequiredProp(Date),
  4489. maxDate: makeRequiredProp(Date),
  4490. showMark: Boolean,
  4491. rowHeight: numericProp,
  4492. formatter: Function,
  4493. lazyRender: Boolean,
  4494. currentDate: [Date, Array],
  4495. allowSameDay: Boolean,
  4496. showSubtitle: Boolean,
  4497. showMonthTitle: Boolean,
  4498. firstDayOfWeek: Number
  4499. };
  4500. var stdin_default$1a = vue.defineComponent({
  4501. name: name$13,
  4502. props: calendarMonthProps,
  4503. emits: ["click", "update-height"],
  4504. setup(props, {
  4505. emit,
  4506. slots
  4507. }) {
  4508. const [visible, setVisible] = use.useToggle();
  4509. const daysRef = vue.ref();
  4510. const monthRef = vue.ref();
  4511. const height = useHeight(monthRef);
  4512. const title = vue.computed(() => formatMonthTitle(props.date));
  4513. const rowHeight = vue.computed(() => addUnit(props.rowHeight));
  4514. const offset = vue.computed(() => {
  4515. const realDay = props.date.getDay();
  4516. if (props.firstDayOfWeek) {
  4517. return (realDay + 7 - props.firstDayOfWeek) % 7;
  4518. }
  4519. return realDay;
  4520. });
  4521. const totalDay = vue.computed(() => getMonthEndDay(props.date.getFullYear(), props.date.getMonth() + 1));
  4522. const shouldRender = vue.computed(() => visible.value || !props.lazyRender);
  4523. const getTitle = () => title.value;
  4524. const getMultipleDayType = (day) => {
  4525. const isSelected = (date) => props.currentDate.some((item) => compareDay(item, date) === 0);
  4526. if (isSelected(day)) {
  4527. const prevDay = getPrevDay(day);
  4528. const nextDay = getNextDay(day);
  4529. const prevSelected = isSelected(prevDay);
  4530. const nextSelected = isSelected(nextDay);
  4531. if (prevSelected && nextSelected) {
  4532. return "multiple-middle";
  4533. }
  4534. if (prevSelected) {
  4535. return "end";
  4536. }
  4537. if (nextSelected) {
  4538. return "start";
  4539. }
  4540. return "multiple-selected";
  4541. }
  4542. return "";
  4543. };
  4544. const getRangeDayType = (day) => {
  4545. const [startDay, endDay] = props.currentDate;
  4546. if (!startDay) {
  4547. return "";
  4548. }
  4549. const compareToStart = compareDay(day, startDay);
  4550. if (!endDay) {
  4551. return compareToStart === 0 ? "start" : "";
  4552. }
  4553. const compareToEnd = compareDay(day, endDay);
  4554. if (props.allowSameDay && compareToStart === 0 && compareToEnd === 0) {
  4555. return "start-end";
  4556. }
  4557. if (compareToStart === 0) {
  4558. return "start";
  4559. }
  4560. if (compareToEnd === 0) {
  4561. return "end";
  4562. }
  4563. if (compareToStart > 0 && compareToEnd < 0) {
  4564. return "middle";
  4565. }
  4566. return "";
  4567. };
  4568. const getDayType = (day) => {
  4569. const {
  4570. type,
  4571. minDate,
  4572. maxDate,
  4573. currentDate
  4574. } = props;
  4575. if (compareDay(day, minDate) < 0 || compareDay(day, maxDate) > 0) {
  4576. return "disabled";
  4577. }
  4578. if (currentDate === null) {
  4579. return "";
  4580. }
  4581. if (Array.isArray(currentDate)) {
  4582. if (type === "multiple") {
  4583. return getMultipleDayType(day);
  4584. }
  4585. if (type === "range") {
  4586. return getRangeDayType(day);
  4587. }
  4588. } else if (type === "single") {
  4589. return compareDay(day, currentDate) === 0 ? "selected" : "";
  4590. }
  4591. return "";
  4592. };
  4593. const getBottomInfo = (dayType) => {
  4594. if (props.type === "range") {
  4595. if (dayType === "start" || dayType === "end") {
  4596. return t$f(dayType);
  4597. }
  4598. if (dayType === "start-end") {
  4599. return `${t$f("start")}/${t$f("end")}`;
  4600. }
  4601. }
  4602. };
  4603. const renderTitle = () => {
  4604. if (props.showMonthTitle) {
  4605. return vue.createVNode("div", {
  4606. "class": bem$11("month-title")
  4607. }, [title.value]);
  4608. }
  4609. };
  4610. const renderMark = () => {
  4611. if (props.showMark && shouldRender.value) {
  4612. return vue.createVNode("div", {
  4613. "class": bem$11("month-mark")
  4614. }, [props.date.getMonth() + 1]);
  4615. }
  4616. };
  4617. const placeholders = vue.computed(() => {
  4618. const count = Math.ceil((totalDay.value + offset.value) / 7);
  4619. return Array(count).fill({
  4620. type: "placeholder"
  4621. });
  4622. });
  4623. const days = vue.computed(() => {
  4624. const days2 = [];
  4625. const year = props.date.getFullYear();
  4626. const month = props.date.getMonth();
  4627. for (let day = 1; day <= totalDay.value; day++) {
  4628. const date = new Date(year, month, day);
  4629. const type = getDayType(date);
  4630. let config = {
  4631. date,
  4632. type,
  4633. text: day,
  4634. bottomInfo: getBottomInfo(type)
  4635. };
  4636. if (props.formatter) {
  4637. config = props.formatter(config);
  4638. }
  4639. days2.push(config);
  4640. }
  4641. return days2;
  4642. });
  4643. const disabledDays = vue.computed(() => days.value.filter((day) => day.type === "disabled"));
  4644. const scrollToDate = (body, targetDate) => {
  4645. if (daysRef.value) {
  4646. const daysRect = use.useRect(daysRef.value);
  4647. const totalRows = placeholders.value.length;
  4648. const currentRow = Math.ceil((targetDate.getDate() + offset.value) / 7);
  4649. const rowOffset = (currentRow - 1) * daysRect.height / totalRows;
  4650. setScrollTop(body, daysRect.top + rowOffset + body.scrollTop - use.useRect(body).top);
  4651. }
  4652. };
  4653. const renderDay = (item, index) => vue.createVNode(stdin_default$1b, {
  4654. "item": item,
  4655. "index": index,
  4656. "color": props.color,
  4657. "offset": offset.value,
  4658. "rowHeight": rowHeight.value,
  4659. "onClick": (item2) => emit("click", item2)
  4660. }, pick(slots, ["top-info", "bottom-info"]));
  4661. const renderDays = () => vue.createVNode("div", {
  4662. "ref": daysRef,
  4663. "role": "grid",
  4664. "class": bem$11("days")
  4665. }, [renderMark(), (shouldRender.value ? days : placeholders).value.map(renderDay)]);
  4666. useExpose({
  4667. getTitle,
  4668. getHeight: () => height.value,
  4669. setVisible,
  4670. scrollToDate,
  4671. disabledDays
  4672. });
  4673. return () => vue.createVNode("div", {
  4674. "class": bem$11("month"),
  4675. "ref": monthRef
  4676. }, [renderTitle(), renderDays()]);
  4677. }
  4678. });
  4679. const [name$12] = createNamespace("calendar-header");
  4680. var stdin_default$19 = vue.defineComponent({
  4681. name: name$12,
  4682. props: {
  4683. title: String,
  4684. subtitle: String,
  4685. showTitle: Boolean,
  4686. showSubtitle: Boolean,
  4687. firstDayOfWeek: Number
  4688. },
  4689. emits: ["click-subtitle"],
  4690. setup(props, {
  4691. slots,
  4692. emit
  4693. }) {
  4694. const renderTitle = () => {
  4695. if (props.showTitle) {
  4696. const text = props.title || t$f("title");
  4697. const title = slots.title ? slots.title() : text;
  4698. return vue.createVNode("div", {
  4699. "class": bem$11("header-title")
  4700. }, [title]);
  4701. }
  4702. };
  4703. const onClickSubtitle = (event) => emit("click-subtitle", event);
  4704. const renderSubtitle = () => {
  4705. if (props.showSubtitle) {
  4706. const title = slots.subtitle ? slots.subtitle() : props.subtitle;
  4707. return vue.createVNode("div", {
  4708. "class": bem$11("header-subtitle"),
  4709. "onClick": onClickSubtitle
  4710. }, [title]);
  4711. }
  4712. };
  4713. const renderWeekDays = () => {
  4714. const {
  4715. firstDayOfWeek
  4716. } = props;
  4717. const weekdays = t$f("weekdays");
  4718. const renderWeekDays2 = [...weekdays.slice(firstDayOfWeek, 7), ...weekdays.slice(0, firstDayOfWeek)];
  4719. return vue.createVNode("div", {
  4720. "class": bem$11("weekdays")
  4721. }, [renderWeekDays2.map((text) => vue.createVNode("span", {
  4722. "class": bem$11("weekday")
  4723. }, [text]))]);
  4724. };
  4725. return () => vue.createVNode("div", {
  4726. "class": bem$11("header")
  4727. }, [renderTitle(), renderSubtitle(), renderWeekDays()]);
  4728. }
  4729. });
  4730. const calendarProps = {
  4731. show: Boolean,
  4732. type: makeStringProp("single"),
  4733. title: String,
  4734. color: String,
  4735. round: truthProp,
  4736. readonly: Boolean,
  4737. poppable: truthProp,
  4738. maxRange: makeNumericProp(null),
  4739. position: makeStringProp("bottom"),
  4740. teleport: [String, Object],
  4741. showMark: truthProp,
  4742. showTitle: truthProp,
  4743. formatter: Function,
  4744. rowHeight: numericProp,
  4745. confirmText: String,
  4746. rangePrompt: String,
  4747. lazyRender: truthProp,
  4748. showConfirm: truthProp,
  4749. defaultDate: [Date, Array],
  4750. allowSameDay: Boolean,
  4751. showSubtitle: truthProp,
  4752. closeOnPopstate: truthProp,
  4753. showRangePrompt: truthProp,
  4754. confirmDisabledText: String,
  4755. closeOnClickOverlay: truthProp,
  4756. safeAreaInsetTop: Boolean,
  4757. safeAreaInsetBottom: truthProp,
  4758. minDate: {
  4759. type: Date,
  4760. validator: isDate,
  4761. default: getToday
  4762. },
  4763. maxDate: {
  4764. type: Date,
  4765. validator: isDate,
  4766. default: () => {
  4767. const now = getToday();
  4768. return new Date(now.getFullYear(), now.getMonth() + 6, now.getDate());
  4769. }
  4770. },
  4771. firstDayOfWeek: {
  4772. type: numericProp,
  4773. default: 0,
  4774. validator: (val) => val >= 0 && val <= 6
  4775. }
  4776. };
  4777. var stdin_default$18 = vue.defineComponent({
  4778. name: name$15,
  4779. props: calendarProps,
  4780. emits: ["select", "confirm", "unselect", "month-show", "over-range", "update:show", "click-subtitle"],
  4781. setup(props, {
  4782. emit,
  4783. slots
  4784. }) {
  4785. const limitDateRange = (date, minDate = props.minDate, maxDate = props.maxDate) => {
  4786. if (compareDay(date, minDate) === -1) {
  4787. return minDate;
  4788. }
  4789. if (compareDay(date, maxDate) === 1) {
  4790. return maxDate;
  4791. }
  4792. return date;
  4793. };
  4794. const getInitialDate = (defaultDate = props.defaultDate) => {
  4795. const {
  4796. type,
  4797. minDate,
  4798. maxDate,
  4799. allowSameDay
  4800. } = props;
  4801. if (defaultDate === null) {
  4802. return defaultDate;
  4803. }
  4804. const now = getToday();
  4805. if (type === "range") {
  4806. if (!Array.isArray(defaultDate)) {
  4807. defaultDate = [];
  4808. }
  4809. const start = limitDateRange(defaultDate[0] || now, minDate, allowSameDay ? maxDate : getPrevDay(maxDate));
  4810. const end = limitDateRange(defaultDate[1] || now, allowSameDay ? minDate : getNextDay(minDate));
  4811. return [start, end];
  4812. }
  4813. if (type === "multiple") {
  4814. if (Array.isArray(defaultDate)) {
  4815. return defaultDate.map((date) => limitDateRange(date));
  4816. }
  4817. return [limitDateRange(now)];
  4818. }
  4819. if (!defaultDate || Array.isArray(defaultDate)) {
  4820. defaultDate = now;
  4821. }
  4822. return limitDateRange(defaultDate);
  4823. };
  4824. let bodyHeight;
  4825. const bodyRef = vue.ref();
  4826. const subtitle = vue.ref("");
  4827. const currentDate = vue.ref(getInitialDate());
  4828. const [monthRefs, setMonthRefs] = useRefs();
  4829. const dayOffset = vue.computed(() => props.firstDayOfWeek ? +props.firstDayOfWeek % 7 : 0);
  4830. const months = vue.computed(() => {
  4831. const months2 = [];
  4832. const cursor = new Date(props.minDate);
  4833. cursor.setDate(1);
  4834. do {
  4835. months2.push(new Date(cursor));
  4836. cursor.setMonth(cursor.getMonth() + 1);
  4837. } while (compareMonth(cursor, props.maxDate) !== 1);
  4838. return months2;
  4839. });
  4840. const buttonDisabled = vue.computed(() => {
  4841. if (currentDate.value) {
  4842. if (props.type === "range") {
  4843. return !currentDate.value[0] || !currentDate.value[1];
  4844. }
  4845. if (props.type === "multiple") {
  4846. return !currentDate.value.length;
  4847. }
  4848. }
  4849. return !currentDate.value;
  4850. });
  4851. const getSelectedDate = () => currentDate.value;
  4852. const onScroll = () => {
  4853. const top = getScrollTop(bodyRef.value);
  4854. const bottom = top + bodyHeight;
  4855. const heights = months.value.map((item, index) => monthRefs.value[index].getHeight());
  4856. const heightSum = heights.reduce((a, b) => a + b, 0);
  4857. if (bottom > heightSum && top > 0) {
  4858. return;
  4859. }
  4860. let height = 0;
  4861. let currentMonth;
  4862. const visibleRange = [-1, -1];
  4863. for (let i = 0; i < months.value.length; i++) {
  4864. const month = monthRefs.value[i];
  4865. const visible = height <= bottom && height + heights[i] >= top;
  4866. if (visible) {
  4867. visibleRange[1] = i;
  4868. if (!currentMonth) {
  4869. currentMonth = month;
  4870. visibleRange[0] = i;
  4871. }
  4872. if (!monthRefs.value[i].showed) {
  4873. monthRefs.value[i].showed = true;
  4874. emit("month-show", {
  4875. date: month.date,
  4876. title: month.getTitle()
  4877. });
  4878. }
  4879. }
  4880. height += heights[i];
  4881. }
  4882. months.value.forEach((month, index) => {
  4883. const visible = index >= visibleRange[0] - 1 && index <= visibleRange[1] + 1;
  4884. monthRefs.value[index].setVisible(visible);
  4885. });
  4886. if (currentMonth) {
  4887. subtitle.value = currentMonth.getTitle();
  4888. }
  4889. };
  4890. const scrollToDate = (targetDate) => {
  4891. use.raf(() => {
  4892. months.value.some((month, index) => {
  4893. if (compareMonth(month, targetDate) === 0) {
  4894. if (bodyRef.value) {
  4895. monthRefs.value[index].scrollToDate(bodyRef.value, targetDate);
  4896. }
  4897. return true;
  4898. }
  4899. return false;
  4900. });
  4901. onScroll();
  4902. });
  4903. };
  4904. const scrollToCurrentDate = () => {
  4905. if (props.poppable && !props.show) {
  4906. return;
  4907. }
  4908. if (currentDate.value) {
  4909. const targetDate = props.type === "single" ? currentDate.value : currentDate.value[0];
  4910. if (isDate(targetDate)) {
  4911. scrollToDate(targetDate);
  4912. }
  4913. } else {
  4914. use.raf(onScroll);
  4915. }
  4916. };
  4917. const init = () => {
  4918. if (props.poppable && !props.show) {
  4919. return;
  4920. }
  4921. use.raf(() => {
  4922. bodyHeight = Math.floor(use.useRect(bodyRef).height);
  4923. });
  4924. scrollToCurrentDate();
  4925. };
  4926. const reset = (date = getInitialDate()) => {
  4927. currentDate.value = date;
  4928. scrollToCurrentDate();
  4929. };
  4930. const checkRange = (date) => {
  4931. const {
  4932. maxRange,
  4933. rangePrompt,
  4934. showRangePrompt
  4935. } = props;
  4936. if (maxRange && calcDateNum(date) > maxRange) {
  4937. if (showRangePrompt) {
  4938. Toast(rangePrompt || t$f("rangePrompt", maxRange));
  4939. }
  4940. emit("over-range");
  4941. return false;
  4942. }
  4943. return true;
  4944. };
  4945. const onConfirm = () => {
  4946. var _a;
  4947. return emit("confirm", (_a = currentDate.value) != null ? _a : cloneDates(currentDate.value));
  4948. };
  4949. const select = (date, complete) => {
  4950. const setCurrentDate = (date2) => {
  4951. currentDate.value = date2;
  4952. emit("select", cloneDates(date2));
  4953. };
  4954. if (complete && props.type === "range") {
  4955. const valid = checkRange(date);
  4956. if (!valid) {
  4957. setCurrentDate([date[0], getDayByOffset(date[0], +props.maxRange - 1)]);
  4958. return;
  4959. }
  4960. }
  4961. setCurrentDate(date);
  4962. if (complete && !props.showConfirm) {
  4963. onConfirm();
  4964. }
  4965. };
  4966. const getDisabledDate = (disabledDays2, startDay, date) => {
  4967. var _a;
  4968. return (_a = disabledDays2.find((day) => compareDay(startDay, day.date) === -1 && compareDay(day.date, date) === -1)) == null ? void 0 : _a.date;
  4969. };
  4970. const disabledDays = vue.computed(() => monthRefs.value.reduce((arr, ref2) => {
  4971. var _a, _b;
  4972. arr.push(...(_b = (_a = ref2.disabledDays) == null ? void 0 : _a.value) != null ? _b : []);
  4973. return arr;
  4974. }, []));
  4975. const onClickDay = (item) => {
  4976. if (props.readonly || !item.date) {
  4977. return;
  4978. }
  4979. const {
  4980. date
  4981. } = item;
  4982. const {
  4983. type
  4984. } = props;
  4985. if (type === "range") {
  4986. if (!currentDate.value) {
  4987. select([date]);
  4988. return;
  4989. }
  4990. const [startDay, endDay] = currentDate.value;
  4991. if (startDay && !endDay) {
  4992. const compareToStart = compareDay(date, startDay);
  4993. if (compareToStart === 1) {
  4994. const disabledDay = getDisabledDate(disabledDays.value, startDay, date);
  4995. if (disabledDay) {
  4996. const endDay2 = getPrevDay(disabledDay);
  4997. if (compareDay(startDay, endDay2) === -1) {
  4998. select([startDay, endDay2]);
  4999. } else {
  5000. select([date]);
  5001. }
  5002. } else {
  5003. select([startDay, date], true);
  5004. }
  5005. } else if (compareToStart === -1) {
  5006. select([date]);
  5007. } else if (props.allowSameDay) {
  5008. select([date, date], true);
  5009. }
  5010. } else {
  5011. select([date]);
  5012. }
  5013. } else if (type === "multiple") {
  5014. if (!currentDate.value) {
  5015. select([date]);
  5016. return;
  5017. }
  5018. const dates = currentDate.value;
  5019. const selectedIndex = dates.findIndex((dateItem) => compareDay(dateItem, date) === 0);
  5020. if (selectedIndex !== -1) {
  5021. const [unselectedDate] = dates.splice(selectedIndex, 1);
  5022. emit("unselect", cloneDate(unselectedDate));
  5023. } else if (props.maxRange && dates.length >= props.maxRange) {
  5024. Toast(props.rangePrompt || t$f("rangePrompt", props.maxRange));
  5025. } else {
  5026. select([...dates, date]);
  5027. }
  5028. } else {
  5029. select(date, true);
  5030. }
  5031. };
  5032. const updateShow = (value) => emit("update:show", value);
  5033. const renderMonth = (date, index) => {
  5034. const showMonthTitle = index !== 0 || !props.showSubtitle;
  5035. return vue.createVNode(stdin_default$1a, vue.mergeProps({
  5036. "ref": setMonthRefs(index),
  5037. "date": date,
  5038. "currentDate": currentDate.value,
  5039. "showMonthTitle": showMonthTitle,
  5040. "firstDayOfWeek": dayOffset.value
  5041. }, pick(props, ["type", "color", "minDate", "maxDate", "showMark", "formatter", "rowHeight", "lazyRender", "showSubtitle", "allowSameDay"]), {
  5042. "onClick": onClickDay
  5043. }), pick(slots, ["top-info", "bottom-info"]));
  5044. };
  5045. const renderFooterButton = () => {
  5046. if (slots.footer) {
  5047. return slots.footer();
  5048. }
  5049. if (props.showConfirm) {
  5050. const slot = slots["confirm-text"];
  5051. const disabled = buttonDisabled.value;
  5052. const text = disabled ? props.confirmDisabledText : props.confirmText;
  5053. return vue.createVNode(Button, {
  5054. "round": true,
  5055. "block": true,
  5056. "type": "danger",
  5057. "color": props.color,
  5058. "class": bem$11("confirm"),
  5059. "disabled": disabled,
  5060. "nativeType": "button",
  5061. "onClick": onConfirm
  5062. }, {
  5063. default: () => [slot ? slot({
  5064. disabled
  5065. }) : text || t$f("confirm")]
  5066. });
  5067. }
  5068. };
  5069. const renderFooter = () => vue.createVNode("div", {
  5070. "class": [bem$11("footer"), {
  5071. "van-safe-area-bottom": props.safeAreaInsetBottom
  5072. }]
  5073. }, [renderFooterButton()]);
  5074. const renderCalendar = () => vue.createVNode("div", {
  5075. "class": bem$11()
  5076. }, [vue.createVNode(stdin_default$19, {
  5077. "title": props.title,
  5078. "subtitle": subtitle.value,
  5079. "showTitle": props.showTitle,
  5080. "showSubtitle": props.showSubtitle,
  5081. "firstDayOfWeek": dayOffset.value,
  5082. "onClick-subtitle": (event) => emit("click-subtitle", event)
  5083. }, pick(slots, ["title", "subtitle"])), vue.createVNode("div", {
  5084. "ref": bodyRef,
  5085. "class": bem$11("body"),
  5086. "onScroll": onScroll
  5087. }, [months.value.map(renderMonth)]), renderFooter()]);
  5088. vue.watch(() => props.show, init);
  5089. vue.watch(() => [props.type, props.minDate, props.maxDate], () => reset(getInitialDate(currentDate.value)));
  5090. vue.watch(() => props.defaultDate, (value = null) => {
  5091. currentDate.value = value;
  5092. scrollToCurrentDate();
  5093. });
  5094. useExpose({
  5095. reset,
  5096. scrollToDate,
  5097. getSelectedDate
  5098. });
  5099. use.onMountedOrActivated(init);
  5100. return () => {
  5101. if (props.poppable) {
  5102. return vue.createVNode(Popup, {
  5103. "show": props.show,
  5104. "class": bem$11("popup"),
  5105. "round": props.round,
  5106. "position": props.position,
  5107. "closeable": props.showTitle || props.showSubtitle,
  5108. "teleport": props.teleport,
  5109. "closeOnPopstate": props.closeOnPopstate,
  5110. "safeAreaInsetTop": props.safeAreaInsetTop,
  5111. "closeOnClickOverlay": props.closeOnClickOverlay,
  5112. "onUpdate:show": updateShow
  5113. }, {
  5114. default: renderCalendar
  5115. });
  5116. }
  5117. return renderCalendar();
  5118. };
  5119. }
  5120. });
  5121. const Calendar = withInstall(stdin_default$18);
  5122. const [name$11, bem$10] = createNamespace("image");
  5123. const imageProps = {
  5124. src: String,
  5125. alt: String,
  5126. fit: String,
  5127. position: String,
  5128. round: Boolean,
  5129. block: Boolean,
  5130. width: numericProp,
  5131. height: numericProp,
  5132. radius: numericProp,
  5133. lazyLoad: Boolean,
  5134. iconSize: numericProp,
  5135. showError: truthProp,
  5136. errorIcon: makeStringProp("photo-fail"),
  5137. iconPrefix: String,
  5138. showLoading: truthProp,
  5139. loadingIcon: makeStringProp("photo")
  5140. };
  5141. var stdin_default$17 = vue.defineComponent({
  5142. name: name$11,
  5143. props: imageProps,
  5144. emits: ["load", "error"],
  5145. setup(props, {
  5146. emit,
  5147. slots
  5148. }) {
  5149. const error = vue.ref(false);
  5150. const loading = vue.ref(true);
  5151. const imageRef = vue.ref();
  5152. const {
  5153. $Lazyload
  5154. } = vue.getCurrentInstance().proxy;
  5155. const style = vue.computed(() => {
  5156. const style2 = {
  5157. width: addUnit(props.width),
  5158. height: addUnit(props.height)
  5159. };
  5160. if (isDef(props.radius)) {
  5161. style2.overflow = "hidden";
  5162. style2.borderRadius = addUnit(props.radius);
  5163. }
  5164. return style2;
  5165. });
  5166. vue.watch(() => props.src, () => {
  5167. error.value = false;
  5168. loading.value = true;
  5169. });
  5170. const onLoad = (event) => {
  5171. loading.value = false;
  5172. emit("load", event);
  5173. };
  5174. const onError = (event) => {
  5175. error.value = true;
  5176. loading.value = false;
  5177. emit("error", event);
  5178. };
  5179. const renderIcon = (name2, className, slot) => {
  5180. if (slot) {
  5181. return slot();
  5182. }
  5183. return vue.createVNode(Icon, {
  5184. "name": name2,
  5185. "size": props.iconSize,
  5186. "class": className,
  5187. "classPrefix": props.iconPrefix
  5188. }, null);
  5189. };
  5190. const renderPlaceholder = () => {
  5191. if (loading.value && props.showLoading) {
  5192. return vue.createVNode("div", {
  5193. "class": bem$10("loading")
  5194. }, [renderIcon(props.loadingIcon, bem$10("loading-icon"), slots.loading)]);
  5195. }
  5196. if (error.value && props.showError) {
  5197. return vue.createVNode("div", {
  5198. "class": bem$10("error")
  5199. }, [renderIcon(props.errorIcon, bem$10("error-icon"), slots.error)]);
  5200. }
  5201. };
  5202. const renderImage = () => {
  5203. if (error.value || !props.src) {
  5204. return;
  5205. }
  5206. const attrs = {
  5207. alt: props.alt,
  5208. class: bem$10("img"),
  5209. style: {
  5210. objectFit: props.fit,
  5211. objectPosition: props.position
  5212. }
  5213. };
  5214. if (props.lazyLoad) {
  5215. return vue.withDirectives(vue.createVNode("img", vue.mergeProps({
  5216. "ref": imageRef
  5217. }, attrs), null), [[vue.resolveDirective("lazy"), props.src]]);
  5218. }
  5219. return vue.createVNode("img", vue.mergeProps({
  5220. "src": props.src,
  5221. "onLoad": onLoad,
  5222. "onError": onError
  5223. }, attrs), null);
  5224. };
  5225. const onLazyLoaded = ({
  5226. el
  5227. }) => {
  5228. const check = () => {
  5229. if (el === imageRef.value && loading.value) {
  5230. onLoad();
  5231. }
  5232. };
  5233. if (imageRef.value) {
  5234. check();
  5235. } else {
  5236. vue.nextTick(check);
  5237. }
  5238. };
  5239. const onLazyLoadError = ({
  5240. el
  5241. }) => {
  5242. if (el === imageRef.value && !error.value) {
  5243. onError();
  5244. }
  5245. };
  5246. if ($Lazyload && inBrowser) {
  5247. $Lazyload.$on("loaded", onLazyLoaded);
  5248. $Lazyload.$on("error", onLazyLoadError);
  5249. vue.onBeforeUnmount(() => {
  5250. $Lazyload.$off("loaded", onLazyLoaded);
  5251. $Lazyload.$off("error", onLazyLoadError);
  5252. });
  5253. }
  5254. return () => {
  5255. var _a;
  5256. return vue.createVNode("div", {
  5257. "class": bem$10({
  5258. round: props.round,
  5259. block: props.block
  5260. }),
  5261. "style": style.value
  5262. }, [renderImage(), renderPlaceholder(), (_a = slots.default) == null ? void 0 : _a.call(slots)]);
  5263. };
  5264. }
  5265. });
  5266. const Image$1 = withInstall(stdin_default$17);
  5267. const [name$10, bem$$] = createNamespace("card");
  5268. const cardProps = {
  5269. tag: String,
  5270. num: numericProp,
  5271. desc: String,
  5272. thumb: String,
  5273. title: String,
  5274. price: numericProp,
  5275. centered: Boolean,
  5276. lazyLoad: Boolean,
  5277. currency: makeStringProp("\xA5"),
  5278. thumbLink: String,
  5279. originPrice: numericProp
  5280. };
  5281. var stdin_default$16 = vue.defineComponent({
  5282. name: name$10,
  5283. props: cardProps,
  5284. emits: ["click-thumb"],
  5285. setup(props, {
  5286. slots,
  5287. emit
  5288. }) {
  5289. const renderTitle = () => {
  5290. if (slots.title) {
  5291. return slots.title();
  5292. }
  5293. if (props.title) {
  5294. return vue.createVNode("div", {
  5295. "class": [bem$$("title"), "van-multi-ellipsis--l2"]
  5296. }, [props.title]);
  5297. }
  5298. };
  5299. const renderThumbTag = () => {
  5300. if (slots.tag || props.tag) {
  5301. return vue.createVNode("div", {
  5302. "class": bem$$("tag")
  5303. }, [slots.tag ? slots.tag() : vue.createVNode(Tag, {
  5304. "mark": true,
  5305. "type": "danger"
  5306. }, {
  5307. default: () => [props.tag]
  5308. })]);
  5309. }
  5310. };
  5311. const renderThumbImage = () => {
  5312. if (slots.thumb) {
  5313. return slots.thumb();
  5314. }
  5315. return vue.createVNode(Image$1, {
  5316. "src": props.thumb,
  5317. "fit": "cover",
  5318. "width": "100%",
  5319. "height": "100%",
  5320. "lazyLoad": props.lazyLoad
  5321. }, null);
  5322. };
  5323. const renderThumb = () => {
  5324. if (slots.thumb || props.thumb) {
  5325. return vue.createVNode("a", {
  5326. "href": props.thumbLink,
  5327. "class": bem$$("thumb"),
  5328. "onClick": (event) => emit("click-thumb", event)
  5329. }, [renderThumbImage(), renderThumbTag()]);
  5330. }
  5331. };
  5332. const renderDesc = () => {
  5333. if (slots.desc) {
  5334. return slots.desc();
  5335. }
  5336. if (props.desc) {
  5337. return vue.createVNode("div", {
  5338. "class": [bem$$("desc"), "van-ellipsis"]
  5339. }, [props.desc]);
  5340. }
  5341. };
  5342. const renderPriceText = () => {
  5343. const priceArr = props.price.toString().split(".");
  5344. return vue.createVNode("div", null, [vue.createVNode("span", {
  5345. "class": bem$$("price-currency")
  5346. }, [props.currency]), vue.createVNode("span", {
  5347. "class": bem$$("price-integer")
  5348. }, [priceArr[0]]), vue.createTextVNode("."), vue.createVNode("span", {
  5349. "class": bem$$("price-decimal")
  5350. }, [priceArr[1]])]);
  5351. };
  5352. return () => {
  5353. var _a, _b, _c;
  5354. const showNum = slots.num || isDef(props.num);
  5355. const showPrice = slots.price || isDef(props.price);
  5356. const showOriginPrice = slots["origin-price"] || isDef(props.originPrice);
  5357. const showBottom = showNum || showPrice || showOriginPrice || slots.bottom;
  5358. const Price = showPrice && vue.createVNode("div", {
  5359. "class": bem$$("price")
  5360. }, [slots.price ? slots.price() : renderPriceText()]);
  5361. const OriginPrice = showOriginPrice && vue.createVNode("div", {
  5362. "class": bem$$("origin-price")
  5363. }, [slots["origin-price"] ? slots["origin-price"]() : `${props.currency} ${props.originPrice}`]);
  5364. const Num = showNum && vue.createVNode("div", {
  5365. "class": bem$$("num")
  5366. }, [slots.num ? slots.num() : `x${props.num}`]);
  5367. const Footer = slots.footer && vue.createVNode("div", {
  5368. "class": bem$$("footer")
  5369. }, [slots.footer()]);
  5370. const Bottom = showBottom && vue.createVNode("div", {
  5371. "class": bem$$("bottom")
  5372. }, [(_a = slots["price-top"]) == null ? void 0 : _a.call(slots), Price, OriginPrice, Num, (_b = slots.bottom) == null ? void 0 : _b.call(slots)]);
  5373. return vue.createVNode("div", {
  5374. "class": bem$$()
  5375. }, [vue.createVNode("div", {
  5376. "class": bem$$("header")
  5377. }, [renderThumb(), vue.createVNode("div", {
  5378. "class": bem$$("content", {
  5379. centered: props.centered
  5380. })
  5381. }, [vue.createVNode("div", null, [renderTitle(), renderDesc(), (_c = slots.tags) == null ? void 0 : _c.call(slots)]), Bottom])]), Footer]);
  5382. };
  5383. }
  5384. });
  5385. const Card = withInstall(stdin_default$16);
  5386. function scrollLeftTo(scroller, to, duration) {
  5387. let count = 0;
  5388. const from = scroller.scrollLeft;
  5389. const frames = duration === 0 ? 1 : Math.round(duration * 1e3 / 16);
  5390. function animate() {
  5391. scroller.scrollLeft += (to - from) / frames;
  5392. if (++count < frames) {
  5393. use.raf(animate);
  5394. }
  5395. }
  5396. animate();
  5397. }
  5398. function scrollTopTo(scroller, to, duration, callback) {
  5399. let current2 = getScrollTop(scroller);
  5400. const isDown = current2 < to;
  5401. const frames = duration === 0 ? 1 : Math.round(duration * 1e3 / 16);
  5402. const step = (to - current2) / frames;
  5403. function animate() {
  5404. current2 += step;
  5405. if (isDown && current2 > to || !isDown && current2 < to) {
  5406. current2 = to;
  5407. }
  5408. setScrollTop(scroller, current2);
  5409. if (isDown && current2 < to || !isDown && current2 > to) {
  5410. use.raf(animate);
  5411. } else if (callback) {
  5412. use.raf(callback);
  5413. }
  5414. }
  5415. animate();
  5416. }
  5417. function useVisibilityChange(target, onChange) {
  5418. if (!inBrowser || !window.IntersectionObserver) {
  5419. return;
  5420. }
  5421. const observer = new IntersectionObserver(
  5422. (entries) => {
  5423. onChange(entries[0].intersectionRatio > 0);
  5424. },
  5425. { root: document.body }
  5426. );
  5427. const observe = () => {
  5428. if (target.value) {
  5429. observer.observe(target.value);
  5430. }
  5431. };
  5432. const unobserve = () => {
  5433. if (target.value) {
  5434. observer.unobserve(target.value);
  5435. }
  5436. };
  5437. vue.onDeactivated(unobserve);
  5438. vue.onBeforeUnmount(unobserve);
  5439. use.onMountedOrActivated(observe);
  5440. }
  5441. const [name$$, bem$_] = createNamespace("sticky");
  5442. const stickyProps = {
  5443. zIndex: numericProp,
  5444. position: makeStringProp("top"),
  5445. container: Object,
  5446. offsetTop: makeNumericProp(0),
  5447. offsetBottom: makeNumericProp(0)
  5448. };
  5449. var stdin_default$15 = vue.defineComponent({
  5450. name: name$$,
  5451. props: stickyProps,
  5452. emits: ["scroll", "change"],
  5453. setup(props, {
  5454. emit,
  5455. slots
  5456. }) {
  5457. const root = vue.ref();
  5458. const scrollParent = use.useScrollParent(root);
  5459. const state = vue.reactive({
  5460. fixed: false,
  5461. width: 0,
  5462. height: 0,
  5463. transform: 0
  5464. });
  5465. const offset = vue.computed(() => unitToPx(props.position === "top" ? props.offsetTop : props.offsetBottom));
  5466. const rootStyle = vue.computed(() => {
  5467. const {
  5468. fixed,
  5469. height,
  5470. width
  5471. } = state;
  5472. if (fixed) {
  5473. return {
  5474. width: `${width}px`,
  5475. height: `${height}px`
  5476. };
  5477. }
  5478. });
  5479. const stickyStyle = vue.computed(() => {
  5480. if (!state.fixed) {
  5481. return;
  5482. }
  5483. const style = extend(getZIndexStyle(props.zIndex), {
  5484. width: `${state.width}px`,
  5485. height: `${state.height}px`,
  5486. [props.position]: `${offset.value}px`
  5487. });
  5488. if (state.transform) {
  5489. style.transform = `translate3d(0, ${state.transform}px, 0)`;
  5490. }
  5491. return style;
  5492. });
  5493. const emitScroll = (scrollTop) => emit("scroll", {
  5494. scrollTop,
  5495. isFixed: state.fixed
  5496. });
  5497. const onScroll = () => {
  5498. if (!root.value || isHidden(root)) {
  5499. return;
  5500. }
  5501. const {
  5502. container,
  5503. position
  5504. } = props;
  5505. const rootRect = use.useRect(root);
  5506. const scrollTop = getScrollTop(window);
  5507. state.width = rootRect.width;
  5508. state.height = rootRect.height;
  5509. if (position === "top") {
  5510. if (container) {
  5511. const containerRect = use.useRect(container);
  5512. const difference = containerRect.bottom - offset.value - state.height;
  5513. state.fixed = offset.value > rootRect.top && containerRect.bottom > 0;
  5514. state.transform = difference < 0 ? difference : 0;
  5515. } else {
  5516. state.fixed = offset.value > rootRect.top;
  5517. }
  5518. } else {
  5519. const {
  5520. clientHeight
  5521. } = document.documentElement;
  5522. if (container) {
  5523. const containerRect = use.useRect(container);
  5524. const difference = clientHeight - containerRect.top - offset.value - state.height;
  5525. state.fixed = clientHeight - offset.value < rootRect.bottom && clientHeight > containerRect.top;
  5526. state.transform = difference < 0 ? -difference : 0;
  5527. } else {
  5528. state.fixed = clientHeight - offset.value < rootRect.bottom;
  5529. }
  5530. }
  5531. emitScroll(scrollTop);
  5532. };
  5533. vue.watch(() => state.fixed, (value) => emit("change", value));
  5534. use.useEventListener("scroll", onScroll, {
  5535. target: scrollParent,
  5536. passive: true
  5537. });
  5538. useVisibilityChange(root, onScroll);
  5539. return () => {
  5540. var _a;
  5541. return vue.createVNode("div", {
  5542. "ref": root,
  5543. "style": rootStyle.value
  5544. }, [vue.createVNode("div", {
  5545. "class": bem$_({
  5546. fixed: state.fixed
  5547. }),
  5548. "style": stickyStyle.value
  5549. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)])]);
  5550. };
  5551. }
  5552. });
  5553. const Sticky = withInstall(stdin_default$15);
  5554. const [name$_, bem$Z] = createNamespace("tab");
  5555. var stdin_default$14 = vue.defineComponent({
  5556. name: name$_,
  5557. props: {
  5558. id: String,
  5559. dot: Boolean,
  5560. type: String,
  5561. color: String,
  5562. title: String,
  5563. badge: numericProp,
  5564. shrink: Boolean,
  5565. isActive: Boolean,
  5566. disabled: Boolean,
  5567. controls: String,
  5568. scrollable: Boolean,
  5569. activeColor: String,
  5570. inactiveColor: String,
  5571. showZeroBadge: truthProp
  5572. },
  5573. setup(props, {
  5574. slots
  5575. }) {
  5576. const style = vue.computed(() => {
  5577. const style2 = {};
  5578. const {
  5579. type,
  5580. color,
  5581. disabled,
  5582. isActive,
  5583. activeColor,
  5584. inactiveColor
  5585. } = props;
  5586. const isCard = type === "card";
  5587. if (color && isCard) {
  5588. style2.borderColor = color;
  5589. if (!disabled) {
  5590. if (isActive) {
  5591. style2.backgroundColor = color;
  5592. } else {
  5593. style2.color = color;
  5594. }
  5595. }
  5596. }
  5597. const titleColor = isActive ? activeColor : inactiveColor;
  5598. if (titleColor) {
  5599. style2.color = titleColor;
  5600. }
  5601. return style2;
  5602. });
  5603. const renderText = () => {
  5604. const Text2 = vue.createVNode("span", {
  5605. "class": bem$Z("text", {
  5606. ellipsis: !props.scrollable
  5607. })
  5608. }, [slots.title ? slots.title() : props.title]);
  5609. if (props.dot || isDef(props.badge) && props.badge !== "") {
  5610. return vue.createVNode(Badge, {
  5611. "dot": props.dot,
  5612. "content": props.badge,
  5613. "showZero": props.showZeroBadge
  5614. }, {
  5615. default: () => [Text2]
  5616. });
  5617. }
  5618. return Text2;
  5619. };
  5620. return () => vue.createVNode("div", {
  5621. "id": props.id,
  5622. "role": "tab",
  5623. "class": [bem$Z([props.type, {
  5624. grow: props.scrollable && !props.shrink,
  5625. shrink: props.shrink,
  5626. active: props.isActive,
  5627. disabled: props.disabled
  5628. }])],
  5629. "style": style.value,
  5630. "tabindex": props.disabled ? void 0 : props.isActive ? 0 : -1,
  5631. "aria-selected": props.isActive,
  5632. "aria-disabled": props.disabled || void 0,
  5633. "aria-controls": props.controls
  5634. }, [renderText()]);
  5635. }
  5636. });
  5637. const [name$Z, bem$Y] = createNamespace("swipe");
  5638. const swipeProps = {
  5639. loop: truthProp,
  5640. width: numericProp,
  5641. height: numericProp,
  5642. vertical: Boolean,
  5643. autoplay: makeNumericProp(0),
  5644. duration: makeNumericProp(500),
  5645. touchable: truthProp,
  5646. lazyRender: Boolean,
  5647. initialSwipe: makeNumericProp(0),
  5648. indicatorColor: String,
  5649. showIndicators: truthProp,
  5650. stopPropagation: truthProp
  5651. };
  5652. const SWIPE_KEY = Symbol(name$Z);
  5653. var stdin_default$13 = vue.defineComponent({
  5654. name: name$Z,
  5655. props: swipeProps,
  5656. emits: ["change"],
  5657. setup(props, {
  5658. emit,
  5659. slots
  5660. }) {
  5661. const root = vue.ref();
  5662. const track = vue.ref();
  5663. const state = vue.reactive({
  5664. rect: null,
  5665. width: 0,
  5666. height: 0,
  5667. offset: 0,
  5668. active: 0,
  5669. swiping: false
  5670. });
  5671. const touch = useTouch();
  5672. const {
  5673. children,
  5674. linkChildren
  5675. } = use.useChildren(SWIPE_KEY);
  5676. const count = vue.computed(() => children.length);
  5677. const size = vue.computed(() => state[props.vertical ? "height" : "width"]);
  5678. const delta = vue.computed(() => props.vertical ? touch.deltaY.value : touch.deltaX.value);
  5679. const minOffset = vue.computed(() => {
  5680. if (state.rect) {
  5681. const base = props.vertical ? state.rect.height : state.rect.width;
  5682. return base - size.value * count.value;
  5683. }
  5684. return 0;
  5685. });
  5686. const maxCount = vue.computed(() => Math.ceil(Math.abs(minOffset.value) / size.value));
  5687. const trackSize = vue.computed(() => count.value * size.value);
  5688. const activeIndicator = vue.computed(() => (state.active + count.value) % count.value);
  5689. const isCorrectDirection = vue.computed(() => {
  5690. const expect = props.vertical ? "vertical" : "horizontal";
  5691. return touch.direction.value === expect;
  5692. });
  5693. const trackStyle = vue.computed(() => {
  5694. const style = {
  5695. transitionDuration: `${state.swiping ? 0 : props.duration}ms`,
  5696. transform: `translate${props.vertical ? "Y" : "X"}(${state.offset}px)`
  5697. };
  5698. if (size.value) {
  5699. const mainAxis = props.vertical ? "height" : "width";
  5700. const crossAxis = props.vertical ? "width" : "height";
  5701. style[mainAxis] = `${trackSize.value}px`;
  5702. style[crossAxis] = props[crossAxis] ? `${props[crossAxis]}px` : "";
  5703. }
  5704. return style;
  5705. });
  5706. const getTargetActive = (pace) => {
  5707. const {
  5708. active
  5709. } = state;
  5710. if (pace) {
  5711. if (props.loop) {
  5712. return clamp(active + pace, -1, count.value);
  5713. }
  5714. return clamp(active + pace, 0, maxCount.value);
  5715. }
  5716. return active;
  5717. };
  5718. const getTargetOffset = (targetActive, offset = 0) => {
  5719. let currentPosition = targetActive * size.value;
  5720. if (!props.loop) {
  5721. currentPosition = Math.min(currentPosition, -minOffset.value);
  5722. }
  5723. let targetOffset = offset - currentPosition;
  5724. if (!props.loop) {
  5725. targetOffset = clamp(targetOffset, minOffset.value, 0);
  5726. }
  5727. return targetOffset;
  5728. };
  5729. const move = ({
  5730. pace = 0,
  5731. offset = 0,
  5732. emitChange
  5733. }) => {
  5734. if (count.value <= 1) {
  5735. return;
  5736. }
  5737. const {
  5738. active
  5739. } = state;
  5740. const targetActive = getTargetActive(pace);
  5741. const targetOffset = getTargetOffset(targetActive, offset);
  5742. if (props.loop) {
  5743. if (children[0] && targetOffset !== minOffset.value) {
  5744. const outRightBound = targetOffset < minOffset.value;
  5745. children[0].setOffset(outRightBound ? trackSize.value : 0);
  5746. }
  5747. if (children[count.value - 1] && targetOffset !== 0) {
  5748. const outLeftBound = targetOffset > 0;
  5749. children[count.value - 1].setOffset(outLeftBound ? -trackSize.value : 0);
  5750. }
  5751. }
  5752. state.active = targetActive;
  5753. state.offset = targetOffset;
  5754. if (emitChange && targetActive !== active) {
  5755. emit("change", activeIndicator.value);
  5756. }
  5757. };
  5758. const correctPosition = () => {
  5759. state.swiping = true;
  5760. if (state.active <= -1) {
  5761. move({
  5762. pace: count.value
  5763. });
  5764. } else if (state.active >= count.value) {
  5765. move({
  5766. pace: -count.value
  5767. });
  5768. }
  5769. };
  5770. const prev = () => {
  5771. correctPosition();
  5772. touch.reset();
  5773. use.doubleRaf(() => {
  5774. state.swiping = false;
  5775. move({
  5776. pace: -1,
  5777. emitChange: true
  5778. });
  5779. });
  5780. };
  5781. const next = () => {
  5782. correctPosition();
  5783. touch.reset();
  5784. use.doubleRaf(() => {
  5785. state.swiping = false;
  5786. move({
  5787. pace: 1,
  5788. emitChange: true
  5789. });
  5790. });
  5791. };
  5792. let autoplayTimer;
  5793. const stopAutoplay = () => clearTimeout(autoplayTimer);
  5794. const autoplay = () => {
  5795. stopAutoplay();
  5796. if (props.autoplay > 0 && count.value > 1) {
  5797. autoplayTimer = setTimeout(() => {
  5798. next();
  5799. autoplay();
  5800. }, +props.autoplay);
  5801. }
  5802. };
  5803. const initialize = (active = +props.initialSwipe) => {
  5804. if (!root.value) {
  5805. return;
  5806. }
  5807. const cb = () => {
  5808. var _a, _b;
  5809. if (!isHidden(root)) {
  5810. const rect = {
  5811. width: root.value.offsetWidth,
  5812. height: root.value.offsetHeight
  5813. };
  5814. state.rect = rect;
  5815. state.width = +((_a = props.width) != null ? _a : rect.width);
  5816. state.height = +((_b = props.height) != null ? _b : rect.height);
  5817. }
  5818. if (count.value) {
  5819. active = Math.min(count.value - 1, active);
  5820. }
  5821. state.active = active;
  5822. state.swiping = true;
  5823. state.offset = getTargetOffset(active);
  5824. children.forEach((swipe) => {
  5825. swipe.setOffset(0);
  5826. });
  5827. autoplay();
  5828. };
  5829. if (isHidden(root)) {
  5830. vue.nextTick().then(cb);
  5831. } else {
  5832. cb();
  5833. }
  5834. };
  5835. const resize = () => initialize(state.active);
  5836. let touchStartTime;
  5837. const onTouchStart = (event) => {
  5838. if (!props.touchable)
  5839. return;
  5840. touch.start(event);
  5841. touchStartTime = Date.now();
  5842. stopAutoplay();
  5843. correctPosition();
  5844. };
  5845. const onTouchMove = (event) => {
  5846. if (props.touchable && state.swiping) {
  5847. touch.move(event);
  5848. if (isCorrectDirection.value) {
  5849. const isEdgeTouch = !props.loop && (state.active === 0 && delta.value > 0 || state.active === count.value - 1 && delta.value < 0);
  5850. if (!isEdgeTouch) {
  5851. preventDefault(event, props.stopPropagation);
  5852. move({
  5853. offset: delta.value
  5854. });
  5855. }
  5856. }
  5857. }
  5858. };
  5859. const onTouchEnd = () => {
  5860. if (!props.touchable || !state.swiping) {
  5861. return;
  5862. }
  5863. const duration = Date.now() - touchStartTime;
  5864. const speed = delta.value / duration;
  5865. const shouldSwipe = Math.abs(speed) > 0.25 || Math.abs(delta.value) > size.value / 2;
  5866. if (shouldSwipe && isCorrectDirection.value) {
  5867. const offset = props.vertical ? touch.offsetY.value : touch.offsetX.value;
  5868. let pace = 0;
  5869. if (props.loop) {
  5870. pace = offset > 0 ? delta.value > 0 ? -1 : 1 : 0;
  5871. } else {
  5872. pace = -Math[delta.value > 0 ? "ceil" : "floor"](delta.value / size.value);
  5873. }
  5874. move({
  5875. pace,
  5876. emitChange: true
  5877. });
  5878. } else if (delta.value) {
  5879. move({
  5880. pace: 0
  5881. });
  5882. }
  5883. state.swiping = false;
  5884. autoplay();
  5885. };
  5886. const swipeTo = (index, options = {}) => {
  5887. correctPosition();
  5888. touch.reset();
  5889. use.doubleRaf(() => {
  5890. let targetIndex;
  5891. if (props.loop && index === count.value) {
  5892. targetIndex = state.active === 0 ? 0 : index;
  5893. } else {
  5894. targetIndex = index % count.value;
  5895. }
  5896. if (options.immediate) {
  5897. use.doubleRaf(() => {
  5898. state.swiping = false;
  5899. });
  5900. } else {
  5901. state.swiping = false;
  5902. }
  5903. move({
  5904. pace: targetIndex - state.active,
  5905. emitChange: true
  5906. });
  5907. });
  5908. };
  5909. const renderDot = (_, index) => {
  5910. const active = index === activeIndicator.value;
  5911. const style = active ? {
  5912. backgroundColor: props.indicatorColor
  5913. } : void 0;
  5914. return vue.createVNode("i", {
  5915. "style": style,
  5916. "class": bem$Y("indicator", {
  5917. active
  5918. })
  5919. }, null);
  5920. };
  5921. const renderIndicator = () => {
  5922. if (slots.indicator) {
  5923. return slots.indicator({
  5924. active: activeIndicator.value,
  5925. total: count.value
  5926. });
  5927. }
  5928. if (props.showIndicators && count.value > 1) {
  5929. return vue.createVNode("div", {
  5930. "class": bem$Y("indicators", {
  5931. vertical: props.vertical
  5932. })
  5933. }, [Array(count.value).fill("").map(renderDot)]);
  5934. }
  5935. };
  5936. useExpose({
  5937. prev,
  5938. next,
  5939. state,
  5940. resize,
  5941. swipeTo
  5942. });
  5943. linkChildren({
  5944. size,
  5945. props,
  5946. count,
  5947. activeIndicator
  5948. });
  5949. vue.watch(() => props.initialSwipe, (value) => initialize(+value));
  5950. vue.watch(count, () => initialize(state.active));
  5951. vue.watch(() => props.autoplay, autoplay);
  5952. vue.watch([windowWidth, windowHeight], resize);
  5953. vue.watch(use.usePageVisibility(), (visible) => {
  5954. if (visible === "visible") {
  5955. autoplay();
  5956. } else {
  5957. stopAutoplay();
  5958. }
  5959. });
  5960. vue.onMounted(initialize);
  5961. vue.onActivated(() => initialize(state.active));
  5962. onPopupReopen(() => initialize(state.active));
  5963. vue.onDeactivated(stopAutoplay);
  5964. vue.onBeforeUnmount(stopAutoplay);
  5965. use.useEventListener("touchmove", onTouchMove, {
  5966. target: track
  5967. });
  5968. return () => {
  5969. var _a;
  5970. return vue.createVNode("div", {
  5971. "ref": root,
  5972. "class": bem$Y()
  5973. }, [vue.createVNode("div", {
  5974. "ref": track,
  5975. "style": trackStyle.value,
  5976. "class": bem$Y("track", {
  5977. vertical: props.vertical
  5978. }),
  5979. "onTouchstartPassive": onTouchStart,
  5980. "onTouchend": onTouchEnd,
  5981. "onTouchcancel": onTouchEnd
  5982. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]), renderIndicator()]);
  5983. };
  5984. }
  5985. });
  5986. const Swipe = withInstall(stdin_default$13);
  5987. const [name$Y, bem$X] = createNamespace("tabs");
  5988. var stdin_default$12 = vue.defineComponent({
  5989. name: name$Y,
  5990. props: {
  5991. count: makeRequiredProp(Number),
  5992. inited: Boolean,
  5993. animated: Boolean,
  5994. duration: makeRequiredProp(numericProp),
  5995. swipeable: Boolean,
  5996. lazyRender: Boolean,
  5997. currentIndex: makeRequiredProp(Number)
  5998. },
  5999. emits: ["change"],
  6000. setup(props, {
  6001. emit,
  6002. slots
  6003. }) {
  6004. const swipeRef = vue.ref();
  6005. const onChange = (index) => emit("change", index);
  6006. const renderChildren = () => {
  6007. var _a;
  6008. const Content = (_a = slots.default) == null ? void 0 : _a.call(slots);
  6009. if (props.animated || props.swipeable) {
  6010. return vue.createVNode(Swipe, {
  6011. "ref": swipeRef,
  6012. "loop": false,
  6013. "class": bem$X("track"),
  6014. "duration": +props.duration * 1e3,
  6015. "touchable": props.swipeable,
  6016. "lazyRender": props.lazyRender,
  6017. "showIndicators": false,
  6018. "onChange": onChange
  6019. }, {
  6020. default: () => [Content]
  6021. });
  6022. }
  6023. return Content;
  6024. };
  6025. const swipeToCurrentTab = (index) => {
  6026. const swipe = swipeRef.value;
  6027. if (swipe && swipe.state.active !== index) {
  6028. swipe.swipeTo(index, {
  6029. immediate: !props.inited
  6030. });
  6031. }
  6032. };
  6033. vue.watch(() => props.currentIndex, swipeToCurrentTab);
  6034. vue.onMounted(() => {
  6035. swipeToCurrentTab(props.currentIndex);
  6036. });
  6037. useExpose({
  6038. swipeRef
  6039. });
  6040. return () => vue.createVNode("div", {
  6041. "class": bem$X("content", {
  6042. animated: props.animated || props.swipeable
  6043. })
  6044. }, [renderChildren()]);
  6045. }
  6046. });
  6047. const [name$X, bem$W] = createNamespace("tabs");
  6048. const tabsProps = {
  6049. type: makeStringProp("line"),
  6050. color: String,
  6051. border: Boolean,
  6052. sticky: Boolean,
  6053. shrink: Boolean,
  6054. active: makeNumericProp(0),
  6055. duration: makeNumericProp(0.3),
  6056. animated: Boolean,
  6057. ellipsis: truthProp,
  6058. swipeable: Boolean,
  6059. scrollspy: Boolean,
  6060. offsetTop: makeNumericProp(0),
  6061. background: String,
  6062. lazyRender: truthProp,
  6063. lineWidth: numericProp,
  6064. lineHeight: numericProp,
  6065. beforeChange: Function,
  6066. swipeThreshold: makeNumericProp(5),
  6067. titleActiveColor: String,
  6068. titleInactiveColor: String
  6069. };
  6070. const TABS_KEY = Symbol(name$X);
  6071. var stdin_default$11 = vue.defineComponent({
  6072. name: name$X,
  6073. props: tabsProps,
  6074. emits: ["click", "change", "scroll", "disabled", "rendered", "click-tab", "update:active"],
  6075. setup(props, {
  6076. emit,
  6077. slots
  6078. }) {
  6079. var _a, _b;
  6080. if (process.env.NODE_ENV !== "production") {
  6081. const props2 = (_b = (_a = vue.getCurrentInstance()) == null ? void 0 : _a.vnode) == null ? void 0 : _b.props;
  6082. if (props2 && "onClick" in props2) {
  6083. console.warn('[Vant] Tabs: "click" event is deprecated, using "click-tab" instead.');
  6084. }
  6085. if (props2 && "onDisabled" in props2) {
  6086. console.warn('[Vant] Tabs: "disabled" event is deprecated, using "click-tab" instead.');
  6087. }
  6088. }
  6089. let tabHeight;
  6090. let lockScroll;
  6091. let stickyFixed;
  6092. const root = vue.ref();
  6093. const navRef = vue.ref();
  6094. const wrapRef = vue.ref();
  6095. const contentRef = vue.ref();
  6096. const id = useId();
  6097. const scroller = use.useScrollParent(root);
  6098. const [titleRefs, setTitleRefs] = useRefs();
  6099. const {
  6100. children,
  6101. linkChildren
  6102. } = use.useChildren(TABS_KEY);
  6103. const state = vue.reactive({
  6104. inited: false,
  6105. position: "",
  6106. lineStyle: {},
  6107. currentIndex: -1
  6108. });
  6109. const scrollable = vue.computed(() => children.length > props.swipeThreshold || !props.ellipsis || props.shrink);
  6110. const navStyle = vue.computed(() => ({
  6111. borderColor: props.color,
  6112. background: props.background
  6113. }));
  6114. const getTabName = (tab, index) => {
  6115. var _a2;
  6116. return (_a2 = tab.name) != null ? _a2 : index;
  6117. };
  6118. const currentName = vue.computed(() => {
  6119. const activeTab = children[state.currentIndex];
  6120. if (activeTab) {
  6121. return getTabName(activeTab, state.currentIndex);
  6122. }
  6123. });
  6124. const offsetTopPx = vue.computed(() => unitToPx(props.offsetTop));
  6125. const scrollOffset = vue.computed(() => {
  6126. if (props.sticky) {
  6127. return offsetTopPx.value + tabHeight;
  6128. }
  6129. return 0;
  6130. });
  6131. const scrollIntoView = (immediate) => {
  6132. const nav = navRef.value;
  6133. const titles = titleRefs.value;
  6134. if (!scrollable.value || !nav || !titles || !titles[state.currentIndex]) {
  6135. return;
  6136. }
  6137. const title = titles[state.currentIndex].$el;
  6138. const to = title.offsetLeft - (nav.offsetWidth - title.offsetWidth) / 2;
  6139. scrollLeftTo(nav, to, immediate ? 0 : +props.duration);
  6140. };
  6141. const setLine = () => {
  6142. const shouldAnimate = state.inited;
  6143. vue.nextTick(() => {
  6144. const titles = titleRefs.value;
  6145. if (!titles || !titles[state.currentIndex] || props.type !== "line" || isHidden(root.value)) {
  6146. return;
  6147. }
  6148. const title = titles[state.currentIndex].$el;
  6149. const {
  6150. lineWidth,
  6151. lineHeight
  6152. } = props;
  6153. const left = title.offsetLeft + title.offsetWidth / 2;
  6154. const lineStyle = {
  6155. width: addUnit(lineWidth),
  6156. backgroundColor: props.color,
  6157. transform: `translateX(${left}px) translateX(-50%)`
  6158. };
  6159. if (shouldAnimate) {
  6160. lineStyle.transitionDuration = `${props.duration}s`;
  6161. }
  6162. if (isDef(lineHeight)) {
  6163. const height = addUnit(lineHeight);
  6164. lineStyle.height = height;
  6165. lineStyle.borderRadius = height;
  6166. }
  6167. state.lineStyle = lineStyle;
  6168. });
  6169. };
  6170. const findAvailableTab = (index) => {
  6171. const diff = index < state.currentIndex ? -1 : 1;
  6172. while (index >= 0 && index < children.length) {
  6173. if (!children[index].disabled) {
  6174. return index;
  6175. }
  6176. index += diff;
  6177. }
  6178. };
  6179. const setCurrentIndex = (currentIndex, skipScrollIntoView) => {
  6180. const newIndex = findAvailableTab(currentIndex);
  6181. if (!isDef(newIndex)) {
  6182. return;
  6183. }
  6184. const newTab = children[newIndex];
  6185. const newName = getTabName(newTab, newIndex);
  6186. const shouldEmitChange = state.currentIndex !== null;
  6187. if (state.currentIndex !== newIndex) {
  6188. state.currentIndex = newIndex;
  6189. if (!skipScrollIntoView) {
  6190. scrollIntoView();
  6191. }
  6192. setLine();
  6193. }
  6194. if (newName !== props.active) {
  6195. emit("update:active", newName);
  6196. if (shouldEmitChange) {
  6197. emit("change", newName, newTab.title);
  6198. }
  6199. }
  6200. if (stickyFixed && !props.scrollspy) {
  6201. setRootScrollTop(Math.ceil(getElementTop(root.value) - offsetTopPx.value));
  6202. }
  6203. };
  6204. const setCurrentIndexByName = (name2, skipScrollIntoView) => {
  6205. const matched = children.find((tab, index2) => getTabName(tab, index2) === name2);
  6206. const index = matched ? children.indexOf(matched) : 0;
  6207. setCurrentIndex(index, skipScrollIntoView);
  6208. };
  6209. const scrollToCurrentContent = (immediate = false) => {
  6210. if (props.scrollspy) {
  6211. const target = children[state.currentIndex].$el;
  6212. if (target && scroller.value) {
  6213. const to = getElementTop(target, scroller.value) - scrollOffset.value;
  6214. lockScroll = true;
  6215. scrollTopTo(scroller.value, to, immediate ? 0 : +props.duration, () => {
  6216. lockScroll = false;
  6217. });
  6218. }
  6219. }
  6220. };
  6221. const onClickTab = (item, index, event) => {
  6222. const {
  6223. title,
  6224. disabled
  6225. } = children[index];
  6226. const name2 = getTabName(children[index], index);
  6227. if (disabled) {
  6228. emit("disabled", name2, title);
  6229. } else {
  6230. callInterceptor(props.beforeChange, {
  6231. args: [name2],
  6232. done: () => {
  6233. setCurrentIndex(index);
  6234. scrollToCurrentContent();
  6235. }
  6236. });
  6237. emit("click", name2, title);
  6238. route(item);
  6239. }
  6240. emit("click-tab", {
  6241. name: name2,
  6242. title,
  6243. event,
  6244. disabled
  6245. });
  6246. };
  6247. const onStickyScroll = (params) => {
  6248. stickyFixed = params.isFixed;
  6249. emit("scroll", params);
  6250. };
  6251. const scrollTo = (name2) => {
  6252. vue.nextTick(() => {
  6253. setCurrentIndexByName(name2);
  6254. scrollToCurrentContent(true);
  6255. });
  6256. };
  6257. const getCurrentIndexOnScroll = () => {
  6258. for (let index = 0; index < children.length; index++) {
  6259. const {
  6260. top
  6261. } = use.useRect(children[index].$el);
  6262. if (top > scrollOffset.value) {
  6263. return index === 0 ? 0 : index - 1;
  6264. }
  6265. }
  6266. return children.length - 1;
  6267. };
  6268. const onScroll = () => {
  6269. if (props.scrollspy && !lockScroll) {
  6270. const index = getCurrentIndexOnScroll();
  6271. setCurrentIndex(index);
  6272. }
  6273. };
  6274. const renderNav = () => children.map((item, index) => vue.createVNode(stdin_default$14, vue.mergeProps({
  6275. "key": item.id,
  6276. "id": `${id}-${index}`,
  6277. "ref": setTitleRefs(index),
  6278. "type": props.type,
  6279. "color": props.color,
  6280. "style": item.titleStyle,
  6281. "class": item.titleClass,
  6282. "shrink": props.shrink,
  6283. "isActive": index === state.currentIndex,
  6284. "controls": item.id,
  6285. "scrollable": scrollable.value,
  6286. "activeColor": props.titleActiveColor,
  6287. "inactiveColor": props.titleInactiveColor,
  6288. "onClick": (event) => onClickTab(item, index, event)
  6289. }, pick(item, ["dot", "badge", "title", "disabled", "showZeroBadge"])), {
  6290. title: item.$slots.title
  6291. }));
  6292. const renderLine = () => {
  6293. if (props.type === "line" && children.length) {
  6294. return vue.createVNode("div", {
  6295. "class": bem$W("line"),
  6296. "style": state.lineStyle
  6297. }, null);
  6298. }
  6299. };
  6300. const renderHeader = () => {
  6301. var _a2, _b2, _c;
  6302. const {
  6303. type,
  6304. border,
  6305. sticky
  6306. } = props;
  6307. const Header = [vue.createVNode("div", {
  6308. "ref": sticky ? void 0 : wrapRef,
  6309. "class": [bem$W("wrap"), {
  6310. [BORDER_TOP_BOTTOM]: type === "line" && border
  6311. }]
  6312. }, [vue.createVNode("div", {
  6313. "ref": navRef,
  6314. "role": "tablist",
  6315. "class": bem$W("nav", [type, {
  6316. shrink: props.shrink,
  6317. complete: scrollable.value
  6318. }]),
  6319. "style": navStyle.value,
  6320. "aria-orientation": "horizontal"
  6321. }, [(_a2 = slots["nav-left"]) == null ? void 0 : _a2.call(slots), renderNav(), renderLine(), (_b2 = slots["nav-right"]) == null ? void 0 : _b2.call(slots)])]), (_c = slots["nav-bottom"]) == null ? void 0 : _c.call(slots)];
  6322. if (sticky) {
  6323. return vue.createVNode("div", {
  6324. "ref": wrapRef
  6325. }, [Header]);
  6326. }
  6327. return Header;
  6328. };
  6329. vue.watch([() => props.color, windowWidth], setLine);
  6330. vue.watch(() => props.active, (value) => {
  6331. if (value !== currentName.value) {
  6332. setCurrentIndexByName(value);
  6333. }
  6334. });
  6335. vue.watch(() => children.length, () => {
  6336. if (state.inited) {
  6337. setCurrentIndexByName(props.active);
  6338. setLine();
  6339. vue.nextTick(() => {
  6340. scrollIntoView(true);
  6341. });
  6342. }
  6343. });
  6344. const init = () => {
  6345. setCurrentIndexByName(props.active, true);
  6346. vue.nextTick(() => {
  6347. state.inited = true;
  6348. if (wrapRef.value) {
  6349. tabHeight = use.useRect(wrapRef.value).height;
  6350. }
  6351. scrollIntoView(true);
  6352. });
  6353. };
  6354. const onRendered = (name2, title) => emit("rendered", name2, title);
  6355. const resize = () => {
  6356. setLine();
  6357. vue.nextTick(() => {
  6358. var _a2, _b2;
  6359. return (_b2 = (_a2 = contentRef.value) == null ? void 0 : _a2.swipeRef.value) == null ? void 0 : _b2.resize();
  6360. });
  6361. };
  6362. useExpose({
  6363. resize,
  6364. scrollTo
  6365. });
  6366. vue.onActivated(setLine);
  6367. onPopupReopen(setLine);
  6368. use.onMountedOrActivated(init);
  6369. use.useEventListener("scroll", onScroll, {
  6370. target: scroller,
  6371. passive: true
  6372. });
  6373. linkChildren({
  6374. id,
  6375. props,
  6376. setLine,
  6377. onRendered,
  6378. currentName,
  6379. scrollIntoView
  6380. });
  6381. return () => vue.createVNode("div", {
  6382. "ref": root,
  6383. "class": bem$W([props.type])
  6384. }, [props.sticky ? vue.createVNode(Sticky, {
  6385. "container": root.value,
  6386. "offsetTop": offsetTopPx.value,
  6387. "onScroll": onStickyScroll
  6388. }, {
  6389. default: () => [renderHeader()]
  6390. }) : renderHeader(), vue.createVNode(stdin_default$12, {
  6391. "ref": contentRef,
  6392. "count": children.length,
  6393. "inited": state.inited,
  6394. "animated": props.animated,
  6395. "duration": props.duration,
  6396. "swipeable": props.swipeable,
  6397. "lazyRender": props.lazyRender,
  6398. "currentIndex": state.currentIndex,
  6399. "onChange": setCurrentIndex
  6400. }, {
  6401. default: () => {
  6402. var _a2;
  6403. return [(_a2 = slots.default) == null ? void 0 : _a2.call(slots)];
  6404. }
  6405. })]);
  6406. }
  6407. });
  6408. const TAB_STATUS_KEY = Symbol();
  6409. const useTabStatus = () => vue.inject(TAB_STATUS_KEY, null);
  6410. const [name$W, bem$V] = createNamespace("swipe-item");
  6411. var stdin_default$10 = vue.defineComponent({
  6412. name: name$W,
  6413. setup(props, {
  6414. slots
  6415. }) {
  6416. let rendered;
  6417. const state = vue.reactive({
  6418. offset: 0,
  6419. inited: false,
  6420. mounted: false
  6421. });
  6422. const {
  6423. parent,
  6424. index
  6425. } = use.useParent(SWIPE_KEY);
  6426. if (!parent) {
  6427. if (process.env.NODE_ENV !== "production") {
  6428. console.error("[Vant] <SwipeItem> must be a child component of <Swipe>.");
  6429. }
  6430. return;
  6431. }
  6432. const style = vue.computed(() => {
  6433. const style2 = {};
  6434. const {
  6435. vertical
  6436. } = parent.props;
  6437. if (parent.size.value) {
  6438. style2[vertical ? "height" : "width"] = `${parent.size.value}px`;
  6439. }
  6440. if (state.offset) {
  6441. style2.transform = `translate${vertical ? "Y" : "X"}(${state.offset}px)`;
  6442. }
  6443. return style2;
  6444. });
  6445. const shouldRender = vue.computed(() => {
  6446. const {
  6447. loop,
  6448. lazyRender
  6449. } = parent.props;
  6450. if (!lazyRender || rendered) {
  6451. return true;
  6452. }
  6453. if (!state.mounted) {
  6454. return false;
  6455. }
  6456. const active = parent.activeIndicator.value;
  6457. const maxActive = parent.count.value - 1;
  6458. const prevActive = active === 0 && loop ? maxActive : active - 1;
  6459. const nextActive = active === maxActive && loop ? 0 : active + 1;
  6460. rendered = index.value === active || index.value === prevActive || index.value === nextActive;
  6461. return rendered;
  6462. });
  6463. const setOffset = (offset) => {
  6464. state.offset = offset;
  6465. };
  6466. vue.onMounted(() => {
  6467. vue.nextTick(() => {
  6468. state.mounted = true;
  6469. });
  6470. });
  6471. useExpose({
  6472. setOffset
  6473. });
  6474. return () => {
  6475. var _a;
  6476. return vue.createVNode("div", {
  6477. "class": bem$V(),
  6478. "style": style.value
  6479. }, [shouldRender.value ? (_a = slots.default) == null ? void 0 : _a.call(slots) : null]);
  6480. };
  6481. }
  6482. });
  6483. const SwipeItem = withInstall(stdin_default$10);
  6484. const [name$V, bem$U] = createNamespace("tab");
  6485. const tabProps = extend({}, routeProps, {
  6486. dot: Boolean,
  6487. name: numericProp,
  6488. badge: numericProp,
  6489. title: String,
  6490. disabled: Boolean,
  6491. titleClass: unknownProp,
  6492. titleStyle: [String, Object],
  6493. showZeroBadge: truthProp
  6494. });
  6495. var stdin_default$$ = vue.defineComponent({
  6496. name: name$V,
  6497. props: tabProps,
  6498. setup(props, {
  6499. slots
  6500. }) {
  6501. const id = useId();
  6502. const inited = vue.ref(false);
  6503. const {
  6504. parent,
  6505. index
  6506. } = use.useParent(TABS_KEY);
  6507. if (!parent) {
  6508. if (process.env.NODE_ENV !== "production") {
  6509. console.error("[Vant] <Tab> must be a child component of <Tabs>.");
  6510. }
  6511. return;
  6512. }
  6513. const getName = () => {
  6514. var _a;
  6515. return (_a = props.name) != null ? _a : index.value;
  6516. };
  6517. const init = () => {
  6518. inited.value = true;
  6519. if (parent.props.lazyRender) {
  6520. vue.nextTick(() => {
  6521. parent.onRendered(getName(), props.title);
  6522. });
  6523. }
  6524. };
  6525. const active = vue.computed(() => {
  6526. const isActive = getName() === parent.currentName.value;
  6527. if (isActive && !inited.value) {
  6528. init();
  6529. }
  6530. return isActive;
  6531. });
  6532. const hasInactiveClass = vue.ref(!active.value);
  6533. vue.watch(active, (val) => {
  6534. if (val) {
  6535. hasInactiveClass.value = false;
  6536. } else {
  6537. use.doubleRaf(() => {
  6538. hasInactiveClass.value = true;
  6539. });
  6540. }
  6541. });
  6542. vue.watch(() => props.title, () => {
  6543. parent.setLine();
  6544. parent.scrollIntoView();
  6545. });
  6546. vue.provide(TAB_STATUS_KEY, active);
  6547. return () => {
  6548. var _a;
  6549. const label = `${parent.id}-${index.value}`;
  6550. const {
  6551. animated,
  6552. swipeable,
  6553. scrollspy,
  6554. lazyRender
  6555. } = parent.props;
  6556. if (!slots.default && !animated) {
  6557. return;
  6558. }
  6559. const show = scrollspy || active.value;
  6560. if (animated || swipeable) {
  6561. return vue.createVNode(SwipeItem, {
  6562. "id": id,
  6563. "role": "tabpanel",
  6564. "class": bem$U("panel-wrapper", {
  6565. inactive: hasInactiveClass.value
  6566. }),
  6567. "tabindex": active.value ? 0 : -1,
  6568. "aria-hidden": !active.value,
  6569. "aria-labelledby": label
  6570. }, {
  6571. default: () => {
  6572. var _a2;
  6573. return [vue.createVNode("div", {
  6574. "class": bem$U("panel")
  6575. }, [(_a2 = slots.default) == null ? void 0 : _a2.call(slots)])];
  6576. }
  6577. });
  6578. }
  6579. const shouldRender = inited.value || scrollspy || !lazyRender;
  6580. const Content = shouldRender ? (_a = slots.default) == null ? void 0 : _a.call(slots) : null;
  6581. useExpose({
  6582. id
  6583. });
  6584. return vue.withDirectives(vue.createVNode("div", {
  6585. "id": id,
  6586. "role": "tabpanel",
  6587. "class": bem$U("panel"),
  6588. "tabindex": show ? 0 : -1,
  6589. "aria-labelledby": label
  6590. }, [Content]), [[vue.vShow, show]]);
  6591. };
  6592. }
  6593. });
  6594. const Tab = withInstall(stdin_default$$);
  6595. const Tabs = withInstall(stdin_default$11);
  6596. const [name$U, bem$T, t$e] = createNamespace("cascader");
  6597. const cascaderProps = {
  6598. title: String,
  6599. options: makeArrayProp(),
  6600. closeable: truthProp,
  6601. swipeable: truthProp,
  6602. closeIcon: makeStringProp("cross"),
  6603. showHeader: truthProp,
  6604. modelValue: numericProp,
  6605. fieldNames: Object,
  6606. placeholder: String,
  6607. activeColor: String
  6608. };
  6609. var stdin_default$_ = vue.defineComponent({
  6610. name: name$U,
  6611. props: cascaderProps,
  6612. emits: ["close", "change", "finish", "click-tab", "update:modelValue"],
  6613. setup(props, {
  6614. slots,
  6615. emit
  6616. }) {
  6617. const tabs = vue.ref([]);
  6618. const activeTab = vue.ref(0);
  6619. const {
  6620. text: textKey,
  6621. value: valueKey,
  6622. children: childrenKey
  6623. } = extend({
  6624. text: "text",
  6625. value: "value",
  6626. children: "children"
  6627. }, props.fieldNames);
  6628. const getSelectedOptionsByValue = (options, value) => {
  6629. for (const option of options) {
  6630. if (option[valueKey] === value) {
  6631. return [option];
  6632. }
  6633. if (option[childrenKey]) {
  6634. const selectedOptions = getSelectedOptionsByValue(option[childrenKey], value);
  6635. if (selectedOptions) {
  6636. return [option, ...selectedOptions];
  6637. }
  6638. }
  6639. }
  6640. };
  6641. const updateTabs = () => {
  6642. const {
  6643. options,
  6644. modelValue
  6645. } = props;
  6646. if (modelValue !== void 0) {
  6647. const selectedOptions = getSelectedOptionsByValue(options, modelValue);
  6648. if (selectedOptions) {
  6649. let optionsCursor = options;
  6650. tabs.value = selectedOptions.map((option) => {
  6651. const tab = {
  6652. options: optionsCursor,
  6653. selected: option
  6654. };
  6655. const next = optionsCursor.find((item) => item[valueKey] === option[valueKey]);
  6656. if (next) {
  6657. optionsCursor = next[childrenKey];
  6658. }
  6659. return tab;
  6660. });
  6661. if (optionsCursor) {
  6662. tabs.value.push({
  6663. options: optionsCursor,
  6664. selected: null
  6665. });
  6666. }
  6667. vue.nextTick(() => {
  6668. activeTab.value = tabs.value.length - 1;
  6669. });
  6670. return;
  6671. }
  6672. }
  6673. tabs.value = [{
  6674. options,
  6675. selected: null
  6676. }];
  6677. };
  6678. const onSelect = (option, tabIndex) => {
  6679. if (option.disabled) {
  6680. return;
  6681. }
  6682. tabs.value[tabIndex].selected = option;
  6683. if (tabs.value.length > tabIndex + 1) {
  6684. tabs.value = tabs.value.slice(0, tabIndex + 1);
  6685. }
  6686. if (option[childrenKey]) {
  6687. const nextTab = {
  6688. options: option[childrenKey],
  6689. selected: null
  6690. };
  6691. if (tabs.value[tabIndex + 1]) {
  6692. tabs.value[tabIndex + 1] = nextTab;
  6693. } else {
  6694. tabs.value.push(nextTab);
  6695. }
  6696. vue.nextTick(() => {
  6697. activeTab.value++;
  6698. });
  6699. }
  6700. const selectedOptions = tabs.value.map((tab) => tab.selected).filter(Boolean);
  6701. emit("update:modelValue", option[valueKey]);
  6702. const params = {
  6703. value: option[valueKey],
  6704. tabIndex,
  6705. selectedOptions
  6706. };
  6707. emit("change", params);
  6708. if (!option[childrenKey]) {
  6709. emit("finish", params);
  6710. }
  6711. };
  6712. const onClose = () => emit("close");
  6713. const onClickTab = ({
  6714. name: name2,
  6715. title
  6716. }) => emit("click-tab", name2, title);
  6717. const renderHeader = () => props.showHeader ? vue.createVNode("div", {
  6718. "class": bem$T("header")
  6719. }, [vue.createVNode("h2", {
  6720. "class": bem$T("title")
  6721. }, [slots.title ? slots.title() : props.title]), props.closeable ? vue.createVNode(Icon, {
  6722. "name": props.closeIcon,
  6723. "class": [bem$T("close-icon"), HAPTICS_FEEDBACK],
  6724. "onClick": onClose
  6725. }, null) : null]) : null;
  6726. const renderOption = (option, selectedOption, tabIndex) => {
  6727. const {
  6728. disabled
  6729. } = option;
  6730. const selected = !!(selectedOption && option[valueKey] === selectedOption[valueKey]);
  6731. const color = option.color || (selected ? props.activeColor : void 0);
  6732. const Text2 = slots.option ? slots.option({
  6733. option,
  6734. selected
  6735. }) : vue.createVNode("span", null, [option[textKey]]);
  6736. return vue.createVNode("li", {
  6737. "role": "menuitemradio",
  6738. "class": [bem$T("option", {
  6739. selected,
  6740. disabled
  6741. }), option.className],
  6742. "style": {
  6743. color
  6744. },
  6745. "tabindex": disabled ? void 0 : selected ? 0 : -1,
  6746. "aria-checked": selected,
  6747. "aria-disabled": disabled || void 0,
  6748. "onClick": () => onSelect(option, tabIndex)
  6749. }, [Text2, selected ? vue.createVNode(Icon, {
  6750. "name": "success",
  6751. "class": bem$T("selected-icon")
  6752. }, null) : null]);
  6753. };
  6754. const renderOptions = (options, selectedOption, tabIndex) => vue.createVNode("ul", {
  6755. "role": "menu",
  6756. "class": bem$T("options")
  6757. }, [options.map((option) => renderOption(option, selectedOption, tabIndex))]);
  6758. const renderTab = (tab, tabIndex) => {
  6759. const {
  6760. options,
  6761. selected
  6762. } = tab;
  6763. const placeholder = props.placeholder || t$e("select");
  6764. const title = selected ? selected[textKey] : placeholder;
  6765. return vue.createVNode(Tab, {
  6766. "title": title,
  6767. "titleClass": bem$T("tab", {
  6768. unselected: !selected
  6769. })
  6770. }, {
  6771. default: () => {
  6772. var _a, _b;
  6773. return [(_a = slots["options-top"]) == null ? void 0 : _a.call(slots, {
  6774. tabIndex
  6775. }), renderOptions(options, selected, tabIndex), (_b = slots["options-bottom"]) == null ? void 0 : _b.call(slots, {
  6776. tabIndex
  6777. })];
  6778. }
  6779. });
  6780. };
  6781. const renderTabs = () => vue.createVNode(Tabs, {
  6782. "active": activeTab.value,
  6783. "onUpdate:active": ($event) => activeTab.value = $event,
  6784. "shrink": true,
  6785. "animated": true,
  6786. "class": bem$T("tabs"),
  6787. "color": props.activeColor,
  6788. "swipeable": props.swipeable,
  6789. "onClick-tab": onClickTab
  6790. }, {
  6791. default: () => [tabs.value.map(renderTab)]
  6792. });
  6793. updateTabs();
  6794. vue.watch(() => props.options, updateTabs, {
  6795. deep: true
  6796. });
  6797. vue.watch(() => props.modelValue, (value) => {
  6798. if (value !== void 0) {
  6799. const values = tabs.value.map((tab) => {
  6800. var _a;
  6801. return (_a = tab.selected) == null ? void 0 : _a[valueKey];
  6802. });
  6803. if (values.includes(value)) {
  6804. return;
  6805. }
  6806. }
  6807. updateTabs();
  6808. });
  6809. return () => vue.createVNode("div", {
  6810. "class": bem$T()
  6811. }, [renderHeader(), renderTabs()]);
  6812. }
  6813. });
  6814. const Cascader = withInstall(stdin_default$_);
  6815. const [name$T, bem$S] = createNamespace("cell-group");
  6816. const cellGroupProps = {
  6817. title: String,
  6818. inset: Boolean,
  6819. border: truthProp
  6820. };
  6821. var stdin_default$Z = vue.defineComponent({
  6822. name: name$T,
  6823. inheritAttrs: false,
  6824. props: cellGroupProps,
  6825. setup(props, {
  6826. slots,
  6827. attrs
  6828. }) {
  6829. const renderGroup = () => {
  6830. var _a;
  6831. return vue.createVNode("div", vue.mergeProps({
  6832. "class": [bem$S({
  6833. inset: props.inset
  6834. }), {
  6835. [BORDER_TOP_BOTTOM]: props.border && !props.inset
  6836. }]
  6837. }, attrs), [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
  6838. };
  6839. const renderTitle = () => vue.createVNode("div", {
  6840. "class": bem$S("title", {
  6841. inset: props.inset
  6842. })
  6843. }, [slots.title ? slots.title() : props.title]);
  6844. return () => {
  6845. if (props.title || slots.title) {
  6846. return vue.createVNode(vue.Fragment, null, [renderTitle(), renderGroup()]);
  6847. }
  6848. return renderGroup();
  6849. };
  6850. }
  6851. });
  6852. const CellGroup = withInstall(stdin_default$Z);
  6853. const [name$S, bem$R] = createNamespace("checkbox-group");
  6854. const checkboxGroupProps = {
  6855. max: numericProp,
  6856. disabled: Boolean,
  6857. iconSize: numericProp,
  6858. direction: String,
  6859. modelValue: makeArrayProp(),
  6860. checkedColor: String
  6861. };
  6862. const CHECKBOX_GROUP_KEY = Symbol(name$S);
  6863. var stdin_default$Y = vue.defineComponent({
  6864. name: name$S,
  6865. props: checkboxGroupProps,
  6866. emits: ["change", "update:modelValue"],
  6867. setup(props, {
  6868. emit,
  6869. slots
  6870. }) {
  6871. const {
  6872. children,
  6873. linkChildren
  6874. } = use.useChildren(CHECKBOX_GROUP_KEY);
  6875. const updateValue = (value) => emit("update:modelValue", value);
  6876. const toggleAll = (options = {}) => {
  6877. if (typeof options === "boolean") {
  6878. options = {
  6879. checked: options
  6880. };
  6881. }
  6882. const {
  6883. checked,
  6884. skipDisabled
  6885. } = options;
  6886. const checkedChildren = children.filter((item) => {
  6887. if (!item.props.bindGroup) {
  6888. return false;
  6889. }
  6890. if (item.props.disabled && skipDisabled) {
  6891. return item.checked.value;
  6892. }
  6893. return checked != null ? checked : !item.checked.value;
  6894. });
  6895. const names = checkedChildren.map((item) => item.name);
  6896. updateValue(names);
  6897. };
  6898. vue.watch(() => props.modelValue, (value) => emit("change", value));
  6899. useExpose({
  6900. toggleAll
  6901. });
  6902. use.useCustomFieldValue(() => props.modelValue);
  6903. linkChildren({
  6904. props,
  6905. updateValue
  6906. });
  6907. return () => {
  6908. var _a;
  6909. return vue.createVNode("div", {
  6910. "class": bem$R([props.direction])
  6911. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
  6912. };
  6913. }
  6914. });
  6915. const [name$R, bem$Q] = createNamespace("checkbox");
  6916. const checkboxProps = extend({}, checkerProps, {
  6917. bindGroup: truthProp
  6918. });
  6919. var stdin_default$X = vue.defineComponent({
  6920. name: name$R,
  6921. props: checkboxProps,
  6922. emits: ["change", "update:modelValue"],
  6923. setup(props, {
  6924. emit,
  6925. slots
  6926. }) {
  6927. const {
  6928. parent
  6929. } = use.useParent(CHECKBOX_GROUP_KEY);
  6930. const setParentValue = (checked2) => {
  6931. const {
  6932. name: name2
  6933. } = props;
  6934. const {
  6935. max,
  6936. modelValue
  6937. } = parent.props;
  6938. const value = modelValue.slice();
  6939. if (checked2) {
  6940. const overlimit = max && value.length >= max;
  6941. if (!overlimit && !value.includes(name2)) {
  6942. value.push(name2);
  6943. if (props.bindGroup) {
  6944. parent.updateValue(value);
  6945. }
  6946. }
  6947. } else {
  6948. const index = value.indexOf(name2);
  6949. if (index !== -1) {
  6950. value.splice(index, 1);
  6951. if (props.bindGroup) {
  6952. parent.updateValue(value);
  6953. }
  6954. }
  6955. }
  6956. };
  6957. const checked = vue.computed(() => {
  6958. if (parent && props.bindGroup) {
  6959. return parent.props.modelValue.indexOf(props.name) !== -1;
  6960. }
  6961. return !!props.modelValue;
  6962. });
  6963. const toggle = (newValue = !checked.value) => {
  6964. if (parent && props.bindGroup) {
  6965. setParentValue(newValue);
  6966. } else {
  6967. emit("update:modelValue", newValue);
  6968. }
  6969. };
  6970. vue.watch(() => props.modelValue, (value) => emit("change", value));
  6971. useExpose({
  6972. toggle,
  6973. props,
  6974. checked
  6975. });
  6976. use.useCustomFieldValue(() => props.modelValue);
  6977. return () => vue.createVNode(stdin_default$1f, vue.mergeProps({
  6978. "bem": bem$Q,
  6979. "role": "checkbox",
  6980. "parent": parent,
  6981. "checked": checked.value,
  6982. "onToggle": toggle
  6983. }, props), pick(slots, ["default", "icon"]));
  6984. }
  6985. });
  6986. const Checkbox = withInstall(stdin_default$X);
  6987. const CheckboxGroup = withInstall(stdin_default$Y);
  6988. const [name$Q, bem$P] = createNamespace("circle");
  6989. let uid = 0;
  6990. const format = (rate) => Math.min(Math.max(+rate, 0), 100);
  6991. function getPath(clockwise, viewBoxSize) {
  6992. const sweepFlag = clockwise ? 1 : 0;
  6993. return `M ${viewBoxSize / 2} ${viewBoxSize / 2} m 0, -500 a 500, 500 0 1, ${sweepFlag} 0, 1000 a 500, 500 0 1, ${sweepFlag} 0, -1000`;
  6994. }
  6995. const circleProps = {
  6996. text: String,
  6997. size: numericProp,
  6998. fill: makeStringProp("none"),
  6999. rate: makeNumericProp(100),
  7000. speed: makeNumericProp(0),
  7001. color: [String, Object],
  7002. clockwise: truthProp,
  7003. layerColor: String,
  7004. currentRate: makeNumberProp(0),
  7005. strokeWidth: makeNumericProp(40),
  7006. strokeLinecap: String,
  7007. startPosition: makeStringProp("top")
  7008. };
  7009. var stdin_default$W = vue.defineComponent({
  7010. name: name$Q,
  7011. props: circleProps,
  7012. emits: ["update:currentRate"],
  7013. setup(props, {
  7014. emit,
  7015. slots
  7016. }) {
  7017. const id = `van-circle-${uid++}`;
  7018. const viewBoxSize = vue.computed(() => +props.strokeWidth + 1e3);
  7019. const path = vue.computed(() => getPath(props.clockwise, viewBoxSize.value));
  7020. const svgStyle = vue.computed(() => {
  7021. const ROTATE_ANGLE_MAP = {
  7022. top: 0,
  7023. right: 90,
  7024. bottom: 180,
  7025. left: 270
  7026. };
  7027. const angleValue = ROTATE_ANGLE_MAP[props.startPosition];
  7028. if (angleValue) {
  7029. return {
  7030. transform: `rotate(${angleValue}deg)`
  7031. };
  7032. }
  7033. });
  7034. vue.watch(() => props.rate, (rate) => {
  7035. let rafId;
  7036. const startTime = Date.now();
  7037. const startRate = props.currentRate;
  7038. const endRate = format(rate);
  7039. const duration = Math.abs((startRate - endRate) * 1e3 / +props.speed);
  7040. const animate = () => {
  7041. const now = Date.now();
  7042. const progress = Math.min((now - startTime) / duration, 1);
  7043. const rate2 = progress * (endRate - startRate) + startRate;
  7044. emit("update:currentRate", format(parseFloat(rate2.toFixed(1))));
  7045. if (endRate > startRate ? rate2 < endRate : rate2 > endRate) {
  7046. rafId = use.raf(animate);
  7047. }
  7048. };
  7049. if (props.speed) {
  7050. if (rafId) {
  7051. use.cancelRaf(rafId);
  7052. }
  7053. rafId = use.raf(animate);
  7054. } else {
  7055. emit("update:currentRate", endRate);
  7056. }
  7057. }, {
  7058. immediate: true
  7059. });
  7060. const renderHover = () => {
  7061. const PERIMETER = 3140;
  7062. const {
  7063. strokeWidth,
  7064. currentRate,
  7065. strokeLinecap
  7066. } = props;
  7067. const offset = PERIMETER * currentRate / 100;
  7068. const color = isObject(props.color) ? `url(#${id})` : props.color;
  7069. const style = {
  7070. stroke: color,
  7071. strokeWidth: `${+strokeWidth + 1}px`,
  7072. strokeLinecap,
  7073. strokeDasharray: `${offset}px ${PERIMETER}px`
  7074. };
  7075. return vue.createVNode("path", {
  7076. "d": path.value,
  7077. "style": style,
  7078. "class": bem$P("hover"),
  7079. "stroke": color
  7080. }, null);
  7081. };
  7082. const renderLayer = () => {
  7083. const style = {
  7084. fill: props.fill,
  7085. stroke: props.layerColor,
  7086. strokeWidth: `${props.strokeWidth}px`
  7087. };
  7088. return vue.createVNode("path", {
  7089. "class": bem$P("layer"),
  7090. "style": style,
  7091. "d": path.value
  7092. }, null);
  7093. };
  7094. const renderGradient = () => {
  7095. const {
  7096. color
  7097. } = props;
  7098. if (!isObject(color)) {
  7099. return;
  7100. }
  7101. const Stops = Object.keys(color).sort((a, b) => parseFloat(a) - parseFloat(b)).map((key, index) => vue.createVNode("stop", {
  7102. "key": index,
  7103. "offset": key,
  7104. "stop-color": color[key]
  7105. }, null));
  7106. return vue.createVNode("defs", null, [vue.createVNode("linearGradient", {
  7107. "id": id,
  7108. "x1": "100%",
  7109. "y1": "0%",
  7110. "x2": "0%",
  7111. "y2": "0%"
  7112. }, [Stops])]);
  7113. };
  7114. const renderText = () => {
  7115. if (slots.default) {
  7116. return slots.default();
  7117. }
  7118. if (props.text) {
  7119. return vue.createVNode("div", {
  7120. "class": bem$P("text")
  7121. }, [props.text]);
  7122. }
  7123. };
  7124. return () => vue.createVNode("div", {
  7125. "class": bem$P(),
  7126. "style": getSizeStyle(props.size)
  7127. }, [vue.createVNode("svg", {
  7128. "viewBox": `0 0 ${viewBoxSize.value} ${viewBoxSize.value}`,
  7129. "style": svgStyle.value
  7130. }, [renderGradient(), renderLayer(), renderHover()]), renderText()]);
  7131. }
  7132. });
  7133. const Circle = withInstall(stdin_default$W);
  7134. const [name$P, bem$O] = createNamespace("row");
  7135. const ROW_KEY = Symbol(name$P);
  7136. const rowProps = {
  7137. tag: makeStringProp("div"),
  7138. wrap: truthProp,
  7139. align: String,
  7140. gutter: makeNumericProp(0),
  7141. justify: String
  7142. };
  7143. var stdin_default$V = vue.defineComponent({
  7144. name: name$P,
  7145. props: rowProps,
  7146. setup(props, {
  7147. slots
  7148. }) {
  7149. const {
  7150. children,
  7151. linkChildren
  7152. } = use.useChildren(ROW_KEY);
  7153. const groups = vue.computed(() => {
  7154. const groups2 = [[]];
  7155. let totalSpan = 0;
  7156. children.forEach((child, index) => {
  7157. totalSpan += Number(child.span);
  7158. if (totalSpan > 24) {
  7159. groups2.push([index]);
  7160. totalSpan -= 24;
  7161. } else {
  7162. groups2[groups2.length - 1].push(index);
  7163. }
  7164. });
  7165. return groups2;
  7166. });
  7167. const spaces = vue.computed(() => {
  7168. const gutter = Number(props.gutter);
  7169. const spaces2 = [];
  7170. if (!gutter) {
  7171. return spaces2;
  7172. }
  7173. groups.value.forEach((group) => {
  7174. const averagePadding = gutter * (group.length - 1) / group.length;
  7175. group.forEach((item, index) => {
  7176. if (index === 0) {
  7177. spaces2.push({
  7178. right: averagePadding
  7179. });
  7180. } else {
  7181. const left = gutter - spaces2[item - 1].right;
  7182. const right = averagePadding - left;
  7183. spaces2.push({
  7184. left,
  7185. right
  7186. });
  7187. }
  7188. });
  7189. });
  7190. return spaces2;
  7191. });
  7192. linkChildren({
  7193. spaces
  7194. });
  7195. return () => {
  7196. const {
  7197. tag,
  7198. wrap,
  7199. align,
  7200. justify
  7201. } = props;
  7202. return vue.createVNode(tag, {
  7203. "class": bem$O({
  7204. [`align-${align}`]: align,
  7205. [`justify-${justify}`]: justify,
  7206. nowrap: !wrap
  7207. })
  7208. }, {
  7209. default: () => {
  7210. var _a;
  7211. return [(_a = slots.default) == null ? void 0 : _a.call(slots)];
  7212. }
  7213. });
  7214. };
  7215. }
  7216. });
  7217. const [name$O, bem$N] = createNamespace("col");
  7218. const colProps = {
  7219. tag: makeStringProp("div"),
  7220. span: makeNumericProp(0),
  7221. offset: numericProp
  7222. };
  7223. var stdin_default$U = vue.defineComponent({
  7224. name: name$O,
  7225. props: colProps,
  7226. setup(props, {
  7227. slots
  7228. }) {
  7229. const {
  7230. parent,
  7231. index
  7232. } = use.useParent(ROW_KEY);
  7233. const style = vue.computed(() => {
  7234. if (!parent) {
  7235. return;
  7236. }
  7237. const {
  7238. spaces
  7239. } = parent;
  7240. if (spaces && spaces.value && spaces.value[index.value]) {
  7241. const {
  7242. left,
  7243. right
  7244. } = spaces.value[index.value];
  7245. return {
  7246. paddingLeft: left ? `${left}px` : null,
  7247. paddingRight: right ? `${right}px` : null
  7248. };
  7249. }
  7250. });
  7251. return () => {
  7252. const {
  7253. tag,
  7254. span,
  7255. offset
  7256. } = props;
  7257. return vue.createVNode(tag, {
  7258. "style": style.value,
  7259. "class": bem$N({
  7260. [span]: span,
  7261. [`offset-${offset}`]: offset
  7262. })
  7263. }, {
  7264. default: () => {
  7265. var _a;
  7266. return [(_a = slots.default) == null ? void 0 : _a.call(slots)];
  7267. }
  7268. });
  7269. };
  7270. }
  7271. });
  7272. const Col = withInstall(stdin_default$U);
  7273. const [name$N, bem$M] = createNamespace("collapse");
  7274. const COLLAPSE_KEY = Symbol(name$N);
  7275. const collapseProps = {
  7276. border: truthProp,
  7277. accordion: Boolean,
  7278. modelValue: {
  7279. type: [String, Number, Array],
  7280. default: ""
  7281. }
  7282. };
  7283. function validateModelValue(modelValue, accordion) {
  7284. if (accordion && Array.isArray(modelValue)) {
  7285. console.error('[Vant] Collapse: "v-model" should not be Array in accordion mode');
  7286. return false;
  7287. }
  7288. if (!accordion && !Array.isArray(modelValue)) {
  7289. console.error('[Vant] Collapse: "v-model" should be Array in non-accordion mode');
  7290. return false;
  7291. }
  7292. return true;
  7293. }
  7294. var stdin_default$T = vue.defineComponent({
  7295. name: name$N,
  7296. props: collapseProps,
  7297. emits: ["change", "update:modelValue"],
  7298. setup(props, {
  7299. emit,
  7300. slots
  7301. }) {
  7302. const {
  7303. linkChildren,
  7304. children
  7305. } = use.useChildren(COLLAPSE_KEY);
  7306. const updateName = (name2) => {
  7307. emit("change", name2);
  7308. emit("update:modelValue", name2);
  7309. };
  7310. const toggle = (name2, expanded) => {
  7311. const {
  7312. accordion,
  7313. modelValue
  7314. } = props;
  7315. if (accordion) {
  7316. updateName(name2 === modelValue ? "" : name2);
  7317. } else if (expanded) {
  7318. updateName(modelValue.concat(name2));
  7319. } else {
  7320. updateName(modelValue.filter((activeName) => activeName !== name2));
  7321. }
  7322. };
  7323. const toggleAll = (options = {}) => {
  7324. if (props.accordion) {
  7325. return;
  7326. }
  7327. if (typeof options === "boolean") {
  7328. options = {
  7329. expanded: options
  7330. };
  7331. }
  7332. const {
  7333. expanded,
  7334. skipDisabled
  7335. } = options;
  7336. const expandedChildren = children.filter((item) => {
  7337. if (item.disabled && skipDisabled) {
  7338. return item.expanded.value;
  7339. }
  7340. return expanded != null ? expanded : !item.expanded.value;
  7341. });
  7342. const names = expandedChildren.map((item) => item.itemName.value);
  7343. updateName(names);
  7344. };
  7345. const isExpanded = (name2) => {
  7346. const {
  7347. accordion,
  7348. modelValue
  7349. } = props;
  7350. if (process.env.NODE_ENV !== "production" && !validateModelValue(modelValue, accordion)) {
  7351. return false;
  7352. }
  7353. return accordion ? modelValue === name2 : modelValue.includes(name2);
  7354. };
  7355. useExpose({
  7356. toggleAll
  7357. });
  7358. linkChildren({
  7359. toggle,
  7360. isExpanded
  7361. });
  7362. return () => {
  7363. var _a;
  7364. return vue.createVNode("div", {
  7365. "class": [bem$M(), {
  7366. [BORDER_TOP_BOTTOM]: props.border
  7367. }]
  7368. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
  7369. };
  7370. }
  7371. });
  7372. const Collapse = withInstall(stdin_default$T);
  7373. const [name$M, bem$L] = createNamespace("collapse-item");
  7374. const CELL_SLOTS = ["icon", "title", "value", "label", "right-icon"];
  7375. const collapseItemProps = extend({}, cellSharedProps, {
  7376. name: numericProp,
  7377. isLink: truthProp,
  7378. disabled: Boolean,
  7379. readonly: Boolean,
  7380. lazyRender: truthProp
  7381. });
  7382. var stdin_default$S = vue.defineComponent({
  7383. name: name$M,
  7384. props: collapseItemProps,
  7385. setup(props, {
  7386. slots
  7387. }) {
  7388. const wrapperRef = vue.ref();
  7389. const contentRef = vue.ref();
  7390. const {
  7391. parent,
  7392. index
  7393. } = use.useParent(COLLAPSE_KEY);
  7394. if (!parent) {
  7395. if (process.env.NODE_ENV !== "production") {
  7396. console.error("[Vant] <CollapseItem> must be a child component of <Collapse>.");
  7397. }
  7398. return;
  7399. }
  7400. const name2 = vue.computed(() => {
  7401. var _a;
  7402. return (_a = props.name) != null ? _a : index.value;
  7403. });
  7404. const expanded = vue.computed(() => parent.isExpanded(name2.value));
  7405. const show = vue.ref(expanded.value);
  7406. const lazyRender = useLazyRender(() => show.value || !props.lazyRender);
  7407. const onTransitionEnd = () => {
  7408. if (!expanded.value) {
  7409. show.value = false;
  7410. } else if (wrapperRef.value) {
  7411. wrapperRef.value.style.height = "";
  7412. }
  7413. };
  7414. vue.watch(expanded, (value, oldValue) => {
  7415. if (oldValue === null) {
  7416. return;
  7417. }
  7418. if (value) {
  7419. show.value = true;
  7420. }
  7421. const tick = value ? vue.nextTick : use.raf;
  7422. tick(() => {
  7423. if (!contentRef.value || !wrapperRef.value) {
  7424. return;
  7425. }
  7426. const {
  7427. offsetHeight
  7428. } = contentRef.value;
  7429. if (offsetHeight) {
  7430. const contentHeight = `${offsetHeight}px`;
  7431. wrapperRef.value.style.height = value ? "0" : contentHeight;
  7432. use.doubleRaf(() => {
  7433. if (wrapperRef.value) {
  7434. wrapperRef.value.style.height = value ? contentHeight : "0";
  7435. }
  7436. });
  7437. } else {
  7438. onTransitionEnd();
  7439. }
  7440. });
  7441. });
  7442. const toggle = (newValue = !expanded.value) => {
  7443. parent.toggle(name2.value, newValue);
  7444. };
  7445. const onClickTitle = () => {
  7446. if (!props.disabled && !props.readonly) {
  7447. toggle();
  7448. }
  7449. };
  7450. const renderTitle = () => {
  7451. const {
  7452. border,
  7453. disabled,
  7454. readonly
  7455. } = props;
  7456. const attrs = pick(props, Object.keys(cellSharedProps));
  7457. if (readonly) {
  7458. attrs.isLink = false;
  7459. }
  7460. if (disabled || readonly) {
  7461. attrs.clickable = false;
  7462. }
  7463. return vue.createVNode(Cell, vue.mergeProps({
  7464. "role": "button",
  7465. "class": bem$L("title", {
  7466. disabled,
  7467. expanded: expanded.value,
  7468. borderless: !border
  7469. }),
  7470. "aria-expanded": String(expanded.value),
  7471. "onClick": onClickTitle
  7472. }, attrs), pick(slots, CELL_SLOTS));
  7473. };
  7474. const renderContent = lazyRender(() => {
  7475. var _a;
  7476. return vue.withDirectives(vue.createVNode("div", {
  7477. "ref": wrapperRef,
  7478. "class": bem$L("wrapper"),
  7479. "onTransitionend": onTransitionEnd
  7480. }, [vue.createVNode("div", {
  7481. "ref": contentRef,
  7482. "class": bem$L("content")
  7483. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)])]), [[vue.vShow, show.value]]);
  7484. });
  7485. useExpose({
  7486. toggle,
  7487. expanded,
  7488. itemName: name2
  7489. });
  7490. return () => vue.createVNode("div", {
  7491. "class": [bem$L({
  7492. border: index.value && props.border
  7493. })]
  7494. }, [renderTitle(), renderContent()]);
  7495. }
  7496. });
  7497. const CollapseItem = withInstall(stdin_default$S);
  7498. const ConfigProvider = withInstall(stdin_default$1A);
  7499. const [name$L, bem$K, t$d] = createNamespace("contact-card");
  7500. const contactCardProps = {
  7501. tel: String,
  7502. name: String,
  7503. type: makeStringProp("add"),
  7504. addText: String,
  7505. editable: truthProp
  7506. };
  7507. var stdin_default$R = vue.defineComponent({
  7508. name: name$L,
  7509. props: contactCardProps,
  7510. emits: ["click"],
  7511. setup(props, {
  7512. emit
  7513. }) {
  7514. const onClick = (event) => {
  7515. if (props.editable) {
  7516. emit("click", event);
  7517. }
  7518. };
  7519. const renderContent = () => {
  7520. if (props.type === "add") {
  7521. return props.addText || t$d("addContact");
  7522. }
  7523. return [vue.createVNode("div", null, [`${t$d("name")}\uFF1A${props.name}`]), vue.createVNode("div", null, [`${t$d("tel")}\uFF1A${props.tel}`])];
  7524. };
  7525. return () => vue.createVNode(Cell, {
  7526. "center": true,
  7527. "icon": props.type === "edit" ? "contact" : "add-square",
  7528. "class": bem$K([props.type]),
  7529. "border": false,
  7530. "isLink": props.editable,
  7531. "valueClass": bem$K("value"),
  7532. "onClick": onClick
  7533. }, {
  7534. value: renderContent
  7535. });
  7536. }
  7537. });
  7538. const ContactCard = withInstall(stdin_default$R);
  7539. const [name$K, bem$J, t$c] = createNamespace("contact-edit");
  7540. const DEFAULT_CONTACT = {
  7541. tel: "",
  7542. name: ""
  7543. };
  7544. const contactEditProps = {
  7545. isEdit: Boolean,
  7546. isSaving: Boolean,
  7547. isDeleting: Boolean,
  7548. showSetDefault: Boolean,
  7549. setDefaultLabel: String,
  7550. contactInfo: {
  7551. type: Object,
  7552. default: () => extend({}, DEFAULT_CONTACT)
  7553. },
  7554. telValidator: {
  7555. type: Function,
  7556. default: isMobile
  7557. }
  7558. };
  7559. var stdin_default$Q = vue.defineComponent({
  7560. name: name$K,
  7561. props: contactEditProps,
  7562. emits: ["save", "delete", "change-default"],
  7563. setup(props, {
  7564. emit
  7565. }) {
  7566. const contact = vue.reactive(extend({}, DEFAULT_CONTACT, props.contactInfo));
  7567. const onSave = () => {
  7568. if (!props.isSaving) {
  7569. emit("save", contact);
  7570. }
  7571. };
  7572. const onDelete = () => emit("delete", contact);
  7573. const renderButtons = () => vue.createVNode("div", {
  7574. "class": bem$J("buttons")
  7575. }, [vue.createVNode(Button, {
  7576. "block": true,
  7577. "round": true,
  7578. "type": "danger",
  7579. "text": t$c("save"),
  7580. "class": bem$J("button"),
  7581. "loading": props.isSaving,
  7582. "nativeType": "submit"
  7583. }, null), props.isEdit && vue.createVNode(Button, {
  7584. "block": true,
  7585. "round": true,
  7586. "text": t$c("delete"),
  7587. "class": bem$J("button"),
  7588. "loading": props.isDeleting,
  7589. "onClick": onDelete
  7590. }, null)]);
  7591. const renderSwitch = () => vue.createVNode(Switch, {
  7592. "modelValue": contact.isDefault,
  7593. "onUpdate:modelValue": ($event) => contact.isDefault = $event,
  7594. "size": 24,
  7595. "onChange": (checked) => emit("change-default", checked)
  7596. }, null);
  7597. const renderSetDefault = () => {
  7598. if (props.showSetDefault) {
  7599. return vue.createVNode(Cell, {
  7600. "title": props.setDefaultLabel,
  7601. "class": bem$J("switch-cell"),
  7602. "border": false
  7603. }, {
  7604. "right-icon": renderSwitch
  7605. });
  7606. }
  7607. };
  7608. vue.watch(() => props.contactInfo, (value) => extend(contact, DEFAULT_CONTACT, value));
  7609. return () => vue.createVNode(Form, {
  7610. "class": bem$J(),
  7611. "onSubmit": onSave
  7612. }, {
  7613. default: () => [vue.createVNode("div", {
  7614. "class": bem$J("fields")
  7615. }, [vue.createVNode(Field, {
  7616. "modelValue": contact.name,
  7617. "onUpdate:modelValue": ($event) => contact.name = $event,
  7618. "clearable": true,
  7619. "label": t$c("name"),
  7620. "rules": [{
  7621. required: true,
  7622. message: t$c("nameEmpty")
  7623. }],
  7624. "maxlength": "30",
  7625. "placeholder": t$c("name")
  7626. }, null), vue.createVNode(Field, {
  7627. "modelValue": contact.tel,
  7628. "onUpdate:modelValue": ($event) => contact.tel = $event,
  7629. "clearable": true,
  7630. "type": "tel",
  7631. "label": t$c("tel"),
  7632. "rules": [{
  7633. validator: props.telValidator,
  7634. message: t$c("telInvalid")
  7635. }],
  7636. "placeholder": t$c("tel")
  7637. }, null)]), renderSetDefault(), renderButtons()]
  7638. });
  7639. }
  7640. });
  7641. const ContactEdit = withInstall(stdin_default$Q);
  7642. const [name$J, bem$I, t$b] = createNamespace("contact-list");
  7643. const contactListProps = {
  7644. list: Array,
  7645. addText: String,
  7646. modelValue: unknownProp,
  7647. defaultTagText: String
  7648. };
  7649. var stdin_default$P = vue.defineComponent({
  7650. name: name$J,
  7651. props: contactListProps,
  7652. emits: ["add", "edit", "select", "update:modelValue"],
  7653. setup(props, {
  7654. emit
  7655. }) {
  7656. const renderItem = (item, index) => {
  7657. const onClick = () => {
  7658. emit("update:modelValue", item.id);
  7659. emit("select", item, index);
  7660. };
  7661. const renderRightIcon = () => vue.createVNode(Radio, {
  7662. "class": bem$I("radio"),
  7663. "name": item.id,
  7664. "iconSize": 16
  7665. }, null);
  7666. const renderEditIcon = () => vue.createVNode(Icon, {
  7667. "name": "edit",
  7668. "class": bem$I("edit"),
  7669. "onClick": (event) => {
  7670. event.stopPropagation();
  7671. emit("edit", item, index);
  7672. }
  7673. }, null);
  7674. const renderContent = () => {
  7675. const nodes = [`${item.name}\uFF0C${item.tel}`];
  7676. if (item.isDefault && props.defaultTagText) {
  7677. nodes.push(vue.createVNode(Tag, {
  7678. "type": "danger",
  7679. "round": true,
  7680. "class": bem$I("item-tag")
  7681. }, {
  7682. default: () => [props.defaultTagText]
  7683. }));
  7684. }
  7685. return nodes;
  7686. };
  7687. return vue.createVNode(Cell, {
  7688. "key": item.id,
  7689. "isLink": true,
  7690. "center": true,
  7691. "class": bem$I("item"),
  7692. "valueClass": bem$I("item-value"),
  7693. "onClick": onClick
  7694. }, {
  7695. icon: renderEditIcon,
  7696. value: renderContent,
  7697. "right-icon": renderRightIcon
  7698. });
  7699. };
  7700. return () => vue.createVNode("div", {
  7701. "class": bem$I()
  7702. }, [vue.createVNode(RadioGroup, {
  7703. "modelValue": props.modelValue,
  7704. "class": bem$I("group")
  7705. }, {
  7706. default: () => [props.list && props.list.map(renderItem)]
  7707. }), vue.createVNode("div", {
  7708. "class": [bem$I("bottom"), "van-safe-area-bottom"]
  7709. }, [vue.createVNode(Button, {
  7710. "round": true,
  7711. "block": true,
  7712. "type": "danger",
  7713. "class": bem$I("add"),
  7714. "text": props.addText || t$b("addContact"),
  7715. "onClick": () => emit("add")
  7716. }, null)])]);
  7717. }
  7718. });
  7719. const ContactList = withInstall(stdin_default$P);
  7720. function parseFormat(format2, currentTime) {
  7721. const { days } = currentTime;
  7722. let { hours, minutes, seconds, milliseconds } = currentTime;
  7723. if (format2.includes("DD")) {
  7724. format2 = format2.replace("DD", padZero(days));
  7725. } else {
  7726. hours += days * 24;
  7727. }
  7728. if (format2.includes("HH")) {
  7729. format2 = format2.replace("HH", padZero(hours));
  7730. } else {
  7731. minutes += hours * 60;
  7732. }
  7733. if (format2.includes("mm")) {
  7734. format2 = format2.replace("mm", padZero(minutes));
  7735. } else {
  7736. seconds += minutes * 60;
  7737. }
  7738. if (format2.includes("ss")) {
  7739. format2 = format2.replace("ss", padZero(seconds));
  7740. } else {
  7741. milliseconds += seconds * 1e3;
  7742. }
  7743. if (format2.includes("S")) {
  7744. const ms = padZero(milliseconds, 3);
  7745. if (format2.includes("SSS")) {
  7746. format2 = format2.replace("SSS", ms);
  7747. } else if (format2.includes("SS")) {
  7748. format2 = format2.replace("SS", ms.slice(0, 2));
  7749. } else {
  7750. format2 = format2.replace("S", ms.charAt(0));
  7751. }
  7752. }
  7753. return format2;
  7754. }
  7755. const [name$I, bem$H] = createNamespace("count-down");
  7756. const countDownProps = {
  7757. time: makeNumericProp(0),
  7758. format: makeStringProp("HH:mm:ss"),
  7759. autoStart: truthProp,
  7760. millisecond: Boolean
  7761. };
  7762. var stdin_default$O = vue.defineComponent({
  7763. name: name$I,
  7764. props: countDownProps,
  7765. emits: ["change", "finish"],
  7766. setup(props, {
  7767. emit,
  7768. slots
  7769. }) {
  7770. const {
  7771. start,
  7772. pause,
  7773. reset,
  7774. current: current2
  7775. } = use.useCountDown({
  7776. time: +props.time,
  7777. millisecond: props.millisecond,
  7778. onChange: (current22) => emit("change", current22),
  7779. onFinish: () => emit("finish")
  7780. });
  7781. const timeText = vue.computed(() => parseFormat(props.format, current2.value));
  7782. const resetTime = () => {
  7783. reset(+props.time);
  7784. if (props.autoStart) {
  7785. start();
  7786. }
  7787. };
  7788. vue.watch(() => props.time, resetTime, {
  7789. immediate: true
  7790. });
  7791. useExpose({
  7792. start,
  7793. pause,
  7794. reset: resetTime
  7795. });
  7796. return () => vue.createVNode("div", {
  7797. "role": "timer",
  7798. "class": bem$H()
  7799. }, [slots.default ? slots.default(current2.value) : timeText.value]);
  7800. }
  7801. });
  7802. const CountDown = withInstall(stdin_default$O);
  7803. function getDate(timeStamp) {
  7804. const date = new Date(timeStamp * 1e3);
  7805. return `${date.getFullYear()}.${padZero(date.getMonth() + 1)}.${padZero(
  7806. date.getDate()
  7807. )}`;
  7808. }
  7809. const formatDiscount = (discount) => (discount / 10).toFixed(discount % 10 === 0 ? 0 : 1);
  7810. const formatAmount = (amount) => (amount / 100).toFixed(amount % 100 === 0 ? 0 : amount % 10 === 0 ? 1 : 2);
  7811. const [name$H, bem$G, t$a] = createNamespace("coupon");
  7812. var stdin_default$N = vue.defineComponent({
  7813. name: name$H,
  7814. props: {
  7815. chosen: Boolean,
  7816. coupon: makeRequiredProp(Object),
  7817. disabled: Boolean,
  7818. currency: makeStringProp("\xA5")
  7819. },
  7820. setup(props) {
  7821. const validPeriod = vue.computed(() => {
  7822. const {
  7823. startAt,
  7824. endAt
  7825. } = props.coupon;
  7826. return `${getDate(startAt)} - ${getDate(endAt)}`;
  7827. });
  7828. const faceAmount = vue.computed(() => {
  7829. const {
  7830. coupon,
  7831. currency
  7832. } = props;
  7833. if (coupon.valueDesc) {
  7834. return [coupon.valueDesc, vue.createVNode("span", null, [coupon.unitDesc || ""])];
  7835. }
  7836. if (coupon.denominations) {
  7837. const denominations = formatAmount(coupon.denominations);
  7838. return [vue.createVNode("span", null, [currency]), ` ${denominations}`];
  7839. }
  7840. if (coupon.discount) {
  7841. return t$a("discount", formatDiscount(coupon.discount));
  7842. }
  7843. return "";
  7844. });
  7845. const conditionMessage = vue.computed(() => {
  7846. const condition = formatAmount(props.coupon.originCondition || 0);
  7847. return condition === "0" ? t$a("unlimited") : t$a("condition", condition);
  7848. });
  7849. return () => {
  7850. const {
  7851. chosen,
  7852. coupon,
  7853. disabled
  7854. } = props;
  7855. const description = disabled && coupon.reason || coupon.description;
  7856. return vue.createVNode("div", {
  7857. "class": bem$G({
  7858. disabled
  7859. })
  7860. }, [vue.createVNode("div", {
  7861. "class": bem$G("content")
  7862. }, [vue.createVNode("div", {
  7863. "class": bem$G("head")
  7864. }, [vue.createVNode("h2", {
  7865. "class": bem$G("amount")
  7866. }, [faceAmount.value]), vue.createVNode("p", {
  7867. "class": bem$G("condition")
  7868. }, [coupon.condition || conditionMessage.value])]), vue.createVNode("div", {
  7869. "class": bem$G("body")
  7870. }, [vue.createVNode("p", {
  7871. "class": bem$G("name")
  7872. }, [coupon.name]), vue.createVNode("p", {
  7873. "class": bem$G("valid")
  7874. }, [validPeriod.value]), !disabled && vue.createVNode(Checkbox, {
  7875. "class": bem$G("corner"),
  7876. "modelValue": chosen
  7877. }, null)])]), description && vue.createVNode("p", {
  7878. "class": bem$G("description")
  7879. }, [description])]);
  7880. };
  7881. }
  7882. });
  7883. const Coupon = withInstall(stdin_default$N);
  7884. const [name$G, bem$F, t$9] = createNamespace("coupon-cell");
  7885. const couponCellProps = {
  7886. title: String,
  7887. border: truthProp,
  7888. editable: truthProp,
  7889. coupons: makeArrayProp(),
  7890. currency: makeStringProp("\xA5"),
  7891. chosenCoupon: makeNumericProp(-1)
  7892. };
  7893. function formatValue({
  7894. coupons,
  7895. chosenCoupon,
  7896. currency
  7897. }) {
  7898. const coupon = coupons[+chosenCoupon];
  7899. if (coupon) {
  7900. let value = 0;
  7901. if (isDef(coupon.value)) {
  7902. ({
  7903. value
  7904. } = coupon);
  7905. } else if (isDef(coupon.denominations)) {
  7906. value = coupon.denominations;
  7907. }
  7908. return `-${currency} ${(value / 100).toFixed(2)}`;
  7909. }
  7910. return coupons.length === 0 ? t$9("noCoupon") : t$9("count", coupons.length);
  7911. }
  7912. var stdin_default$M = vue.defineComponent({
  7913. name: name$G,
  7914. props: couponCellProps,
  7915. setup(props) {
  7916. return () => {
  7917. const selected = props.coupons[+props.chosenCoupon];
  7918. return vue.createVNode(Cell, {
  7919. "class": bem$F(),
  7920. "value": formatValue(props),
  7921. "title": props.title || t$9("title"),
  7922. "border": props.border,
  7923. "isLink": props.editable,
  7924. "valueClass": bem$F("value", {
  7925. selected
  7926. })
  7927. }, null);
  7928. };
  7929. }
  7930. });
  7931. const CouponCell = withInstall(stdin_default$M);
  7932. const [name$F, bem$E] = createNamespace("empty");
  7933. const emptyProps = {
  7934. image: makeStringProp("default"),
  7935. imageSize: [Number, String, Array],
  7936. description: String
  7937. };
  7938. var stdin_default$L = vue.defineComponent({
  7939. name: name$F,
  7940. props: emptyProps,
  7941. setup(props, {
  7942. slots
  7943. }) {
  7944. const renderDescription = () => {
  7945. const description = slots.description ? slots.description() : props.description;
  7946. if (description) {
  7947. return vue.createVNode("p", {
  7948. "class": bem$E("description")
  7949. }, [description]);
  7950. }
  7951. };
  7952. const renderBottom = () => {
  7953. if (slots.default) {
  7954. return vue.createVNode("div", {
  7955. "class": bem$E("bottom")
  7956. }, [slots.default()]);
  7957. }
  7958. };
  7959. const baseId = useId();
  7960. const getId = (num) => `${baseId}-${num}`;
  7961. const getUrlById = (num) => `url(#${getId(num)})`;
  7962. const renderStop = (color, offset, opacity) => vue.createVNode("stop", {
  7963. "stop-color": color,
  7964. "offset": `${offset}%`,
  7965. "stop-opacity": opacity
  7966. }, null);
  7967. const renderStops = (fromColor, toColor) => [renderStop(fromColor, 0), renderStop(toColor, 100)];
  7968. const renderShadow = (id) => [vue.createVNode("defs", null, [vue.createVNode("radialGradient", {
  7969. "id": getId(id),
  7970. "cx": "50%",
  7971. "cy": "54%",
  7972. "fx": "50%",
  7973. "fy": "54%",
  7974. "r": "297%",
  7975. "gradientTransform": "matrix(-.16 0 0 -.33 .58 .72)"
  7976. }, [renderStop("#EBEDF0", 0), renderStop("#F2F3F5", 100, 0.3)])]), vue.createVNode("ellipse", {
  7977. "fill": getUrlById(id),
  7978. "opacity": ".8",
  7979. "cx": "80",
  7980. "cy": "140",
  7981. "rx": "46",
  7982. "ry": "8"
  7983. }, null)];
  7984. const renderBuilding = () => [vue.createVNode("defs", null, [vue.createVNode("linearGradient", {
  7985. "id": getId("a"),
  7986. "x1": "64%",
  7987. "y1": "100%",
  7988. "x2": "64%"
  7989. }, [renderStop("#FFF", 0, 0.5), renderStop("#F2F3F5", 100)])]), vue.createVNode("g", {
  7990. "opacity": ".8"
  7991. }, [vue.createVNode("path", {
  7992. "d": "M36 131V53H16v20H2v58h34z",
  7993. "fill": getUrlById("a")
  7994. }, null), vue.createVNode("path", {
  7995. "d": "M123 15h22v14h9v77h-31V15z",
  7996. "fill": getUrlById("a")
  7997. }, null)])];
  7998. const renderCloud = () => [vue.createVNode("defs", null, [vue.createVNode("linearGradient", {
  7999. "id": getId("b"),
  8000. "x1": "64%",
  8001. "y1": "97%",
  8002. "x2": "64%",
  8003. "y2": "0%"
  8004. }, [renderStop("#F2F3F5", 0, 0.3), renderStop("#F2F3F5", 100)])]), vue.createVNode("g", {
  8005. "opacity": ".8"
  8006. }, [vue.createVNode("path", {
  8007. "d": "M87 6c3 0 7 3 8 6a8 8 0 1 1-1 16H80a7 7 0 0 1-8-6c0-4 3-7 6-7 0-5 4-9 9-9Z",
  8008. "fill": getUrlById("b")
  8009. }, null), vue.createVNode("path", {
  8010. "d": "M19 23c2 0 3 1 4 3 2 0 4 2 4 4a4 4 0 0 1-4 3v1h-7v-1l-1 1c-2 0-3-2-3-4 0-1 1-3 3-3 0-2 2-4 4-4Z",
  8011. "fill": getUrlById("b")
  8012. }, null)])];
  8013. const renderNetwork = () => vue.createVNode("svg", {
  8014. "viewBox": "0 0 160 160"
  8015. }, [vue.createVNode("defs", null, [vue.createVNode("linearGradient", {
  8016. "id": getId(1),
  8017. "x1": "64%",
  8018. "y1": "100%",
  8019. "x2": "64%"
  8020. }, [renderStop("#FFF", 0, 0.5), renderStop("#F2F3F5", 100)]), vue.createVNode("linearGradient", {
  8021. "id": getId(2),
  8022. "x1": "50%",
  8023. "x2": "50%",
  8024. "y2": "84%"
  8025. }, [renderStop("#EBEDF0", 0), renderStop("#DCDEE0", 100, 0)]), vue.createVNode("linearGradient", {
  8026. "id": getId(3),
  8027. "x1": "100%",
  8028. "x2": "100%",
  8029. "y2": "100%"
  8030. }, [renderStops("#EAEDF0", "#DCDEE0")]), vue.createVNode("radialGradient", {
  8031. "id": getId(4),
  8032. "cx": "50%",
  8033. "cy": "0%",
  8034. "fx": "50%",
  8035. "fy": "0%",
  8036. "r": "100%",
  8037. "gradientTransform": "matrix(0 1 -.54 0 .5 -.5)"
  8038. }, [renderStop("#EBEDF0", 0), renderStop("#FFF", 100, 0)])]), vue.createVNode("g", {
  8039. "fill": "none"
  8040. }, [renderBuilding(), vue.createVNode("path", {
  8041. "fill": getUrlById(4),
  8042. "d": "M0 139h160v21H0z"
  8043. }, null), vue.createVNode("path", {
  8044. "d": "M80 54a7 7 0 0 1 3 13v27l-2 2h-2a2 2 0 0 1-2-2V67a7 7 0 0 1 3-13z",
  8045. "fill": getUrlById(2)
  8046. }, null), vue.createVNode("g", {
  8047. "opacity": ".6",
  8048. "stroke-linecap": "round",
  8049. "stroke-width": "7"
  8050. }, [vue.createVNode("path", {
  8051. "d": "M64 47a19 19 0 0 0-5 13c0 5 2 10 5 13",
  8052. "stroke": getUrlById(3)
  8053. }, null), vue.createVNode("path", {
  8054. "d": "M53 36a34 34 0 0 0 0 48",
  8055. "stroke": getUrlById(3)
  8056. }, null), vue.createVNode("path", {
  8057. "d": "M95 73a19 19 0 0 0 6-13c0-5-2-9-6-13",
  8058. "stroke": getUrlById(3)
  8059. }, null), vue.createVNode("path", {
  8060. "d": "M106 84a34 34 0 0 0 0-48",
  8061. "stroke": getUrlById(3)
  8062. }, null)]), vue.createVNode("g", {
  8063. "transform": "translate(31 105)"
  8064. }, [vue.createVNode("rect", {
  8065. "fill": "#EBEDF0",
  8066. "width": "98",
  8067. "height": "34",
  8068. "rx": "2"
  8069. }, null), vue.createVNode("rect", {
  8070. "fill": "#FFF",
  8071. "x": "9",
  8072. "y": "8",
  8073. "width": "80",
  8074. "height": "18",
  8075. "rx": "1.1"
  8076. }, null), vue.createVNode("rect", {
  8077. "fill": "#EBEDF0",
  8078. "x": "15",
  8079. "y": "12",
  8080. "width": "18",
  8081. "height": "6",
  8082. "rx": "1.1"
  8083. }, null)])])]);
  8084. const renderMaterial = () => vue.createVNode("svg", {
  8085. "viewBox": "0 0 160 160"
  8086. }, [vue.createVNode("defs", null, [vue.createVNode("linearGradient", {
  8087. "x1": "50%",
  8088. "x2": "50%",
  8089. "y2": "100%",
  8090. "id": getId(5)
  8091. }, [renderStops("#F2F3F5", "#DCDEE0")]), vue.createVNode("linearGradient", {
  8092. "x1": "95%",
  8093. "y1": "48%",
  8094. "x2": "5.5%",
  8095. "y2": "51%",
  8096. "id": getId(6)
  8097. }, [renderStops("#EAEDF1", "#DCDEE0")]), vue.createVNode("linearGradient", {
  8098. "y1": "45%",
  8099. "x2": "100%",
  8100. "y2": "54%",
  8101. "id": getId(7)
  8102. }, [renderStops("#EAEDF1", "#DCDEE0")])]), renderBuilding(), renderCloud(), vue.createVNode("g", {
  8103. "transform": "translate(36 50)",
  8104. "fill": "none"
  8105. }, [vue.createVNode("g", {
  8106. "transform": "translate(8)"
  8107. }, [vue.createVNode("rect", {
  8108. "fill": "#EBEDF0",
  8109. "opacity": ".6",
  8110. "x": "38",
  8111. "y": "13",
  8112. "width": "36",
  8113. "height": "53",
  8114. "rx": "2"
  8115. }, null), vue.createVNode("rect", {
  8116. "fill": getUrlById(5),
  8117. "width": "64",
  8118. "height": "66",
  8119. "rx": "2"
  8120. }, null), vue.createVNode("rect", {
  8121. "fill": "#FFF",
  8122. "x": "6",
  8123. "y": "6",
  8124. "width": "52",
  8125. "height": "55",
  8126. "rx": "1"
  8127. }, null), vue.createVNode("g", {
  8128. "transform": "translate(15 17)",
  8129. "fill": getUrlById(6)
  8130. }, [vue.createVNode("rect", {
  8131. "width": "34",
  8132. "height": "6",
  8133. "rx": "1"
  8134. }, null), vue.createVNode("path", {
  8135. "d": "M0 14h34v6H0z"
  8136. }, null), vue.createVNode("rect", {
  8137. "y": "28",
  8138. "width": "34",
  8139. "height": "6",
  8140. "rx": "1"
  8141. }, null)])]), vue.createVNode("rect", {
  8142. "fill": getUrlById(7),
  8143. "y": "61",
  8144. "width": "88",
  8145. "height": "28",
  8146. "rx": "1"
  8147. }, null), vue.createVNode("rect", {
  8148. "fill": "#F7F8FA",
  8149. "x": "29",
  8150. "y": "72",
  8151. "width": "30",
  8152. "height": "6",
  8153. "rx": "1"
  8154. }, null)])]);
  8155. const renderError = () => vue.createVNode("svg", {
  8156. "viewBox": "0 0 160 160"
  8157. }, [vue.createVNode("defs", null, [vue.createVNode("linearGradient", {
  8158. "x1": "50%",
  8159. "x2": "50%",
  8160. "y2": "100%",
  8161. "id": getId(8)
  8162. }, [renderStops("#EAEDF1", "#DCDEE0")])]), renderBuilding(), renderCloud(), renderShadow("c"), vue.createVNode("path", {
  8163. "d": "m59 60 21 21 21-21h3l9 9v3L92 93l21 21v3l-9 9h-3l-21-21-21 21h-3l-9-9v-3l21-21-21-21v-3l9-9h3Z",
  8164. "fill": getUrlById(8)
  8165. }, null)]);
  8166. const renderSearch = () => vue.createVNode("svg", {
  8167. "viewBox": "0 0 160 160"
  8168. }, [vue.createVNode("defs", null, [vue.createVNode("linearGradient", {
  8169. "x1": "50%",
  8170. "y1": "100%",
  8171. "x2": "50%",
  8172. "id": getId(9)
  8173. }, [renderStops("#EEE", "#D8D8D8")]), vue.createVNode("linearGradient", {
  8174. "x1": "100%",
  8175. "y1": "50%",
  8176. "y2": "50%",
  8177. "id": getId(10)
  8178. }, [renderStops("#F2F3F5", "#DCDEE0")]), vue.createVNode("linearGradient", {
  8179. "x1": "50%",
  8180. "x2": "50%",
  8181. "y2": "100%",
  8182. "id": getId(11)
  8183. }, [renderStops("#F2F3F5", "#DCDEE0")]), vue.createVNode("linearGradient", {
  8184. "x1": "50%",
  8185. "x2": "50%",
  8186. "y2": "100%",
  8187. "id": getId(12)
  8188. }, [renderStops("#FFF", "#F7F8FA")])]), renderBuilding(), renderCloud(), renderShadow("d"), vue.createVNode("g", {
  8189. "transform": "rotate(-45 113 -4)",
  8190. "fill": "none"
  8191. }, [vue.createVNode("rect", {
  8192. "fill": getUrlById(9),
  8193. "x": "24",
  8194. "y": "52.8",
  8195. "width": "5.8",
  8196. "height": "19",
  8197. "rx": "1"
  8198. }, null), vue.createVNode("rect", {
  8199. "fill": getUrlById(10),
  8200. "x": "22.1",
  8201. "y": "67.3",
  8202. "width": "9.9",
  8203. "height": "28",
  8204. "rx": "1"
  8205. }, null), vue.createVNode("circle", {
  8206. "stroke": getUrlById(11),
  8207. "stroke-width": "8",
  8208. "cx": "27",
  8209. "cy": "27",
  8210. "r": "27"
  8211. }, null), vue.createVNode("circle", {
  8212. "fill": getUrlById(12),
  8213. "cx": "27",
  8214. "cy": "27",
  8215. "r": "16"
  8216. }, null), vue.createVNode("path", {
  8217. "d": "M37 7c-8 0-15 5-16 12",
  8218. "stroke": getUrlById(11),
  8219. "stroke-width": "3",
  8220. "opacity": ".5",
  8221. "stroke-linecap": "round",
  8222. "transform": "rotate(45 29 13)"
  8223. }, null)])]);
  8224. const renderImage = () => {
  8225. var _a;
  8226. if (slots.image) {
  8227. return slots.image();
  8228. }
  8229. const PRESET_IMAGES = {
  8230. error: renderError,
  8231. search: renderSearch,
  8232. network: renderNetwork,
  8233. default: renderMaterial
  8234. };
  8235. return ((_a = PRESET_IMAGES[props.image]) == null ? void 0 : _a.call(PRESET_IMAGES)) || vue.createVNode("img", {
  8236. "src": props.image
  8237. }, null);
  8238. };
  8239. return () => vue.createVNode("div", {
  8240. "class": bem$E()
  8241. }, [vue.createVNode("div", {
  8242. "class": bem$E("image"),
  8243. "style": getSizeStyle(props.imageSize)
  8244. }, [renderImage()]), renderDescription(), renderBottom()]);
  8245. }
  8246. });
  8247. const Empty = withInstall(stdin_default$L);
  8248. const [name$E, bem$D, t$8] = createNamespace("coupon-list");
  8249. const couponListProps = {
  8250. code: makeStringProp(""),
  8251. coupons: makeArrayProp(),
  8252. currency: makeStringProp("\xA5"),
  8253. showCount: truthProp,
  8254. emptyImage: String,
  8255. chosenCoupon: makeNumberProp(-1),
  8256. enabledTitle: String,
  8257. disabledTitle: String,
  8258. disabledCoupons: makeArrayProp(),
  8259. showExchangeBar: truthProp,
  8260. showCloseButton: truthProp,
  8261. closeButtonText: String,
  8262. inputPlaceholder: String,
  8263. exchangeMinLength: makeNumberProp(1),
  8264. exchangeButtonText: String,
  8265. displayedCouponIndex: makeNumberProp(-1),
  8266. exchangeButtonLoading: Boolean,
  8267. exchangeButtonDisabled: Boolean
  8268. };
  8269. var stdin_default$K = vue.defineComponent({
  8270. name: name$E,
  8271. props: couponListProps,
  8272. emits: ["change", "exchange", "update:code"],
  8273. setup(props, {
  8274. emit,
  8275. slots
  8276. }) {
  8277. const [couponRefs, setCouponRefs] = useRefs();
  8278. const root = vue.ref();
  8279. const barRef = vue.ref();
  8280. const activeTab = vue.ref(0);
  8281. const listHeight = vue.ref(0);
  8282. const currentCode = vue.ref(props.code);
  8283. const buttonDisabled = vue.computed(() => !props.exchangeButtonLoading && (props.exchangeButtonDisabled || !currentCode.value || currentCode.value.length < props.exchangeMinLength));
  8284. const updateListHeight = () => {
  8285. const TABS_HEIGHT = 44;
  8286. const rootHeight = use.useRect(root).height;
  8287. const headerHeight = use.useRect(barRef).height + TABS_HEIGHT;
  8288. listHeight.value = (rootHeight > headerHeight ? rootHeight : windowHeight.value) - headerHeight;
  8289. };
  8290. const onExchange = () => {
  8291. emit("exchange", currentCode.value);
  8292. if (!props.code) {
  8293. currentCode.value = "";
  8294. }
  8295. };
  8296. const scrollToCoupon = (index) => {
  8297. vue.nextTick(() => {
  8298. var _a;
  8299. return (_a = couponRefs.value[index]) == null ? void 0 : _a.scrollIntoView();
  8300. });
  8301. };
  8302. const renderEmpty = () => vue.createVNode(Empty, {
  8303. "image": props.emptyImage
  8304. }, {
  8305. default: () => [vue.createVNode("p", {
  8306. "class": bem$D("empty-tip")
  8307. }, [t$8("noCoupon")])]
  8308. });
  8309. const renderExchangeBar = () => {
  8310. if (props.showExchangeBar) {
  8311. return vue.createVNode("div", {
  8312. "ref": barRef,
  8313. "class": bem$D("exchange-bar")
  8314. }, [vue.createVNode(Field, {
  8315. "modelValue": currentCode.value,
  8316. "onUpdate:modelValue": ($event) => currentCode.value = $event,
  8317. "clearable": true,
  8318. "border": false,
  8319. "class": bem$D("field"),
  8320. "placeholder": props.inputPlaceholder || t$8("placeholder"),
  8321. "maxlength": "20"
  8322. }, null), vue.createVNode(Button, {
  8323. "plain": true,
  8324. "type": "danger",
  8325. "class": bem$D("exchange"),
  8326. "text": props.exchangeButtonText || t$8("exchange"),
  8327. "loading": props.exchangeButtonLoading,
  8328. "disabled": buttonDisabled.value,
  8329. "onClick": onExchange
  8330. }, null)]);
  8331. }
  8332. };
  8333. const renderCouponTab = () => {
  8334. const {
  8335. coupons
  8336. } = props;
  8337. const count = props.showCount ? ` (${coupons.length})` : "";
  8338. const title = (props.enabledTitle || t$8("enable")) + count;
  8339. return vue.createVNode(Tab, {
  8340. "title": title
  8341. }, {
  8342. default: () => {
  8343. var _a;
  8344. return [vue.createVNode("div", {
  8345. "class": bem$D("list", {
  8346. "with-bottom": props.showCloseButton
  8347. }),
  8348. "style": {
  8349. height: `${listHeight.value}px`
  8350. }
  8351. }, [coupons.map((coupon, index) => vue.createVNode(Coupon, {
  8352. "key": coupon.id,
  8353. "ref": setCouponRefs(index),
  8354. "coupon": coupon,
  8355. "chosen": index === props.chosenCoupon,
  8356. "currency": props.currency,
  8357. "onClick": () => emit("change", index)
  8358. }, null)), !coupons.length && renderEmpty(), (_a = slots["list-footer"]) == null ? void 0 : _a.call(slots)])];
  8359. }
  8360. });
  8361. };
  8362. const renderDisabledTab = () => {
  8363. const {
  8364. disabledCoupons
  8365. } = props;
  8366. const count = props.showCount ? ` (${disabledCoupons.length})` : "";
  8367. const title = (props.disabledTitle || t$8("disabled")) + count;
  8368. return vue.createVNode(Tab, {
  8369. "title": title
  8370. }, {
  8371. default: () => {
  8372. var _a;
  8373. return [vue.createVNode("div", {
  8374. "class": bem$D("list", {
  8375. "with-bottom": props.showCloseButton
  8376. }),
  8377. "style": {
  8378. height: `${listHeight.value}px`
  8379. }
  8380. }, [disabledCoupons.map((coupon) => vue.createVNode(Coupon, {
  8381. "disabled": true,
  8382. "key": coupon.id,
  8383. "coupon": coupon,
  8384. "currency": props.currency
  8385. }, null)), !disabledCoupons.length && renderEmpty(), (_a = slots["disabled-list-footer"]) == null ? void 0 : _a.call(slots)])];
  8386. }
  8387. });
  8388. };
  8389. vue.watch(() => props.code, (value) => {
  8390. currentCode.value = value;
  8391. });
  8392. vue.watch(windowHeight, updateListHeight);
  8393. vue.watch(currentCode, (value) => emit("update:code", value));
  8394. vue.watch(() => props.displayedCouponIndex, scrollToCoupon);
  8395. vue.onMounted(() => {
  8396. updateListHeight();
  8397. scrollToCoupon(props.displayedCouponIndex);
  8398. });
  8399. return () => vue.createVNode("div", {
  8400. "ref": root,
  8401. "class": bem$D()
  8402. }, [renderExchangeBar(), vue.createVNode(Tabs, {
  8403. "active": activeTab.value,
  8404. "onUpdate:active": ($event) => activeTab.value = $event,
  8405. "class": bem$D("tab")
  8406. }, {
  8407. default: () => [renderCouponTab(), renderDisabledTab()]
  8408. }), vue.createVNode("div", {
  8409. "class": bem$D("bottom")
  8410. }, [vue.withDirectives(vue.createVNode(Button, {
  8411. "round": true,
  8412. "block": true,
  8413. "type": "danger",
  8414. "class": bem$D("close"),
  8415. "text": props.closeButtonText || t$8("close"),
  8416. "onClick": () => emit("change", -1)
  8417. }, null), [[vue.vShow, props.showCloseButton]])])]);
  8418. }
  8419. });
  8420. const CouponList = withInstall(stdin_default$K);
  8421. const [name$D] = createNamespace("time-picker");
  8422. var stdin_default$J = vue.defineComponent({
  8423. name: name$D,
  8424. props: extend({}, sharedProps, {
  8425. minHour: makeNumericProp(0),
  8426. maxHour: makeNumericProp(23),
  8427. minMinute: makeNumericProp(0),
  8428. maxMinute: makeNumericProp(59),
  8429. modelValue: String
  8430. }),
  8431. emits: ["confirm", "cancel", "change", "update:modelValue"],
  8432. setup(props, {
  8433. emit,
  8434. slots
  8435. }) {
  8436. const formatValue2 = (value) => {
  8437. const {
  8438. minHour,
  8439. maxHour,
  8440. maxMinute,
  8441. minMinute
  8442. } = props;
  8443. if (!value) {
  8444. value = `${padZero(minHour)}:${padZero(minMinute)}`;
  8445. }
  8446. let [hour, minute] = value.split(":");
  8447. hour = padZero(clamp(+hour, +minHour, +maxHour));
  8448. minute = padZero(clamp(+minute, +minMinute, +maxMinute));
  8449. return `${hour}:${minute}`;
  8450. };
  8451. const picker = vue.ref();
  8452. const currentDate = vue.ref(formatValue2(props.modelValue));
  8453. const ranges = vue.computed(() => [{
  8454. type: "hour",
  8455. range: [+props.minHour, +props.maxHour]
  8456. }, {
  8457. type: "minute",
  8458. range: [+props.minMinute, +props.maxMinute]
  8459. }]);
  8460. const originColumns = vue.computed(() => ranges.value.map(({
  8461. type,
  8462. range: rangeArr
  8463. }) => {
  8464. let values = times(rangeArr[1] - rangeArr[0] + 1, (index) => padZero(rangeArr[0] + index));
  8465. if (props.filter) {
  8466. values = props.filter(type, values);
  8467. }
  8468. return {
  8469. type,
  8470. values
  8471. };
  8472. }));
  8473. const columns = vue.computed(() => originColumns.value.map((column) => ({
  8474. values: column.values.map((value) => props.formatter(column.type, value))
  8475. })));
  8476. const updateColumnValue = () => {
  8477. const pair = currentDate.value.split(":");
  8478. const values = [props.formatter("hour", pair[0]), props.formatter("minute", pair[1])];
  8479. vue.nextTick(() => {
  8480. var _a;
  8481. (_a = picker.value) == null ? void 0 : _a.setValues(values);
  8482. });
  8483. };
  8484. const updateInnerValue = () => {
  8485. const [hourIndex, minuteIndex] = picker.value.getIndexes();
  8486. const [hourColumn, minuteColumn] = originColumns.value;
  8487. const hour = hourColumn.values[hourIndex] || hourColumn.values[0];
  8488. const minute = minuteColumn.values[minuteIndex] || minuteColumn.values[0];
  8489. currentDate.value = formatValue2(`${hour}:${minute}`);
  8490. updateColumnValue();
  8491. };
  8492. const onConfirm = () => emit("confirm", currentDate.value);
  8493. const onCancel = () => emit("cancel");
  8494. const onChange = () => {
  8495. updateInnerValue();
  8496. vue.nextTick(() => {
  8497. vue.nextTick(() => emit("change", currentDate.value));
  8498. });
  8499. };
  8500. vue.onMounted(() => {
  8501. updateColumnValue();
  8502. vue.nextTick(updateInnerValue);
  8503. });
  8504. vue.watch(columns, updateColumnValue);
  8505. vue.watch(() => [props.filter, props.maxHour, props.minMinute, props.maxMinute], updateInnerValue);
  8506. vue.watch(() => props.minHour, () => {
  8507. vue.nextTick(updateInnerValue);
  8508. });
  8509. vue.watch(currentDate, (value) => emit("update:modelValue", value));
  8510. vue.watch(() => props.modelValue, (value) => {
  8511. value = formatValue2(value);
  8512. if (value !== currentDate.value) {
  8513. currentDate.value = value;
  8514. updateColumnValue();
  8515. }
  8516. });
  8517. useExpose({
  8518. getPicker: () => picker.value && proxyPickerMethods(picker.value, updateInnerValue)
  8519. });
  8520. return () => vue.createVNode(Picker, vue.mergeProps({
  8521. "ref": picker,
  8522. "columns": columns.value,
  8523. "onChange": onChange,
  8524. "onCancel": onCancel,
  8525. "onConfirm": onConfirm
  8526. }, pick(props, pickerInheritKeys)), slots);
  8527. }
  8528. });
  8529. const currentYear = new Date().getFullYear();
  8530. const [name$C] = createNamespace("date-picker");
  8531. var stdin_default$I = vue.defineComponent({
  8532. name: name$C,
  8533. props: extend({}, sharedProps, {
  8534. type: makeStringProp("datetime"),
  8535. modelValue: Date,
  8536. minDate: {
  8537. type: Date,
  8538. default: () => new Date(currentYear - 10, 0, 1),
  8539. validator: isDate
  8540. },
  8541. maxDate: {
  8542. type: Date,
  8543. default: () => new Date(currentYear + 10, 11, 31),
  8544. validator: isDate
  8545. }
  8546. }),
  8547. emits: ["confirm", "cancel", "change", "update:modelValue"],
  8548. setup(props, {
  8549. emit,
  8550. slots
  8551. }) {
  8552. const formatValue2 = (value) => {
  8553. if (isDate(value)) {
  8554. const timestamp = clamp(value.getTime(), props.minDate.getTime(), props.maxDate.getTime());
  8555. return new Date(timestamp);
  8556. }
  8557. return void 0;
  8558. };
  8559. const picker = vue.ref();
  8560. const currentDate = vue.ref(formatValue2(props.modelValue));
  8561. const getBoundary = (type, value) => {
  8562. const boundary = props[`${type}Date`];
  8563. const year = boundary.getFullYear();
  8564. let month = 1;
  8565. let date = 1;
  8566. let hour = 0;
  8567. let minute = 0;
  8568. if (type === "max") {
  8569. month = 12;
  8570. date = getMonthEndDay(value.getFullYear(), value.getMonth() + 1);
  8571. hour = 23;
  8572. minute = 59;
  8573. }
  8574. if (value.getFullYear() === year) {
  8575. month = boundary.getMonth() + 1;
  8576. if (value.getMonth() + 1 === month) {
  8577. date = boundary.getDate();
  8578. if (value.getDate() === date) {
  8579. hour = boundary.getHours();
  8580. if (value.getHours() === hour) {
  8581. minute = boundary.getMinutes();
  8582. }
  8583. }
  8584. }
  8585. }
  8586. return {
  8587. [`${type}Year`]: year,
  8588. [`${type}Month`]: month,
  8589. [`${type}Date`]: date,
  8590. [`${type}Hour`]: hour,
  8591. [`${type}Minute`]: minute
  8592. };
  8593. };
  8594. const ranges = vue.computed(() => {
  8595. const {
  8596. maxYear,
  8597. maxDate,
  8598. maxMonth,
  8599. maxHour,
  8600. maxMinute
  8601. } = getBoundary("max", currentDate.value || props.minDate);
  8602. const {
  8603. minYear,
  8604. minDate,
  8605. minMonth,
  8606. minHour,
  8607. minMinute
  8608. } = getBoundary("min", currentDate.value || props.minDate);
  8609. let result = [{
  8610. type: "year",
  8611. range: [minYear, maxYear]
  8612. }, {
  8613. type: "month",
  8614. range: [minMonth, maxMonth]
  8615. }, {
  8616. type: "day",
  8617. range: [minDate, maxDate]
  8618. }, {
  8619. type: "hour",
  8620. range: [minHour, maxHour]
  8621. }, {
  8622. type: "minute",
  8623. range: [minMinute, maxMinute]
  8624. }];
  8625. switch (props.type) {
  8626. case "date":
  8627. result = result.slice(0, 3);
  8628. break;
  8629. case "year-month":
  8630. result = result.slice(0, 2);
  8631. break;
  8632. case "month-day":
  8633. result = result.slice(1, 3);
  8634. break;
  8635. case "datehour":
  8636. result = result.slice(0, 4);
  8637. break;
  8638. }
  8639. if (props.columnsOrder) {
  8640. const columnsOrder = props.columnsOrder.concat(result.map((column) => column.type));
  8641. result.sort((a, b) => columnsOrder.indexOf(a.type) - columnsOrder.indexOf(b.type));
  8642. }
  8643. return result;
  8644. });
  8645. const originColumns = vue.computed(() => ranges.value.map(({
  8646. type,
  8647. range: rangeArr
  8648. }) => {
  8649. let values = times(rangeArr[1] - rangeArr[0] + 1, (index) => padZero(rangeArr[0] + index));
  8650. if (props.filter) {
  8651. values = props.filter(type, values);
  8652. }
  8653. return {
  8654. type,
  8655. values
  8656. };
  8657. }));
  8658. const columns = vue.computed(() => originColumns.value.map((column) => ({
  8659. values: column.values.map((value) => props.formatter(column.type, value))
  8660. })));
  8661. const updateColumnValue = () => {
  8662. const value = currentDate.value || props.minDate;
  8663. const {
  8664. formatter
  8665. } = props;
  8666. const values = originColumns.value.map((column) => {
  8667. switch (column.type) {
  8668. case "year":
  8669. return formatter("year", `${value.getFullYear()}`);
  8670. case "month":
  8671. return formatter("month", padZero(value.getMonth() + 1));
  8672. case "day":
  8673. return formatter("day", padZero(value.getDate()));
  8674. case "hour":
  8675. return formatter("hour", padZero(value.getHours()));
  8676. case "minute":
  8677. return formatter("minute", padZero(value.getMinutes()));
  8678. default:
  8679. return "";
  8680. }
  8681. });
  8682. vue.nextTick(() => {
  8683. var _a;
  8684. (_a = picker.value) == null ? void 0 : _a.setValues(values);
  8685. });
  8686. };
  8687. const updateInnerValue = () => {
  8688. const {
  8689. type
  8690. } = props;
  8691. const indexes = picker.value.getIndexes();
  8692. const getValue = (type2) => {
  8693. let index = 0;
  8694. originColumns.value.forEach((column, columnIndex) => {
  8695. if (type2 === column.type) {
  8696. index = columnIndex;
  8697. }
  8698. });
  8699. const {
  8700. values
  8701. } = originColumns.value[index];
  8702. return getTrueValue(values[indexes[index]]);
  8703. };
  8704. let year;
  8705. let month;
  8706. let day;
  8707. if (type === "month-day") {
  8708. year = (currentDate.value || props.minDate).getFullYear();
  8709. month = getValue("month");
  8710. day = getValue("day");
  8711. } else {
  8712. year = getValue("year");
  8713. month = getValue("month");
  8714. day = type === "year-month" ? 1 : getValue("day");
  8715. }
  8716. const maxDay = getMonthEndDay(year, month);
  8717. day = day > maxDay ? maxDay : day;
  8718. let hour = 0;
  8719. let minute = 0;
  8720. if (type === "datehour") {
  8721. hour = getValue("hour");
  8722. }
  8723. if (type === "datetime") {
  8724. hour = getValue("hour");
  8725. minute = getValue("minute");
  8726. }
  8727. const value = new Date(year, month - 1, day, hour, minute);
  8728. currentDate.value = formatValue2(value);
  8729. };
  8730. const onConfirm = () => {
  8731. emit("update:modelValue", currentDate.value);
  8732. emit("confirm", currentDate.value);
  8733. };
  8734. const onCancel = () => emit("cancel");
  8735. const onChange = () => {
  8736. updateInnerValue();
  8737. vue.nextTick(() => {
  8738. updateInnerValue();
  8739. vue.nextTick(() => emit("change", currentDate.value));
  8740. });
  8741. };
  8742. vue.onMounted(() => {
  8743. updateColumnValue();
  8744. vue.nextTick(updateInnerValue);
  8745. });
  8746. vue.watch(columns, updateColumnValue);
  8747. vue.watch(currentDate, (value, oldValue) => emit("update:modelValue", oldValue ? value : null));
  8748. vue.watch(() => [props.filter, props.minDate, props.maxDate], () => {
  8749. vue.nextTick(updateInnerValue);
  8750. });
  8751. vue.watch(() => props.modelValue, (value) => {
  8752. var _a;
  8753. value = formatValue2(value);
  8754. if (value && value.valueOf() !== ((_a = currentDate.value) == null ? void 0 : _a.valueOf())) {
  8755. currentDate.value = value;
  8756. }
  8757. });
  8758. useExpose({
  8759. getPicker: () => picker.value && proxyPickerMethods(picker.value, updateInnerValue)
  8760. });
  8761. return () => vue.createVNode(Picker, vue.mergeProps({
  8762. "ref": picker,
  8763. "columns": columns.value,
  8764. "onChange": onChange,
  8765. "onCancel": onCancel,
  8766. "onConfirm": onConfirm
  8767. }, pick(props, pickerInheritKeys)), slots);
  8768. }
  8769. });
  8770. const [name$B, bem$C] = createNamespace("datetime-picker");
  8771. const timePickerPropKeys = Object.keys(stdin_default$J.props);
  8772. const datePickerPropKeys = Object.keys(stdin_default$I.props);
  8773. const datetimePickerProps = extend({}, stdin_default$J.props, stdin_default$I.props, {
  8774. modelValue: [String, Date]
  8775. });
  8776. var stdin_default$H = vue.defineComponent({
  8777. name: name$B,
  8778. props: datetimePickerProps,
  8779. setup(props, {
  8780. attrs,
  8781. slots
  8782. }) {
  8783. const root = vue.ref();
  8784. useExpose({
  8785. getPicker: () => {
  8786. var _a;
  8787. return (_a = root.value) == null ? void 0 : _a.getPicker();
  8788. }
  8789. });
  8790. return () => {
  8791. const isTimePicker = props.type === "time";
  8792. const Component = isTimePicker ? stdin_default$J : stdin_default$I;
  8793. const inheritProps = pick(props, isTimePicker ? timePickerPropKeys : datePickerPropKeys);
  8794. return vue.createVNode(Component, vue.mergeProps({
  8795. "ref": root,
  8796. "class": bem$C()
  8797. }, inheritProps, attrs), slots);
  8798. };
  8799. }
  8800. });
  8801. const DatetimePicker = withInstall(stdin_default$H);
  8802. const [name$A, bem$B, t$7] = createNamespace("dialog");
  8803. const dialogProps = extend({}, popupSharedProps, {
  8804. title: String,
  8805. theme: String,
  8806. width: numericProp,
  8807. message: [String, Function],
  8808. callback: Function,
  8809. allowHtml: Boolean,
  8810. className: unknownProp,
  8811. transition: makeStringProp("van-dialog-bounce"),
  8812. messageAlign: String,
  8813. closeOnPopstate: truthProp,
  8814. showCancelButton: Boolean,
  8815. cancelButtonText: String,
  8816. cancelButtonColor: String,
  8817. cancelButtonDisabled: Boolean,
  8818. confirmButtonText: String,
  8819. confirmButtonColor: String,
  8820. confirmButtonDisabled: Boolean,
  8821. showConfirmButton: truthProp,
  8822. closeOnClickOverlay: Boolean
  8823. });
  8824. const popupInheritKeys$1 = [...popupSharedPropKeys, "transition", "closeOnPopstate"];
  8825. var stdin_default$G = vue.defineComponent({
  8826. name: name$A,
  8827. props: dialogProps,
  8828. emits: ["confirm", "cancel", "keydown", "update:show"],
  8829. setup(props, {
  8830. emit,
  8831. slots
  8832. }) {
  8833. const root = vue.ref();
  8834. const loading = vue.reactive({
  8835. confirm: false,
  8836. cancel: false
  8837. });
  8838. const updateShow = (value) => emit("update:show", value);
  8839. const close = (action) => {
  8840. var _a;
  8841. updateShow(false);
  8842. (_a = props.callback) == null ? void 0 : _a.call(props, action);
  8843. };
  8844. const getActionHandler = (action) => () => {
  8845. if (!props.show) {
  8846. return;
  8847. }
  8848. emit(action);
  8849. if (props.beforeClose) {
  8850. loading[action] = true;
  8851. callInterceptor(props.beforeClose, {
  8852. args: [action],
  8853. done() {
  8854. close(action);
  8855. loading[action] = false;
  8856. },
  8857. canceled() {
  8858. loading[action] = false;
  8859. }
  8860. });
  8861. } else {
  8862. close(action);
  8863. }
  8864. };
  8865. const onCancel = getActionHandler("cancel");
  8866. const onConfirm = getActionHandler("confirm");
  8867. const onKeydown = vue.withKeys((event) => {
  8868. var _a, _b;
  8869. if (event.target !== ((_b = (_a = root.value) == null ? void 0 : _a.popupRef) == null ? void 0 : _b.value)) {
  8870. return;
  8871. }
  8872. const onEventType = {
  8873. Enter: props.showConfirmButton ? onConfirm : noop,
  8874. Escape: props.showCancelButton ? onCancel : noop
  8875. };
  8876. onEventType[event.key]();
  8877. emit("keydown", event);
  8878. }, ["enter", "esc"]);
  8879. const renderTitle = () => {
  8880. const title = slots.title ? slots.title() : props.title;
  8881. if (title) {
  8882. return vue.createVNode("div", {
  8883. "class": bem$B("header", {
  8884. isolated: !props.message && !slots.default
  8885. })
  8886. }, [title]);
  8887. }
  8888. };
  8889. const renderMessage = (hasTitle) => {
  8890. const {
  8891. message,
  8892. allowHtml,
  8893. messageAlign
  8894. } = props;
  8895. const classNames = bem$B("message", {
  8896. "has-title": hasTitle,
  8897. [messageAlign]: messageAlign
  8898. });
  8899. const content = isFunction(message) ? message() : message;
  8900. if (allowHtml && typeof content === "string") {
  8901. return vue.createVNode("div", {
  8902. "class": classNames,
  8903. "innerHTML": content
  8904. }, null);
  8905. }
  8906. return vue.createVNode("div", {
  8907. "class": classNames
  8908. }, [content]);
  8909. };
  8910. const renderContent = () => {
  8911. if (slots.default) {
  8912. return vue.createVNode("div", {
  8913. "class": bem$B("content")
  8914. }, [slots.default()]);
  8915. }
  8916. const {
  8917. title,
  8918. message,
  8919. allowHtml
  8920. } = props;
  8921. if (message) {
  8922. const hasTitle = !!(title || slots.title);
  8923. return vue.createVNode("div", {
  8924. "key": allowHtml ? 1 : 0,
  8925. "class": bem$B("content", {
  8926. isolated: !hasTitle
  8927. })
  8928. }, [renderMessage(hasTitle)]);
  8929. }
  8930. };
  8931. const renderButtons = () => vue.createVNode("div", {
  8932. "class": [BORDER_TOP, bem$B("footer")]
  8933. }, [props.showCancelButton && vue.createVNode(Button, {
  8934. "size": "large",
  8935. "text": props.cancelButtonText || t$7("cancel"),
  8936. "class": bem$B("cancel"),
  8937. "style": {
  8938. color: props.cancelButtonColor
  8939. },
  8940. "loading": loading.cancel,
  8941. "disabled": props.cancelButtonDisabled,
  8942. "onClick": onCancel
  8943. }, null), props.showConfirmButton && vue.createVNode(Button, {
  8944. "size": "large",
  8945. "text": props.confirmButtonText || t$7("confirm"),
  8946. "class": [bem$B("confirm"), {
  8947. [BORDER_LEFT]: props.showCancelButton
  8948. }],
  8949. "style": {
  8950. color: props.confirmButtonColor
  8951. },
  8952. "loading": loading.confirm,
  8953. "disabled": props.confirmButtonDisabled,
  8954. "onClick": onConfirm
  8955. }, null)]);
  8956. const renderRoundButtons = () => vue.createVNode(ActionBar, {
  8957. "class": bem$B("footer")
  8958. }, {
  8959. default: () => [props.showCancelButton && vue.createVNode(ActionBarButton, {
  8960. "type": "warning",
  8961. "text": props.cancelButtonText || t$7("cancel"),
  8962. "class": bem$B("cancel"),
  8963. "color": props.cancelButtonColor,
  8964. "loading": loading.cancel,
  8965. "disabled": props.cancelButtonDisabled,
  8966. "onClick": onCancel
  8967. }, null), props.showConfirmButton && vue.createVNode(ActionBarButton, {
  8968. "type": "danger",
  8969. "text": props.confirmButtonText || t$7("confirm"),
  8970. "class": bem$B("confirm"),
  8971. "color": props.confirmButtonColor,
  8972. "loading": loading.confirm,
  8973. "disabled": props.confirmButtonDisabled,
  8974. "onClick": onConfirm
  8975. }, null)]
  8976. });
  8977. const renderFooter = () => {
  8978. if (slots.footer) {
  8979. return slots.footer();
  8980. }
  8981. return props.theme === "round-button" ? renderRoundButtons() : renderButtons();
  8982. };
  8983. return () => {
  8984. const {
  8985. width,
  8986. title,
  8987. theme,
  8988. message,
  8989. className
  8990. } = props;
  8991. return vue.createVNode(Popup, vue.mergeProps({
  8992. "ref": root,
  8993. "role": "dialog",
  8994. "class": [bem$B([theme]), className],
  8995. "style": {
  8996. width: addUnit(width)
  8997. },
  8998. "tabindex": 0,
  8999. "aria-labelledby": title || message,
  9000. "onKeydown": onKeydown,
  9001. "onUpdate:show": updateShow
  9002. }, pick(props, popupInheritKeys$1)), {
  9003. default: () => [renderTitle(), renderContent(), renderFooter()]
  9004. });
  9005. };
  9006. }
  9007. });
  9008. let instance$2;
  9009. function initInstance$2() {
  9010. const Wrapper = {
  9011. setup() {
  9012. const {
  9013. state,
  9014. toggle
  9015. } = usePopupState();
  9016. return () => vue.createVNode(stdin_default$G, vue.mergeProps(state, {
  9017. "onUpdate:show": toggle
  9018. }), null);
  9019. }
  9020. };
  9021. ({
  9022. instance: instance$2
  9023. } = mountComponent(Wrapper));
  9024. }
  9025. function Dialog(options) {
  9026. if (!inBrowser) {
  9027. return Promise.resolve();
  9028. }
  9029. return new Promise((resolve, reject) => {
  9030. if (!instance$2) {
  9031. initInstance$2();
  9032. }
  9033. instance$2.open(extend({}, Dialog.currentOptions, options, {
  9034. callback: (action) => {
  9035. (action === "confirm" ? resolve : reject)(action);
  9036. }
  9037. }));
  9038. });
  9039. }
  9040. Dialog.defaultOptions = {
  9041. title: "",
  9042. width: "",
  9043. theme: null,
  9044. message: "",
  9045. overlay: true,
  9046. callback: null,
  9047. teleport: "body",
  9048. className: "",
  9049. allowHtml: false,
  9050. lockScroll: true,
  9051. transition: void 0,
  9052. beforeClose: null,
  9053. overlayClass: "",
  9054. overlayStyle: void 0,
  9055. messageAlign: "",
  9056. cancelButtonText: "",
  9057. cancelButtonColor: null,
  9058. cancelButtonDisabled: false,
  9059. confirmButtonText: "",
  9060. confirmButtonColor: null,
  9061. confirmButtonDisabled: false,
  9062. showConfirmButton: true,
  9063. showCancelButton: false,
  9064. closeOnPopstate: true,
  9065. closeOnClickOverlay: false
  9066. };
  9067. Dialog.currentOptions = extend({}, Dialog.defaultOptions);
  9068. Dialog.alert = Dialog;
  9069. Dialog.confirm = (options) => Dialog(extend({
  9070. showCancelButton: true
  9071. }, options));
  9072. Dialog.close = () => {
  9073. if (instance$2) {
  9074. instance$2.toggle(false);
  9075. }
  9076. };
  9077. Dialog.setDefaultOptions = (options) => {
  9078. extend(Dialog.currentOptions, options);
  9079. };
  9080. Dialog.resetDefaultOptions = () => {
  9081. Dialog.currentOptions = extend({}, Dialog.defaultOptions);
  9082. };
  9083. Dialog.Component = withInstall(stdin_default$G);
  9084. Dialog.install = (app) => {
  9085. app.use(Dialog.Component);
  9086. app.config.globalProperties.$dialog = Dialog;
  9087. };
  9088. const [name$z, bem$A] = createNamespace("divider");
  9089. const dividerProps = {
  9090. dashed: Boolean,
  9091. hairline: truthProp,
  9092. contentPosition: makeStringProp("center")
  9093. };
  9094. var stdin_default$F = vue.defineComponent({
  9095. name: name$z,
  9096. props: dividerProps,
  9097. setup(props, {
  9098. slots
  9099. }) {
  9100. return () => {
  9101. var _a;
  9102. return vue.createVNode("div", {
  9103. "role": "separator",
  9104. "class": bem$A({
  9105. dashed: props.dashed,
  9106. hairline: props.hairline,
  9107. [`content-${props.contentPosition}`]: !!slots.default
  9108. })
  9109. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
  9110. };
  9111. }
  9112. });
  9113. const Divider = withInstall(stdin_default$F);
  9114. const [name$y, bem$z] = createNamespace("dropdown-menu");
  9115. const dropdownMenuProps = {
  9116. overlay: truthProp,
  9117. zIndex: numericProp,
  9118. duration: makeNumericProp(0.2),
  9119. direction: makeStringProp("down"),
  9120. activeColor: String,
  9121. closeOnClickOutside: truthProp,
  9122. closeOnClickOverlay: truthProp
  9123. };
  9124. const DROPDOWN_KEY = Symbol(name$y);
  9125. var stdin_default$E = vue.defineComponent({
  9126. name: name$y,
  9127. props: dropdownMenuProps,
  9128. setup(props, {
  9129. slots
  9130. }) {
  9131. const id = useId();
  9132. const root = vue.ref();
  9133. const barRef = vue.ref();
  9134. const offset = vue.ref(0);
  9135. const {
  9136. children,
  9137. linkChildren
  9138. } = use.useChildren(DROPDOWN_KEY);
  9139. const scrollParent = use.useScrollParent(root);
  9140. const opened = vue.computed(() => children.some((item) => item.state.showWrapper));
  9141. const barStyle = vue.computed(() => {
  9142. if (opened.value && isDef(props.zIndex)) {
  9143. return {
  9144. zIndex: +props.zIndex + 1
  9145. };
  9146. }
  9147. });
  9148. const onClickAway = () => {
  9149. if (props.closeOnClickOutside) {
  9150. children.forEach((item) => {
  9151. item.toggle(false);
  9152. });
  9153. }
  9154. };
  9155. const updateOffset = () => {
  9156. if (barRef.value) {
  9157. const rect = use.useRect(barRef);
  9158. if (props.direction === "down") {
  9159. offset.value = rect.bottom;
  9160. } else {
  9161. offset.value = windowHeight.value - rect.top;
  9162. }
  9163. }
  9164. };
  9165. const onScroll = () => {
  9166. if (opened.value) {
  9167. updateOffset();
  9168. }
  9169. };
  9170. const toggleItem = (active) => {
  9171. children.forEach((item, index) => {
  9172. if (index === active) {
  9173. updateOffset();
  9174. item.toggle();
  9175. } else if (item.state.showPopup) {
  9176. item.toggle(false, {
  9177. immediate: true
  9178. });
  9179. }
  9180. });
  9181. };
  9182. const renderTitle = (item, index) => {
  9183. const {
  9184. showPopup
  9185. } = item.state;
  9186. const {
  9187. disabled,
  9188. titleClass
  9189. } = item;
  9190. return vue.createVNode("div", {
  9191. "id": `${id}-${index}`,
  9192. "role": "button",
  9193. "tabindex": disabled ? void 0 : 0,
  9194. "class": [bem$z("item", {
  9195. disabled
  9196. }), {
  9197. [HAPTICS_FEEDBACK]: !disabled
  9198. }],
  9199. "onClick": () => {
  9200. if (!disabled) {
  9201. toggleItem(index);
  9202. }
  9203. }
  9204. }, [vue.createVNode("span", {
  9205. "class": [bem$z("title", {
  9206. down: showPopup === (props.direction === "down"),
  9207. active: showPopup
  9208. }), titleClass],
  9209. "style": {
  9210. color: showPopup ? props.activeColor : ""
  9211. }
  9212. }, [vue.createVNode("div", {
  9213. "class": "van-ellipsis"
  9214. }, [item.renderTitle()])])]);
  9215. };
  9216. linkChildren({
  9217. id,
  9218. props,
  9219. offset
  9220. });
  9221. use.useClickAway(root, onClickAway);
  9222. use.useEventListener("scroll", onScroll, {
  9223. target: scrollParent,
  9224. passive: true
  9225. });
  9226. return () => {
  9227. var _a;
  9228. return vue.createVNode("div", {
  9229. "ref": root,
  9230. "class": bem$z()
  9231. }, [vue.createVNode("div", {
  9232. "ref": barRef,
  9233. "style": barStyle.value,
  9234. "class": bem$z("bar", {
  9235. opened: opened.value
  9236. })
  9237. }, [children.map(renderTitle)]), (_a = slots.default) == null ? void 0 : _a.call(slots)]);
  9238. };
  9239. }
  9240. });
  9241. const [name$x, bem$y] = createNamespace("dropdown-item");
  9242. const dropdownItemProps = {
  9243. title: String,
  9244. options: makeArrayProp(),
  9245. disabled: Boolean,
  9246. teleport: [String, Object],
  9247. lazyRender: truthProp,
  9248. modelValue: unknownProp,
  9249. titleClass: unknownProp
  9250. };
  9251. var stdin_default$D = vue.defineComponent({
  9252. name: name$x,
  9253. props: dropdownItemProps,
  9254. emits: ["open", "opened", "close", "closed", "change", "update:modelValue"],
  9255. setup(props, {
  9256. emit,
  9257. slots
  9258. }) {
  9259. const state = vue.reactive({
  9260. showPopup: false,
  9261. transition: true,
  9262. showWrapper: false
  9263. });
  9264. const {
  9265. parent,
  9266. index
  9267. } = use.useParent(DROPDOWN_KEY);
  9268. if (!parent) {
  9269. if (process.env.NODE_ENV !== "production") {
  9270. console.error("[Vant] <DropdownItem> must be a child component of <DropdownMenu>.");
  9271. }
  9272. return;
  9273. }
  9274. const getEmitter = (name2) => () => emit(name2);
  9275. const onOpen = getEmitter("open");
  9276. const onClose = getEmitter("close");
  9277. const onOpened = getEmitter("opened");
  9278. const onClosed = () => {
  9279. state.showWrapper = false;
  9280. emit("closed");
  9281. };
  9282. const onClickWrapper = (event) => {
  9283. if (props.teleport) {
  9284. event.stopPropagation();
  9285. }
  9286. };
  9287. const toggle = (show = !state.showPopup, options = {}) => {
  9288. if (show === state.showPopup) {
  9289. return;
  9290. }
  9291. state.showPopup = show;
  9292. state.transition = !options.immediate;
  9293. if (show) {
  9294. state.showWrapper = true;
  9295. }
  9296. };
  9297. const renderTitle = () => {
  9298. if (slots.title) {
  9299. return slots.title();
  9300. }
  9301. if (props.title) {
  9302. return props.title;
  9303. }
  9304. const match = props.options.find((option) => option.value === props.modelValue);
  9305. return match ? match.text : "";
  9306. };
  9307. const renderOption = (option) => {
  9308. const {
  9309. activeColor
  9310. } = parent.props;
  9311. const active = option.value === props.modelValue;
  9312. const onClick = () => {
  9313. state.showPopup = false;
  9314. if (option.value !== props.modelValue) {
  9315. emit("update:modelValue", option.value);
  9316. emit("change", option.value);
  9317. }
  9318. };
  9319. const renderIcon = () => {
  9320. if (active) {
  9321. return vue.createVNode(Icon, {
  9322. "class": bem$y("icon"),
  9323. "color": activeColor,
  9324. "name": "success"
  9325. }, null);
  9326. }
  9327. };
  9328. return vue.createVNode(Cell, {
  9329. "role": "menuitem",
  9330. "key": option.value,
  9331. "icon": option.icon,
  9332. "title": option.text,
  9333. "class": bem$y("option", {
  9334. active
  9335. }),
  9336. "style": {
  9337. color: active ? activeColor : ""
  9338. },
  9339. "tabindex": active ? 0 : -1,
  9340. "clickable": true,
  9341. "onClick": onClick
  9342. }, {
  9343. value: renderIcon
  9344. });
  9345. };
  9346. const renderContent = () => {
  9347. const {
  9348. offset
  9349. } = parent;
  9350. const {
  9351. zIndex,
  9352. overlay,
  9353. duration,
  9354. direction,
  9355. closeOnClickOverlay
  9356. } = parent.props;
  9357. const style = getZIndexStyle(zIndex);
  9358. if (direction === "down") {
  9359. style.top = `${offset.value}px`;
  9360. } else {
  9361. style.bottom = `${offset.value}px`;
  9362. }
  9363. return vue.withDirectives(vue.createVNode("div", {
  9364. "style": style,
  9365. "class": bem$y([direction]),
  9366. "onClick": onClickWrapper
  9367. }, [vue.createVNode(Popup, {
  9368. "show": state.showPopup,
  9369. "onUpdate:show": ($event) => state.showPopup = $event,
  9370. "role": "menu",
  9371. "class": bem$y("content"),
  9372. "overlay": overlay,
  9373. "position": direction === "down" ? "top" : "bottom",
  9374. "duration": state.transition ? duration : 0,
  9375. "lazyRender": props.lazyRender,
  9376. "overlayStyle": {
  9377. position: "absolute"
  9378. },
  9379. "aria-labelledby": `${parent.id}-${index.value}`,
  9380. "closeOnClickOverlay": closeOnClickOverlay,
  9381. "onOpen": onOpen,
  9382. "onClose": onClose,
  9383. "onOpened": onOpened,
  9384. "onClosed": onClosed
  9385. }, {
  9386. default: () => {
  9387. var _a;
  9388. return [props.options.map(renderOption), (_a = slots.default) == null ? void 0 : _a.call(slots)];
  9389. }
  9390. })]), [[vue.vShow, state.showWrapper]]);
  9391. };
  9392. useExpose({
  9393. state,
  9394. toggle,
  9395. renderTitle
  9396. });
  9397. return () => {
  9398. if (props.teleport) {
  9399. return vue.createVNode(vue.Teleport, {
  9400. "to": props.teleport
  9401. }, {
  9402. default: () => [renderContent()]
  9403. });
  9404. }
  9405. return renderContent();
  9406. };
  9407. }
  9408. });
  9409. const DropdownItem = withInstall(stdin_default$D);
  9410. const DropdownMenu = withInstall(stdin_default$E);
  9411. const [name$w, bem$x] = createNamespace("grid");
  9412. const gridProps = {
  9413. square: Boolean,
  9414. center: truthProp,
  9415. border: truthProp,
  9416. gutter: numericProp,
  9417. reverse: Boolean,
  9418. iconSize: numericProp,
  9419. direction: String,
  9420. clickable: Boolean,
  9421. columnNum: makeNumericProp(4)
  9422. };
  9423. const GRID_KEY = Symbol(name$w);
  9424. var stdin_default$C = vue.defineComponent({
  9425. name: name$w,
  9426. props: gridProps,
  9427. setup(props, {
  9428. slots
  9429. }) {
  9430. const {
  9431. linkChildren
  9432. } = use.useChildren(GRID_KEY);
  9433. linkChildren({
  9434. props
  9435. });
  9436. return () => {
  9437. var _a;
  9438. return vue.createVNode("div", {
  9439. "style": {
  9440. paddingLeft: addUnit(props.gutter)
  9441. },
  9442. "class": [bem$x(), {
  9443. [BORDER_TOP]: props.border && !props.gutter
  9444. }]
  9445. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
  9446. };
  9447. }
  9448. });
  9449. const Grid = withInstall(stdin_default$C);
  9450. const [name$v, bem$w] = createNamespace("grid-item");
  9451. const gridItemProps = extend({}, routeProps, {
  9452. dot: Boolean,
  9453. text: String,
  9454. icon: String,
  9455. badge: numericProp,
  9456. iconColor: String,
  9457. iconPrefix: String,
  9458. badgeProps: Object
  9459. });
  9460. var stdin_default$B = vue.defineComponent({
  9461. name: name$v,
  9462. props: gridItemProps,
  9463. setup(props, {
  9464. slots
  9465. }) {
  9466. const {
  9467. parent,
  9468. index
  9469. } = use.useParent(GRID_KEY);
  9470. const route2 = useRoute();
  9471. if (!parent) {
  9472. if (process.env.NODE_ENV !== "production") {
  9473. console.error("[Vant] <GridItem> must be a child component of <Grid>.");
  9474. }
  9475. return;
  9476. }
  9477. const rootStyle = vue.computed(() => {
  9478. const {
  9479. square,
  9480. gutter,
  9481. columnNum
  9482. } = parent.props;
  9483. const percent = `${100 / +columnNum}%`;
  9484. const style = {
  9485. flexBasis: percent
  9486. };
  9487. if (square) {
  9488. style.paddingTop = percent;
  9489. } else if (gutter) {
  9490. const gutterValue = addUnit(gutter);
  9491. style.paddingRight = gutterValue;
  9492. if (index.value >= columnNum) {
  9493. style.marginTop = gutterValue;
  9494. }
  9495. }
  9496. return style;
  9497. });
  9498. const contentStyle = vue.computed(() => {
  9499. const {
  9500. square,
  9501. gutter
  9502. } = parent.props;
  9503. if (square && gutter) {
  9504. const gutterValue = addUnit(gutter);
  9505. return {
  9506. right: gutterValue,
  9507. bottom: gutterValue,
  9508. height: "auto"
  9509. };
  9510. }
  9511. });
  9512. const renderIcon = () => {
  9513. if (slots.icon) {
  9514. return vue.createVNode(Badge, vue.mergeProps({
  9515. "dot": props.dot,
  9516. "content": props.badge
  9517. }, props.badgeProps), {
  9518. default: slots.icon
  9519. });
  9520. }
  9521. if (props.icon) {
  9522. return vue.createVNode(Icon, {
  9523. "dot": props.dot,
  9524. "name": props.icon,
  9525. "size": parent.props.iconSize,
  9526. "badge": props.badge,
  9527. "class": bem$w("icon"),
  9528. "color": props.iconColor,
  9529. "badgeProps": props.badgeProps,
  9530. "classPrefix": props.iconPrefix
  9531. }, null);
  9532. }
  9533. };
  9534. const renderText = () => {
  9535. if (slots.text) {
  9536. return slots.text();
  9537. }
  9538. if (props.text) {
  9539. return vue.createVNode("span", {
  9540. "class": bem$w("text")
  9541. }, [props.text]);
  9542. }
  9543. };
  9544. const renderContent = () => {
  9545. if (slots.default) {
  9546. return slots.default();
  9547. }
  9548. return [renderIcon(), renderText()];
  9549. };
  9550. return () => {
  9551. const {
  9552. center,
  9553. border,
  9554. square,
  9555. gutter,
  9556. reverse,
  9557. direction,
  9558. clickable
  9559. } = parent.props;
  9560. const classes = [bem$w("content", [direction, {
  9561. center,
  9562. square,
  9563. reverse,
  9564. clickable,
  9565. surround: border && gutter
  9566. }]), {
  9567. [BORDER]: border
  9568. }];
  9569. return vue.createVNode("div", {
  9570. "class": [bem$w({
  9571. square
  9572. })],
  9573. "style": rootStyle.value
  9574. }, [vue.createVNode("div", {
  9575. "role": clickable ? "button" : void 0,
  9576. "class": classes,
  9577. "style": contentStyle.value,
  9578. "tabindex": clickable ? 0 : void 0,
  9579. "onClick": route2
  9580. }, [renderContent()])]);
  9581. };
  9582. }
  9583. });
  9584. const GridItem = withInstall(stdin_default$B);
  9585. const getDistance = (touches) => Math.sqrt((touches[0].clientX - touches[1].clientX) ** 2 + (touches[0].clientY - touches[1].clientY) ** 2);
  9586. const bem$v = createNamespace("image-preview")[1];
  9587. var stdin_default$A = vue.defineComponent({
  9588. props: {
  9589. src: String,
  9590. show: Boolean,
  9591. active: Number,
  9592. minZoom: makeRequiredProp(numericProp),
  9593. maxZoom: makeRequiredProp(numericProp),
  9594. rootWidth: makeRequiredProp(Number),
  9595. rootHeight: makeRequiredProp(Number)
  9596. },
  9597. emits: ["scale", "close"],
  9598. setup(props, {
  9599. emit
  9600. }) {
  9601. const state = vue.reactive({
  9602. scale: 1,
  9603. moveX: 0,
  9604. moveY: 0,
  9605. moving: false,
  9606. zooming: false,
  9607. imageRatio: 0,
  9608. displayWidth: 0,
  9609. displayHeight: 0
  9610. });
  9611. const touch = useTouch();
  9612. const swipeItem = vue.ref();
  9613. const vertical = vue.computed(() => {
  9614. const {
  9615. rootWidth,
  9616. rootHeight
  9617. } = props;
  9618. const rootRatio = rootHeight / rootWidth;
  9619. return state.imageRatio > rootRatio;
  9620. });
  9621. const imageStyle = vue.computed(() => {
  9622. const {
  9623. scale,
  9624. moveX,
  9625. moveY,
  9626. moving,
  9627. zooming
  9628. } = state;
  9629. const style = {
  9630. transitionDuration: zooming || moving ? "0s" : ".3s"
  9631. };
  9632. if (scale !== 1) {
  9633. const offsetX = moveX / scale;
  9634. const offsetY = moveY / scale;
  9635. style.transform = `scale(${scale}, ${scale}) translate(${offsetX}px, ${offsetY}px)`;
  9636. }
  9637. return style;
  9638. });
  9639. const maxMoveX = vue.computed(() => {
  9640. if (state.imageRatio) {
  9641. const {
  9642. rootWidth,
  9643. rootHeight
  9644. } = props;
  9645. const displayWidth = vertical.value ? rootHeight / state.imageRatio : rootWidth;
  9646. return Math.max(0, (state.scale * displayWidth - rootWidth) / 2);
  9647. }
  9648. return 0;
  9649. });
  9650. const maxMoveY = vue.computed(() => {
  9651. if (state.imageRatio) {
  9652. const {
  9653. rootWidth,
  9654. rootHeight
  9655. } = props;
  9656. const displayHeight = vertical.value ? rootHeight : rootWidth * state.imageRatio;
  9657. return Math.max(0, (state.scale * displayHeight - rootHeight) / 2);
  9658. }
  9659. return 0;
  9660. });
  9661. const setScale = (scale) => {
  9662. scale = clamp(scale, +props.minZoom, +props.maxZoom + 1);
  9663. if (scale !== state.scale) {
  9664. state.scale = scale;
  9665. emit("scale", {
  9666. scale,
  9667. index: props.active
  9668. });
  9669. }
  9670. };
  9671. const resetScale = () => {
  9672. setScale(1);
  9673. state.moveX = 0;
  9674. state.moveY = 0;
  9675. };
  9676. const toggleScale = () => {
  9677. const scale = state.scale > 1 ? 1 : 2;
  9678. setScale(scale);
  9679. state.moveX = 0;
  9680. state.moveY = 0;
  9681. };
  9682. let fingerNum;
  9683. let startMoveX;
  9684. let startMoveY;
  9685. let startScale;
  9686. let startDistance;
  9687. let doubleTapTimer;
  9688. let touchStartTime;
  9689. const onTouchStart = (event) => {
  9690. const {
  9691. touches
  9692. } = event;
  9693. const {
  9694. offsetX
  9695. } = touch;
  9696. touch.start(event);
  9697. fingerNum = touches.length;
  9698. startMoveX = state.moveX;
  9699. startMoveY = state.moveY;
  9700. touchStartTime = Date.now();
  9701. state.moving = fingerNum === 1 && state.scale !== 1;
  9702. state.zooming = fingerNum === 2 && !offsetX.value;
  9703. if (state.zooming) {
  9704. startScale = state.scale;
  9705. startDistance = getDistance(event.touches);
  9706. }
  9707. };
  9708. const onTouchMove = (event) => {
  9709. const {
  9710. touches
  9711. } = event;
  9712. touch.move(event);
  9713. if (state.moving || state.zooming) {
  9714. preventDefault(event, true);
  9715. }
  9716. if (state.moving) {
  9717. const {
  9718. deltaX,
  9719. deltaY
  9720. } = touch;
  9721. const moveX = deltaX.value + startMoveX;
  9722. const moveY = deltaY.value + startMoveY;
  9723. state.moveX = clamp(moveX, -maxMoveX.value, maxMoveX.value);
  9724. state.moveY = clamp(moveY, -maxMoveY.value, maxMoveY.value);
  9725. }
  9726. if (state.zooming && touches.length === 2) {
  9727. const distance = getDistance(touches);
  9728. const scale = startScale * distance / startDistance;
  9729. setScale(scale);
  9730. }
  9731. };
  9732. const checkTap = () => {
  9733. if (fingerNum > 1) {
  9734. return;
  9735. }
  9736. const {
  9737. offsetX,
  9738. offsetY
  9739. } = touch;
  9740. const deltaTime = Date.now() - touchStartTime;
  9741. const TAP_TIME = 250;
  9742. const TAP_OFFSET = 5;
  9743. if (offsetX.value < TAP_OFFSET && offsetY.value < TAP_OFFSET && deltaTime < TAP_TIME) {
  9744. if (doubleTapTimer) {
  9745. clearTimeout(doubleTapTimer);
  9746. doubleTapTimer = null;
  9747. toggleScale();
  9748. } else {
  9749. doubleTapTimer = setTimeout(() => {
  9750. emit("close");
  9751. doubleTapTimer = null;
  9752. }, TAP_TIME);
  9753. }
  9754. }
  9755. };
  9756. const onTouchEnd = (event) => {
  9757. let stopPropagation2 = false;
  9758. if (state.moving || state.zooming) {
  9759. stopPropagation2 = true;
  9760. if (state.moving && startMoveX === state.moveX && startMoveY === state.moveY) {
  9761. stopPropagation2 = false;
  9762. }
  9763. if (!event.touches.length) {
  9764. if (state.zooming) {
  9765. state.moveX = clamp(state.moveX, -maxMoveX.value, maxMoveX.value);
  9766. state.moveY = clamp(state.moveY, -maxMoveY.value, maxMoveY.value);
  9767. state.zooming = false;
  9768. }
  9769. state.moving = false;
  9770. startMoveX = 0;
  9771. startMoveY = 0;
  9772. startScale = 1;
  9773. if (state.scale < 1) {
  9774. resetScale();
  9775. }
  9776. if (state.scale > props.maxZoom) {
  9777. state.scale = +props.maxZoom;
  9778. }
  9779. }
  9780. }
  9781. preventDefault(event, stopPropagation2);
  9782. checkTap();
  9783. touch.reset();
  9784. };
  9785. const onLoad = (event) => {
  9786. const {
  9787. naturalWidth,
  9788. naturalHeight
  9789. } = event.target;
  9790. state.imageRatio = naturalHeight / naturalWidth;
  9791. };
  9792. vue.watch(() => props.active, resetScale);
  9793. vue.watch(() => props.show, (value) => {
  9794. if (!value) {
  9795. resetScale();
  9796. }
  9797. });
  9798. use.useEventListener("touchmove", onTouchMove, {
  9799. target: vue.computed(() => {
  9800. var _a;
  9801. return (_a = swipeItem.value) == null ? void 0 : _a.$el;
  9802. })
  9803. });
  9804. return () => {
  9805. const imageSlots = {
  9806. loading: () => vue.createVNode(Loading, {
  9807. "type": "spinner"
  9808. }, null)
  9809. };
  9810. return vue.createVNode(SwipeItem, {
  9811. "ref": swipeItem,
  9812. "class": bem$v("swipe-item"),
  9813. "onTouchstartPassive": onTouchStart,
  9814. "onTouchend": onTouchEnd,
  9815. "onTouchcancel": onTouchEnd
  9816. }, {
  9817. default: () => [vue.createVNode(Image$1, {
  9818. "src": props.src,
  9819. "fit": "contain",
  9820. "class": bem$v("image", {
  9821. vertical: vertical.value
  9822. }),
  9823. "style": imageStyle.value,
  9824. "onLoad": onLoad
  9825. }, imageSlots)]
  9826. });
  9827. };
  9828. }
  9829. });
  9830. const [name$u, bem$u] = createNamespace("image-preview");
  9831. const popupProps$1 = ["show", "transition", "overlayStyle", "closeOnPopstate"];
  9832. const imagePreviewProps = {
  9833. show: Boolean,
  9834. loop: truthProp,
  9835. images: makeArrayProp(),
  9836. minZoom: makeNumericProp(1 / 3),
  9837. maxZoom: makeNumericProp(3),
  9838. overlay: truthProp,
  9839. closeable: Boolean,
  9840. showIndex: truthProp,
  9841. className: unknownProp,
  9842. closeIcon: makeStringProp("clear"),
  9843. transition: String,
  9844. beforeClose: Function,
  9845. overlayClass: unknownProp,
  9846. overlayStyle: Object,
  9847. swipeDuration: makeNumericProp(300),
  9848. startPosition: makeNumericProp(0),
  9849. showIndicators: Boolean,
  9850. closeOnPopstate: truthProp,
  9851. closeIconPosition: makeStringProp("top-right")
  9852. };
  9853. var stdin_default$z = vue.defineComponent({
  9854. name: name$u,
  9855. props: imagePreviewProps,
  9856. emits: ["scale", "close", "closed", "change", "update:show"],
  9857. setup(props, {
  9858. emit,
  9859. slots
  9860. }) {
  9861. const swipeRef = vue.ref();
  9862. const state = vue.reactive({
  9863. active: 0,
  9864. rootWidth: 0,
  9865. rootHeight: 0
  9866. });
  9867. const resize = () => {
  9868. if (swipeRef.value) {
  9869. const rect = use.useRect(swipeRef.value.$el);
  9870. state.rootWidth = rect.width;
  9871. state.rootHeight = rect.height;
  9872. swipeRef.value.resize();
  9873. }
  9874. };
  9875. const emitScale = (args) => emit("scale", args);
  9876. const updateShow = (show) => emit("update:show", show);
  9877. const emitClose = () => {
  9878. callInterceptor(props.beforeClose, {
  9879. args: [state.active],
  9880. done: () => updateShow(false)
  9881. });
  9882. };
  9883. const setActive = (active) => {
  9884. if (active !== state.active) {
  9885. state.active = active;
  9886. emit("change", active);
  9887. }
  9888. };
  9889. const renderIndex = () => {
  9890. if (props.showIndex) {
  9891. return vue.createVNode("div", {
  9892. "class": bem$u("index")
  9893. }, [slots.index ? slots.index({
  9894. index: state.active
  9895. }) : `${state.active + 1} / ${props.images.length}`]);
  9896. }
  9897. };
  9898. const renderCover = () => {
  9899. if (slots.cover) {
  9900. return vue.createVNode("div", {
  9901. "class": bem$u("cover")
  9902. }, [slots.cover()]);
  9903. }
  9904. };
  9905. const renderImages = () => vue.createVNode(Swipe, {
  9906. "ref": swipeRef,
  9907. "lazyRender": true,
  9908. "loop": props.loop,
  9909. "class": bem$u("swipe"),
  9910. "duration": props.swipeDuration,
  9911. "initialSwipe": props.startPosition,
  9912. "showIndicators": props.showIndicators,
  9913. "indicatorColor": "white",
  9914. "onChange": setActive
  9915. }, {
  9916. default: () => [props.images.map((image) => vue.createVNode(stdin_default$A, {
  9917. "src": image,
  9918. "show": props.show,
  9919. "active": state.active,
  9920. "maxZoom": props.maxZoom,
  9921. "minZoom": props.minZoom,
  9922. "rootWidth": state.rootWidth,
  9923. "rootHeight": state.rootHeight,
  9924. "onScale": emitScale,
  9925. "onClose": emitClose
  9926. }, null))]
  9927. });
  9928. const renderClose = () => {
  9929. if (props.closeable) {
  9930. return vue.createVNode(Icon, {
  9931. "role": "button",
  9932. "name": props.closeIcon,
  9933. "class": [bem$u("close-icon", props.closeIconPosition), HAPTICS_FEEDBACK],
  9934. "onClick": emitClose
  9935. }, null);
  9936. }
  9937. };
  9938. const onClosed = () => emit("closed");
  9939. const swipeTo = (index, options) => {
  9940. var _a;
  9941. return (_a = swipeRef.value) == null ? void 0 : _a.swipeTo(index, options);
  9942. };
  9943. useExpose({
  9944. swipeTo
  9945. });
  9946. vue.onMounted(resize);
  9947. vue.watch([windowWidth, windowHeight], resize);
  9948. vue.watch(() => props.startPosition, (value) => setActive(+value));
  9949. vue.watch(() => props.show, (value) => {
  9950. const {
  9951. images,
  9952. startPosition
  9953. } = props;
  9954. if (value) {
  9955. setActive(+startPosition);
  9956. vue.nextTick(() => {
  9957. resize();
  9958. swipeTo(+startPosition, {
  9959. immediate: true
  9960. });
  9961. });
  9962. } else {
  9963. emit("close", {
  9964. index: state.active,
  9965. url: images[state.active]
  9966. });
  9967. }
  9968. });
  9969. return () => vue.createVNode(Popup, vue.mergeProps({
  9970. "class": [bem$u(), props.className],
  9971. "overlayClass": [bem$u("overlay"), props.overlayClass],
  9972. "onClosed": onClosed,
  9973. "onUpdate:show": updateShow
  9974. }, pick(props, popupProps$1)), {
  9975. default: () => [renderClose(), renderImages(), renderIndex(), renderCover()]
  9976. });
  9977. }
  9978. });
  9979. let instance$1;
  9980. const defaultConfig = {
  9981. loop: true,
  9982. images: [],
  9983. maxZoom: 3,
  9984. minZoom: 1 / 3,
  9985. onScale: void 0,
  9986. onClose: void 0,
  9987. onChange: void 0,
  9988. teleport: "body",
  9989. className: "",
  9990. showIndex: true,
  9991. closeable: false,
  9992. closeIcon: "clear",
  9993. transition: void 0,
  9994. beforeClose: void 0,
  9995. overlayStyle: void 0,
  9996. overlayClass: void 0,
  9997. startPosition: 0,
  9998. swipeDuration: 300,
  9999. showIndicators: false,
  10000. closeOnPopstate: true,
  10001. closeIconPosition: "top-right"
  10002. };
  10003. function initInstance$1() {
  10004. ({
  10005. instance: instance$1
  10006. } = mountComponent({
  10007. setup() {
  10008. const {
  10009. state,
  10010. toggle
  10011. } = usePopupState();
  10012. const onClosed = () => {
  10013. state.images = [];
  10014. };
  10015. return () => vue.createVNode(stdin_default$z, vue.mergeProps(state, {
  10016. "onClosed": onClosed,
  10017. "onUpdate:show": toggle
  10018. }), null);
  10019. }
  10020. }));
  10021. }
  10022. const ImagePreview = (options, startPosition = 0) => {
  10023. if (!inBrowser) {
  10024. return;
  10025. }
  10026. if (!instance$1) {
  10027. initInstance$1();
  10028. }
  10029. options = Array.isArray(options) ? {
  10030. images: options,
  10031. startPosition
  10032. } : options;
  10033. instance$1.open(extend({}, defaultConfig, options));
  10034. return instance$1;
  10035. };
  10036. ImagePreview.Component = withInstall(stdin_default$z);
  10037. ImagePreview.install = (app) => {
  10038. app.use(ImagePreview.Component);
  10039. };
  10040. function genAlphabet() {
  10041. const charCodeOfA = "A".charCodeAt(0);
  10042. const indexList = Array(26).fill("").map((_, i) => String.fromCharCode(charCodeOfA + i));
  10043. return indexList;
  10044. }
  10045. const [name$t, bem$t] = createNamespace("index-bar");
  10046. const indexBarProps = {
  10047. sticky: truthProp,
  10048. zIndex: numericProp,
  10049. teleport: [String, Object],
  10050. highlightColor: String,
  10051. stickyOffsetTop: makeNumberProp(0),
  10052. indexList: {
  10053. type: Array,
  10054. default: genAlphabet
  10055. }
  10056. };
  10057. const INDEX_BAR_KEY = Symbol(name$t);
  10058. var stdin_default$y = vue.defineComponent({
  10059. name: name$t,
  10060. props: indexBarProps,
  10061. emits: ["select", "change"],
  10062. setup(props, {
  10063. emit,
  10064. slots
  10065. }) {
  10066. const root = vue.ref();
  10067. const sidebar = vue.ref();
  10068. const activeAnchor = vue.ref("");
  10069. const touch = useTouch();
  10070. const scrollParent = use.useScrollParent(root);
  10071. const {
  10072. children,
  10073. linkChildren
  10074. } = use.useChildren(INDEX_BAR_KEY);
  10075. let selectActiveIndex;
  10076. linkChildren({
  10077. props
  10078. });
  10079. const sidebarStyle = vue.computed(() => {
  10080. if (isDef(props.zIndex)) {
  10081. return {
  10082. zIndex: +props.zIndex + 1
  10083. };
  10084. }
  10085. });
  10086. const highlightStyle = vue.computed(() => {
  10087. if (props.highlightColor) {
  10088. return {
  10089. color: props.highlightColor
  10090. };
  10091. }
  10092. });
  10093. const getActiveAnchor = (scrollTop, rects) => {
  10094. for (let i = children.length - 1; i >= 0; i--) {
  10095. const prevHeight = i > 0 ? rects[i - 1].height : 0;
  10096. const reachTop = props.sticky ? prevHeight + props.stickyOffsetTop : 0;
  10097. if (scrollTop + reachTop >= rects[i].top) {
  10098. return i;
  10099. }
  10100. }
  10101. return -1;
  10102. };
  10103. const getMatchAnchor = (index) => children.find((item) => String(item.index) === index);
  10104. const onScroll = () => {
  10105. if (isHidden(root)) {
  10106. return;
  10107. }
  10108. const {
  10109. sticky,
  10110. indexList
  10111. } = props;
  10112. const scrollTop = getScrollTop(scrollParent.value);
  10113. const scrollParentRect = use.useRect(scrollParent);
  10114. const rects = children.map((item) => item.getRect(scrollParent.value, scrollParentRect));
  10115. let active = -1;
  10116. if (selectActiveIndex) {
  10117. const match = getMatchAnchor(selectActiveIndex);
  10118. if (match) {
  10119. const rect = match.getRect(scrollParent.value, scrollParentRect);
  10120. active = getActiveAnchor(rect.top, rects);
  10121. }
  10122. } else {
  10123. active = getActiveAnchor(scrollTop, rects);
  10124. }
  10125. activeAnchor.value = indexList[active];
  10126. if (sticky) {
  10127. children.forEach((item, index) => {
  10128. const {
  10129. state,
  10130. $el
  10131. } = item;
  10132. if (index === active || index === active - 1) {
  10133. const rect = $el.getBoundingClientRect();
  10134. state.left = rect.left;
  10135. state.width = rect.width;
  10136. } else {
  10137. state.left = null;
  10138. state.width = null;
  10139. }
  10140. if (index === active) {
  10141. state.active = true;
  10142. state.top = Math.max(props.stickyOffsetTop, rects[index].top - scrollTop) + scrollParentRect.top;
  10143. } else if (index === active - 1 && selectActiveIndex === "") {
  10144. const activeItemTop = rects[active].top - scrollTop;
  10145. state.active = activeItemTop > 0;
  10146. state.top = activeItemTop + scrollParentRect.top - rects[index].height;
  10147. } else {
  10148. state.active = false;
  10149. }
  10150. });
  10151. }
  10152. selectActiveIndex = "";
  10153. };
  10154. const init = () => {
  10155. vue.nextTick(onScroll);
  10156. };
  10157. use.useEventListener("scroll", onScroll, {
  10158. target: scrollParent,
  10159. passive: true
  10160. });
  10161. vue.onMounted(init);
  10162. vue.watch(() => props.indexList, init);
  10163. vue.watch(activeAnchor, (value) => {
  10164. if (value) {
  10165. emit("change", value);
  10166. }
  10167. });
  10168. const renderIndexes = () => props.indexList.map((index) => {
  10169. const active = index === activeAnchor.value;
  10170. return vue.createVNode("span", {
  10171. "class": bem$t("index", {
  10172. active
  10173. }),
  10174. "style": active ? highlightStyle.value : void 0,
  10175. "data-index": index
  10176. }, [index]);
  10177. });
  10178. const scrollTo = (index) => {
  10179. selectActiveIndex = String(index);
  10180. const match = getMatchAnchor(selectActiveIndex);
  10181. if (match) {
  10182. const scrollTop = getScrollTop(scrollParent.value);
  10183. const scrollParentRect = use.useRect(scrollParent);
  10184. const {
  10185. offsetHeight
  10186. } = document.documentElement;
  10187. match.$el.scrollIntoView();
  10188. if (scrollTop === offsetHeight - scrollParentRect.height) {
  10189. onScroll();
  10190. return;
  10191. }
  10192. if (props.sticky && props.stickyOffsetTop) {
  10193. setRootScrollTop(getRootScrollTop() - props.stickyOffsetTop);
  10194. }
  10195. emit("select", match.index);
  10196. }
  10197. };
  10198. const scrollToElement = (element) => {
  10199. const {
  10200. index
  10201. } = element.dataset;
  10202. if (index) {
  10203. scrollTo(index);
  10204. }
  10205. };
  10206. const onClickSidebar = (event) => {
  10207. scrollToElement(event.target);
  10208. };
  10209. let touchActiveIndex;
  10210. const onTouchMove = (event) => {
  10211. touch.move(event);
  10212. if (touch.isVertical()) {
  10213. preventDefault(event);
  10214. const {
  10215. clientX,
  10216. clientY
  10217. } = event.touches[0];
  10218. const target = document.elementFromPoint(clientX, clientY);
  10219. if (target) {
  10220. const {
  10221. index
  10222. } = target.dataset;
  10223. if (index && touchActiveIndex !== index) {
  10224. touchActiveIndex = index;
  10225. scrollToElement(target);
  10226. }
  10227. }
  10228. }
  10229. };
  10230. const renderSidebar = () => vue.createVNode("div", {
  10231. "ref": sidebar,
  10232. "class": bem$t("sidebar"),
  10233. "style": sidebarStyle.value,
  10234. "onClick": onClickSidebar,
  10235. "onTouchstartPassive": touch.start
  10236. }, [renderIndexes()]);
  10237. useExpose({
  10238. scrollTo
  10239. });
  10240. use.useEventListener("touchmove", onTouchMove, {
  10241. target: sidebar
  10242. });
  10243. return () => {
  10244. var _a;
  10245. return vue.createVNode("div", {
  10246. "ref": root,
  10247. "class": bem$t()
  10248. }, [props.teleport ? vue.createVNode(vue.Teleport, {
  10249. "to": props.teleport
  10250. }, {
  10251. default: () => [renderSidebar()]
  10252. }) : renderSidebar(), (_a = slots.default) == null ? void 0 : _a.call(slots)]);
  10253. };
  10254. }
  10255. });
  10256. const [name$s, bem$s] = createNamespace("index-anchor");
  10257. const indexAnchorProps = {
  10258. index: numericProp
  10259. };
  10260. var stdin_default$x = vue.defineComponent({
  10261. name: name$s,
  10262. props: indexAnchorProps,
  10263. setup(props, {
  10264. slots
  10265. }) {
  10266. const state = vue.reactive({
  10267. top: 0,
  10268. left: null,
  10269. rect: {
  10270. top: 0,
  10271. height: 0
  10272. },
  10273. width: null,
  10274. active: false
  10275. });
  10276. const root = vue.ref();
  10277. const {
  10278. parent
  10279. } = use.useParent(INDEX_BAR_KEY);
  10280. if (!parent) {
  10281. if (process.env.NODE_ENV !== "production") {
  10282. console.error("[Vant] <IndexAnchor> must be a child component of <IndexBar>.");
  10283. }
  10284. return;
  10285. }
  10286. const isSticky = () => state.active && parent.props.sticky;
  10287. const anchorStyle = vue.computed(() => {
  10288. const {
  10289. zIndex,
  10290. highlightColor
  10291. } = parent.props;
  10292. if (isSticky()) {
  10293. return extend(getZIndexStyle(zIndex), {
  10294. left: state.left ? `${state.left}px` : void 0,
  10295. width: state.width ? `${state.width}px` : void 0,
  10296. transform: state.top ? `translate3d(0, ${state.top}px, 0)` : void 0,
  10297. color: highlightColor
  10298. });
  10299. }
  10300. });
  10301. const getRect = (scrollParent, scrollParentRect) => {
  10302. const rootRect = use.useRect(root);
  10303. state.rect.height = rootRect.height;
  10304. if (scrollParent === window || scrollParent === document.body) {
  10305. state.rect.top = rootRect.top + getRootScrollTop();
  10306. } else {
  10307. state.rect.top = rootRect.top + getScrollTop(scrollParent) - scrollParentRect.top;
  10308. }
  10309. return state.rect;
  10310. };
  10311. useExpose({
  10312. state,
  10313. getRect
  10314. });
  10315. return () => {
  10316. const sticky = isSticky();
  10317. return vue.createVNode("div", {
  10318. "ref": root,
  10319. "style": {
  10320. height: sticky ? `${state.rect.height}px` : void 0
  10321. }
  10322. }, [vue.createVNode("div", {
  10323. "style": anchorStyle.value,
  10324. "class": [bem$s({
  10325. sticky
  10326. }), {
  10327. [BORDER_BOTTOM]: sticky
  10328. }]
  10329. }, [slots.default ? slots.default() : props.index])]);
  10330. };
  10331. }
  10332. });
  10333. const IndexAnchor = withInstall(stdin_default$x);
  10334. const IndexBar = withInstall(stdin_default$y);
  10335. const [name$r, bem$r, t$6] = createNamespace("list");
  10336. const listProps = {
  10337. error: Boolean,
  10338. offset: makeNumericProp(300),
  10339. loading: Boolean,
  10340. finished: Boolean,
  10341. errorText: String,
  10342. direction: makeStringProp("down"),
  10343. loadingText: String,
  10344. finishedText: String,
  10345. immediateCheck: truthProp
  10346. };
  10347. var stdin_default$w = vue.defineComponent({
  10348. name: name$r,
  10349. props: listProps,
  10350. emits: ["load", "update:error", "update:loading"],
  10351. setup(props, {
  10352. emit,
  10353. slots
  10354. }) {
  10355. const loading = vue.ref(false);
  10356. const root = vue.ref();
  10357. const placeholder = vue.ref();
  10358. const tabStatus = useTabStatus();
  10359. const scrollParent = use.useScrollParent(root);
  10360. const check = () => {
  10361. vue.nextTick(() => {
  10362. if (loading.value || props.finished || props.error || (tabStatus == null ? void 0 : tabStatus.value) === false) {
  10363. return;
  10364. }
  10365. const {
  10366. offset,
  10367. direction
  10368. } = props;
  10369. const scrollParentRect = use.useRect(scrollParent);
  10370. if (!scrollParentRect.height || isHidden(root)) {
  10371. return;
  10372. }
  10373. let isReachEdge = false;
  10374. const placeholderRect = use.useRect(placeholder);
  10375. if (direction === "up") {
  10376. isReachEdge = scrollParentRect.top - placeholderRect.top <= offset;
  10377. } else {
  10378. isReachEdge = placeholderRect.bottom - scrollParentRect.bottom <= offset;
  10379. }
  10380. if (isReachEdge) {
  10381. loading.value = true;
  10382. emit("update:loading", true);
  10383. emit("load");
  10384. }
  10385. });
  10386. };
  10387. const renderFinishedText = () => {
  10388. if (props.finished) {
  10389. const text = slots.finished ? slots.finished() : props.finishedText;
  10390. if (text) {
  10391. return vue.createVNode("div", {
  10392. "class": bem$r("finished-text")
  10393. }, [text]);
  10394. }
  10395. }
  10396. };
  10397. const clickErrorText = () => {
  10398. emit("update:error", false);
  10399. check();
  10400. };
  10401. const renderErrorText = () => {
  10402. if (props.error) {
  10403. const text = slots.error ? slots.error() : props.errorText;
  10404. if (text) {
  10405. return vue.createVNode("div", {
  10406. "role": "button",
  10407. "class": bem$r("error-text"),
  10408. "tabindex": 0,
  10409. "onClick": clickErrorText
  10410. }, [text]);
  10411. }
  10412. }
  10413. };
  10414. const renderLoading = () => {
  10415. if (loading.value && !props.finished) {
  10416. return vue.createVNode("div", {
  10417. "class": bem$r("loading")
  10418. }, [slots.loading ? slots.loading() : vue.createVNode(Loading, {
  10419. "class": bem$r("loading-icon")
  10420. }, {
  10421. default: () => [props.loadingText || t$6("loading")]
  10422. })]);
  10423. }
  10424. };
  10425. vue.watch(() => [props.loading, props.finished, props.error], check);
  10426. if (tabStatus) {
  10427. vue.watch(tabStatus, (tabActive) => {
  10428. if (tabActive) {
  10429. check();
  10430. }
  10431. });
  10432. }
  10433. vue.onUpdated(() => {
  10434. loading.value = props.loading;
  10435. });
  10436. vue.onMounted(() => {
  10437. if (props.immediateCheck) {
  10438. check();
  10439. }
  10440. });
  10441. useExpose({
  10442. check
  10443. });
  10444. use.useEventListener("scroll", check, {
  10445. target: scrollParent,
  10446. passive: true
  10447. });
  10448. return () => {
  10449. var _a;
  10450. const Content = (_a = slots.default) == null ? void 0 : _a.call(slots);
  10451. const Placeholder = vue.createVNode("div", {
  10452. "ref": placeholder,
  10453. "class": bem$r("placeholder")
  10454. }, null);
  10455. return vue.createVNode("div", {
  10456. "ref": root,
  10457. "role": "feed",
  10458. "class": bem$r(),
  10459. "aria-busy": loading.value
  10460. }, [props.direction === "down" ? Content : Placeholder, renderLoading(), renderFinishedText(), renderErrorText(), props.direction === "up" ? Content : Placeholder]);
  10461. };
  10462. }
  10463. });
  10464. const List = withInstall(stdin_default$w);
  10465. const [name$q, bem$q] = createNamespace("nav-bar");
  10466. const navBarProps = {
  10467. title: String,
  10468. fixed: Boolean,
  10469. zIndex: numericProp,
  10470. border: truthProp,
  10471. leftText: String,
  10472. rightText: String,
  10473. leftArrow: Boolean,
  10474. placeholder: Boolean,
  10475. safeAreaInsetTop: Boolean
  10476. };
  10477. var stdin_default$v = vue.defineComponent({
  10478. name: name$q,
  10479. props: navBarProps,
  10480. emits: ["click-left", "click-right"],
  10481. setup(props, {
  10482. emit,
  10483. slots
  10484. }) {
  10485. const navBarRef = vue.ref();
  10486. const renderPlaceholder = usePlaceholder(navBarRef, bem$q);
  10487. const onClickLeft = (event) => emit("click-left", event);
  10488. const onClickRight = (event) => emit("click-right", event);
  10489. const renderLeft = () => {
  10490. if (slots.left) {
  10491. return slots.left();
  10492. }
  10493. return [props.leftArrow && vue.createVNode(Icon, {
  10494. "class": bem$q("arrow"),
  10495. "name": "arrow-left"
  10496. }, null), props.leftText && vue.createVNode("span", {
  10497. "class": bem$q("text")
  10498. }, [props.leftText])];
  10499. };
  10500. const renderRight = () => {
  10501. if (slots.right) {
  10502. return slots.right();
  10503. }
  10504. return vue.createVNode("span", {
  10505. "class": bem$q("text")
  10506. }, [props.rightText]);
  10507. };
  10508. const renderNavBar = () => {
  10509. const {
  10510. title,
  10511. fixed,
  10512. border,
  10513. zIndex
  10514. } = props;
  10515. const style = getZIndexStyle(zIndex);
  10516. const hasLeft = props.leftArrow || props.leftText || slots.left;
  10517. const hasRight = props.rightText || slots.right;
  10518. return vue.createVNode("div", {
  10519. "ref": navBarRef,
  10520. "style": style,
  10521. "class": [bem$q({
  10522. fixed
  10523. }), {
  10524. [BORDER_BOTTOM]: border,
  10525. "van-safe-area-top": props.safeAreaInsetTop
  10526. }]
  10527. }, [vue.createVNode("div", {
  10528. "class": bem$q("content")
  10529. }, [hasLeft && vue.createVNode("div", {
  10530. "class": [bem$q("left"), HAPTICS_FEEDBACK],
  10531. "onClick": onClickLeft
  10532. }, [renderLeft()]), vue.createVNode("div", {
  10533. "class": [bem$q("title"), "van-ellipsis"]
  10534. }, [slots.title ? slots.title() : title]), hasRight && vue.createVNode("div", {
  10535. "class": [bem$q("right"), HAPTICS_FEEDBACK],
  10536. "onClick": onClickRight
  10537. }, [renderRight()])])]);
  10538. };
  10539. return () => {
  10540. if (props.fixed && props.placeholder) {
  10541. return renderPlaceholder(renderNavBar);
  10542. }
  10543. return renderNavBar();
  10544. };
  10545. }
  10546. });
  10547. const NavBar = withInstall(stdin_default$v);
  10548. const [name$p, bem$p] = createNamespace("notice-bar");
  10549. const noticeBarProps = {
  10550. text: String,
  10551. mode: String,
  10552. color: String,
  10553. delay: makeNumericProp(1),
  10554. speed: makeNumericProp(60),
  10555. leftIcon: String,
  10556. wrapable: Boolean,
  10557. background: String,
  10558. scrollable: {
  10559. type: Boolean,
  10560. default: null
  10561. }
  10562. };
  10563. var stdin_default$u = vue.defineComponent({
  10564. name: name$p,
  10565. props: noticeBarProps,
  10566. emits: ["close", "replay"],
  10567. setup(props, {
  10568. emit,
  10569. slots
  10570. }) {
  10571. let wrapWidth = 0;
  10572. let contentWidth = 0;
  10573. let startTimer;
  10574. const wrapRef = vue.ref();
  10575. const contentRef = vue.ref();
  10576. const state = vue.reactive({
  10577. show: true,
  10578. offset: 0,
  10579. duration: 0
  10580. });
  10581. const renderLeftIcon = () => {
  10582. if (slots["left-icon"]) {
  10583. return slots["left-icon"]();
  10584. }
  10585. if (props.leftIcon) {
  10586. return vue.createVNode(Icon, {
  10587. "class": bem$p("left-icon"),
  10588. "name": props.leftIcon
  10589. }, null);
  10590. }
  10591. };
  10592. const getRightIconName = () => {
  10593. if (props.mode === "closeable") {
  10594. return "cross";
  10595. }
  10596. if (props.mode === "link") {
  10597. return "arrow";
  10598. }
  10599. };
  10600. const onClickRightIcon = (event) => {
  10601. if (props.mode === "closeable") {
  10602. state.show = false;
  10603. emit("close", event);
  10604. }
  10605. };
  10606. const renderRightIcon = () => {
  10607. if (slots["right-icon"]) {
  10608. return slots["right-icon"]();
  10609. }
  10610. const name2 = getRightIconName();
  10611. if (name2) {
  10612. return vue.createVNode(Icon, {
  10613. "name": name2,
  10614. "class": bem$p("right-icon"),
  10615. "onClick": onClickRightIcon
  10616. }, null);
  10617. }
  10618. };
  10619. const onTransitionEnd = () => {
  10620. state.offset = wrapWidth;
  10621. state.duration = 0;
  10622. use.raf(() => {
  10623. use.doubleRaf(() => {
  10624. state.offset = -contentWidth;
  10625. state.duration = (contentWidth + wrapWidth) / +props.speed;
  10626. emit("replay");
  10627. });
  10628. });
  10629. };
  10630. const renderMarquee = () => {
  10631. const ellipsis = props.scrollable === false && !props.wrapable;
  10632. const style = {
  10633. transform: state.offset ? `translateX(${state.offset}px)` : "",
  10634. transitionDuration: `${state.duration}s`
  10635. };
  10636. return vue.createVNode("div", {
  10637. "ref": wrapRef,
  10638. "role": "marquee",
  10639. "class": bem$p("wrap")
  10640. }, [vue.createVNode("div", {
  10641. "ref": contentRef,
  10642. "style": style,
  10643. "class": [bem$p("content"), {
  10644. "van-ellipsis": ellipsis
  10645. }],
  10646. "onTransitionend": onTransitionEnd
  10647. }, [slots.default ? slots.default() : props.text])]);
  10648. };
  10649. const reset = () => {
  10650. const {
  10651. delay,
  10652. speed,
  10653. scrollable
  10654. } = props;
  10655. const ms = isDef(delay) ? +delay * 1e3 : 0;
  10656. wrapWidth = 0;
  10657. contentWidth = 0;
  10658. state.offset = 0;
  10659. state.duration = 0;
  10660. clearTimeout(startTimer);
  10661. startTimer = setTimeout(() => {
  10662. if (!wrapRef.value || !contentRef.value || scrollable === false) {
  10663. return;
  10664. }
  10665. const wrapRefWidth = use.useRect(wrapRef).width;
  10666. const contentRefWidth = use.useRect(contentRef).width;
  10667. if (scrollable || contentRefWidth > wrapRefWidth) {
  10668. use.doubleRaf(() => {
  10669. wrapWidth = wrapRefWidth;
  10670. contentWidth = contentRefWidth;
  10671. state.offset = -contentWidth;
  10672. state.duration = contentWidth / +speed;
  10673. });
  10674. }
  10675. }, ms);
  10676. };
  10677. onPopupReopen(reset);
  10678. use.onMountedOrActivated(reset);
  10679. use.useEventListener("pageshow", reset);
  10680. useExpose({
  10681. reset
  10682. });
  10683. vue.watch(() => [props.text, props.scrollable], reset);
  10684. return () => {
  10685. const {
  10686. color,
  10687. wrapable,
  10688. background
  10689. } = props;
  10690. return vue.withDirectives(vue.createVNode("div", {
  10691. "role": "alert",
  10692. "class": bem$p({
  10693. wrapable
  10694. }),
  10695. "style": {
  10696. color,
  10697. background
  10698. }
  10699. }, [renderLeftIcon(), renderMarquee(), renderRightIcon()]), [[vue.vShow, state.show]]);
  10700. };
  10701. }
  10702. });
  10703. const NoticeBar = withInstall(stdin_default$u);
  10704. const [name$o, bem$o] = createNamespace("notify");
  10705. const notifyProps = extend({}, popupSharedProps, {
  10706. type: makeStringProp("danger"),
  10707. color: String,
  10708. message: numericProp,
  10709. position: makeStringProp("top"),
  10710. className: unknownProp,
  10711. background: String,
  10712. lockScroll: Boolean
  10713. });
  10714. var stdin_default$t = vue.defineComponent({
  10715. name: name$o,
  10716. props: notifyProps,
  10717. emits: ["update:show"],
  10718. setup(props, {
  10719. emit,
  10720. slots
  10721. }) {
  10722. const updateShow = (show) => emit("update:show", show);
  10723. return () => vue.createVNode(Popup, {
  10724. "show": props.show,
  10725. "class": [bem$o([props.type]), props.className],
  10726. "style": {
  10727. color: props.color,
  10728. background: props.background
  10729. },
  10730. "overlay": false,
  10731. "position": props.position,
  10732. "duration": 0.2,
  10733. "lockScroll": props.lockScroll,
  10734. "onUpdate:show": updateShow
  10735. }, {
  10736. default: () => [slots.default ? slots.default() : props.message]
  10737. });
  10738. }
  10739. });
  10740. let timer;
  10741. let instance;
  10742. const parseOptions = (message) => isObject(message) ? message : {
  10743. message
  10744. };
  10745. function initInstance() {
  10746. ({
  10747. instance
  10748. } = mountComponent({
  10749. setup() {
  10750. const {
  10751. state,
  10752. toggle
  10753. } = usePopupState();
  10754. return () => vue.createVNode(stdin_default$t, vue.mergeProps(state, {
  10755. "onUpdate:show": toggle
  10756. }), null);
  10757. }
  10758. }));
  10759. }
  10760. function Notify(options) {
  10761. if (!inBrowser) {
  10762. return;
  10763. }
  10764. if (!instance) {
  10765. initInstance();
  10766. }
  10767. options = extend({}, Notify.currentOptions, parseOptions(options));
  10768. instance.open(options);
  10769. clearTimeout(timer);
  10770. if (options.duration > 0) {
  10771. timer = window.setTimeout(Notify.clear, options.duration);
  10772. }
  10773. return instance;
  10774. }
  10775. const getDefaultOptions = () => ({
  10776. type: "danger",
  10777. color: void 0,
  10778. message: "",
  10779. onClose: void 0,
  10780. onClick: void 0,
  10781. onOpened: void 0,
  10782. duration: 3e3,
  10783. position: void 0,
  10784. className: "",
  10785. lockScroll: false,
  10786. background: void 0
  10787. });
  10788. Notify.clear = () => {
  10789. if (instance) {
  10790. instance.toggle(false);
  10791. }
  10792. };
  10793. Notify.currentOptions = getDefaultOptions();
  10794. Notify.setDefaultOptions = (options) => {
  10795. extend(Notify.currentOptions, options);
  10796. };
  10797. Notify.resetDefaultOptions = () => {
  10798. Notify.currentOptions = getDefaultOptions();
  10799. };
  10800. Notify.Component = withInstall(stdin_default$t);
  10801. Notify.install = (app) => {
  10802. app.use(Notify.Component);
  10803. app.config.globalProperties.$notify = Notify;
  10804. };
  10805. const [name$n, bem$n] = createNamespace("key");
  10806. const CollapseIcon = vue.createVNode("svg", {
  10807. "class": bem$n("collapse-icon"),
  10808. "viewBox": "0 0 30 24"
  10809. }, [vue.createVNode("path", {
  10810. "d": "M26 13h-2v2h2v-2zm-8-3h2V8h-2v2zm2-4h2V4h-2v2zm2 4h4V4h-2v4h-2v2zm-7 14 3-3h-6l3 3zM6 13H4v2h2v-2zm16 0H8v2h14v-2zm-12-3h2V8h-2v2zM28 0l1 1 1 1v15l-1 2H1l-1-2V2l1-1 1-1zm0 2H2v15h26V2zM6 4v2H4V4zm10 2h2V4h-2v2zM8 9v1H4V8zm8 0v1h-2V8zm-6-5v2H8V4zm4 0v2h-2V4z",
  10811. "fill": "currentColor"
  10812. }, null)]);
  10813. const DeleteIcon = vue.createVNode("svg", {
  10814. "class": bem$n("delete-icon"),
  10815. "viewBox": "0 0 32 22"
  10816. }, [vue.createVNode("path", {
  10817. "d": "M28 0a4 4 0 0 1 4 4v14a4 4 0 0 1-4 4H10.4a2 2 0 0 1-1.4-.6L1 13.1c-.6-.5-.9-1.3-.9-2 0-1 .3-1.7.9-2.2L9 .6a2 2 0 0 1 1.4-.6zm0 2H10.4l-8.2 8.3a1 1 0 0 0-.3.7c0 .3.1.5.3.7l8.2 8.4H28a2 2 0 0 0 2-2V4c0-1.1-.9-2-2-2zm-5 4a1 1 0 0 1 .7.3 1 1 0 0 1 0 1.4L20.4 11l3.3 3.3c.2.2.3.5.3.7 0 .3-.1.5-.3.7a1 1 0 0 1-.7.3 1 1 0 0 1-.7-.3L19 12.4l-3.4 3.3a1 1 0 0 1-.6.3 1 1 0 0 1-.7-.3 1 1 0 0 1-.3-.7c0-.2.1-.5.3-.7l3.3-3.3-3.3-3.3A1 1 0 0 1 14 7c0-.3.1-.5.3-.7A1 1 0 0 1 15 6a1 1 0 0 1 .6.3L19 9.6l3.3-3.3A1 1 0 0 1 23 6z",
  10818. "fill": "currentColor"
  10819. }, null)]);
  10820. var stdin_default$s = vue.defineComponent({
  10821. name: name$n,
  10822. props: {
  10823. type: String,
  10824. text: numericProp,
  10825. color: String,
  10826. wider: Boolean,
  10827. large: Boolean,
  10828. loading: Boolean
  10829. },
  10830. emits: ["press"],
  10831. setup(props, {
  10832. emit,
  10833. slots
  10834. }) {
  10835. const active = vue.ref(false);
  10836. const touch = useTouch();
  10837. const onTouchStart = (event) => {
  10838. touch.start(event);
  10839. active.value = true;
  10840. };
  10841. const onTouchMove = (event) => {
  10842. touch.move(event);
  10843. if (touch.direction.value) {
  10844. active.value = false;
  10845. }
  10846. };
  10847. const onTouchEnd = (event) => {
  10848. if (active.value) {
  10849. if (!slots.default) {
  10850. preventDefault(event);
  10851. }
  10852. active.value = false;
  10853. emit("press", props.text, props.type);
  10854. }
  10855. };
  10856. const renderContent = () => {
  10857. if (props.loading) {
  10858. return vue.createVNode(Loading, {
  10859. "class": bem$n("loading-icon")
  10860. }, null);
  10861. }
  10862. const text = slots.default ? slots.default() : props.text;
  10863. switch (props.type) {
  10864. case "delete":
  10865. return text || DeleteIcon;
  10866. case "extra":
  10867. return text || CollapseIcon;
  10868. default:
  10869. return text;
  10870. }
  10871. };
  10872. return () => vue.createVNode("div", {
  10873. "class": bem$n("wrapper", {
  10874. wider: props.wider
  10875. }),
  10876. "onTouchstartPassive": onTouchStart,
  10877. "onTouchmovePassive": onTouchMove,
  10878. "onTouchend": onTouchEnd,
  10879. "onTouchcancel": onTouchEnd
  10880. }, [vue.createVNode("div", {
  10881. "role": "button",
  10882. "tabindex": 0,
  10883. "class": bem$n([props.color, {
  10884. large: props.large,
  10885. active: active.value,
  10886. delete: props.type === "delete"
  10887. }])
  10888. }, [renderContent()])]);
  10889. }
  10890. });
  10891. const [name$m, bem$m] = createNamespace("number-keyboard");
  10892. const numberKeyboardProps = {
  10893. show: Boolean,
  10894. title: String,
  10895. theme: makeStringProp("default"),
  10896. zIndex: numericProp,
  10897. teleport: [String, Object],
  10898. maxlength: makeNumericProp(Infinity),
  10899. modelValue: makeStringProp(""),
  10900. transition: truthProp,
  10901. blurOnClose: truthProp,
  10902. showDeleteKey: truthProp,
  10903. randomKeyOrder: Boolean,
  10904. closeButtonText: String,
  10905. deleteButtonText: String,
  10906. closeButtonLoading: Boolean,
  10907. hideOnClickOutside: truthProp,
  10908. safeAreaInsetBottom: truthProp,
  10909. extraKey: {
  10910. type: [String, Array],
  10911. default: ""
  10912. }
  10913. };
  10914. function shuffle(array) {
  10915. for (let i = array.length - 1; i > 0; i--) {
  10916. const j = Math.floor(Math.random() * (i + 1));
  10917. const temp = array[i];
  10918. array[i] = array[j];
  10919. array[j] = temp;
  10920. }
  10921. return array;
  10922. }
  10923. var stdin_default$r = vue.defineComponent({
  10924. name: name$m,
  10925. props: numberKeyboardProps,
  10926. emits: ["show", "hide", "blur", "input", "close", "delete", "update:modelValue"],
  10927. setup(props, {
  10928. emit,
  10929. slots
  10930. }) {
  10931. const root = vue.ref();
  10932. const genBasicKeys = () => {
  10933. const keys2 = Array(9).fill("").map((_, i) => ({
  10934. text: i + 1
  10935. }));
  10936. if (props.randomKeyOrder) {
  10937. shuffle(keys2);
  10938. }
  10939. return keys2;
  10940. };
  10941. const genDefaultKeys = () => [...genBasicKeys(), {
  10942. text: props.extraKey,
  10943. type: "extra"
  10944. }, {
  10945. text: 0
  10946. }, {
  10947. text: props.showDeleteKey ? props.deleteButtonText : "",
  10948. type: props.showDeleteKey ? "delete" : ""
  10949. }];
  10950. const genCustomKeys = () => {
  10951. const keys2 = genBasicKeys();
  10952. const {
  10953. extraKey
  10954. } = props;
  10955. const extraKeys = Array.isArray(extraKey) ? extraKey : [extraKey];
  10956. if (extraKeys.length === 1) {
  10957. keys2.push({
  10958. text: 0,
  10959. wider: true
  10960. }, {
  10961. text: extraKeys[0],
  10962. type: "extra"
  10963. });
  10964. } else if (extraKeys.length === 2) {
  10965. keys2.push({
  10966. text: extraKeys[0],
  10967. type: "extra"
  10968. }, {
  10969. text: 0
  10970. }, {
  10971. text: extraKeys[1],
  10972. type: "extra"
  10973. });
  10974. }
  10975. return keys2;
  10976. };
  10977. const keys = vue.computed(() => props.theme === "custom" ? genCustomKeys() : genDefaultKeys());
  10978. const onBlur = () => {
  10979. if (props.show) {
  10980. emit("blur");
  10981. }
  10982. };
  10983. const onClose = () => {
  10984. emit("close");
  10985. if (props.blurOnClose) {
  10986. onBlur();
  10987. }
  10988. };
  10989. const onAnimationEnd = () => emit(props.show ? "show" : "hide");
  10990. const onPress = (text, type) => {
  10991. if (text === "") {
  10992. if (type === "extra") {
  10993. onBlur();
  10994. }
  10995. return;
  10996. }
  10997. const value = props.modelValue;
  10998. if (type === "delete") {
  10999. emit("delete");
  11000. emit("update:modelValue", value.slice(0, value.length - 1));
  11001. } else if (type === "close") {
  11002. onClose();
  11003. } else if (value.length < props.maxlength) {
  11004. emit("input", text);
  11005. emit("update:modelValue", value + text);
  11006. }
  11007. };
  11008. const renderTitle = () => {
  11009. const {
  11010. title,
  11011. theme,
  11012. closeButtonText
  11013. } = props;
  11014. const leftSlot = slots["title-left"];
  11015. const showClose = closeButtonText && theme === "default";
  11016. const showTitle = title || showClose || leftSlot;
  11017. if (!showTitle) {
  11018. return;
  11019. }
  11020. return vue.createVNode("div", {
  11021. "class": bem$m("header")
  11022. }, [leftSlot && vue.createVNode("span", {
  11023. "class": bem$m("title-left")
  11024. }, [leftSlot()]), title && vue.createVNode("h2", {
  11025. "class": bem$m("title")
  11026. }, [title]), showClose && vue.createVNode("button", {
  11027. "type": "button",
  11028. "class": [bem$m("close"), HAPTICS_FEEDBACK],
  11029. "onClick": onClose
  11030. }, [closeButtonText])]);
  11031. };
  11032. const renderKeys = () => keys.value.map((key) => {
  11033. const keySlots = {};
  11034. if (key.type === "delete") {
  11035. keySlots.default = slots.delete;
  11036. }
  11037. if (key.type === "extra") {
  11038. keySlots.default = slots["extra-key"];
  11039. }
  11040. return vue.createVNode(stdin_default$s, {
  11041. "key": key.text,
  11042. "text": key.text,
  11043. "type": key.type,
  11044. "wider": key.wider,
  11045. "color": key.color,
  11046. "onPress": onPress
  11047. }, keySlots);
  11048. });
  11049. const renderSidebar = () => {
  11050. if (props.theme === "custom") {
  11051. return vue.createVNode("div", {
  11052. "class": bem$m("sidebar")
  11053. }, [props.showDeleteKey && vue.createVNode(stdin_default$s, {
  11054. "large": true,
  11055. "text": props.deleteButtonText,
  11056. "type": "delete",
  11057. "onPress": onPress
  11058. }, {
  11059. delete: slots.delete
  11060. }), vue.createVNode(stdin_default$s, {
  11061. "large": true,
  11062. "text": props.closeButtonText,
  11063. "type": "close",
  11064. "color": "blue",
  11065. "loading": props.closeButtonLoading,
  11066. "onPress": onPress
  11067. }, null)]);
  11068. }
  11069. };
  11070. vue.watch(() => props.show, (value) => {
  11071. if (!props.transition) {
  11072. emit(value ? "show" : "hide");
  11073. }
  11074. });
  11075. if (props.hideOnClickOutside) {
  11076. use.useClickAway(root, onBlur, {
  11077. eventName: "touchstart"
  11078. });
  11079. }
  11080. return () => {
  11081. const Title = renderTitle();
  11082. const Content = vue.createVNode(vue.Transition, {
  11083. "name": props.transition ? "van-slide-up" : ""
  11084. }, {
  11085. default: () => [vue.withDirectives(vue.createVNode("div", {
  11086. "ref": root,
  11087. "style": getZIndexStyle(props.zIndex),
  11088. "class": bem$m({
  11089. unfit: !props.safeAreaInsetBottom,
  11090. "with-title": !!Title
  11091. }),
  11092. "onAnimationend": onAnimationEnd,
  11093. "onTouchstartPassive": stopPropagation
  11094. }, [Title, vue.createVNode("div", {
  11095. "class": bem$m("body")
  11096. }, [vue.createVNode("div", {
  11097. "class": bem$m("keys")
  11098. }, [renderKeys()]), renderSidebar()])]), [[vue.vShow, props.show]])]
  11099. });
  11100. if (props.teleport) {
  11101. return vue.createVNode(vue.Teleport, {
  11102. "to": props.teleport
  11103. }, {
  11104. default: () => [Content]
  11105. });
  11106. }
  11107. return Content;
  11108. };
  11109. }
  11110. });
  11111. const NumberKeyboard = withInstall(stdin_default$r);
  11112. const [name$l, bem$l, t$5] = createNamespace("pagination");
  11113. const makePage = (number, text, active) => ({
  11114. number,
  11115. text,
  11116. active
  11117. });
  11118. const paginationProps = {
  11119. mode: makeStringProp("multi"),
  11120. prevText: String,
  11121. nextText: String,
  11122. pageCount: makeNumericProp(0),
  11123. modelValue: makeNumberProp(0),
  11124. totalItems: makeNumericProp(0),
  11125. showPageSize: makeNumericProp(5),
  11126. itemsPerPage: makeNumericProp(10),
  11127. forceEllipses: Boolean
  11128. };
  11129. var stdin_default$q = vue.defineComponent({
  11130. name: name$l,
  11131. props: paginationProps,
  11132. emits: ["change", "update:modelValue"],
  11133. setup(props, {
  11134. emit,
  11135. slots
  11136. }) {
  11137. const count = vue.computed(() => {
  11138. const {
  11139. pageCount,
  11140. totalItems,
  11141. itemsPerPage
  11142. } = props;
  11143. const count2 = +pageCount || Math.ceil(+totalItems / +itemsPerPage);
  11144. return Math.max(1, count2);
  11145. });
  11146. const pages = vue.computed(() => {
  11147. const items = [];
  11148. const pageCount = count.value;
  11149. const showPageSize = +props.showPageSize;
  11150. const {
  11151. modelValue,
  11152. forceEllipses
  11153. } = props;
  11154. let startPage = 1;
  11155. let endPage = pageCount;
  11156. const isMaxSized = showPageSize < pageCount;
  11157. if (isMaxSized) {
  11158. startPage = Math.max(modelValue - Math.floor(showPageSize / 2), 1);
  11159. endPage = startPage + showPageSize - 1;
  11160. if (endPage > pageCount) {
  11161. endPage = pageCount;
  11162. startPage = endPage - showPageSize + 1;
  11163. }
  11164. }
  11165. for (let number = startPage; number <= endPage; number++) {
  11166. const page = makePage(number, number, number === modelValue);
  11167. items.push(page);
  11168. }
  11169. if (isMaxSized && showPageSize > 0 && forceEllipses) {
  11170. if (startPage > 1) {
  11171. const prevPages = makePage(startPage - 1, "...");
  11172. items.unshift(prevPages);
  11173. }
  11174. if (endPage < pageCount) {
  11175. const nextPages = makePage(endPage + 1, "...");
  11176. items.push(nextPages);
  11177. }
  11178. }
  11179. return items;
  11180. });
  11181. const updateModelValue = (value, emitChange) => {
  11182. value = clamp(value, 1, count.value);
  11183. if (props.modelValue !== value) {
  11184. emit("update:modelValue", value);
  11185. if (emitChange) {
  11186. emit("change", value);
  11187. }
  11188. }
  11189. };
  11190. vue.watchEffect(() => updateModelValue(props.modelValue));
  11191. const renderDesc = () => vue.createVNode("li", {
  11192. "class": bem$l("page-desc")
  11193. }, [slots.pageDesc ? slots.pageDesc() : `${props.modelValue}/${count.value}`]);
  11194. const renderPrevButton = () => {
  11195. const {
  11196. mode,
  11197. modelValue
  11198. } = props;
  11199. const slot = slots["prev-text"];
  11200. const disabled = modelValue === 1;
  11201. return vue.createVNode("li", {
  11202. "class": [bem$l("item", {
  11203. disabled,
  11204. border: mode === "simple",
  11205. prev: true
  11206. }), BORDER_SURROUND]
  11207. }, [vue.createVNode("button", {
  11208. "type": "button",
  11209. "disabled": disabled,
  11210. "onClick": () => updateModelValue(modelValue - 1, true)
  11211. }, [slot ? slot() : props.prevText || t$5("prev")])]);
  11212. };
  11213. const renderNextButton = () => {
  11214. const {
  11215. mode,
  11216. modelValue
  11217. } = props;
  11218. const slot = slots["next-text"];
  11219. const disabled = modelValue === count.value;
  11220. return vue.createVNode("li", {
  11221. "class": [bem$l("item", {
  11222. disabled,
  11223. border: mode === "simple",
  11224. next: true
  11225. }), BORDER_SURROUND]
  11226. }, [vue.createVNode("button", {
  11227. "type": "button",
  11228. "disabled": disabled,
  11229. "onClick": () => updateModelValue(modelValue + 1, true)
  11230. }, [slot ? slot() : props.nextText || t$5("next")])]);
  11231. };
  11232. const renderPages = () => pages.value.map((page) => vue.createVNode("li", {
  11233. "class": [bem$l("item", {
  11234. active: page.active,
  11235. page: true
  11236. }), BORDER_SURROUND]
  11237. }, [vue.createVNode("button", {
  11238. "type": "button",
  11239. "aria-current": page.active || void 0,
  11240. "onClick": () => updateModelValue(page.number, true)
  11241. }, [slots.page ? slots.page(page) : page.text])]));
  11242. return () => vue.createVNode("nav", {
  11243. "role": "navigation",
  11244. "class": bem$l()
  11245. }, [vue.createVNode("ul", {
  11246. "class": bem$l("items")
  11247. }, [renderPrevButton(), props.mode === "simple" ? renderDesc() : renderPages(), renderNextButton()])]);
  11248. }
  11249. });
  11250. const Pagination = withInstall(stdin_default$q);
  11251. const [name$k, bem$k] = createNamespace("password-input");
  11252. const passwordInputProps = {
  11253. info: String,
  11254. mask: truthProp,
  11255. value: makeStringProp(""),
  11256. gutter: numericProp,
  11257. length: makeNumericProp(6),
  11258. focused: Boolean,
  11259. errorInfo: String
  11260. };
  11261. var stdin_default$p = vue.defineComponent({
  11262. name: name$k,
  11263. props: passwordInputProps,
  11264. emits: ["focus"],
  11265. setup(props, {
  11266. emit
  11267. }) {
  11268. const onTouchStart = (event) => {
  11269. event.stopPropagation();
  11270. emit("focus", event);
  11271. };
  11272. const renderPoints = () => {
  11273. const Points = [];
  11274. const {
  11275. mask,
  11276. value,
  11277. length,
  11278. gutter,
  11279. focused
  11280. } = props;
  11281. for (let i = 0; i < length; i++) {
  11282. const char = value[i];
  11283. const showBorder = i !== 0 && !gutter;
  11284. const showCursor = focused && i === value.length;
  11285. let style;
  11286. if (i !== 0 && gutter) {
  11287. style = {
  11288. marginLeft: addUnit(gutter)
  11289. };
  11290. }
  11291. Points.push(vue.createVNode("li", {
  11292. "class": [{
  11293. [BORDER_LEFT]: showBorder
  11294. }, bem$k("item", {
  11295. focus: showCursor
  11296. })],
  11297. "style": style
  11298. }, [mask ? vue.createVNode("i", {
  11299. "style": {
  11300. visibility: char ? "visible" : "hidden"
  11301. }
  11302. }, null) : char, showCursor && vue.createVNode("div", {
  11303. "class": bem$k("cursor")
  11304. }, null)]));
  11305. }
  11306. return Points;
  11307. };
  11308. return () => {
  11309. const info = props.errorInfo || props.info;
  11310. return vue.createVNode("div", {
  11311. "class": bem$k()
  11312. }, [vue.createVNode("ul", {
  11313. "class": [bem$k("security"), {
  11314. [BORDER_SURROUND]: !props.gutter
  11315. }],
  11316. "onTouchstartPassive": onTouchStart
  11317. }, [renderPoints()]), info && vue.createVNode("div", {
  11318. "class": bem$k(props.errorInfo ? "error-info" : "info")
  11319. }, [info])]);
  11320. };
  11321. }
  11322. });
  11323. const PasswordInput = withInstall(stdin_default$p);
  11324. const [name$j, bem$j] = createNamespace("popover");
  11325. const popupProps = ["show", "overlay", "duration", "teleport", "overlayStyle", "overlayClass", "closeOnClickOverlay"];
  11326. const popoverProps = {
  11327. show: Boolean,
  11328. theme: makeStringProp("light"),
  11329. overlay: Boolean,
  11330. actions: makeArrayProp(),
  11331. trigger: makeStringProp("click"),
  11332. duration: numericProp,
  11333. showArrow: truthProp,
  11334. placement: makeStringProp("bottom"),
  11335. iconPrefix: String,
  11336. overlayClass: unknownProp,
  11337. overlayStyle: Object,
  11338. closeOnClickAction: truthProp,
  11339. closeOnClickOverlay: truthProp,
  11340. closeOnClickOutside: truthProp,
  11341. offset: {
  11342. type: Array,
  11343. default: () => [0, 8]
  11344. },
  11345. teleport: {
  11346. type: [String, Object],
  11347. default: "body"
  11348. }
  11349. };
  11350. var stdin_default$o = vue.defineComponent({
  11351. name: name$j,
  11352. props: popoverProps,
  11353. emits: ["select", "touchstart", "update:show"],
  11354. setup(props, {
  11355. emit,
  11356. slots,
  11357. attrs
  11358. }) {
  11359. let popper;
  11360. const popupRef = vue.ref();
  11361. const wrapperRef = vue.ref();
  11362. const popoverRef = vue.ref();
  11363. const getPopoverOptions = () => ({
  11364. placement: props.placement,
  11365. modifiers: [{
  11366. name: "computeStyles",
  11367. options: {
  11368. adaptive: false,
  11369. gpuAcceleration: false
  11370. }
  11371. }, extend({}, popperjs.offsetModifier, {
  11372. options: {
  11373. offset: props.offset
  11374. }
  11375. })]
  11376. });
  11377. const createPopperInstance = () => {
  11378. if (wrapperRef.value && popoverRef.value) {
  11379. return popperjs.createPopper(wrapperRef.value, popoverRef.value.popupRef.value, getPopoverOptions());
  11380. }
  11381. return null;
  11382. };
  11383. const updateLocation = () => {
  11384. vue.nextTick(() => {
  11385. if (!props.show) {
  11386. return;
  11387. }
  11388. if (!popper) {
  11389. popper = createPopperInstance();
  11390. } else {
  11391. popper.setOptions(getPopoverOptions());
  11392. }
  11393. });
  11394. };
  11395. const updateShow = (value) => emit("update:show", value);
  11396. const onClickWrapper = () => {
  11397. if (props.trigger === "click") {
  11398. updateShow(!props.show);
  11399. }
  11400. };
  11401. const onClickAction = (action, index) => {
  11402. if (action.disabled) {
  11403. return;
  11404. }
  11405. emit("select", action, index);
  11406. if (props.closeOnClickAction) {
  11407. updateShow(false);
  11408. }
  11409. };
  11410. const onClickAway = () => {
  11411. if (props.show && props.closeOnClickOutside && (!props.overlay || props.closeOnClickOverlay)) {
  11412. updateShow(false);
  11413. }
  11414. };
  11415. const renderActionContent = (action, index) => {
  11416. if (slots.action) {
  11417. return slots.action({
  11418. action,
  11419. index
  11420. });
  11421. }
  11422. return [action.icon && vue.createVNode(Icon, {
  11423. "name": action.icon,
  11424. "classPrefix": props.iconPrefix,
  11425. "class": bem$j("action-icon")
  11426. }, null), vue.createVNode("div", {
  11427. "class": [bem$j("action-text"), BORDER_BOTTOM]
  11428. }, [action.text])];
  11429. };
  11430. const renderAction = (action, index) => {
  11431. const {
  11432. icon,
  11433. color,
  11434. disabled,
  11435. className
  11436. } = action;
  11437. return vue.createVNode("div", {
  11438. "role": "menuitem",
  11439. "class": [bem$j("action", {
  11440. disabled,
  11441. "with-icon": icon
  11442. }), className],
  11443. "style": {
  11444. color
  11445. },
  11446. "tabindex": disabled ? void 0 : 0,
  11447. "aria-disabled": disabled || void 0,
  11448. "onClick": () => onClickAction(action, index)
  11449. }, [renderActionContent(action, index)]);
  11450. };
  11451. vue.onMounted(() => {
  11452. updateLocation();
  11453. vue.watchEffect(() => {
  11454. var _a;
  11455. popupRef.value = (_a = popoverRef.value) == null ? void 0 : _a.popupRef.value;
  11456. });
  11457. });
  11458. vue.onBeforeUnmount(() => {
  11459. if (popper) {
  11460. popper.destroy();
  11461. popper = null;
  11462. }
  11463. });
  11464. vue.watch(() => [props.show, props.offset, props.placement], updateLocation);
  11465. use.useClickAway([wrapperRef, popupRef], onClickAway, {
  11466. eventName: "touchstart"
  11467. });
  11468. return () => {
  11469. var _a;
  11470. return vue.createVNode(vue.Fragment, null, [vue.createVNode("span", {
  11471. "ref": wrapperRef,
  11472. "class": bem$j("wrapper"),
  11473. "onClick": onClickWrapper
  11474. }, [(_a = slots.reference) == null ? void 0 : _a.call(slots)]), vue.createVNode(Popup, vue.mergeProps({
  11475. "ref": popoverRef,
  11476. "class": bem$j([props.theme]),
  11477. "position": "",
  11478. "transition": "van-popover-zoom",
  11479. "lockScroll": false,
  11480. "onUpdate:show": updateShow
  11481. }, attrs, pick(props, popupProps)), {
  11482. default: () => [props.showArrow && vue.createVNode("div", {
  11483. "class": bem$j("arrow")
  11484. }, null), vue.createVNode("div", {
  11485. "role": "menu",
  11486. "class": bem$j("content")
  11487. }, [slots.default ? slots.default() : props.actions.map(renderAction)])]
  11488. })]);
  11489. };
  11490. }
  11491. });
  11492. const Popover = withInstall(stdin_default$o);
  11493. const [name$i, bem$i] = createNamespace("progress");
  11494. const progressProps = {
  11495. color: String,
  11496. inactive: Boolean,
  11497. pivotText: String,
  11498. textColor: String,
  11499. showPivot: truthProp,
  11500. pivotColor: String,
  11501. trackColor: String,
  11502. strokeWidth: numericProp,
  11503. percentage: {
  11504. type: numericProp,
  11505. default: 0,
  11506. validator: (value) => value >= 0 && value <= 100
  11507. }
  11508. };
  11509. var stdin_default$n = vue.defineComponent({
  11510. name: name$i,
  11511. props: progressProps,
  11512. setup(props) {
  11513. const background = vue.computed(() => props.inactive ? void 0 : props.color);
  11514. const renderPivot = () => {
  11515. const {
  11516. textColor,
  11517. pivotText,
  11518. pivotColor,
  11519. percentage
  11520. } = props;
  11521. const text = pivotText != null ? pivotText : `${percentage}%`;
  11522. if (props.showPivot && text) {
  11523. const style = {
  11524. color: textColor,
  11525. left: `${+percentage}%`,
  11526. transform: `translate(-${+percentage}%,-50%)`,
  11527. background: pivotColor || background.value
  11528. };
  11529. return vue.createVNode("span", {
  11530. "style": style,
  11531. "class": bem$i("pivot", {
  11532. inactive: props.inactive
  11533. })
  11534. }, [text]);
  11535. }
  11536. };
  11537. return () => {
  11538. const {
  11539. trackColor,
  11540. percentage,
  11541. strokeWidth
  11542. } = props;
  11543. const rootStyle = {
  11544. background: trackColor,
  11545. height: addUnit(strokeWidth)
  11546. };
  11547. const portionStyle = {
  11548. width: `${percentage}%`,
  11549. background: background.value
  11550. };
  11551. return vue.createVNode("div", {
  11552. "class": bem$i(),
  11553. "style": rootStyle
  11554. }, [vue.createVNode("span", {
  11555. "class": bem$i("portion", {
  11556. inactive: props.inactive
  11557. }),
  11558. "style": portionStyle
  11559. }, null), renderPivot()]);
  11560. };
  11561. }
  11562. });
  11563. const Progress = withInstall(stdin_default$n);
  11564. const [name$h, bem$h, t$4] = createNamespace("pull-refresh");
  11565. const DEFAULT_HEAD_HEIGHT = 50;
  11566. const TEXT_STATUS = ["pulling", "loosing", "success"];
  11567. const pullRefreshProps = {
  11568. disabled: Boolean,
  11569. modelValue: Boolean,
  11570. headHeight: makeNumericProp(DEFAULT_HEAD_HEIGHT),
  11571. successText: String,
  11572. pullingText: String,
  11573. loosingText: String,
  11574. loadingText: String,
  11575. pullDistance: numericProp,
  11576. successDuration: makeNumericProp(500),
  11577. animationDuration: makeNumericProp(300)
  11578. };
  11579. var stdin_default$m = vue.defineComponent({
  11580. name: name$h,
  11581. props: pullRefreshProps,
  11582. emits: ["change", "refresh", "update:modelValue"],
  11583. setup(props, {
  11584. emit,
  11585. slots
  11586. }) {
  11587. let reachTop;
  11588. const root = vue.ref();
  11589. const track = vue.ref();
  11590. const scrollParent = use.useScrollParent(root);
  11591. const state = vue.reactive({
  11592. status: "normal",
  11593. distance: 0,
  11594. duration: 0
  11595. });
  11596. const touch = useTouch();
  11597. const getHeadStyle = () => {
  11598. if (props.headHeight !== DEFAULT_HEAD_HEIGHT) {
  11599. return {
  11600. height: `${props.headHeight}px`
  11601. };
  11602. }
  11603. };
  11604. const isTouchable = () => state.status !== "loading" && state.status !== "success" && !props.disabled;
  11605. const ease = (distance) => {
  11606. const pullDistance = +(props.pullDistance || props.headHeight);
  11607. if (distance > pullDistance) {
  11608. if (distance < pullDistance * 2) {
  11609. distance = pullDistance + (distance - pullDistance) / 2;
  11610. } else {
  11611. distance = pullDistance * 1.5 + (distance - pullDistance * 2) / 4;
  11612. }
  11613. }
  11614. return Math.round(distance);
  11615. };
  11616. const setStatus = (distance, isLoading) => {
  11617. const pullDistance = +(props.pullDistance || props.headHeight);
  11618. state.distance = distance;
  11619. if (isLoading) {
  11620. state.status = "loading";
  11621. } else if (distance === 0) {
  11622. state.status = "normal";
  11623. } else if (distance < pullDistance) {
  11624. state.status = "pulling";
  11625. } else {
  11626. state.status = "loosing";
  11627. }
  11628. emit("change", {
  11629. status: state.status,
  11630. distance
  11631. });
  11632. };
  11633. const getStatusText = () => {
  11634. const {
  11635. status
  11636. } = state;
  11637. if (status === "normal") {
  11638. return "";
  11639. }
  11640. return props[`${status}Text`] || t$4(status);
  11641. };
  11642. const renderStatus = () => {
  11643. const {
  11644. status,
  11645. distance
  11646. } = state;
  11647. if (slots[status]) {
  11648. return slots[status]({
  11649. distance
  11650. });
  11651. }
  11652. const nodes = [];
  11653. if (TEXT_STATUS.includes(status)) {
  11654. nodes.push(vue.createVNode("div", {
  11655. "class": bem$h("text")
  11656. }, [getStatusText()]));
  11657. }
  11658. if (status === "loading") {
  11659. nodes.push(vue.createVNode(Loading, {
  11660. "class": bem$h("loading")
  11661. }, {
  11662. default: getStatusText
  11663. }));
  11664. }
  11665. return nodes;
  11666. };
  11667. const showSuccessTip = () => {
  11668. state.status = "success";
  11669. setTimeout(() => {
  11670. setStatus(0);
  11671. }, +props.successDuration);
  11672. };
  11673. const checkPosition = (event) => {
  11674. reachTop = getScrollTop(scrollParent.value) === 0;
  11675. if (reachTop) {
  11676. state.duration = 0;
  11677. touch.start(event);
  11678. }
  11679. };
  11680. const onTouchStart = (event) => {
  11681. if (isTouchable()) {
  11682. checkPosition(event);
  11683. }
  11684. };
  11685. const onTouchMove = (event) => {
  11686. if (isTouchable()) {
  11687. if (!reachTop) {
  11688. checkPosition(event);
  11689. }
  11690. const {
  11691. deltaY
  11692. } = touch;
  11693. touch.move(event);
  11694. if (reachTop && deltaY.value >= 0 && touch.isVertical()) {
  11695. preventDefault(event);
  11696. setStatus(ease(deltaY.value));
  11697. }
  11698. }
  11699. };
  11700. const onTouchEnd = () => {
  11701. if (reachTop && touch.deltaY.value && isTouchable()) {
  11702. state.duration = +props.animationDuration;
  11703. if (state.status === "loosing") {
  11704. setStatus(+props.headHeight, true);
  11705. emit("update:modelValue", true);
  11706. vue.nextTick(() => emit("refresh"));
  11707. } else {
  11708. setStatus(0);
  11709. }
  11710. }
  11711. };
  11712. vue.watch(() => props.modelValue, (value) => {
  11713. state.duration = +props.animationDuration;
  11714. if (value) {
  11715. setStatus(+props.headHeight, true);
  11716. } else if (slots.success || props.successText) {
  11717. showSuccessTip();
  11718. } else {
  11719. setStatus(0, false);
  11720. }
  11721. });
  11722. use.useEventListener("touchmove", onTouchMove, {
  11723. target: track
  11724. });
  11725. return () => {
  11726. var _a;
  11727. const trackStyle = {
  11728. transitionDuration: `${state.duration}ms`,
  11729. transform: state.distance ? `translate3d(0,${state.distance}px, 0)` : ""
  11730. };
  11731. return vue.createVNode("div", {
  11732. "ref": root,
  11733. "class": bem$h()
  11734. }, [vue.createVNode("div", {
  11735. "ref": track,
  11736. "class": bem$h("track"),
  11737. "style": trackStyle,
  11738. "onTouchstartPassive": onTouchStart,
  11739. "onTouchend": onTouchEnd,
  11740. "onTouchcancel": onTouchEnd
  11741. }, [vue.createVNode("div", {
  11742. "class": bem$h("head"),
  11743. "style": getHeadStyle()
  11744. }, [renderStatus()]), (_a = slots.default) == null ? void 0 : _a.call(slots)])]);
  11745. };
  11746. }
  11747. });
  11748. const PullRefresh = withInstall(stdin_default$m);
  11749. const [name$g, bem$g] = createNamespace("rate");
  11750. function getRateStatus(value, index, allowHalf, readonly) {
  11751. if (value >= index) {
  11752. return {
  11753. status: "full",
  11754. value: 1
  11755. };
  11756. }
  11757. if (value + 0.5 >= index && allowHalf && !readonly) {
  11758. return {
  11759. status: "half",
  11760. value: 0.5
  11761. };
  11762. }
  11763. if (value + 1 >= index && allowHalf && readonly) {
  11764. const cardinal = 10 ** 10;
  11765. return {
  11766. status: "half",
  11767. value: Math.round((value - index + 1) * cardinal) / cardinal
  11768. };
  11769. }
  11770. return {
  11771. status: "void",
  11772. value: 0
  11773. };
  11774. }
  11775. const rateProps = {
  11776. size: numericProp,
  11777. icon: makeStringProp("star"),
  11778. color: String,
  11779. count: makeNumericProp(5),
  11780. gutter: numericProp,
  11781. readonly: Boolean,
  11782. disabled: Boolean,
  11783. voidIcon: makeStringProp("star-o"),
  11784. allowHalf: Boolean,
  11785. voidColor: String,
  11786. touchable: truthProp,
  11787. iconPrefix: String,
  11788. modelValue: makeNumberProp(0),
  11789. disabledColor: String
  11790. };
  11791. var stdin_default$l = vue.defineComponent({
  11792. name: name$g,
  11793. props: rateProps,
  11794. emits: ["change", "update:modelValue"],
  11795. setup(props, {
  11796. emit
  11797. }) {
  11798. const touch = useTouch();
  11799. const [itemRefs, setItemRefs] = useRefs();
  11800. const groupRef = vue.ref();
  11801. const untouchable = () => props.readonly || props.disabled || !props.touchable;
  11802. const list = vue.computed(() => Array(+props.count).fill("").map((_, i) => getRateStatus(props.modelValue, i + 1, props.allowHalf, props.readonly)));
  11803. let ranges;
  11804. let groupRefRect;
  11805. let minRectTop = Number.MAX_SAFE_INTEGER;
  11806. let maxRectTop = Number.MIN_SAFE_INTEGER;
  11807. const updateRanges = () => {
  11808. groupRefRect = use.useRect(groupRef);
  11809. const rects = itemRefs.value.map(use.useRect);
  11810. ranges = [];
  11811. rects.forEach((rect, index) => {
  11812. minRectTop = Math.min(rect.top, minRectTop);
  11813. maxRectTop = Math.max(rect.top, maxRectTop);
  11814. if (props.allowHalf) {
  11815. ranges.push({
  11816. score: index + 0.5,
  11817. left: rect.left,
  11818. top: rect.top,
  11819. height: rect.height
  11820. }, {
  11821. score: index + 1,
  11822. left: rect.left + rect.width / 2,
  11823. top: rect.top,
  11824. height: rect.height
  11825. });
  11826. } else {
  11827. ranges.push({
  11828. score: index + 1,
  11829. left: rect.left,
  11830. top: rect.top,
  11831. height: rect.height
  11832. });
  11833. }
  11834. });
  11835. };
  11836. const getScoreByPosition = (x, y) => {
  11837. for (let i = ranges.length - 1; i > 0; i--) {
  11838. if (y >= groupRefRect.top && y <= groupRefRect.bottom) {
  11839. if (x > ranges[i].left && y >= ranges[i].top && y <= ranges[i].top + ranges[i].height) {
  11840. return ranges[i].score;
  11841. }
  11842. } else {
  11843. const curTop = y < groupRefRect.top ? minRectTop : maxRectTop;
  11844. if (x > ranges[i].left && ranges[i].top === curTop) {
  11845. return ranges[i].score;
  11846. }
  11847. }
  11848. }
  11849. return props.allowHalf ? 0.5 : 1;
  11850. };
  11851. const select = (index) => {
  11852. if (!props.disabled && !props.readonly && index !== props.modelValue) {
  11853. emit("update:modelValue", index);
  11854. emit("change", index);
  11855. }
  11856. };
  11857. const onTouchStart = (event) => {
  11858. if (untouchable()) {
  11859. return;
  11860. }
  11861. touch.start(event);
  11862. updateRanges();
  11863. };
  11864. const onTouchMove = (event) => {
  11865. if (untouchable()) {
  11866. return;
  11867. }
  11868. touch.move(event);
  11869. if (touch.isHorizontal()) {
  11870. const {
  11871. clientX,
  11872. clientY
  11873. } = event.touches[0];
  11874. preventDefault(event);
  11875. select(getScoreByPosition(clientX, clientY));
  11876. }
  11877. };
  11878. const renderStar = (item, index) => {
  11879. const {
  11880. icon,
  11881. size,
  11882. color,
  11883. count,
  11884. gutter,
  11885. voidIcon,
  11886. disabled,
  11887. voidColor,
  11888. allowHalf,
  11889. iconPrefix,
  11890. disabledColor
  11891. } = props;
  11892. const score = index + 1;
  11893. const isFull = item.status === "full";
  11894. const isVoid = item.status === "void";
  11895. const renderHalf = allowHalf && item.value > 0 && item.value < 1;
  11896. let style;
  11897. if (gutter && score !== +count) {
  11898. style = {
  11899. paddingRight: addUnit(gutter)
  11900. };
  11901. }
  11902. const onClickItem = (event) => {
  11903. updateRanges();
  11904. select(allowHalf ? getScoreByPosition(event.clientX, event.clientY) : score);
  11905. };
  11906. return vue.createVNode("div", {
  11907. "key": index,
  11908. "ref": setItemRefs(index),
  11909. "role": "radio",
  11910. "style": style,
  11911. "class": bem$g("item"),
  11912. "tabindex": disabled ? void 0 : 0,
  11913. "aria-setsize": count,
  11914. "aria-posinset": score,
  11915. "aria-checked": !isVoid,
  11916. "onClick": onClickItem
  11917. }, [vue.createVNode(Icon, {
  11918. "size": size,
  11919. "name": isFull ? icon : voidIcon,
  11920. "class": bem$g("icon", {
  11921. disabled,
  11922. full: isFull
  11923. }),
  11924. "color": disabled ? disabledColor : isFull ? color : voidColor,
  11925. "classPrefix": iconPrefix
  11926. }, null), renderHalf && vue.createVNode(Icon, {
  11927. "size": size,
  11928. "style": {
  11929. width: item.value + "em"
  11930. },
  11931. "name": isVoid ? voidIcon : icon,
  11932. "class": bem$g("icon", ["half", {
  11933. disabled,
  11934. full: !isVoid
  11935. }]),
  11936. "color": disabled ? disabledColor : isVoid ? voidColor : color,
  11937. "classPrefix": iconPrefix
  11938. }, null)]);
  11939. };
  11940. use.useCustomFieldValue(() => props.modelValue);
  11941. use.useEventListener("touchmove", onTouchMove, {
  11942. target: groupRef
  11943. });
  11944. return () => vue.createVNode("div", {
  11945. "ref": groupRef,
  11946. "role": "radiogroup",
  11947. "class": bem$g({
  11948. readonly: props.readonly,
  11949. disabled: props.disabled
  11950. }),
  11951. "tabindex": props.disabled ? void 0 : 0,
  11952. "aria-disabled": props.disabled,
  11953. "aria-readonly": props.readonly,
  11954. "onTouchstartPassive": onTouchStart
  11955. }, [list.value.map(renderStar)]);
  11956. }
  11957. });
  11958. const Rate = withInstall(stdin_default$l);
  11959. const Row = withInstall(stdin_default$V);
  11960. const [name$f, bem$f, t$3] = createNamespace("search");
  11961. const searchProps = extend({}, fieldSharedProps, {
  11962. label: String,
  11963. shape: makeStringProp("square"),
  11964. leftIcon: makeStringProp("search"),
  11965. clearable: truthProp,
  11966. actionText: String,
  11967. background: String,
  11968. showAction: Boolean
  11969. });
  11970. var stdin_default$k = vue.defineComponent({
  11971. name: name$f,
  11972. props: searchProps,
  11973. emits: ["blur", "focus", "clear", "search", "cancel", "click-input", "click-left-icon", "click-right-icon", "update:modelValue"],
  11974. setup(props, {
  11975. emit,
  11976. slots,
  11977. attrs
  11978. }) {
  11979. const id = useId();
  11980. const filedRef = vue.ref();
  11981. const onCancel = () => {
  11982. if (!slots.action) {
  11983. emit("update:modelValue", "");
  11984. emit("cancel");
  11985. }
  11986. };
  11987. const onKeypress = (event) => {
  11988. const ENTER_CODE = 13;
  11989. if (event.keyCode === ENTER_CODE) {
  11990. preventDefault(event);
  11991. emit("search", props.modelValue);
  11992. }
  11993. };
  11994. const getInputId = () => props.id || `${id}-input`;
  11995. const renderLabel = () => {
  11996. if (slots.label || props.label) {
  11997. return vue.createVNode("label", {
  11998. "class": bem$f("label"),
  11999. "for": getInputId()
  12000. }, [slots.label ? slots.label() : props.label]);
  12001. }
  12002. };
  12003. const renderAction = () => {
  12004. if (props.showAction) {
  12005. const text = props.actionText || t$3("cancel");
  12006. return vue.createVNode("div", {
  12007. "class": bem$f("action"),
  12008. "role": "button",
  12009. "tabindex": 0,
  12010. "onClick": onCancel
  12011. }, [slots.action ? slots.action() : text]);
  12012. }
  12013. };
  12014. const blur = () => {
  12015. var _a;
  12016. return (_a = filedRef.value) == null ? void 0 : _a.blur();
  12017. };
  12018. const focus = () => {
  12019. var _a;
  12020. return (_a = filedRef.value) == null ? void 0 : _a.focus();
  12021. };
  12022. const onBlur = (event) => emit("blur", event);
  12023. const onFocus = (event) => emit("focus", event);
  12024. const onClear = (event) => emit("clear", event);
  12025. const onClickInput = (event) => emit("click-input", event);
  12026. const onClickLeftIcon = (event) => emit("click-left-icon", event);
  12027. const onClickRightIcon = (event) => emit("click-right-icon", event);
  12028. const fieldPropNames = Object.keys(fieldSharedProps);
  12029. const renderField = () => {
  12030. const fieldAttrs = extend({}, attrs, pick(props, fieldPropNames), {
  12031. id: getInputId()
  12032. });
  12033. const onInput = (value) => emit("update:modelValue", value);
  12034. return vue.createVNode(Field, vue.mergeProps({
  12035. "ref": filedRef,
  12036. "type": "search",
  12037. "class": bem$f("field"),
  12038. "border": false,
  12039. "onBlur": onBlur,
  12040. "onFocus": onFocus,
  12041. "onClear": onClear,
  12042. "onKeypress": onKeypress,
  12043. "onClick-input": onClickInput,
  12044. "onClick-left-icon": onClickLeftIcon,
  12045. "onClick-right-icon": onClickRightIcon,
  12046. "onUpdate:modelValue": onInput
  12047. }, fieldAttrs), pick(slots, ["left-icon", "right-icon"]));
  12048. };
  12049. useExpose({
  12050. focus,
  12051. blur
  12052. });
  12053. return () => {
  12054. var _a;
  12055. return vue.createVNode("div", {
  12056. "class": bem$f({
  12057. "show-action": props.showAction
  12058. }),
  12059. "style": {
  12060. background: props.background
  12061. }
  12062. }, [(_a = slots.left) == null ? void 0 : _a.call(slots), vue.createVNode("div", {
  12063. "class": bem$f("content", props.shape)
  12064. }, [renderLabel(), renderField()]), renderAction()]);
  12065. };
  12066. }
  12067. });
  12068. const Search = withInstall(stdin_default$k);
  12069. const popupInheritKeys = [...popupSharedPropKeys, "round", "closeOnPopstate", "safeAreaInsetBottom"];
  12070. const iconMap = {
  12071. qq: "qq",
  12072. link: "link-o",
  12073. weibo: "weibo",
  12074. qrcode: "qr",
  12075. poster: "photo-o",
  12076. wechat: "wechat",
  12077. "weapp-qrcode": "miniprogram-o",
  12078. "wechat-moments": "wechat-moments"
  12079. };
  12080. const [name$e, bem$e, t$2] = createNamespace("share-sheet");
  12081. const shareSheetProps = extend({}, popupSharedProps, {
  12082. title: String,
  12083. round: truthProp,
  12084. options: makeArrayProp(),
  12085. cancelText: String,
  12086. description: String,
  12087. closeOnPopstate: truthProp,
  12088. safeAreaInsetBottom: truthProp
  12089. });
  12090. var stdin_default$j = vue.defineComponent({
  12091. name: name$e,
  12092. props: shareSheetProps,
  12093. emits: ["cancel", "select", "update:show"],
  12094. setup(props, {
  12095. emit,
  12096. slots
  12097. }) {
  12098. const updateShow = (value) => emit("update:show", value);
  12099. const onCancel = () => {
  12100. updateShow(false);
  12101. emit("cancel");
  12102. };
  12103. const onSelect = (option, index) => emit("select", option, index);
  12104. const renderHeader = () => {
  12105. const title = slots.title ? slots.title() : props.title;
  12106. const description = slots.description ? slots.description() : props.description;
  12107. if (title || description) {
  12108. return vue.createVNode("div", {
  12109. "class": bem$e("header")
  12110. }, [title && vue.createVNode("h2", {
  12111. "class": bem$e("title")
  12112. }, [title]), description && vue.createVNode("span", {
  12113. "class": bem$e("description")
  12114. }, [description])]);
  12115. }
  12116. };
  12117. const renderIcon = (icon) => {
  12118. if (iconMap[icon]) {
  12119. return vue.createVNode("div", {
  12120. "class": bem$e("icon", [icon])
  12121. }, [vue.createVNode(Icon, {
  12122. "name": iconMap[icon] || icon
  12123. }, null)]);
  12124. }
  12125. return vue.createVNode("img", {
  12126. "src": icon,
  12127. "class": bem$e("image-icon")
  12128. }, null);
  12129. };
  12130. const renderOption = (option, index) => {
  12131. const {
  12132. name: name2,
  12133. icon,
  12134. className,
  12135. description
  12136. } = option;
  12137. return vue.createVNode("div", {
  12138. "role": "button",
  12139. "tabindex": 0,
  12140. "class": [bem$e("option"), className, HAPTICS_FEEDBACK],
  12141. "onClick": () => onSelect(option, index)
  12142. }, [renderIcon(icon), name2 && vue.createVNode("span", {
  12143. "class": bem$e("name")
  12144. }, [name2]), description && vue.createVNode("span", {
  12145. "class": bem$e("option-description")
  12146. }, [description])]);
  12147. };
  12148. const renderOptions = (options, border) => vue.createVNode("div", {
  12149. "class": bem$e("options", {
  12150. border
  12151. })
  12152. }, [options.map(renderOption)]);
  12153. const renderRows = () => {
  12154. const {
  12155. options
  12156. } = props;
  12157. if (Array.isArray(options[0])) {
  12158. return options.map((item, index) => renderOptions(item, index !== 0));
  12159. }
  12160. return renderOptions(options);
  12161. };
  12162. const renderCancelButton = () => {
  12163. var _a;
  12164. const cancelText = (_a = props.cancelText) != null ? _a : t$2("cancel");
  12165. if (slots.cancel || cancelText) {
  12166. return vue.createVNode("button", {
  12167. "type": "button",
  12168. "class": bem$e("cancel"),
  12169. "onClick": onCancel
  12170. }, [slots.cancel ? slots.cancel() : cancelText]);
  12171. }
  12172. };
  12173. return () => vue.createVNode(Popup, vue.mergeProps({
  12174. "class": bem$e(),
  12175. "position": "bottom",
  12176. "onUpdate:show": updateShow
  12177. }, pick(props, popupInheritKeys)), {
  12178. default: () => [renderHeader(), renderRows(), renderCancelButton()]
  12179. });
  12180. }
  12181. });
  12182. const ShareSheet = withInstall(stdin_default$j);
  12183. const [name$d, bem$d] = createNamespace("sidebar");
  12184. const SIDEBAR_KEY = Symbol(name$d);
  12185. const sidebarProps = {
  12186. modelValue: makeNumericProp(0)
  12187. };
  12188. var stdin_default$i = vue.defineComponent({
  12189. name: name$d,
  12190. props: sidebarProps,
  12191. emits: ["change", "update:modelValue"],
  12192. setup(props, {
  12193. emit,
  12194. slots
  12195. }) {
  12196. const {
  12197. linkChildren
  12198. } = use.useChildren(SIDEBAR_KEY);
  12199. const getActive = () => +props.modelValue;
  12200. const setActive = (value) => {
  12201. if (value !== getActive()) {
  12202. emit("update:modelValue", value);
  12203. emit("change", value);
  12204. }
  12205. };
  12206. linkChildren({
  12207. getActive,
  12208. setActive
  12209. });
  12210. return () => {
  12211. var _a;
  12212. return vue.createVNode("div", {
  12213. "role": "tablist",
  12214. "class": bem$d()
  12215. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
  12216. };
  12217. }
  12218. });
  12219. const Sidebar = withInstall(stdin_default$i);
  12220. const [name$c, bem$c] = createNamespace("sidebar-item");
  12221. const sidebarItemProps = extend({}, routeProps, {
  12222. dot: Boolean,
  12223. title: String,
  12224. badge: numericProp,
  12225. disabled: Boolean,
  12226. badgeProps: Object
  12227. });
  12228. var stdin_default$h = vue.defineComponent({
  12229. name: name$c,
  12230. props: sidebarItemProps,
  12231. emits: ["click"],
  12232. setup(props, {
  12233. emit,
  12234. slots
  12235. }) {
  12236. const route2 = useRoute();
  12237. const {
  12238. parent,
  12239. index
  12240. } = use.useParent(SIDEBAR_KEY);
  12241. if (!parent) {
  12242. if (process.env.NODE_ENV !== "production") {
  12243. console.error("[Vant] <SidebarItem> must be a child component of <Sidebar>.");
  12244. }
  12245. return;
  12246. }
  12247. const onClick = () => {
  12248. if (props.disabled) {
  12249. return;
  12250. }
  12251. emit("click", index.value);
  12252. parent.setActive(index.value);
  12253. route2();
  12254. };
  12255. return () => {
  12256. const {
  12257. dot,
  12258. badge,
  12259. title,
  12260. disabled
  12261. } = props;
  12262. const selected = index.value === parent.getActive();
  12263. return vue.createVNode("div", {
  12264. "role": "tab",
  12265. "class": bem$c({
  12266. select: selected,
  12267. disabled
  12268. }),
  12269. "tabindex": disabled ? void 0 : 0,
  12270. "aria-selected": selected,
  12271. "onClick": onClick
  12272. }, [vue.createVNode(Badge, vue.mergeProps({
  12273. "dot": dot,
  12274. "class": bem$c("text"),
  12275. "content": badge
  12276. }, props.badgeProps), {
  12277. default: () => [slots.title ? slots.title() : title]
  12278. })]);
  12279. };
  12280. }
  12281. });
  12282. const SidebarItem = withInstall(stdin_default$h);
  12283. const [name$b, bem$b] = createNamespace("skeleton");
  12284. const DEFAULT_ROW_WIDTH = "100%";
  12285. const DEFAULT_LAST_ROW_WIDTH = "60%";
  12286. const skeletonProps = {
  12287. row: makeNumericProp(0),
  12288. title: Boolean,
  12289. round: Boolean,
  12290. avatar: Boolean,
  12291. loading: truthProp,
  12292. animate: truthProp,
  12293. avatarSize: numericProp,
  12294. titleWidth: numericProp,
  12295. avatarShape: makeStringProp("round"),
  12296. rowWidth: {
  12297. type: [Number, String, Array],
  12298. default: DEFAULT_ROW_WIDTH
  12299. }
  12300. };
  12301. var stdin_default$g = vue.defineComponent({
  12302. name: name$b,
  12303. inheritAttrs: false,
  12304. props: skeletonProps,
  12305. setup(props, {
  12306. slots,
  12307. attrs
  12308. }) {
  12309. const renderAvatar = () => {
  12310. if (props.avatar) {
  12311. return vue.createVNode("div", {
  12312. "class": bem$b("avatar", props.avatarShape),
  12313. "style": getSizeStyle(props.avatarSize)
  12314. }, null);
  12315. }
  12316. };
  12317. const renderTitle = () => {
  12318. if (props.title) {
  12319. return vue.createVNode("h3", {
  12320. "class": bem$b("title"),
  12321. "style": {
  12322. width: addUnit(props.titleWidth)
  12323. }
  12324. }, null);
  12325. }
  12326. };
  12327. const getRowWidth = (index) => {
  12328. const {
  12329. rowWidth
  12330. } = props;
  12331. if (rowWidth === DEFAULT_ROW_WIDTH && index === +props.row - 1) {
  12332. return DEFAULT_LAST_ROW_WIDTH;
  12333. }
  12334. if (Array.isArray(rowWidth)) {
  12335. return rowWidth[index];
  12336. }
  12337. return rowWidth;
  12338. };
  12339. const renderRows = () => Array(+props.row).fill("").map((_, i) => vue.createVNode("div", {
  12340. "class": bem$b("row"),
  12341. "style": {
  12342. width: addUnit(getRowWidth(i))
  12343. }
  12344. }, null));
  12345. return () => {
  12346. var _a;
  12347. if (!props.loading) {
  12348. return (_a = slots.default) == null ? void 0 : _a.call(slots);
  12349. }
  12350. return vue.createVNode("div", vue.mergeProps({
  12351. "class": bem$b({
  12352. animate: props.animate,
  12353. round: props.round
  12354. })
  12355. }, attrs), [renderAvatar(), vue.createVNode("div", {
  12356. "class": bem$b("content")
  12357. }, [renderTitle(), renderRows()])]);
  12358. };
  12359. }
  12360. });
  12361. const Skeleton = withInstall(stdin_default$g);
  12362. const [name$a, bem$a] = createNamespace("slider");
  12363. const sliderProps = {
  12364. min: makeNumericProp(0),
  12365. max: makeNumericProp(100),
  12366. step: makeNumericProp(1),
  12367. range: Boolean,
  12368. reverse: Boolean,
  12369. disabled: Boolean,
  12370. readonly: Boolean,
  12371. vertical: Boolean,
  12372. barHeight: numericProp,
  12373. buttonSize: numericProp,
  12374. activeColor: String,
  12375. inactiveColor: String,
  12376. modelValue: {
  12377. type: [Number, Array],
  12378. default: 0
  12379. }
  12380. };
  12381. var stdin_default$f = vue.defineComponent({
  12382. name: name$a,
  12383. props: sliderProps,
  12384. emits: ["change", "drag-end", "drag-start", "update:modelValue"],
  12385. setup(props, {
  12386. emit,
  12387. slots
  12388. }) {
  12389. let buttonIndex;
  12390. let current2;
  12391. let startValue;
  12392. const root = vue.ref();
  12393. const slider = vue.ref();
  12394. const dragStatus = vue.ref();
  12395. const touch = useTouch();
  12396. const scope = vue.computed(() => Number(props.max) - Number(props.min));
  12397. const wrapperStyle = vue.computed(() => {
  12398. const crossAxis = props.vertical ? "width" : "height";
  12399. return {
  12400. background: props.inactiveColor,
  12401. [crossAxis]: addUnit(props.barHeight)
  12402. };
  12403. });
  12404. const isRange = (val) => props.range && Array.isArray(val);
  12405. const calcMainAxis = () => {
  12406. const {
  12407. modelValue,
  12408. min
  12409. } = props;
  12410. if (isRange(modelValue)) {
  12411. return `${(modelValue[1] - modelValue[0]) * 100 / scope.value}%`;
  12412. }
  12413. return `${(modelValue - Number(min)) * 100 / scope.value}%`;
  12414. };
  12415. const calcOffset = () => {
  12416. const {
  12417. modelValue,
  12418. min
  12419. } = props;
  12420. if (isRange(modelValue)) {
  12421. return `${(modelValue[0] - Number(min)) * 100 / scope.value}%`;
  12422. }
  12423. return "0%";
  12424. };
  12425. const barStyle = vue.computed(() => {
  12426. const mainAxis = props.vertical ? "height" : "width";
  12427. const style = {
  12428. [mainAxis]: calcMainAxis(),
  12429. background: props.activeColor
  12430. };
  12431. if (dragStatus.value) {
  12432. style.transition = "none";
  12433. }
  12434. const getPositionKey = () => {
  12435. if (props.vertical) {
  12436. return props.reverse ? "bottom" : "top";
  12437. }
  12438. return props.reverse ? "right" : "left";
  12439. };
  12440. style[getPositionKey()] = calcOffset();
  12441. return style;
  12442. });
  12443. const format2 = (value) => {
  12444. const min = +props.min;
  12445. const max = +props.max;
  12446. const step = +props.step;
  12447. value = clamp(value, min, max);
  12448. const diff = Math.round((value - min) / step) * step;
  12449. return addNumber(min, diff);
  12450. };
  12451. const isSameValue = (newValue, oldValue) => JSON.stringify(newValue) === JSON.stringify(oldValue);
  12452. const handleRangeValue = (value) => {
  12453. var _a, _b;
  12454. const left = (_a = value[0]) != null ? _a : Number(props.min);
  12455. const right = (_b = value[1]) != null ? _b : Number(props.max);
  12456. return left > right ? [right, left] : [left, right];
  12457. };
  12458. const updateValue = (value, end) => {
  12459. if (isRange(value)) {
  12460. value = handleRangeValue(value).map(format2);
  12461. } else {
  12462. value = format2(value);
  12463. }
  12464. if (!isSameValue(value, props.modelValue)) {
  12465. emit("update:modelValue", value);
  12466. }
  12467. if (end && !isSameValue(value, startValue)) {
  12468. emit("change", value);
  12469. }
  12470. };
  12471. const onClick = (event) => {
  12472. event.stopPropagation();
  12473. if (props.disabled || props.readonly) {
  12474. return;
  12475. }
  12476. const {
  12477. min,
  12478. reverse,
  12479. vertical,
  12480. modelValue
  12481. } = props;
  12482. const rect = use.useRect(root);
  12483. const getDelta = () => {
  12484. if (vertical) {
  12485. if (reverse) {
  12486. return rect.bottom - event.clientY;
  12487. }
  12488. return event.clientY - rect.top;
  12489. }
  12490. if (reverse) {
  12491. return rect.right - event.clientX;
  12492. }
  12493. return event.clientX - rect.left;
  12494. };
  12495. const total = vertical ? rect.height : rect.width;
  12496. const value = Number(min) + getDelta() / total * scope.value;
  12497. if (isRange(modelValue)) {
  12498. const [left, right] = modelValue;
  12499. const middle = (left + right) / 2;
  12500. if (value <= middle) {
  12501. updateValue([value, right], true);
  12502. } else {
  12503. updateValue([left, value], true);
  12504. }
  12505. } else {
  12506. updateValue(value, true);
  12507. }
  12508. };
  12509. const onTouchStart = (event) => {
  12510. if (props.disabled || props.readonly) {
  12511. return;
  12512. }
  12513. touch.start(event);
  12514. current2 = props.modelValue;
  12515. if (isRange(current2)) {
  12516. startValue = current2.map(format2);
  12517. } else {
  12518. startValue = format2(current2);
  12519. }
  12520. dragStatus.value = "start";
  12521. };
  12522. const onTouchMove = (event) => {
  12523. if (props.disabled || props.readonly) {
  12524. return;
  12525. }
  12526. if (dragStatus.value === "start") {
  12527. emit("drag-start", event);
  12528. }
  12529. preventDefault(event, true);
  12530. touch.move(event);
  12531. dragStatus.value = "dragging";
  12532. const rect = use.useRect(root);
  12533. const delta = props.vertical ? touch.deltaY.value : touch.deltaX.value;
  12534. const total = props.vertical ? rect.height : rect.width;
  12535. let diff = delta / total * scope.value;
  12536. if (props.reverse) {
  12537. diff = -diff;
  12538. }
  12539. if (isRange(startValue)) {
  12540. const index = props.reverse ? 1 - buttonIndex : buttonIndex;
  12541. current2[index] = startValue[index] + diff;
  12542. } else {
  12543. current2 = startValue + diff;
  12544. }
  12545. updateValue(current2);
  12546. };
  12547. const onTouchEnd = (event) => {
  12548. if (props.disabled || props.readonly) {
  12549. return;
  12550. }
  12551. if (dragStatus.value === "dragging") {
  12552. updateValue(current2, true);
  12553. emit("drag-end", event);
  12554. }
  12555. dragStatus.value = "";
  12556. };
  12557. const getButtonClassName = (index) => {
  12558. if (typeof index === "number") {
  12559. const position = ["left", "right"];
  12560. return bem$a(`button-wrapper`, position[index]);
  12561. }
  12562. return bem$a("button-wrapper", props.reverse ? "left" : "right");
  12563. };
  12564. const renderButtonContent = (value, index) => {
  12565. if (typeof index === "number") {
  12566. const slot = slots[index === 0 ? "left-button" : "right-button"];
  12567. if (slot) {
  12568. return slot({
  12569. value
  12570. });
  12571. }
  12572. }
  12573. if (slots.button) {
  12574. return slots.button({
  12575. value
  12576. });
  12577. }
  12578. return vue.createVNode("div", {
  12579. "class": bem$a("button"),
  12580. "style": getSizeStyle(props.buttonSize)
  12581. }, null);
  12582. };
  12583. const renderButton = (index) => {
  12584. const current22 = typeof index === "number" ? props.modelValue[index] : props.modelValue;
  12585. return vue.createVNode("div", {
  12586. "ref": slider,
  12587. "role": "slider",
  12588. "class": getButtonClassName(index),
  12589. "tabindex": props.disabled ? void 0 : 0,
  12590. "aria-valuemin": props.min,
  12591. "aria-valuenow": current22,
  12592. "aria-valuemax": props.max,
  12593. "aria-disabled": props.disabled || void 0,
  12594. "aria-readonly": props.readonly || void 0,
  12595. "aria-orientation": props.vertical ? "vertical" : "horizontal",
  12596. "onTouchstartPassive": (event) => {
  12597. if (typeof index === "number") {
  12598. buttonIndex = index;
  12599. }
  12600. onTouchStart(event);
  12601. },
  12602. "onTouchend": onTouchEnd,
  12603. "onTouchcancel": onTouchEnd,
  12604. "onClick": stopPropagation
  12605. }, [renderButtonContent(current22, index)]);
  12606. };
  12607. updateValue(props.modelValue);
  12608. use.useCustomFieldValue(() => props.modelValue);
  12609. use.useEventListener("touchmove", onTouchMove, {
  12610. target: slider
  12611. });
  12612. return () => vue.createVNode("div", {
  12613. "ref": root,
  12614. "style": wrapperStyle.value,
  12615. "class": bem$a({
  12616. vertical: props.vertical,
  12617. disabled: props.disabled
  12618. }),
  12619. "onClick": onClick
  12620. }, [vue.createVNode("div", {
  12621. "class": bem$a("bar"),
  12622. "style": barStyle.value
  12623. }, [props.range ? [renderButton(0), renderButton(1)] : renderButton()])]);
  12624. }
  12625. });
  12626. const Slider = withInstall(stdin_default$f);
  12627. const [name$9, bem$9] = createNamespace("space");
  12628. const spaceProps = {
  12629. align: String,
  12630. direction: {
  12631. type: String,
  12632. default: "horizontal"
  12633. },
  12634. size: {
  12635. type: [Number, String, Array],
  12636. default: 8
  12637. },
  12638. wrap: Boolean,
  12639. fill: Boolean
  12640. };
  12641. function filterEmpty(children = []) {
  12642. const nodes = [];
  12643. children.forEach((child) => {
  12644. if (Array.isArray(child)) {
  12645. nodes.push(...child);
  12646. } else if (child.type === vue.Fragment) {
  12647. nodes.push(...filterEmpty(child.children));
  12648. } else {
  12649. nodes.push(child);
  12650. }
  12651. });
  12652. return nodes.filter((c) => {
  12653. var _a;
  12654. return !(c && (typeof Comment !== "undefined" && c.type === Comment || c.type === vue.Fragment && ((_a = c.children) == null ? void 0 : _a.length) === 0 || c.type === Text && c.children.trim() === ""));
  12655. });
  12656. }
  12657. var stdin_default$e = vue.defineComponent({
  12658. name: name$9,
  12659. props: spaceProps,
  12660. setup(props, {
  12661. slots
  12662. }) {
  12663. const mergedAlign = vue.computed(() => {
  12664. var _a;
  12665. return (_a = props.align) != null ? _a : props.direction === "horizontal" ? "center" : "";
  12666. });
  12667. const getMargin = (size) => {
  12668. if (typeof size === "number") {
  12669. return size + "px";
  12670. }
  12671. return size;
  12672. };
  12673. const getMarginStyle = (isLast) => {
  12674. const style = {};
  12675. const marginRight = `${getMargin(Array.isArray(props.size) ? props.size[0] : props.size)}`;
  12676. const marginBottom = `${getMargin(Array.isArray(props.size) ? props.size[1] : props.size)}`;
  12677. if (isLast) {
  12678. return props.wrap ? {
  12679. marginBottom
  12680. } : {};
  12681. }
  12682. if (props.direction === "horizontal") {
  12683. style.marginRight = marginRight;
  12684. }
  12685. if (props.direction === "vertical" || props.wrap) {
  12686. style.marginBottom = marginBottom;
  12687. }
  12688. return style;
  12689. };
  12690. return () => {
  12691. var _a;
  12692. const children = filterEmpty((_a = slots.default) == null ? void 0 : _a.call(slots));
  12693. return vue.createVNode("div", {
  12694. "class": [bem$9({
  12695. [props.direction]: props.direction,
  12696. [`align-${mergedAlign.value}`]: mergedAlign.value,
  12697. wrap: props.wrap,
  12698. fill: props.fill
  12699. })]
  12700. }, [children.map((c, i) => vue.createVNode("div", {
  12701. "key": `item-${i}`,
  12702. "class": `${name$9}-item`,
  12703. "style": getMarginStyle(i === children.length - 1)
  12704. }, [c]))]);
  12705. };
  12706. }
  12707. });
  12708. const Space = withInstall(stdin_default$e);
  12709. const [name$8, bem$8] = createNamespace("steps");
  12710. const stepsProps = {
  12711. active: makeNumericProp(0),
  12712. direction: makeStringProp("horizontal"),
  12713. activeIcon: makeStringProp("checked"),
  12714. iconPrefix: String,
  12715. finishIcon: String,
  12716. activeColor: String,
  12717. inactiveIcon: String,
  12718. inactiveColor: String
  12719. };
  12720. const STEPS_KEY = Symbol(name$8);
  12721. var stdin_default$d = vue.defineComponent({
  12722. name: name$8,
  12723. props: stepsProps,
  12724. emits: ["click-step"],
  12725. setup(props, {
  12726. emit,
  12727. slots
  12728. }) {
  12729. const {
  12730. linkChildren
  12731. } = use.useChildren(STEPS_KEY);
  12732. const onClickStep = (index) => emit("click-step", index);
  12733. linkChildren({
  12734. props,
  12735. onClickStep
  12736. });
  12737. return () => {
  12738. var _a;
  12739. return vue.createVNode("div", {
  12740. "class": bem$8([props.direction])
  12741. }, [vue.createVNode("div", {
  12742. "class": bem$8("items")
  12743. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)])]);
  12744. };
  12745. }
  12746. });
  12747. const [name$7, bem$7] = createNamespace("step");
  12748. var stdin_default$c = vue.defineComponent({
  12749. name: name$7,
  12750. setup(props, {
  12751. slots
  12752. }) {
  12753. const {
  12754. parent,
  12755. index
  12756. } = use.useParent(STEPS_KEY);
  12757. if (!parent) {
  12758. if (process.env.NODE_ENV !== "production") {
  12759. console.error("[Vant] <Step> must be a child component of <Steps>.");
  12760. }
  12761. return;
  12762. }
  12763. const parentProps = parent.props;
  12764. const getStatus = () => {
  12765. const active = +parentProps.active;
  12766. if (index.value < active) {
  12767. return "finish";
  12768. }
  12769. return index.value === active ? "process" : "waiting";
  12770. };
  12771. const isActive = () => getStatus() === "process";
  12772. const lineStyle = vue.computed(() => ({
  12773. background: getStatus() === "finish" ? parentProps.activeColor : parentProps.inactiveColor
  12774. }));
  12775. const titleStyle = vue.computed(() => {
  12776. if (isActive()) {
  12777. return {
  12778. color: parentProps.activeColor
  12779. };
  12780. }
  12781. if (getStatus() === "waiting") {
  12782. return {
  12783. color: parentProps.inactiveColor
  12784. };
  12785. }
  12786. });
  12787. const onClickStep = () => parent.onClickStep(index.value);
  12788. const renderCircle = () => {
  12789. const {
  12790. iconPrefix,
  12791. finishIcon,
  12792. activeIcon,
  12793. activeColor,
  12794. inactiveIcon
  12795. } = parentProps;
  12796. if (isActive()) {
  12797. if (slots["active-icon"]) {
  12798. return slots["active-icon"]();
  12799. }
  12800. return vue.createVNode(Icon, {
  12801. "class": bem$7("icon", "active"),
  12802. "name": activeIcon,
  12803. "color": activeColor,
  12804. "classPrefix": iconPrefix
  12805. }, null);
  12806. }
  12807. if (getStatus() === "finish" && (finishIcon || slots["finish-icon"])) {
  12808. if (slots["finish-icon"]) {
  12809. return slots["finish-icon"]();
  12810. }
  12811. return vue.createVNode(Icon, {
  12812. "class": bem$7("icon", "finish"),
  12813. "name": finishIcon,
  12814. "color": activeColor,
  12815. "classPrefix": iconPrefix
  12816. }, null);
  12817. }
  12818. if (slots["inactive-icon"]) {
  12819. return slots["inactive-icon"]();
  12820. }
  12821. if (inactiveIcon) {
  12822. return vue.createVNode(Icon, {
  12823. "class": bem$7("icon"),
  12824. "name": inactiveIcon,
  12825. "classPrefix": iconPrefix
  12826. }, null);
  12827. }
  12828. return vue.createVNode("i", {
  12829. "class": bem$7("circle"),
  12830. "style": lineStyle.value
  12831. }, null);
  12832. };
  12833. return () => {
  12834. var _a;
  12835. const status = getStatus();
  12836. return vue.createVNode("div", {
  12837. "class": [BORDER, bem$7([parentProps.direction, {
  12838. [status]: status
  12839. }])]
  12840. }, [vue.createVNode("div", {
  12841. "class": bem$7("title", {
  12842. active: isActive()
  12843. }),
  12844. "style": titleStyle.value,
  12845. "onClick": onClickStep
  12846. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]), vue.createVNode("div", {
  12847. "class": bem$7("circle-container"),
  12848. "onClick": onClickStep
  12849. }, [renderCircle()]), vue.createVNode("div", {
  12850. "class": bem$7("line"),
  12851. "style": lineStyle.value
  12852. }, null)]);
  12853. };
  12854. }
  12855. });
  12856. const Step = withInstall(stdin_default$c);
  12857. const [name$6, bem$6] = createNamespace("stepper");
  12858. const LONG_PRESS_INTERVAL = 200;
  12859. const LONG_PRESS_START_TIME = 600;
  12860. const isEqual = (value1, value2) => String(value1) === String(value2);
  12861. const stepperProps = {
  12862. min: makeNumericProp(1),
  12863. max: makeNumericProp(Infinity),
  12864. name: makeNumericProp(""),
  12865. step: makeNumericProp(1),
  12866. theme: String,
  12867. integer: Boolean,
  12868. disabled: Boolean,
  12869. showPlus: truthProp,
  12870. showMinus: truthProp,
  12871. showInput: truthProp,
  12872. longPress: truthProp,
  12873. allowEmpty: Boolean,
  12874. modelValue: numericProp,
  12875. inputWidth: numericProp,
  12876. buttonSize: numericProp,
  12877. placeholder: String,
  12878. disablePlus: Boolean,
  12879. disableMinus: Boolean,
  12880. disableInput: Boolean,
  12881. beforeChange: Function,
  12882. defaultValue: makeNumericProp(1),
  12883. decimalLength: numericProp
  12884. };
  12885. var stdin_default$b = vue.defineComponent({
  12886. name: name$6,
  12887. props: stepperProps,
  12888. emits: ["plus", "blur", "minus", "focus", "change", "overlimit", "update:modelValue"],
  12889. setup(props, {
  12890. emit
  12891. }) {
  12892. const format2 = (value) => {
  12893. const {
  12894. min,
  12895. max,
  12896. allowEmpty,
  12897. decimalLength
  12898. } = props;
  12899. if (allowEmpty && value === "") {
  12900. return value;
  12901. }
  12902. value = formatNumber(String(value), !props.integer);
  12903. value = value === "" ? 0 : +value;
  12904. value = Number.isNaN(value) ? +min : value;
  12905. value = Math.max(Math.min(+max, value), +min);
  12906. if (isDef(decimalLength)) {
  12907. value = value.toFixed(+decimalLength);
  12908. }
  12909. return value;
  12910. };
  12911. const getInitialValue = () => {
  12912. var _a;
  12913. const defaultValue = (_a = props.modelValue) != null ? _a : props.defaultValue;
  12914. const value = format2(defaultValue);
  12915. if (!isEqual(value, props.modelValue)) {
  12916. emit("update:modelValue", value);
  12917. }
  12918. return value;
  12919. };
  12920. let actionType;
  12921. const inputRef = vue.ref();
  12922. const current2 = vue.ref(getInitialValue());
  12923. const minusDisabled = vue.computed(() => props.disabled || props.disableMinus || current2.value <= +props.min);
  12924. const plusDisabled = vue.computed(() => props.disabled || props.disablePlus || current2.value >= +props.max);
  12925. const inputStyle = vue.computed(() => ({
  12926. width: addUnit(props.inputWidth),
  12927. height: addUnit(props.buttonSize)
  12928. }));
  12929. const buttonStyle = vue.computed(() => getSizeStyle(props.buttonSize));
  12930. const check = () => {
  12931. const value = format2(current2.value);
  12932. if (!isEqual(value, current2.value)) {
  12933. current2.value = value;
  12934. }
  12935. };
  12936. const setValue = (value) => {
  12937. if (props.beforeChange) {
  12938. callInterceptor(props.beforeChange, {
  12939. args: [value],
  12940. done() {
  12941. current2.value = value;
  12942. }
  12943. });
  12944. } else {
  12945. current2.value = value;
  12946. }
  12947. };
  12948. const onChange = () => {
  12949. if (actionType === "plus" && plusDisabled.value || actionType === "minus" && minusDisabled.value) {
  12950. emit("overlimit", actionType);
  12951. return;
  12952. }
  12953. const diff = actionType === "minus" ? -props.step : +props.step;
  12954. const value = format2(addNumber(+current2.value, diff));
  12955. setValue(value);
  12956. emit(actionType);
  12957. };
  12958. const onInput = (event) => {
  12959. const input = event.target;
  12960. const {
  12961. value
  12962. } = input;
  12963. const {
  12964. decimalLength
  12965. } = props;
  12966. let formatted = formatNumber(String(value), !props.integer);
  12967. if (isDef(decimalLength) && formatted.includes(".")) {
  12968. const pair = formatted.split(".");
  12969. formatted = `${pair[0]}.${pair[1].slice(0, +decimalLength)}`;
  12970. }
  12971. if (props.beforeChange) {
  12972. input.value = String(current2.value);
  12973. } else if (!isEqual(value, formatted)) {
  12974. input.value = formatted;
  12975. }
  12976. const isNumeric2 = formatted === String(+formatted);
  12977. setValue(isNumeric2 ? +formatted : formatted);
  12978. };
  12979. const onFocus = (event) => {
  12980. var _a;
  12981. if (props.disableInput) {
  12982. (_a = inputRef.value) == null ? void 0 : _a.blur();
  12983. } else {
  12984. emit("focus", event);
  12985. }
  12986. };
  12987. const onBlur = (event) => {
  12988. const input = event.target;
  12989. const value = format2(input.value);
  12990. input.value = String(value);
  12991. current2.value = value;
  12992. vue.nextTick(() => {
  12993. emit("blur", event);
  12994. resetScroll();
  12995. });
  12996. };
  12997. let isLongPress;
  12998. let longPressTimer;
  12999. const longPressStep = () => {
  13000. longPressTimer = setTimeout(() => {
  13001. onChange();
  13002. longPressStep();
  13003. }, LONG_PRESS_INTERVAL);
  13004. };
  13005. const onTouchStart = () => {
  13006. if (props.longPress) {
  13007. isLongPress = false;
  13008. clearTimeout(longPressTimer);
  13009. longPressTimer = setTimeout(() => {
  13010. isLongPress = true;
  13011. onChange();
  13012. longPressStep();
  13013. }, LONG_PRESS_START_TIME);
  13014. }
  13015. };
  13016. const onTouchEnd = (event) => {
  13017. if (props.longPress) {
  13018. clearTimeout(longPressTimer);
  13019. if (isLongPress) {
  13020. preventDefault(event);
  13021. }
  13022. }
  13023. };
  13024. const onMousedown = (event) => {
  13025. if (props.disableInput) {
  13026. preventDefault(event);
  13027. }
  13028. };
  13029. const createListeners = (type) => ({
  13030. onClick: (event) => {
  13031. preventDefault(event);
  13032. actionType = type;
  13033. onChange();
  13034. },
  13035. onTouchstartPassive: () => {
  13036. actionType = type;
  13037. onTouchStart();
  13038. },
  13039. onTouchend: onTouchEnd,
  13040. onTouchcancel: onTouchEnd
  13041. });
  13042. vue.watch(() => [props.max, props.min, props.integer, props.decimalLength], check);
  13043. vue.watch(() => props.modelValue, (value) => {
  13044. if (!isEqual(value, current2.value)) {
  13045. current2.value = format2(value);
  13046. }
  13047. });
  13048. vue.watch(current2, (value) => {
  13049. emit("update:modelValue", value);
  13050. emit("change", value, {
  13051. name: props.name
  13052. });
  13053. });
  13054. use.useCustomFieldValue(() => props.modelValue);
  13055. return () => vue.createVNode("div", {
  13056. "role": "group",
  13057. "class": bem$6([props.theme])
  13058. }, [vue.withDirectives(vue.createVNode("button", vue.mergeProps({
  13059. "type": "button",
  13060. "style": buttonStyle.value,
  13061. "class": [bem$6("minus", {
  13062. disabled: minusDisabled.value
  13063. }), {
  13064. [HAPTICS_FEEDBACK]: !minusDisabled.value
  13065. }],
  13066. "aria-disabled": minusDisabled.value || void 0
  13067. }, createListeners("minus")), null), [[vue.vShow, props.showMinus]]), vue.withDirectives(vue.createVNode("input", {
  13068. "ref": inputRef,
  13069. "type": props.integer ? "tel" : "text",
  13070. "role": "spinbutton",
  13071. "class": bem$6("input"),
  13072. "value": current2.value,
  13073. "style": inputStyle.value,
  13074. "disabled": props.disabled,
  13075. "readonly": props.disableInput,
  13076. "inputmode": props.integer ? "numeric" : "decimal",
  13077. "placeholder": props.placeholder,
  13078. "aria-valuemax": props.max,
  13079. "aria-valuemin": props.min,
  13080. "aria-valuenow": current2.value,
  13081. "onBlur": onBlur,
  13082. "onInput": onInput,
  13083. "onFocus": onFocus,
  13084. "onMousedown": onMousedown
  13085. }, null), [[vue.vShow, props.showInput]]), vue.withDirectives(vue.createVNode("button", vue.mergeProps({
  13086. "type": "button",
  13087. "style": buttonStyle.value,
  13088. "class": [bem$6("plus", {
  13089. disabled: plusDisabled.value
  13090. }), {
  13091. [HAPTICS_FEEDBACK]: !plusDisabled.value
  13092. }],
  13093. "aria-disabled": plusDisabled.value || void 0
  13094. }, createListeners("plus")), null), [[vue.vShow, props.showPlus]])]);
  13095. }
  13096. });
  13097. const Stepper = withInstall(stdin_default$b);
  13098. const Steps = withInstall(stdin_default$d);
  13099. const [name$5, bem$5, t$1] = createNamespace("submit-bar");
  13100. const submitBarProps = {
  13101. tip: String,
  13102. label: String,
  13103. price: Number,
  13104. tipIcon: String,
  13105. loading: Boolean,
  13106. currency: makeStringProp("\xA5"),
  13107. disabled: Boolean,
  13108. textAlign: String,
  13109. buttonText: String,
  13110. buttonType: makeStringProp("danger"),
  13111. buttonColor: String,
  13112. suffixLabel: String,
  13113. placeholder: Boolean,
  13114. decimalLength: makeNumericProp(2),
  13115. safeAreaInsetBottom: truthProp
  13116. };
  13117. var stdin_default$a = vue.defineComponent({
  13118. name: name$5,
  13119. props: submitBarProps,
  13120. emits: ["submit"],
  13121. setup(props, {
  13122. emit,
  13123. slots
  13124. }) {
  13125. const root = vue.ref();
  13126. const renderPlaceholder = usePlaceholder(root, bem$5);
  13127. const renderText = () => {
  13128. const {
  13129. price,
  13130. label,
  13131. currency,
  13132. textAlign,
  13133. suffixLabel,
  13134. decimalLength
  13135. } = props;
  13136. if (typeof price === "number") {
  13137. const pricePair = (price / 100).toFixed(+decimalLength).split(".");
  13138. const decimal = decimalLength ? `.${pricePair[1]}` : "";
  13139. return vue.createVNode("div", {
  13140. "class": bem$5("text"),
  13141. "style": {
  13142. textAlign
  13143. }
  13144. }, [vue.createVNode("span", null, [label || t$1("label")]), vue.createVNode("span", {
  13145. "class": bem$5("price")
  13146. }, [currency, vue.createVNode("span", {
  13147. "class": bem$5("price-integer")
  13148. }, [pricePair[0]]), decimal]), suffixLabel && vue.createVNode("span", {
  13149. "class": bem$5("suffix-label")
  13150. }, [suffixLabel])]);
  13151. }
  13152. };
  13153. const renderTip = () => {
  13154. var _a;
  13155. const {
  13156. tip,
  13157. tipIcon
  13158. } = props;
  13159. if (slots.tip || tip) {
  13160. return vue.createVNode("div", {
  13161. "class": bem$5("tip")
  13162. }, [tipIcon && vue.createVNode(Icon, {
  13163. "class": bem$5("tip-icon"),
  13164. "name": tipIcon
  13165. }, null), tip && vue.createVNode("span", {
  13166. "class": bem$5("tip-text")
  13167. }, [tip]), (_a = slots.tip) == null ? void 0 : _a.call(slots)]);
  13168. }
  13169. };
  13170. const onClickButton = () => emit("submit");
  13171. const renderButton = () => {
  13172. if (slots.button) {
  13173. return slots.button();
  13174. }
  13175. return vue.createVNode(Button, {
  13176. "round": true,
  13177. "type": props.buttonType,
  13178. "text": props.buttonText,
  13179. "class": bem$5("button", props.buttonType),
  13180. "color": props.buttonColor,
  13181. "loading": props.loading,
  13182. "disabled": props.disabled,
  13183. "onClick": onClickButton
  13184. }, null);
  13185. };
  13186. const renderSubmitBar = () => {
  13187. var _a, _b;
  13188. return vue.createVNode("div", {
  13189. "ref": root,
  13190. "class": [bem$5(), {
  13191. "van-safe-area-bottom": props.safeAreaInsetBottom
  13192. }]
  13193. }, [(_a = slots.top) == null ? void 0 : _a.call(slots), renderTip(), vue.createVNode("div", {
  13194. "class": bem$5("bar")
  13195. }, [(_b = slots.default) == null ? void 0 : _b.call(slots), renderText(), renderButton()])]);
  13196. };
  13197. return () => {
  13198. if (props.placeholder) {
  13199. return renderPlaceholder(renderSubmitBar);
  13200. }
  13201. return renderSubmitBar();
  13202. };
  13203. }
  13204. });
  13205. const SubmitBar = withInstall(stdin_default$a);
  13206. const [name$4, bem$4] = createNamespace("swipe-cell");
  13207. const swipeCellProps = {
  13208. name: makeNumericProp(""),
  13209. disabled: Boolean,
  13210. leftWidth: numericProp,
  13211. rightWidth: numericProp,
  13212. beforeClose: Function,
  13213. stopPropagation: Boolean
  13214. };
  13215. var stdin_default$9 = vue.defineComponent({
  13216. name: name$4,
  13217. props: swipeCellProps,
  13218. emits: ["open", "close", "click"],
  13219. setup(props, {
  13220. emit,
  13221. slots
  13222. }) {
  13223. let opened;
  13224. let lockClick2;
  13225. let startOffset;
  13226. const root = vue.ref();
  13227. const leftRef = vue.ref();
  13228. const rightRef = vue.ref();
  13229. const state = vue.reactive({
  13230. offset: 0,
  13231. dragging: false
  13232. });
  13233. const touch = useTouch();
  13234. const getWidthByRef = (ref2) => ref2.value ? use.useRect(ref2).width : 0;
  13235. const leftWidth = vue.computed(() => isDef(props.leftWidth) ? +props.leftWidth : getWidthByRef(leftRef));
  13236. const rightWidth = vue.computed(() => isDef(props.rightWidth) ? +props.rightWidth : getWidthByRef(rightRef));
  13237. const open = (side) => {
  13238. state.offset = side === "left" ? leftWidth.value : -rightWidth.value;
  13239. if (!opened) {
  13240. opened = true;
  13241. emit("open", {
  13242. name: props.name,
  13243. position: side
  13244. });
  13245. }
  13246. };
  13247. const close = (position) => {
  13248. state.offset = 0;
  13249. if (opened) {
  13250. opened = false;
  13251. emit("close", {
  13252. name: props.name,
  13253. position
  13254. });
  13255. }
  13256. };
  13257. const toggle = (side) => {
  13258. const offset = Math.abs(state.offset);
  13259. const THRESHOLD = 0.15;
  13260. const threshold = opened ? 1 - THRESHOLD : THRESHOLD;
  13261. const width = side === "left" ? leftWidth.value : rightWidth.value;
  13262. if (width && offset > width * threshold) {
  13263. open(side);
  13264. } else {
  13265. close(side);
  13266. }
  13267. };
  13268. const onTouchStart = (event) => {
  13269. if (!props.disabled) {
  13270. startOffset = state.offset;
  13271. touch.start(event);
  13272. }
  13273. };
  13274. const onTouchMove = (event) => {
  13275. if (props.disabled) {
  13276. return;
  13277. }
  13278. const {
  13279. deltaX
  13280. } = touch;
  13281. touch.move(event);
  13282. if (touch.isHorizontal()) {
  13283. lockClick2 = true;
  13284. state.dragging = true;
  13285. const isEdge = !opened || deltaX.value * startOffset < 0;
  13286. if (isEdge) {
  13287. preventDefault(event, props.stopPropagation);
  13288. }
  13289. state.offset = clamp(deltaX.value + startOffset, -rightWidth.value, leftWidth.value);
  13290. }
  13291. };
  13292. const onTouchEnd = () => {
  13293. if (state.dragging) {
  13294. state.dragging = false;
  13295. toggle(state.offset > 0 ? "left" : "right");
  13296. setTimeout(() => {
  13297. lockClick2 = false;
  13298. }, 0);
  13299. }
  13300. };
  13301. const onClick = (position = "outside") => {
  13302. emit("click", position);
  13303. if (opened && !lockClick2) {
  13304. callInterceptor(props.beforeClose, {
  13305. args: [{
  13306. name: props.name,
  13307. position
  13308. }],
  13309. done: () => close(position)
  13310. });
  13311. }
  13312. };
  13313. const getClickHandler = (position, stop) => (event) => {
  13314. if (stop) {
  13315. event.stopPropagation();
  13316. }
  13317. onClick(position);
  13318. };
  13319. const renderSideContent = (side, ref2) => {
  13320. const contentSlot = slots[side];
  13321. if (contentSlot) {
  13322. return vue.createVNode("div", {
  13323. "ref": ref2,
  13324. "class": bem$4(side),
  13325. "onClick": getClickHandler(side, true)
  13326. }, [contentSlot()]);
  13327. }
  13328. };
  13329. useExpose({
  13330. open,
  13331. close
  13332. });
  13333. use.useClickAway(root, () => onClick("outside"), {
  13334. eventName: "touchstart"
  13335. });
  13336. use.useEventListener("touchmove", onTouchMove, {
  13337. target: root
  13338. });
  13339. return () => {
  13340. var _a;
  13341. const wrapperStyle = {
  13342. transform: `translate3d(${state.offset}px, 0, 0)`,
  13343. transitionDuration: state.dragging ? "0s" : ".6s"
  13344. };
  13345. return vue.createVNode("div", {
  13346. "ref": root,
  13347. "class": bem$4(),
  13348. "onClick": getClickHandler("cell", lockClick2),
  13349. "onTouchstartPassive": onTouchStart,
  13350. "onTouchend": onTouchEnd,
  13351. "onTouchcancel": onTouchEnd
  13352. }, [vue.createVNode("div", {
  13353. "class": bem$4("wrapper"),
  13354. "style": wrapperStyle
  13355. }, [renderSideContent("left", leftRef), (_a = slots.default) == null ? void 0 : _a.call(slots), renderSideContent("right", rightRef)])]);
  13356. };
  13357. }
  13358. });
  13359. const SwipeCell = withInstall(stdin_default$9);
  13360. const [name$3, bem$3] = createNamespace("tabbar");
  13361. const tabbarProps = {
  13362. route: Boolean,
  13363. fixed: truthProp,
  13364. border: truthProp,
  13365. zIndex: numericProp,
  13366. placeholder: Boolean,
  13367. activeColor: String,
  13368. beforeChange: Function,
  13369. inactiveColor: String,
  13370. modelValue: makeNumericProp(0),
  13371. safeAreaInsetBottom: {
  13372. type: Boolean,
  13373. default: null
  13374. }
  13375. };
  13376. const TABBAR_KEY = Symbol(name$3);
  13377. var stdin_default$8 = vue.defineComponent({
  13378. name: name$3,
  13379. props: tabbarProps,
  13380. emits: ["change", "update:modelValue"],
  13381. setup(props, {
  13382. emit,
  13383. slots
  13384. }) {
  13385. const root = vue.ref();
  13386. const {
  13387. linkChildren
  13388. } = use.useChildren(TABBAR_KEY);
  13389. const renderPlaceholder = usePlaceholder(root, bem$3);
  13390. const enableSafeArea = () => {
  13391. var _a;
  13392. return (_a = props.safeAreaInsetBottom) != null ? _a : props.fixed;
  13393. };
  13394. const renderTabbar = () => {
  13395. var _a;
  13396. const {
  13397. fixed,
  13398. zIndex,
  13399. border
  13400. } = props;
  13401. return vue.createVNode("div", {
  13402. "ref": root,
  13403. "role": "tablist",
  13404. "style": getZIndexStyle(zIndex),
  13405. "class": [bem$3({
  13406. fixed
  13407. }), {
  13408. [BORDER_TOP_BOTTOM]: border,
  13409. "van-safe-area-bottom": enableSafeArea()
  13410. }]
  13411. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
  13412. };
  13413. const setActive = (active, afterChange) => {
  13414. callInterceptor(props.beforeChange, {
  13415. args: [active],
  13416. done() {
  13417. emit("update:modelValue", active);
  13418. emit("change", active);
  13419. afterChange();
  13420. }
  13421. });
  13422. };
  13423. linkChildren({
  13424. props,
  13425. setActive
  13426. });
  13427. return () => {
  13428. if (props.fixed && props.placeholder) {
  13429. return renderPlaceholder(renderTabbar);
  13430. }
  13431. return renderTabbar();
  13432. };
  13433. }
  13434. });
  13435. const Tabbar = withInstall(stdin_default$8);
  13436. const [name$2, bem$2] = createNamespace("tabbar-item");
  13437. const tabbarItemProps = extend({}, routeProps, {
  13438. dot: Boolean,
  13439. icon: String,
  13440. name: numericProp,
  13441. badge: numericProp,
  13442. badgeProps: Object,
  13443. iconPrefix: String
  13444. });
  13445. var stdin_default$7 = vue.defineComponent({
  13446. name: name$2,
  13447. props: tabbarItemProps,
  13448. emits: ["click"],
  13449. setup(props, {
  13450. emit,
  13451. slots
  13452. }) {
  13453. const route2 = useRoute();
  13454. const vm = vue.getCurrentInstance().proxy;
  13455. const {
  13456. parent,
  13457. index
  13458. } = use.useParent(TABBAR_KEY);
  13459. if (!parent) {
  13460. if (process.env.NODE_ENV !== "production") {
  13461. console.error("[Vant] <TabbarItem> must be a child component of <Tabbar>.");
  13462. }
  13463. return;
  13464. }
  13465. const active = vue.computed(() => {
  13466. var _a;
  13467. const {
  13468. route: route22,
  13469. modelValue
  13470. } = parent.props;
  13471. if (route22 && "$route" in vm) {
  13472. const {
  13473. $route
  13474. } = vm;
  13475. const {
  13476. to
  13477. } = props;
  13478. const config = isObject(to) ? to : {
  13479. path: to
  13480. };
  13481. return !!$route.matched.find((val) => {
  13482. const pathMatched = "path" in config && config.path === val.path;
  13483. const nameMatched = "name" in config && config.name === val.name;
  13484. return pathMatched || nameMatched;
  13485. });
  13486. }
  13487. return ((_a = props.name) != null ? _a : index.value) === modelValue;
  13488. });
  13489. const onClick = (event) => {
  13490. var _a;
  13491. if (!active.value) {
  13492. parent.setActive((_a = props.name) != null ? _a : index.value, route2);
  13493. }
  13494. emit("click", event);
  13495. };
  13496. const renderIcon = () => {
  13497. if (slots.icon) {
  13498. return slots.icon({
  13499. active: active.value
  13500. });
  13501. }
  13502. if (props.icon) {
  13503. return vue.createVNode(Icon, {
  13504. "name": props.icon,
  13505. "classPrefix": props.iconPrefix
  13506. }, null);
  13507. }
  13508. };
  13509. return () => {
  13510. var _a;
  13511. const {
  13512. dot,
  13513. badge
  13514. } = props;
  13515. const {
  13516. activeColor,
  13517. inactiveColor
  13518. } = parent.props;
  13519. const color = active.value ? activeColor : inactiveColor;
  13520. return vue.createVNode("div", {
  13521. "role": "tab",
  13522. "class": bem$2({
  13523. active: active.value
  13524. }),
  13525. "style": {
  13526. color
  13527. },
  13528. "tabindex": 0,
  13529. "aria-selected": active.value,
  13530. "onClick": onClick
  13531. }, [vue.createVNode(Badge, vue.mergeProps({
  13532. "dot": dot,
  13533. "class": bem$2("icon"),
  13534. "content": badge
  13535. }, props.badgeProps), {
  13536. default: renderIcon
  13537. }), vue.createVNode("div", {
  13538. "class": bem$2("text")
  13539. }, [(_a = slots.default) == null ? void 0 : _a.call(slots, {
  13540. active: active.value
  13541. })])]);
  13542. };
  13543. }
  13544. });
  13545. const TabbarItem = withInstall(stdin_default$7);
  13546. const [name$1, bem$1] = createNamespace("tree-select");
  13547. const treeSelectProps = {
  13548. max: makeNumericProp(Infinity),
  13549. items: makeArrayProp(),
  13550. height: makeNumericProp(300),
  13551. selectedIcon: makeStringProp("success"),
  13552. mainActiveIndex: makeNumericProp(0),
  13553. activeId: {
  13554. type: [Number, String, Array],
  13555. default: 0
  13556. }
  13557. };
  13558. var stdin_default$6 = vue.defineComponent({
  13559. name: name$1,
  13560. props: treeSelectProps,
  13561. emits: ["click-nav", "click-item", "update:activeId", "update:mainActiveIndex"],
  13562. setup(props, {
  13563. emit,
  13564. slots
  13565. }) {
  13566. const isActiveItem = (id) => Array.isArray(props.activeId) ? props.activeId.includes(id) : props.activeId === id;
  13567. const renderSubItem = (item) => {
  13568. const onClick = () => {
  13569. if (item.disabled) {
  13570. return;
  13571. }
  13572. let activeId;
  13573. if (Array.isArray(props.activeId)) {
  13574. activeId = props.activeId.slice();
  13575. const index = activeId.indexOf(item.id);
  13576. if (index !== -1) {
  13577. activeId.splice(index, 1);
  13578. } else if (activeId.length < props.max) {
  13579. activeId.push(item.id);
  13580. }
  13581. } else {
  13582. activeId = item.id;
  13583. }
  13584. emit("update:activeId", activeId);
  13585. emit("click-item", item);
  13586. };
  13587. return vue.createVNode("div", {
  13588. "key": item.id,
  13589. "class": ["van-ellipsis", bem$1("item", {
  13590. active: isActiveItem(item.id),
  13591. disabled: item.disabled
  13592. })],
  13593. "onClick": onClick
  13594. }, [item.text, isActiveItem(item.id) && vue.createVNode(Icon, {
  13595. "name": props.selectedIcon,
  13596. "class": bem$1("selected")
  13597. }, null)]);
  13598. };
  13599. const onSidebarChange = (index) => {
  13600. emit("update:mainActiveIndex", index);
  13601. };
  13602. const onClickSidebarItem = (index) => emit("click-nav", index);
  13603. const renderSidebar = () => {
  13604. const Items = props.items.map((item) => vue.createVNode(SidebarItem, {
  13605. "dot": item.dot,
  13606. "title": item.text,
  13607. "badge": item.badge,
  13608. "class": [bem$1("nav-item"), item.className],
  13609. "disabled": item.disabled,
  13610. "onClick": onClickSidebarItem
  13611. }, null));
  13612. return vue.createVNode(Sidebar, {
  13613. "class": bem$1("nav"),
  13614. "modelValue": props.mainActiveIndex,
  13615. "onChange": onSidebarChange
  13616. }, {
  13617. default: () => [Items]
  13618. });
  13619. };
  13620. const renderContent = () => {
  13621. if (slots.content) {
  13622. return slots.content();
  13623. }
  13624. const selected = props.items[+props.mainActiveIndex] || {};
  13625. if (selected.children) {
  13626. return selected.children.map(renderSubItem);
  13627. }
  13628. };
  13629. return () => vue.createVNode("div", {
  13630. "class": bem$1(),
  13631. "style": {
  13632. height: addUnit(props.height)
  13633. }
  13634. }, [renderSidebar(), vue.createVNode("div", {
  13635. "class": bem$1("content")
  13636. }, [renderContent()])]);
  13637. }
  13638. });
  13639. const TreeSelect = withInstall(stdin_default$6);
  13640. const [name, bem, t] = createNamespace("uploader");
  13641. function readFileContent(file, resultType) {
  13642. return new Promise((resolve) => {
  13643. if (resultType === "file") {
  13644. resolve();
  13645. return;
  13646. }
  13647. const reader = new FileReader();
  13648. reader.onload = (event) => {
  13649. resolve(event.target.result);
  13650. };
  13651. if (resultType === "dataUrl") {
  13652. reader.readAsDataURL(file);
  13653. } else if (resultType === "text") {
  13654. reader.readAsText(file);
  13655. }
  13656. });
  13657. }
  13658. function isOversize(items, maxSize) {
  13659. return toArray(items).some((item) => {
  13660. if (item.file) {
  13661. if (isFunction(maxSize)) {
  13662. return maxSize(item.file);
  13663. }
  13664. return item.file.size > maxSize;
  13665. }
  13666. return false;
  13667. });
  13668. }
  13669. function filterFiles(items, maxSize) {
  13670. const valid = [];
  13671. const invalid = [];
  13672. items.forEach((item) => {
  13673. if (isOversize(item, maxSize)) {
  13674. invalid.push(item);
  13675. } else {
  13676. valid.push(item);
  13677. }
  13678. });
  13679. return { valid, invalid };
  13680. }
  13681. const IMAGE_REGEXP = /\.(jpeg|jpg|gif|png|svg|webp|jfif|bmp|dpg)/i;
  13682. const isImageUrl = (url) => IMAGE_REGEXP.test(url);
  13683. function isImageFile(item) {
  13684. if (item.isImage) {
  13685. return true;
  13686. }
  13687. if (item.file && item.file.type) {
  13688. return item.file.type.indexOf("image") === 0;
  13689. }
  13690. if (item.url) {
  13691. return isImageUrl(item.url);
  13692. }
  13693. if (typeof item.content === "string") {
  13694. return item.content.indexOf("data:image") === 0;
  13695. }
  13696. return false;
  13697. }
  13698. var stdin_default$5 = vue.defineComponent({
  13699. props: {
  13700. name: numericProp,
  13701. item: makeRequiredProp(Object),
  13702. index: Number,
  13703. imageFit: String,
  13704. lazyLoad: Boolean,
  13705. deletable: Boolean,
  13706. previewSize: [Number, String, Array],
  13707. beforeDelete: Function
  13708. },
  13709. emits: ["delete", "preview"],
  13710. setup(props, {
  13711. emit,
  13712. slots
  13713. }) {
  13714. const renderMask = () => {
  13715. const {
  13716. status,
  13717. message
  13718. } = props.item;
  13719. if (status === "uploading" || status === "failed") {
  13720. const MaskIcon = status === "failed" ? vue.createVNode(Icon, {
  13721. "name": "close",
  13722. "class": bem("mask-icon")
  13723. }, null) : vue.createVNode(Loading, {
  13724. "class": bem("loading")
  13725. }, null);
  13726. const showMessage = isDef(message) && message !== "";
  13727. return vue.createVNode("div", {
  13728. "class": bem("mask")
  13729. }, [MaskIcon, showMessage && vue.createVNode("div", {
  13730. "class": bem("mask-message")
  13731. }, [message])]);
  13732. }
  13733. };
  13734. const onDelete = (event) => {
  13735. const {
  13736. name: name2,
  13737. item,
  13738. index,
  13739. beforeDelete
  13740. } = props;
  13741. event.stopPropagation();
  13742. callInterceptor(beforeDelete, {
  13743. args: [item, {
  13744. name: name2,
  13745. index
  13746. }],
  13747. done: () => emit("delete")
  13748. });
  13749. };
  13750. const onPreview = () => emit("preview");
  13751. const renderDeleteIcon = () => {
  13752. if (props.deletable && props.item.status !== "uploading") {
  13753. const slot = slots["preview-delete"];
  13754. return vue.createVNode("div", {
  13755. "role": "button",
  13756. "class": bem("preview-delete", {
  13757. shadow: !slot
  13758. }),
  13759. "tabindex": 0,
  13760. "aria-label": t("delete"),
  13761. "onClick": onDelete
  13762. }, [slot ? slot() : vue.createVNode(Icon, {
  13763. "name": "cross",
  13764. "class": bem("preview-delete-icon")
  13765. }, null)]);
  13766. }
  13767. };
  13768. const renderCover = () => {
  13769. if (slots["preview-cover"]) {
  13770. const {
  13771. index,
  13772. item
  13773. } = props;
  13774. return vue.createVNode("div", {
  13775. "class": bem("preview-cover")
  13776. }, [slots["preview-cover"](extend({
  13777. index
  13778. }, item))]);
  13779. }
  13780. };
  13781. const renderPreview = () => {
  13782. const {
  13783. item,
  13784. lazyLoad,
  13785. imageFit,
  13786. previewSize
  13787. } = props;
  13788. if (isImageFile(item)) {
  13789. return vue.createVNode(Image$1, {
  13790. "fit": imageFit,
  13791. "src": item.content || item.url,
  13792. "class": bem("preview-image"),
  13793. "width": Array.isArray(previewSize) ? previewSize[0] : previewSize,
  13794. "height": Array.isArray(previewSize) ? previewSize[1] : previewSize,
  13795. "lazyLoad": lazyLoad,
  13796. "onClick": onPreview
  13797. }, {
  13798. default: renderCover
  13799. });
  13800. }
  13801. return vue.createVNode("div", {
  13802. "class": bem("file"),
  13803. "style": getSizeStyle(props.previewSize)
  13804. }, [vue.createVNode(Icon, {
  13805. "class": bem("file-icon"),
  13806. "name": "description"
  13807. }, null), vue.createVNode("div", {
  13808. "class": [bem("file-name"), "van-ellipsis"]
  13809. }, [item.file ? item.file.name : item.url]), renderCover()]);
  13810. };
  13811. return () => vue.createVNode("div", {
  13812. "class": bem("preview")
  13813. }, [renderPreview(), renderMask(), renderDeleteIcon()]);
  13814. }
  13815. });
  13816. const uploaderProps = {
  13817. name: makeNumericProp(""),
  13818. accept: makeStringProp("image/*"),
  13819. capture: String,
  13820. multiple: Boolean,
  13821. disabled: Boolean,
  13822. readonly: Boolean,
  13823. lazyLoad: Boolean,
  13824. maxCount: makeNumericProp(Infinity),
  13825. imageFit: makeStringProp("cover"),
  13826. resultType: makeStringProp("dataUrl"),
  13827. uploadIcon: makeStringProp("photograph"),
  13828. uploadText: String,
  13829. deletable: truthProp,
  13830. afterRead: Function,
  13831. showUpload: truthProp,
  13832. modelValue: makeArrayProp(),
  13833. beforeRead: Function,
  13834. beforeDelete: Function,
  13835. previewSize: [Number, String, Array],
  13836. previewImage: truthProp,
  13837. previewOptions: Object,
  13838. previewFullImage: truthProp,
  13839. maxSize: {
  13840. type: [Number, String, Function],
  13841. default: Infinity
  13842. }
  13843. };
  13844. var stdin_default$4 = vue.defineComponent({
  13845. name,
  13846. props: uploaderProps,
  13847. emits: ["delete", "oversize", "click-upload", "close-preview", "click-preview", "update:modelValue"],
  13848. setup(props, {
  13849. emit,
  13850. slots
  13851. }) {
  13852. const inputRef = vue.ref();
  13853. const urls = [];
  13854. const getDetail = (index = props.modelValue.length) => ({
  13855. name: props.name,
  13856. index
  13857. });
  13858. const resetInput = () => {
  13859. if (inputRef.value) {
  13860. inputRef.value.value = "";
  13861. }
  13862. };
  13863. const onAfterRead = (items) => {
  13864. resetInput();
  13865. if (isOversize(items, props.maxSize)) {
  13866. if (Array.isArray(items)) {
  13867. const result = filterFiles(items, props.maxSize);
  13868. items = result.valid;
  13869. emit("oversize", result.invalid, getDetail());
  13870. if (!items.length) {
  13871. return;
  13872. }
  13873. } else {
  13874. emit("oversize", items, getDetail());
  13875. return;
  13876. }
  13877. }
  13878. items = vue.reactive(items);
  13879. emit("update:modelValue", [...props.modelValue, ...toArray(items)]);
  13880. if (props.afterRead) {
  13881. props.afterRead(items, getDetail());
  13882. }
  13883. };
  13884. const readFile = (files) => {
  13885. const {
  13886. maxCount,
  13887. modelValue,
  13888. resultType
  13889. } = props;
  13890. if (Array.isArray(files)) {
  13891. const remainCount = +maxCount - modelValue.length;
  13892. if (files.length > remainCount) {
  13893. files = files.slice(0, remainCount);
  13894. }
  13895. Promise.all(files.map((file) => readFileContent(file, resultType))).then((contents) => {
  13896. const fileList = files.map((file, index) => {
  13897. const result = {
  13898. file,
  13899. status: "",
  13900. message: ""
  13901. };
  13902. if (contents[index]) {
  13903. result.content = contents[index];
  13904. }
  13905. return result;
  13906. });
  13907. onAfterRead(fileList);
  13908. });
  13909. } else {
  13910. readFileContent(files, resultType).then((content) => {
  13911. const result = {
  13912. file: files,
  13913. status: "",
  13914. message: ""
  13915. };
  13916. if (content) {
  13917. result.content = content;
  13918. }
  13919. onAfterRead(result);
  13920. });
  13921. }
  13922. };
  13923. const onChange = (event) => {
  13924. const {
  13925. files
  13926. } = event.target;
  13927. if (props.disabled || !files || !files.length) {
  13928. return;
  13929. }
  13930. const file = files.length === 1 ? files[0] : [].slice.call(files);
  13931. if (props.beforeRead) {
  13932. const response = props.beforeRead(file, getDetail());
  13933. if (!response) {
  13934. resetInput();
  13935. return;
  13936. }
  13937. if (isPromise(response)) {
  13938. response.then((data) => {
  13939. if (data) {
  13940. readFile(data);
  13941. } else {
  13942. readFile(file);
  13943. }
  13944. }).catch(resetInput);
  13945. return;
  13946. }
  13947. }
  13948. readFile(file);
  13949. };
  13950. let imagePreview;
  13951. const onClosePreview = () => emit("close-preview");
  13952. const previewImage = (item) => {
  13953. if (props.previewFullImage) {
  13954. const imageFiles = props.modelValue.filter(isImageFile);
  13955. const images = imageFiles.map((item2) => {
  13956. if (item2.file && !item2.url && item2.status !== "failed") {
  13957. item2.url = URL.createObjectURL(item2.file);
  13958. urls.push(item2.url);
  13959. }
  13960. return item2.url;
  13961. }).filter(Boolean);
  13962. imagePreview = ImagePreview(extend({
  13963. images,
  13964. startPosition: imageFiles.indexOf(item),
  13965. onClose: onClosePreview
  13966. }, props.previewOptions));
  13967. }
  13968. };
  13969. const closeImagePreview = () => {
  13970. if (imagePreview) {
  13971. imagePreview.close();
  13972. }
  13973. };
  13974. const deleteFile = (item, index) => {
  13975. const fileList = props.modelValue.slice(0);
  13976. fileList.splice(index, 1);
  13977. emit("update:modelValue", fileList);
  13978. emit("delete", item, getDetail(index));
  13979. };
  13980. const renderPreviewItem = (item, index) => {
  13981. const needPickData = ["imageFit", "deletable", "previewSize", "beforeDelete"];
  13982. const previewData = extend(pick(props, needPickData), pick(item, needPickData, true));
  13983. return vue.createVNode(stdin_default$5, vue.mergeProps({
  13984. "item": item,
  13985. "index": index,
  13986. "onClick": () => emit("click-preview", item, getDetail(index)),
  13987. "onDelete": () => deleteFile(item, index),
  13988. "onPreview": () => previewImage(item)
  13989. }, pick(props, ["name", "lazyLoad"]), previewData), pick(slots, ["preview-cover", "preview-delete"]));
  13990. };
  13991. const renderPreviewList = () => {
  13992. if (props.previewImage) {
  13993. return props.modelValue.map(renderPreviewItem);
  13994. }
  13995. };
  13996. const onClickUpload = (event) => emit("click-upload", event);
  13997. const renderUpload = () => {
  13998. if (props.modelValue.length >= props.maxCount || !props.showUpload) {
  13999. return;
  14000. }
  14001. const Input = props.readonly ? null : vue.createVNode("input", {
  14002. "ref": inputRef,
  14003. "type": "file",
  14004. "class": bem("input"),
  14005. "accept": props.accept,
  14006. "capture": props.capture,
  14007. "multiple": props.multiple,
  14008. "disabled": props.disabled,
  14009. "onChange": onChange
  14010. }, null);
  14011. if (slots.default) {
  14012. return vue.createVNode("div", {
  14013. "class": bem("input-wrapper"),
  14014. "onClick": onClickUpload
  14015. }, [slots.default(), Input]);
  14016. }
  14017. return vue.createVNode("div", {
  14018. "class": bem("upload", {
  14019. readonly: props.readonly
  14020. }),
  14021. "style": getSizeStyle(props.previewSize),
  14022. "onClick": onClickUpload
  14023. }, [vue.createVNode(Icon, {
  14024. "name": props.uploadIcon,
  14025. "class": bem("upload-icon")
  14026. }, null), props.uploadText && vue.createVNode("span", {
  14027. "class": bem("upload-text")
  14028. }, [props.uploadText]), Input]);
  14029. };
  14030. const chooseFile = () => {
  14031. if (inputRef.value && !props.disabled) {
  14032. inputRef.value.click();
  14033. }
  14034. };
  14035. vue.onBeforeUnmount(() => {
  14036. urls.forEach((url) => URL.revokeObjectURL(url));
  14037. });
  14038. useExpose({
  14039. chooseFile,
  14040. closeImagePreview
  14041. });
  14042. use.useCustomFieldValue(() => props.modelValue);
  14043. return () => vue.createVNode("div", {
  14044. "class": bem()
  14045. }, [vue.createVNode("div", {
  14046. "class": bem("wrapper", {
  14047. disabled: props.disabled
  14048. })
  14049. }, [renderPreviewList(), renderUpload()])]);
  14050. }
  14051. });
  14052. const Uploader = withInstall(stdin_default$4);
  14053. const hasIntersectionObserver = use.inBrowser && "IntersectionObserver" in window && "IntersectionObserverEntry" in window && "intersectionRatio" in window.IntersectionObserverEntry.prototype;
  14054. const modeType = {
  14055. event: "event",
  14056. observer: "observer"
  14057. };
  14058. function remove(arr, item) {
  14059. if (!arr.length)
  14060. return;
  14061. const index = arr.indexOf(item);
  14062. if (index > -1)
  14063. return arr.splice(index, 1);
  14064. }
  14065. function getBestSelectionFromSrcset(el, scale) {
  14066. if (el.tagName !== "IMG" || !el.getAttribute("data-srcset"))
  14067. return;
  14068. let options = el.getAttribute("data-srcset");
  14069. const container = el.parentNode;
  14070. const containerWidth = container.offsetWidth * scale;
  14071. let spaceIndex;
  14072. let tmpSrc;
  14073. let tmpWidth;
  14074. options = options.trim().split(",");
  14075. const result = options.map((item) => {
  14076. item = item.trim();
  14077. spaceIndex = item.lastIndexOf(" ");
  14078. if (spaceIndex === -1) {
  14079. tmpSrc = item;
  14080. tmpWidth = 999998;
  14081. } else {
  14082. tmpSrc = item.substr(0, spaceIndex);
  14083. tmpWidth = parseInt(
  14084. item.substr(spaceIndex + 1, item.length - spaceIndex - 2),
  14085. 10
  14086. );
  14087. }
  14088. return [tmpWidth, tmpSrc];
  14089. });
  14090. result.sort((a, b) => {
  14091. if (a[0] < b[0]) {
  14092. return 1;
  14093. }
  14094. if (a[0] > b[0]) {
  14095. return -1;
  14096. }
  14097. if (a[0] === b[0]) {
  14098. if (b[1].indexOf(".webp", b[1].length - 5) !== -1) {
  14099. return 1;
  14100. }
  14101. if (a[1].indexOf(".webp", a[1].length - 5) !== -1) {
  14102. return -1;
  14103. }
  14104. }
  14105. return 0;
  14106. });
  14107. let bestSelectedSrc = "";
  14108. let tmpOption;
  14109. for (let i = 0; i < result.length; i++) {
  14110. tmpOption = result[i];
  14111. bestSelectedSrc = tmpOption[1];
  14112. const next = result[i + 1];
  14113. if (next && next[0] < containerWidth) {
  14114. bestSelectedSrc = tmpOption[1];
  14115. break;
  14116. } else if (!next) {
  14117. bestSelectedSrc = tmpOption[1];
  14118. break;
  14119. }
  14120. }
  14121. return bestSelectedSrc;
  14122. }
  14123. const getDPR = (scale = 1) => use.inBrowser ? window.devicePixelRatio || scale : scale;
  14124. function supportWebp() {
  14125. if (!use.inBrowser)
  14126. return false;
  14127. let support = true;
  14128. try {
  14129. const elem = document.createElement("canvas");
  14130. if (elem.getContext && elem.getContext("2d")) {
  14131. support = elem.toDataURL("image/webp").indexOf("data:image/webp") === 0;
  14132. }
  14133. } catch (err) {
  14134. support = false;
  14135. }
  14136. return support;
  14137. }
  14138. function throttle(action, delay) {
  14139. let timeout = null;
  14140. let lastRun = 0;
  14141. return function(...args) {
  14142. if (timeout) {
  14143. return;
  14144. }
  14145. const elapsed = Date.now() - lastRun;
  14146. const runCallback = () => {
  14147. lastRun = Date.now();
  14148. timeout = false;
  14149. action.apply(this, args);
  14150. };
  14151. if (elapsed >= delay) {
  14152. runCallback();
  14153. } else {
  14154. timeout = setTimeout(runCallback, delay);
  14155. }
  14156. };
  14157. }
  14158. function on(el, type, func) {
  14159. el.addEventListener(type, func, {
  14160. capture: false,
  14161. passive: true
  14162. });
  14163. }
  14164. function off(el, type, func) {
  14165. el.removeEventListener(type, func, false);
  14166. }
  14167. const loadImageAsync = (item, resolve, reject) => {
  14168. const image = new Image();
  14169. if (!item || !item.src) {
  14170. return reject(new Error("image src is required"));
  14171. }
  14172. image.src = item.src;
  14173. if (item.cors) {
  14174. image.crossOrigin = item.cors;
  14175. }
  14176. image.onload = () => resolve({
  14177. naturalHeight: image.naturalHeight,
  14178. naturalWidth: image.naturalWidth,
  14179. src: image.src
  14180. });
  14181. image.onerror = (e) => reject(e);
  14182. };
  14183. class ImageCache {
  14184. constructor({ max }) {
  14185. this.options = {
  14186. max: max || 100
  14187. };
  14188. this.caches = [];
  14189. }
  14190. has(key) {
  14191. return this.caches.indexOf(key) > -1;
  14192. }
  14193. add(key) {
  14194. if (this.has(key))
  14195. return;
  14196. this.caches.push(key);
  14197. if (this.caches.length > this.options.max) {
  14198. this.free();
  14199. }
  14200. }
  14201. free() {
  14202. this.caches.shift();
  14203. }
  14204. }
  14205. class ReactiveListener {
  14206. constructor({
  14207. el,
  14208. src,
  14209. error,
  14210. loading,
  14211. bindType,
  14212. $parent,
  14213. options,
  14214. cors,
  14215. elRenderer,
  14216. imageCache
  14217. }) {
  14218. this.el = el;
  14219. this.src = src;
  14220. this.error = error;
  14221. this.loading = loading;
  14222. this.bindType = bindType;
  14223. this.attempt = 0;
  14224. this.cors = cors;
  14225. this.naturalHeight = 0;
  14226. this.naturalWidth = 0;
  14227. this.options = options;
  14228. this.$parent = $parent;
  14229. this.elRenderer = elRenderer;
  14230. this.imageCache = imageCache;
  14231. this.performanceData = {
  14232. loadStart: 0,
  14233. loadEnd: 0
  14234. };
  14235. this.filter();
  14236. this.initState();
  14237. this.render("loading", false);
  14238. }
  14239. initState() {
  14240. if ("dataset" in this.el) {
  14241. this.el.dataset.src = this.src;
  14242. } else {
  14243. this.el.setAttribute("data-src", this.src);
  14244. }
  14245. this.state = {
  14246. loading: false,
  14247. error: false,
  14248. loaded: false,
  14249. rendered: false
  14250. };
  14251. }
  14252. record(event) {
  14253. this.performanceData[event] = Date.now();
  14254. }
  14255. update({ src, loading, error }) {
  14256. const oldSrc = this.src;
  14257. this.src = src;
  14258. this.loading = loading;
  14259. this.error = error;
  14260. this.filter();
  14261. if (oldSrc !== this.src) {
  14262. this.attempt = 0;
  14263. this.initState();
  14264. }
  14265. }
  14266. checkInView() {
  14267. const rect = use.useRect(this.el);
  14268. return rect.top < window.innerHeight * this.options.preLoad && rect.bottom > this.options.preLoadTop && rect.left < window.innerWidth * this.options.preLoad && rect.right > 0;
  14269. }
  14270. filter() {
  14271. Object.keys(this.options.filter).forEach((key) => {
  14272. this.options.filter[key](this, this.options);
  14273. });
  14274. }
  14275. renderLoading(cb) {
  14276. this.state.loading = true;
  14277. loadImageAsync(
  14278. {
  14279. src: this.loading,
  14280. cors: this.cors
  14281. },
  14282. () => {
  14283. this.render("loading", false);
  14284. this.state.loading = false;
  14285. cb();
  14286. },
  14287. () => {
  14288. cb();
  14289. this.state.loading = false;
  14290. if (process.env.NODE_ENV !== "production" && !this.options.silent)
  14291. console.warn(
  14292. `[@vant/lazyload] load failed with loading image(${this.loading})`
  14293. );
  14294. }
  14295. );
  14296. }
  14297. load(onFinish = noop) {
  14298. if (this.attempt > this.options.attempt - 1 && this.state.error) {
  14299. if (process.env.NODE_ENV !== "production" && !this.options.silent) {
  14300. console.log(
  14301. `[@vant/lazyload] ${this.src} tried too more than ${this.options.attempt} times`
  14302. );
  14303. }
  14304. onFinish();
  14305. return;
  14306. }
  14307. if (this.state.rendered && this.state.loaded)
  14308. return;
  14309. if (this.imageCache.has(this.src)) {
  14310. this.state.loaded = true;
  14311. this.render("loaded", true);
  14312. this.state.rendered = true;
  14313. return onFinish();
  14314. }
  14315. this.renderLoading(() => {
  14316. var _a, _b;
  14317. this.attempt++;
  14318. (_b = (_a = this.options.adapter).beforeLoad) == null ? void 0 : _b.call(_a, this, this.options);
  14319. this.record("loadStart");
  14320. loadImageAsync(
  14321. {
  14322. src: this.src,
  14323. cors: this.cors
  14324. },
  14325. (data) => {
  14326. this.naturalHeight = data.naturalHeight;
  14327. this.naturalWidth = data.naturalWidth;
  14328. this.state.loaded = true;
  14329. this.state.error = false;
  14330. this.record("loadEnd");
  14331. this.render("loaded", false);
  14332. this.state.rendered = true;
  14333. this.imageCache.add(this.src);
  14334. onFinish();
  14335. },
  14336. (err) => {
  14337. !this.options.silent && console.error(err);
  14338. this.state.error = true;
  14339. this.state.loaded = false;
  14340. this.render("error", false);
  14341. }
  14342. );
  14343. });
  14344. }
  14345. render(state, cache) {
  14346. this.elRenderer(this, state, cache);
  14347. }
  14348. performance() {
  14349. let state = "loading";
  14350. let time = 0;
  14351. if (this.state.loaded) {
  14352. state = "loaded";
  14353. time = (this.performanceData.loadEnd - this.performanceData.loadStart) / 1e3;
  14354. }
  14355. if (this.state.error)
  14356. state = "error";
  14357. return {
  14358. src: this.src,
  14359. state,
  14360. time
  14361. };
  14362. }
  14363. $destroy() {
  14364. this.el = null;
  14365. this.src = null;
  14366. this.error = null;
  14367. this.loading = null;
  14368. this.bindType = null;
  14369. this.attempt = 0;
  14370. }
  14371. }
  14372. const DEFAULT_URL = "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7";
  14373. const DEFAULT_EVENTS = [
  14374. "scroll",
  14375. "wheel",
  14376. "mousewheel",
  14377. "resize",
  14378. "animationend",
  14379. "transitionend",
  14380. "touchmove"
  14381. ];
  14382. const DEFAULT_OBSERVER_OPTIONS = {
  14383. rootMargin: "0px",
  14384. threshold: 0
  14385. };
  14386. function stdin_default$3() {
  14387. return class Lazy {
  14388. constructor({
  14389. preLoad,
  14390. error,
  14391. throttleWait,
  14392. preLoadTop,
  14393. dispatchEvent,
  14394. loading,
  14395. attempt,
  14396. silent = true,
  14397. scale,
  14398. listenEvents,
  14399. filter,
  14400. adapter,
  14401. observer,
  14402. observerOptions
  14403. }) {
  14404. this.mode = modeType.event;
  14405. this.listeners = [];
  14406. this.targetIndex = 0;
  14407. this.targets = [];
  14408. this.options = {
  14409. silent,
  14410. dispatchEvent: !!dispatchEvent,
  14411. throttleWait: throttleWait || 200,
  14412. preLoad: preLoad || 1.3,
  14413. preLoadTop: preLoadTop || 0,
  14414. error: error || DEFAULT_URL,
  14415. loading: loading || DEFAULT_URL,
  14416. attempt: attempt || 3,
  14417. scale: scale || getDPR(scale),
  14418. ListenEvents: listenEvents || DEFAULT_EVENTS,
  14419. supportWebp: supportWebp(),
  14420. filter: filter || {},
  14421. adapter: adapter || {},
  14422. observer: !!observer,
  14423. observerOptions: observerOptions || DEFAULT_OBSERVER_OPTIONS
  14424. };
  14425. this.initEvent();
  14426. this.imageCache = new ImageCache({ max: 200 });
  14427. this.lazyLoadHandler = throttle(
  14428. this.lazyLoadHandler.bind(this),
  14429. this.options.throttleWait
  14430. );
  14431. this.setMode(this.options.observer ? modeType.observer : modeType.event);
  14432. }
  14433. config(options = {}) {
  14434. Object.assign(this.options, options);
  14435. }
  14436. performance() {
  14437. return this.listeners.map((item) => item.performance());
  14438. }
  14439. addLazyBox(vm) {
  14440. this.listeners.push(vm);
  14441. if (use.inBrowser) {
  14442. this.addListenerTarget(window);
  14443. this.observer && this.observer.observe(vm.el);
  14444. if (vm.$el && vm.$el.parentNode) {
  14445. this.addListenerTarget(vm.$el.parentNode);
  14446. }
  14447. }
  14448. }
  14449. add(el, binding, vnode) {
  14450. if (this.listeners.some((item) => item.el === el)) {
  14451. this.update(el, binding);
  14452. return vue.nextTick(this.lazyLoadHandler);
  14453. }
  14454. const value = this.valueFormatter(binding.value);
  14455. let { src } = value;
  14456. vue.nextTick(() => {
  14457. src = getBestSelectionFromSrcset(el, this.options.scale) || src;
  14458. this.observer && this.observer.observe(el);
  14459. const container = Object.keys(binding.modifiers)[0];
  14460. let $parent;
  14461. if (container) {
  14462. $parent = vnode.context.$refs[container];
  14463. $parent = $parent ? $parent.$el || $parent : document.getElementById(container);
  14464. }
  14465. if (!$parent) {
  14466. $parent = use.getScrollParent(el);
  14467. }
  14468. const newListener = new ReactiveListener({
  14469. bindType: binding.arg,
  14470. $parent,
  14471. el,
  14472. src,
  14473. loading: value.loading,
  14474. error: value.error,
  14475. cors: value.cors,
  14476. elRenderer: this.elRenderer.bind(this),
  14477. options: this.options,
  14478. imageCache: this.imageCache
  14479. });
  14480. this.listeners.push(newListener);
  14481. if (use.inBrowser) {
  14482. this.addListenerTarget(window);
  14483. this.addListenerTarget($parent);
  14484. }
  14485. this.lazyLoadHandler();
  14486. vue.nextTick(() => this.lazyLoadHandler());
  14487. });
  14488. }
  14489. update(el, binding, vnode) {
  14490. const value = this.valueFormatter(binding.value);
  14491. let { src } = value;
  14492. src = getBestSelectionFromSrcset(el, this.options.scale) || src;
  14493. const exist = this.listeners.find((item) => item.el === el);
  14494. if (!exist) {
  14495. this.add(el, binding, vnode);
  14496. } else {
  14497. exist.update({
  14498. src,
  14499. error: value.error,
  14500. loading: value.loading
  14501. });
  14502. }
  14503. if (this.observer) {
  14504. this.observer.unobserve(el);
  14505. this.observer.observe(el);
  14506. }
  14507. this.lazyLoadHandler();
  14508. vue.nextTick(() => this.lazyLoadHandler());
  14509. }
  14510. remove(el) {
  14511. if (!el)
  14512. return;
  14513. this.observer && this.observer.unobserve(el);
  14514. const existItem = this.listeners.find((item) => item.el === el);
  14515. if (existItem) {
  14516. this.removeListenerTarget(existItem.$parent);
  14517. this.removeListenerTarget(window);
  14518. remove(this.listeners, existItem);
  14519. existItem.$destroy();
  14520. }
  14521. }
  14522. removeComponent(vm) {
  14523. if (!vm)
  14524. return;
  14525. remove(this.listeners, vm);
  14526. this.observer && this.observer.unobserve(vm.el);
  14527. if (vm.$parent && vm.$el.parentNode) {
  14528. this.removeListenerTarget(vm.$el.parentNode);
  14529. }
  14530. this.removeListenerTarget(window);
  14531. }
  14532. setMode(mode) {
  14533. if (!hasIntersectionObserver && mode === modeType.observer) {
  14534. mode = modeType.event;
  14535. }
  14536. this.mode = mode;
  14537. if (mode === modeType.event) {
  14538. if (this.observer) {
  14539. this.listeners.forEach((listener) => {
  14540. this.observer.unobserve(listener.el);
  14541. });
  14542. this.observer = null;
  14543. }
  14544. this.targets.forEach((target) => {
  14545. this.initListen(target.el, true);
  14546. });
  14547. } else {
  14548. this.targets.forEach((target) => {
  14549. this.initListen(target.el, false);
  14550. });
  14551. this.initIntersectionObserver();
  14552. }
  14553. }
  14554. addListenerTarget(el) {
  14555. if (!el)
  14556. return;
  14557. let target = this.targets.find((target2) => target2.el === el);
  14558. if (!target) {
  14559. target = {
  14560. el,
  14561. id: ++this.targetIndex,
  14562. childrenCount: 1,
  14563. listened: true
  14564. };
  14565. this.mode === modeType.event && this.initListen(target.el, true);
  14566. this.targets.push(target);
  14567. } else {
  14568. target.childrenCount++;
  14569. }
  14570. return this.targetIndex;
  14571. }
  14572. removeListenerTarget(el) {
  14573. this.targets.forEach((target, index) => {
  14574. if (target.el === el) {
  14575. target.childrenCount--;
  14576. if (!target.childrenCount) {
  14577. this.initListen(target.el, false);
  14578. this.targets.splice(index, 1);
  14579. target = null;
  14580. }
  14581. }
  14582. });
  14583. }
  14584. initListen(el, start) {
  14585. this.options.ListenEvents.forEach(
  14586. (evt) => (start ? on : off)(el, evt, this.lazyLoadHandler)
  14587. );
  14588. }
  14589. initEvent() {
  14590. this.Event = {
  14591. listeners: {
  14592. loading: [],
  14593. loaded: [],
  14594. error: []
  14595. }
  14596. };
  14597. this.$on = (event, func) => {
  14598. if (!this.Event.listeners[event])
  14599. this.Event.listeners[event] = [];
  14600. this.Event.listeners[event].push(func);
  14601. };
  14602. this.$once = (event, func) => {
  14603. const on2 = (...args) => {
  14604. this.$off(event, on2);
  14605. func.apply(this, args);
  14606. };
  14607. this.$on(event, on2);
  14608. };
  14609. this.$off = (event, func) => {
  14610. if (!func) {
  14611. if (!this.Event.listeners[event])
  14612. return;
  14613. this.Event.listeners[event].length = 0;
  14614. return;
  14615. }
  14616. remove(this.Event.listeners[event], func);
  14617. };
  14618. this.$emit = (event, context, inCache) => {
  14619. if (!this.Event.listeners[event])
  14620. return;
  14621. this.Event.listeners[event].forEach((func) => func(context, inCache));
  14622. };
  14623. }
  14624. lazyLoadHandler() {
  14625. const freeList = [];
  14626. this.listeners.forEach((listener) => {
  14627. if (!listener.el || !listener.el.parentNode) {
  14628. freeList.push(listener);
  14629. }
  14630. const catIn = listener.checkInView();
  14631. if (!catIn)
  14632. return;
  14633. listener.load();
  14634. });
  14635. freeList.forEach((item) => {
  14636. remove(this.listeners, item);
  14637. item.$destroy();
  14638. });
  14639. }
  14640. initIntersectionObserver() {
  14641. if (!hasIntersectionObserver) {
  14642. return;
  14643. }
  14644. this.observer = new IntersectionObserver(
  14645. this.observerHandler.bind(this),
  14646. this.options.observerOptions
  14647. );
  14648. if (this.listeners.length) {
  14649. this.listeners.forEach((listener) => {
  14650. this.observer.observe(listener.el);
  14651. });
  14652. }
  14653. }
  14654. observerHandler(entries) {
  14655. entries.forEach((entry) => {
  14656. if (entry.isIntersecting) {
  14657. this.listeners.forEach((listener) => {
  14658. if (listener.el === entry.target) {
  14659. if (listener.state.loaded)
  14660. return this.observer.unobserve(listener.el);
  14661. listener.load();
  14662. }
  14663. });
  14664. }
  14665. });
  14666. }
  14667. elRenderer(listener, state, cache) {
  14668. if (!listener.el)
  14669. return;
  14670. const { el, bindType } = listener;
  14671. let src;
  14672. switch (state) {
  14673. case "loading":
  14674. src = listener.loading;
  14675. break;
  14676. case "error":
  14677. src = listener.error;
  14678. break;
  14679. default:
  14680. ({ src } = listener);
  14681. break;
  14682. }
  14683. if (bindType) {
  14684. el.style[bindType] = 'url("' + src + '")';
  14685. } else if (el.getAttribute("src") !== src) {
  14686. el.setAttribute("src", src);
  14687. }
  14688. el.setAttribute("lazy", state);
  14689. this.$emit(state, listener, cache);
  14690. this.options.adapter[state] && this.options.adapter[state](listener, this.options);
  14691. if (this.options.dispatchEvent) {
  14692. const event = new CustomEvent(state, {
  14693. detail: listener
  14694. });
  14695. el.dispatchEvent(event);
  14696. }
  14697. }
  14698. valueFormatter(value) {
  14699. let src = value;
  14700. let { loading, error } = this.options;
  14701. if (isObject(value)) {
  14702. if (process.env.NODE_ENV !== "production" && !value.src && !this.options.silent) {
  14703. console.error("[@vant/lazyload] miss src with " + value);
  14704. }
  14705. ({ src } = value);
  14706. loading = value.loading || this.options.loading;
  14707. error = value.error || this.options.error;
  14708. }
  14709. return {
  14710. src,
  14711. loading,
  14712. error
  14713. };
  14714. }
  14715. };
  14716. }
  14717. var stdin_default$2 = (lazy) => ({
  14718. props: {
  14719. tag: {
  14720. type: String,
  14721. default: "div"
  14722. }
  14723. },
  14724. emits: ["show"],
  14725. render() {
  14726. return vue.h(
  14727. this.tag,
  14728. this.show && this.$slots.default ? this.$slots.default() : null
  14729. );
  14730. },
  14731. data() {
  14732. return {
  14733. el: null,
  14734. state: {
  14735. loaded: false
  14736. },
  14737. show: false
  14738. };
  14739. },
  14740. mounted() {
  14741. this.el = this.$el;
  14742. lazy.addLazyBox(this);
  14743. lazy.lazyLoadHandler();
  14744. },
  14745. beforeUnmount() {
  14746. lazy.removeComponent(this);
  14747. },
  14748. methods: {
  14749. checkInView() {
  14750. const rect = use.useRect(this.$el);
  14751. return use.inBrowser && rect.top < window.innerHeight * lazy.options.preLoad && rect.bottom > 0 && rect.left < window.innerWidth * lazy.options.preLoad && rect.right > 0;
  14752. },
  14753. load() {
  14754. this.show = true;
  14755. this.state.loaded = true;
  14756. this.$emit("show", this);
  14757. },
  14758. destroy() {
  14759. return this.$destroy;
  14760. }
  14761. }
  14762. });
  14763. const defaultOptions = {
  14764. selector: "img"
  14765. };
  14766. class LazyContainer {
  14767. constructor({ el, binding, vnode, lazy }) {
  14768. this.el = null;
  14769. this.vnode = vnode;
  14770. this.binding = binding;
  14771. this.options = {};
  14772. this.lazy = lazy;
  14773. this.queue = [];
  14774. this.update({ el, binding });
  14775. }
  14776. update({ el, binding }) {
  14777. this.el = el;
  14778. this.options = Object.assign({}, defaultOptions, binding.value);
  14779. const imgs = this.getImgs();
  14780. imgs.forEach((el2) => {
  14781. this.lazy.add(
  14782. el2,
  14783. Object.assign({}, this.binding, {
  14784. value: {
  14785. src: "dataset" in el2 ? el2.dataset.src : el2.getAttribute("data-src"),
  14786. error: ("dataset" in el2 ? el2.dataset.error : el2.getAttribute("data-error")) || this.options.error,
  14787. loading: ("dataset" in el2 ? el2.dataset.loading : el2.getAttribute("data-loading")) || this.options.loading
  14788. }
  14789. }),
  14790. this.vnode
  14791. );
  14792. });
  14793. }
  14794. getImgs() {
  14795. return Array.from(this.el.querySelectorAll(this.options.selector));
  14796. }
  14797. clear() {
  14798. const imgs = this.getImgs();
  14799. imgs.forEach((el) => this.lazy.remove(el));
  14800. this.vnode = null;
  14801. this.binding = null;
  14802. this.lazy = null;
  14803. }
  14804. }
  14805. class LazyContainerManager {
  14806. constructor({ lazy }) {
  14807. this.lazy = lazy;
  14808. this.queue = [];
  14809. }
  14810. bind(el, binding, vnode) {
  14811. const container = new LazyContainer({
  14812. el,
  14813. binding,
  14814. vnode,
  14815. lazy: this.lazy
  14816. });
  14817. this.queue.push(container);
  14818. }
  14819. update(el, binding, vnode) {
  14820. const container = this.queue.find((item) => item.el === el);
  14821. if (!container)
  14822. return;
  14823. container.update({ el, binding, vnode });
  14824. }
  14825. unbind(el) {
  14826. const container = this.queue.find((item) => item.el === el);
  14827. if (!container)
  14828. return;
  14829. container.clear();
  14830. remove(this.queue, container);
  14831. }
  14832. }
  14833. var stdin_default$1 = (lazyManager) => ({
  14834. props: {
  14835. src: [String, Object],
  14836. tag: {
  14837. type: String,
  14838. default: "img"
  14839. }
  14840. },
  14841. render(h) {
  14842. return h(
  14843. this.tag,
  14844. {
  14845. attrs: {
  14846. src: this.renderSrc
  14847. }
  14848. },
  14849. this.$slots.default
  14850. );
  14851. },
  14852. data() {
  14853. return {
  14854. el: null,
  14855. options: {
  14856. src: "",
  14857. error: "",
  14858. loading: "",
  14859. attempt: lazyManager.options.attempt
  14860. },
  14861. state: {
  14862. loaded: false,
  14863. error: false,
  14864. attempt: 0
  14865. },
  14866. renderSrc: ""
  14867. };
  14868. },
  14869. watch: {
  14870. src() {
  14871. this.init();
  14872. lazyManager.addLazyBox(this);
  14873. lazyManager.lazyLoadHandler();
  14874. }
  14875. },
  14876. created() {
  14877. this.init();
  14878. this.renderSrc = this.options.loading;
  14879. },
  14880. mounted() {
  14881. this.el = this.$el;
  14882. lazyManager.addLazyBox(this);
  14883. lazyManager.lazyLoadHandler();
  14884. },
  14885. beforeUnmount() {
  14886. lazyManager.removeComponent(this);
  14887. },
  14888. methods: {
  14889. init() {
  14890. const { src, loading, error } = lazyManager.valueFormatter(this.src);
  14891. this.state.loaded = false;
  14892. this.options.src = src;
  14893. this.options.error = error;
  14894. this.options.loading = loading;
  14895. this.renderSrc = this.options.loading;
  14896. },
  14897. checkInView() {
  14898. const rect = use.useRect(this.$el);
  14899. return rect.top < window.innerHeight * lazyManager.options.preLoad && rect.bottom > 0 && rect.left < window.innerWidth * lazyManager.options.preLoad && rect.right > 0;
  14900. },
  14901. load(onFinish = noop) {
  14902. if (this.state.attempt > this.options.attempt - 1 && this.state.error) {
  14903. if (process.env.NODE_ENV !== "production" && !lazyManager.options.silent) {
  14904. console.log(
  14905. `[@vant/lazyload] ${this.options.src} tried too more than ${this.options.attempt} times`
  14906. );
  14907. }
  14908. onFinish();
  14909. return;
  14910. }
  14911. const { src } = this.options;
  14912. loadImageAsync(
  14913. { src },
  14914. ({ src: src2 }) => {
  14915. this.renderSrc = src2;
  14916. this.state.loaded = true;
  14917. },
  14918. () => {
  14919. this.state.attempt++;
  14920. this.renderSrc = this.options.error;
  14921. this.state.error = true;
  14922. }
  14923. );
  14924. }
  14925. }
  14926. });
  14927. const Lazyload = {
  14928. install(app, options = {}) {
  14929. const LazyClass = stdin_default$3();
  14930. const lazy = new LazyClass(options);
  14931. const lazyContainer = new LazyContainerManager({ lazy });
  14932. app.config.globalProperties.$Lazyload = lazy;
  14933. if (options.lazyComponent) {
  14934. app.component("LazyComponent", stdin_default$2(lazy));
  14935. }
  14936. if (options.lazyImage) {
  14937. app.component("LazyImage", stdin_default$1(lazy));
  14938. }
  14939. app.directive("lazy", {
  14940. beforeMount: lazy.add.bind(lazy),
  14941. updated: lazy.update.bind(lazy),
  14942. unmounted: lazy.remove.bind(lazy)
  14943. });
  14944. app.directive("lazy-container", {
  14945. beforeMount: lazyContainer.bind.bind(lazyContainer),
  14946. updated: lazyContainer.update.bind(lazyContainer),
  14947. unmounted: lazyContainer.unbind.bind(lazyContainer)
  14948. });
  14949. }
  14950. };
  14951. const version = "3.6.4";
  14952. function install(app) {
  14953. const components = [
  14954. ActionBar,
  14955. ActionBarButton,
  14956. ActionBarIcon,
  14957. ActionSheet,
  14958. AddressEdit,
  14959. AddressList,
  14960. Area,
  14961. Badge,
  14962. Button,
  14963. Calendar,
  14964. Card,
  14965. Cascader,
  14966. Cell,
  14967. CellGroup,
  14968. Checkbox,
  14969. CheckboxGroup,
  14970. Circle,
  14971. Col,
  14972. Collapse,
  14973. CollapseItem,
  14974. ConfigProvider,
  14975. ContactCard,
  14976. ContactEdit,
  14977. ContactList,
  14978. CountDown,
  14979. Coupon,
  14980. CouponCell,
  14981. CouponList,
  14982. DatetimePicker,
  14983. Dialog,
  14984. Divider,
  14985. DropdownItem,
  14986. DropdownMenu,
  14987. Empty,
  14988. Field,
  14989. Form,
  14990. Grid,
  14991. GridItem,
  14992. Icon,
  14993. Image$1,
  14994. ImagePreview,
  14995. IndexAnchor,
  14996. IndexBar,
  14997. List,
  14998. Loading,
  14999. Locale,
  15000. NavBar,
  15001. NoticeBar,
  15002. Notify,
  15003. NumberKeyboard,
  15004. Overlay,
  15005. Pagination,
  15006. PasswordInput,
  15007. Picker,
  15008. Popover,
  15009. Popup,
  15010. Progress,
  15011. PullRefresh,
  15012. Radio,
  15013. RadioGroup,
  15014. Rate,
  15015. Row,
  15016. Search,
  15017. ShareSheet,
  15018. Sidebar,
  15019. SidebarItem,
  15020. Skeleton,
  15021. Slider,
  15022. Space,
  15023. Step,
  15024. Stepper,
  15025. Steps,
  15026. Sticky,
  15027. SubmitBar,
  15028. Swipe,
  15029. SwipeCell,
  15030. SwipeItem,
  15031. Switch,
  15032. Tab,
  15033. Tabbar,
  15034. TabbarItem,
  15035. Tabs,
  15036. Tag,
  15037. Toast,
  15038. TreeSelect,
  15039. Uploader
  15040. ];
  15041. components.forEach((item) => {
  15042. if (item.install) {
  15043. app.use(item);
  15044. } else if (item.name) {
  15045. app.component(item.name, item);
  15046. }
  15047. });
  15048. }
  15049. var stdin_default = {
  15050. install,
  15051. version
  15052. };
  15053. exports.ActionBar = ActionBar;
  15054. exports.ActionBarButton = ActionBarButton;
  15055. exports.ActionBarIcon = ActionBarIcon;
  15056. exports.ActionSheet = ActionSheet;
  15057. exports.AddressEdit = AddressEdit;
  15058. exports.AddressList = AddressList;
  15059. exports.Area = Area;
  15060. exports.Badge = Badge;
  15061. exports.Button = Button;
  15062. exports.Calendar = Calendar;
  15063. exports.Card = Card;
  15064. exports.Cascader = Cascader;
  15065. exports.Cell = Cell;
  15066. exports.CellGroup = CellGroup;
  15067. exports.Checkbox = Checkbox;
  15068. exports.CheckboxGroup = CheckboxGroup;
  15069. exports.Circle = Circle;
  15070. exports.Col = Col;
  15071. exports.Collapse = Collapse;
  15072. exports.CollapseItem = CollapseItem;
  15073. exports.ConfigProvider = ConfigProvider;
  15074. exports.ContactCard = ContactCard;
  15075. exports.ContactEdit = ContactEdit;
  15076. exports.ContactList = ContactList;
  15077. exports.CountDown = CountDown;
  15078. exports.Coupon = Coupon;
  15079. exports.CouponCell = CouponCell;
  15080. exports.CouponList = CouponList;
  15081. exports.DatetimePicker = DatetimePicker;
  15082. exports.Dialog = Dialog;
  15083. exports.Divider = Divider;
  15084. exports.DropdownItem = DropdownItem;
  15085. exports.DropdownMenu = DropdownMenu;
  15086. exports.Empty = Empty;
  15087. exports.Field = Field;
  15088. exports.Form = Form;
  15089. exports.Grid = Grid;
  15090. exports.GridItem = GridItem;
  15091. exports.Icon = Icon;
  15092. exports.Image = Image$1;
  15093. exports.ImagePreview = ImagePreview;
  15094. exports.IndexAnchor = IndexAnchor;
  15095. exports.IndexBar = IndexBar;
  15096. exports.Lazyload = Lazyload;
  15097. exports.List = List;
  15098. exports.Loading = Loading;
  15099. exports.Locale = Locale;
  15100. exports.NavBar = NavBar;
  15101. exports.NoticeBar = NoticeBar;
  15102. exports.Notify = Notify;
  15103. exports.NumberKeyboard = NumberKeyboard;
  15104. exports.Overlay = Overlay;
  15105. exports.Pagination = Pagination;
  15106. exports.PasswordInput = PasswordInput;
  15107. exports.Picker = Picker;
  15108. exports.Popover = Popover;
  15109. exports.Popup = Popup;
  15110. exports.Progress = Progress;
  15111. exports.PullRefresh = PullRefresh;
  15112. exports.Radio = Radio;
  15113. exports.RadioGroup = RadioGroup;
  15114. exports.Rate = Rate;
  15115. exports.Row = Row;
  15116. exports.Search = Search;
  15117. exports.ShareSheet = ShareSheet;
  15118. exports.Sidebar = Sidebar;
  15119. exports.SidebarItem = SidebarItem;
  15120. exports.Skeleton = Skeleton;
  15121. exports.Slider = Slider;
  15122. exports.Space = Space;
  15123. exports.Step = Step;
  15124. exports.Stepper = Stepper;
  15125. exports.Steps = Steps;
  15126. exports.Sticky = Sticky;
  15127. exports.SubmitBar = SubmitBar;
  15128. exports.Swipe = Swipe;
  15129. exports.SwipeCell = SwipeCell;
  15130. exports.SwipeItem = SwipeItem;
  15131. exports.Switch = Switch;
  15132. exports.Tab = Tab;
  15133. exports.Tabbar = Tabbar;
  15134. exports.TabbarItem = TabbarItem;
  15135. exports.Tabs = Tabs;
  15136. exports.Tag = Tag;
  15137. exports.Toast = Toast;
  15138. exports.TreeSelect = TreeSelect;
  15139. exports.Uploader = Uploader;
  15140. exports.default = stdin_default;
  15141. exports.install = install;
  15142. exports.version = version;