vant.cjs.js 427 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200
  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 isSameValue = (newValue, oldValue) => JSON.stringify(newValue) === JSON.stringify(oldValue);
  39. const toArray = (item) => Array.isArray(item) ? item : [item];
  40. const unknownProp = null;
  41. const numericProp = [Number, String];
  42. const truthProp = {
  43. type: Boolean,
  44. default: true
  45. };
  46. const makeRequiredProp = (type) => ({
  47. type,
  48. required: true
  49. });
  50. const makeArrayProp = () => ({
  51. type: Array,
  52. default: () => []
  53. });
  54. const makeNumberProp = (defaultVal) => ({
  55. type: Number,
  56. default: defaultVal
  57. });
  58. const makeNumericProp = (defaultVal) => ({
  59. type: numericProp,
  60. default: defaultVal
  61. });
  62. const makeStringProp = (defaultVal) => ({
  63. type: String,
  64. default: defaultVal
  65. });
  66. function getScrollTop(el) {
  67. const top = "scrollTop" in el ? el.scrollTop : el.pageYOffset;
  68. return Math.max(top, 0);
  69. }
  70. function setScrollTop(el, value) {
  71. if ("scrollTop" in el) {
  72. el.scrollTop = value;
  73. } else {
  74. el.scrollTo(el.scrollX, value);
  75. }
  76. }
  77. function getRootScrollTop() {
  78. return window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0;
  79. }
  80. function setRootScrollTop(value) {
  81. setScrollTop(window, value);
  82. setScrollTop(document.body, value);
  83. }
  84. function getElementTop(el, scroller) {
  85. if (el === window) {
  86. return 0;
  87. }
  88. const scrollTop = scroller ? getScrollTop(scroller) : getRootScrollTop();
  89. return use.useRect(el).top + scrollTop;
  90. }
  91. const isIOS = isIOS$1();
  92. function resetScroll() {
  93. if (isIOS) {
  94. setRootScrollTop(getRootScrollTop());
  95. }
  96. }
  97. const stopPropagation = (event) => event.stopPropagation();
  98. function preventDefault(event, isStopPropagation) {
  99. if (typeof event.cancelable !== "boolean" || event.cancelable) {
  100. event.preventDefault();
  101. }
  102. if (isStopPropagation) {
  103. stopPropagation(event);
  104. }
  105. }
  106. function isHidden(elementRef) {
  107. const el = vue.unref(elementRef);
  108. if (!el) {
  109. return false;
  110. }
  111. const style = window.getComputedStyle(el);
  112. const hidden = style.display === "none";
  113. const parentHidden = el.offsetParent === null && style.position !== "fixed";
  114. return hidden || parentHidden;
  115. }
  116. const { width: windowWidth, height: windowHeight } = use.useWindowSize();
  117. function addUnit(value) {
  118. if (isDef(value)) {
  119. return isNumeric(value) ? `${value}px` : String(value);
  120. }
  121. return void 0;
  122. }
  123. function getSizeStyle(originSize) {
  124. if (isDef(originSize)) {
  125. if (Array.isArray(originSize)) {
  126. return {
  127. width: addUnit(originSize[0]),
  128. height: addUnit(originSize[1])
  129. };
  130. }
  131. const size = addUnit(originSize);
  132. return {
  133. width: size,
  134. height: size
  135. };
  136. }
  137. }
  138. function getZIndexStyle(zIndex) {
  139. const style = {};
  140. if (zIndex !== void 0) {
  141. style.zIndex = +zIndex;
  142. }
  143. return style;
  144. }
  145. let rootFontSize;
  146. function getRootFontSize() {
  147. if (!rootFontSize) {
  148. const doc = document.documentElement;
  149. const fontSize = doc.style.fontSize || window.getComputedStyle(doc).fontSize;
  150. rootFontSize = parseFloat(fontSize);
  151. }
  152. return rootFontSize;
  153. }
  154. function convertRem(value) {
  155. value = value.replace(/rem/g, "");
  156. return +value * getRootFontSize();
  157. }
  158. function convertVw(value) {
  159. value = value.replace(/vw/g, "");
  160. return +value * windowWidth.value / 100;
  161. }
  162. function convertVh(value) {
  163. value = value.replace(/vh/g, "");
  164. return +value * windowHeight.value / 100;
  165. }
  166. function unitToPx(value) {
  167. if (typeof value === "number") {
  168. return value;
  169. }
  170. if (inBrowser) {
  171. if (value.includes("rem")) {
  172. return convertRem(value);
  173. }
  174. if (value.includes("vw")) {
  175. return convertVw(value);
  176. }
  177. if (value.includes("vh")) {
  178. return convertVh(value);
  179. }
  180. }
  181. return parseFloat(value);
  182. }
  183. const camelizeRE = /-(\w)/g;
  184. const camelize = (str) => str.replace(camelizeRE, (_, c) => c.toUpperCase());
  185. const kebabCase = (str) => str.replace(/([A-Z])/g, "-$1").toLowerCase().replace(/^-/, "");
  186. function padZero(num, targetLength = 2) {
  187. let str = num + "";
  188. while (str.length < targetLength) {
  189. str = "0" + str;
  190. }
  191. return str;
  192. }
  193. const clamp = (num, min, max) => Math.min(Math.max(num, min), max);
  194. function trimExtraChar(value, char, regExp) {
  195. const index = value.indexOf(char);
  196. if (index === -1) {
  197. return value;
  198. }
  199. if (char === "-" && index !== 0) {
  200. return value.slice(0, index);
  201. }
  202. return value.slice(0, index + 1) + value.slice(index).replace(regExp, "");
  203. }
  204. function formatNumber(value, allowDot = true, allowMinus = true) {
  205. if (allowDot) {
  206. value = trimExtraChar(value, ".", /\./g);
  207. } else {
  208. value = value.split(".")[0];
  209. }
  210. if (allowMinus) {
  211. value = trimExtraChar(value, "-", /-/g);
  212. } else {
  213. value = value.replace(/-/, "");
  214. }
  215. const regExp = allowDot ? /[^-0-9.]/g : /[^-0-9]/g;
  216. return value.replace(regExp, "");
  217. }
  218. function addNumber(num1, num2) {
  219. const cardinal = 10 ** 10;
  220. return Math.round((num1 + num2) * cardinal) / cardinal;
  221. }
  222. const { hasOwnProperty } = Object.prototype;
  223. function assignKey(to, from, key) {
  224. const val = from[key];
  225. if (!isDef(val)) {
  226. return;
  227. }
  228. if (!hasOwnProperty.call(to, key) || !isObject(val)) {
  229. to[key] = val;
  230. } else {
  231. to[key] = deepAssign(Object(to[key]), val);
  232. }
  233. }
  234. function deepAssign(to, from) {
  235. Object.keys(from).forEach((key) => {
  236. assignKey(to, from, key);
  237. });
  238. return to;
  239. }
  240. var stdin_default$1K = {
  241. name: "\u59D3\u540D",
  242. tel: "\u7535\u8BDD",
  243. save: "\u4FDD\u5B58",
  244. confirm: "\u786E\u8BA4",
  245. cancel: "\u53D6\u6D88",
  246. delete: "\u5220\u9664",
  247. loading: "\u52A0\u8F7D\u4E2D...",
  248. noCoupon: "\u6682\u65E0\u4F18\u60E0\u5238",
  249. nameEmpty: "\u8BF7\u586B\u5199\u59D3\u540D",
  250. addContact: "\u6DFB\u52A0\u8054\u7CFB\u4EBA",
  251. telInvalid: "\u8BF7\u586B\u5199\u6B63\u786E\u7684\u7535\u8BDD",
  252. vanCalendar: {
  253. end: "\u7ED3\u675F",
  254. start: "\u5F00\u59CB",
  255. title: "\u65E5\u671F\u9009\u62E9",
  256. weekdays: ["\u65E5", "\u4E00", "\u4E8C", "\u4E09", "\u56DB", "\u4E94", "\u516D"],
  257. monthTitle: (year, month) => `${year}\u5E74${month}\u6708`,
  258. rangePrompt: (maxRange) => `\u6700\u591A\u9009\u62E9 ${maxRange} \u5929`
  259. },
  260. vanCascader: {
  261. select: "\u8BF7\u9009\u62E9"
  262. },
  263. vanPagination: {
  264. prev: "\u4E0A\u4E00\u9875",
  265. next: "\u4E0B\u4E00\u9875"
  266. },
  267. vanPullRefresh: {
  268. pulling: "\u4E0B\u62C9\u5373\u53EF\u5237\u65B0...",
  269. loosing: "\u91CA\u653E\u5373\u53EF\u5237\u65B0..."
  270. },
  271. vanSubmitBar: {
  272. label: "\u5408\u8BA1:"
  273. },
  274. vanCoupon: {
  275. unlimited: "\u65E0\u95E8\u69DB",
  276. discount: (discount) => `${discount}\u6298`,
  277. condition: (condition) => `\u6EE1${condition}\u5143\u53EF\u7528`
  278. },
  279. vanCouponCell: {
  280. title: "\u4F18\u60E0\u5238",
  281. count: (count) => `${count}\u5F20\u53EF\u7528`
  282. },
  283. vanCouponList: {
  284. exchange: "\u5151\u6362",
  285. close: "\u4E0D\u4F7F\u7528",
  286. enable: "\u53EF\u7528",
  287. disabled: "\u4E0D\u53EF\u7528",
  288. placeholder: "\u8F93\u5165\u4F18\u60E0\u7801"
  289. },
  290. vanAddressEdit: {
  291. area: "\u5730\u533A",
  292. areaEmpty: "\u8BF7\u9009\u62E9\u5730\u533A",
  293. addressEmpty: "\u8BF7\u586B\u5199\u8BE6\u7EC6\u5730\u5740",
  294. addressDetail: "\u8BE6\u7EC6\u5730\u5740",
  295. defaultAddress: "\u8BBE\u4E3A\u9ED8\u8BA4\u6536\u8D27\u5730\u5740"
  296. },
  297. vanAddressList: {
  298. add: "\u65B0\u589E\u5730\u5740"
  299. }
  300. };
  301. const lang = vue.ref("zh-CN");
  302. const messages = vue.reactive({
  303. "zh-CN": stdin_default$1K
  304. });
  305. const Locale = {
  306. messages() {
  307. return messages[lang.value];
  308. },
  309. use(newLang, newMessages) {
  310. lang.value = newLang;
  311. this.add({ [newLang]: newMessages });
  312. },
  313. add(newMessages = {}) {
  314. deepAssign(messages, newMessages);
  315. }
  316. };
  317. var stdin_default$1J = Locale;
  318. function createTranslate(name2) {
  319. const prefix = camelize(name2) + ".";
  320. return (path, ...args) => {
  321. const messages2 = stdin_default$1J.messages();
  322. const message = get(messages2, prefix + path) || get(messages2, path);
  323. return isFunction(message) ? message(...args) : message;
  324. };
  325. }
  326. function genBem(name2, mods) {
  327. if (!mods) {
  328. return "";
  329. }
  330. if (typeof mods === "string") {
  331. return ` ${name2}--${mods}`;
  332. }
  333. if (Array.isArray(mods)) {
  334. return mods.reduce(
  335. (ret, item) => ret + genBem(name2, item),
  336. ""
  337. );
  338. }
  339. return Object.keys(mods).reduce(
  340. (ret, key) => ret + (mods[key] ? genBem(name2, key) : ""),
  341. ""
  342. );
  343. }
  344. function createBEM(name2) {
  345. return (el, mods) => {
  346. if (el && typeof el !== "string") {
  347. mods = el;
  348. el = "";
  349. }
  350. el = el ? `${name2}__${el}` : name2;
  351. return `${el}${genBem(el, mods)}`;
  352. };
  353. }
  354. function createNamespace(name2) {
  355. const prefixedName = `van-${name2}`;
  356. return [
  357. prefixedName,
  358. createBEM(prefixedName),
  359. createTranslate(prefixedName)
  360. ];
  361. }
  362. const BORDER = "van-hairline";
  363. const BORDER_TOP = `${BORDER}--top`;
  364. const BORDER_LEFT = `${BORDER}--left`;
  365. const BORDER_BOTTOM = `${BORDER}--bottom`;
  366. const BORDER_SURROUND = `${BORDER}--surround`;
  367. const BORDER_TOP_BOTTOM = `${BORDER}--top-bottom`;
  368. const BORDER_UNSET_TOP_BOTTOM = `${BORDER}-unset--top-bottom`;
  369. const HAPTICS_FEEDBACK = "van-haptics-feedback";
  370. const FORM_KEY = Symbol("van-form");
  371. const LONG_PRESS_START_TIME = 500;
  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. vue.watch([windowWidth, windowHeight], setHeight);
  432. return height;
  433. };
  434. function usePlaceholder(contentRef, bem2) {
  435. const height = useHeight(contentRef, true);
  436. return (renderContent) => vue.createVNode("div", {
  437. "class": bem2("placeholder"),
  438. "style": {
  439. height: height.value ? `${height.value}px` : void 0
  440. }
  441. }, [renderContent()]);
  442. }
  443. const [name$1B, bem$1w] = createNamespace("action-bar");
  444. const ACTION_BAR_KEY = Symbol(name$1B);
  445. const actionBarProps = {
  446. placeholder: Boolean,
  447. safeAreaInsetBottom: truthProp
  448. };
  449. var stdin_default$1I = vue.defineComponent({
  450. name: name$1B,
  451. props: actionBarProps,
  452. setup(props, {
  453. slots
  454. }) {
  455. const root = vue.ref();
  456. const renderPlaceholder = usePlaceholder(root, bem$1w);
  457. const {
  458. linkChildren
  459. } = use.useChildren(ACTION_BAR_KEY);
  460. linkChildren();
  461. const renderActionBar = () => {
  462. var _a;
  463. return vue.createVNode("div", {
  464. "ref": root,
  465. "class": [bem$1w(), {
  466. "van-safe-area-bottom": props.safeAreaInsetBottom
  467. }]
  468. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
  469. };
  470. return () => {
  471. if (props.placeholder) {
  472. return renderPlaceholder(renderActionBar);
  473. }
  474. return renderActionBar();
  475. };
  476. }
  477. });
  478. const ActionBar = withInstall(stdin_default$1I);
  479. function useExpose(apis) {
  480. const instance2 = vue.getCurrentInstance();
  481. if (instance2) {
  482. extend(instance2.proxy, apis);
  483. }
  484. }
  485. const routeProps = {
  486. to: [String, Object],
  487. url: String,
  488. replace: Boolean
  489. };
  490. function route({
  491. to,
  492. url,
  493. replace,
  494. $router: router
  495. }) {
  496. if (to && router) {
  497. router[replace ? "replace" : "push"](to);
  498. } else if (url) {
  499. replace ? location.replace(url) : location.href = url;
  500. }
  501. }
  502. function useRoute() {
  503. const vm = vue.getCurrentInstance().proxy;
  504. return () => route(vm);
  505. }
  506. const [name$1A, bem$1v] = createNamespace("badge");
  507. const badgeProps = {
  508. dot: Boolean,
  509. max: numericProp,
  510. tag: makeStringProp("div"),
  511. color: String,
  512. offset: Array,
  513. content: numericProp,
  514. showZero: truthProp,
  515. position: makeStringProp("top-right")
  516. };
  517. var stdin_default$1H = vue.defineComponent({
  518. name: name$1A,
  519. props: badgeProps,
  520. setup(props, {
  521. slots
  522. }) {
  523. const hasContent = () => {
  524. if (slots.content) {
  525. return true;
  526. }
  527. const {
  528. content,
  529. showZero
  530. } = props;
  531. return isDef(content) && content !== "" && (showZero || content !== 0 && content !== "0");
  532. };
  533. const renderContent = () => {
  534. const {
  535. dot,
  536. max,
  537. content
  538. } = props;
  539. if (!dot && hasContent()) {
  540. if (slots.content) {
  541. return slots.content();
  542. }
  543. if (isDef(max) && isNumeric(content) && +content > max) {
  544. return `${max}+`;
  545. }
  546. return content;
  547. }
  548. };
  549. const style = vue.computed(() => {
  550. const style2 = {
  551. background: props.color
  552. };
  553. if (props.offset) {
  554. const [x, y] = props.offset;
  555. if (slots.default) {
  556. style2.top = addUnit(y);
  557. if (typeof x === "number") {
  558. style2.right = addUnit(-x);
  559. } else {
  560. style2.right = x.startsWith("-") ? x.replace("-", "") : `-${x}`;
  561. }
  562. } else {
  563. style2.marginTop = addUnit(y);
  564. style2.marginLeft = addUnit(x);
  565. }
  566. }
  567. return style2;
  568. });
  569. const renderBadge = () => {
  570. if (hasContent() || props.dot) {
  571. return vue.createVNode("div", {
  572. "class": bem$1v([props.position, {
  573. dot: props.dot,
  574. fixed: !!slots.default
  575. }]),
  576. "style": style.value
  577. }, [renderContent()]);
  578. }
  579. };
  580. return () => {
  581. if (slots.default) {
  582. const {
  583. tag
  584. } = props;
  585. return vue.createVNode(tag, {
  586. "class": bem$1v("wrapper")
  587. }, {
  588. default: () => [slots.default(), renderBadge()]
  589. });
  590. }
  591. return renderBadge();
  592. };
  593. }
  594. });
  595. const Badge = withInstall(stdin_default$1H);
  596. let globalZIndex = 2e3;
  597. const useGlobalZIndex = () => ++globalZIndex;
  598. const setGlobalZIndex = (val) => {
  599. globalZIndex = val;
  600. };
  601. const [name$1z, bem$1u] = createNamespace("config-provider");
  602. const CONFIG_PROVIDER_KEY = Symbol(name$1z);
  603. const configProviderProps = {
  604. tag: makeStringProp("div"),
  605. theme: makeStringProp("light"),
  606. zIndex: Number,
  607. themeVars: Object,
  608. themeVarsDark: Object,
  609. themeVarsLight: Object,
  610. iconPrefix: String
  611. };
  612. function mapThemeVarsToCSSVars(themeVars) {
  613. const cssVars = {};
  614. Object.keys(themeVars).forEach((key) => {
  615. cssVars[`--van-${kebabCase(key)}`] = themeVars[key];
  616. });
  617. return cssVars;
  618. }
  619. var stdin_default$1G = vue.defineComponent({
  620. name: name$1z,
  621. props: configProviderProps,
  622. setup(props, {
  623. slots
  624. }) {
  625. const style = vue.computed(() => mapThemeVarsToCSSVars(extend({}, props.themeVars, props.theme === "dark" ? props.themeVarsDark : props.themeVarsLight)));
  626. if (inBrowser) {
  627. const addTheme = () => {
  628. document.documentElement.classList.add(`van-theme-${props.theme}`);
  629. };
  630. const removeTheme = (theme = props.theme) => {
  631. document.documentElement.classList.remove(`van-theme-${theme}`);
  632. };
  633. vue.watch(() => props.theme, (newVal, oldVal) => {
  634. if (oldVal) {
  635. removeTheme(oldVal);
  636. }
  637. addTheme();
  638. }, {
  639. immediate: true
  640. });
  641. vue.onActivated(addTheme);
  642. vue.onDeactivated(removeTheme);
  643. vue.onBeforeUnmount(removeTheme);
  644. }
  645. vue.provide(CONFIG_PROVIDER_KEY, props);
  646. vue.watchEffect(() => {
  647. if (props.zIndex !== void 0) {
  648. setGlobalZIndex(props.zIndex);
  649. }
  650. });
  651. return () => vue.createVNode(props.tag, {
  652. "class": bem$1u(),
  653. "style": style.value
  654. }, {
  655. default: () => {
  656. var _a;
  657. return [(_a = slots.default) == null ? void 0 : _a.call(slots)];
  658. }
  659. });
  660. }
  661. });
  662. const [name$1y, bem$1t] = createNamespace("icon");
  663. const isImage = (name2) => name2 == null ? void 0 : name2.includes("/");
  664. const iconProps = {
  665. dot: Boolean,
  666. tag: makeStringProp("i"),
  667. name: String,
  668. size: numericProp,
  669. badge: numericProp,
  670. color: String,
  671. badgeProps: Object,
  672. classPrefix: String
  673. };
  674. var stdin_default$1F = vue.defineComponent({
  675. name: name$1y,
  676. props: iconProps,
  677. setup(props, {
  678. slots
  679. }) {
  680. const config = vue.inject(CONFIG_PROVIDER_KEY, null);
  681. const classPrefix = vue.computed(() => props.classPrefix || (config == null ? void 0 : config.iconPrefix) || bem$1t());
  682. return () => {
  683. const {
  684. tag,
  685. dot,
  686. name: name2,
  687. size,
  688. badge,
  689. color
  690. } = props;
  691. const isImageIcon = isImage(name2);
  692. return vue.createVNode(Badge, vue.mergeProps({
  693. "dot": dot,
  694. "tag": tag,
  695. "class": [classPrefix.value, isImageIcon ? "" : `${classPrefix.value}-${name2}`],
  696. "style": {
  697. color,
  698. fontSize: addUnit(size)
  699. },
  700. "content": badge
  701. }, props.badgeProps), {
  702. default: () => {
  703. var _a;
  704. return [(_a = slots.default) == null ? void 0 : _a.call(slots), isImageIcon && vue.createVNode("img", {
  705. "class": bem$1t("image"),
  706. "src": name2
  707. }, null)];
  708. }
  709. });
  710. };
  711. }
  712. });
  713. const Icon = withInstall(stdin_default$1F);
  714. const [name$1x, bem$1s] = createNamespace("loading");
  715. const SpinIcon = Array(12).fill(null).map((_, index) => vue.createVNode("i", {
  716. "class": bem$1s("line", String(index + 1))
  717. }, null));
  718. const CircularIcon = vue.createVNode("svg", {
  719. "class": bem$1s("circular"),
  720. "viewBox": "25 25 50 50"
  721. }, [vue.createVNode("circle", {
  722. "cx": "50",
  723. "cy": "50",
  724. "r": "20",
  725. "fill": "none"
  726. }, null)]);
  727. const loadingProps = {
  728. size: numericProp,
  729. type: makeStringProp("circular"),
  730. color: String,
  731. vertical: Boolean,
  732. textSize: numericProp,
  733. textColor: String
  734. };
  735. var stdin_default$1E = vue.defineComponent({
  736. name: name$1x,
  737. props: loadingProps,
  738. setup(props, {
  739. slots
  740. }) {
  741. const spinnerStyle = vue.computed(() => extend({
  742. color: props.color
  743. }, getSizeStyle(props.size)));
  744. const renderIcon = () => {
  745. const DefaultIcon = props.type === "spinner" ? SpinIcon : CircularIcon;
  746. return vue.createVNode("span", {
  747. "class": bem$1s("spinner", props.type),
  748. "style": spinnerStyle.value
  749. }, [slots.icon ? slots.icon() : DefaultIcon]);
  750. };
  751. const renderText = () => {
  752. var _a;
  753. if (slots.default) {
  754. return vue.createVNode("span", {
  755. "class": bem$1s("text"),
  756. "style": {
  757. fontSize: addUnit(props.textSize),
  758. color: (_a = props.textColor) != null ? _a : props.color
  759. }
  760. }, [slots.default()]);
  761. }
  762. };
  763. return () => {
  764. const {
  765. type,
  766. vertical
  767. } = props;
  768. return vue.createVNode("div", {
  769. "class": bem$1s([type, {
  770. vertical
  771. }]),
  772. "aria-live": "polite",
  773. "aria-busy": true
  774. }, [renderIcon(), renderText()]);
  775. };
  776. }
  777. });
  778. const Loading = withInstall(stdin_default$1E);
  779. const [name$1w, bem$1r] = createNamespace("button");
  780. const buttonProps = extend({}, routeProps, {
  781. tag: makeStringProp("button"),
  782. text: String,
  783. icon: String,
  784. type: makeStringProp("default"),
  785. size: makeStringProp("normal"),
  786. color: String,
  787. block: Boolean,
  788. plain: Boolean,
  789. round: Boolean,
  790. square: Boolean,
  791. loading: Boolean,
  792. hairline: Boolean,
  793. disabled: Boolean,
  794. iconPrefix: String,
  795. nativeType: makeStringProp("button"),
  796. loadingSize: numericProp,
  797. loadingText: String,
  798. loadingType: String,
  799. iconPosition: makeStringProp("left")
  800. });
  801. var stdin_default$1D = vue.defineComponent({
  802. name: name$1w,
  803. props: buttonProps,
  804. emits: ["click"],
  805. setup(props, {
  806. emit,
  807. slots
  808. }) {
  809. const route2 = useRoute();
  810. const renderLoadingIcon = () => {
  811. if (slots.loading) {
  812. return slots.loading();
  813. }
  814. return vue.createVNode(Loading, {
  815. "size": props.loadingSize,
  816. "type": props.loadingType,
  817. "class": bem$1r("loading")
  818. }, null);
  819. };
  820. const renderIcon = () => {
  821. if (props.loading) {
  822. return renderLoadingIcon();
  823. }
  824. if (slots.icon) {
  825. return vue.createVNode("div", {
  826. "class": bem$1r("icon")
  827. }, [slots.icon()]);
  828. }
  829. if (props.icon) {
  830. return vue.createVNode(Icon, {
  831. "name": props.icon,
  832. "class": bem$1r("icon"),
  833. "classPrefix": props.iconPrefix
  834. }, null);
  835. }
  836. };
  837. const renderText = () => {
  838. let text;
  839. if (props.loading) {
  840. text = props.loadingText;
  841. } else {
  842. text = slots.default ? slots.default() : props.text;
  843. }
  844. if (text) {
  845. return vue.createVNode("span", {
  846. "class": bem$1r("text")
  847. }, [text]);
  848. }
  849. };
  850. const getStyle = () => {
  851. const {
  852. color,
  853. plain
  854. } = props;
  855. if (color) {
  856. const style = {
  857. color: plain ? color : "white"
  858. };
  859. if (!plain) {
  860. style.background = color;
  861. }
  862. if (color.includes("gradient")) {
  863. style.border = 0;
  864. } else {
  865. style.borderColor = color;
  866. }
  867. return style;
  868. }
  869. };
  870. const onClick = (event) => {
  871. if (props.loading) {
  872. preventDefault(event);
  873. } else if (!props.disabled) {
  874. emit("click", event);
  875. route2();
  876. }
  877. };
  878. return () => {
  879. const {
  880. tag,
  881. type,
  882. size,
  883. block,
  884. round,
  885. plain,
  886. square,
  887. loading,
  888. disabled,
  889. hairline,
  890. nativeType,
  891. iconPosition
  892. } = props;
  893. const classes = [bem$1r([type, size, {
  894. plain,
  895. block,
  896. round,
  897. square,
  898. loading,
  899. disabled,
  900. hairline
  901. }]), {
  902. [BORDER_SURROUND]: hairline
  903. }];
  904. return vue.createVNode(tag, {
  905. "type": nativeType,
  906. "class": classes,
  907. "style": getStyle(),
  908. "disabled": disabled,
  909. "onClick": onClick
  910. }, {
  911. default: () => [vue.createVNode("div", {
  912. "class": bem$1r("content")
  913. }, [iconPosition === "left" && renderIcon(), renderText(), iconPosition === "right" && renderIcon()])]
  914. });
  915. };
  916. }
  917. });
  918. const Button = withInstall(stdin_default$1D);
  919. const [name$1v, bem$1q] = createNamespace("action-bar-button");
  920. const actionBarButtonProps = extend({}, routeProps, {
  921. type: String,
  922. text: String,
  923. icon: String,
  924. color: String,
  925. loading: Boolean,
  926. disabled: Boolean
  927. });
  928. var stdin_default$1C = vue.defineComponent({
  929. name: name$1v,
  930. props: actionBarButtonProps,
  931. setup(props, {
  932. slots
  933. }) {
  934. const route2 = useRoute();
  935. const {
  936. parent,
  937. index
  938. } = use.useParent(ACTION_BAR_KEY);
  939. const isFirst = vue.computed(() => {
  940. if (parent) {
  941. const prev = parent.children[index.value - 1];
  942. return !(prev && "isButton" in prev);
  943. }
  944. });
  945. const isLast = vue.computed(() => {
  946. if (parent) {
  947. const next = parent.children[index.value + 1];
  948. return !(next && "isButton" in next);
  949. }
  950. });
  951. useExpose({
  952. isButton: true
  953. });
  954. return () => {
  955. const {
  956. type,
  957. icon,
  958. text,
  959. color,
  960. loading,
  961. disabled
  962. } = props;
  963. return vue.createVNode(Button, {
  964. "class": bem$1q([type, {
  965. last: isLast.value,
  966. first: isFirst.value
  967. }]),
  968. "size": "large",
  969. "type": type,
  970. "icon": icon,
  971. "color": color,
  972. "loading": loading,
  973. "disabled": disabled,
  974. "onClick": route2
  975. }, {
  976. default: () => [slots.default ? slots.default() : text]
  977. });
  978. };
  979. }
  980. });
  981. const ActionBarButton = withInstall(stdin_default$1C);
  982. const [name$1u, bem$1p] = createNamespace("action-bar-icon");
  983. const actionBarIconProps = extend({}, routeProps, {
  984. dot: Boolean,
  985. text: String,
  986. icon: String,
  987. color: String,
  988. badge: numericProp,
  989. iconClass: unknownProp,
  990. badgeProps: Object,
  991. iconPrefix: String
  992. });
  993. var stdin_default$1B = vue.defineComponent({
  994. name: name$1u,
  995. props: actionBarIconProps,
  996. setup(props, {
  997. slots
  998. }) {
  999. const route2 = useRoute();
  1000. use.useParent(ACTION_BAR_KEY);
  1001. const renderIcon = () => {
  1002. const {
  1003. dot,
  1004. badge,
  1005. icon,
  1006. color,
  1007. iconClass,
  1008. badgeProps: badgeProps2,
  1009. iconPrefix
  1010. } = props;
  1011. if (slots.icon) {
  1012. return vue.createVNode(Badge, vue.mergeProps({
  1013. "dot": dot,
  1014. "class": bem$1p("icon"),
  1015. "content": badge
  1016. }, badgeProps2), {
  1017. default: slots.icon
  1018. });
  1019. }
  1020. return vue.createVNode(Icon, {
  1021. "tag": "div",
  1022. "dot": dot,
  1023. "name": icon,
  1024. "badge": badge,
  1025. "color": color,
  1026. "class": [bem$1p("icon"), iconClass],
  1027. "badgeProps": badgeProps2,
  1028. "classPrefix": iconPrefix
  1029. }, null);
  1030. };
  1031. return () => vue.createVNode("div", {
  1032. "role": "button",
  1033. "class": bem$1p(),
  1034. "tabindex": 0,
  1035. "onClick": route2
  1036. }, [renderIcon(), slots.default ? slots.default() : props.text]);
  1037. }
  1038. });
  1039. const ActionBarIcon = withInstall(stdin_default$1B);
  1040. const popupSharedProps = {
  1041. show: Boolean,
  1042. zIndex: numericProp,
  1043. overlay: truthProp,
  1044. duration: numericProp,
  1045. teleport: [String, Object],
  1046. lockScroll: truthProp,
  1047. lazyRender: truthProp,
  1048. beforeClose: Function,
  1049. overlayStyle: Object,
  1050. overlayClass: unknownProp,
  1051. transitionAppear: Boolean,
  1052. closeOnClickOverlay: truthProp
  1053. };
  1054. const popupSharedPropKeys = Object.keys(
  1055. popupSharedProps
  1056. );
  1057. function getDirection(x, y) {
  1058. if (x > y) {
  1059. return "horizontal";
  1060. }
  1061. if (y > x) {
  1062. return "vertical";
  1063. }
  1064. return "";
  1065. }
  1066. function useTouch() {
  1067. const startX = vue.ref(0);
  1068. const startY = vue.ref(0);
  1069. const deltaX = vue.ref(0);
  1070. const deltaY = vue.ref(0);
  1071. const offsetX = vue.ref(0);
  1072. const offsetY = vue.ref(0);
  1073. const direction = vue.ref("");
  1074. const isVertical = () => direction.value === "vertical";
  1075. const isHorizontal = () => direction.value === "horizontal";
  1076. const reset = () => {
  1077. deltaX.value = 0;
  1078. deltaY.value = 0;
  1079. offsetX.value = 0;
  1080. offsetY.value = 0;
  1081. direction.value = "";
  1082. };
  1083. const start = (event) => {
  1084. reset();
  1085. startX.value = event.touches[0].clientX;
  1086. startY.value = event.touches[0].clientY;
  1087. };
  1088. const move = (event) => {
  1089. const touch = event.touches[0];
  1090. deltaX.value = (touch.clientX < 0 ? 0 : touch.clientX) - startX.value;
  1091. deltaY.value = touch.clientY - startY.value;
  1092. offsetX.value = Math.abs(deltaX.value);
  1093. offsetY.value = Math.abs(deltaY.value);
  1094. const LOCK_DIRECTION_DISTANCE = 10;
  1095. if (!direction.value || offsetX.value < LOCK_DIRECTION_DISTANCE && offsetY.value < LOCK_DIRECTION_DISTANCE) {
  1096. direction.value = getDirection(offsetX.value, offsetY.value);
  1097. }
  1098. };
  1099. return {
  1100. move,
  1101. start,
  1102. reset,
  1103. startX,
  1104. startY,
  1105. deltaX,
  1106. deltaY,
  1107. offsetX,
  1108. offsetY,
  1109. direction,
  1110. isVertical,
  1111. isHorizontal
  1112. };
  1113. }
  1114. let totalLockCount = 0;
  1115. const BODY_LOCK_CLASS = "van-overflow-hidden";
  1116. function useLockScroll(rootRef, shouldLock) {
  1117. const touch = useTouch();
  1118. const DIRECTION_UP = "01";
  1119. const DIRECTION_DOWN = "10";
  1120. const onTouchMove = (event) => {
  1121. touch.move(event);
  1122. const direction = touch.deltaY.value > 0 ? DIRECTION_DOWN : DIRECTION_UP;
  1123. const el = use.getScrollParent(
  1124. event.target,
  1125. rootRef.value
  1126. );
  1127. const { scrollHeight, offsetHeight, scrollTop } = el;
  1128. let status = "11";
  1129. if (scrollTop === 0) {
  1130. status = offsetHeight >= scrollHeight ? "00" : "01";
  1131. } else if (scrollTop + offsetHeight >= scrollHeight) {
  1132. status = "10";
  1133. }
  1134. if (status !== "11" && touch.isVertical() && !(parseInt(status, 2) & parseInt(direction, 2))) {
  1135. preventDefault(event, true);
  1136. }
  1137. };
  1138. const lock = () => {
  1139. document.addEventListener("touchstart", touch.start);
  1140. document.addEventListener("touchmove", onTouchMove, { passive: false });
  1141. if (!totalLockCount) {
  1142. document.body.classList.add(BODY_LOCK_CLASS);
  1143. }
  1144. totalLockCount++;
  1145. };
  1146. const unlock = () => {
  1147. if (totalLockCount) {
  1148. document.removeEventListener("touchstart", touch.start);
  1149. document.removeEventListener("touchmove", onTouchMove);
  1150. totalLockCount--;
  1151. if (!totalLockCount) {
  1152. document.body.classList.remove(BODY_LOCK_CLASS);
  1153. }
  1154. }
  1155. };
  1156. const init = () => shouldLock() && lock();
  1157. const destroy = () => shouldLock() && unlock();
  1158. use.onMountedOrActivated(init);
  1159. vue.onDeactivated(destroy);
  1160. vue.onBeforeUnmount(destroy);
  1161. vue.watch(shouldLock, (value) => {
  1162. value ? lock() : unlock();
  1163. });
  1164. }
  1165. function useLazyRender(show) {
  1166. const inited = vue.ref(false);
  1167. vue.watch(
  1168. show,
  1169. (value) => {
  1170. if (value) {
  1171. inited.value = value;
  1172. }
  1173. },
  1174. { immediate: true }
  1175. );
  1176. return (render) => () => inited.value ? render() : null;
  1177. }
  1178. const [name$1t, bem$1o] = createNamespace("overlay");
  1179. const overlayProps = {
  1180. show: Boolean,
  1181. zIndex: numericProp,
  1182. duration: numericProp,
  1183. className: unknownProp,
  1184. lockScroll: truthProp,
  1185. lazyRender: truthProp,
  1186. customStyle: Object
  1187. };
  1188. var stdin_default$1A = vue.defineComponent({
  1189. name: name$1t,
  1190. props: overlayProps,
  1191. setup(props, {
  1192. slots
  1193. }) {
  1194. const root = vue.ref();
  1195. const lazyRender = useLazyRender(() => props.show || !props.lazyRender);
  1196. const onTouchMove = (event) => {
  1197. if (props.lockScroll) {
  1198. preventDefault(event, true);
  1199. }
  1200. };
  1201. const renderOverlay = lazyRender(() => {
  1202. var _a;
  1203. const style = extend(getZIndexStyle(props.zIndex), props.customStyle);
  1204. if (isDef(props.duration)) {
  1205. style.animationDuration = `${props.duration}s`;
  1206. }
  1207. return vue.withDirectives(vue.createVNode("div", {
  1208. "ref": root,
  1209. "style": style,
  1210. "class": [bem$1o(), props.className]
  1211. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]), [[vue.vShow, props.show]]);
  1212. });
  1213. use.useEventListener("touchmove", onTouchMove, {
  1214. target: root
  1215. });
  1216. return () => vue.createVNode(vue.Transition, {
  1217. "name": "van-fade",
  1218. "appear": true
  1219. }, {
  1220. default: renderOverlay
  1221. });
  1222. }
  1223. });
  1224. const Overlay = withInstall(stdin_default$1A);
  1225. const popupProps$2 = extend({}, popupSharedProps, {
  1226. round: Boolean,
  1227. position: makeStringProp("center"),
  1228. closeIcon: makeStringProp("cross"),
  1229. closeable: Boolean,
  1230. transition: String,
  1231. iconPrefix: String,
  1232. closeOnPopstate: Boolean,
  1233. closeIconPosition: makeStringProp("top-right"),
  1234. safeAreaInsetTop: Boolean,
  1235. safeAreaInsetBottom: Boolean
  1236. });
  1237. const [name$1s, bem$1n] = createNamespace("popup");
  1238. var stdin_default$1z = vue.defineComponent({
  1239. name: name$1s,
  1240. inheritAttrs: false,
  1241. props: popupProps$2,
  1242. emits: ["open", "close", "opened", "closed", "keydown", "update:show", "clickOverlay", "clickCloseIcon"],
  1243. setup(props, {
  1244. emit,
  1245. attrs,
  1246. slots
  1247. }) {
  1248. let opened;
  1249. let shouldReopen;
  1250. const zIndex = vue.ref();
  1251. const popupRef = vue.ref();
  1252. const lazyRender = useLazyRender(() => props.show || !props.lazyRender);
  1253. const style = vue.computed(() => {
  1254. const style2 = {
  1255. zIndex: zIndex.value
  1256. };
  1257. if (isDef(props.duration)) {
  1258. const key = props.position === "center" ? "animationDuration" : "transitionDuration";
  1259. style2[key] = `${props.duration}s`;
  1260. }
  1261. return style2;
  1262. });
  1263. const open = () => {
  1264. if (!opened) {
  1265. opened = true;
  1266. zIndex.value = props.zIndex !== void 0 ? +props.zIndex : useGlobalZIndex();
  1267. emit("open");
  1268. }
  1269. };
  1270. const close = () => {
  1271. if (opened) {
  1272. callInterceptor(props.beforeClose, {
  1273. done() {
  1274. opened = false;
  1275. emit("close");
  1276. emit("update:show", false);
  1277. }
  1278. });
  1279. }
  1280. };
  1281. const onClickOverlay = (event) => {
  1282. emit("clickOverlay", event);
  1283. if (props.closeOnClickOverlay) {
  1284. close();
  1285. }
  1286. };
  1287. const renderOverlay = () => {
  1288. if (props.overlay) {
  1289. return vue.createVNode(Overlay, {
  1290. "show": props.show,
  1291. "class": props.overlayClass,
  1292. "zIndex": zIndex.value,
  1293. "duration": props.duration,
  1294. "customStyle": props.overlayStyle,
  1295. "role": props.closeOnClickOverlay ? "button" : void 0,
  1296. "tabindex": props.closeOnClickOverlay ? 0 : void 0,
  1297. "onClick": onClickOverlay
  1298. }, {
  1299. default: slots["overlay-content"]
  1300. });
  1301. }
  1302. };
  1303. const onClickCloseIcon = (event) => {
  1304. emit("clickCloseIcon", event);
  1305. close();
  1306. };
  1307. const renderCloseIcon = () => {
  1308. if (props.closeable) {
  1309. return vue.createVNode(Icon, {
  1310. "role": "button",
  1311. "tabindex": 0,
  1312. "name": props.closeIcon,
  1313. "class": [bem$1n("close-icon", props.closeIconPosition), HAPTICS_FEEDBACK],
  1314. "classPrefix": props.iconPrefix,
  1315. "onClick": onClickCloseIcon
  1316. }, null);
  1317. }
  1318. };
  1319. const onOpened = () => emit("opened");
  1320. const onClosed = () => emit("closed");
  1321. const onKeydown = (event) => emit("keydown", event);
  1322. const renderPopup = lazyRender(() => {
  1323. var _a;
  1324. const {
  1325. round,
  1326. position,
  1327. safeAreaInsetTop,
  1328. safeAreaInsetBottom
  1329. } = props;
  1330. return vue.withDirectives(vue.createVNode("div", vue.mergeProps({
  1331. "ref": popupRef,
  1332. "style": style.value,
  1333. "role": "dialog",
  1334. "tabindex": 0,
  1335. "class": [bem$1n({
  1336. round,
  1337. [position]: position
  1338. }), {
  1339. "van-safe-area-top": safeAreaInsetTop,
  1340. "van-safe-area-bottom": safeAreaInsetBottom
  1341. }],
  1342. "onKeydown": onKeydown
  1343. }, attrs), [(_a = slots.default) == null ? void 0 : _a.call(slots), renderCloseIcon()]), [[vue.vShow, props.show]]);
  1344. });
  1345. const renderTransition = () => {
  1346. const {
  1347. position,
  1348. transition,
  1349. transitionAppear
  1350. } = props;
  1351. const name2 = position === "center" ? "van-fade" : `van-popup-slide-${position}`;
  1352. return vue.createVNode(vue.Transition, {
  1353. "name": transition || name2,
  1354. "appear": transitionAppear,
  1355. "onAfterEnter": onOpened,
  1356. "onAfterLeave": onClosed
  1357. }, {
  1358. default: renderPopup
  1359. });
  1360. };
  1361. vue.watch(() => props.show, (show) => {
  1362. if (show && !opened) {
  1363. open();
  1364. if (attrs.tabindex === 0) {
  1365. vue.nextTick(() => {
  1366. var _a;
  1367. (_a = popupRef.value) == null ? void 0 : _a.focus();
  1368. });
  1369. }
  1370. }
  1371. if (!show && opened) {
  1372. opened = false;
  1373. emit("close");
  1374. }
  1375. });
  1376. useExpose({
  1377. popupRef
  1378. });
  1379. useLockScroll(popupRef, () => props.show && props.lockScroll);
  1380. use.useEventListener("popstate", () => {
  1381. if (props.closeOnPopstate) {
  1382. close();
  1383. shouldReopen = false;
  1384. }
  1385. });
  1386. vue.onMounted(() => {
  1387. if (props.show) {
  1388. open();
  1389. }
  1390. });
  1391. vue.onActivated(() => {
  1392. if (shouldReopen) {
  1393. emit("update:show", true);
  1394. shouldReopen = false;
  1395. }
  1396. });
  1397. vue.onDeactivated(() => {
  1398. if (props.show && props.teleport) {
  1399. close();
  1400. shouldReopen = true;
  1401. }
  1402. });
  1403. vue.provide(POPUP_TOGGLE_KEY, () => props.show);
  1404. return () => {
  1405. if (props.teleport) {
  1406. return vue.createVNode(vue.Teleport, {
  1407. "to": props.teleport
  1408. }, {
  1409. default: () => [renderOverlay(), renderTransition()]
  1410. });
  1411. }
  1412. return vue.createVNode(vue.Fragment, null, [renderOverlay(), renderTransition()]);
  1413. };
  1414. }
  1415. });
  1416. const Popup = withInstall(stdin_default$1z);
  1417. const [name$1r, bem$1m] = createNamespace("action-sheet");
  1418. const actionSheetProps = extend({}, popupSharedProps, {
  1419. title: String,
  1420. round: truthProp,
  1421. actions: makeArrayProp(),
  1422. closeIcon: makeStringProp("cross"),
  1423. closeable: truthProp,
  1424. cancelText: String,
  1425. description: String,
  1426. closeOnPopstate: truthProp,
  1427. closeOnClickAction: Boolean,
  1428. safeAreaInsetBottom: truthProp
  1429. });
  1430. const popupInheritKeys$2 = [...popupSharedPropKeys, "round", "closeOnPopstate", "safeAreaInsetBottom"];
  1431. var stdin_default$1y = vue.defineComponent({
  1432. name: name$1r,
  1433. props: actionSheetProps,
  1434. emits: ["select", "cancel", "update:show"],
  1435. setup(props, {
  1436. slots,
  1437. emit
  1438. }) {
  1439. const updateShow = (show) => emit("update:show", show);
  1440. const onCancel = () => {
  1441. updateShow(false);
  1442. emit("cancel");
  1443. };
  1444. const renderHeader = () => {
  1445. if (props.title) {
  1446. return vue.createVNode("div", {
  1447. "class": bem$1m("header")
  1448. }, [props.title, props.closeable && vue.createVNode(Icon, {
  1449. "name": props.closeIcon,
  1450. "class": [bem$1m("close"), HAPTICS_FEEDBACK],
  1451. "onClick": onCancel
  1452. }, null)]);
  1453. }
  1454. };
  1455. const renderCancel = () => {
  1456. if (slots.cancel || props.cancelText) {
  1457. return [vue.createVNode("div", {
  1458. "class": bem$1m("gap")
  1459. }, null), vue.createVNode("button", {
  1460. "type": "button",
  1461. "class": bem$1m("cancel"),
  1462. "onClick": onCancel
  1463. }, [slots.cancel ? slots.cancel() : props.cancelText])];
  1464. }
  1465. };
  1466. const renderActionContent = (action, index) => {
  1467. if (action.loading) {
  1468. return vue.createVNode(Loading, {
  1469. "class": bem$1m("loading-icon")
  1470. }, null);
  1471. }
  1472. if (slots.action) {
  1473. return slots.action({
  1474. action,
  1475. index
  1476. });
  1477. }
  1478. return [vue.createVNode("span", {
  1479. "class": bem$1m("name")
  1480. }, [action.name]), action.subname && vue.createVNode("div", {
  1481. "class": bem$1m("subname")
  1482. }, [action.subname])];
  1483. };
  1484. const renderAction = (action, index) => {
  1485. const {
  1486. color,
  1487. loading,
  1488. callback,
  1489. disabled,
  1490. className
  1491. } = action;
  1492. const onClick = () => {
  1493. if (disabled || loading) {
  1494. return;
  1495. }
  1496. if (callback) {
  1497. callback(action);
  1498. }
  1499. if (props.closeOnClickAction) {
  1500. updateShow(false);
  1501. }
  1502. vue.nextTick(() => emit("select", action, index));
  1503. };
  1504. return vue.createVNode("button", {
  1505. "type": "button",
  1506. "style": {
  1507. color
  1508. },
  1509. "class": [bem$1m("item", {
  1510. loading,
  1511. disabled
  1512. }), className],
  1513. "onClick": onClick
  1514. }, [renderActionContent(action, index)]);
  1515. };
  1516. const renderDescription = () => {
  1517. if (props.description || slots.description) {
  1518. const content = slots.description ? slots.description() : props.description;
  1519. return vue.createVNode("div", {
  1520. "class": bem$1m("description")
  1521. }, [content]);
  1522. }
  1523. };
  1524. return () => vue.createVNode(Popup, vue.mergeProps({
  1525. "class": bem$1m(),
  1526. "position": "bottom",
  1527. "onUpdate:show": updateShow
  1528. }, pick(props, popupInheritKeys$2)), {
  1529. default: () => {
  1530. var _a;
  1531. return [renderHeader(), renderDescription(), vue.createVNode("div", {
  1532. "class": bem$1m("content")
  1533. }, [props.actions.map(renderAction), (_a = slots.default) == null ? void 0 : _a.call(slots)]), renderCancel()];
  1534. }
  1535. });
  1536. }
  1537. });
  1538. const ActionSheet = withInstall(stdin_default$1y);
  1539. const [name$1q, bem$1l, t$j] = createNamespace("picker");
  1540. const getFirstEnabledOption = (options) => options.find((option) => !option.disabled) || options[0];
  1541. function getColumnsType(columns, fields) {
  1542. const firstColumn = columns[0];
  1543. if (firstColumn) {
  1544. if (Array.isArray(firstColumn)) {
  1545. return "multiple";
  1546. }
  1547. if (fields.children in firstColumn) {
  1548. return "cascade";
  1549. }
  1550. }
  1551. return "default";
  1552. }
  1553. function findIndexOfEnabledOption(options, index) {
  1554. index = clamp(index, 0, options.length);
  1555. for (let i = index; i < options.length; i++) {
  1556. if (!options[i].disabled)
  1557. return i;
  1558. }
  1559. for (let i = index - 1; i >= 0; i--) {
  1560. if (!options[i].disabled)
  1561. return i;
  1562. }
  1563. return 0;
  1564. }
  1565. const isOptionExist = (options, value, fields) => value !== void 0 && !!options.find((option) => option[fields.value] === value);
  1566. function findOptionByValue(options, value, fields) {
  1567. const index = options.findIndex((option) => option[fields.value] === value);
  1568. const enabledIndex = findIndexOfEnabledOption(options, index);
  1569. return options[enabledIndex];
  1570. }
  1571. function formatCascadeColumns(columns, fields, selectedValues) {
  1572. const formatted = [];
  1573. let cursor = {
  1574. [fields.children]: columns
  1575. };
  1576. let columnIndex = 0;
  1577. while (cursor && cursor[fields.children]) {
  1578. const options = cursor[fields.children];
  1579. const value = selectedValues.value[columnIndex];
  1580. cursor = isDef(value) ? findOptionByValue(options, value, fields) : void 0;
  1581. if (!cursor && options.length) {
  1582. const firstValue = getFirstEnabledOption(options)[fields.value];
  1583. cursor = findOptionByValue(options, firstValue, fields);
  1584. }
  1585. columnIndex++;
  1586. formatted.push(options);
  1587. }
  1588. return formatted;
  1589. }
  1590. function getElementTranslateY(element) {
  1591. const { transform } = window.getComputedStyle(element);
  1592. const translateY = transform.slice(7, transform.length - 1).split(", ")[5];
  1593. return Number(translateY);
  1594. }
  1595. function assignDefaultFields(fields) {
  1596. return extend(
  1597. {
  1598. text: "text",
  1599. value: "value",
  1600. children: "children"
  1601. },
  1602. fields
  1603. );
  1604. }
  1605. const DEFAULT_DURATION = 200;
  1606. const MOMENTUM_TIME = 300;
  1607. const MOMENTUM_DISTANCE = 15;
  1608. const [name$1p, bem$1k] = createNamespace("picker-column");
  1609. const PICKER_KEY = Symbol(name$1p);
  1610. var stdin_default$1x = vue.defineComponent({
  1611. name: name$1p,
  1612. props: {
  1613. value: numericProp,
  1614. fields: makeRequiredProp(Object),
  1615. options: makeArrayProp(),
  1616. readonly: Boolean,
  1617. allowHtml: Boolean,
  1618. optionHeight: makeRequiredProp(Number),
  1619. swipeDuration: makeRequiredProp(numericProp),
  1620. visibleOptionNum: makeRequiredProp(numericProp)
  1621. },
  1622. emits: ["change", "clickOption"],
  1623. setup(props, {
  1624. emit,
  1625. slots
  1626. }) {
  1627. let moving;
  1628. let startOffset;
  1629. let touchStartTime;
  1630. let momentumOffset;
  1631. let transitionEndTrigger;
  1632. const root = vue.ref();
  1633. const wrapper = vue.ref();
  1634. const currentOffset = vue.ref(0);
  1635. const currentDuration = vue.ref(0);
  1636. const touch = useTouch();
  1637. const count = () => props.options.length;
  1638. const baseOffset = () => props.optionHeight * (+props.visibleOptionNum - 1) / 2;
  1639. const updateValueByIndex = (index) => {
  1640. const enabledIndex = findIndexOfEnabledOption(props.options, index);
  1641. const offset = -enabledIndex * props.optionHeight;
  1642. const trigger = () => {
  1643. const value = props.options[enabledIndex][props.fields.value];
  1644. if (value !== props.value) {
  1645. emit("change", value);
  1646. }
  1647. };
  1648. if (moving && offset !== currentOffset.value) {
  1649. transitionEndTrigger = trigger;
  1650. } else {
  1651. trigger();
  1652. }
  1653. currentOffset.value = offset;
  1654. };
  1655. const isReadonly = () => props.readonly || !props.options.length;
  1656. const onClickOption = (index) => {
  1657. if (moving || isReadonly()) {
  1658. return;
  1659. }
  1660. transitionEndTrigger = null;
  1661. currentDuration.value = DEFAULT_DURATION;
  1662. updateValueByIndex(index);
  1663. emit("clickOption", props.options[index]);
  1664. };
  1665. const getIndexByOffset = (offset) => clamp(Math.round(-offset / props.optionHeight), 0, count() - 1);
  1666. const momentum = (distance, duration) => {
  1667. const speed = Math.abs(distance / duration);
  1668. distance = currentOffset.value + speed / 3e-3 * (distance < 0 ? -1 : 1);
  1669. const index = getIndexByOffset(distance);
  1670. currentDuration.value = +props.swipeDuration;
  1671. updateValueByIndex(index);
  1672. };
  1673. const stopMomentum = () => {
  1674. moving = false;
  1675. currentDuration.value = 0;
  1676. if (transitionEndTrigger) {
  1677. transitionEndTrigger();
  1678. transitionEndTrigger = null;
  1679. }
  1680. };
  1681. const onTouchStart = (event) => {
  1682. if (isReadonly()) {
  1683. return;
  1684. }
  1685. touch.start(event);
  1686. if (moving) {
  1687. const translateY = getElementTranslateY(wrapper.value);
  1688. currentOffset.value = Math.min(0, translateY - baseOffset());
  1689. }
  1690. currentDuration.value = 0;
  1691. startOffset = currentOffset.value;
  1692. touchStartTime = Date.now();
  1693. momentumOffset = startOffset;
  1694. transitionEndTrigger = null;
  1695. };
  1696. const onTouchMove = (event) => {
  1697. if (isReadonly()) {
  1698. return;
  1699. }
  1700. touch.move(event);
  1701. if (touch.isVertical()) {
  1702. moving = true;
  1703. preventDefault(event, true);
  1704. }
  1705. currentOffset.value = clamp(startOffset + touch.deltaY.value, -(count() * props.optionHeight), props.optionHeight);
  1706. const now = Date.now();
  1707. if (now - touchStartTime > MOMENTUM_TIME) {
  1708. touchStartTime = now;
  1709. momentumOffset = currentOffset.value;
  1710. }
  1711. };
  1712. const onTouchEnd = () => {
  1713. if (isReadonly()) {
  1714. return;
  1715. }
  1716. const distance = currentOffset.value - momentumOffset;
  1717. const duration = Date.now() - touchStartTime;
  1718. const startMomentum = duration < MOMENTUM_TIME && Math.abs(distance) > MOMENTUM_DISTANCE;
  1719. if (startMomentum) {
  1720. momentum(distance, duration);
  1721. return;
  1722. }
  1723. const index = getIndexByOffset(currentOffset.value);
  1724. currentDuration.value = DEFAULT_DURATION;
  1725. updateValueByIndex(index);
  1726. setTimeout(() => {
  1727. moving = false;
  1728. }, 0);
  1729. };
  1730. const renderOptions = () => {
  1731. const optionStyle = {
  1732. height: `${props.optionHeight}px`
  1733. };
  1734. return props.options.map((option, index) => {
  1735. const text = option[props.fields.text];
  1736. const {
  1737. disabled
  1738. } = option;
  1739. const value = option[props.fields.value];
  1740. const data = {
  1741. role: "button",
  1742. style: optionStyle,
  1743. tabindex: disabled ? -1 : 0,
  1744. class: [bem$1k("item", {
  1745. disabled,
  1746. selected: value === props.value
  1747. }), option.className],
  1748. onClick: () => onClickOption(index)
  1749. };
  1750. const childData = {
  1751. class: "van-ellipsis",
  1752. [props.allowHtml ? "innerHTML" : "textContent"]: text
  1753. };
  1754. return vue.createVNode("li", data, [slots.option ? slots.option(option) : vue.createVNode("div", childData, null)]);
  1755. });
  1756. };
  1757. use.useParent(PICKER_KEY);
  1758. useExpose({
  1759. stopMomentum
  1760. });
  1761. vue.watchEffect(() => {
  1762. const index = props.options.findIndex((option) => option[props.fields.value] === props.value);
  1763. const enabledIndex = findIndexOfEnabledOption(props.options, index);
  1764. const offset = -enabledIndex * props.optionHeight;
  1765. currentOffset.value = offset;
  1766. });
  1767. use.useEventListener("touchmove", onTouchMove, {
  1768. target: root
  1769. });
  1770. return () => vue.createVNode("div", {
  1771. "ref": root,
  1772. "class": bem$1k(),
  1773. "onTouchstartPassive": onTouchStart,
  1774. "onTouchend": onTouchEnd,
  1775. "onTouchcancel": onTouchEnd
  1776. }, [vue.createVNode("ul", {
  1777. "ref": wrapper,
  1778. "style": {
  1779. transform: `translate3d(0, ${currentOffset.value + baseOffset()}px, 0)`,
  1780. transitionDuration: `${currentDuration.value}ms`,
  1781. transitionProperty: currentDuration.value ? "all" : "none"
  1782. },
  1783. "class": bem$1k("wrapper"),
  1784. "onTransitionend": stopMomentum
  1785. }, [renderOptions()])]);
  1786. }
  1787. });
  1788. const [name$1o] = createNamespace("picker-toolbar");
  1789. const pickerToolbarProps = {
  1790. title: String,
  1791. cancelButtonText: String,
  1792. confirmButtonText: String
  1793. };
  1794. const pickerToolbarSlots = ["cancel", "confirm", "title", "toolbar"];
  1795. const pickerToolbarPropKeys = Object.keys(pickerToolbarProps);
  1796. var stdin_default$1w = vue.defineComponent({
  1797. name: name$1o,
  1798. props: pickerToolbarProps,
  1799. emits: ["confirm", "cancel"],
  1800. setup(props, {
  1801. emit,
  1802. slots
  1803. }) {
  1804. const renderTitle = () => {
  1805. if (slots.title) {
  1806. return slots.title();
  1807. }
  1808. if (props.title) {
  1809. return vue.createVNode("div", {
  1810. "class": [bem$1l("title"), "van-ellipsis"]
  1811. }, [props.title]);
  1812. }
  1813. };
  1814. const onCancel = () => emit("cancel");
  1815. const onConfirm = () => emit("confirm");
  1816. const renderCancel = () => {
  1817. const text = props.cancelButtonText || t$j("cancel");
  1818. return vue.createVNode("button", {
  1819. "type": "button",
  1820. "class": [bem$1l("cancel"), HAPTICS_FEEDBACK],
  1821. "onClick": onCancel
  1822. }, [slots.cancel ? slots.cancel() : text]);
  1823. };
  1824. const renderConfirm = () => {
  1825. const text = props.confirmButtonText || t$j("confirm");
  1826. return vue.createVNode("button", {
  1827. "type": "button",
  1828. "class": [bem$1l("confirm"), HAPTICS_FEEDBACK],
  1829. "onClick": onConfirm
  1830. }, [slots.confirm ? slots.confirm() : text]);
  1831. };
  1832. return () => vue.createVNode("div", {
  1833. "class": bem$1l("toolbar")
  1834. }, [slots.toolbar ? slots.toolbar() : [renderCancel(), renderTitle(), renderConfirm()]]);
  1835. }
  1836. });
  1837. function scrollLeftTo(scroller, to, duration) {
  1838. let count = 0;
  1839. const from = scroller.scrollLeft;
  1840. const frames = duration === 0 ? 1 : Math.round(duration * 1e3 / 16);
  1841. function animate() {
  1842. scroller.scrollLeft += (to - from) / frames;
  1843. if (++count < frames) {
  1844. use.raf(animate);
  1845. }
  1846. }
  1847. animate();
  1848. }
  1849. function scrollTopTo(scroller, to, duration, callback) {
  1850. let current2 = getScrollTop(scroller);
  1851. const isDown = current2 < to;
  1852. const frames = duration === 0 ? 1 : Math.round(duration * 1e3 / 16);
  1853. const step = (to - current2) / frames;
  1854. function animate() {
  1855. current2 += step;
  1856. if (isDown && current2 > to || !isDown && current2 < to) {
  1857. current2 = to;
  1858. }
  1859. setScrollTop(scroller, current2);
  1860. if (isDown && current2 < to || !isDown && current2 > to) {
  1861. use.raf(animate);
  1862. } else if (callback) {
  1863. use.raf(callback);
  1864. }
  1865. }
  1866. animate();
  1867. }
  1868. let current = 0;
  1869. function useId() {
  1870. const vm = vue.getCurrentInstance();
  1871. const { name: name2 = "unknown" } = (vm == null ? void 0 : vm.type) || {};
  1872. if (process.env.NODE_ENV === "test") {
  1873. return name2;
  1874. }
  1875. return `${name2}-${++current}`;
  1876. }
  1877. function useRefs() {
  1878. const refs = vue.ref([]);
  1879. const cache = [];
  1880. vue.onBeforeUpdate(() => {
  1881. refs.value = [];
  1882. });
  1883. const setRefs = (index) => {
  1884. if (!cache[index]) {
  1885. cache[index] = (el) => {
  1886. refs.value[index] = el;
  1887. };
  1888. }
  1889. return cache[index];
  1890. };
  1891. return [refs, setRefs];
  1892. }
  1893. function useVisibilityChange(target, onChange) {
  1894. if (!inBrowser || !window.IntersectionObserver) {
  1895. return;
  1896. }
  1897. const observer = new IntersectionObserver(
  1898. (entries) => {
  1899. onChange(entries[0].intersectionRatio > 0);
  1900. },
  1901. { root: document.body }
  1902. );
  1903. const observe = () => {
  1904. if (target.value) {
  1905. observer.observe(target.value);
  1906. }
  1907. };
  1908. const unobserve = () => {
  1909. if (target.value) {
  1910. observer.unobserve(target.value);
  1911. }
  1912. };
  1913. vue.onDeactivated(unobserve);
  1914. vue.onBeforeUnmount(unobserve);
  1915. use.onMountedOrActivated(observe);
  1916. }
  1917. const [name$1n, bem$1j] = createNamespace("sticky");
  1918. const stickyProps = {
  1919. zIndex: numericProp,
  1920. position: makeStringProp("top"),
  1921. container: Object,
  1922. offsetTop: makeNumericProp(0),
  1923. offsetBottom: makeNumericProp(0)
  1924. };
  1925. var stdin_default$1v = vue.defineComponent({
  1926. name: name$1n,
  1927. props: stickyProps,
  1928. emits: ["scroll", "change"],
  1929. setup(props, {
  1930. emit,
  1931. slots
  1932. }) {
  1933. const root = vue.ref();
  1934. const scrollParent = use.useScrollParent(root);
  1935. const state = vue.reactive({
  1936. fixed: false,
  1937. width: 0,
  1938. height: 0,
  1939. transform: 0
  1940. });
  1941. const offset = vue.computed(() => unitToPx(props.position === "top" ? props.offsetTop : props.offsetBottom));
  1942. const rootStyle = vue.computed(() => {
  1943. const {
  1944. fixed,
  1945. height,
  1946. width
  1947. } = state;
  1948. if (fixed) {
  1949. return {
  1950. width: `${width}px`,
  1951. height: `${height}px`
  1952. };
  1953. }
  1954. });
  1955. const stickyStyle = vue.computed(() => {
  1956. if (!state.fixed) {
  1957. return;
  1958. }
  1959. const style = extend(getZIndexStyle(props.zIndex), {
  1960. width: `${state.width}px`,
  1961. height: `${state.height}px`,
  1962. [props.position]: `${offset.value}px`
  1963. });
  1964. if (state.transform) {
  1965. style.transform = `translate3d(0, ${state.transform}px, 0)`;
  1966. }
  1967. return style;
  1968. });
  1969. const emitScroll = (scrollTop) => emit("scroll", {
  1970. scrollTop,
  1971. isFixed: state.fixed
  1972. });
  1973. const onScroll = () => {
  1974. if (!root.value || isHidden(root)) {
  1975. return;
  1976. }
  1977. const {
  1978. container,
  1979. position
  1980. } = props;
  1981. const rootRect = use.useRect(root);
  1982. const scrollTop = getScrollTop(window);
  1983. state.width = rootRect.width;
  1984. state.height = rootRect.height;
  1985. if (position === "top") {
  1986. if (container) {
  1987. const containerRect = use.useRect(container);
  1988. const difference = containerRect.bottom - offset.value - state.height;
  1989. state.fixed = offset.value > rootRect.top && containerRect.bottom > 0;
  1990. state.transform = difference < 0 ? difference : 0;
  1991. } else {
  1992. state.fixed = offset.value > rootRect.top;
  1993. }
  1994. } else {
  1995. const {
  1996. clientHeight
  1997. } = document.documentElement;
  1998. if (container) {
  1999. const containerRect = use.useRect(container);
  2000. const difference = clientHeight - containerRect.top - offset.value - state.height;
  2001. state.fixed = clientHeight - offset.value < rootRect.bottom && clientHeight > containerRect.top;
  2002. state.transform = difference < 0 ? -difference : 0;
  2003. } else {
  2004. state.fixed = clientHeight - offset.value < rootRect.bottom;
  2005. }
  2006. }
  2007. emitScroll(scrollTop);
  2008. };
  2009. vue.watch(() => state.fixed, (value) => emit("change", value));
  2010. use.useEventListener("scroll", onScroll, {
  2011. target: scrollParent,
  2012. passive: true
  2013. });
  2014. useVisibilityChange(root, onScroll);
  2015. return () => {
  2016. var _a;
  2017. return vue.createVNode("div", {
  2018. "ref": root,
  2019. "style": rootStyle.value
  2020. }, [vue.createVNode("div", {
  2021. "class": bem$1j({
  2022. fixed: state.fixed
  2023. }),
  2024. "style": stickyStyle.value
  2025. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)])]);
  2026. };
  2027. }
  2028. });
  2029. const Sticky = withInstall(stdin_default$1v);
  2030. const [name$1m, bem$1i] = createNamespace("tab");
  2031. var stdin_default$1u = vue.defineComponent({
  2032. name: name$1m,
  2033. props: {
  2034. id: String,
  2035. dot: Boolean,
  2036. type: String,
  2037. color: String,
  2038. title: String,
  2039. badge: numericProp,
  2040. shrink: Boolean,
  2041. isActive: Boolean,
  2042. disabled: Boolean,
  2043. controls: String,
  2044. scrollable: Boolean,
  2045. activeColor: String,
  2046. inactiveColor: String,
  2047. showZeroBadge: truthProp
  2048. },
  2049. setup(props, {
  2050. slots
  2051. }) {
  2052. const style = vue.computed(() => {
  2053. const style2 = {};
  2054. const {
  2055. type,
  2056. color,
  2057. disabled,
  2058. isActive,
  2059. activeColor,
  2060. inactiveColor
  2061. } = props;
  2062. const isCard = type === "card";
  2063. if (color && isCard) {
  2064. style2.borderColor = color;
  2065. if (!disabled) {
  2066. if (isActive) {
  2067. style2.backgroundColor = color;
  2068. } else {
  2069. style2.color = color;
  2070. }
  2071. }
  2072. }
  2073. const titleColor = isActive ? activeColor : inactiveColor;
  2074. if (titleColor) {
  2075. style2.color = titleColor;
  2076. }
  2077. return style2;
  2078. });
  2079. const renderText = () => {
  2080. const Text2 = vue.createVNode("span", {
  2081. "class": bem$1i("text", {
  2082. ellipsis: !props.scrollable
  2083. })
  2084. }, [slots.title ? slots.title() : props.title]);
  2085. if (props.dot || isDef(props.badge) && props.badge !== "") {
  2086. return vue.createVNode(Badge, {
  2087. "dot": props.dot,
  2088. "content": props.badge,
  2089. "showZero": props.showZeroBadge
  2090. }, {
  2091. default: () => [Text2]
  2092. });
  2093. }
  2094. return Text2;
  2095. };
  2096. return () => vue.createVNode("div", {
  2097. "id": props.id,
  2098. "role": "tab",
  2099. "class": [bem$1i([props.type, {
  2100. grow: props.scrollable && !props.shrink,
  2101. shrink: props.shrink,
  2102. active: props.isActive,
  2103. disabled: props.disabled
  2104. }])],
  2105. "style": style.value,
  2106. "tabindex": props.disabled ? void 0 : props.isActive ? 0 : -1,
  2107. "aria-selected": props.isActive,
  2108. "aria-disabled": props.disabled || void 0,
  2109. "aria-controls": props.controls
  2110. }, [renderText()]);
  2111. }
  2112. });
  2113. const [name$1l, bem$1h] = createNamespace("swipe");
  2114. const swipeProps = {
  2115. loop: truthProp,
  2116. width: numericProp,
  2117. height: numericProp,
  2118. vertical: Boolean,
  2119. autoplay: makeNumericProp(0),
  2120. duration: makeNumericProp(500),
  2121. touchable: truthProp,
  2122. lazyRender: Boolean,
  2123. initialSwipe: makeNumericProp(0),
  2124. indicatorColor: String,
  2125. showIndicators: truthProp,
  2126. stopPropagation: truthProp
  2127. };
  2128. const SWIPE_KEY = Symbol(name$1l);
  2129. var stdin_default$1t = vue.defineComponent({
  2130. name: name$1l,
  2131. props: swipeProps,
  2132. emits: ["change"],
  2133. setup(props, {
  2134. emit,
  2135. slots
  2136. }) {
  2137. const root = vue.ref();
  2138. const track = vue.ref();
  2139. const state = vue.reactive({
  2140. rect: null,
  2141. width: 0,
  2142. height: 0,
  2143. offset: 0,
  2144. active: 0,
  2145. swiping: false
  2146. });
  2147. const touch = useTouch();
  2148. const {
  2149. children,
  2150. linkChildren
  2151. } = use.useChildren(SWIPE_KEY);
  2152. const count = vue.computed(() => children.length);
  2153. const size = vue.computed(() => state[props.vertical ? "height" : "width"]);
  2154. const delta = vue.computed(() => props.vertical ? touch.deltaY.value : touch.deltaX.value);
  2155. const minOffset = vue.computed(() => {
  2156. if (state.rect) {
  2157. const base = props.vertical ? state.rect.height : state.rect.width;
  2158. return base - size.value * count.value;
  2159. }
  2160. return 0;
  2161. });
  2162. const maxCount = vue.computed(() => size.value ? Math.ceil(Math.abs(minOffset.value) / size.value) : count.value);
  2163. const trackSize = vue.computed(() => count.value * size.value);
  2164. const activeIndicator = vue.computed(() => (state.active + count.value) % count.value);
  2165. const isCorrectDirection = vue.computed(() => {
  2166. const expect = props.vertical ? "vertical" : "horizontal";
  2167. return touch.direction.value === expect;
  2168. });
  2169. const trackStyle = vue.computed(() => {
  2170. const style = {
  2171. transitionDuration: `${state.swiping ? 0 : props.duration}ms`,
  2172. transform: `translate${props.vertical ? "Y" : "X"}(${state.offset}px)`
  2173. };
  2174. if (size.value) {
  2175. const mainAxis = props.vertical ? "height" : "width";
  2176. const crossAxis = props.vertical ? "width" : "height";
  2177. style[mainAxis] = `${trackSize.value}px`;
  2178. style[crossAxis] = props[crossAxis] ? `${props[crossAxis]}px` : "";
  2179. }
  2180. return style;
  2181. });
  2182. const getTargetActive = (pace) => {
  2183. const {
  2184. active
  2185. } = state;
  2186. if (pace) {
  2187. if (props.loop) {
  2188. return clamp(active + pace, -1, count.value);
  2189. }
  2190. return clamp(active + pace, 0, maxCount.value);
  2191. }
  2192. return active;
  2193. };
  2194. const getTargetOffset = (targetActive, offset = 0) => {
  2195. let currentPosition = targetActive * size.value;
  2196. if (!props.loop) {
  2197. currentPosition = Math.min(currentPosition, -minOffset.value);
  2198. }
  2199. let targetOffset = offset - currentPosition;
  2200. if (!props.loop) {
  2201. targetOffset = clamp(targetOffset, minOffset.value, 0);
  2202. }
  2203. return targetOffset;
  2204. };
  2205. const move = ({
  2206. pace = 0,
  2207. offset = 0,
  2208. emitChange
  2209. }) => {
  2210. if (count.value <= 1) {
  2211. return;
  2212. }
  2213. const {
  2214. active
  2215. } = state;
  2216. const targetActive = getTargetActive(pace);
  2217. const targetOffset = getTargetOffset(targetActive, offset);
  2218. if (props.loop) {
  2219. if (children[0] && targetOffset !== minOffset.value) {
  2220. const outRightBound = targetOffset < minOffset.value;
  2221. children[0].setOffset(outRightBound ? trackSize.value : 0);
  2222. }
  2223. if (children[count.value - 1] && targetOffset !== 0) {
  2224. const outLeftBound = targetOffset > 0;
  2225. children[count.value - 1].setOffset(outLeftBound ? -trackSize.value : 0);
  2226. }
  2227. }
  2228. state.active = targetActive;
  2229. state.offset = targetOffset;
  2230. if (emitChange && targetActive !== active) {
  2231. emit("change", activeIndicator.value);
  2232. }
  2233. };
  2234. const correctPosition = () => {
  2235. state.swiping = true;
  2236. if (state.active <= -1) {
  2237. move({
  2238. pace: count.value
  2239. });
  2240. } else if (state.active >= count.value) {
  2241. move({
  2242. pace: -count.value
  2243. });
  2244. }
  2245. };
  2246. const prev = () => {
  2247. correctPosition();
  2248. touch.reset();
  2249. use.doubleRaf(() => {
  2250. state.swiping = false;
  2251. move({
  2252. pace: -1,
  2253. emitChange: true
  2254. });
  2255. });
  2256. };
  2257. const next = () => {
  2258. correctPosition();
  2259. touch.reset();
  2260. use.doubleRaf(() => {
  2261. state.swiping = false;
  2262. move({
  2263. pace: 1,
  2264. emitChange: true
  2265. });
  2266. });
  2267. };
  2268. let autoplayTimer;
  2269. const stopAutoplay = () => clearTimeout(autoplayTimer);
  2270. const autoplay = () => {
  2271. stopAutoplay();
  2272. if (props.autoplay > 0 && count.value > 1) {
  2273. autoplayTimer = setTimeout(() => {
  2274. next();
  2275. autoplay();
  2276. }, +props.autoplay);
  2277. }
  2278. };
  2279. const initialize = (active = +props.initialSwipe) => {
  2280. if (!root.value) {
  2281. return;
  2282. }
  2283. const cb = () => {
  2284. var _a, _b;
  2285. if (!isHidden(root)) {
  2286. const rect = {
  2287. width: root.value.offsetWidth,
  2288. height: root.value.offsetHeight
  2289. };
  2290. state.rect = rect;
  2291. state.width = +((_a = props.width) != null ? _a : rect.width);
  2292. state.height = +((_b = props.height) != null ? _b : rect.height);
  2293. }
  2294. if (count.value) {
  2295. active = Math.min(count.value - 1, active);
  2296. }
  2297. state.active = active;
  2298. state.swiping = true;
  2299. state.offset = getTargetOffset(active);
  2300. children.forEach((swipe) => {
  2301. swipe.setOffset(0);
  2302. });
  2303. autoplay();
  2304. };
  2305. if (isHidden(root)) {
  2306. vue.nextTick().then(cb);
  2307. } else {
  2308. cb();
  2309. }
  2310. };
  2311. const resize = () => initialize(state.active);
  2312. let touchStartTime;
  2313. const onTouchStart = (event) => {
  2314. if (!props.touchable)
  2315. return;
  2316. touch.start(event);
  2317. touchStartTime = Date.now();
  2318. stopAutoplay();
  2319. correctPosition();
  2320. };
  2321. const onTouchMove = (event) => {
  2322. if (props.touchable && state.swiping) {
  2323. touch.move(event);
  2324. if (isCorrectDirection.value) {
  2325. const isEdgeTouch = !props.loop && (state.active === 0 && delta.value > 0 || state.active === count.value - 1 && delta.value < 0);
  2326. if (!isEdgeTouch) {
  2327. preventDefault(event, props.stopPropagation);
  2328. move({
  2329. offset: delta.value
  2330. });
  2331. }
  2332. }
  2333. }
  2334. };
  2335. const onTouchEnd = () => {
  2336. if (!props.touchable || !state.swiping) {
  2337. return;
  2338. }
  2339. const duration = Date.now() - touchStartTime;
  2340. const speed = delta.value / duration;
  2341. const shouldSwipe = Math.abs(speed) > 0.25 || Math.abs(delta.value) > size.value / 2;
  2342. if (shouldSwipe && isCorrectDirection.value) {
  2343. const offset = props.vertical ? touch.offsetY.value : touch.offsetX.value;
  2344. let pace = 0;
  2345. if (props.loop) {
  2346. pace = offset > 0 ? delta.value > 0 ? -1 : 1 : 0;
  2347. } else {
  2348. pace = -Math[delta.value > 0 ? "ceil" : "floor"](delta.value / size.value);
  2349. }
  2350. move({
  2351. pace,
  2352. emitChange: true
  2353. });
  2354. } else if (delta.value) {
  2355. move({
  2356. pace: 0
  2357. });
  2358. }
  2359. state.swiping = false;
  2360. autoplay();
  2361. };
  2362. const swipeTo = (index, options = {}) => {
  2363. correctPosition();
  2364. touch.reset();
  2365. use.doubleRaf(() => {
  2366. let targetIndex;
  2367. if (props.loop && index === count.value) {
  2368. targetIndex = state.active === 0 ? 0 : index;
  2369. } else {
  2370. targetIndex = index % count.value;
  2371. }
  2372. if (options.immediate) {
  2373. use.doubleRaf(() => {
  2374. state.swiping = false;
  2375. });
  2376. } else {
  2377. state.swiping = false;
  2378. }
  2379. move({
  2380. pace: targetIndex - state.active,
  2381. emitChange: true
  2382. });
  2383. });
  2384. };
  2385. const renderDot = (_, index) => {
  2386. const active = index === activeIndicator.value;
  2387. const style = active ? {
  2388. backgroundColor: props.indicatorColor
  2389. } : void 0;
  2390. return vue.createVNode("i", {
  2391. "style": style,
  2392. "class": bem$1h("indicator", {
  2393. active
  2394. })
  2395. }, null);
  2396. };
  2397. const renderIndicator = () => {
  2398. if (slots.indicator) {
  2399. return slots.indicator({
  2400. active: activeIndicator.value,
  2401. total: count.value
  2402. });
  2403. }
  2404. if (props.showIndicators && count.value > 1) {
  2405. return vue.createVNode("div", {
  2406. "class": bem$1h("indicators", {
  2407. vertical: props.vertical
  2408. })
  2409. }, [Array(count.value).fill("").map(renderDot)]);
  2410. }
  2411. };
  2412. useExpose({
  2413. prev,
  2414. next,
  2415. state,
  2416. resize,
  2417. swipeTo
  2418. });
  2419. linkChildren({
  2420. size,
  2421. props,
  2422. count,
  2423. activeIndicator
  2424. });
  2425. vue.watch(() => props.initialSwipe, (value) => initialize(+value));
  2426. vue.watch(count, () => initialize(state.active));
  2427. vue.watch(() => props.autoplay, autoplay);
  2428. vue.watch([windowWidth, windowHeight], resize);
  2429. vue.watch(use.usePageVisibility(), (visible) => {
  2430. if (visible === "visible") {
  2431. autoplay();
  2432. } else {
  2433. stopAutoplay();
  2434. }
  2435. });
  2436. vue.onMounted(initialize);
  2437. vue.onActivated(() => initialize(state.active));
  2438. onPopupReopen(() => initialize(state.active));
  2439. vue.onDeactivated(stopAutoplay);
  2440. vue.onBeforeUnmount(stopAutoplay);
  2441. use.useEventListener("touchmove", onTouchMove, {
  2442. target: track
  2443. });
  2444. return () => {
  2445. var _a;
  2446. return vue.createVNode("div", {
  2447. "ref": root,
  2448. "class": bem$1h()
  2449. }, [vue.createVNode("div", {
  2450. "ref": track,
  2451. "style": trackStyle.value,
  2452. "class": bem$1h("track", {
  2453. vertical: props.vertical
  2454. }),
  2455. "onTouchstartPassive": onTouchStart,
  2456. "onTouchend": onTouchEnd,
  2457. "onTouchcancel": onTouchEnd
  2458. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]), renderIndicator()]);
  2459. };
  2460. }
  2461. });
  2462. const Swipe = withInstall(stdin_default$1t);
  2463. const [name$1k, bem$1g] = createNamespace("tabs");
  2464. var stdin_default$1s = vue.defineComponent({
  2465. name: name$1k,
  2466. props: {
  2467. count: makeRequiredProp(Number),
  2468. inited: Boolean,
  2469. animated: Boolean,
  2470. duration: makeRequiredProp(numericProp),
  2471. swipeable: Boolean,
  2472. lazyRender: Boolean,
  2473. currentIndex: makeRequiredProp(Number)
  2474. },
  2475. emits: ["change"],
  2476. setup(props, {
  2477. emit,
  2478. slots
  2479. }) {
  2480. const swipeRef = vue.ref();
  2481. const onChange = (index) => emit("change", index);
  2482. const renderChildren = () => {
  2483. var _a;
  2484. const Content = (_a = slots.default) == null ? void 0 : _a.call(slots);
  2485. if (props.animated || props.swipeable) {
  2486. return vue.createVNode(Swipe, {
  2487. "ref": swipeRef,
  2488. "loop": false,
  2489. "class": bem$1g("track"),
  2490. "duration": +props.duration * 1e3,
  2491. "touchable": props.swipeable,
  2492. "lazyRender": props.lazyRender,
  2493. "showIndicators": false,
  2494. "onChange": onChange
  2495. }, {
  2496. default: () => [Content]
  2497. });
  2498. }
  2499. return Content;
  2500. };
  2501. const swipeToCurrentTab = (index) => {
  2502. const swipe = swipeRef.value;
  2503. if (swipe && swipe.state.active !== index) {
  2504. swipe.swipeTo(index, {
  2505. immediate: !props.inited
  2506. });
  2507. }
  2508. };
  2509. vue.watch(() => props.currentIndex, swipeToCurrentTab);
  2510. vue.onMounted(() => {
  2511. swipeToCurrentTab(props.currentIndex);
  2512. });
  2513. useExpose({
  2514. swipeRef
  2515. });
  2516. return () => vue.createVNode("div", {
  2517. "class": bem$1g("content", {
  2518. animated: props.animated || props.swipeable
  2519. })
  2520. }, [renderChildren()]);
  2521. }
  2522. });
  2523. const [name$1j, bem$1f] = createNamespace("tabs");
  2524. const tabsProps = {
  2525. type: makeStringProp("line"),
  2526. color: String,
  2527. border: Boolean,
  2528. sticky: Boolean,
  2529. shrink: Boolean,
  2530. active: makeNumericProp(0),
  2531. duration: makeNumericProp(0.3),
  2532. animated: Boolean,
  2533. ellipsis: truthProp,
  2534. swipeable: Boolean,
  2535. scrollspy: Boolean,
  2536. offsetTop: makeNumericProp(0),
  2537. background: String,
  2538. lazyRender: truthProp,
  2539. lineWidth: numericProp,
  2540. lineHeight: numericProp,
  2541. beforeChange: Function,
  2542. swipeThreshold: makeNumericProp(5),
  2543. titleActiveColor: String,
  2544. titleInactiveColor: String
  2545. };
  2546. const TABS_KEY = Symbol(name$1j);
  2547. var stdin_default$1r = vue.defineComponent({
  2548. name: name$1j,
  2549. props: tabsProps,
  2550. emits: ["change", "scroll", "rendered", "clickTab", "update:active"],
  2551. setup(props, {
  2552. emit,
  2553. slots
  2554. }) {
  2555. let tabHeight;
  2556. let lockScroll;
  2557. let stickyFixed;
  2558. const root = vue.ref();
  2559. const navRef = vue.ref();
  2560. const wrapRef = vue.ref();
  2561. const contentRef = vue.ref();
  2562. const id = useId();
  2563. const scroller = use.useScrollParent(root);
  2564. const [titleRefs, setTitleRefs] = useRefs();
  2565. const {
  2566. children,
  2567. linkChildren
  2568. } = use.useChildren(TABS_KEY);
  2569. const state = vue.reactive({
  2570. inited: false,
  2571. position: "",
  2572. lineStyle: {},
  2573. currentIndex: -1
  2574. });
  2575. const scrollable = vue.computed(() => children.length > props.swipeThreshold || !props.ellipsis || props.shrink);
  2576. const navStyle = vue.computed(() => ({
  2577. borderColor: props.color,
  2578. background: props.background
  2579. }));
  2580. const getTabName = (tab, index) => {
  2581. var _a;
  2582. return (_a = tab.name) != null ? _a : index;
  2583. };
  2584. const currentName = vue.computed(() => {
  2585. const activeTab = children[state.currentIndex];
  2586. if (activeTab) {
  2587. return getTabName(activeTab, state.currentIndex);
  2588. }
  2589. });
  2590. const offsetTopPx = vue.computed(() => unitToPx(props.offsetTop));
  2591. const scrollOffset = vue.computed(() => {
  2592. if (props.sticky) {
  2593. return offsetTopPx.value + tabHeight;
  2594. }
  2595. return 0;
  2596. });
  2597. const scrollIntoView = (immediate) => {
  2598. const nav = navRef.value;
  2599. const titles = titleRefs.value;
  2600. if (!scrollable.value || !nav || !titles || !titles[state.currentIndex]) {
  2601. return;
  2602. }
  2603. const title = titles[state.currentIndex].$el;
  2604. const to = title.offsetLeft - (nav.offsetWidth - title.offsetWidth) / 2;
  2605. scrollLeftTo(nav, to, immediate ? 0 : +props.duration);
  2606. };
  2607. const setLine = () => {
  2608. const shouldAnimate = state.inited;
  2609. vue.nextTick(() => {
  2610. const titles = titleRefs.value;
  2611. if (!titles || !titles[state.currentIndex] || props.type !== "line" || isHidden(root.value)) {
  2612. return;
  2613. }
  2614. const title = titles[state.currentIndex].$el;
  2615. const {
  2616. lineWidth,
  2617. lineHeight
  2618. } = props;
  2619. const left = title.offsetLeft + title.offsetWidth / 2;
  2620. const lineStyle = {
  2621. width: addUnit(lineWidth),
  2622. backgroundColor: props.color,
  2623. transform: `translateX(${left}px) translateX(-50%)`
  2624. };
  2625. if (shouldAnimate) {
  2626. lineStyle.transitionDuration = `${props.duration}s`;
  2627. }
  2628. if (isDef(lineHeight)) {
  2629. const height = addUnit(lineHeight);
  2630. lineStyle.height = height;
  2631. lineStyle.borderRadius = height;
  2632. }
  2633. state.lineStyle = lineStyle;
  2634. });
  2635. };
  2636. const findAvailableTab = (index) => {
  2637. const diff = index < state.currentIndex ? -1 : 1;
  2638. while (index >= 0 && index < children.length) {
  2639. if (!children[index].disabled) {
  2640. return index;
  2641. }
  2642. index += diff;
  2643. }
  2644. };
  2645. const setCurrentIndex = (currentIndex, skipScrollIntoView) => {
  2646. const newIndex = findAvailableTab(currentIndex);
  2647. if (!isDef(newIndex)) {
  2648. return;
  2649. }
  2650. const newTab = children[newIndex];
  2651. const newName = getTabName(newTab, newIndex);
  2652. const shouldEmitChange = state.currentIndex !== null;
  2653. if (state.currentIndex !== newIndex) {
  2654. state.currentIndex = newIndex;
  2655. if (!skipScrollIntoView) {
  2656. scrollIntoView();
  2657. }
  2658. setLine();
  2659. }
  2660. if (newName !== props.active) {
  2661. emit("update:active", newName);
  2662. if (shouldEmitChange) {
  2663. emit("change", newName, newTab.title);
  2664. }
  2665. }
  2666. if (stickyFixed && !props.scrollspy) {
  2667. setRootScrollTop(Math.ceil(getElementTop(root.value) - offsetTopPx.value));
  2668. }
  2669. };
  2670. const setCurrentIndexByName = (name2, skipScrollIntoView) => {
  2671. const matched = children.find((tab, index2) => getTabName(tab, index2) === name2);
  2672. const index = matched ? children.indexOf(matched) : 0;
  2673. setCurrentIndex(index, skipScrollIntoView);
  2674. };
  2675. const scrollToCurrentContent = (immediate = false) => {
  2676. if (props.scrollspy) {
  2677. const target = children[state.currentIndex].$el;
  2678. if (target && scroller.value) {
  2679. const to = getElementTop(target, scroller.value) - scrollOffset.value;
  2680. lockScroll = true;
  2681. scrollTopTo(scroller.value, to, immediate ? 0 : +props.duration, () => {
  2682. lockScroll = false;
  2683. });
  2684. }
  2685. }
  2686. };
  2687. const onClickTab = (item, index, event) => {
  2688. const {
  2689. title,
  2690. disabled
  2691. } = children[index];
  2692. const name2 = getTabName(children[index], index);
  2693. if (!disabled) {
  2694. callInterceptor(props.beforeChange, {
  2695. args: [name2],
  2696. done: () => {
  2697. setCurrentIndex(index);
  2698. scrollToCurrentContent();
  2699. }
  2700. });
  2701. route(item);
  2702. }
  2703. emit("clickTab", {
  2704. name: name2,
  2705. title,
  2706. event,
  2707. disabled
  2708. });
  2709. };
  2710. const onStickyScroll = (params) => {
  2711. stickyFixed = params.isFixed;
  2712. emit("scroll", params);
  2713. };
  2714. const scrollTo = (name2) => {
  2715. vue.nextTick(() => {
  2716. setCurrentIndexByName(name2);
  2717. scrollToCurrentContent(true);
  2718. });
  2719. };
  2720. const getCurrentIndexOnScroll = () => {
  2721. for (let index = 0; index < children.length; index++) {
  2722. const {
  2723. top
  2724. } = use.useRect(children[index].$el);
  2725. if (top > scrollOffset.value) {
  2726. return index === 0 ? 0 : index - 1;
  2727. }
  2728. }
  2729. return children.length - 1;
  2730. };
  2731. const onScroll = () => {
  2732. if (props.scrollspy && !lockScroll) {
  2733. const index = getCurrentIndexOnScroll();
  2734. setCurrentIndex(index);
  2735. }
  2736. };
  2737. const renderNav = () => children.map((item, index) => vue.createVNode(stdin_default$1u, vue.mergeProps({
  2738. "key": item.id,
  2739. "id": `${id}-${index}`,
  2740. "ref": setTitleRefs(index),
  2741. "type": props.type,
  2742. "color": props.color,
  2743. "style": item.titleStyle,
  2744. "class": item.titleClass,
  2745. "shrink": props.shrink,
  2746. "isActive": index === state.currentIndex,
  2747. "controls": item.id,
  2748. "scrollable": scrollable.value,
  2749. "activeColor": props.titleActiveColor,
  2750. "inactiveColor": props.titleInactiveColor,
  2751. "onClick": (event) => onClickTab(item, index, event)
  2752. }, pick(item, ["dot", "badge", "title", "disabled", "showZeroBadge"])), {
  2753. title: item.$slots.title
  2754. }));
  2755. const renderLine = () => {
  2756. if (props.type === "line" && children.length) {
  2757. return vue.createVNode("div", {
  2758. "class": bem$1f("line"),
  2759. "style": state.lineStyle
  2760. }, null);
  2761. }
  2762. };
  2763. const renderHeader = () => {
  2764. var _a, _b, _c;
  2765. const {
  2766. type,
  2767. border,
  2768. sticky
  2769. } = props;
  2770. const Header = [vue.createVNode("div", {
  2771. "ref": sticky ? void 0 : wrapRef,
  2772. "class": [bem$1f("wrap"), {
  2773. [BORDER_TOP_BOTTOM]: type === "line" && border
  2774. }]
  2775. }, [vue.createVNode("div", {
  2776. "ref": navRef,
  2777. "role": "tablist",
  2778. "class": bem$1f("nav", [type, {
  2779. shrink: props.shrink,
  2780. complete: scrollable.value
  2781. }]),
  2782. "style": navStyle.value,
  2783. "aria-orientation": "horizontal"
  2784. }, [(_a = slots["nav-left"]) == null ? void 0 : _a.call(slots), renderNav(), renderLine(), (_b = slots["nav-right"]) == null ? void 0 : _b.call(slots)])]), (_c = slots["nav-bottom"]) == null ? void 0 : _c.call(slots)];
  2785. if (sticky) {
  2786. return vue.createVNode("div", {
  2787. "ref": wrapRef
  2788. }, [Header]);
  2789. }
  2790. return Header;
  2791. };
  2792. vue.watch([() => props.color, windowWidth], setLine);
  2793. vue.watch(() => props.active, (value) => {
  2794. if (value !== currentName.value) {
  2795. setCurrentIndexByName(value);
  2796. }
  2797. });
  2798. vue.watch(() => children.length, () => {
  2799. if (state.inited) {
  2800. setCurrentIndexByName(props.active);
  2801. setLine();
  2802. vue.nextTick(() => {
  2803. scrollIntoView(true);
  2804. });
  2805. }
  2806. });
  2807. const init = () => {
  2808. setCurrentIndexByName(props.active, true);
  2809. vue.nextTick(() => {
  2810. state.inited = true;
  2811. if (wrapRef.value) {
  2812. tabHeight = use.useRect(wrapRef.value).height;
  2813. }
  2814. scrollIntoView(true);
  2815. });
  2816. };
  2817. const onRendered = (name2, title) => emit("rendered", name2, title);
  2818. const resize = () => {
  2819. setLine();
  2820. vue.nextTick(() => {
  2821. var _a, _b;
  2822. return (_b = (_a = contentRef.value) == null ? void 0 : _a.swipeRef.value) == null ? void 0 : _b.resize();
  2823. });
  2824. };
  2825. useExpose({
  2826. resize,
  2827. scrollTo
  2828. });
  2829. vue.onActivated(setLine);
  2830. onPopupReopen(setLine);
  2831. use.onMountedOrActivated(init);
  2832. use.useEventListener("scroll", onScroll, {
  2833. target: scroller,
  2834. passive: true
  2835. });
  2836. linkChildren({
  2837. id,
  2838. props,
  2839. setLine,
  2840. onRendered,
  2841. currentName,
  2842. scrollIntoView
  2843. });
  2844. return () => vue.createVNode("div", {
  2845. "ref": root,
  2846. "class": bem$1f([props.type])
  2847. }, [props.sticky ? vue.createVNode(Sticky, {
  2848. "container": root.value,
  2849. "offsetTop": offsetTopPx.value,
  2850. "onScroll": onStickyScroll
  2851. }, {
  2852. default: () => [renderHeader()]
  2853. }) : renderHeader(), vue.createVNode(stdin_default$1s, {
  2854. "ref": contentRef,
  2855. "count": children.length,
  2856. "inited": state.inited,
  2857. "animated": props.animated,
  2858. "duration": props.duration,
  2859. "swipeable": props.swipeable,
  2860. "lazyRender": props.lazyRender,
  2861. "currentIndex": state.currentIndex,
  2862. "onChange": setCurrentIndex
  2863. }, {
  2864. default: () => {
  2865. var _a;
  2866. return [(_a = slots.default) == null ? void 0 : _a.call(slots)];
  2867. }
  2868. })]);
  2869. }
  2870. });
  2871. const TAB_STATUS_KEY = Symbol();
  2872. const useTabStatus = () => vue.inject(TAB_STATUS_KEY, null);
  2873. const [name$1i, bem$1e] = createNamespace("swipe-item");
  2874. var stdin_default$1q = vue.defineComponent({
  2875. name: name$1i,
  2876. setup(props, {
  2877. slots
  2878. }) {
  2879. let rendered;
  2880. const state = vue.reactive({
  2881. offset: 0,
  2882. inited: false,
  2883. mounted: false
  2884. });
  2885. const {
  2886. parent,
  2887. index
  2888. } = use.useParent(SWIPE_KEY);
  2889. if (!parent) {
  2890. if (process.env.NODE_ENV !== "production") {
  2891. console.error("[Vant] <SwipeItem> must be a child component of <Swipe>.");
  2892. }
  2893. return;
  2894. }
  2895. const style = vue.computed(() => {
  2896. const style2 = {};
  2897. const {
  2898. vertical
  2899. } = parent.props;
  2900. if (parent.size.value) {
  2901. style2[vertical ? "height" : "width"] = `${parent.size.value}px`;
  2902. }
  2903. if (state.offset) {
  2904. style2.transform = `translate${vertical ? "Y" : "X"}(${state.offset}px)`;
  2905. }
  2906. return style2;
  2907. });
  2908. const shouldRender = vue.computed(() => {
  2909. const {
  2910. loop,
  2911. lazyRender
  2912. } = parent.props;
  2913. if (!lazyRender || rendered) {
  2914. return true;
  2915. }
  2916. if (!state.mounted) {
  2917. return false;
  2918. }
  2919. const active = parent.activeIndicator.value;
  2920. const maxActive = parent.count.value - 1;
  2921. const prevActive = active === 0 && loop ? maxActive : active - 1;
  2922. const nextActive = active === maxActive && loop ? 0 : active + 1;
  2923. rendered = index.value === active || index.value === prevActive || index.value === nextActive;
  2924. return rendered;
  2925. });
  2926. const setOffset = (offset) => {
  2927. state.offset = offset;
  2928. };
  2929. vue.onMounted(() => {
  2930. vue.nextTick(() => {
  2931. state.mounted = true;
  2932. });
  2933. });
  2934. useExpose({
  2935. setOffset
  2936. });
  2937. return () => {
  2938. var _a;
  2939. return vue.createVNode("div", {
  2940. "class": bem$1e(),
  2941. "style": style.value
  2942. }, [shouldRender.value ? (_a = slots.default) == null ? void 0 : _a.call(slots) : null]);
  2943. };
  2944. }
  2945. });
  2946. const SwipeItem = withInstall(stdin_default$1q);
  2947. const [name$1h, bem$1d] = createNamespace("tab");
  2948. const tabProps = extend({}, routeProps, {
  2949. dot: Boolean,
  2950. name: numericProp,
  2951. badge: numericProp,
  2952. title: String,
  2953. disabled: Boolean,
  2954. titleClass: unknownProp,
  2955. titleStyle: [String, Object],
  2956. showZeroBadge: truthProp
  2957. });
  2958. var stdin_default$1p = vue.defineComponent({
  2959. name: name$1h,
  2960. props: tabProps,
  2961. setup(props, {
  2962. slots
  2963. }) {
  2964. const id = useId();
  2965. const inited = vue.ref(false);
  2966. const {
  2967. parent,
  2968. index
  2969. } = use.useParent(TABS_KEY);
  2970. if (!parent) {
  2971. if (process.env.NODE_ENV !== "production") {
  2972. console.error("[Vant] <Tab> must be a child component of <Tabs>.");
  2973. }
  2974. return;
  2975. }
  2976. const getName = () => {
  2977. var _a;
  2978. return (_a = props.name) != null ? _a : index.value;
  2979. };
  2980. const init = () => {
  2981. inited.value = true;
  2982. if (parent.props.lazyRender) {
  2983. vue.nextTick(() => {
  2984. parent.onRendered(getName(), props.title);
  2985. });
  2986. }
  2987. };
  2988. const active = vue.computed(() => {
  2989. const isActive = getName() === parent.currentName.value;
  2990. if (isActive && !inited.value) {
  2991. init();
  2992. }
  2993. return isActive;
  2994. });
  2995. const hasInactiveClass = vue.ref(!active.value);
  2996. vue.watch(active, (val) => {
  2997. if (val) {
  2998. hasInactiveClass.value = false;
  2999. } else {
  3000. use.doubleRaf(() => {
  3001. hasInactiveClass.value = true;
  3002. });
  3003. }
  3004. });
  3005. vue.watch(() => props.title, () => {
  3006. parent.setLine();
  3007. parent.scrollIntoView();
  3008. });
  3009. vue.provide(TAB_STATUS_KEY, active);
  3010. return () => {
  3011. var _a;
  3012. const label = `${parent.id}-${index.value}`;
  3013. const {
  3014. animated,
  3015. swipeable,
  3016. scrollspy,
  3017. lazyRender
  3018. } = parent.props;
  3019. if (!slots.default && !animated) {
  3020. return;
  3021. }
  3022. const show = scrollspy || active.value;
  3023. if (animated || swipeable) {
  3024. return vue.createVNode(SwipeItem, {
  3025. "id": id,
  3026. "role": "tabpanel",
  3027. "class": bem$1d("panel-wrapper", {
  3028. inactive: hasInactiveClass.value
  3029. }),
  3030. "tabindex": active.value ? 0 : -1,
  3031. "aria-hidden": !active.value,
  3032. "aria-labelledby": label
  3033. }, {
  3034. default: () => {
  3035. var _a2;
  3036. return [vue.createVNode("div", {
  3037. "class": bem$1d("panel")
  3038. }, [(_a2 = slots.default) == null ? void 0 : _a2.call(slots)])];
  3039. }
  3040. });
  3041. }
  3042. const shouldRender = inited.value || scrollspy || !lazyRender;
  3043. const Content = shouldRender ? (_a = slots.default) == null ? void 0 : _a.call(slots) : null;
  3044. useExpose({
  3045. id
  3046. });
  3047. return vue.withDirectives(vue.createVNode("div", {
  3048. "id": id,
  3049. "role": "tabpanel",
  3050. "class": bem$1d("panel"),
  3051. "tabindex": show ? 0 : -1,
  3052. "aria-labelledby": label
  3053. }, [Content]), [[vue.vShow, show]]);
  3054. };
  3055. }
  3056. });
  3057. const Tab = withInstall(stdin_default$1p);
  3058. const Tabs = withInstall(stdin_default$1r);
  3059. const [name$1g, bem$1c] = createNamespace("picker-group");
  3060. const PICKER_GROUP_KEY = Symbol(name$1g);
  3061. const pickerGroupProps = extend({
  3062. tabs: makeArrayProp()
  3063. }, pickerToolbarProps);
  3064. var stdin_default$1o = vue.defineComponent({
  3065. name: name$1g,
  3066. props: pickerGroupProps,
  3067. emits: ["confirm", "cancel"],
  3068. setup(props, {
  3069. emit,
  3070. slots
  3071. }) {
  3072. const {
  3073. children,
  3074. linkChildren
  3075. } = use.useChildren(PICKER_GROUP_KEY);
  3076. linkChildren();
  3077. const onConfirm = () => {
  3078. emit("confirm", children.map((item) => item.confirm()));
  3079. };
  3080. const onCancel = () => emit("cancel");
  3081. return () => {
  3082. var _a;
  3083. const childNodes = (_a = slots.default) == null ? void 0 : _a.call(slots);
  3084. return vue.createVNode("div", {
  3085. "class": bem$1c()
  3086. }, [vue.createVNode(stdin_default$1w, vue.mergeProps(props, {
  3087. "onConfirm": onConfirm,
  3088. "onCancel": onCancel
  3089. }), null), vue.createVNode(Tabs, {
  3090. "shrink": true,
  3091. "class": bem$1c("tabs"),
  3092. "animated": true
  3093. }, {
  3094. default: () => [props.tabs.map((title, index) => vue.createVNode(Tab, {
  3095. "title": title,
  3096. "titleClass": bem$1c("tab-title")
  3097. }, {
  3098. default: () => [childNodes == null ? void 0 : childNodes[index]]
  3099. }))]
  3100. })]);
  3101. };
  3102. }
  3103. });
  3104. const pickerSharedProps = extend({
  3105. loading: Boolean,
  3106. readonly: Boolean,
  3107. allowHtml: Boolean,
  3108. optionHeight: makeNumericProp(44),
  3109. showToolbar: truthProp,
  3110. swipeDuration: makeNumericProp(1e3),
  3111. visibleOptionNum: makeNumericProp(6)
  3112. }, pickerToolbarProps);
  3113. const pickerProps = extend({}, pickerSharedProps, {
  3114. columns: makeArrayProp(),
  3115. modelValue: makeArrayProp(),
  3116. toolbarPosition: makeStringProp("top"),
  3117. columnsFieldNames: Object
  3118. });
  3119. var stdin_default$1n = vue.defineComponent({
  3120. name: name$1q,
  3121. props: pickerProps,
  3122. emits: ["confirm", "cancel", "change", "clickOption", "update:modelValue"],
  3123. setup(props, {
  3124. emit,
  3125. slots
  3126. }) {
  3127. const columnsRef = vue.ref();
  3128. const selectedValues = vue.ref(props.modelValue.slice(0));
  3129. const {
  3130. parent
  3131. } = use.useParent(PICKER_GROUP_KEY);
  3132. const {
  3133. children,
  3134. linkChildren
  3135. } = use.useChildren(PICKER_KEY);
  3136. linkChildren();
  3137. const fields = vue.computed(() => assignDefaultFields(props.columnsFieldNames));
  3138. const optionHeight = vue.computed(() => unitToPx(props.optionHeight));
  3139. const columnsType = vue.computed(() => getColumnsType(props.columns, fields.value));
  3140. const currentColumns = vue.computed(() => {
  3141. const {
  3142. columns
  3143. } = props;
  3144. switch (columnsType.value) {
  3145. case "multiple":
  3146. return columns;
  3147. case "cascade":
  3148. return formatCascadeColumns(columns, fields.value, selectedValues);
  3149. default:
  3150. return [columns];
  3151. }
  3152. });
  3153. const hasOptions = vue.computed(() => currentColumns.value.some((options) => options.length));
  3154. const selectedOptions = vue.computed(() => currentColumns.value.map((options, index) => findOptionByValue(options, selectedValues.value[index], fields.value)));
  3155. const selectedIndexes = vue.computed(() => currentColumns.value.map((options, index) => options.findIndex((option) => option[fields.value.value] === selectedValues.value[index])));
  3156. const setValue = (index, value) => {
  3157. if (selectedValues.value[index] !== value) {
  3158. const newValues = selectedValues.value.slice(0);
  3159. newValues[index] = value;
  3160. selectedValues.value = newValues;
  3161. }
  3162. };
  3163. const getEventParams = () => ({
  3164. selectedValues: selectedValues.value.slice(0),
  3165. selectedOptions: selectedOptions.value,
  3166. selectedIndexes: selectedIndexes.value
  3167. });
  3168. const onChange = (value, columnIndex) => {
  3169. setValue(columnIndex, value);
  3170. if (columnsType.value === "cascade") {
  3171. selectedValues.value.forEach((value2, index) => {
  3172. const options = currentColumns.value[index];
  3173. if (!isOptionExist(options, value2, fields.value)) {
  3174. setValue(index, options.length ? options[0][fields.value.value] : void 0);
  3175. }
  3176. });
  3177. }
  3178. emit("change", extend({
  3179. columnIndex
  3180. }, getEventParams()));
  3181. };
  3182. const onClickOption = (currentOption, columnIndex) => emit("clickOption", extend({
  3183. columnIndex,
  3184. currentOption
  3185. }, getEventParams()));
  3186. const confirm = () => {
  3187. children.forEach((child) => child.stopMomentum());
  3188. const params = getEventParams();
  3189. vue.nextTick(() => {
  3190. emit("confirm", params);
  3191. });
  3192. return params;
  3193. };
  3194. const cancel = () => emit("cancel", getEventParams());
  3195. const renderColumnItems = () => currentColumns.value.map((options, columnIndex) => vue.createVNode(stdin_default$1x, {
  3196. "value": selectedValues.value[columnIndex],
  3197. "fields": fields.value,
  3198. "options": options,
  3199. "readonly": props.readonly,
  3200. "allowHtml": props.allowHtml,
  3201. "optionHeight": optionHeight.value,
  3202. "swipeDuration": props.swipeDuration,
  3203. "visibleOptionNum": props.visibleOptionNum,
  3204. "onChange": (value) => onChange(value, columnIndex),
  3205. "onClickOption": (option) => onClickOption(option, columnIndex)
  3206. }, {
  3207. option: slots.option
  3208. }));
  3209. const renderMask = (wrapHeight) => {
  3210. if (hasOptions.value) {
  3211. const frameStyle = {
  3212. height: `${optionHeight.value}px`
  3213. };
  3214. const maskStyle = {
  3215. backgroundSize: `100% ${(wrapHeight - optionHeight.value) / 2}px`
  3216. };
  3217. return [vue.createVNode("div", {
  3218. "class": bem$1l("mask"),
  3219. "style": maskStyle
  3220. }, null), vue.createVNode("div", {
  3221. "class": [BORDER_UNSET_TOP_BOTTOM, bem$1l("frame")],
  3222. "style": frameStyle
  3223. }, null)];
  3224. }
  3225. };
  3226. const renderColumns = () => {
  3227. const wrapHeight = optionHeight.value * +props.visibleOptionNum;
  3228. const columnsStyle = {
  3229. height: `${wrapHeight}px`
  3230. };
  3231. return vue.createVNode("div", {
  3232. "ref": columnsRef,
  3233. "class": bem$1l("columns"),
  3234. "style": columnsStyle
  3235. }, [renderColumnItems(), renderMask(wrapHeight)]);
  3236. };
  3237. const renderToolbar = () => {
  3238. if (props.showToolbar && !parent) {
  3239. return vue.createVNode(stdin_default$1w, vue.mergeProps(pick(props, pickerToolbarPropKeys), {
  3240. "onConfirm": confirm,
  3241. "onCancel": cancel
  3242. }), pick(slots, pickerToolbarSlots));
  3243. }
  3244. };
  3245. vue.watch(currentColumns, (columns) => {
  3246. columns.forEach((options, index) => {
  3247. if (options.length && !isOptionExist(options, selectedValues.value[index], fields.value)) {
  3248. setValue(index, getFirstEnabledOption(options)[fields.value.value]);
  3249. }
  3250. });
  3251. }, {
  3252. immediate: true
  3253. });
  3254. let lastEmittedModelValue;
  3255. vue.watch(() => props.modelValue, (newValues) => {
  3256. if (!isSameValue(newValues, selectedValues.value) && !isSameValue(newValues, lastEmittedModelValue)) {
  3257. selectedValues.value = newValues.slice(0);
  3258. }
  3259. }, {
  3260. deep: true
  3261. });
  3262. vue.watch(selectedValues, (newValues) => {
  3263. if (!isSameValue(newValues, props.modelValue)) {
  3264. lastEmittedModelValue = newValues.slice(0);
  3265. emit("update:modelValue", lastEmittedModelValue);
  3266. }
  3267. }, {
  3268. immediate: true
  3269. });
  3270. use.useEventListener("touchmove", preventDefault, {
  3271. target: columnsRef
  3272. });
  3273. const getSelectedOptions = () => selectedOptions.value;
  3274. useExpose({
  3275. confirm,
  3276. getSelectedOptions
  3277. });
  3278. return () => {
  3279. var _a, _b;
  3280. return vue.createVNode("div", {
  3281. "class": bem$1l()
  3282. }, [props.toolbarPosition === "top" ? renderToolbar() : null, props.loading ? vue.createVNode(Loading, {
  3283. "class": bem$1l("loading")
  3284. }, 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]);
  3285. };
  3286. }
  3287. });
  3288. const AREA_EMPTY_CODE = "000000";
  3289. const INHERIT_SLOTS = [
  3290. "title",
  3291. "cancel",
  3292. "confirm",
  3293. "toolbar",
  3294. "columns-top",
  3295. "columns-bottom"
  3296. ];
  3297. const INHERIT_PROPS = [
  3298. "title",
  3299. "loading",
  3300. "readonly",
  3301. "optionHeight",
  3302. "swipeDuration",
  3303. "visibleOptionNum",
  3304. "cancelButtonText",
  3305. "confirmButtonText"
  3306. ];
  3307. const makeOption = (text = "", value = AREA_EMPTY_CODE, children = void 0) => ({
  3308. text,
  3309. value,
  3310. children
  3311. });
  3312. function formatDataForCascade({
  3313. areaList,
  3314. columnsNum,
  3315. columnsPlaceholder: placeholder
  3316. }) {
  3317. const {
  3318. city_list: city = {},
  3319. county_list: county = {},
  3320. province_list: province = {}
  3321. } = areaList;
  3322. const showCity = columnsNum > 1;
  3323. const showCounty = columnsNum > 2;
  3324. const getProvinceChildren = () => {
  3325. if (showCity) {
  3326. return placeholder.length ? [
  3327. makeOption(
  3328. placeholder[0],
  3329. AREA_EMPTY_CODE,
  3330. showCounty ? [] : void 0
  3331. )
  3332. ] : [];
  3333. }
  3334. };
  3335. const provinceMap = /* @__PURE__ */ new Map();
  3336. Object.keys(province).forEach((code) => {
  3337. provinceMap.set(
  3338. code.slice(0, 2),
  3339. makeOption(province[code], code, getProvinceChildren())
  3340. );
  3341. });
  3342. const cityMap = /* @__PURE__ */ new Map();
  3343. if (showCity) {
  3344. const getCityChildren = () => {
  3345. if (showCounty) {
  3346. return placeholder.length ? [makeOption(placeholder[1])] : [];
  3347. }
  3348. };
  3349. Object.keys(city).forEach((code) => {
  3350. const option = makeOption(city[code], code, getCityChildren());
  3351. cityMap.set(code.slice(0, 4), option);
  3352. const province2 = provinceMap.get(code.slice(0, 2));
  3353. if (province2) {
  3354. province2.children.push(option);
  3355. }
  3356. });
  3357. }
  3358. if (showCounty) {
  3359. Object.keys(county).forEach((code) => {
  3360. const city2 = cityMap.get(code.slice(0, 4));
  3361. if (city2) {
  3362. city2.children.push(makeOption(county[code], code));
  3363. }
  3364. });
  3365. }
  3366. const options = Array.from(provinceMap.values());
  3367. if (placeholder.length) {
  3368. const county2 = showCounty ? [makeOption(placeholder[2])] : void 0;
  3369. const city2 = showCity ? [makeOption(placeholder[1], AREA_EMPTY_CODE, county2)] : void 0;
  3370. options.unshift(makeOption(placeholder[0], AREA_EMPTY_CODE, city2));
  3371. }
  3372. return options;
  3373. }
  3374. const Picker = withInstall(stdin_default$1n);
  3375. const [name$1f, bem$1b] = createNamespace("area");
  3376. const areaProps = extend({}, pickerSharedProps, {
  3377. modelValue: String,
  3378. columnsNum: makeNumericProp(3),
  3379. columnsPlaceholder: makeArrayProp(),
  3380. areaList: {
  3381. type: Object,
  3382. default: () => ({})
  3383. }
  3384. });
  3385. var stdin_default$1m = vue.defineComponent({
  3386. name: name$1f,
  3387. props: areaProps,
  3388. emits: ["change", "confirm", "cancel", "update:modelValue"],
  3389. setup(props, {
  3390. emit,
  3391. slots
  3392. }) {
  3393. const codes = vue.ref([]);
  3394. const picker = vue.ref();
  3395. const columns = vue.computed(() => formatDataForCascade(props));
  3396. const onChange = (...args) => emit("change", ...args);
  3397. const onCancel = (...args) => emit("cancel", ...args);
  3398. const onConfirm = (...args) => emit("confirm", ...args);
  3399. vue.watch(codes, (newCodes) => {
  3400. const lastCode = newCodes.length ? newCodes[newCodes.length - 1] : "";
  3401. if (lastCode && lastCode !== props.modelValue) {
  3402. emit("update:modelValue", lastCode);
  3403. }
  3404. }, {
  3405. deep: true
  3406. });
  3407. vue.watch(() => props.modelValue, (newCode) => {
  3408. if (newCode) {
  3409. const lastCode = codes.value.length ? codes.value[codes.value.length - 1] : "";
  3410. if (newCode !== lastCode) {
  3411. codes.value = [`${newCode.slice(0, 2)}0000`, `${newCode.slice(0, 4)}00`, newCode].slice(0, +props.columnsNum);
  3412. }
  3413. } else {
  3414. codes.value = [];
  3415. }
  3416. }, {
  3417. immediate: true
  3418. });
  3419. useExpose({
  3420. confirm: () => {
  3421. var _a;
  3422. return (_a = picker.value) == null ? void 0 : _a.confirm();
  3423. },
  3424. getSelectedOptions: () => {
  3425. var _a;
  3426. return ((_a = picker.value) == null ? void 0 : _a.getSelectedOptions()) || [];
  3427. }
  3428. });
  3429. return () => vue.createVNode(Picker, vue.mergeProps({
  3430. "ref": picker,
  3431. "modelValue": codes.value,
  3432. "onUpdate:modelValue": ($event) => codes.value = $event,
  3433. "class": bem$1b(),
  3434. "columns": columns.value,
  3435. "onChange": onChange,
  3436. "onCancel": onCancel,
  3437. "onConfirm": onConfirm
  3438. }, pick(props, INHERIT_PROPS)), pick(slots, INHERIT_SLOTS));
  3439. }
  3440. });
  3441. const Area = withInstall(stdin_default$1m);
  3442. const [name$1e, bem$1a] = createNamespace("cell");
  3443. const cellSharedProps = {
  3444. tag: makeStringProp("div"),
  3445. icon: String,
  3446. size: String,
  3447. title: numericProp,
  3448. value: numericProp,
  3449. label: numericProp,
  3450. center: Boolean,
  3451. isLink: Boolean,
  3452. border: truthProp,
  3453. required: Boolean,
  3454. iconPrefix: String,
  3455. valueClass: unknownProp,
  3456. labelClass: unknownProp,
  3457. titleClass: unknownProp,
  3458. titleStyle: null,
  3459. arrowDirection: String,
  3460. clickable: {
  3461. type: Boolean,
  3462. default: null
  3463. }
  3464. };
  3465. const cellProps = extend({}, cellSharedProps, routeProps);
  3466. var stdin_default$1l = vue.defineComponent({
  3467. name: name$1e,
  3468. props: cellProps,
  3469. setup(props, {
  3470. slots
  3471. }) {
  3472. const route2 = useRoute();
  3473. const renderLabel = () => {
  3474. const showLabel = slots.label || isDef(props.label);
  3475. if (showLabel) {
  3476. return vue.createVNode("div", {
  3477. "class": [bem$1a("label"), props.labelClass]
  3478. }, [slots.label ? slots.label() : props.label]);
  3479. }
  3480. };
  3481. const renderTitle = () => {
  3482. var _a;
  3483. if (slots.title || isDef(props.title)) {
  3484. const titleSlot = (_a = slots.title) == null ? void 0 : _a.call(slots);
  3485. if (Array.isArray(titleSlot) && titleSlot.length === 0) {
  3486. return;
  3487. }
  3488. return vue.createVNode("div", {
  3489. "class": [bem$1a("title"), props.titleClass],
  3490. "style": props.titleStyle
  3491. }, [titleSlot || vue.createVNode("span", null, [props.title]), renderLabel()]);
  3492. }
  3493. };
  3494. const renderValue = () => {
  3495. const slot = slots.value || slots.default;
  3496. const hasValue = slot || isDef(props.value);
  3497. if (hasValue) {
  3498. return vue.createVNode("div", {
  3499. "class": [bem$1a("value"), props.valueClass]
  3500. }, [slot ? slot() : vue.createVNode("span", null, [props.value])]);
  3501. }
  3502. };
  3503. const renderLeftIcon = () => {
  3504. if (slots.icon) {
  3505. return slots.icon();
  3506. }
  3507. if (props.icon) {
  3508. return vue.createVNode(Icon, {
  3509. "name": props.icon,
  3510. "class": bem$1a("left-icon"),
  3511. "classPrefix": props.iconPrefix
  3512. }, null);
  3513. }
  3514. };
  3515. const renderRightIcon = () => {
  3516. if (slots["right-icon"]) {
  3517. return slots["right-icon"]();
  3518. }
  3519. if (props.isLink) {
  3520. const name2 = props.arrowDirection && props.arrowDirection !== "right" ? `arrow-${props.arrowDirection}` : "arrow";
  3521. return vue.createVNode(Icon, {
  3522. "name": name2,
  3523. "class": bem$1a("right-icon")
  3524. }, null);
  3525. }
  3526. };
  3527. return () => {
  3528. var _a;
  3529. const {
  3530. tag,
  3531. size,
  3532. center,
  3533. border,
  3534. isLink,
  3535. required
  3536. } = props;
  3537. const clickable = (_a = props.clickable) != null ? _a : isLink;
  3538. const classes = {
  3539. center,
  3540. required,
  3541. clickable,
  3542. borderless: !border
  3543. };
  3544. if (size) {
  3545. classes[size] = !!size;
  3546. }
  3547. return vue.createVNode(tag, {
  3548. "class": bem$1a(classes),
  3549. "role": clickable ? "button" : void 0,
  3550. "tabindex": clickable ? 0 : void 0,
  3551. "onClick": route2
  3552. }, {
  3553. default: () => {
  3554. var _a2;
  3555. return [renderLeftIcon(), renderTitle(), renderValue(), renderRightIcon(), (_a2 = slots.extra) == null ? void 0 : _a2.call(slots)];
  3556. }
  3557. });
  3558. };
  3559. }
  3560. });
  3561. const Cell = withInstall(stdin_default$1l);
  3562. const [name$1d, bem$19] = createNamespace("form");
  3563. const formProps = {
  3564. colon: Boolean,
  3565. disabled: Boolean,
  3566. readonly: Boolean,
  3567. showError: Boolean,
  3568. labelWidth: numericProp,
  3569. labelAlign: String,
  3570. inputAlign: String,
  3571. scrollToError: Boolean,
  3572. validateFirst: Boolean,
  3573. submitOnEnter: truthProp,
  3574. showErrorMessage: truthProp,
  3575. errorMessageAlign: String,
  3576. validateTrigger: {
  3577. type: [String, Array],
  3578. default: "onBlur"
  3579. }
  3580. };
  3581. var stdin_default$1k = vue.defineComponent({
  3582. name: name$1d,
  3583. props: formProps,
  3584. emits: ["submit", "failed"],
  3585. setup(props, {
  3586. emit,
  3587. slots
  3588. }) {
  3589. const {
  3590. children,
  3591. linkChildren
  3592. } = use.useChildren(FORM_KEY);
  3593. const getFieldsByNames = (names) => {
  3594. if (names) {
  3595. return children.filter((field) => names.includes(field.name));
  3596. }
  3597. return children;
  3598. };
  3599. const validateSeq = (names) => new Promise((resolve, reject) => {
  3600. const errors = [];
  3601. const fields = getFieldsByNames(names);
  3602. fields.reduce((promise, field) => promise.then(() => {
  3603. if (!errors.length) {
  3604. return field.validate().then((error) => {
  3605. if (error) {
  3606. errors.push(error);
  3607. }
  3608. });
  3609. }
  3610. }), Promise.resolve()).then(() => {
  3611. if (errors.length) {
  3612. reject(errors);
  3613. } else {
  3614. resolve();
  3615. }
  3616. });
  3617. });
  3618. const validateAll = (names) => new Promise((resolve, reject) => {
  3619. const fields = getFieldsByNames(names);
  3620. Promise.all(fields.map((item) => item.validate())).then((errors) => {
  3621. errors = errors.filter(Boolean);
  3622. if (errors.length) {
  3623. reject(errors);
  3624. } else {
  3625. resolve();
  3626. }
  3627. });
  3628. });
  3629. const validateField = (name2) => {
  3630. const matched = children.find((item) => item.name === name2);
  3631. if (matched) {
  3632. return new Promise((resolve, reject) => {
  3633. matched.validate().then((error) => {
  3634. if (error) {
  3635. reject(error);
  3636. } else {
  3637. resolve();
  3638. }
  3639. });
  3640. });
  3641. }
  3642. return Promise.reject();
  3643. };
  3644. const validate = (name2) => {
  3645. if (typeof name2 === "string") {
  3646. return validateField(name2);
  3647. }
  3648. return props.validateFirst ? validateSeq(name2) : validateAll(name2);
  3649. };
  3650. const resetValidation = (name2) => {
  3651. if (typeof name2 === "string") {
  3652. name2 = [name2];
  3653. }
  3654. const fields = getFieldsByNames(name2);
  3655. fields.forEach((item) => {
  3656. item.resetValidation();
  3657. });
  3658. };
  3659. const getValidationStatus = () => children.reduce((form, field) => {
  3660. form[field.name] = field.getValidationStatus();
  3661. return form;
  3662. }, {});
  3663. const scrollToField = (name2, options) => {
  3664. children.some((item) => {
  3665. if (item.name === name2) {
  3666. item.$el.scrollIntoView(options);
  3667. return true;
  3668. }
  3669. return false;
  3670. });
  3671. };
  3672. const getValues = () => children.reduce((form, field) => {
  3673. form[field.name] = field.formValue.value;
  3674. return form;
  3675. }, {});
  3676. const submit = () => {
  3677. const values = getValues();
  3678. validate().then(() => emit("submit", values)).catch((errors) => {
  3679. emit("failed", {
  3680. values,
  3681. errors
  3682. });
  3683. if (props.scrollToError && errors[0].name) {
  3684. scrollToField(errors[0].name);
  3685. }
  3686. });
  3687. };
  3688. const onSubmit = (event) => {
  3689. preventDefault(event);
  3690. submit();
  3691. };
  3692. linkChildren({
  3693. props
  3694. });
  3695. useExpose({
  3696. submit,
  3697. validate,
  3698. getValues,
  3699. scrollToField,
  3700. resetValidation,
  3701. getValidationStatus
  3702. });
  3703. return () => {
  3704. var _a;
  3705. return vue.createVNode("form", {
  3706. "class": bem$19(),
  3707. "onSubmit": onSubmit
  3708. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
  3709. };
  3710. }
  3711. });
  3712. const Form = withInstall(stdin_default$1k);
  3713. function isEmptyValue(value) {
  3714. if (Array.isArray(value)) {
  3715. return !value.length;
  3716. }
  3717. if (value === 0) {
  3718. return false;
  3719. }
  3720. return !value;
  3721. }
  3722. function runSyncRule(value, rule) {
  3723. if (isEmptyValue(value)) {
  3724. if (rule.required) {
  3725. return false;
  3726. }
  3727. if (rule.validateEmpty === false) {
  3728. return true;
  3729. }
  3730. }
  3731. if (rule.pattern && !rule.pattern.test(String(value))) {
  3732. return false;
  3733. }
  3734. return true;
  3735. }
  3736. function runRuleValidator(value, rule) {
  3737. return new Promise((resolve) => {
  3738. const returnVal = rule.validator(value, rule);
  3739. if (isPromise(returnVal)) {
  3740. returnVal.then(resolve);
  3741. return;
  3742. }
  3743. resolve(returnVal);
  3744. });
  3745. }
  3746. function getRuleMessage(value, rule) {
  3747. const { message } = rule;
  3748. if (isFunction(message)) {
  3749. return message(value, rule);
  3750. }
  3751. return message || "";
  3752. }
  3753. function startComposing({ target }) {
  3754. target.composing = true;
  3755. }
  3756. function endComposing({ target }) {
  3757. if (target.composing) {
  3758. target.composing = false;
  3759. target.dispatchEvent(new Event("input"));
  3760. }
  3761. }
  3762. function resizeTextarea(input, autosize) {
  3763. const scrollTop = getRootScrollTop();
  3764. input.style.height = "auto";
  3765. let height = input.scrollHeight;
  3766. if (isObject(autosize)) {
  3767. const { maxHeight, minHeight } = autosize;
  3768. if (maxHeight !== void 0) {
  3769. height = Math.min(height, maxHeight);
  3770. }
  3771. if (minHeight !== void 0) {
  3772. height = Math.max(height, minHeight);
  3773. }
  3774. }
  3775. if (height) {
  3776. input.style.height = `${height}px`;
  3777. setRootScrollTop(scrollTop);
  3778. }
  3779. }
  3780. function mapInputType(type) {
  3781. if (type === "number") {
  3782. return {
  3783. type: "text",
  3784. inputmode: "decimal"
  3785. };
  3786. }
  3787. if (type === "digit") {
  3788. return {
  3789. type: "tel",
  3790. inputmode: "numeric"
  3791. };
  3792. }
  3793. return { type };
  3794. }
  3795. function getStringLength(str) {
  3796. return [...str].length;
  3797. }
  3798. function cutString(str, maxlength) {
  3799. return [...str].slice(0, maxlength).join("");
  3800. }
  3801. const [name$1c, bem$18] = createNamespace("field");
  3802. const fieldSharedProps = {
  3803. id: String,
  3804. name: String,
  3805. leftIcon: String,
  3806. rightIcon: String,
  3807. autofocus: Boolean,
  3808. clearable: Boolean,
  3809. maxlength: numericProp,
  3810. formatter: Function,
  3811. clearIcon: makeStringProp("clear"),
  3812. modelValue: makeNumericProp(""),
  3813. inputAlign: String,
  3814. placeholder: String,
  3815. autocomplete: String,
  3816. errorMessage: String,
  3817. enterkeyhint: String,
  3818. clearTrigger: makeStringProp("focus"),
  3819. formatTrigger: makeStringProp("onChange"),
  3820. error: {
  3821. type: Boolean,
  3822. default: null
  3823. },
  3824. disabled: {
  3825. type: Boolean,
  3826. default: null
  3827. },
  3828. readonly: {
  3829. type: Boolean,
  3830. default: null
  3831. }
  3832. };
  3833. const fieldProps = extend({}, cellSharedProps, fieldSharedProps, {
  3834. rows: numericProp,
  3835. type: makeStringProp("text"),
  3836. rules: Array,
  3837. autosize: [Boolean, Object],
  3838. labelWidth: numericProp,
  3839. labelClass: unknownProp,
  3840. labelAlign: String,
  3841. showWordLimit: Boolean,
  3842. errorMessageAlign: String,
  3843. colon: {
  3844. type: Boolean,
  3845. default: null
  3846. }
  3847. });
  3848. var stdin_default$1j = vue.defineComponent({
  3849. name: name$1c,
  3850. props: fieldProps,
  3851. emits: ["blur", "focus", "clear", "keypress", "clickInput", "endValidate", "startValidate", "clickLeftIcon", "clickRightIcon", "update:modelValue"],
  3852. setup(props, {
  3853. emit,
  3854. slots
  3855. }) {
  3856. const id = useId();
  3857. const state = vue.reactive({
  3858. status: "unvalidated",
  3859. focused: false,
  3860. validateMessage: ""
  3861. });
  3862. const inputRef = vue.ref();
  3863. const clearIconRef = vue.ref();
  3864. const customValue = vue.ref();
  3865. const {
  3866. parent: form
  3867. } = use.useParent(FORM_KEY);
  3868. const getModelValue = () => {
  3869. var _a;
  3870. return String((_a = props.modelValue) != null ? _a : "");
  3871. };
  3872. const getProp = (key) => {
  3873. if (isDef(props[key])) {
  3874. return props[key];
  3875. }
  3876. if (form && isDef(form.props[key])) {
  3877. return form.props[key];
  3878. }
  3879. };
  3880. const showClear = vue.computed(() => {
  3881. const readonly = getProp("readonly");
  3882. if (props.clearable && !readonly) {
  3883. const hasValue = getModelValue() !== "";
  3884. const trigger = props.clearTrigger === "always" || props.clearTrigger === "focus" && state.focused;
  3885. return hasValue && trigger;
  3886. }
  3887. return false;
  3888. });
  3889. const formValue = vue.computed(() => {
  3890. if (customValue.value && slots.input) {
  3891. return customValue.value();
  3892. }
  3893. return props.modelValue;
  3894. });
  3895. const runRules = (rules) => rules.reduce((promise, rule) => promise.then(() => {
  3896. if (state.status === "failed") {
  3897. return;
  3898. }
  3899. let {
  3900. value
  3901. } = formValue;
  3902. if (rule.formatter) {
  3903. value = rule.formatter(value, rule);
  3904. }
  3905. if (!runSyncRule(value, rule)) {
  3906. state.status = "failed";
  3907. state.validateMessage = getRuleMessage(value, rule);
  3908. return;
  3909. }
  3910. if (rule.validator) {
  3911. if (isEmptyValue(value) && rule.validateEmpty === false) {
  3912. return;
  3913. }
  3914. return runRuleValidator(value, rule).then((result) => {
  3915. if (result && typeof result === "string") {
  3916. state.status = "failed";
  3917. state.validateMessage = result;
  3918. } else if (result === false) {
  3919. state.status = "failed";
  3920. state.validateMessage = getRuleMessage(value, rule);
  3921. }
  3922. });
  3923. }
  3924. }), Promise.resolve());
  3925. const resetValidation = () => {
  3926. state.status = "unvalidated";
  3927. state.validateMessage = "";
  3928. };
  3929. const endValidate = () => emit("endValidate", {
  3930. status: state.status,
  3931. message: state.validateMessage
  3932. });
  3933. const validate = (rules = props.rules) => new Promise((resolve) => {
  3934. resetValidation();
  3935. if (rules) {
  3936. emit("startValidate");
  3937. runRules(rules).then(() => {
  3938. if (state.status === "failed") {
  3939. resolve({
  3940. name: props.name,
  3941. message: state.validateMessage
  3942. });
  3943. endValidate();
  3944. } else {
  3945. state.status = "passed";
  3946. resolve();
  3947. endValidate();
  3948. }
  3949. });
  3950. } else {
  3951. resolve();
  3952. }
  3953. });
  3954. const validateWithTrigger = (trigger) => {
  3955. if (form && props.rules) {
  3956. const {
  3957. validateTrigger
  3958. } = form.props;
  3959. const defaultTrigger = toArray(validateTrigger).includes(trigger);
  3960. const rules = props.rules.filter((rule) => {
  3961. if (rule.trigger) {
  3962. return toArray(rule.trigger).includes(trigger);
  3963. }
  3964. return defaultTrigger;
  3965. });
  3966. if (rules.length) {
  3967. validate(rules);
  3968. }
  3969. }
  3970. };
  3971. const limitValueLength = (value) => {
  3972. var _a;
  3973. const {
  3974. maxlength
  3975. } = props;
  3976. if (isDef(maxlength) && getStringLength(value) > maxlength) {
  3977. const modelValue = getModelValue();
  3978. if (modelValue && getStringLength(modelValue) === +maxlength) {
  3979. return modelValue;
  3980. }
  3981. const selectionEnd = (_a = inputRef.value) == null ? void 0 : _a.selectionEnd;
  3982. if (state.focused && selectionEnd) {
  3983. const valueArr = [...value];
  3984. const exceededLength = valueArr.length - +maxlength;
  3985. valueArr.splice(selectionEnd - exceededLength, exceededLength);
  3986. return valueArr.join("");
  3987. }
  3988. return cutString(value, +maxlength);
  3989. }
  3990. return value;
  3991. };
  3992. const updateValue = (value, trigger = "onChange") => {
  3993. const originalValue = value;
  3994. value = limitValueLength(value);
  3995. const limitDiffLen = getStringLength(originalValue) - getStringLength(value);
  3996. if (props.type === "number" || props.type === "digit") {
  3997. const isNumber = props.type === "number";
  3998. value = formatNumber(value, isNumber, isNumber);
  3999. }
  4000. let formatterDiffLen = 0;
  4001. if (props.formatter && trigger === props.formatTrigger) {
  4002. const {
  4003. formatter,
  4004. maxlength
  4005. } = props;
  4006. value = formatter(value);
  4007. if (isDef(maxlength) && getStringLength(value) > maxlength) {
  4008. value = cutString(value, +maxlength);
  4009. }
  4010. if (inputRef.value && state.focused) {
  4011. const {
  4012. selectionEnd
  4013. } = inputRef.value;
  4014. const bcoVal = cutString(originalValue, selectionEnd);
  4015. formatterDiffLen = getStringLength(formatter(bcoVal)) - getStringLength(bcoVal);
  4016. }
  4017. }
  4018. if (inputRef.value && inputRef.value.value !== value) {
  4019. if (state.focused) {
  4020. let {
  4021. selectionStart,
  4022. selectionEnd
  4023. } = inputRef.value;
  4024. inputRef.value.value = value;
  4025. if (isDef(selectionStart) && isDef(selectionEnd)) {
  4026. const valueLen = getStringLength(value);
  4027. if (limitDiffLen) {
  4028. selectionStart -= limitDiffLen;
  4029. selectionEnd -= limitDiffLen;
  4030. } else if (formatterDiffLen) {
  4031. selectionStart += formatterDiffLen;
  4032. selectionEnd += formatterDiffLen;
  4033. }
  4034. inputRef.value.setSelectionRange(Math.min(selectionStart, valueLen), Math.min(selectionEnd, valueLen));
  4035. }
  4036. } else {
  4037. inputRef.value.value = value;
  4038. }
  4039. }
  4040. if (value !== props.modelValue) {
  4041. emit("update:modelValue", value);
  4042. }
  4043. };
  4044. const onInput = (event) => {
  4045. if (!event.target.composing) {
  4046. updateValue(event.target.value);
  4047. }
  4048. };
  4049. const blur = () => {
  4050. var _a;
  4051. return (_a = inputRef.value) == null ? void 0 : _a.blur();
  4052. };
  4053. const focus = () => {
  4054. var _a;
  4055. return (_a = inputRef.value) == null ? void 0 : _a.focus();
  4056. };
  4057. const adjustTextareaSize = () => {
  4058. const input = inputRef.value;
  4059. if (props.type === "textarea" && props.autosize && input) {
  4060. resizeTextarea(input, props.autosize);
  4061. }
  4062. };
  4063. const onFocus = (event) => {
  4064. state.focused = true;
  4065. emit("focus", event);
  4066. vue.nextTick(adjustTextareaSize);
  4067. if (getProp("readonly")) {
  4068. blur();
  4069. }
  4070. };
  4071. const onBlur = (event) => {
  4072. if (getProp("readonly")) {
  4073. return;
  4074. }
  4075. state.focused = false;
  4076. updateValue(getModelValue(), "onBlur");
  4077. emit("blur", event);
  4078. validateWithTrigger("onBlur");
  4079. vue.nextTick(adjustTextareaSize);
  4080. resetScroll();
  4081. };
  4082. const onClickInput = (event) => emit("clickInput", event);
  4083. const onClickLeftIcon = (event) => emit("clickLeftIcon", event);
  4084. const onClickRightIcon = (event) => emit("clickRightIcon", event);
  4085. const onClear = (event) => {
  4086. preventDefault(event);
  4087. emit("update:modelValue", "");
  4088. emit("clear", event);
  4089. };
  4090. const showError = vue.computed(() => {
  4091. if (typeof props.error === "boolean") {
  4092. return props.error;
  4093. }
  4094. if (form && form.props.showError && state.status === "failed") {
  4095. return true;
  4096. }
  4097. });
  4098. const labelStyle = vue.computed(() => {
  4099. const labelWidth = getProp("labelWidth");
  4100. if (labelWidth) {
  4101. return {
  4102. width: addUnit(labelWidth)
  4103. };
  4104. }
  4105. });
  4106. const onKeypress = (event) => {
  4107. const ENTER_CODE = 13;
  4108. if (event.keyCode === ENTER_CODE) {
  4109. const submitOnEnter = form && form.props.submitOnEnter;
  4110. if (!submitOnEnter && props.type !== "textarea") {
  4111. preventDefault(event);
  4112. }
  4113. if (props.type === "search") {
  4114. blur();
  4115. }
  4116. }
  4117. emit("keypress", event);
  4118. };
  4119. const getInputId = () => props.id || `${id}-input`;
  4120. const getValidationStatus = () => state.status;
  4121. const renderInput = () => {
  4122. const controlClass = bem$18("control", [getProp("inputAlign"), {
  4123. error: showError.value,
  4124. custom: !!slots.input,
  4125. "min-height": props.type === "textarea" && !props.autosize
  4126. }]);
  4127. if (slots.input) {
  4128. return vue.createVNode("div", {
  4129. "class": controlClass,
  4130. "onClick": onClickInput
  4131. }, [slots.input()]);
  4132. }
  4133. const inputAttrs = {
  4134. id: getInputId(),
  4135. ref: inputRef,
  4136. name: props.name,
  4137. rows: props.rows !== void 0 ? +props.rows : void 0,
  4138. class: controlClass,
  4139. disabled: getProp("disabled"),
  4140. readonly: getProp("readonly"),
  4141. autofocus: props.autofocus,
  4142. placeholder: props.placeholder,
  4143. autocomplete: props.autocomplete,
  4144. enterkeyhint: props.enterkeyhint,
  4145. "aria-labelledby": props.label ? `${id}-label` : void 0,
  4146. onBlur,
  4147. onFocus,
  4148. onInput,
  4149. onClick: onClickInput,
  4150. onChange: endComposing,
  4151. onKeypress,
  4152. onCompositionend: endComposing,
  4153. onCompositionstart: startComposing
  4154. };
  4155. if (props.type === "textarea") {
  4156. return vue.createVNode("textarea", inputAttrs, null);
  4157. }
  4158. return vue.createVNode("input", vue.mergeProps(mapInputType(props.type), inputAttrs), null);
  4159. };
  4160. const renderLeftIcon = () => {
  4161. const leftIconSlot = slots["left-icon"];
  4162. if (props.leftIcon || leftIconSlot) {
  4163. return vue.createVNode("div", {
  4164. "class": bem$18("left-icon"),
  4165. "onClick": onClickLeftIcon
  4166. }, [leftIconSlot ? leftIconSlot() : vue.createVNode(Icon, {
  4167. "name": props.leftIcon,
  4168. "classPrefix": props.iconPrefix
  4169. }, null)]);
  4170. }
  4171. };
  4172. const renderRightIcon = () => {
  4173. const rightIconSlot = slots["right-icon"];
  4174. if (props.rightIcon || rightIconSlot) {
  4175. return vue.createVNode("div", {
  4176. "class": bem$18("right-icon"),
  4177. "onClick": onClickRightIcon
  4178. }, [rightIconSlot ? rightIconSlot() : vue.createVNode(Icon, {
  4179. "name": props.rightIcon,
  4180. "classPrefix": props.iconPrefix
  4181. }, null)]);
  4182. }
  4183. };
  4184. const renderWordLimit = () => {
  4185. if (props.showWordLimit && props.maxlength) {
  4186. const count = getStringLength(getModelValue());
  4187. return vue.createVNode("div", {
  4188. "class": bem$18("word-limit")
  4189. }, [vue.createVNode("span", {
  4190. "class": bem$18("word-num")
  4191. }, [count]), vue.createTextVNode("/"), props.maxlength]);
  4192. }
  4193. };
  4194. const renderMessage = () => {
  4195. if (form && form.props.showErrorMessage === false) {
  4196. return;
  4197. }
  4198. const message = props.errorMessage || state.validateMessage;
  4199. if (message) {
  4200. const slot = slots["error-message"];
  4201. const errorMessageAlign = getProp("errorMessageAlign");
  4202. return vue.createVNode("div", {
  4203. "class": bem$18("error-message", errorMessageAlign)
  4204. }, [slot ? slot({
  4205. message
  4206. }) : message]);
  4207. }
  4208. };
  4209. const renderLabel = () => {
  4210. const colon = getProp("colon") ? ":" : "";
  4211. if (slots.label) {
  4212. return [slots.label(), colon];
  4213. }
  4214. if (props.label) {
  4215. return vue.createVNode("label", {
  4216. "id": `${id}-label`,
  4217. "for": getInputId()
  4218. }, [props.label + colon]);
  4219. }
  4220. };
  4221. const renderFieldBody = () => [vue.createVNode("div", {
  4222. "class": bem$18("body")
  4223. }, [renderInput(), showClear.value && vue.createVNode(Icon, {
  4224. "ref": clearIconRef,
  4225. "name": props.clearIcon,
  4226. "class": bem$18("clear")
  4227. }, null), renderRightIcon(), slots.button && vue.createVNode("div", {
  4228. "class": bem$18("button")
  4229. }, [slots.button()])]), renderWordLimit(), renderMessage()];
  4230. useExpose({
  4231. blur,
  4232. focus,
  4233. validate,
  4234. formValue,
  4235. resetValidation,
  4236. getValidationStatus
  4237. });
  4238. vue.provide(use.CUSTOM_FIELD_INJECTION_KEY, {
  4239. customValue,
  4240. resetValidation,
  4241. validateWithTrigger
  4242. });
  4243. vue.watch(() => props.modelValue, () => {
  4244. updateValue(getModelValue());
  4245. resetValidation();
  4246. validateWithTrigger("onChange");
  4247. vue.nextTick(adjustTextareaSize);
  4248. });
  4249. vue.onMounted(() => {
  4250. updateValue(getModelValue(), props.formatTrigger);
  4251. vue.nextTick(adjustTextareaSize);
  4252. });
  4253. use.useEventListener("touchstart", onClear, {
  4254. target: vue.computed(() => {
  4255. var _a;
  4256. return (_a = clearIconRef.value) == null ? void 0 : _a.$el;
  4257. })
  4258. });
  4259. return () => {
  4260. const disabled = getProp("disabled");
  4261. const labelAlign = getProp("labelAlign");
  4262. const LeftIcon = renderLeftIcon();
  4263. const renderTitle = () => {
  4264. const Label = renderLabel();
  4265. if (labelAlign === "top") {
  4266. return [LeftIcon, Label].filter(Boolean);
  4267. }
  4268. return Label || [];
  4269. };
  4270. return vue.createVNode(Cell, {
  4271. "size": props.size,
  4272. "class": bem$18({
  4273. error: showError.value,
  4274. disabled,
  4275. [`label-${labelAlign}`]: labelAlign
  4276. }),
  4277. "center": props.center,
  4278. "border": props.border,
  4279. "isLink": props.isLink,
  4280. "clickable": props.clickable,
  4281. "titleStyle": labelStyle.value,
  4282. "valueClass": bem$18("value"),
  4283. "titleClass": [bem$18("label", [labelAlign, {
  4284. required: props.required
  4285. }]), props.labelClass],
  4286. "arrowDirection": props.arrowDirection
  4287. }, {
  4288. icon: LeftIcon && labelAlign !== "top" ? () => LeftIcon : null,
  4289. title: renderTitle,
  4290. value: renderFieldBody,
  4291. extra: slots.extra
  4292. });
  4293. };
  4294. }
  4295. });
  4296. const Field = withInstall(stdin_default$1j);
  4297. let lockCount = 0;
  4298. function lockClick(lock) {
  4299. if (lock) {
  4300. if (!lockCount) {
  4301. document.body.classList.add("van-toast--unclickable");
  4302. }
  4303. lockCount++;
  4304. } else if (lockCount) {
  4305. lockCount--;
  4306. if (!lockCount) {
  4307. document.body.classList.remove("van-toast--unclickable");
  4308. }
  4309. }
  4310. }
  4311. const [name$1b, bem$17] = createNamespace("toast");
  4312. const popupInheritProps = ["show", "overlay", "teleport", "transition", "overlayClass", "overlayStyle", "closeOnClickOverlay"];
  4313. const toastProps = {
  4314. icon: String,
  4315. show: Boolean,
  4316. type: makeStringProp("text"),
  4317. overlay: Boolean,
  4318. message: numericProp,
  4319. iconSize: numericProp,
  4320. duration: makeNumberProp(2e3),
  4321. position: makeStringProp("middle"),
  4322. teleport: [String, Object],
  4323. wordBreak: String,
  4324. className: unknownProp,
  4325. iconPrefix: String,
  4326. transition: makeStringProp("van-fade"),
  4327. loadingType: String,
  4328. forbidClick: Boolean,
  4329. overlayClass: unknownProp,
  4330. overlayStyle: Object,
  4331. closeOnClick: Boolean,
  4332. closeOnClickOverlay: Boolean
  4333. };
  4334. var stdin_default$1i = vue.defineComponent({
  4335. name: name$1b,
  4336. props: toastProps,
  4337. emits: ["update:show"],
  4338. setup(props, {
  4339. emit,
  4340. slots
  4341. }) {
  4342. let timer2;
  4343. let clickable = false;
  4344. const toggleClickable = () => {
  4345. const newValue = props.show && props.forbidClick;
  4346. if (clickable !== newValue) {
  4347. clickable = newValue;
  4348. lockClick(clickable);
  4349. }
  4350. };
  4351. const updateShow = (show) => emit("update:show", show);
  4352. const onClick = () => {
  4353. if (props.closeOnClick) {
  4354. updateShow(false);
  4355. }
  4356. };
  4357. const clearTimer = () => clearTimeout(timer2);
  4358. const renderIcon = () => {
  4359. const {
  4360. icon,
  4361. type,
  4362. iconSize,
  4363. iconPrefix,
  4364. loadingType
  4365. } = props;
  4366. const hasIcon = icon || type === "success" || type === "fail";
  4367. if (hasIcon) {
  4368. return vue.createVNode(Icon, {
  4369. "name": icon || type,
  4370. "size": iconSize,
  4371. "class": bem$17("icon"),
  4372. "classPrefix": iconPrefix
  4373. }, null);
  4374. }
  4375. if (type === "loading") {
  4376. return vue.createVNode(Loading, {
  4377. "class": bem$17("loading"),
  4378. "size": iconSize,
  4379. "type": loadingType
  4380. }, null);
  4381. }
  4382. };
  4383. const renderMessage = () => {
  4384. const {
  4385. type,
  4386. message
  4387. } = props;
  4388. if (slots.message) {
  4389. return vue.createVNode("div", {
  4390. "class": bem$17("text")
  4391. }, [slots.message()]);
  4392. }
  4393. if (isDef(message) && message !== "") {
  4394. return type === "html" ? vue.createVNode("div", {
  4395. "key": 0,
  4396. "class": bem$17("text"),
  4397. "innerHTML": String(message)
  4398. }, null) : vue.createVNode("div", {
  4399. "class": bem$17("text")
  4400. }, [message]);
  4401. }
  4402. };
  4403. vue.watch(() => [props.show, props.forbidClick], toggleClickable);
  4404. vue.watch(() => [props.show, props.type, props.message, props.duration], () => {
  4405. clearTimer();
  4406. if (props.show && props.duration > 0) {
  4407. timer2 = setTimeout(() => {
  4408. updateShow(false);
  4409. }, props.duration);
  4410. }
  4411. });
  4412. vue.onMounted(toggleClickable);
  4413. vue.onUnmounted(toggleClickable);
  4414. return () => vue.createVNode(Popup, vue.mergeProps({
  4415. "class": [bem$17([props.position, props.wordBreak === "normal" ? "break-normal" : props.wordBreak, {
  4416. [props.type]: !props.icon
  4417. }]), props.className],
  4418. "lockScroll": false,
  4419. "onClick": onClick,
  4420. "onClosed": clearTimer,
  4421. "onUpdate:show": updateShow
  4422. }, pick(props, popupInheritProps)), {
  4423. default: () => [renderIcon(), renderMessage()]
  4424. });
  4425. }
  4426. });
  4427. function usePopupState() {
  4428. const state = vue.reactive({
  4429. show: false
  4430. });
  4431. const toggle = (show) => {
  4432. state.show = show;
  4433. };
  4434. const open = (props) => {
  4435. extend(state, props, { transitionAppear: true });
  4436. toggle(true);
  4437. };
  4438. const close = () => toggle(false);
  4439. useExpose({ open, close, toggle });
  4440. return {
  4441. open,
  4442. close,
  4443. state,
  4444. toggle
  4445. };
  4446. }
  4447. function mountComponent(RootComponent) {
  4448. const app = vue.createApp(RootComponent);
  4449. const root = document.createElement("div");
  4450. document.body.appendChild(root);
  4451. return {
  4452. instance: app.mount(root),
  4453. unmount() {
  4454. app.unmount();
  4455. document.body.removeChild(root);
  4456. }
  4457. };
  4458. }
  4459. const defaultOptions$1 = {
  4460. icon: "",
  4461. type: "text",
  4462. message: "",
  4463. className: "",
  4464. overlay: false,
  4465. onClose: void 0,
  4466. onOpened: void 0,
  4467. duration: 2e3,
  4468. teleport: "body",
  4469. iconSize: void 0,
  4470. iconPrefix: void 0,
  4471. position: "middle",
  4472. transition: "van-fade",
  4473. forbidClick: false,
  4474. loadingType: void 0,
  4475. overlayClass: "",
  4476. overlayStyle: void 0,
  4477. closeOnClick: false,
  4478. closeOnClickOverlay: false
  4479. };
  4480. let queue = [];
  4481. let allowMultiple = false;
  4482. let currentOptions$2 = extend({}, defaultOptions$1);
  4483. const defaultOptionsMap = /* @__PURE__ */ new Map();
  4484. function parseOptions$1(message) {
  4485. if (isObject(message)) {
  4486. return message;
  4487. }
  4488. return {
  4489. message
  4490. };
  4491. }
  4492. function createInstance() {
  4493. const {
  4494. instance: instance2,
  4495. unmount
  4496. } = mountComponent({
  4497. setup() {
  4498. const message = vue.ref("");
  4499. const {
  4500. open,
  4501. state,
  4502. close,
  4503. toggle
  4504. } = usePopupState();
  4505. const onClosed = () => {
  4506. if (allowMultiple) {
  4507. queue = queue.filter((item) => item !== instance2);
  4508. unmount();
  4509. }
  4510. };
  4511. const render = () => {
  4512. const attrs = {
  4513. onClosed,
  4514. "onUpdate:show": toggle
  4515. };
  4516. return vue.createVNode(stdin_default$1i, vue.mergeProps(state, attrs), null);
  4517. };
  4518. vue.watch(message, (val) => {
  4519. state.message = val;
  4520. });
  4521. vue.getCurrentInstance().render = render;
  4522. return {
  4523. open,
  4524. close,
  4525. message
  4526. };
  4527. }
  4528. });
  4529. return instance2;
  4530. }
  4531. function getInstance() {
  4532. if (!queue.length || allowMultiple) {
  4533. const instance2 = createInstance();
  4534. queue.push(instance2);
  4535. }
  4536. return queue[queue.length - 1];
  4537. }
  4538. function showToast(options = {}) {
  4539. if (!inBrowser) {
  4540. return {};
  4541. }
  4542. const toast = getInstance();
  4543. const parsedOptions = parseOptions$1(options);
  4544. toast.open(extend({}, currentOptions$2, defaultOptionsMap.get(parsedOptions.type || currentOptions$2.type), parsedOptions));
  4545. return toast;
  4546. }
  4547. const createMethod = (type) => (options) => showToast(extend({
  4548. type
  4549. }, parseOptions$1(options)));
  4550. const showLoadingToast = createMethod("loading");
  4551. const showSuccessToast = createMethod("success");
  4552. const showFailToast = createMethod("fail");
  4553. const closeToast = (all) => {
  4554. var _a;
  4555. if (queue.length) {
  4556. if (all) {
  4557. queue.forEach((toast) => {
  4558. toast.close();
  4559. });
  4560. queue = [];
  4561. } else if (!allowMultiple) {
  4562. queue[0].close();
  4563. } else {
  4564. (_a = queue.shift()) == null ? void 0 : _a.close();
  4565. }
  4566. }
  4567. };
  4568. function setToastDefaultOptions(type, options) {
  4569. if (typeof type === "string") {
  4570. defaultOptionsMap.set(type, options);
  4571. } else {
  4572. extend(currentOptions$2, type);
  4573. }
  4574. }
  4575. const resetToastDefaultOptions = (type) => {
  4576. if (typeof type === "string") {
  4577. defaultOptionsMap.delete(type);
  4578. } else {
  4579. currentOptions$2 = extend({}, defaultOptions$1);
  4580. defaultOptionsMap.clear();
  4581. }
  4582. };
  4583. const allowMultipleToast = (value = true) => {
  4584. allowMultiple = value;
  4585. };
  4586. const Toast = withInstall(stdin_default$1i);
  4587. const [name$1a, bem$16] = createNamespace("switch");
  4588. const switchProps = {
  4589. size: numericProp,
  4590. loading: Boolean,
  4591. disabled: Boolean,
  4592. modelValue: unknownProp,
  4593. activeColor: String,
  4594. inactiveColor: String,
  4595. activeValue: {
  4596. type: unknownProp,
  4597. default: true
  4598. },
  4599. inactiveValue: {
  4600. type: unknownProp,
  4601. default: false
  4602. }
  4603. };
  4604. var stdin_default$1h = vue.defineComponent({
  4605. name: name$1a,
  4606. props: switchProps,
  4607. emits: ["change", "update:modelValue"],
  4608. setup(props, {
  4609. emit,
  4610. slots
  4611. }) {
  4612. const isChecked = () => props.modelValue === props.activeValue;
  4613. const onClick = () => {
  4614. if (!props.disabled && !props.loading) {
  4615. const newValue = isChecked() ? props.inactiveValue : props.activeValue;
  4616. emit("update:modelValue", newValue);
  4617. emit("change", newValue);
  4618. }
  4619. };
  4620. const renderLoading = () => {
  4621. if (props.loading) {
  4622. const color = isChecked() ? props.activeColor : props.inactiveColor;
  4623. return vue.createVNode(Loading, {
  4624. "class": bem$16("loading"),
  4625. "color": color
  4626. }, null);
  4627. }
  4628. if (slots.node) {
  4629. return slots.node();
  4630. }
  4631. };
  4632. use.useCustomFieldValue(() => props.modelValue);
  4633. return () => {
  4634. var _a;
  4635. const {
  4636. size,
  4637. loading,
  4638. disabled,
  4639. activeColor,
  4640. inactiveColor
  4641. } = props;
  4642. const checked = isChecked();
  4643. const style = {
  4644. fontSize: addUnit(size),
  4645. backgroundColor: checked ? activeColor : inactiveColor
  4646. };
  4647. return vue.createVNode("div", {
  4648. "role": "switch",
  4649. "class": bem$16({
  4650. on: checked,
  4651. loading,
  4652. disabled
  4653. }),
  4654. "style": style,
  4655. "tabindex": disabled ? void 0 : 0,
  4656. "aria-checked": checked,
  4657. "onClick": onClick
  4658. }, [vue.createVNode("div", {
  4659. "class": bem$16("node")
  4660. }, [renderLoading()]), (_a = slots.background) == null ? void 0 : _a.call(slots)]);
  4661. };
  4662. }
  4663. });
  4664. const Switch = withInstall(stdin_default$1h);
  4665. const [name$19, bem$15] = createNamespace("address-edit-detail");
  4666. const t$i = createNamespace("address-edit")[2];
  4667. var stdin_default$1g = vue.defineComponent({
  4668. name: name$19,
  4669. props: {
  4670. show: Boolean,
  4671. rows: numericProp,
  4672. value: String,
  4673. rules: Array,
  4674. focused: Boolean,
  4675. maxlength: numericProp,
  4676. searchResult: Array,
  4677. showSearchResult: Boolean
  4678. },
  4679. emits: ["blur", "focus", "input", "selectSearch"],
  4680. setup(props, {
  4681. emit
  4682. }) {
  4683. const field = vue.ref();
  4684. const showSearchResult = () => props.focused && props.searchResult && props.showSearchResult;
  4685. const onSelect = (express) => {
  4686. emit("selectSearch", express);
  4687. emit("input", `${express.address || ""} ${express.name || ""}`.trim());
  4688. };
  4689. const renderSearchResult = () => {
  4690. if (!showSearchResult()) {
  4691. return;
  4692. }
  4693. const {
  4694. searchResult
  4695. } = props;
  4696. return searchResult.map((express) => vue.createVNode(Cell, {
  4697. "clickable": true,
  4698. "key": (express.name || "") + (express.address || ""),
  4699. "icon": "location-o",
  4700. "title": express.name,
  4701. "label": express.address,
  4702. "class": bem$15("search-item"),
  4703. "border": false,
  4704. "onClick": () => onSelect(express)
  4705. }, null));
  4706. };
  4707. const onBlur = (event) => emit("blur", event);
  4708. const onFocus = (event) => emit("focus", event);
  4709. const onInput = (value) => emit("input", value);
  4710. return () => {
  4711. if (props.show) {
  4712. return vue.createVNode(vue.Fragment, null, [vue.createVNode(Field, {
  4713. "autosize": true,
  4714. "clearable": true,
  4715. "ref": field,
  4716. "class": bem$15(),
  4717. "rows": props.rows,
  4718. "type": "textarea",
  4719. "rules": props.rules,
  4720. "label": t$i("addressDetail"),
  4721. "border": !showSearchResult(),
  4722. "maxlength": props.maxlength,
  4723. "modelValue": props.value,
  4724. "placeholder": t$i("addressDetail"),
  4725. "onBlur": onBlur,
  4726. "onFocus": onFocus,
  4727. "onUpdate:modelValue": onInput
  4728. }, null), renderSearchResult()]);
  4729. }
  4730. };
  4731. }
  4732. });
  4733. const [name$18, bem$14, t$h] = createNamespace("address-edit");
  4734. const DEFAULT_DATA = {
  4735. name: "",
  4736. tel: "",
  4737. city: "",
  4738. county: "",
  4739. country: "",
  4740. province: "",
  4741. areaCode: "",
  4742. isDefault: false,
  4743. addressDetail: ""
  4744. };
  4745. const addressEditProps = {
  4746. areaList: Object,
  4747. isSaving: Boolean,
  4748. isDeleting: Boolean,
  4749. validator: Function,
  4750. showArea: truthProp,
  4751. showDetail: truthProp,
  4752. showDelete: Boolean,
  4753. disableArea: Boolean,
  4754. searchResult: Array,
  4755. telMaxlength: numericProp,
  4756. showSetDefault: Boolean,
  4757. saveButtonText: String,
  4758. areaPlaceholder: String,
  4759. deleteButtonText: String,
  4760. showSearchResult: Boolean,
  4761. detailRows: makeNumericProp(1),
  4762. detailMaxlength: makeNumericProp(200),
  4763. areaColumnsPlaceholder: makeArrayProp(),
  4764. addressInfo: {
  4765. type: Object,
  4766. default: () => extend({}, DEFAULT_DATA)
  4767. },
  4768. telValidator: {
  4769. type: Function,
  4770. default: isMobile
  4771. }
  4772. };
  4773. var stdin_default$1f = vue.defineComponent({
  4774. name: name$18,
  4775. props: addressEditProps,
  4776. emits: ["save", "focus", "delete", "clickArea", "changeArea", "changeDetail", "selectSearch", "changeDefault"],
  4777. setup(props, {
  4778. emit,
  4779. slots
  4780. }) {
  4781. const areaRef = vue.ref();
  4782. const data = vue.reactive({});
  4783. const showAreaPopup = vue.ref(false);
  4784. const detailFocused = vue.ref(false);
  4785. const areaListLoaded = vue.computed(() => isObject(props.areaList) && Object.keys(props.areaList).length);
  4786. const areaText = vue.computed(() => {
  4787. const {
  4788. province,
  4789. city,
  4790. county,
  4791. areaCode
  4792. } = data;
  4793. if (areaCode) {
  4794. const arr = [province, city, county];
  4795. if (province && province === city) {
  4796. arr.splice(1, 1);
  4797. }
  4798. return arr.filter(Boolean).join("/");
  4799. }
  4800. return "";
  4801. });
  4802. const hideBottomFields = vue.computed(() => {
  4803. var _a;
  4804. return ((_a = props.searchResult) == null ? void 0 : _a.length) && detailFocused.value;
  4805. });
  4806. const onFocus = (key) => {
  4807. detailFocused.value = key === "addressDetail";
  4808. emit("focus", key);
  4809. };
  4810. const rules = vue.computed(() => {
  4811. const {
  4812. validator,
  4813. telValidator
  4814. } = props;
  4815. const makeRule = (name2, emptyMessage) => ({
  4816. validator: (value) => {
  4817. if (validator) {
  4818. const message = validator(name2, value);
  4819. if (message) {
  4820. return message;
  4821. }
  4822. }
  4823. if (!value) {
  4824. return emptyMessage;
  4825. }
  4826. return true;
  4827. }
  4828. });
  4829. return {
  4830. name: [makeRule("name", t$h("nameEmpty"))],
  4831. tel: [makeRule("tel", t$h("telInvalid")), {
  4832. validator: telValidator,
  4833. message: t$h("telInvalid")
  4834. }],
  4835. areaCode: [makeRule("areaCode", t$h("areaEmpty"))],
  4836. addressDetail: [makeRule("addressDetail", t$h("addressEmpty"))]
  4837. };
  4838. });
  4839. const onSave = () => emit("save", data);
  4840. const onChangeDetail = (val) => {
  4841. data.addressDetail = val;
  4842. emit("changeDetail", val);
  4843. };
  4844. const assignAreaText = (options) => {
  4845. data.province = options[0].text;
  4846. data.city = options[1].text;
  4847. data.county = options[2].text;
  4848. };
  4849. const onAreaConfirm = ({
  4850. selectedValues,
  4851. selectedOptions
  4852. }) => {
  4853. if (selectedValues.some((value) => value === AREA_EMPTY_CODE)) {
  4854. showToast(t$h("areaEmpty"));
  4855. } else {
  4856. showAreaPopup.value = false;
  4857. assignAreaText(selectedOptions);
  4858. emit("changeArea", selectedOptions);
  4859. }
  4860. };
  4861. const onDelete = () => emit("delete", data);
  4862. const setAreaCode = (code) => {
  4863. data.areaCode = code || "";
  4864. };
  4865. const onDetailBlur = () => {
  4866. setTimeout(() => {
  4867. detailFocused.value = false;
  4868. });
  4869. };
  4870. const setAddressDetail = (value) => {
  4871. data.addressDetail = value;
  4872. };
  4873. const renderSetDefaultCell = () => {
  4874. if (props.showSetDefault) {
  4875. const slots2 = {
  4876. "right-icon": () => vue.createVNode(Switch, {
  4877. "modelValue": data.isDefault,
  4878. "onUpdate:modelValue": ($event) => data.isDefault = $event,
  4879. "onChange": (event) => emit("changeDefault", event)
  4880. }, null)
  4881. };
  4882. return vue.withDirectives(vue.createVNode(Cell, {
  4883. "center": true,
  4884. "title": t$h("defaultAddress"),
  4885. "class": bem$14("default")
  4886. }, slots2), [[vue.vShow, !hideBottomFields.value]]);
  4887. }
  4888. };
  4889. useExpose({
  4890. setAreaCode,
  4891. setAddressDetail
  4892. });
  4893. vue.watch(() => props.addressInfo, (value) => {
  4894. extend(data, DEFAULT_DATA, value);
  4895. vue.nextTick(() => {
  4896. var _a;
  4897. const options = (_a = areaRef.value) == null ? void 0 : _a.getSelectedOptions();
  4898. if (options && options.every((option) => option && option.value !== AREA_EMPTY_CODE)) {
  4899. assignAreaText(options);
  4900. }
  4901. });
  4902. }, {
  4903. deep: true,
  4904. immediate: true
  4905. });
  4906. return () => {
  4907. const {
  4908. disableArea
  4909. } = props;
  4910. return vue.createVNode(Form, {
  4911. "class": bem$14(),
  4912. "onSubmit": onSave
  4913. }, {
  4914. default: () => {
  4915. var _a;
  4916. return [vue.createVNode("div", {
  4917. "class": bem$14("fields")
  4918. }, [vue.createVNode(Field, {
  4919. "modelValue": data.name,
  4920. "onUpdate:modelValue": ($event) => data.name = $event,
  4921. "clearable": true,
  4922. "label": t$h("name"),
  4923. "rules": rules.value.name,
  4924. "placeholder": t$h("name"),
  4925. "onFocus": () => onFocus("name")
  4926. }, null), vue.createVNode(Field, {
  4927. "modelValue": data.tel,
  4928. "onUpdate:modelValue": ($event) => data.tel = $event,
  4929. "clearable": true,
  4930. "type": "tel",
  4931. "label": t$h("tel"),
  4932. "rules": rules.value.tel,
  4933. "maxlength": props.telMaxlength,
  4934. "placeholder": t$h("tel"),
  4935. "onFocus": () => onFocus("tel")
  4936. }, null), vue.withDirectives(vue.createVNode(Field, {
  4937. "readonly": true,
  4938. "label": t$h("area"),
  4939. "is-link": !disableArea,
  4940. "modelValue": areaText.value,
  4941. "rules": rules.value.areaCode,
  4942. "placeholder": props.areaPlaceholder || t$h("area"),
  4943. "onFocus": () => onFocus("areaCode"),
  4944. "onClick": () => {
  4945. emit("clickArea");
  4946. showAreaPopup.value = !disableArea;
  4947. }
  4948. }, null), [[vue.vShow, props.showArea]]), vue.createVNode(stdin_default$1g, {
  4949. "show": props.showDetail,
  4950. "rows": props.detailRows,
  4951. "rules": rules.value.addressDetail,
  4952. "value": data.addressDetail,
  4953. "focused": detailFocused.value,
  4954. "maxlength": props.detailMaxlength,
  4955. "searchResult": props.searchResult,
  4956. "showSearchResult": props.showSearchResult,
  4957. "onBlur": onDetailBlur,
  4958. "onFocus": () => onFocus("addressDetail"),
  4959. "onInput": onChangeDetail,
  4960. "onSelectSearch": (event) => emit("selectSearch", event)
  4961. }, null), (_a = slots.default) == null ? void 0 : _a.call(slots)]), renderSetDefaultCell(), vue.withDirectives(vue.createVNode("div", {
  4962. "class": bem$14("buttons")
  4963. }, [vue.createVNode(Button, {
  4964. "block": true,
  4965. "round": true,
  4966. "type": "primary",
  4967. "text": props.saveButtonText || t$h("save"),
  4968. "class": bem$14("button"),
  4969. "loading": props.isSaving,
  4970. "nativeType": "submit"
  4971. }, null), props.showDelete && vue.createVNode(Button, {
  4972. "block": true,
  4973. "round": true,
  4974. "class": bem$14("button"),
  4975. "loading": props.isDeleting,
  4976. "text": props.deleteButtonText || t$h("delete"),
  4977. "onClick": onDelete
  4978. }, null)]), [[vue.vShow, !hideBottomFields.value]]), vue.createVNode(Popup, {
  4979. "show": showAreaPopup.value,
  4980. "onUpdate:show": ($event) => showAreaPopup.value = $event,
  4981. "round": true,
  4982. "teleport": "body",
  4983. "position": "bottom",
  4984. "lazyRender": false
  4985. }, {
  4986. default: () => [vue.createVNode(Area, {
  4987. "modelValue": data.areaCode,
  4988. "onUpdate:modelValue": ($event) => data.areaCode = $event,
  4989. "ref": areaRef,
  4990. "loading": !areaListLoaded.value,
  4991. "areaList": props.areaList,
  4992. "columnsPlaceholder": props.areaColumnsPlaceholder,
  4993. "onConfirm": onAreaConfirm,
  4994. "onCancel": () => {
  4995. showAreaPopup.value = false;
  4996. }
  4997. }, null)]
  4998. })];
  4999. }
  5000. });
  5001. };
  5002. }
  5003. });
  5004. const AddressEdit = withInstall(stdin_default$1f);
  5005. const [name$17, bem$13] = createNamespace("radio-group");
  5006. const radioGroupProps = {
  5007. disabled: Boolean,
  5008. iconSize: numericProp,
  5009. direction: String,
  5010. modelValue: unknownProp,
  5011. checkedColor: String
  5012. };
  5013. const RADIO_KEY = Symbol(name$17);
  5014. var stdin_default$1e = vue.defineComponent({
  5015. name: name$17,
  5016. props: radioGroupProps,
  5017. emits: ["change", "update:modelValue"],
  5018. setup(props, {
  5019. emit,
  5020. slots
  5021. }) {
  5022. const {
  5023. linkChildren
  5024. } = use.useChildren(RADIO_KEY);
  5025. const updateValue = (value) => emit("update:modelValue", value);
  5026. vue.watch(() => props.modelValue, (value) => emit("change", value));
  5027. linkChildren({
  5028. props,
  5029. updateValue
  5030. });
  5031. use.useCustomFieldValue(() => props.modelValue);
  5032. return () => {
  5033. var _a;
  5034. return vue.createVNode("div", {
  5035. "class": bem$13([props.direction]),
  5036. "role": "radiogroup"
  5037. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
  5038. };
  5039. }
  5040. });
  5041. const RadioGroup = withInstall(stdin_default$1e);
  5042. const [name$16, bem$12] = createNamespace("tag");
  5043. const tagProps = {
  5044. size: String,
  5045. mark: Boolean,
  5046. show: truthProp,
  5047. type: makeStringProp("default"),
  5048. color: String,
  5049. plain: Boolean,
  5050. round: Boolean,
  5051. textColor: String,
  5052. closeable: Boolean
  5053. };
  5054. var stdin_default$1d = vue.defineComponent({
  5055. name: name$16,
  5056. props: tagProps,
  5057. emits: ["close"],
  5058. setup(props, {
  5059. slots,
  5060. emit
  5061. }) {
  5062. const onClose = (event) => {
  5063. event.stopPropagation();
  5064. emit("close", event);
  5065. };
  5066. const getStyle = () => {
  5067. if (props.plain) {
  5068. return {
  5069. color: props.textColor || props.color,
  5070. borderColor: props.color
  5071. };
  5072. }
  5073. return {
  5074. color: props.textColor,
  5075. background: props.color
  5076. };
  5077. };
  5078. const renderTag = () => {
  5079. var _a;
  5080. const {
  5081. type,
  5082. mark,
  5083. plain,
  5084. round,
  5085. size,
  5086. closeable
  5087. } = props;
  5088. const classes = {
  5089. mark,
  5090. plain,
  5091. round
  5092. };
  5093. if (size) {
  5094. classes[size] = size;
  5095. }
  5096. const CloseIcon = closeable && vue.createVNode(Icon, {
  5097. "name": "cross",
  5098. "class": [bem$12("close"), HAPTICS_FEEDBACK],
  5099. "onClick": onClose
  5100. }, null);
  5101. return vue.createVNode("span", {
  5102. "style": getStyle(),
  5103. "class": bem$12([classes, type])
  5104. }, [(_a = slots.default) == null ? void 0 : _a.call(slots), CloseIcon]);
  5105. };
  5106. return () => vue.createVNode(vue.Transition, {
  5107. "name": props.closeable ? "van-fade" : void 0
  5108. }, {
  5109. default: () => [props.show ? renderTag() : null]
  5110. });
  5111. }
  5112. });
  5113. const Tag = withInstall(stdin_default$1d);
  5114. const checkerProps = {
  5115. name: unknownProp,
  5116. shape: makeStringProp("round"),
  5117. disabled: Boolean,
  5118. iconSize: numericProp,
  5119. modelValue: unknownProp,
  5120. checkedColor: String,
  5121. labelPosition: String,
  5122. labelDisabled: Boolean
  5123. };
  5124. var stdin_default$1c = vue.defineComponent({
  5125. props: extend({}, checkerProps, {
  5126. bem: makeRequiredProp(Function),
  5127. role: String,
  5128. parent: Object,
  5129. checked: Boolean,
  5130. bindGroup: truthProp
  5131. }),
  5132. emits: ["click", "toggle"],
  5133. setup(props, {
  5134. emit,
  5135. slots
  5136. }) {
  5137. const iconRef = vue.ref();
  5138. const getParentProp = (name2) => {
  5139. if (props.parent && props.bindGroup) {
  5140. return props.parent.props[name2];
  5141. }
  5142. };
  5143. const disabled = vue.computed(() => getParentProp("disabled") || props.disabled);
  5144. const direction = vue.computed(() => getParentProp("direction"));
  5145. const iconStyle = vue.computed(() => {
  5146. const checkedColor = props.checkedColor || getParentProp("checkedColor");
  5147. if (checkedColor && props.checked && !disabled.value) {
  5148. return {
  5149. borderColor: checkedColor,
  5150. backgroundColor: checkedColor
  5151. };
  5152. }
  5153. });
  5154. const onClick = (event) => {
  5155. const {
  5156. target
  5157. } = event;
  5158. const icon = iconRef.value;
  5159. const iconClicked = icon === target || (icon == null ? void 0 : icon.contains(target));
  5160. if (!disabled.value && (iconClicked || !props.labelDisabled)) {
  5161. emit("toggle");
  5162. }
  5163. emit("click", event);
  5164. };
  5165. const renderIcon = () => {
  5166. const {
  5167. bem: bem2,
  5168. shape,
  5169. checked
  5170. } = props;
  5171. const iconSize = props.iconSize || getParentProp("iconSize");
  5172. return vue.createVNode("div", {
  5173. "ref": iconRef,
  5174. "class": bem2("icon", [shape, {
  5175. disabled: disabled.value,
  5176. checked
  5177. }]),
  5178. "style": {
  5179. fontSize: addUnit(iconSize)
  5180. }
  5181. }, [slots.icon ? slots.icon({
  5182. checked,
  5183. disabled: disabled.value
  5184. }) : vue.createVNode(Icon, {
  5185. "name": "success",
  5186. "style": iconStyle.value
  5187. }, null)]);
  5188. };
  5189. const renderLabel = () => {
  5190. if (slots.default) {
  5191. return vue.createVNode("span", {
  5192. "class": props.bem("label", [props.labelPosition, {
  5193. disabled: disabled.value
  5194. }])
  5195. }, [slots.default()]);
  5196. }
  5197. };
  5198. return () => {
  5199. const nodes = props.labelPosition === "left" ? [renderLabel(), renderIcon()] : [renderIcon(), renderLabel()];
  5200. return vue.createVNode("div", {
  5201. "role": props.role,
  5202. "class": props.bem([{
  5203. disabled: disabled.value,
  5204. "label-disabled": props.labelDisabled
  5205. }, direction.value]),
  5206. "tabindex": disabled.value ? void 0 : 0,
  5207. "aria-checked": props.checked,
  5208. "onClick": onClick
  5209. }, [nodes]);
  5210. };
  5211. }
  5212. });
  5213. const radioProps = checkerProps;
  5214. const [name$15, bem$11] = createNamespace("radio");
  5215. var stdin_default$1b = vue.defineComponent({
  5216. name: name$15,
  5217. props: checkerProps,
  5218. emits: ["update:modelValue"],
  5219. setup(props, {
  5220. emit,
  5221. slots
  5222. }) {
  5223. const {
  5224. parent
  5225. } = use.useParent(RADIO_KEY);
  5226. const checked = () => {
  5227. const value = parent ? parent.props.modelValue : props.modelValue;
  5228. return value === props.name;
  5229. };
  5230. const toggle = () => {
  5231. if (parent) {
  5232. parent.updateValue(props.name);
  5233. } else {
  5234. emit("update:modelValue", props.name);
  5235. }
  5236. };
  5237. return () => vue.createVNode(stdin_default$1c, vue.mergeProps({
  5238. "bem": bem$11,
  5239. "role": "radio",
  5240. "parent": parent,
  5241. "checked": checked(),
  5242. "onToggle": toggle
  5243. }, props), pick(slots, ["default", "icon"]));
  5244. }
  5245. });
  5246. const Radio = withInstall(stdin_default$1b);
  5247. const [name$14, bem$10] = createNamespace("address-item");
  5248. var stdin_default$1a = vue.defineComponent({
  5249. name: name$14,
  5250. props: {
  5251. address: makeRequiredProp(Object),
  5252. disabled: Boolean,
  5253. switchable: Boolean,
  5254. defaultTagText: String
  5255. },
  5256. emits: ["edit", "click", "select"],
  5257. setup(props, {
  5258. slots,
  5259. emit
  5260. }) {
  5261. const onClick = () => {
  5262. if (props.switchable) {
  5263. emit("select");
  5264. }
  5265. emit("click");
  5266. };
  5267. const renderRightIcon = () => vue.createVNode(Icon, {
  5268. "name": "edit",
  5269. "class": bem$10("edit"),
  5270. "onClick": (event) => {
  5271. event.stopPropagation();
  5272. emit("edit");
  5273. emit("click");
  5274. }
  5275. }, null);
  5276. const renderTag = () => {
  5277. if (slots.tag) {
  5278. return slots.tag(props.address);
  5279. }
  5280. if (props.address.isDefault && props.defaultTagText) {
  5281. return vue.createVNode(Tag, {
  5282. "type": "primary",
  5283. "round": true,
  5284. "class": bem$10("tag")
  5285. }, {
  5286. default: () => [props.defaultTagText]
  5287. });
  5288. }
  5289. };
  5290. const renderContent = () => {
  5291. const {
  5292. address,
  5293. disabled,
  5294. switchable
  5295. } = props;
  5296. const Info = [vue.createVNode("div", {
  5297. "class": bem$10("name")
  5298. }, [`${address.name} ${address.tel}`, renderTag()]), vue.createVNode("div", {
  5299. "class": bem$10("address")
  5300. }, [address.address])];
  5301. if (switchable && !disabled) {
  5302. return vue.createVNode(Radio, {
  5303. "name": address.id,
  5304. "iconSize": 18
  5305. }, {
  5306. default: () => [Info]
  5307. });
  5308. }
  5309. return Info;
  5310. };
  5311. return () => {
  5312. var _a;
  5313. const {
  5314. disabled
  5315. } = props;
  5316. return vue.createVNode("div", {
  5317. "class": bem$10({
  5318. disabled
  5319. }),
  5320. "onClick": onClick
  5321. }, [vue.createVNode(Cell, {
  5322. "border": false,
  5323. "titleClass": bem$10("title")
  5324. }, {
  5325. title: renderContent,
  5326. "right-icon": renderRightIcon
  5327. }), (_a = slots.bottom) == null ? void 0 : _a.call(slots, extend({}, props.address, {
  5328. disabled
  5329. }))]);
  5330. };
  5331. }
  5332. });
  5333. const [name$13, bem$$, t$g] = createNamespace("address-list");
  5334. const addressListProps = {
  5335. list: makeArrayProp(),
  5336. modelValue: numericProp,
  5337. switchable: truthProp,
  5338. disabledText: String,
  5339. disabledList: makeArrayProp(),
  5340. addButtonText: String,
  5341. defaultTagText: String
  5342. };
  5343. var stdin_default$19 = vue.defineComponent({
  5344. name: name$13,
  5345. props: addressListProps,
  5346. emits: ["add", "edit", "select", "clickItem", "editDisabled", "selectDisabled", "update:modelValue"],
  5347. setup(props, {
  5348. slots,
  5349. emit
  5350. }) {
  5351. const renderItem = (item, index, disabled) => {
  5352. const onEdit = () => emit(disabled ? "editDisabled" : "edit", item, index);
  5353. const onClick = () => emit("clickItem", item, index);
  5354. const onSelect = () => {
  5355. emit(disabled ? "selectDisabled" : "select", item, index);
  5356. if (!disabled) {
  5357. emit("update:modelValue", item.id);
  5358. }
  5359. };
  5360. return vue.createVNode(stdin_default$1a, {
  5361. "key": item.id,
  5362. "address": item,
  5363. "disabled": disabled,
  5364. "switchable": props.switchable,
  5365. "defaultTagText": props.defaultTagText,
  5366. "onEdit": onEdit,
  5367. "onClick": onClick,
  5368. "onSelect": onSelect
  5369. }, {
  5370. bottom: slots["item-bottom"],
  5371. tag: slots.tag
  5372. });
  5373. };
  5374. const renderList = (list, disabled) => {
  5375. if (list) {
  5376. return list.map((item, index) => renderItem(item, index, disabled));
  5377. }
  5378. };
  5379. const renderBottom = () => vue.createVNode("div", {
  5380. "class": [bem$$("bottom"), "van-safe-area-bottom"]
  5381. }, [vue.createVNode(Button, {
  5382. "round": true,
  5383. "block": true,
  5384. "type": "primary",
  5385. "text": props.addButtonText || t$g("add"),
  5386. "class": bem$$("add"),
  5387. "onClick": () => emit("add")
  5388. }, null)]);
  5389. return () => {
  5390. var _a, _b;
  5391. const List2 = renderList(props.list);
  5392. const DisabledList = renderList(props.disabledList, true);
  5393. const DisabledText = props.disabledText && vue.createVNode("div", {
  5394. "class": bem$$("disabled-text")
  5395. }, [props.disabledText]);
  5396. return vue.createVNode("div", {
  5397. "class": bem$$()
  5398. }, [(_a = slots.top) == null ? void 0 : _a.call(slots), vue.createVNode(RadioGroup, {
  5399. "modelValue": props.modelValue
  5400. }, {
  5401. default: () => [List2]
  5402. }), DisabledText, DisabledList, (_b = slots.default) == null ? void 0 : _b.call(slots), renderBottom()]);
  5403. };
  5404. }
  5405. });
  5406. const AddressList = withInstall(stdin_default$19);
  5407. const hasIntersectionObserver = use.inBrowser && "IntersectionObserver" in window && "IntersectionObserverEntry" in window && "intersectionRatio" in window.IntersectionObserverEntry.prototype;
  5408. const modeType = {
  5409. event: "event",
  5410. observer: "observer"
  5411. };
  5412. function remove(arr, item) {
  5413. if (!arr.length)
  5414. return;
  5415. const index = arr.indexOf(item);
  5416. if (index > -1)
  5417. return arr.splice(index, 1);
  5418. }
  5419. function getBestSelectionFromSrcset(el, scale) {
  5420. if (el.tagName !== "IMG" || !el.getAttribute("data-srcset"))
  5421. return;
  5422. let options = el.getAttribute("data-srcset");
  5423. const container = el.parentNode;
  5424. const containerWidth = container.offsetWidth * scale;
  5425. let spaceIndex;
  5426. let tmpSrc;
  5427. let tmpWidth;
  5428. options = options.trim().split(",");
  5429. const result = options.map((item) => {
  5430. item = item.trim();
  5431. spaceIndex = item.lastIndexOf(" ");
  5432. if (spaceIndex === -1) {
  5433. tmpSrc = item;
  5434. tmpWidth = 999998;
  5435. } else {
  5436. tmpSrc = item.substr(0, spaceIndex);
  5437. tmpWidth = parseInt(
  5438. item.substr(spaceIndex + 1, item.length - spaceIndex - 2),
  5439. 10
  5440. );
  5441. }
  5442. return [tmpWidth, tmpSrc];
  5443. });
  5444. result.sort((a, b) => {
  5445. if (a[0] < b[0]) {
  5446. return 1;
  5447. }
  5448. if (a[0] > b[0]) {
  5449. return -1;
  5450. }
  5451. if (a[0] === b[0]) {
  5452. if (b[1].indexOf(".webp", b[1].length - 5) !== -1) {
  5453. return 1;
  5454. }
  5455. if (a[1].indexOf(".webp", a[1].length - 5) !== -1) {
  5456. return -1;
  5457. }
  5458. }
  5459. return 0;
  5460. });
  5461. let bestSelectedSrc = "";
  5462. let tmpOption;
  5463. for (let i = 0; i < result.length; i++) {
  5464. tmpOption = result[i];
  5465. bestSelectedSrc = tmpOption[1];
  5466. const next = result[i + 1];
  5467. if (next && next[0] < containerWidth) {
  5468. bestSelectedSrc = tmpOption[1];
  5469. break;
  5470. } else if (!next) {
  5471. bestSelectedSrc = tmpOption[1];
  5472. break;
  5473. }
  5474. }
  5475. return bestSelectedSrc;
  5476. }
  5477. const getDPR = (scale = 1) => use.inBrowser ? window.devicePixelRatio || scale : scale;
  5478. function supportWebp() {
  5479. if (!use.inBrowser)
  5480. return false;
  5481. let support = true;
  5482. try {
  5483. const elem = document.createElement("canvas");
  5484. if (elem.getContext && elem.getContext("2d")) {
  5485. support = elem.toDataURL("image/webp").indexOf("data:image/webp") === 0;
  5486. }
  5487. } catch (err) {
  5488. support = false;
  5489. }
  5490. return support;
  5491. }
  5492. function throttle(action, delay) {
  5493. let timeout = null;
  5494. let lastRun = 0;
  5495. return function(...args) {
  5496. if (timeout) {
  5497. return;
  5498. }
  5499. const elapsed = Date.now() - lastRun;
  5500. const runCallback = () => {
  5501. lastRun = Date.now();
  5502. timeout = false;
  5503. action.apply(this, args);
  5504. };
  5505. if (elapsed >= delay) {
  5506. runCallback();
  5507. } else {
  5508. timeout = setTimeout(runCallback, delay);
  5509. }
  5510. };
  5511. }
  5512. function on(el, type, func) {
  5513. el.addEventListener(type, func, {
  5514. capture: false,
  5515. passive: true
  5516. });
  5517. }
  5518. function off(el, type, func) {
  5519. el.removeEventListener(type, func, false);
  5520. }
  5521. const loadImageAsync = (item, resolve, reject) => {
  5522. const image = new Image();
  5523. if (!item || !item.src) {
  5524. return reject(new Error("image src is required"));
  5525. }
  5526. image.src = item.src;
  5527. if (item.cors) {
  5528. image.crossOrigin = item.cors;
  5529. }
  5530. image.onload = () => resolve({
  5531. naturalHeight: image.naturalHeight,
  5532. naturalWidth: image.naturalWidth,
  5533. src: image.src
  5534. });
  5535. image.onerror = (e) => reject(e);
  5536. };
  5537. class ImageCache {
  5538. constructor({ max }) {
  5539. this.options = {
  5540. max: max || 100
  5541. };
  5542. this.caches = [];
  5543. }
  5544. has(key) {
  5545. return this.caches.indexOf(key) > -1;
  5546. }
  5547. add(key) {
  5548. if (this.has(key))
  5549. return;
  5550. this.caches.push(key);
  5551. if (this.caches.length > this.options.max) {
  5552. this.free();
  5553. }
  5554. }
  5555. free() {
  5556. this.caches.shift();
  5557. }
  5558. }
  5559. const [name$12, bem$_] = createNamespace("back-top");
  5560. const backTopProps = {
  5561. right: numericProp,
  5562. bottom: numericProp,
  5563. target: [String, Object],
  5564. offset: makeNumericProp(200),
  5565. teleport: {
  5566. type: [String, Object],
  5567. default: "body"
  5568. }
  5569. };
  5570. var stdin_default$18 = vue.defineComponent({
  5571. name: name$12,
  5572. inheritAttrs: false,
  5573. props: backTopProps,
  5574. emits: ["click"],
  5575. setup(props, {
  5576. emit,
  5577. slots,
  5578. attrs
  5579. }) {
  5580. const show = vue.ref(false);
  5581. const root = vue.ref();
  5582. const scrollParent = vue.ref();
  5583. const style = vue.computed(() => ({
  5584. right: addUnit(props.right),
  5585. bottom: addUnit(props.bottom)
  5586. }));
  5587. const onClick = (event) => {
  5588. var _a;
  5589. emit("click", event);
  5590. (_a = scrollParent.value) == null ? void 0 : _a.scrollTo({
  5591. top: 0,
  5592. behavior: "smooth"
  5593. });
  5594. };
  5595. const scroll = () => {
  5596. show.value = scrollParent.value ? getScrollTop(scrollParent.value) >= props.offset : false;
  5597. };
  5598. const getTarget = () => {
  5599. const {
  5600. target
  5601. } = props;
  5602. if (typeof target === "string") {
  5603. const el = document.querySelector(target);
  5604. if (el) {
  5605. return el;
  5606. }
  5607. if (process.env.NODE_ENV !== "production") {
  5608. console.error(`[Vant] BackTop: target element "${target}" was not found, the BackTop component will not be rendered.`);
  5609. }
  5610. } else {
  5611. return target;
  5612. }
  5613. };
  5614. const updateTarget = () => {
  5615. if (inBrowser) {
  5616. vue.nextTick(() => {
  5617. scrollParent.value = props.target ? getTarget() : use.getScrollParent(root.value);
  5618. scroll();
  5619. });
  5620. }
  5621. };
  5622. use.useEventListener("scroll", throttle(scroll, 100), {
  5623. target: scrollParent
  5624. });
  5625. vue.onMounted(updateTarget);
  5626. vue.watch(() => props.target, updateTarget);
  5627. return () => {
  5628. const Content = vue.createVNode("div", vue.mergeProps({
  5629. "ref": root,
  5630. "class": bem$_({
  5631. active: show.value
  5632. }),
  5633. "style": style.value,
  5634. "onClick": onClick
  5635. }, attrs), [slots.default ? slots.default() : vue.createVNode(Icon, {
  5636. "name": "back-top",
  5637. "class": bem$_("icon")
  5638. }, null)]);
  5639. if (props.teleport) {
  5640. return vue.createVNode(vue.Teleport, {
  5641. "to": props.teleport
  5642. }, {
  5643. default: () => [Content]
  5644. });
  5645. }
  5646. return Content;
  5647. };
  5648. }
  5649. });
  5650. const BackTop = withInstall(stdin_default$18);
  5651. const [name$11, bem$Z, t$f] = createNamespace("calendar");
  5652. const formatMonthTitle = (date) => t$f("monthTitle", date.getFullYear(), date.getMonth() + 1);
  5653. function compareMonth(date1, date2) {
  5654. const year1 = date1.getFullYear();
  5655. const year2 = date2.getFullYear();
  5656. if (year1 === year2) {
  5657. const month1 = date1.getMonth();
  5658. const month2 = date2.getMonth();
  5659. return month1 === month2 ? 0 : month1 > month2 ? 1 : -1;
  5660. }
  5661. return year1 > year2 ? 1 : -1;
  5662. }
  5663. function compareDay(day1, day2) {
  5664. const compareMonthResult = compareMonth(day1, day2);
  5665. if (compareMonthResult === 0) {
  5666. const date1 = day1.getDate();
  5667. const date2 = day2.getDate();
  5668. return date1 === date2 ? 0 : date1 > date2 ? 1 : -1;
  5669. }
  5670. return compareMonthResult;
  5671. }
  5672. const cloneDate = (date) => new Date(date);
  5673. const cloneDates = (dates) => Array.isArray(dates) ? dates.map(cloneDate) : cloneDate(dates);
  5674. function getDayByOffset(date, offset) {
  5675. const cloned = cloneDate(date);
  5676. cloned.setDate(cloned.getDate() + offset);
  5677. return cloned;
  5678. }
  5679. const getPrevDay = (date) => getDayByOffset(date, -1);
  5680. const getNextDay = (date) => getDayByOffset(date, 1);
  5681. const getToday = () => {
  5682. const today = new Date();
  5683. today.setHours(0, 0, 0, 0);
  5684. return today;
  5685. };
  5686. function calcDateNum(date) {
  5687. const day1 = date[0].getTime();
  5688. const day2 = date[1].getTime();
  5689. return (day2 - day1) / (1e3 * 60 * 60 * 24) + 1;
  5690. }
  5691. const sharedProps = extend({}, pickerSharedProps, {
  5692. modelValue: makeArrayProp(),
  5693. filter: Function,
  5694. formatter: {
  5695. type: Function,
  5696. default: (type, option) => option
  5697. }
  5698. });
  5699. const pickerInheritKeys = Object.keys(pickerSharedProps);
  5700. function times(n, iteratee) {
  5701. if (n < 0) {
  5702. return [];
  5703. }
  5704. const result = Array(n);
  5705. let index = -1;
  5706. while (++index < n) {
  5707. result[index] = iteratee(index);
  5708. }
  5709. return result;
  5710. }
  5711. const getMonthEndDay = (year, month) => 32 - new Date(year, month - 1, 32).getDate();
  5712. const genOptions = (min, max, type, formatter, filter) => {
  5713. const options = times(max - min + 1, (index) => {
  5714. const value = padZero(min + index);
  5715. return formatter(type, {
  5716. text: value,
  5717. value
  5718. });
  5719. });
  5720. return filter ? filter(type, options) : options;
  5721. };
  5722. const formatValueRange = (values, columns) => values.map((value, index) => {
  5723. const column = columns[index];
  5724. if (column.length) {
  5725. const maxValue = +column[column.length - 1].value;
  5726. if (+value > maxValue) {
  5727. return String(maxValue);
  5728. }
  5729. }
  5730. return value;
  5731. });
  5732. const [name$10] = createNamespace("calendar-day");
  5733. var stdin_default$17 = vue.defineComponent({
  5734. name: name$10,
  5735. props: {
  5736. item: makeRequiredProp(Object),
  5737. color: String,
  5738. index: Number,
  5739. offset: makeNumberProp(0),
  5740. rowHeight: String
  5741. },
  5742. emits: ["click"],
  5743. setup(props, {
  5744. emit,
  5745. slots
  5746. }) {
  5747. const style = vue.computed(() => {
  5748. var _a;
  5749. const {
  5750. item,
  5751. index,
  5752. color,
  5753. offset,
  5754. rowHeight
  5755. } = props;
  5756. const style2 = {
  5757. height: rowHeight
  5758. };
  5759. if (item.type === "placeholder") {
  5760. style2.width = "100%";
  5761. return style2;
  5762. }
  5763. if (index === 0) {
  5764. style2.marginLeft = `${100 * offset / 7}%`;
  5765. }
  5766. if (color) {
  5767. switch (item.type) {
  5768. case "end":
  5769. case "start":
  5770. case "start-end":
  5771. case "multiple-middle":
  5772. case "multiple-selected":
  5773. style2.background = color;
  5774. break;
  5775. case "middle":
  5776. style2.color = color;
  5777. break;
  5778. }
  5779. }
  5780. if (offset + (((_a = item.date) == null ? void 0 : _a.getDate()) || 1) > 28) {
  5781. style2.marginBottom = 0;
  5782. }
  5783. return style2;
  5784. });
  5785. const onClick = () => {
  5786. if (props.item.type !== "disabled") {
  5787. emit("click", props.item);
  5788. }
  5789. };
  5790. const renderTopInfo = () => {
  5791. const {
  5792. topInfo
  5793. } = props.item;
  5794. if (topInfo || slots["top-info"]) {
  5795. return vue.createVNode("div", {
  5796. "class": bem$Z("top-info")
  5797. }, [slots["top-info"] ? slots["top-info"](props.item) : topInfo]);
  5798. }
  5799. };
  5800. const renderBottomInfo = () => {
  5801. const {
  5802. bottomInfo
  5803. } = props.item;
  5804. if (bottomInfo || slots["bottom-info"]) {
  5805. return vue.createVNode("div", {
  5806. "class": bem$Z("bottom-info")
  5807. }, [slots["bottom-info"] ? slots["bottom-info"](props.item) : bottomInfo]);
  5808. }
  5809. };
  5810. const renderContent = () => {
  5811. const {
  5812. item,
  5813. color,
  5814. rowHeight
  5815. } = props;
  5816. const {
  5817. type,
  5818. text
  5819. } = item;
  5820. const Nodes = [renderTopInfo(), text, renderBottomInfo()];
  5821. if (type === "selected") {
  5822. return vue.createVNode("div", {
  5823. "class": bem$Z("selected-day"),
  5824. "style": {
  5825. width: rowHeight,
  5826. height: rowHeight,
  5827. background: color
  5828. }
  5829. }, [Nodes]);
  5830. }
  5831. return Nodes;
  5832. };
  5833. return () => {
  5834. const {
  5835. type,
  5836. className
  5837. } = props.item;
  5838. if (type === "placeholder") {
  5839. return vue.createVNode("div", {
  5840. "class": bem$Z("day"),
  5841. "style": style.value
  5842. }, null);
  5843. }
  5844. return vue.createVNode("div", {
  5845. "role": "gridcell",
  5846. "style": style.value,
  5847. "class": [bem$Z("day", type), className],
  5848. "tabindex": type === "disabled" ? void 0 : -1,
  5849. "onClick": onClick
  5850. }, [renderContent()]);
  5851. };
  5852. }
  5853. });
  5854. const [name$$] = createNamespace("calendar-month");
  5855. const calendarMonthProps = {
  5856. date: makeRequiredProp(Date),
  5857. type: String,
  5858. color: String,
  5859. minDate: makeRequiredProp(Date),
  5860. maxDate: makeRequiredProp(Date),
  5861. showMark: Boolean,
  5862. rowHeight: numericProp,
  5863. formatter: Function,
  5864. lazyRender: Boolean,
  5865. currentDate: [Date, Array],
  5866. allowSameDay: Boolean,
  5867. showSubtitle: Boolean,
  5868. showMonthTitle: Boolean,
  5869. firstDayOfWeek: Number
  5870. };
  5871. var stdin_default$16 = vue.defineComponent({
  5872. name: name$$,
  5873. props: calendarMonthProps,
  5874. emits: ["click"],
  5875. setup(props, {
  5876. emit,
  5877. slots
  5878. }) {
  5879. const [visible, setVisible] = use.useToggle();
  5880. const daysRef = vue.ref();
  5881. const monthRef = vue.ref();
  5882. const height = useHeight(monthRef);
  5883. const title = vue.computed(() => formatMonthTitle(props.date));
  5884. const rowHeight = vue.computed(() => addUnit(props.rowHeight));
  5885. const offset = vue.computed(() => {
  5886. const realDay = props.date.getDay();
  5887. if (props.firstDayOfWeek) {
  5888. return (realDay + 7 - props.firstDayOfWeek) % 7;
  5889. }
  5890. return realDay;
  5891. });
  5892. const totalDay = vue.computed(() => getMonthEndDay(props.date.getFullYear(), props.date.getMonth() + 1));
  5893. const shouldRender = vue.computed(() => visible.value || !props.lazyRender);
  5894. const getTitle = () => title.value;
  5895. const getMultipleDayType = (day) => {
  5896. const isSelected = (date) => props.currentDate.some((item) => compareDay(item, date) === 0);
  5897. if (isSelected(day)) {
  5898. const prevDay = getPrevDay(day);
  5899. const nextDay = getNextDay(day);
  5900. const prevSelected = isSelected(prevDay);
  5901. const nextSelected = isSelected(nextDay);
  5902. if (prevSelected && nextSelected) {
  5903. return "multiple-middle";
  5904. }
  5905. if (prevSelected) {
  5906. return "end";
  5907. }
  5908. if (nextSelected) {
  5909. return "start";
  5910. }
  5911. return "multiple-selected";
  5912. }
  5913. return "";
  5914. };
  5915. const getRangeDayType = (day) => {
  5916. const [startDay, endDay] = props.currentDate;
  5917. if (!startDay) {
  5918. return "";
  5919. }
  5920. const compareToStart = compareDay(day, startDay);
  5921. if (!endDay) {
  5922. return compareToStart === 0 ? "start" : "";
  5923. }
  5924. const compareToEnd = compareDay(day, endDay);
  5925. if (props.allowSameDay && compareToStart === 0 && compareToEnd === 0) {
  5926. return "start-end";
  5927. }
  5928. if (compareToStart === 0) {
  5929. return "start";
  5930. }
  5931. if (compareToEnd === 0) {
  5932. return "end";
  5933. }
  5934. if (compareToStart > 0 && compareToEnd < 0) {
  5935. return "middle";
  5936. }
  5937. return "";
  5938. };
  5939. const getDayType = (day) => {
  5940. const {
  5941. type,
  5942. minDate,
  5943. maxDate,
  5944. currentDate
  5945. } = props;
  5946. if (compareDay(day, minDate) < 0 || compareDay(day, maxDate) > 0) {
  5947. return "disabled";
  5948. }
  5949. if (currentDate === null) {
  5950. return "";
  5951. }
  5952. if (Array.isArray(currentDate)) {
  5953. if (type === "multiple") {
  5954. return getMultipleDayType(day);
  5955. }
  5956. if (type === "range") {
  5957. return getRangeDayType(day);
  5958. }
  5959. } else if (type === "single") {
  5960. return compareDay(day, currentDate) === 0 ? "selected" : "";
  5961. }
  5962. return "";
  5963. };
  5964. const getBottomInfo = (dayType) => {
  5965. if (props.type === "range") {
  5966. if (dayType === "start" || dayType === "end") {
  5967. return t$f(dayType);
  5968. }
  5969. if (dayType === "start-end") {
  5970. return `${t$f("start")}/${t$f("end")}`;
  5971. }
  5972. }
  5973. };
  5974. const renderTitle = () => {
  5975. if (props.showMonthTitle) {
  5976. return vue.createVNode("div", {
  5977. "class": bem$Z("month-title")
  5978. }, [title.value]);
  5979. }
  5980. };
  5981. const renderMark = () => {
  5982. if (props.showMark && shouldRender.value) {
  5983. return vue.createVNode("div", {
  5984. "class": bem$Z("month-mark")
  5985. }, [props.date.getMonth() + 1]);
  5986. }
  5987. };
  5988. const placeholders = vue.computed(() => {
  5989. const count = Math.ceil((totalDay.value + offset.value) / 7);
  5990. return Array(count).fill({
  5991. type: "placeholder"
  5992. });
  5993. });
  5994. const days = vue.computed(() => {
  5995. const days2 = [];
  5996. const year = props.date.getFullYear();
  5997. const month = props.date.getMonth();
  5998. for (let day = 1; day <= totalDay.value; day++) {
  5999. const date = new Date(year, month, day);
  6000. const type = getDayType(date);
  6001. let config = {
  6002. date,
  6003. type,
  6004. text: day,
  6005. bottomInfo: getBottomInfo(type)
  6006. };
  6007. if (props.formatter) {
  6008. config = props.formatter(config);
  6009. }
  6010. days2.push(config);
  6011. }
  6012. return days2;
  6013. });
  6014. const disabledDays = vue.computed(() => days.value.filter((day) => day.type === "disabled"));
  6015. const scrollToDate = (body, targetDate) => {
  6016. if (daysRef.value) {
  6017. const daysRect = use.useRect(daysRef.value);
  6018. const totalRows = placeholders.value.length;
  6019. const currentRow = Math.ceil((targetDate.getDate() + offset.value) / 7);
  6020. const rowOffset = (currentRow - 1) * daysRect.height / totalRows;
  6021. setScrollTop(body, daysRect.top + rowOffset + body.scrollTop - use.useRect(body).top);
  6022. }
  6023. };
  6024. const renderDay = (item, index) => vue.createVNode(stdin_default$17, {
  6025. "item": item,
  6026. "index": index,
  6027. "color": props.color,
  6028. "offset": offset.value,
  6029. "rowHeight": rowHeight.value,
  6030. "onClick": (item2) => emit("click", item2)
  6031. }, pick(slots, ["top-info", "bottom-info"]));
  6032. const renderDays = () => vue.createVNode("div", {
  6033. "ref": daysRef,
  6034. "role": "grid",
  6035. "class": bem$Z("days")
  6036. }, [renderMark(), (shouldRender.value ? days : placeholders).value.map(renderDay)]);
  6037. useExpose({
  6038. getTitle,
  6039. getHeight: () => height.value,
  6040. setVisible,
  6041. scrollToDate,
  6042. disabledDays
  6043. });
  6044. return () => vue.createVNode("div", {
  6045. "class": bem$Z("month"),
  6046. "ref": monthRef
  6047. }, [renderTitle(), renderDays()]);
  6048. }
  6049. });
  6050. const [name$_] = createNamespace("calendar-header");
  6051. var stdin_default$15 = vue.defineComponent({
  6052. name: name$_,
  6053. props: {
  6054. date: Date,
  6055. title: String,
  6056. subtitle: String,
  6057. showTitle: Boolean,
  6058. showSubtitle: Boolean,
  6059. firstDayOfWeek: Number
  6060. },
  6061. emits: ["clickSubtitle"],
  6062. setup(props, {
  6063. slots,
  6064. emit
  6065. }) {
  6066. const renderTitle = () => {
  6067. if (props.showTitle) {
  6068. const text = props.title || t$f("title");
  6069. const title = slots.title ? slots.title() : text;
  6070. return vue.createVNode("div", {
  6071. "class": bem$Z("header-title")
  6072. }, [title]);
  6073. }
  6074. };
  6075. const onClickSubtitle = (event) => emit("clickSubtitle", event);
  6076. const renderSubtitle = () => {
  6077. if (props.showSubtitle) {
  6078. const title = slots.subtitle ? slots.subtitle({
  6079. date: props.date,
  6080. text: props.subtitle
  6081. }) : props.subtitle;
  6082. return vue.createVNode("div", {
  6083. "class": bem$Z("header-subtitle"),
  6084. "onClick": onClickSubtitle
  6085. }, [title]);
  6086. }
  6087. };
  6088. const renderWeekDays = () => {
  6089. const {
  6090. firstDayOfWeek
  6091. } = props;
  6092. const weekdays = t$f("weekdays");
  6093. const renderWeekDays2 = [...weekdays.slice(firstDayOfWeek, 7), ...weekdays.slice(0, firstDayOfWeek)];
  6094. return vue.createVNode("div", {
  6095. "class": bem$Z("weekdays")
  6096. }, [renderWeekDays2.map((text) => vue.createVNode("span", {
  6097. "class": bem$Z("weekday")
  6098. }, [text]))]);
  6099. };
  6100. return () => vue.createVNode("div", {
  6101. "class": bem$Z("header")
  6102. }, [renderTitle(), renderSubtitle(), renderWeekDays()]);
  6103. }
  6104. });
  6105. const calendarProps = {
  6106. show: Boolean,
  6107. type: makeStringProp("single"),
  6108. title: String,
  6109. color: String,
  6110. round: truthProp,
  6111. readonly: Boolean,
  6112. poppable: truthProp,
  6113. maxRange: makeNumericProp(null),
  6114. position: makeStringProp("bottom"),
  6115. teleport: [String, Object],
  6116. showMark: truthProp,
  6117. showTitle: truthProp,
  6118. formatter: Function,
  6119. rowHeight: numericProp,
  6120. confirmText: String,
  6121. rangePrompt: String,
  6122. lazyRender: truthProp,
  6123. showConfirm: truthProp,
  6124. defaultDate: [Date, Array],
  6125. allowSameDay: Boolean,
  6126. showSubtitle: truthProp,
  6127. closeOnPopstate: truthProp,
  6128. showRangePrompt: truthProp,
  6129. confirmDisabledText: String,
  6130. closeOnClickOverlay: truthProp,
  6131. safeAreaInsetTop: Boolean,
  6132. safeAreaInsetBottom: truthProp,
  6133. minDate: {
  6134. type: Date,
  6135. validator: isDate,
  6136. default: getToday
  6137. },
  6138. maxDate: {
  6139. type: Date,
  6140. validator: isDate,
  6141. default: () => {
  6142. const now = getToday();
  6143. return new Date(now.getFullYear(), now.getMonth() + 6, now.getDate());
  6144. }
  6145. },
  6146. firstDayOfWeek: {
  6147. type: numericProp,
  6148. default: 0,
  6149. validator: (val) => val >= 0 && val <= 6
  6150. }
  6151. };
  6152. var stdin_default$14 = vue.defineComponent({
  6153. name: name$11,
  6154. props: calendarProps,
  6155. emits: ["select", "confirm", "unselect", "monthShow", "overRange", "update:show", "clickSubtitle"],
  6156. setup(props, {
  6157. emit,
  6158. slots
  6159. }) {
  6160. const limitDateRange = (date, minDate = props.minDate, maxDate = props.maxDate) => {
  6161. if (compareDay(date, minDate) === -1) {
  6162. return minDate;
  6163. }
  6164. if (compareDay(date, maxDate) === 1) {
  6165. return maxDate;
  6166. }
  6167. return date;
  6168. };
  6169. const getInitialDate = (defaultDate = props.defaultDate) => {
  6170. const {
  6171. type,
  6172. minDate,
  6173. maxDate,
  6174. allowSameDay
  6175. } = props;
  6176. if (defaultDate === null) {
  6177. return defaultDate;
  6178. }
  6179. const now = getToday();
  6180. if (type === "range") {
  6181. if (!Array.isArray(defaultDate)) {
  6182. defaultDate = [];
  6183. }
  6184. const start = limitDateRange(defaultDate[0] || now, minDate, allowSameDay ? maxDate : getPrevDay(maxDate));
  6185. const end = limitDateRange(defaultDate[1] || now, allowSameDay ? minDate : getNextDay(minDate));
  6186. return [start, end];
  6187. }
  6188. if (type === "multiple") {
  6189. if (Array.isArray(defaultDate)) {
  6190. return defaultDate.map((date) => limitDateRange(date));
  6191. }
  6192. return [limitDateRange(now)];
  6193. }
  6194. if (!defaultDate || Array.isArray(defaultDate)) {
  6195. defaultDate = now;
  6196. }
  6197. return limitDateRange(defaultDate);
  6198. };
  6199. let bodyHeight;
  6200. const bodyRef = vue.ref();
  6201. const subtitle = vue.ref({
  6202. text: "",
  6203. date: void 0
  6204. });
  6205. const currentDate = vue.ref(getInitialDate());
  6206. const [monthRefs, setMonthRefs] = useRefs();
  6207. const dayOffset = vue.computed(() => props.firstDayOfWeek ? +props.firstDayOfWeek % 7 : 0);
  6208. const months = vue.computed(() => {
  6209. const months2 = [];
  6210. const cursor = new Date(props.minDate);
  6211. cursor.setDate(1);
  6212. do {
  6213. months2.push(new Date(cursor));
  6214. cursor.setMonth(cursor.getMonth() + 1);
  6215. } while (compareMonth(cursor, props.maxDate) !== 1);
  6216. return months2;
  6217. });
  6218. const buttonDisabled = vue.computed(() => {
  6219. if (currentDate.value) {
  6220. if (props.type === "range") {
  6221. return !currentDate.value[0] || !currentDate.value[1];
  6222. }
  6223. if (props.type === "multiple") {
  6224. return !currentDate.value.length;
  6225. }
  6226. }
  6227. return !currentDate.value;
  6228. });
  6229. const getSelectedDate = () => currentDate.value;
  6230. const onScroll = () => {
  6231. const top = getScrollTop(bodyRef.value);
  6232. const bottom = top + bodyHeight;
  6233. const heights = months.value.map((item, index) => monthRefs.value[index].getHeight());
  6234. const heightSum = heights.reduce((a, b) => a + b, 0);
  6235. if (bottom > heightSum && top > 0) {
  6236. return;
  6237. }
  6238. let height = 0;
  6239. let currentMonth;
  6240. const visibleRange = [-1, -1];
  6241. for (let i = 0; i < months.value.length; i++) {
  6242. const month = monthRefs.value[i];
  6243. const visible = height <= bottom && height + heights[i] >= top;
  6244. if (visible) {
  6245. visibleRange[1] = i;
  6246. if (!currentMonth) {
  6247. currentMonth = month;
  6248. visibleRange[0] = i;
  6249. }
  6250. if (!monthRefs.value[i].showed) {
  6251. monthRefs.value[i].showed = true;
  6252. emit("monthShow", {
  6253. date: month.date,
  6254. title: month.getTitle()
  6255. });
  6256. }
  6257. }
  6258. height += heights[i];
  6259. }
  6260. months.value.forEach((month, index) => {
  6261. const visible = index >= visibleRange[0] - 1 && index <= visibleRange[1] + 1;
  6262. monthRefs.value[index].setVisible(visible);
  6263. });
  6264. if (currentMonth) {
  6265. subtitle.value = {
  6266. text: currentMonth.getTitle(),
  6267. date: currentMonth.date
  6268. };
  6269. }
  6270. };
  6271. const scrollToDate = (targetDate) => {
  6272. use.raf(() => {
  6273. months.value.some((month, index) => {
  6274. if (compareMonth(month, targetDate) === 0) {
  6275. if (bodyRef.value) {
  6276. monthRefs.value[index].scrollToDate(bodyRef.value, targetDate);
  6277. }
  6278. return true;
  6279. }
  6280. return false;
  6281. });
  6282. onScroll();
  6283. });
  6284. };
  6285. const scrollToCurrentDate = () => {
  6286. if (props.poppable && !props.show) {
  6287. return;
  6288. }
  6289. if (currentDate.value) {
  6290. const targetDate = props.type === "single" ? currentDate.value : currentDate.value[0];
  6291. if (isDate(targetDate)) {
  6292. scrollToDate(targetDate);
  6293. }
  6294. } else {
  6295. use.raf(onScroll);
  6296. }
  6297. };
  6298. const init = () => {
  6299. if (props.poppable && !props.show) {
  6300. return;
  6301. }
  6302. use.raf(() => {
  6303. bodyHeight = Math.floor(use.useRect(bodyRef).height);
  6304. });
  6305. scrollToCurrentDate();
  6306. };
  6307. const reset = (date = getInitialDate()) => {
  6308. currentDate.value = date;
  6309. scrollToCurrentDate();
  6310. };
  6311. const checkRange = (date) => {
  6312. const {
  6313. maxRange,
  6314. rangePrompt,
  6315. showRangePrompt
  6316. } = props;
  6317. if (maxRange && calcDateNum(date) > maxRange) {
  6318. if (showRangePrompt) {
  6319. showToast(rangePrompt || t$f("rangePrompt", maxRange));
  6320. }
  6321. emit("overRange");
  6322. return false;
  6323. }
  6324. return true;
  6325. };
  6326. const onConfirm = () => {
  6327. var _a;
  6328. return emit("confirm", (_a = currentDate.value) != null ? _a : cloneDates(currentDate.value));
  6329. };
  6330. const select = (date, complete) => {
  6331. const setCurrentDate = (date2) => {
  6332. currentDate.value = date2;
  6333. emit("select", cloneDates(date2));
  6334. };
  6335. if (complete && props.type === "range") {
  6336. const valid = checkRange(date);
  6337. if (!valid) {
  6338. setCurrentDate([date[0], getDayByOffset(date[0], +props.maxRange - 1)]);
  6339. return;
  6340. }
  6341. }
  6342. setCurrentDate(date);
  6343. if (complete && !props.showConfirm) {
  6344. onConfirm();
  6345. }
  6346. };
  6347. const getDisabledDate = (disabledDays2, startDay, date) => {
  6348. var _a;
  6349. return (_a = disabledDays2.find((day) => compareDay(startDay, day.date) === -1 && compareDay(day.date, date) === -1)) == null ? void 0 : _a.date;
  6350. };
  6351. const disabledDays = vue.computed(() => monthRefs.value.reduce((arr, ref2) => {
  6352. var _a, _b;
  6353. arr.push(...(_b = (_a = ref2.disabledDays) == null ? void 0 : _a.value) != null ? _b : []);
  6354. return arr;
  6355. }, []));
  6356. const onClickDay = (item) => {
  6357. if (props.readonly || !item.date) {
  6358. return;
  6359. }
  6360. const {
  6361. date
  6362. } = item;
  6363. const {
  6364. type
  6365. } = props;
  6366. if (type === "range") {
  6367. if (!currentDate.value) {
  6368. select([date]);
  6369. return;
  6370. }
  6371. const [startDay, endDay] = currentDate.value;
  6372. if (startDay && !endDay) {
  6373. const compareToStart = compareDay(date, startDay);
  6374. if (compareToStart === 1) {
  6375. const disabledDay = getDisabledDate(disabledDays.value, startDay, date);
  6376. if (disabledDay) {
  6377. const endDay2 = getPrevDay(disabledDay);
  6378. if (compareDay(startDay, endDay2) === -1) {
  6379. select([startDay, endDay2]);
  6380. } else {
  6381. select([date]);
  6382. }
  6383. } else {
  6384. select([startDay, date], true);
  6385. }
  6386. } else if (compareToStart === -1) {
  6387. select([date]);
  6388. } else if (props.allowSameDay) {
  6389. select([date, date], true);
  6390. }
  6391. } else {
  6392. select([date]);
  6393. }
  6394. } else if (type === "multiple") {
  6395. if (!currentDate.value) {
  6396. select([date]);
  6397. return;
  6398. }
  6399. const dates = currentDate.value;
  6400. const selectedIndex = dates.findIndex((dateItem) => compareDay(dateItem, date) === 0);
  6401. if (selectedIndex !== -1) {
  6402. const [unselectedDate] = dates.splice(selectedIndex, 1);
  6403. emit("unselect", cloneDate(unselectedDate));
  6404. } else if (props.maxRange && dates.length >= props.maxRange) {
  6405. showToast(props.rangePrompt || t$f("rangePrompt", props.maxRange));
  6406. } else {
  6407. select([...dates, date]);
  6408. }
  6409. } else {
  6410. select(date, true);
  6411. }
  6412. };
  6413. const updateShow = (value) => emit("update:show", value);
  6414. const renderMonth = (date, index) => {
  6415. const showMonthTitle = index !== 0 || !props.showSubtitle;
  6416. return vue.createVNode(stdin_default$16, vue.mergeProps({
  6417. "ref": setMonthRefs(index),
  6418. "date": date,
  6419. "currentDate": currentDate.value,
  6420. "showMonthTitle": showMonthTitle,
  6421. "firstDayOfWeek": dayOffset.value
  6422. }, pick(props, ["type", "color", "minDate", "maxDate", "showMark", "formatter", "rowHeight", "lazyRender", "showSubtitle", "allowSameDay"]), {
  6423. "onClick": onClickDay
  6424. }), pick(slots, ["top-info", "bottom-info"]));
  6425. };
  6426. const renderFooterButton = () => {
  6427. if (slots.footer) {
  6428. return slots.footer();
  6429. }
  6430. if (props.showConfirm) {
  6431. const slot = slots["confirm-text"];
  6432. const disabled = buttonDisabled.value;
  6433. const text = disabled ? props.confirmDisabledText : props.confirmText;
  6434. return vue.createVNode(Button, {
  6435. "round": true,
  6436. "block": true,
  6437. "type": "primary",
  6438. "color": props.color,
  6439. "class": bem$Z("confirm"),
  6440. "disabled": disabled,
  6441. "nativeType": "button",
  6442. "onClick": onConfirm
  6443. }, {
  6444. default: () => [slot ? slot({
  6445. disabled
  6446. }) : text || t$f("confirm")]
  6447. });
  6448. }
  6449. };
  6450. const renderFooter = () => vue.createVNode("div", {
  6451. "class": [bem$Z("footer"), {
  6452. "van-safe-area-bottom": props.safeAreaInsetBottom
  6453. }]
  6454. }, [renderFooterButton()]);
  6455. const renderCalendar = () => vue.createVNode("div", {
  6456. "class": bem$Z()
  6457. }, [vue.createVNode(stdin_default$15, {
  6458. "date": subtitle.value.date,
  6459. "title": props.title,
  6460. "subtitle": subtitle.value.text,
  6461. "showTitle": props.showTitle,
  6462. "showSubtitle": props.showSubtitle,
  6463. "firstDayOfWeek": dayOffset.value,
  6464. "onClickSubtitle": (event) => emit("clickSubtitle", event)
  6465. }, pick(slots, ["title", "subtitle"])), vue.createVNode("div", {
  6466. "ref": bodyRef,
  6467. "class": bem$Z("body"),
  6468. "onScroll": onScroll
  6469. }, [months.value.map(renderMonth)]), renderFooter()]);
  6470. vue.watch(() => props.show, init);
  6471. vue.watch(() => [props.type, props.minDate, props.maxDate], () => reset(getInitialDate(currentDate.value)));
  6472. vue.watch(() => props.defaultDate, (value = null) => {
  6473. currentDate.value = value;
  6474. scrollToCurrentDate();
  6475. });
  6476. useExpose({
  6477. reset,
  6478. scrollToDate,
  6479. getSelectedDate
  6480. });
  6481. use.onMountedOrActivated(init);
  6482. return () => {
  6483. if (props.poppable) {
  6484. return vue.createVNode(Popup, {
  6485. "show": props.show,
  6486. "class": bem$Z("popup"),
  6487. "round": props.round,
  6488. "position": props.position,
  6489. "closeable": props.showTitle || props.showSubtitle,
  6490. "teleport": props.teleport,
  6491. "closeOnPopstate": props.closeOnPopstate,
  6492. "safeAreaInsetTop": props.safeAreaInsetTop,
  6493. "closeOnClickOverlay": props.closeOnClickOverlay,
  6494. "onUpdate:show": updateShow
  6495. }, {
  6496. default: renderCalendar
  6497. });
  6498. }
  6499. return renderCalendar();
  6500. };
  6501. }
  6502. });
  6503. const Calendar = withInstall(stdin_default$14);
  6504. const [name$Z, bem$Y] = createNamespace("image");
  6505. const imageProps = {
  6506. src: String,
  6507. alt: String,
  6508. fit: String,
  6509. position: String,
  6510. round: Boolean,
  6511. block: Boolean,
  6512. width: numericProp,
  6513. height: numericProp,
  6514. radius: numericProp,
  6515. lazyLoad: Boolean,
  6516. iconSize: numericProp,
  6517. showError: truthProp,
  6518. errorIcon: makeStringProp("photo-fail"),
  6519. iconPrefix: String,
  6520. showLoading: truthProp,
  6521. loadingIcon: makeStringProp("photo")
  6522. };
  6523. var stdin_default$13 = vue.defineComponent({
  6524. name: name$Z,
  6525. props: imageProps,
  6526. emits: ["load", "error"],
  6527. setup(props, {
  6528. emit,
  6529. slots
  6530. }) {
  6531. const error = vue.ref(false);
  6532. const loading = vue.ref(true);
  6533. const imageRef = vue.ref();
  6534. const {
  6535. $Lazyload
  6536. } = vue.getCurrentInstance().proxy;
  6537. const style = vue.computed(() => {
  6538. const style2 = {
  6539. width: addUnit(props.width),
  6540. height: addUnit(props.height)
  6541. };
  6542. if (isDef(props.radius)) {
  6543. style2.overflow = "hidden";
  6544. style2.borderRadius = addUnit(props.radius);
  6545. }
  6546. return style2;
  6547. });
  6548. vue.watch(() => props.src, () => {
  6549. error.value = false;
  6550. loading.value = true;
  6551. });
  6552. const onLoad = (event) => {
  6553. if (loading.value) {
  6554. loading.value = false;
  6555. emit("load", event);
  6556. }
  6557. };
  6558. const triggerLoad = () => {
  6559. const loadEvent = new Event("load");
  6560. Object.defineProperty(loadEvent, "target", {
  6561. value: imageRef.value,
  6562. enumerable: true
  6563. });
  6564. onLoad(loadEvent);
  6565. };
  6566. const onError = (event) => {
  6567. error.value = true;
  6568. loading.value = false;
  6569. emit("error", event);
  6570. };
  6571. const renderIcon = (name2, className, slot) => {
  6572. if (slot) {
  6573. return slot();
  6574. }
  6575. return vue.createVNode(Icon, {
  6576. "name": name2,
  6577. "size": props.iconSize,
  6578. "class": className,
  6579. "classPrefix": props.iconPrefix
  6580. }, null);
  6581. };
  6582. const renderPlaceholder = () => {
  6583. if (loading.value && props.showLoading) {
  6584. return vue.createVNode("div", {
  6585. "class": bem$Y("loading")
  6586. }, [renderIcon(props.loadingIcon, bem$Y("loading-icon"), slots.loading)]);
  6587. }
  6588. if (error.value && props.showError) {
  6589. return vue.createVNode("div", {
  6590. "class": bem$Y("error")
  6591. }, [renderIcon(props.errorIcon, bem$Y("error-icon"), slots.error)]);
  6592. }
  6593. };
  6594. const renderImage = () => {
  6595. if (error.value || !props.src) {
  6596. return;
  6597. }
  6598. const attrs = {
  6599. alt: props.alt,
  6600. class: bem$Y("img"),
  6601. style: {
  6602. objectFit: props.fit,
  6603. objectPosition: props.position
  6604. }
  6605. };
  6606. if (props.lazyLoad) {
  6607. return vue.withDirectives(vue.createVNode("img", vue.mergeProps({
  6608. "ref": imageRef
  6609. }, attrs), null), [[vue.resolveDirective("lazy"), props.src]]);
  6610. }
  6611. return vue.createVNode("img", vue.mergeProps({
  6612. "ref": imageRef,
  6613. "src": props.src,
  6614. "onLoad": onLoad,
  6615. "onError": onError
  6616. }, attrs), null);
  6617. };
  6618. const onLazyLoaded = ({
  6619. el
  6620. }) => {
  6621. const check = () => {
  6622. if (el === imageRef.value && loading.value) {
  6623. triggerLoad();
  6624. }
  6625. };
  6626. if (imageRef.value) {
  6627. check();
  6628. } else {
  6629. vue.nextTick(check);
  6630. }
  6631. };
  6632. const onLazyLoadError = ({
  6633. el
  6634. }) => {
  6635. if (el === imageRef.value && !error.value) {
  6636. onError();
  6637. }
  6638. };
  6639. if ($Lazyload && inBrowser) {
  6640. $Lazyload.$on("loaded", onLazyLoaded);
  6641. $Lazyload.$on("error", onLazyLoadError);
  6642. vue.onBeforeUnmount(() => {
  6643. $Lazyload.$off("loaded", onLazyLoaded);
  6644. $Lazyload.$off("error", onLazyLoadError);
  6645. });
  6646. }
  6647. vue.onMounted(() => {
  6648. vue.nextTick(() => {
  6649. var _a;
  6650. if ((_a = imageRef.value) == null ? void 0 : _a.complete) {
  6651. triggerLoad();
  6652. }
  6653. });
  6654. });
  6655. return () => {
  6656. var _a;
  6657. return vue.createVNode("div", {
  6658. "class": bem$Y({
  6659. round: props.round,
  6660. block: props.block
  6661. }),
  6662. "style": style.value
  6663. }, [renderImage(), renderPlaceholder(), (_a = slots.default) == null ? void 0 : _a.call(slots)]);
  6664. };
  6665. }
  6666. });
  6667. const Image$1 = withInstall(stdin_default$13);
  6668. const [name$Y, bem$X] = createNamespace("card");
  6669. const cardProps = {
  6670. tag: String,
  6671. num: numericProp,
  6672. desc: String,
  6673. thumb: String,
  6674. title: String,
  6675. price: numericProp,
  6676. centered: Boolean,
  6677. lazyLoad: Boolean,
  6678. currency: makeStringProp("\xA5"),
  6679. thumbLink: String,
  6680. originPrice: numericProp
  6681. };
  6682. var stdin_default$12 = vue.defineComponent({
  6683. name: name$Y,
  6684. props: cardProps,
  6685. emits: ["clickThumb"],
  6686. setup(props, {
  6687. slots,
  6688. emit
  6689. }) {
  6690. const renderTitle = () => {
  6691. if (slots.title) {
  6692. return slots.title();
  6693. }
  6694. if (props.title) {
  6695. return vue.createVNode("div", {
  6696. "class": [bem$X("title"), "van-multi-ellipsis--l2"]
  6697. }, [props.title]);
  6698. }
  6699. };
  6700. const renderThumbTag = () => {
  6701. if (slots.tag || props.tag) {
  6702. return vue.createVNode("div", {
  6703. "class": bem$X("tag")
  6704. }, [slots.tag ? slots.tag() : vue.createVNode(Tag, {
  6705. "mark": true,
  6706. "type": "primary"
  6707. }, {
  6708. default: () => [props.tag]
  6709. })]);
  6710. }
  6711. };
  6712. const renderThumbImage = () => {
  6713. if (slots.thumb) {
  6714. return slots.thumb();
  6715. }
  6716. return vue.createVNode(Image$1, {
  6717. "src": props.thumb,
  6718. "fit": "cover",
  6719. "width": "100%",
  6720. "height": "100%",
  6721. "lazyLoad": props.lazyLoad
  6722. }, null);
  6723. };
  6724. const renderThumb = () => {
  6725. if (slots.thumb || props.thumb) {
  6726. return vue.createVNode("a", {
  6727. "href": props.thumbLink,
  6728. "class": bem$X("thumb"),
  6729. "onClick": (event) => emit("clickThumb", event)
  6730. }, [renderThumbImage(), renderThumbTag()]);
  6731. }
  6732. };
  6733. const renderDesc = () => {
  6734. if (slots.desc) {
  6735. return slots.desc();
  6736. }
  6737. if (props.desc) {
  6738. return vue.createVNode("div", {
  6739. "class": [bem$X("desc"), "van-ellipsis"]
  6740. }, [props.desc]);
  6741. }
  6742. };
  6743. const renderPriceText = () => {
  6744. const priceArr = props.price.toString().split(".");
  6745. return vue.createVNode("div", null, [vue.createVNode("span", {
  6746. "class": bem$X("price-currency")
  6747. }, [props.currency]), vue.createVNode("span", {
  6748. "class": bem$X("price-integer")
  6749. }, [priceArr[0]]), vue.createTextVNode("."), vue.createVNode("span", {
  6750. "class": bem$X("price-decimal")
  6751. }, [priceArr[1]])]);
  6752. };
  6753. return () => {
  6754. var _a, _b, _c;
  6755. const showNum = slots.num || isDef(props.num);
  6756. const showPrice = slots.price || isDef(props.price);
  6757. const showOriginPrice = slots["origin-price"] || isDef(props.originPrice);
  6758. const showBottom = showNum || showPrice || showOriginPrice || slots.bottom;
  6759. const Price = showPrice && vue.createVNode("div", {
  6760. "class": bem$X("price")
  6761. }, [slots.price ? slots.price() : renderPriceText()]);
  6762. const OriginPrice = showOriginPrice && vue.createVNode("div", {
  6763. "class": bem$X("origin-price")
  6764. }, [slots["origin-price"] ? slots["origin-price"]() : `${props.currency} ${props.originPrice}`]);
  6765. const Num = showNum && vue.createVNode("div", {
  6766. "class": bem$X("num")
  6767. }, [slots.num ? slots.num() : `x${props.num}`]);
  6768. const Footer = slots.footer && vue.createVNode("div", {
  6769. "class": bem$X("footer")
  6770. }, [slots.footer()]);
  6771. const Bottom = showBottom && vue.createVNode("div", {
  6772. "class": bem$X("bottom")
  6773. }, [(_a = slots["price-top"]) == null ? void 0 : _a.call(slots), Price, OriginPrice, Num, (_b = slots.bottom) == null ? void 0 : _b.call(slots)]);
  6774. return vue.createVNode("div", {
  6775. "class": bem$X()
  6776. }, [vue.createVNode("div", {
  6777. "class": bem$X("header")
  6778. }, [renderThumb(), vue.createVNode("div", {
  6779. "class": bem$X("content", {
  6780. centered: props.centered
  6781. })
  6782. }, [vue.createVNode("div", null, [renderTitle(), renderDesc(), (_c = slots.tags) == null ? void 0 : _c.call(slots)]), Bottom])]), Footer]);
  6783. };
  6784. }
  6785. });
  6786. const Card = withInstall(stdin_default$12);
  6787. const [name$X, bem$W, t$e] = createNamespace("cascader");
  6788. const cascaderProps = {
  6789. title: String,
  6790. options: makeArrayProp(),
  6791. closeable: truthProp,
  6792. swipeable: truthProp,
  6793. closeIcon: makeStringProp("cross"),
  6794. showHeader: truthProp,
  6795. modelValue: numericProp,
  6796. fieldNames: Object,
  6797. placeholder: String,
  6798. activeColor: String
  6799. };
  6800. var stdin_default$11 = vue.defineComponent({
  6801. name: name$X,
  6802. props: cascaderProps,
  6803. emits: ["close", "change", "finish", "clickTab", "update:modelValue"],
  6804. setup(props, {
  6805. slots,
  6806. emit
  6807. }) {
  6808. const tabs = vue.ref([]);
  6809. const activeTab = vue.ref(0);
  6810. const {
  6811. text: textKey,
  6812. value: valueKey,
  6813. children: childrenKey
  6814. } = extend({
  6815. text: "text",
  6816. value: "value",
  6817. children: "children"
  6818. }, props.fieldNames);
  6819. const getSelectedOptionsByValue = (options, value) => {
  6820. for (const option of options) {
  6821. if (option[valueKey] === value) {
  6822. return [option];
  6823. }
  6824. if (option[childrenKey]) {
  6825. const selectedOptions = getSelectedOptionsByValue(option[childrenKey], value);
  6826. if (selectedOptions) {
  6827. return [option, ...selectedOptions];
  6828. }
  6829. }
  6830. }
  6831. };
  6832. const updateTabs = () => {
  6833. const {
  6834. options,
  6835. modelValue
  6836. } = props;
  6837. if (modelValue !== void 0) {
  6838. const selectedOptions = getSelectedOptionsByValue(options, modelValue);
  6839. if (selectedOptions) {
  6840. let optionsCursor = options;
  6841. tabs.value = selectedOptions.map((option) => {
  6842. const tab = {
  6843. options: optionsCursor,
  6844. selected: option
  6845. };
  6846. const next = optionsCursor.find((item) => item[valueKey] === option[valueKey]);
  6847. if (next) {
  6848. optionsCursor = next[childrenKey];
  6849. }
  6850. return tab;
  6851. });
  6852. if (optionsCursor) {
  6853. tabs.value.push({
  6854. options: optionsCursor,
  6855. selected: null
  6856. });
  6857. }
  6858. vue.nextTick(() => {
  6859. activeTab.value = tabs.value.length - 1;
  6860. });
  6861. return;
  6862. }
  6863. }
  6864. tabs.value = [{
  6865. options,
  6866. selected: null
  6867. }];
  6868. };
  6869. const onSelect = (option, tabIndex) => {
  6870. if (option.disabled) {
  6871. return;
  6872. }
  6873. tabs.value[tabIndex].selected = option;
  6874. if (tabs.value.length > tabIndex + 1) {
  6875. tabs.value = tabs.value.slice(0, tabIndex + 1);
  6876. }
  6877. if (option[childrenKey]) {
  6878. const nextTab = {
  6879. options: option[childrenKey],
  6880. selected: null
  6881. };
  6882. if (tabs.value[tabIndex + 1]) {
  6883. tabs.value[tabIndex + 1] = nextTab;
  6884. } else {
  6885. tabs.value.push(nextTab);
  6886. }
  6887. vue.nextTick(() => {
  6888. activeTab.value++;
  6889. });
  6890. }
  6891. const selectedOptions = tabs.value.map((tab) => tab.selected).filter(Boolean);
  6892. emit("update:modelValue", option[valueKey]);
  6893. const params = {
  6894. value: option[valueKey],
  6895. tabIndex,
  6896. selectedOptions
  6897. };
  6898. emit("change", params);
  6899. if (!option[childrenKey]) {
  6900. emit("finish", params);
  6901. }
  6902. };
  6903. const onClose = () => emit("close");
  6904. const onClickTab = ({
  6905. name: name2,
  6906. title
  6907. }) => emit("clickTab", name2, title);
  6908. const renderHeader = () => props.showHeader ? vue.createVNode("div", {
  6909. "class": bem$W("header")
  6910. }, [vue.createVNode("h2", {
  6911. "class": bem$W("title")
  6912. }, [slots.title ? slots.title() : props.title]), props.closeable ? vue.createVNode(Icon, {
  6913. "name": props.closeIcon,
  6914. "class": [bem$W("close-icon"), HAPTICS_FEEDBACK],
  6915. "onClick": onClose
  6916. }, null) : null]) : null;
  6917. const renderOption = (option, selectedOption, tabIndex) => {
  6918. const {
  6919. disabled
  6920. } = option;
  6921. const selected = !!(selectedOption && option[valueKey] === selectedOption[valueKey]);
  6922. const color = option.color || (selected ? props.activeColor : void 0);
  6923. const Text2 = slots.option ? slots.option({
  6924. option,
  6925. selected
  6926. }) : vue.createVNode("span", null, [option[textKey]]);
  6927. return vue.createVNode("li", {
  6928. "role": "menuitemradio",
  6929. "class": [bem$W("option", {
  6930. selected,
  6931. disabled
  6932. }), option.className],
  6933. "style": {
  6934. color
  6935. },
  6936. "tabindex": disabled ? void 0 : selected ? 0 : -1,
  6937. "aria-checked": selected,
  6938. "aria-disabled": disabled || void 0,
  6939. "onClick": () => onSelect(option, tabIndex)
  6940. }, [Text2, selected ? vue.createVNode(Icon, {
  6941. "name": "success",
  6942. "class": bem$W("selected-icon")
  6943. }, null) : null]);
  6944. };
  6945. const renderOptions = (options, selectedOption, tabIndex) => vue.createVNode("ul", {
  6946. "role": "menu",
  6947. "class": bem$W("options")
  6948. }, [options.map((option) => renderOption(option, selectedOption, tabIndex))]);
  6949. const renderTab = (tab, tabIndex) => {
  6950. const {
  6951. options,
  6952. selected
  6953. } = tab;
  6954. const placeholder = props.placeholder || t$e("select");
  6955. const title = selected ? selected[textKey] : placeholder;
  6956. return vue.createVNode(Tab, {
  6957. "title": title,
  6958. "titleClass": bem$W("tab", {
  6959. unselected: !selected
  6960. })
  6961. }, {
  6962. default: () => {
  6963. var _a, _b;
  6964. return [(_a = slots["options-top"]) == null ? void 0 : _a.call(slots, {
  6965. tabIndex
  6966. }), renderOptions(options, selected, tabIndex), (_b = slots["options-bottom"]) == null ? void 0 : _b.call(slots, {
  6967. tabIndex
  6968. })];
  6969. }
  6970. });
  6971. };
  6972. const renderTabs = () => vue.createVNode(Tabs, {
  6973. "active": activeTab.value,
  6974. "onUpdate:active": ($event) => activeTab.value = $event,
  6975. "shrink": true,
  6976. "animated": true,
  6977. "class": bem$W("tabs"),
  6978. "color": props.activeColor,
  6979. "swipeable": props.swipeable,
  6980. "onClickTab": onClickTab
  6981. }, {
  6982. default: () => [tabs.value.map(renderTab)]
  6983. });
  6984. updateTabs();
  6985. vue.watch(() => props.options, updateTabs, {
  6986. deep: true
  6987. });
  6988. vue.watch(() => props.modelValue, (value) => {
  6989. if (value !== void 0) {
  6990. const values = tabs.value.map((tab) => {
  6991. var _a;
  6992. return (_a = tab.selected) == null ? void 0 : _a[valueKey];
  6993. });
  6994. if (values.includes(value)) {
  6995. return;
  6996. }
  6997. }
  6998. updateTabs();
  6999. });
  7000. return () => vue.createVNode("div", {
  7001. "class": bem$W()
  7002. }, [renderHeader(), renderTabs()]);
  7003. }
  7004. });
  7005. const Cascader = withInstall(stdin_default$11);
  7006. const [name$W, bem$V] = createNamespace("cell-group");
  7007. const cellGroupProps = {
  7008. title: String,
  7009. inset: Boolean,
  7010. border: truthProp
  7011. };
  7012. var stdin_default$10 = vue.defineComponent({
  7013. name: name$W,
  7014. inheritAttrs: false,
  7015. props: cellGroupProps,
  7016. setup(props, {
  7017. slots,
  7018. attrs
  7019. }) {
  7020. const renderGroup = () => {
  7021. var _a;
  7022. return vue.createVNode("div", vue.mergeProps({
  7023. "class": [bem$V({
  7024. inset: props.inset
  7025. }), {
  7026. [BORDER_TOP_BOTTOM]: props.border && !props.inset
  7027. }]
  7028. }, attrs), [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
  7029. };
  7030. const renderTitle = () => vue.createVNode("div", {
  7031. "class": bem$V("title", {
  7032. inset: props.inset
  7033. })
  7034. }, [slots.title ? slots.title() : props.title]);
  7035. return () => {
  7036. if (props.title || slots.title) {
  7037. return vue.createVNode(vue.Fragment, null, [renderTitle(), renderGroup()]);
  7038. }
  7039. return renderGroup();
  7040. };
  7041. }
  7042. });
  7043. const CellGroup = withInstall(stdin_default$10);
  7044. const [name$V, bem$U] = createNamespace("checkbox-group");
  7045. const checkboxGroupProps = {
  7046. max: numericProp,
  7047. disabled: Boolean,
  7048. iconSize: numericProp,
  7049. direction: String,
  7050. modelValue: makeArrayProp(),
  7051. checkedColor: String
  7052. };
  7053. const CHECKBOX_GROUP_KEY = Symbol(name$V);
  7054. var stdin_default$$ = vue.defineComponent({
  7055. name: name$V,
  7056. props: checkboxGroupProps,
  7057. emits: ["change", "update:modelValue"],
  7058. setup(props, {
  7059. emit,
  7060. slots
  7061. }) {
  7062. const {
  7063. children,
  7064. linkChildren
  7065. } = use.useChildren(CHECKBOX_GROUP_KEY);
  7066. const updateValue = (value) => emit("update:modelValue", value);
  7067. const toggleAll = (options = {}) => {
  7068. if (typeof options === "boolean") {
  7069. options = {
  7070. checked: options
  7071. };
  7072. }
  7073. const {
  7074. checked,
  7075. skipDisabled
  7076. } = options;
  7077. const checkedChildren = children.filter((item) => {
  7078. if (!item.props.bindGroup) {
  7079. return false;
  7080. }
  7081. if (item.props.disabled && skipDisabled) {
  7082. return item.checked.value;
  7083. }
  7084. return checked != null ? checked : !item.checked.value;
  7085. });
  7086. const names = checkedChildren.map((item) => item.name);
  7087. updateValue(names);
  7088. };
  7089. vue.watch(() => props.modelValue, (value) => emit("change", value));
  7090. useExpose({
  7091. toggleAll
  7092. });
  7093. use.useCustomFieldValue(() => props.modelValue);
  7094. linkChildren({
  7095. props,
  7096. updateValue
  7097. });
  7098. return () => {
  7099. var _a;
  7100. return vue.createVNode("div", {
  7101. "class": bem$U([props.direction])
  7102. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
  7103. };
  7104. }
  7105. });
  7106. const [name$U, bem$T] = createNamespace("checkbox");
  7107. const checkboxProps = extend({}, checkerProps, {
  7108. bindGroup: truthProp
  7109. });
  7110. var stdin_default$_ = vue.defineComponent({
  7111. name: name$U,
  7112. props: checkboxProps,
  7113. emits: ["change", "update:modelValue"],
  7114. setup(props, {
  7115. emit,
  7116. slots
  7117. }) {
  7118. const {
  7119. parent
  7120. } = use.useParent(CHECKBOX_GROUP_KEY);
  7121. const setParentValue = (checked2) => {
  7122. const {
  7123. name: name2
  7124. } = props;
  7125. const {
  7126. max,
  7127. modelValue
  7128. } = parent.props;
  7129. const value = modelValue.slice();
  7130. if (checked2) {
  7131. const overlimit = max && value.length >= max;
  7132. if (!overlimit && !value.includes(name2)) {
  7133. value.push(name2);
  7134. if (props.bindGroup) {
  7135. parent.updateValue(value);
  7136. }
  7137. }
  7138. } else {
  7139. const index = value.indexOf(name2);
  7140. if (index !== -1) {
  7141. value.splice(index, 1);
  7142. if (props.bindGroup) {
  7143. parent.updateValue(value);
  7144. }
  7145. }
  7146. }
  7147. };
  7148. const checked = vue.computed(() => {
  7149. if (parent && props.bindGroup) {
  7150. return parent.props.modelValue.indexOf(props.name) !== -1;
  7151. }
  7152. return !!props.modelValue;
  7153. });
  7154. const toggle = (newValue = !checked.value) => {
  7155. if (parent && props.bindGroup) {
  7156. setParentValue(newValue);
  7157. } else {
  7158. emit("update:modelValue", newValue);
  7159. }
  7160. };
  7161. vue.watch(() => props.modelValue, (value) => emit("change", value));
  7162. useExpose({
  7163. toggle,
  7164. props,
  7165. checked
  7166. });
  7167. use.useCustomFieldValue(() => props.modelValue);
  7168. return () => vue.createVNode(stdin_default$1c, vue.mergeProps({
  7169. "bem": bem$T,
  7170. "role": "checkbox",
  7171. "parent": parent,
  7172. "checked": checked.value,
  7173. "onToggle": toggle
  7174. }, props), pick(slots, ["default", "icon"]));
  7175. }
  7176. });
  7177. const Checkbox = withInstall(stdin_default$_);
  7178. const CheckboxGroup = withInstall(stdin_default$$);
  7179. const [name$T, bem$S] = createNamespace("circle");
  7180. let uid = 0;
  7181. const format = (rate) => Math.min(Math.max(+rate, 0), 100);
  7182. function getPath(clockwise, viewBoxSize) {
  7183. const sweepFlag = clockwise ? 1 : 0;
  7184. 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`;
  7185. }
  7186. const circleProps = {
  7187. text: String,
  7188. size: numericProp,
  7189. fill: makeStringProp("none"),
  7190. rate: makeNumericProp(100),
  7191. speed: makeNumericProp(0),
  7192. color: [String, Object],
  7193. clockwise: truthProp,
  7194. layerColor: String,
  7195. currentRate: makeNumberProp(0),
  7196. strokeWidth: makeNumericProp(40),
  7197. strokeLinecap: String,
  7198. startPosition: makeStringProp("top")
  7199. };
  7200. var stdin_default$Z = vue.defineComponent({
  7201. name: name$T,
  7202. props: circleProps,
  7203. emits: ["update:currentRate"],
  7204. setup(props, {
  7205. emit,
  7206. slots
  7207. }) {
  7208. const id = `van-circle-${uid++}`;
  7209. const viewBoxSize = vue.computed(() => +props.strokeWidth + 1e3);
  7210. const path = vue.computed(() => getPath(props.clockwise, viewBoxSize.value));
  7211. const svgStyle = vue.computed(() => {
  7212. const ROTATE_ANGLE_MAP = {
  7213. top: 0,
  7214. right: 90,
  7215. bottom: 180,
  7216. left: 270
  7217. };
  7218. const angleValue = ROTATE_ANGLE_MAP[props.startPosition];
  7219. if (angleValue) {
  7220. return {
  7221. transform: `rotate(${angleValue}deg)`
  7222. };
  7223. }
  7224. });
  7225. vue.watch(() => props.rate, (rate) => {
  7226. let rafId;
  7227. const startTime = Date.now();
  7228. const startRate = props.currentRate;
  7229. const endRate = format(rate);
  7230. const duration = Math.abs((startRate - endRate) * 1e3 / +props.speed);
  7231. const animate = () => {
  7232. const now = Date.now();
  7233. const progress = Math.min((now - startTime) / duration, 1);
  7234. const rate2 = progress * (endRate - startRate) + startRate;
  7235. emit("update:currentRate", format(parseFloat(rate2.toFixed(1))));
  7236. if (endRate > startRate ? rate2 < endRate : rate2 > endRate) {
  7237. rafId = use.raf(animate);
  7238. }
  7239. };
  7240. if (props.speed) {
  7241. if (rafId) {
  7242. use.cancelRaf(rafId);
  7243. }
  7244. rafId = use.raf(animate);
  7245. } else {
  7246. emit("update:currentRate", endRate);
  7247. }
  7248. }, {
  7249. immediate: true
  7250. });
  7251. const renderHover = () => {
  7252. const PERIMETER = 3140;
  7253. const {
  7254. strokeWidth,
  7255. currentRate,
  7256. strokeLinecap
  7257. } = props;
  7258. const offset = PERIMETER * currentRate / 100;
  7259. const color = isObject(props.color) ? `url(#${id})` : props.color;
  7260. const style = {
  7261. stroke: color,
  7262. strokeWidth: `${+strokeWidth + 1}px`,
  7263. strokeLinecap,
  7264. strokeDasharray: `${offset}px ${PERIMETER}px`
  7265. };
  7266. return vue.createVNode("path", {
  7267. "d": path.value,
  7268. "style": style,
  7269. "class": bem$S("hover"),
  7270. "stroke": color
  7271. }, null);
  7272. };
  7273. const renderLayer = () => {
  7274. const style = {
  7275. fill: props.fill,
  7276. stroke: props.layerColor,
  7277. strokeWidth: `${props.strokeWidth}px`
  7278. };
  7279. return vue.createVNode("path", {
  7280. "class": bem$S("layer"),
  7281. "style": style,
  7282. "d": path.value
  7283. }, null);
  7284. };
  7285. const renderGradient = () => {
  7286. const {
  7287. color
  7288. } = props;
  7289. if (!isObject(color)) {
  7290. return;
  7291. }
  7292. const Stops = Object.keys(color).sort((a, b) => parseFloat(a) - parseFloat(b)).map((key, index) => vue.createVNode("stop", {
  7293. "key": index,
  7294. "offset": key,
  7295. "stop-color": color[key]
  7296. }, null));
  7297. return vue.createVNode("defs", null, [vue.createVNode("linearGradient", {
  7298. "id": id,
  7299. "x1": "100%",
  7300. "y1": "0%",
  7301. "x2": "0%",
  7302. "y2": "0%"
  7303. }, [Stops])]);
  7304. };
  7305. const renderText = () => {
  7306. if (slots.default) {
  7307. return slots.default();
  7308. }
  7309. if (props.text) {
  7310. return vue.createVNode("div", {
  7311. "class": bem$S("text")
  7312. }, [props.text]);
  7313. }
  7314. };
  7315. return () => vue.createVNode("div", {
  7316. "class": bem$S(),
  7317. "style": getSizeStyle(props.size)
  7318. }, [vue.createVNode("svg", {
  7319. "viewBox": `0 0 ${viewBoxSize.value} ${viewBoxSize.value}`,
  7320. "style": svgStyle.value
  7321. }, [renderGradient(), renderLayer(), renderHover()]), renderText()]);
  7322. }
  7323. });
  7324. const Circle = withInstall(stdin_default$Z);
  7325. const [name$S, bem$R] = createNamespace("row");
  7326. const ROW_KEY = Symbol(name$S);
  7327. const rowProps = {
  7328. tag: makeStringProp("div"),
  7329. wrap: truthProp,
  7330. align: String,
  7331. gutter: makeNumericProp(0),
  7332. justify: String
  7333. };
  7334. var stdin_default$Y = vue.defineComponent({
  7335. name: name$S,
  7336. props: rowProps,
  7337. setup(props, {
  7338. slots
  7339. }) {
  7340. const {
  7341. children,
  7342. linkChildren
  7343. } = use.useChildren(ROW_KEY);
  7344. const groups = vue.computed(() => {
  7345. const groups2 = [[]];
  7346. let totalSpan = 0;
  7347. children.forEach((child, index) => {
  7348. totalSpan += Number(child.span);
  7349. if (totalSpan > 24) {
  7350. groups2.push([index]);
  7351. totalSpan -= 24;
  7352. } else {
  7353. groups2[groups2.length - 1].push(index);
  7354. }
  7355. });
  7356. return groups2;
  7357. });
  7358. const spaces = vue.computed(() => {
  7359. const gutter = Number(props.gutter);
  7360. const spaces2 = [];
  7361. if (!gutter) {
  7362. return spaces2;
  7363. }
  7364. groups.value.forEach((group) => {
  7365. const averagePadding = gutter * (group.length - 1) / group.length;
  7366. group.forEach((item, index) => {
  7367. if (index === 0) {
  7368. spaces2.push({
  7369. right: averagePadding
  7370. });
  7371. } else {
  7372. const left = gutter - spaces2[item - 1].right;
  7373. const right = averagePadding - left;
  7374. spaces2.push({
  7375. left,
  7376. right
  7377. });
  7378. }
  7379. });
  7380. });
  7381. return spaces2;
  7382. });
  7383. linkChildren({
  7384. spaces
  7385. });
  7386. return () => {
  7387. const {
  7388. tag,
  7389. wrap,
  7390. align,
  7391. justify
  7392. } = props;
  7393. return vue.createVNode(tag, {
  7394. "class": bem$R({
  7395. [`align-${align}`]: align,
  7396. [`justify-${justify}`]: justify,
  7397. nowrap: !wrap
  7398. })
  7399. }, {
  7400. default: () => {
  7401. var _a;
  7402. return [(_a = slots.default) == null ? void 0 : _a.call(slots)];
  7403. }
  7404. });
  7405. };
  7406. }
  7407. });
  7408. const [name$R, bem$Q] = createNamespace("col");
  7409. const colProps = {
  7410. tag: makeStringProp("div"),
  7411. span: makeNumericProp(0),
  7412. offset: numericProp
  7413. };
  7414. var stdin_default$X = vue.defineComponent({
  7415. name: name$R,
  7416. props: colProps,
  7417. setup(props, {
  7418. slots
  7419. }) {
  7420. const {
  7421. parent,
  7422. index
  7423. } = use.useParent(ROW_KEY);
  7424. const style = vue.computed(() => {
  7425. if (!parent) {
  7426. return;
  7427. }
  7428. const {
  7429. spaces
  7430. } = parent;
  7431. if (spaces && spaces.value && spaces.value[index.value]) {
  7432. const {
  7433. left,
  7434. right
  7435. } = spaces.value[index.value];
  7436. return {
  7437. paddingLeft: left ? `${left}px` : null,
  7438. paddingRight: right ? `${right}px` : null
  7439. };
  7440. }
  7441. });
  7442. return () => {
  7443. const {
  7444. tag,
  7445. span,
  7446. offset
  7447. } = props;
  7448. return vue.createVNode(tag, {
  7449. "style": style.value,
  7450. "class": bem$Q({
  7451. [span]: span,
  7452. [`offset-${offset}`]: offset
  7453. })
  7454. }, {
  7455. default: () => {
  7456. var _a;
  7457. return [(_a = slots.default) == null ? void 0 : _a.call(slots)];
  7458. }
  7459. });
  7460. };
  7461. }
  7462. });
  7463. const Col = withInstall(stdin_default$X);
  7464. const [name$Q, bem$P] = createNamespace("collapse");
  7465. const COLLAPSE_KEY = Symbol(name$Q);
  7466. const collapseProps = {
  7467. border: truthProp,
  7468. accordion: Boolean,
  7469. modelValue: {
  7470. type: [String, Number, Array],
  7471. default: ""
  7472. }
  7473. };
  7474. function validateModelValue(modelValue, accordion) {
  7475. if (accordion && Array.isArray(modelValue)) {
  7476. console.error('[Vant] Collapse: "v-model" should not be Array in accordion mode');
  7477. return false;
  7478. }
  7479. if (!accordion && !Array.isArray(modelValue)) {
  7480. console.error('[Vant] Collapse: "v-model" should be Array in non-accordion mode');
  7481. return false;
  7482. }
  7483. return true;
  7484. }
  7485. var stdin_default$W = vue.defineComponent({
  7486. name: name$Q,
  7487. props: collapseProps,
  7488. emits: ["change", "update:modelValue"],
  7489. setup(props, {
  7490. emit,
  7491. slots
  7492. }) {
  7493. const {
  7494. linkChildren,
  7495. children
  7496. } = use.useChildren(COLLAPSE_KEY);
  7497. const updateName = (name2) => {
  7498. emit("change", name2);
  7499. emit("update:modelValue", name2);
  7500. };
  7501. const toggle = (name2, expanded) => {
  7502. const {
  7503. accordion,
  7504. modelValue
  7505. } = props;
  7506. if (accordion) {
  7507. updateName(name2 === modelValue ? "" : name2);
  7508. } else if (expanded) {
  7509. updateName(modelValue.concat(name2));
  7510. } else {
  7511. updateName(modelValue.filter((activeName) => activeName !== name2));
  7512. }
  7513. };
  7514. const toggleAll = (options = {}) => {
  7515. if (props.accordion) {
  7516. return;
  7517. }
  7518. if (typeof options === "boolean") {
  7519. options = {
  7520. expanded: options
  7521. };
  7522. }
  7523. const {
  7524. expanded,
  7525. skipDisabled
  7526. } = options;
  7527. const expandedChildren = children.filter((item) => {
  7528. if (item.disabled && skipDisabled) {
  7529. return item.expanded.value;
  7530. }
  7531. return expanded != null ? expanded : !item.expanded.value;
  7532. });
  7533. const names = expandedChildren.map((item) => item.itemName.value);
  7534. updateName(names);
  7535. };
  7536. const isExpanded = (name2) => {
  7537. const {
  7538. accordion,
  7539. modelValue
  7540. } = props;
  7541. if (process.env.NODE_ENV !== "production" && !validateModelValue(modelValue, accordion)) {
  7542. return false;
  7543. }
  7544. return accordion ? modelValue === name2 : modelValue.includes(name2);
  7545. };
  7546. useExpose({
  7547. toggleAll
  7548. });
  7549. linkChildren({
  7550. toggle,
  7551. isExpanded
  7552. });
  7553. return () => {
  7554. var _a;
  7555. return vue.createVNode("div", {
  7556. "class": [bem$P(), {
  7557. [BORDER_TOP_BOTTOM]: props.border
  7558. }]
  7559. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
  7560. };
  7561. }
  7562. });
  7563. const Collapse = withInstall(stdin_default$W);
  7564. const [name$P, bem$O] = createNamespace("collapse-item");
  7565. const CELL_SLOTS = ["icon", "title", "value", "label", "right-icon"];
  7566. const collapseItemProps = extend({}, cellSharedProps, {
  7567. name: numericProp,
  7568. isLink: truthProp,
  7569. disabled: Boolean,
  7570. readonly: Boolean,
  7571. lazyRender: truthProp
  7572. });
  7573. var stdin_default$V = vue.defineComponent({
  7574. name: name$P,
  7575. props: collapseItemProps,
  7576. setup(props, {
  7577. slots
  7578. }) {
  7579. const wrapperRef = vue.ref();
  7580. const contentRef = vue.ref();
  7581. const {
  7582. parent,
  7583. index
  7584. } = use.useParent(COLLAPSE_KEY);
  7585. if (!parent) {
  7586. if (process.env.NODE_ENV !== "production") {
  7587. console.error("[Vant] <CollapseItem> must be a child component of <Collapse>.");
  7588. }
  7589. return;
  7590. }
  7591. const name2 = vue.computed(() => {
  7592. var _a;
  7593. return (_a = props.name) != null ? _a : index.value;
  7594. });
  7595. const expanded = vue.computed(() => parent.isExpanded(name2.value));
  7596. const show = vue.ref(expanded.value);
  7597. const lazyRender = useLazyRender(() => show.value || !props.lazyRender);
  7598. const onTransitionEnd = () => {
  7599. if (!expanded.value) {
  7600. show.value = false;
  7601. } else if (wrapperRef.value) {
  7602. wrapperRef.value.style.height = "";
  7603. }
  7604. };
  7605. vue.watch(expanded, (value, oldValue) => {
  7606. if (oldValue === null) {
  7607. return;
  7608. }
  7609. if (value) {
  7610. show.value = true;
  7611. }
  7612. const tick = value ? vue.nextTick : use.raf;
  7613. tick(() => {
  7614. if (!contentRef.value || !wrapperRef.value) {
  7615. return;
  7616. }
  7617. const {
  7618. offsetHeight
  7619. } = contentRef.value;
  7620. if (offsetHeight) {
  7621. const contentHeight = `${offsetHeight}px`;
  7622. wrapperRef.value.style.height = value ? "0" : contentHeight;
  7623. use.doubleRaf(() => {
  7624. if (wrapperRef.value) {
  7625. wrapperRef.value.style.height = value ? contentHeight : "0";
  7626. }
  7627. });
  7628. } else {
  7629. onTransitionEnd();
  7630. }
  7631. });
  7632. });
  7633. const toggle = (newValue = !expanded.value) => {
  7634. parent.toggle(name2.value, newValue);
  7635. };
  7636. const onClickTitle = () => {
  7637. if (!props.disabled && !props.readonly) {
  7638. toggle();
  7639. }
  7640. };
  7641. const renderTitle = () => {
  7642. const {
  7643. border,
  7644. disabled,
  7645. readonly
  7646. } = props;
  7647. const attrs = pick(props, Object.keys(cellSharedProps));
  7648. if (readonly) {
  7649. attrs.isLink = false;
  7650. }
  7651. if (disabled || readonly) {
  7652. attrs.clickable = false;
  7653. }
  7654. return vue.createVNode(Cell, vue.mergeProps({
  7655. "role": "button",
  7656. "class": bem$O("title", {
  7657. disabled,
  7658. expanded: expanded.value,
  7659. borderless: !border
  7660. }),
  7661. "aria-expanded": String(expanded.value),
  7662. "onClick": onClickTitle
  7663. }, attrs), pick(slots, CELL_SLOTS));
  7664. };
  7665. const renderContent = lazyRender(() => {
  7666. var _a;
  7667. return vue.withDirectives(vue.createVNode("div", {
  7668. "ref": wrapperRef,
  7669. "class": bem$O("wrapper"),
  7670. "onTransitionend": onTransitionEnd
  7671. }, [vue.createVNode("div", {
  7672. "ref": contentRef,
  7673. "class": bem$O("content")
  7674. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)])]), [[vue.vShow, show.value]]);
  7675. });
  7676. useExpose({
  7677. toggle,
  7678. expanded,
  7679. itemName: name2
  7680. });
  7681. return () => vue.createVNode("div", {
  7682. "class": [bem$O({
  7683. border: index.value && props.border
  7684. })]
  7685. }, [renderTitle(), renderContent()]);
  7686. }
  7687. });
  7688. const CollapseItem = withInstall(stdin_default$V);
  7689. const ConfigProvider = withInstall(stdin_default$1G);
  7690. const [name$O, bem$N, t$d] = createNamespace("contact-card");
  7691. const contactCardProps = {
  7692. tel: String,
  7693. name: String,
  7694. type: makeStringProp("add"),
  7695. addText: String,
  7696. editable: truthProp
  7697. };
  7698. var stdin_default$U = vue.defineComponent({
  7699. name: name$O,
  7700. props: contactCardProps,
  7701. emits: ["click"],
  7702. setup(props, {
  7703. emit
  7704. }) {
  7705. const onClick = (event) => {
  7706. if (props.editable) {
  7707. emit("click", event);
  7708. }
  7709. };
  7710. const renderContent = () => {
  7711. if (props.type === "add") {
  7712. return props.addText || t$d("addContact");
  7713. }
  7714. return [vue.createVNode("div", null, [`${t$d("name")}\uFF1A${props.name}`]), vue.createVNode("div", null, [`${t$d("tel")}\uFF1A${props.tel}`])];
  7715. };
  7716. return () => vue.createVNode(Cell, {
  7717. "center": true,
  7718. "icon": props.type === "edit" ? "contact" : "add-square",
  7719. "class": bem$N([props.type]),
  7720. "border": false,
  7721. "isLink": props.editable,
  7722. "titleClass": bem$N("title"),
  7723. "onClick": onClick
  7724. }, {
  7725. title: renderContent
  7726. });
  7727. }
  7728. });
  7729. const ContactCard = withInstall(stdin_default$U);
  7730. const [name$N, bem$M, t$c] = createNamespace("contact-edit");
  7731. const DEFAULT_CONTACT = {
  7732. tel: "",
  7733. name: ""
  7734. };
  7735. const contactEditProps = {
  7736. isEdit: Boolean,
  7737. isSaving: Boolean,
  7738. isDeleting: Boolean,
  7739. showSetDefault: Boolean,
  7740. setDefaultLabel: String,
  7741. contactInfo: {
  7742. type: Object,
  7743. default: () => extend({}, DEFAULT_CONTACT)
  7744. },
  7745. telValidator: {
  7746. type: Function,
  7747. default: isMobile
  7748. }
  7749. };
  7750. var stdin_default$T = vue.defineComponent({
  7751. name: name$N,
  7752. props: contactEditProps,
  7753. emits: ["save", "delete", "changeDefault"],
  7754. setup(props, {
  7755. emit
  7756. }) {
  7757. const contact = vue.reactive(extend({}, DEFAULT_CONTACT, props.contactInfo));
  7758. const onSave = () => {
  7759. if (!props.isSaving) {
  7760. emit("save", contact);
  7761. }
  7762. };
  7763. const onDelete = () => emit("delete", contact);
  7764. const renderButtons = () => vue.createVNode("div", {
  7765. "class": bem$M("buttons")
  7766. }, [vue.createVNode(Button, {
  7767. "block": true,
  7768. "round": true,
  7769. "type": "primary",
  7770. "text": t$c("save"),
  7771. "class": bem$M("button"),
  7772. "loading": props.isSaving,
  7773. "nativeType": "submit"
  7774. }, null), props.isEdit && vue.createVNode(Button, {
  7775. "block": true,
  7776. "round": true,
  7777. "text": t$c("delete"),
  7778. "class": bem$M("button"),
  7779. "loading": props.isDeleting,
  7780. "onClick": onDelete
  7781. }, null)]);
  7782. const renderSwitch = () => vue.createVNode(Switch, {
  7783. "modelValue": contact.isDefault,
  7784. "onUpdate:modelValue": ($event) => contact.isDefault = $event,
  7785. "onChange": (checked) => emit("changeDefault", checked)
  7786. }, null);
  7787. const renderSetDefault = () => {
  7788. if (props.showSetDefault) {
  7789. return vue.createVNode(Cell, {
  7790. "title": props.setDefaultLabel,
  7791. "class": bem$M("switch-cell"),
  7792. "border": false
  7793. }, {
  7794. "right-icon": renderSwitch
  7795. });
  7796. }
  7797. };
  7798. vue.watch(() => props.contactInfo, (value) => extend(contact, DEFAULT_CONTACT, value));
  7799. return () => vue.createVNode(Form, {
  7800. "class": bem$M(),
  7801. "onSubmit": onSave
  7802. }, {
  7803. default: () => [vue.createVNode("div", {
  7804. "class": bem$M("fields")
  7805. }, [vue.createVNode(Field, {
  7806. "modelValue": contact.name,
  7807. "onUpdate:modelValue": ($event) => contact.name = $event,
  7808. "clearable": true,
  7809. "label": t$c("name"),
  7810. "rules": [{
  7811. required: true,
  7812. message: t$c("nameEmpty")
  7813. }],
  7814. "maxlength": "30",
  7815. "placeholder": t$c("name")
  7816. }, null), vue.createVNode(Field, {
  7817. "modelValue": contact.tel,
  7818. "onUpdate:modelValue": ($event) => contact.tel = $event,
  7819. "clearable": true,
  7820. "type": "tel",
  7821. "label": t$c("tel"),
  7822. "rules": [{
  7823. validator: props.telValidator,
  7824. message: t$c("telInvalid")
  7825. }],
  7826. "placeholder": t$c("tel")
  7827. }, null)]), renderSetDefault(), renderButtons()]
  7828. });
  7829. }
  7830. });
  7831. const ContactEdit = withInstall(stdin_default$T);
  7832. const [name$M, bem$L, t$b] = createNamespace("contact-list");
  7833. const contactListProps = {
  7834. list: Array,
  7835. addText: String,
  7836. modelValue: unknownProp,
  7837. defaultTagText: String
  7838. };
  7839. var stdin_default$S = vue.defineComponent({
  7840. name: name$M,
  7841. props: contactListProps,
  7842. emits: ["add", "edit", "select", "update:modelValue"],
  7843. setup(props, {
  7844. emit
  7845. }) {
  7846. const renderItem = (item, index) => {
  7847. const onClick = () => {
  7848. emit("update:modelValue", item.id);
  7849. emit("select", item, index);
  7850. };
  7851. const renderRightIcon = () => vue.createVNode(Radio, {
  7852. "class": bem$L("radio"),
  7853. "name": item.id,
  7854. "iconSize": 16
  7855. }, null);
  7856. const renderEditIcon = () => vue.createVNode(Icon, {
  7857. "name": "edit",
  7858. "class": bem$L("edit"),
  7859. "onClick": (event) => {
  7860. event.stopPropagation();
  7861. emit("edit", item, index);
  7862. }
  7863. }, null);
  7864. const renderContent = () => {
  7865. const nodes = [`${item.name}\uFF0C${item.tel}`];
  7866. if (item.isDefault && props.defaultTagText) {
  7867. nodes.push(vue.createVNode(Tag, {
  7868. "type": "primary",
  7869. "round": true,
  7870. "class": bem$L("item-tag")
  7871. }, {
  7872. default: () => [props.defaultTagText]
  7873. }));
  7874. }
  7875. return nodes;
  7876. };
  7877. return vue.createVNode(Cell, {
  7878. "key": item.id,
  7879. "isLink": true,
  7880. "center": true,
  7881. "class": bem$L("item"),
  7882. "titleClass": bem$L("item-title"),
  7883. "onClick": onClick
  7884. }, {
  7885. icon: renderEditIcon,
  7886. title: renderContent,
  7887. "right-icon": renderRightIcon
  7888. });
  7889. };
  7890. return () => vue.createVNode("div", {
  7891. "class": bem$L()
  7892. }, [vue.createVNode(RadioGroup, {
  7893. "modelValue": props.modelValue,
  7894. "class": bem$L("group")
  7895. }, {
  7896. default: () => [props.list && props.list.map(renderItem)]
  7897. }), vue.createVNode("div", {
  7898. "class": [bem$L("bottom"), "van-safe-area-bottom"]
  7899. }, [vue.createVNode(Button, {
  7900. "round": true,
  7901. "block": true,
  7902. "type": "primary",
  7903. "class": bem$L("add"),
  7904. "text": props.addText || t$b("addContact"),
  7905. "onClick": () => emit("add")
  7906. }, null)])]);
  7907. }
  7908. });
  7909. const ContactList = withInstall(stdin_default$S);
  7910. function parseFormat(format2, currentTime) {
  7911. const { days } = currentTime;
  7912. let { hours, minutes, seconds, milliseconds } = currentTime;
  7913. if (format2.includes("DD")) {
  7914. format2 = format2.replace("DD", padZero(days));
  7915. } else {
  7916. hours += days * 24;
  7917. }
  7918. if (format2.includes("HH")) {
  7919. format2 = format2.replace("HH", padZero(hours));
  7920. } else {
  7921. minutes += hours * 60;
  7922. }
  7923. if (format2.includes("mm")) {
  7924. format2 = format2.replace("mm", padZero(minutes));
  7925. } else {
  7926. seconds += minutes * 60;
  7927. }
  7928. if (format2.includes("ss")) {
  7929. format2 = format2.replace("ss", padZero(seconds));
  7930. } else {
  7931. milliseconds += seconds * 1e3;
  7932. }
  7933. if (format2.includes("S")) {
  7934. const ms = padZero(milliseconds, 3);
  7935. if (format2.includes("SSS")) {
  7936. format2 = format2.replace("SSS", ms);
  7937. } else if (format2.includes("SS")) {
  7938. format2 = format2.replace("SS", ms.slice(0, 2));
  7939. } else {
  7940. format2 = format2.replace("S", ms.charAt(0));
  7941. }
  7942. }
  7943. return format2;
  7944. }
  7945. const [name$L, bem$K] = createNamespace("count-down");
  7946. const countDownProps = {
  7947. time: makeNumericProp(0),
  7948. format: makeStringProp("HH:mm:ss"),
  7949. autoStart: truthProp,
  7950. millisecond: Boolean
  7951. };
  7952. var stdin_default$R = vue.defineComponent({
  7953. name: name$L,
  7954. props: countDownProps,
  7955. emits: ["change", "finish"],
  7956. setup(props, {
  7957. emit,
  7958. slots
  7959. }) {
  7960. const {
  7961. start,
  7962. pause,
  7963. reset,
  7964. current: current2
  7965. } = use.useCountDown({
  7966. time: +props.time,
  7967. millisecond: props.millisecond,
  7968. onChange: (current22) => emit("change", current22),
  7969. onFinish: () => emit("finish")
  7970. });
  7971. const timeText = vue.computed(() => parseFormat(props.format, current2.value));
  7972. const resetTime = () => {
  7973. reset(+props.time);
  7974. if (props.autoStart) {
  7975. start();
  7976. }
  7977. };
  7978. vue.watch(() => props.time, resetTime, {
  7979. immediate: true
  7980. });
  7981. useExpose({
  7982. start,
  7983. pause,
  7984. reset: resetTime
  7985. });
  7986. return () => vue.createVNode("div", {
  7987. "role": "timer",
  7988. "class": bem$K()
  7989. }, [slots.default ? slots.default(current2.value) : timeText.value]);
  7990. }
  7991. });
  7992. const CountDown = withInstall(stdin_default$R);
  7993. function getDate(timeStamp) {
  7994. const date = new Date(timeStamp * 1e3);
  7995. return `${date.getFullYear()}.${padZero(date.getMonth() + 1)}.${padZero(
  7996. date.getDate()
  7997. )}`;
  7998. }
  7999. const formatDiscount = (discount) => (discount / 10).toFixed(discount % 10 === 0 ? 0 : 1);
  8000. const formatAmount = (amount) => (amount / 100).toFixed(amount % 100 === 0 ? 0 : amount % 10 === 0 ? 1 : 2);
  8001. const [name$K, bem$J, t$a] = createNamespace("coupon");
  8002. var stdin_default$Q = vue.defineComponent({
  8003. name: name$K,
  8004. props: {
  8005. chosen: Boolean,
  8006. coupon: makeRequiredProp(Object),
  8007. disabled: Boolean,
  8008. currency: makeStringProp("\xA5")
  8009. },
  8010. setup(props) {
  8011. const validPeriod = vue.computed(() => {
  8012. const {
  8013. startAt,
  8014. endAt
  8015. } = props.coupon;
  8016. return `${getDate(startAt)} - ${getDate(endAt)}`;
  8017. });
  8018. const faceAmount = vue.computed(() => {
  8019. const {
  8020. coupon,
  8021. currency
  8022. } = props;
  8023. if (coupon.valueDesc) {
  8024. return [coupon.valueDesc, vue.createVNode("span", null, [coupon.unitDesc || ""])];
  8025. }
  8026. if (coupon.denominations) {
  8027. const denominations = formatAmount(coupon.denominations);
  8028. return [vue.createVNode("span", null, [currency]), ` ${denominations}`];
  8029. }
  8030. if (coupon.discount) {
  8031. return t$a("discount", formatDiscount(coupon.discount));
  8032. }
  8033. return "";
  8034. });
  8035. const conditionMessage = vue.computed(() => {
  8036. const condition = formatAmount(props.coupon.originCondition || 0);
  8037. return condition === "0" ? t$a("unlimited") : t$a("condition", condition);
  8038. });
  8039. return () => {
  8040. const {
  8041. chosen,
  8042. coupon,
  8043. disabled
  8044. } = props;
  8045. const description = disabled && coupon.reason || coupon.description;
  8046. return vue.createVNode("div", {
  8047. "class": bem$J({
  8048. disabled
  8049. })
  8050. }, [vue.createVNode("div", {
  8051. "class": bem$J("content")
  8052. }, [vue.createVNode("div", {
  8053. "class": bem$J("head")
  8054. }, [vue.createVNode("h2", {
  8055. "class": bem$J("amount")
  8056. }, [faceAmount.value]), vue.createVNode("p", {
  8057. "class": bem$J("condition")
  8058. }, [coupon.condition || conditionMessage.value])]), vue.createVNode("div", {
  8059. "class": bem$J("body")
  8060. }, [vue.createVNode("p", {
  8061. "class": bem$J("name")
  8062. }, [coupon.name]), vue.createVNode("p", {
  8063. "class": bem$J("valid")
  8064. }, [validPeriod.value]), !disabled && vue.createVNode(Checkbox, {
  8065. "class": bem$J("corner"),
  8066. "modelValue": chosen
  8067. }, null)])]), description && vue.createVNode("p", {
  8068. "class": bem$J("description")
  8069. }, [description])]);
  8070. };
  8071. }
  8072. });
  8073. const Coupon = withInstall(stdin_default$Q);
  8074. const [name$J, bem$I, t$9] = createNamespace("coupon-cell");
  8075. const couponCellProps = {
  8076. title: String,
  8077. border: truthProp,
  8078. editable: truthProp,
  8079. coupons: makeArrayProp(),
  8080. currency: makeStringProp("\xA5"),
  8081. chosenCoupon: makeNumericProp(-1)
  8082. };
  8083. function formatValue({
  8084. coupons,
  8085. chosenCoupon,
  8086. currency
  8087. }) {
  8088. const coupon = coupons[+chosenCoupon];
  8089. if (coupon) {
  8090. let value = 0;
  8091. if (isDef(coupon.value)) {
  8092. ({
  8093. value
  8094. } = coupon);
  8095. } else if (isDef(coupon.denominations)) {
  8096. value = coupon.denominations;
  8097. }
  8098. return `-${currency} ${(value / 100).toFixed(2)}`;
  8099. }
  8100. return coupons.length === 0 ? t$9("noCoupon") : t$9("count", coupons.length);
  8101. }
  8102. var stdin_default$P = vue.defineComponent({
  8103. name: name$J,
  8104. props: couponCellProps,
  8105. setup(props) {
  8106. return () => {
  8107. const selected = props.coupons[+props.chosenCoupon];
  8108. return vue.createVNode(Cell, {
  8109. "class": bem$I(),
  8110. "value": formatValue(props),
  8111. "title": props.title || t$9("title"),
  8112. "border": props.border,
  8113. "isLink": props.editable,
  8114. "valueClass": bem$I("value", {
  8115. selected
  8116. })
  8117. }, null);
  8118. };
  8119. }
  8120. });
  8121. const CouponCell = withInstall(stdin_default$P);
  8122. const [name$I, bem$H] = createNamespace("empty");
  8123. const emptyProps = {
  8124. image: makeStringProp("default"),
  8125. imageSize: [Number, String, Array],
  8126. description: String
  8127. };
  8128. var stdin_default$O = vue.defineComponent({
  8129. name: name$I,
  8130. props: emptyProps,
  8131. setup(props, {
  8132. slots
  8133. }) {
  8134. const renderDescription = () => {
  8135. const description = slots.description ? slots.description() : props.description;
  8136. if (description) {
  8137. return vue.createVNode("p", {
  8138. "class": bem$H("description")
  8139. }, [description]);
  8140. }
  8141. };
  8142. const renderBottom = () => {
  8143. if (slots.default) {
  8144. return vue.createVNode("div", {
  8145. "class": bem$H("bottom")
  8146. }, [slots.default()]);
  8147. }
  8148. };
  8149. const baseId = useId();
  8150. const getId = (num) => `${baseId}-${num}`;
  8151. const getUrlById = (num) => `url(#${getId(num)})`;
  8152. const renderStop = (color, offset, opacity) => vue.createVNode("stop", {
  8153. "stop-color": color,
  8154. "offset": `${offset}%`,
  8155. "stop-opacity": opacity
  8156. }, null);
  8157. const renderStops = (fromColor, toColor) => [renderStop(fromColor, 0), renderStop(toColor, 100)];
  8158. const renderShadow = (id) => [vue.createVNode("defs", null, [vue.createVNode("radialGradient", {
  8159. "id": getId(id),
  8160. "cx": "50%",
  8161. "cy": "54%",
  8162. "fx": "50%",
  8163. "fy": "54%",
  8164. "r": "297%",
  8165. "gradientTransform": "matrix(-.16 0 0 -.33 .58 .72)"
  8166. }, [renderStop("#EBEDF0", 0), renderStop("#F2F3F5", 100, 0.3)])]), vue.createVNode("ellipse", {
  8167. "fill": getUrlById(id),
  8168. "opacity": ".8",
  8169. "cx": "80",
  8170. "cy": "140",
  8171. "rx": "46",
  8172. "ry": "8"
  8173. }, null)];
  8174. const renderBuilding = () => [vue.createVNode("defs", null, [vue.createVNode("linearGradient", {
  8175. "id": getId("a"),
  8176. "x1": "64%",
  8177. "y1": "100%",
  8178. "x2": "64%"
  8179. }, [renderStop("#FFF", 0, 0.5), renderStop("#F2F3F5", 100)])]), vue.createVNode("g", {
  8180. "opacity": ".8"
  8181. }, [vue.createVNode("path", {
  8182. "d": "M36 131V53H16v20H2v58h34z",
  8183. "fill": getUrlById("a")
  8184. }, null), vue.createVNode("path", {
  8185. "d": "M123 15h22v14h9v77h-31V15z",
  8186. "fill": getUrlById("a")
  8187. }, null)])];
  8188. const renderCloud = () => [vue.createVNode("defs", null, [vue.createVNode("linearGradient", {
  8189. "id": getId("b"),
  8190. "x1": "64%",
  8191. "y1": "97%",
  8192. "x2": "64%",
  8193. "y2": "0%"
  8194. }, [renderStop("#F2F3F5", 0, 0.3), renderStop("#F2F3F5", 100)])]), vue.createVNode("g", {
  8195. "opacity": ".8"
  8196. }, [vue.createVNode("path", {
  8197. "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",
  8198. "fill": getUrlById("b")
  8199. }, null), vue.createVNode("path", {
  8200. "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",
  8201. "fill": getUrlById("b")
  8202. }, null)])];
  8203. const renderNetwork = () => vue.createVNode("svg", {
  8204. "viewBox": "0 0 160 160"
  8205. }, [vue.createVNode("defs", null, [vue.createVNode("linearGradient", {
  8206. "id": getId(1),
  8207. "x1": "64%",
  8208. "y1": "100%",
  8209. "x2": "64%"
  8210. }, [renderStop("#FFF", 0, 0.5), renderStop("#F2F3F5", 100)]), vue.createVNode("linearGradient", {
  8211. "id": getId(2),
  8212. "x1": "50%",
  8213. "x2": "50%",
  8214. "y2": "84%"
  8215. }, [renderStop("#EBEDF0", 0), renderStop("#DCDEE0", 100, 0)]), vue.createVNode("linearGradient", {
  8216. "id": getId(3),
  8217. "x1": "100%",
  8218. "x2": "100%",
  8219. "y2": "100%"
  8220. }, [renderStops("#EAEDF0", "#DCDEE0")]), vue.createVNode("radialGradient", {
  8221. "id": getId(4),
  8222. "cx": "50%",
  8223. "cy": "0%",
  8224. "fx": "50%",
  8225. "fy": "0%",
  8226. "r": "100%",
  8227. "gradientTransform": "matrix(0 1 -.54 0 .5 -.5)"
  8228. }, [renderStop("#EBEDF0", 0), renderStop("#FFF", 100, 0)])]), vue.createVNode("g", {
  8229. "fill": "none"
  8230. }, [renderBuilding(), vue.createVNode("path", {
  8231. "fill": getUrlById(4),
  8232. "d": "M0 139h160v21H0z"
  8233. }, null), vue.createVNode("path", {
  8234. "d": "M80 54a7 7 0 0 1 3 13v27l-2 2h-2a2 2 0 0 1-2-2V67a7 7 0 0 1 3-13z",
  8235. "fill": getUrlById(2)
  8236. }, null), vue.createVNode("g", {
  8237. "opacity": ".6",
  8238. "stroke-linecap": "round",
  8239. "stroke-width": "7"
  8240. }, [vue.createVNode("path", {
  8241. "d": "M64 47a19 19 0 0 0-5 13c0 5 2 10 5 13",
  8242. "stroke": getUrlById(3)
  8243. }, null), vue.createVNode("path", {
  8244. "d": "M53 36a34 34 0 0 0 0 48",
  8245. "stroke": getUrlById(3)
  8246. }, null), vue.createVNode("path", {
  8247. "d": "M95 73a19 19 0 0 0 6-13c0-5-2-9-6-13",
  8248. "stroke": getUrlById(3)
  8249. }, null), vue.createVNode("path", {
  8250. "d": "M106 84a34 34 0 0 0 0-48",
  8251. "stroke": getUrlById(3)
  8252. }, null)]), vue.createVNode("g", {
  8253. "transform": "translate(31 105)"
  8254. }, [vue.createVNode("rect", {
  8255. "fill": "#EBEDF0",
  8256. "width": "98",
  8257. "height": "34",
  8258. "rx": "2"
  8259. }, null), vue.createVNode("rect", {
  8260. "fill": "#FFF",
  8261. "x": "9",
  8262. "y": "8",
  8263. "width": "80",
  8264. "height": "18",
  8265. "rx": "1.1"
  8266. }, null), vue.createVNode("rect", {
  8267. "fill": "#EBEDF0",
  8268. "x": "15",
  8269. "y": "12",
  8270. "width": "18",
  8271. "height": "6",
  8272. "rx": "1.1"
  8273. }, null)])])]);
  8274. const renderMaterial = () => vue.createVNode("svg", {
  8275. "viewBox": "0 0 160 160"
  8276. }, [vue.createVNode("defs", null, [vue.createVNode("linearGradient", {
  8277. "x1": "50%",
  8278. "x2": "50%",
  8279. "y2": "100%",
  8280. "id": getId(5)
  8281. }, [renderStops("#F2F3F5", "#DCDEE0")]), vue.createVNode("linearGradient", {
  8282. "x1": "95%",
  8283. "y1": "48%",
  8284. "x2": "5.5%",
  8285. "y2": "51%",
  8286. "id": getId(6)
  8287. }, [renderStops("#EAEDF1", "#DCDEE0")]), vue.createVNode("linearGradient", {
  8288. "y1": "45%",
  8289. "x2": "100%",
  8290. "y2": "54%",
  8291. "id": getId(7)
  8292. }, [renderStops("#EAEDF1", "#DCDEE0")])]), renderBuilding(), renderCloud(), vue.createVNode("g", {
  8293. "transform": "translate(36 50)",
  8294. "fill": "none"
  8295. }, [vue.createVNode("g", {
  8296. "transform": "translate(8)"
  8297. }, [vue.createVNode("rect", {
  8298. "fill": "#EBEDF0",
  8299. "opacity": ".6",
  8300. "x": "38",
  8301. "y": "13",
  8302. "width": "36",
  8303. "height": "53",
  8304. "rx": "2"
  8305. }, null), vue.createVNode("rect", {
  8306. "fill": getUrlById(5),
  8307. "width": "64",
  8308. "height": "66",
  8309. "rx": "2"
  8310. }, null), vue.createVNode("rect", {
  8311. "fill": "#FFF",
  8312. "x": "6",
  8313. "y": "6",
  8314. "width": "52",
  8315. "height": "55",
  8316. "rx": "1"
  8317. }, null), vue.createVNode("g", {
  8318. "transform": "translate(15 17)",
  8319. "fill": getUrlById(6)
  8320. }, [vue.createVNode("rect", {
  8321. "width": "34",
  8322. "height": "6",
  8323. "rx": "1"
  8324. }, null), vue.createVNode("path", {
  8325. "d": "M0 14h34v6H0z"
  8326. }, null), vue.createVNode("rect", {
  8327. "y": "28",
  8328. "width": "34",
  8329. "height": "6",
  8330. "rx": "1"
  8331. }, null)])]), vue.createVNode("rect", {
  8332. "fill": getUrlById(7),
  8333. "y": "61",
  8334. "width": "88",
  8335. "height": "28",
  8336. "rx": "1"
  8337. }, null), vue.createVNode("rect", {
  8338. "fill": "#F7F8FA",
  8339. "x": "29",
  8340. "y": "72",
  8341. "width": "30",
  8342. "height": "6",
  8343. "rx": "1"
  8344. }, null)])]);
  8345. const renderError = () => vue.createVNode("svg", {
  8346. "viewBox": "0 0 160 160"
  8347. }, [vue.createVNode("defs", null, [vue.createVNode("linearGradient", {
  8348. "x1": "50%",
  8349. "x2": "50%",
  8350. "y2": "100%",
  8351. "id": getId(8)
  8352. }, [renderStops("#EAEDF1", "#DCDEE0")])]), renderBuilding(), renderCloud(), renderShadow("c"), vue.createVNode("path", {
  8353. "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",
  8354. "fill": getUrlById(8)
  8355. }, null)]);
  8356. const renderSearch = () => vue.createVNode("svg", {
  8357. "viewBox": "0 0 160 160"
  8358. }, [vue.createVNode("defs", null, [vue.createVNode("linearGradient", {
  8359. "x1": "50%",
  8360. "y1": "100%",
  8361. "x2": "50%",
  8362. "id": getId(9)
  8363. }, [renderStops("#EEE", "#D8D8D8")]), vue.createVNode("linearGradient", {
  8364. "x1": "100%",
  8365. "y1": "50%",
  8366. "y2": "50%",
  8367. "id": getId(10)
  8368. }, [renderStops("#F2F3F5", "#DCDEE0")]), vue.createVNode("linearGradient", {
  8369. "x1": "50%",
  8370. "x2": "50%",
  8371. "y2": "100%",
  8372. "id": getId(11)
  8373. }, [renderStops("#F2F3F5", "#DCDEE0")]), vue.createVNode("linearGradient", {
  8374. "x1": "50%",
  8375. "x2": "50%",
  8376. "y2": "100%",
  8377. "id": getId(12)
  8378. }, [renderStops("#FFF", "#F7F8FA")])]), renderBuilding(), renderCloud(), renderShadow("d"), vue.createVNode("g", {
  8379. "transform": "rotate(-45 113 -4)",
  8380. "fill": "none"
  8381. }, [vue.createVNode("rect", {
  8382. "fill": getUrlById(9),
  8383. "x": "24",
  8384. "y": "52.8",
  8385. "width": "5.8",
  8386. "height": "19",
  8387. "rx": "1"
  8388. }, null), vue.createVNode("rect", {
  8389. "fill": getUrlById(10),
  8390. "x": "22.1",
  8391. "y": "67.3",
  8392. "width": "9.9",
  8393. "height": "28",
  8394. "rx": "1"
  8395. }, null), vue.createVNode("circle", {
  8396. "stroke": getUrlById(11),
  8397. "stroke-width": "8",
  8398. "cx": "27",
  8399. "cy": "27",
  8400. "r": "27"
  8401. }, null), vue.createVNode("circle", {
  8402. "fill": getUrlById(12),
  8403. "cx": "27",
  8404. "cy": "27",
  8405. "r": "16"
  8406. }, null), vue.createVNode("path", {
  8407. "d": "M37 7c-8 0-15 5-16 12",
  8408. "stroke": getUrlById(11),
  8409. "stroke-width": "3",
  8410. "opacity": ".5",
  8411. "stroke-linecap": "round",
  8412. "transform": "rotate(45 29 13)"
  8413. }, null)])]);
  8414. const renderImage = () => {
  8415. var _a;
  8416. if (slots.image) {
  8417. return slots.image();
  8418. }
  8419. const PRESET_IMAGES = {
  8420. error: renderError,
  8421. search: renderSearch,
  8422. network: renderNetwork,
  8423. default: renderMaterial
  8424. };
  8425. return ((_a = PRESET_IMAGES[props.image]) == null ? void 0 : _a.call(PRESET_IMAGES)) || vue.createVNode("img", {
  8426. "src": props.image
  8427. }, null);
  8428. };
  8429. return () => vue.createVNode("div", {
  8430. "class": bem$H()
  8431. }, [vue.createVNode("div", {
  8432. "class": bem$H("image"),
  8433. "style": getSizeStyle(props.imageSize)
  8434. }, [renderImage()]), renderDescription(), renderBottom()]);
  8435. }
  8436. });
  8437. const Empty = withInstall(stdin_default$O);
  8438. const [name$H, bem$G, t$8] = createNamespace("coupon-list");
  8439. const couponListProps = {
  8440. code: makeStringProp(""),
  8441. coupons: makeArrayProp(),
  8442. currency: makeStringProp("\xA5"),
  8443. showCount: truthProp,
  8444. emptyImage: String,
  8445. chosenCoupon: makeNumberProp(-1),
  8446. enabledTitle: String,
  8447. disabledTitle: String,
  8448. disabledCoupons: makeArrayProp(),
  8449. showExchangeBar: truthProp,
  8450. showCloseButton: truthProp,
  8451. closeButtonText: String,
  8452. inputPlaceholder: String,
  8453. exchangeMinLength: makeNumberProp(1),
  8454. exchangeButtonText: String,
  8455. displayedCouponIndex: makeNumberProp(-1),
  8456. exchangeButtonLoading: Boolean,
  8457. exchangeButtonDisabled: Boolean
  8458. };
  8459. var stdin_default$N = vue.defineComponent({
  8460. name: name$H,
  8461. props: couponListProps,
  8462. emits: ["change", "exchange", "update:code"],
  8463. setup(props, {
  8464. emit,
  8465. slots
  8466. }) {
  8467. const [couponRefs, setCouponRefs] = useRefs();
  8468. const root = vue.ref();
  8469. const barRef = vue.ref();
  8470. const activeTab = vue.ref(0);
  8471. const listHeight = vue.ref(0);
  8472. const currentCode = vue.ref(props.code);
  8473. const buttonDisabled = vue.computed(() => !props.exchangeButtonLoading && (props.exchangeButtonDisabled || !currentCode.value || currentCode.value.length < props.exchangeMinLength));
  8474. const updateListHeight = () => {
  8475. const TABS_HEIGHT = 44;
  8476. const rootHeight = use.useRect(root).height;
  8477. const headerHeight = use.useRect(barRef).height + TABS_HEIGHT;
  8478. listHeight.value = (rootHeight > headerHeight ? rootHeight : windowHeight.value) - headerHeight;
  8479. };
  8480. const onExchange = () => {
  8481. emit("exchange", currentCode.value);
  8482. if (!props.code) {
  8483. currentCode.value = "";
  8484. }
  8485. };
  8486. const scrollToCoupon = (index) => {
  8487. vue.nextTick(() => {
  8488. var _a;
  8489. return (_a = couponRefs.value[index]) == null ? void 0 : _a.scrollIntoView();
  8490. });
  8491. };
  8492. const renderEmpty = () => vue.createVNode(Empty, {
  8493. "image": props.emptyImage
  8494. }, {
  8495. default: () => [vue.createVNode("p", {
  8496. "class": bem$G("empty-tip")
  8497. }, [t$8("noCoupon")])]
  8498. });
  8499. const renderExchangeBar = () => {
  8500. if (props.showExchangeBar) {
  8501. return vue.createVNode("div", {
  8502. "ref": barRef,
  8503. "class": bem$G("exchange-bar")
  8504. }, [vue.createVNode(Field, {
  8505. "modelValue": currentCode.value,
  8506. "onUpdate:modelValue": ($event) => currentCode.value = $event,
  8507. "clearable": true,
  8508. "border": false,
  8509. "class": bem$G("field"),
  8510. "placeholder": props.inputPlaceholder || t$8("placeholder"),
  8511. "maxlength": "20"
  8512. }, null), vue.createVNode(Button, {
  8513. "plain": true,
  8514. "type": "primary",
  8515. "class": bem$G("exchange"),
  8516. "text": props.exchangeButtonText || t$8("exchange"),
  8517. "loading": props.exchangeButtonLoading,
  8518. "disabled": buttonDisabled.value,
  8519. "onClick": onExchange
  8520. }, null)]);
  8521. }
  8522. };
  8523. const renderCouponTab = () => {
  8524. const {
  8525. coupons
  8526. } = props;
  8527. const count = props.showCount ? ` (${coupons.length})` : "";
  8528. const title = (props.enabledTitle || t$8("enable")) + count;
  8529. return vue.createVNode(Tab, {
  8530. "title": title
  8531. }, {
  8532. default: () => {
  8533. var _a;
  8534. return [vue.createVNode("div", {
  8535. "class": bem$G("list", {
  8536. "with-bottom": props.showCloseButton
  8537. }),
  8538. "style": {
  8539. height: `${listHeight.value}px`
  8540. }
  8541. }, [coupons.map((coupon, index) => vue.createVNode(Coupon, {
  8542. "key": coupon.id,
  8543. "ref": setCouponRefs(index),
  8544. "coupon": coupon,
  8545. "chosen": index === props.chosenCoupon,
  8546. "currency": props.currency,
  8547. "onClick": () => emit("change", index)
  8548. }, null)), !coupons.length && renderEmpty(), (_a = slots["list-footer"]) == null ? void 0 : _a.call(slots)])];
  8549. }
  8550. });
  8551. };
  8552. const renderDisabledTab = () => {
  8553. const {
  8554. disabledCoupons
  8555. } = props;
  8556. const count = props.showCount ? ` (${disabledCoupons.length})` : "";
  8557. const title = (props.disabledTitle || t$8("disabled")) + count;
  8558. return vue.createVNode(Tab, {
  8559. "title": title
  8560. }, {
  8561. default: () => {
  8562. var _a;
  8563. return [vue.createVNode("div", {
  8564. "class": bem$G("list", {
  8565. "with-bottom": props.showCloseButton
  8566. }),
  8567. "style": {
  8568. height: `${listHeight.value}px`
  8569. }
  8570. }, [disabledCoupons.map((coupon) => vue.createVNode(Coupon, {
  8571. "disabled": true,
  8572. "key": coupon.id,
  8573. "coupon": coupon,
  8574. "currency": props.currency
  8575. }, null)), !disabledCoupons.length && renderEmpty(), (_a = slots["disabled-list-footer"]) == null ? void 0 : _a.call(slots)])];
  8576. }
  8577. });
  8578. };
  8579. vue.watch(() => props.code, (value) => {
  8580. currentCode.value = value;
  8581. });
  8582. vue.watch(windowHeight, updateListHeight);
  8583. vue.watch(currentCode, (value) => emit("update:code", value));
  8584. vue.watch(() => props.displayedCouponIndex, scrollToCoupon);
  8585. vue.onMounted(() => {
  8586. updateListHeight();
  8587. scrollToCoupon(props.displayedCouponIndex);
  8588. });
  8589. return () => vue.createVNode("div", {
  8590. "ref": root,
  8591. "class": bem$G()
  8592. }, [renderExchangeBar(), vue.createVNode(Tabs, {
  8593. "active": activeTab.value,
  8594. "onUpdate:active": ($event) => activeTab.value = $event,
  8595. "class": bem$G("tab")
  8596. }, {
  8597. default: () => [renderCouponTab(), renderDisabledTab()]
  8598. }), vue.createVNode("div", {
  8599. "class": bem$G("bottom")
  8600. }, [vue.withDirectives(vue.createVNode(Button, {
  8601. "round": true,
  8602. "block": true,
  8603. "type": "primary",
  8604. "class": bem$G("close"),
  8605. "text": props.closeButtonText || t$8("close"),
  8606. "onClick": () => emit("change", -1)
  8607. }, null), [[vue.vShow, props.showCloseButton]])])]);
  8608. }
  8609. });
  8610. const CouponList = withInstall(stdin_default$N);
  8611. const currentYear = new Date().getFullYear();
  8612. const [name$G] = createNamespace("date-picker");
  8613. const datePickerProps = extend({}, sharedProps, {
  8614. columnsType: {
  8615. type: Array,
  8616. default: () => ["year", "month", "day"]
  8617. },
  8618. minDate: {
  8619. type: Date,
  8620. default: () => new Date(currentYear - 10, 0, 1),
  8621. validator: isDate
  8622. },
  8623. maxDate: {
  8624. type: Date,
  8625. default: () => new Date(currentYear + 10, 11, 31),
  8626. validator: isDate
  8627. }
  8628. });
  8629. var stdin_default$M = vue.defineComponent({
  8630. name: name$G,
  8631. props: datePickerProps,
  8632. emits: ["confirm", "cancel", "change", "update:modelValue"],
  8633. setup(props, {
  8634. emit,
  8635. slots
  8636. }) {
  8637. const currentValues = vue.ref(props.modelValue);
  8638. const genYearOptions = () => {
  8639. const minYear = props.minDate.getFullYear();
  8640. const maxYear = props.maxDate.getFullYear();
  8641. return genOptions(minYear, maxYear, "year", props.formatter, props.filter);
  8642. };
  8643. const isMinYear = (year) => year === props.minDate.getFullYear();
  8644. const isMaxYear = (year) => year === props.maxDate.getFullYear();
  8645. const isMinMonth = (month) => month === props.minDate.getMonth() + 1;
  8646. const isMaxMonth = (month) => month === props.maxDate.getMonth() + 1;
  8647. const getValue = (type) => {
  8648. const {
  8649. minDate,
  8650. columnsType
  8651. } = props;
  8652. const index = columnsType.indexOf(type);
  8653. const value = currentValues.value[index];
  8654. if (value) {
  8655. return +value;
  8656. }
  8657. switch (type) {
  8658. case "year":
  8659. return minDate.getFullYear();
  8660. case "month":
  8661. return minDate.getMonth() + 1;
  8662. case "day":
  8663. return minDate.getDate();
  8664. }
  8665. };
  8666. const genMonthOptions = () => {
  8667. const year = getValue("year");
  8668. const minMonth = isMinYear(year) ? props.minDate.getMonth() + 1 : 1;
  8669. const maxMonth = isMaxYear(year) ? props.maxDate.getMonth() + 1 : 12;
  8670. return genOptions(minMonth, maxMonth, "month", props.formatter, props.filter);
  8671. };
  8672. const genDayOptions = () => {
  8673. const year = getValue("year");
  8674. const month = getValue("month");
  8675. const minDate = isMinYear(year) && isMinMonth(month) ? props.minDate.getDate() : 1;
  8676. const maxDate = isMaxYear(year) && isMaxMonth(month) ? props.maxDate.getDate() : getMonthEndDay(year, month);
  8677. return genOptions(minDate, maxDate, "day", props.formatter, props.filter);
  8678. };
  8679. const columns = vue.computed(() => props.columnsType.map((type) => {
  8680. switch (type) {
  8681. case "year":
  8682. return genYearOptions();
  8683. case "month":
  8684. return genMonthOptions();
  8685. case "day":
  8686. return genDayOptions();
  8687. default:
  8688. if (process.env.NODE_ENV !== "production") {
  8689. throw new Error(`[Vant] DatePicker: unsupported columns type: ${type}`);
  8690. }
  8691. return [];
  8692. }
  8693. }));
  8694. vue.watch(currentValues, (newValues) => {
  8695. if (!isSameValue(newValues, props.modelValue)) {
  8696. emit("update:modelValue", newValues);
  8697. }
  8698. });
  8699. vue.watch(() => props.modelValue, (newValues) => {
  8700. newValues = formatValueRange(newValues, columns.value);
  8701. if (!isSameValue(newValues, currentValues.value)) {
  8702. currentValues.value = newValues;
  8703. }
  8704. }, {
  8705. immediate: true
  8706. });
  8707. const onChange = (...args) => emit("change", ...args);
  8708. const onCancel = (...args) => emit("cancel", ...args);
  8709. const onConfirm = (...args) => emit("confirm", ...args);
  8710. return () => vue.createVNode(Picker, vue.mergeProps({
  8711. "modelValue": currentValues.value,
  8712. "onUpdate:modelValue": ($event) => currentValues.value = $event,
  8713. "columns": columns.value,
  8714. "onChange": onChange,
  8715. "onCancel": onCancel,
  8716. "onConfirm": onConfirm
  8717. }, pick(props, pickerInheritKeys)), slots);
  8718. }
  8719. });
  8720. const DatePicker = withInstall(stdin_default$M);
  8721. const [name$F, bem$F, t$7] = createNamespace("dialog");
  8722. const dialogProps = extend({}, popupSharedProps, {
  8723. title: String,
  8724. theme: String,
  8725. width: numericProp,
  8726. message: [String, Function],
  8727. callback: Function,
  8728. allowHtml: Boolean,
  8729. className: unknownProp,
  8730. transition: makeStringProp("van-dialog-bounce"),
  8731. messageAlign: String,
  8732. closeOnPopstate: truthProp,
  8733. showCancelButton: Boolean,
  8734. cancelButtonText: String,
  8735. cancelButtonColor: String,
  8736. cancelButtonDisabled: Boolean,
  8737. confirmButtonText: String,
  8738. confirmButtonColor: String,
  8739. confirmButtonDisabled: Boolean,
  8740. showConfirmButton: truthProp,
  8741. closeOnClickOverlay: Boolean
  8742. });
  8743. const popupInheritKeys$1 = [...popupSharedPropKeys, "transition", "closeOnPopstate"];
  8744. var stdin_default$L = vue.defineComponent({
  8745. name: name$F,
  8746. props: dialogProps,
  8747. emits: ["confirm", "cancel", "keydown", "update:show"],
  8748. setup(props, {
  8749. emit,
  8750. slots
  8751. }) {
  8752. const root = vue.ref();
  8753. const loading = vue.reactive({
  8754. confirm: false,
  8755. cancel: false
  8756. });
  8757. const updateShow = (value) => emit("update:show", value);
  8758. const close = (action) => {
  8759. var _a;
  8760. updateShow(false);
  8761. (_a = props.callback) == null ? void 0 : _a.call(props, action);
  8762. };
  8763. const getActionHandler = (action) => () => {
  8764. if (!props.show) {
  8765. return;
  8766. }
  8767. emit(action);
  8768. if (props.beforeClose) {
  8769. loading[action] = true;
  8770. callInterceptor(props.beforeClose, {
  8771. args: [action],
  8772. done() {
  8773. close(action);
  8774. loading[action] = false;
  8775. },
  8776. canceled() {
  8777. loading[action] = false;
  8778. }
  8779. });
  8780. } else {
  8781. close(action);
  8782. }
  8783. };
  8784. const onCancel = getActionHandler("cancel");
  8785. const onConfirm = getActionHandler("confirm");
  8786. const onKeydown = vue.withKeys((event) => {
  8787. var _a, _b;
  8788. if (event.target !== ((_b = (_a = root.value) == null ? void 0 : _a.popupRef) == null ? void 0 : _b.value)) {
  8789. return;
  8790. }
  8791. const onEventType = {
  8792. Enter: props.showConfirmButton ? onConfirm : noop,
  8793. Escape: props.showCancelButton ? onCancel : noop
  8794. };
  8795. onEventType[event.key]();
  8796. emit("keydown", event);
  8797. }, ["enter", "esc"]);
  8798. const renderTitle = () => {
  8799. const title = slots.title ? slots.title() : props.title;
  8800. if (title) {
  8801. return vue.createVNode("div", {
  8802. "class": bem$F("header", {
  8803. isolated: !props.message && !slots.default
  8804. })
  8805. }, [title]);
  8806. }
  8807. };
  8808. const renderMessage = (hasTitle) => {
  8809. const {
  8810. message,
  8811. allowHtml,
  8812. messageAlign
  8813. } = props;
  8814. const classNames = bem$F("message", {
  8815. "has-title": hasTitle,
  8816. [messageAlign]: messageAlign
  8817. });
  8818. const content = isFunction(message) ? message() : message;
  8819. if (allowHtml && typeof content === "string") {
  8820. return vue.createVNode("div", {
  8821. "class": classNames,
  8822. "innerHTML": content
  8823. }, null);
  8824. }
  8825. return vue.createVNode("div", {
  8826. "class": classNames
  8827. }, [content]);
  8828. };
  8829. const renderContent = () => {
  8830. if (slots.default) {
  8831. return vue.createVNode("div", {
  8832. "class": bem$F("content")
  8833. }, [slots.default()]);
  8834. }
  8835. const {
  8836. title,
  8837. message,
  8838. allowHtml
  8839. } = props;
  8840. if (message) {
  8841. const hasTitle = !!(title || slots.title);
  8842. return vue.createVNode("div", {
  8843. "key": allowHtml ? 1 : 0,
  8844. "class": bem$F("content", {
  8845. isolated: !hasTitle
  8846. })
  8847. }, [renderMessage(hasTitle)]);
  8848. }
  8849. };
  8850. const renderButtons = () => vue.createVNode("div", {
  8851. "class": [BORDER_TOP, bem$F("footer")]
  8852. }, [props.showCancelButton && vue.createVNode(Button, {
  8853. "size": "large",
  8854. "text": props.cancelButtonText || t$7("cancel"),
  8855. "class": bem$F("cancel"),
  8856. "style": {
  8857. color: props.cancelButtonColor
  8858. },
  8859. "loading": loading.cancel,
  8860. "disabled": props.cancelButtonDisabled,
  8861. "onClick": onCancel
  8862. }, null), props.showConfirmButton && vue.createVNode(Button, {
  8863. "size": "large",
  8864. "text": props.confirmButtonText || t$7("confirm"),
  8865. "class": [bem$F("confirm"), {
  8866. [BORDER_LEFT]: props.showCancelButton
  8867. }],
  8868. "style": {
  8869. color: props.confirmButtonColor
  8870. },
  8871. "loading": loading.confirm,
  8872. "disabled": props.confirmButtonDisabled,
  8873. "onClick": onConfirm
  8874. }, null)]);
  8875. const renderRoundButtons = () => vue.createVNode(ActionBar, {
  8876. "class": bem$F("footer")
  8877. }, {
  8878. default: () => [props.showCancelButton && vue.createVNode(ActionBarButton, {
  8879. "type": "warning",
  8880. "text": props.cancelButtonText || t$7("cancel"),
  8881. "class": bem$F("cancel"),
  8882. "color": props.cancelButtonColor,
  8883. "loading": loading.cancel,
  8884. "disabled": props.cancelButtonDisabled,
  8885. "onClick": onCancel
  8886. }, null), props.showConfirmButton && vue.createVNode(ActionBarButton, {
  8887. "type": "danger",
  8888. "text": props.confirmButtonText || t$7("confirm"),
  8889. "class": bem$F("confirm"),
  8890. "color": props.confirmButtonColor,
  8891. "loading": loading.confirm,
  8892. "disabled": props.confirmButtonDisabled,
  8893. "onClick": onConfirm
  8894. }, null)]
  8895. });
  8896. const renderFooter = () => {
  8897. if (slots.footer) {
  8898. return slots.footer();
  8899. }
  8900. return props.theme === "round-button" ? renderRoundButtons() : renderButtons();
  8901. };
  8902. return () => {
  8903. const {
  8904. width,
  8905. title,
  8906. theme,
  8907. message,
  8908. className
  8909. } = props;
  8910. return vue.createVNode(Popup, vue.mergeProps({
  8911. "ref": root,
  8912. "role": "dialog",
  8913. "class": [bem$F([theme]), className],
  8914. "style": {
  8915. width: addUnit(width)
  8916. },
  8917. "tabindex": 0,
  8918. "aria-labelledby": title || message,
  8919. "onKeydown": onKeydown,
  8920. "onUpdate:show": updateShow
  8921. }, pick(props, popupInheritKeys$1)), {
  8922. default: () => [renderTitle(), renderContent(), renderFooter()]
  8923. });
  8924. };
  8925. }
  8926. });
  8927. let instance$2;
  8928. const DEFAULT_OPTIONS = {
  8929. title: "",
  8930. width: "",
  8931. theme: null,
  8932. message: "",
  8933. overlay: true,
  8934. callback: null,
  8935. teleport: "body",
  8936. className: "",
  8937. allowHtml: false,
  8938. lockScroll: true,
  8939. transition: void 0,
  8940. beforeClose: null,
  8941. overlayClass: "",
  8942. overlayStyle: void 0,
  8943. messageAlign: "",
  8944. cancelButtonText: "",
  8945. cancelButtonColor: null,
  8946. cancelButtonDisabled: false,
  8947. confirmButtonText: "",
  8948. confirmButtonColor: null,
  8949. confirmButtonDisabled: false,
  8950. showConfirmButton: true,
  8951. showCancelButton: false,
  8952. closeOnPopstate: true,
  8953. closeOnClickOverlay: false
  8954. };
  8955. let currentOptions$1 = extend({}, DEFAULT_OPTIONS);
  8956. function initInstance$2() {
  8957. const Wrapper = {
  8958. setup() {
  8959. const {
  8960. state,
  8961. toggle
  8962. } = usePopupState();
  8963. return () => vue.createVNode(stdin_default$L, vue.mergeProps(state, {
  8964. "onUpdate:show": toggle
  8965. }), null);
  8966. }
  8967. };
  8968. ({
  8969. instance: instance$2
  8970. } = mountComponent(Wrapper));
  8971. }
  8972. function showDialog(options) {
  8973. if (!inBrowser) {
  8974. return Promise.resolve();
  8975. }
  8976. return new Promise((resolve, reject) => {
  8977. if (!instance$2) {
  8978. initInstance$2();
  8979. }
  8980. instance$2.open(extend({}, currentOptions$1, options, {
  8981. callback: (action) => {
  8982. (action === "confirm" ? resolve : reject)(action);
  8983. }
  8984. }));
  8985. });
  8986. }
  8987. const setDialogDefaultOptions = (options) => {
  8988. extend(currentOptions$1, options);
  8989. };
  8990. const resetDialogDefaultOptions = () => {
  8991. currentOptions$1 = extend({}, DEFAULT_OPTIONS);
  8992. };
  8993. const showConfirmDialog = (options) => showDialog(extend({
  8994. showCancelButton: true
  8995. }, options));
  8996. const closeDialog = () => {
  8997. if (instance$2) {
  8998. instance$2.toggle(false);
  8999. }
  9000. };
  9001. const Dialog = withInstall(stdin_default$L);
  9002. const [name$E, bem$E] = createNamespace("divider");
  9003. const dividerProps = {
  9004. dashed: Boolean,
  9005. hairline: truthProp,
  9006. contentPosition: makeStringProp("center")
  9007. };
  9008. var stdin_default$K = vue.defineComponent({
  9009. name: name$E,
  9010. props: dividerProps,
  9011. setup(props, {
  9012. slots
  9013. }) {
  9014. return () => {
  9015. var _a;
  9016. return vue.createVNode("div", {
  9017. "role": "separator",
  9018. "class": bem$E({
  9019. dashed: props.dashed,
  9020. hairline: props.hairline,
  9021. [`content-${props.contentPosition}`]: !!slots.default
  9022. })
  9023. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
  9024. };
  9025. }
  9026. });
  9027. const Divider = withInstall(stdin_default$K);
  9028. const [name$D, bem$D] = createNamespace("dropdown-menu");
  9029. const dropdownMenuProps = {
  9030. overlay: truthProp,
  9031. zIndex: numericProp,
  9032. duration: makeNumericProp(0.2),
  9033. direction: makeStringProp("down"),
  9034. activeColor: String,
  9035. closeOnClickOutside: truthProp,
  9036. closeOnClickOverlay: truthProp
  9037. };
  9038. const DROPDOWN_KEY = Symbol(name$D);
  9039. var stdin_default$J = vue.defineComponent({
  9040. name: name$D,
  9041. props: dropdownMenuProps,
  9042. setup(props, {
  9043. slots
  9044. }) {
  9045. const id = useId();
  9046. const root = vue.ref();
  9047. const barRef = vue.ref();
  9048. const offset = vue.ref(0);
  9049. const {
  9050. children,
  9051. linkChildren
  9052. } = use.useChildren(DROPDOWN_KEY);
  9053. const scrollParent = use.useScrollParent(root);
  9054. const opened = vue.computed(() => children.some((item) => item.state.showWrapper));
  9055. const barStyle = vue.computed(() => {
  9056. if (opened.value && isDef(props.zIndex)) {
  9057. return {
  9058. zIndex: +props.zIndex + 1
  9059. };
  9060. }
  9061. });
  9062. const onClickAway = () => {
  9063. if (props.closeOnClickOutside) {
  9064. children.forEach((item) => {
  9065. item.toggle(false);
  9066. });
  9067. }
  9068. };
  9069. const updateOffset = () => {
  9070. if (barRef.value) {
  9071. const rect = use.useRect(barRef);
  9072. if (props.direction === "down") {
  9073. offset.value = rect.bottom;
  9074. } else {
  9075. offset.value = windowHeight.value - rect.top;
  9076. }
  9077. }
  9078. };
  9079. const onScroll = () => {
  9080. if (opened.value) {
  9081. updateOffset();
  9082. }
  9083. };
  9084. const toggleItem = (active) => {
  9085. children.forEach((item, index) => {
  9086. if (index === active) {
  9087. updateOffset();
  9088. item.toggle();
  9089. } else if (item.state.showPopup) {
  9090. item.toggle(false, {
  9091. immediate: true
  9092. });
  9093. }
  9094. });
  9095. };
  9096. const renderTitle = (item, index) => {
  9097. const {
  9098. showPopup
  9099. } = item.state;
  9100. const {
  9101. disabled,
  9102. titleClass
  9103. } = item;
  9104. return vue.createVNode("div", {
  9105. "id": `${id}-${index}`,
  9106. "role": "button",
  9107. "tabindex": disabled ? void 0 : 0,
  9108. "class": [bem$D("item", {
  9109. disabled
  9110. }), {
  9111. [HAPTICS_FEEDBACK]: !disabled
  9112. }],
  9113. "onClick": () => {
  9114. if (!disabled) {
  9115. toggleItem(index);
  9116. }
  9117. }
  9118. }, [vue.createVNode("span", {
  9119. "class": [bem$D("title", {
  9120. down: showPopup === (props.direction === "down"),
  9121. active: showPopup
  9122. }), titleClass],
  9123. "style": {
  9124. color: showPopup ? props.activeColor : ""
  9125. }
  9126. }, [vue.createVNode("div", {
  9127. "class": "van-ellipsis"
  9128. }, [item.renderTitle()])])]);
  9129. };
  9130. linkChildren({
  9131. id,
  9132. props,
  9133. offset
  9134. });
  9135. use.useClickAway(root, onClickAway);
  9136. use.useEventListener("scroll", onScroll, {
  9137. target: scrollParent,
  9138. passive: true
  9139. });
  9140. return () => {
  9141. var _a;
  9142. return vue.createVNode("div", {
  9143. "ref": root,
  9144. "class": bem$D()
  9145. }, [vue.createVNode("div", {
  9146. "ref": barRef,
  9147. "style": barStyle.value,
  9148. "class": bem$D("bar", {
  9149. opened: opened.value
  9150. })
  9151. }, [children.map(renderTitle)]), (_a = slots.default) == null ? void 0 : _a.call(slots)]);
  9152. };
  9153. }
  9154. });
  9155. const [name$C, bem$C] = createNamespace("dropdown-item");
  9156. const dropdownItemProps = {
  9157. title: String,
  9158. options: makeArrayProp(),
  9159. disabled: Boolean,
  9160. teleport: [String, Object],
  9161. lazyRender: truthProp,
  9162. modelValue: unknownProp,
  9163. titleClass: unknownProp
  9164. };
  9165. var stdin_default$I = vue.defineComponent({
  9166. name: name$C,
  9167. inheritAttrs: false,
  9168. props: dropdownItemProps,
  9169. emits: ["open", "opened", "close", "closed", "change", "update:modelValue"],
  9170. setup(props, {
  9171. emit,
  9172. slots,
  9173. attrs
  9174. }) {
  9175. const state = vue.reactive({
  9176. showPopup: false,
  9177. transition: true,
  9178. showWrapper: false
  9179. });
  9180. const {
  9181. parent,
  9182. index
  9183. } = use.useParent(DROPDOWN_KEY);
  9184. if (!parent) {
  9185. if (process.env.NODE_ENV !== "production") {
  9186. console.error("[Vant] <DropdownItem> must be a child component of <DropdownMenu>.");
  9187. }
  9188. return;
  9189. }
  9190. const getEmitter = (name2) => () => emit(name2);
  9191. const onOpen = getEmitter("open");
  9192. const onClose = getEmitter("close");
  9193. const onOpened = getEmitter("opened");
  9194. const onClosed = () => {
  9195. state.showWrapper = false;
  9196. emit("closed");
  9197. };
  9198. const onClickWrapper = (event) => {
  9199. if (props.teleport) {
  9200. event.stopPropagation();
  9201. }
  9202. };
  9203. const toggle = (show = !state.showPopup, options = {}) => {
  9204. if (show === state.showPopup) {
  9205. return;
  9206. }
  9207. state.showPopup = show;
  9208. state.transition = !options.immediate;
  9209. if (show) {
  9210. state.showWrapper = true;
  9211. }
  9212. };
  9213. const renderTitle = () => {
  9214. if (slots.title) {
  9215. return slots.title();
  9216. }
  9217. if (props.title) {
  9218. return props.title;
  9219. }
  9220. const match = props.options.find((option) => option.value === props.modelValue);
  9221. return match ? match.text : "";
  9222. };
  9223. const renderOption = (option) => {
  9224. const {
  9225. activeColor
  9226. } = parent.props;
  9227. const active = option.value === props.modelValue;
  9228. const onClick = () => {
  9229. state.showPopup = false;
  9230. if (option.value !== props.modelValue) {
  9231. emit("update:modelValue", option.value);
  9232. emit("change", option.value);
  9233. }
  9234. };
  9235. const renderIcon = () => {
  9236. if (active) {
  9237. return vue.createVNode(Icon, {
  9238. "class": bem$C("icon"),
  9239. "color": activeColor,
  9240. "name": "success"
  9241. }, null);
  9242. }
  9243. };
  9244. return vue.createVNode(Cell, {
  9245. "role": "menuitem",
  9246. "key": option.value,
  9247. "icon": option.icon,
  9248. "title": option.text,
  9249. "class": bem$C("option", {
  9250. active
  9251. }),
  9252. "style": {
  9253. color: active ? activeColor : ""
  9254. },
  9255. "tabindex": active ? 0 : -1,
  9256. "clickable": true,
  9257. "onClick": onClick
  9258. }, {
  9259. value: renderIcon
  9260. });
  9261. };
  9262. const renderContent = () => {
  9263. const {
  9264. offset
  9265. } = parent;
  9266. const {
  9267. zIndex,
  9268. overlay,
  9269. duration,
  9270. direction,
  9271. closeOnClickOverlay
  9272. } = parent.props;
  9273. const style = getZIndexStyle(zIndex);
  9274. if (direction === "down") {
  9275. style.top = `${offset.value}px`;
  9276. } else {
  9277. style.bottom = `${offset.value}px`;
  9278. }
  9279. return vue.withDirectives(vue.createVNode("div", vue.mergeProps({
  9280. "style": style,
  9281. "class": bem$C([direction]),
  9282. "onClick": onClickWrapper
  9283. }, attrs), [vue.createVNode(Popup, {
  9284. "show": state.showPopup,
  9285. "onUpdate:show": ($event) => state.showPopup = $event,
  9286. "role": "menu",
  9287. "class": bem$C("content"),
  9288. "overlay": overlay,
  9289. "position": direction === "down" ? "top" : "bottom",
  9290. "duration": state.transition ? duration : 0,
  9291. "lazyRender": props.lazyRender,
  9292. "overlayStyle": {
  9293. position: "absolute"
  9294. },
  9295. "aria-labelledby": `${parent.id}-${index.value}`,
  9296. "closeOnClickOverlay": closeOnClickOverlay,
  9297. "onOpen": onOpen,
  9298. "onClose": onClose,
  9299. "onOpened": onOpened,
  9300. "onClosed": onClosed
  9301. }, {
  9302. default: () => {
  9303. var _a;
  9304. return [props.options.map(renderOption), (_a = slots.default) == null ? void 0 : _a.call(slots)];
  9305. }
  9306. })]), [[vue.vShow, state.showWrapper]]);
  9307. };
  9308. useExpose({
  9309. state,
  9310. toggle,
  9311. renderTitle
  9312. });
  9313. return () => {
  9314. if (props.teleport) {
  9315. return vue.createVNode(vue.Teleport, {
  9316. "to": props.teleport
  9317. }, {
  9318. default: () => [renderContent()]
  9319. });
  9320. }
  9321. return renderContent();
  9322. };
  9323. }
  9324. });
  9325. const DropdownItem = withInstall(stdin_default$I);
  9326. const DropdownMenu = withInstall(stdin_default$J);
  9327. const [name$B, bem$B] = createNamespace("grid");
  9328. const gridProps = {
  9329. square: Boolean,
  9330. center: truthProp,
  9331. border: truthProp,
  9332. gutter: numericProp,
  9333. reverse: Boolean,
  9334. iconSize: numericProp,
  9335. direction: String,
  9336. clickable: Boolean,
  9337. columnNum: makeNumericProp(4)
  9338. };
  9339. const GRID_KEY = Symbol(name$B);
  9340. var stdin_default$H = vue.defineComponent({
  9341. name: name$B,
  9342. props: gridProps,
  9343. setup(props, {
  9344. slots
  9345. }) {
  9346. const {
  9347. linkChildren
  9348. } = use.useChildren(GRID_KEY);
  9349. linkChildren({
  9350. props
  9351. });
  9352. return () => {
  9353. var _a;
  9354. return vue.createVNode("div", {
  9355. "style": {
  9356. paddingLeft: addUnit(props.gutter)
  9357. },
  9358. "class": [bem$B(), {
  9359. [BORDER_TOP]: props.border && !props.gutter
  9360. }]
  9361. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
  9362. };
  9363. }
  9364. });
  9365. const Grid = withInstall(stdin_default$H);
  9366. const [name$A, bem$A] = createNamespace("grid-item");
  9367. const gridItemProps = extend({}, routeProps, {
  9368. dot: Boolean,
  9369. text: String,
  9370. icon: String,
  9371. badge: numericProp,
  9372. iconColor: String,
  9373. iconPrefix: String,
  9374. badgeProps: Object
  9375. });
  9376. var stdin_default$G = vue.defineComponent({
  9377. name: name$A,
  9378. props: gridItemProps,
  9379. setup(props, {
  9380. slots
  9381. }) {
  9382. const {
  9383. parent,
  9384. index
  9385. } = use.useParent(GRID_KEY);
  9386. const route2 = useRoute();
  9387. if (!parent) {
  9388. if (process.env.NODE_ENV !== "production") {
  9389. console.error("[Vant] <GridItem> must be a child component of <Grid>.");
  9390. }
  9391. return;
  9392. }
  9393. const rootStyle = vue.computed(() => {
  9394. const {
  9395. square,
  9396. gutter,
  9397. columnNum
  9398. } = parent.props;
  9399. const percent = `${100 / +columnNum}%`;
  9400. const style = {
  9401. flexBasis: percent
  9402. };
  9403. if (square) {
  9404. style.paddingTop = percent;
  9405. } else if (gutter) {
  9406. const gutterValue = addUnit(gutter);
  9407. style.paddingRight = gutterValue;
  9408. if (index.value >= columnNum) {
  9409. style.marginTop = gutterValue;
  9410. }
  9411. }
  9412. return style;
  9413. });
  9414. const contentStyle = vue.computed(() => {
  9415. const {
  9416. square,
  9417. gutter
  9418. } = parent.props;
  9419. if (square && gutter) {
  9420. const gutterValue = addUnit(gutter);
  9421. return {
  9422. right: gutterValue,
  9423. bottom: gutterValue,
  9424. height: "auto"
  9425. };
  9426. }
  9427. });
  9428. const renderIcon = () => {
  9429. if (slots.icon) {
  9430. return vue.createVNode(Badge, vue.mergeProps({
  9431. "dot": props.dot,
  9432. "content": props.badge
  9433. }, props.badgeProps), {
  9434. default: slots.icon
  9435. });
  9436. }
  9437. if (props.icon) {
  9438. return vue.createVNode(Icon, {
  9439. "dot": props.dot,
  9440. "name": props.icon,
  9441. "size": parent.props.iconSize,
  9442. "badge": props.badge,
  9443. "class": bem$A("icon"),
  9444. "color": props.iconColor,
  9445. "badgeProps": props.badgeProps,
  9446. "classPrefix": props.iconPrefix
  9447. }, null);
  9448. }
  9449. };
  9450. const renderText = () => {
  9451. if (slots.text) {
  9452. return slots.text();
  9453. }
  9454. if (props.text) {
  9455. return vue.createVNode("span", {
  9456. "class": bem$A("text")
  9457. }, [props.text]);
  9458. }
  9459. };
  9460. const renderContent = () => {
  9461. if (slots.default) {
  9462. return slots.default();
  9463. }
  9464. return [renderIcon(), renderText()];
  9465. };
  9466. return () => {
  9467. const {
  9468. center,
  9469. border,
  9470. square,
  9471. gutter,
  9472. reverse,
  9473. direction,
  9474. clickable
  9475. } = parent.props;
  9476. const classes = [bem$A("content", [direction, {
  9477. center,
  9478. square,
  9479. reverse,
  9480. clickable,
  9481. surround: border && gutter
  9482. }]), {
  9483. [BORDER]: border
  9484. }];
  9485. return vue.createVNode("div", {
  9486. "class": [bem$A({
  9487. square
  9488. })],
  9489. "style": rootStyle.value
  9490. }, [vue.createVNode("div", {
  9491. "role": clickable ? "button" : void 0,
  9492. "class": classes,
  9493. "style": contentStyle.value,
  9494. "tabindex": clickable ? 0 : void 0,
  9495. "onClick": route2
  9496. }, [renderContent()])]);
  9497. };
  9498. }
  9499. });
  9500. const GridItem = withInstall(stdin_default$G);
  9501. const getDistance = (touches) => Math.sqrt((touches[0].clientX - touches[1].clientX) ** 2 + (touches[0].clientY - touches[1].clientY) ** 2);
  9502. const bem$z = createNamespace("image-preview")[1];
  9503. var stdin_default$F = vue.defineComponent({
  9504. props: {
  9505. src: String,
  9506. show: Boolean,
  9507. active: Number,
  9508. minZoom: makeRequiredProp(numericProp),
  9509. maxZoom: makeRequiredProp(numericProp),
  9510. rootWidth: makeRequiredProp(Number),
  9511. rootHeight: makeRequiredProp(Number)
  9512. },
  9513. emits: ["scale", "close", "longPress"],
  9514. setup(props, {
  9515. emit,
  9516. slots
  9517. }) {
  9518. const state = vue.reactive({
  9519. scale: 1,
  9520. moveX: 0,
  9521. moveY: 0,
  9522. moving: false,
  9523. zooming: false,
  9524. imageRatio: 0,
  9525. displayWidth: 0,
  9526. displayHeight: 0
  9527. });
  9528. const touch = useTouch();
  9529. const swipeItem = vue.ref();
  9530. const vertical = vue.computed(() => {
  9531. const {
  9532. rootWidth,
  9533. rootHeight
  9534. } = props;
  9535. const rootRatio = rootHeight / rootWidth;
  9536. return state.imageRatio > rootRatio;
  9537. });
  9538. const imageStyle = vue.computed(() => {
  9539. const {
  9540. scale,
  9541. moveX,
  9542. moveY,
  9543. moving,
  9544. zooming
  9545. } = state;
  9546. const style = {
  9547. transitionDuration: zooming || moving ? "0s" : ".3s"
  9548. };
  9549. if (scale !== 1) {
  9550. const offsetX = moveX / scale;
  9551. const offsetY = moveY / scale;
  9552. style.transform = `scale(${scale}, ${scale}) translate(${offsetX}px, ${offsetY}px)`;
  9553. }
  9554. return style;
  9555. });
  9556. const maxMoveX = vue.computed(() => {
  9557. if (state.imageRatio) {
  9558. const {
  9559. rootWidth,
  9560. rootHeight
  9561. } = props;
  9562. const displayWidth = vertical.value ? rootHeight / state.imageRatio : rootWidth;
  9563. return Math.max(0, (state.scale * displayWidth - rootWidth) / 2);
  9564. }
  9565. return 0;
  9566. });
  9567. const maxMoveY = vue.computed(() => {
  9568. if (state.imageRatio) {
  9569. const {
  9570. rootWidth,
  9571. rootHeight
  9572. } = props;
  9573. const displayHeight = vertical.value ? rootHeight : rootWidth * state.imageRatio;
  9574. return Math.max(0, (state.scale * displayHeight - rootHeight) / 2);
  9575. }
  9576. return 0;
  9577. });
  9578. const setScale = (scale) => {
  9579. scale = clamp(scale, +props.minZoom, +props.maxZoom + 1);
  9580. if (scale !== state.scale) {
  9581. state.scale = scale;
  9582. emit("scale", {
  9583. scale,
  9584. index: props.active
  9585. });
  9586. }
  9587. };
  9588. const resetScale = () => {
  9589. setScale(1);
  9590. state.moveX = 0;
  9591. state.moveY = 0;
  9592. };
  9593. const toggleScale = () => {
  9594. const scale = state.scale > 1 ? 1 : 2;
  9595. setScale(scale);
  9596. state.moveX = 0;
  9597. state.moveY = 0;
  9598. };
  9599. let fingerNum;
  9600. let startMoveX;
  9601. let startMoveY;
  9602. let startScale;
  9603. let startDistance;
  9604. let doubleTapTimer;
  9605. let touchStartTime;
  9606. const onTouchStart = (event) => {
  9607. const {
  9608. touches
  9609. } = event;
  9610. const {
  9611. offsetX
  9612. } = touch;
  9613. touch.start(event);
  9614. fingerNum = touches.length;
  9615. startMoveX = state.moveX;
  9616. startMoveY = state.moveY;
  9617. touchStartTime = Date.now();
  9618. state.moving = fingerNum === 1 && state.scale !== 1;
  9619. state.zooming = fingerNum === 2 && !offsetX.value;
  9620. if (state.zooming) {
  9621. startScale = state.scale;
  9622. startDistance = getDistance(event.touches);
  9623. }
  9624. };
  9625. const onTouchMove = (event) => {
  9626. const {
  9627. touches
  9628. } = event;
  9629. touch.move(event);
  9630. if (state.moving || state.zooming) {
  9631. preventDefault(event, true);
  9632. }
  9633. if (state.moving) {
  9634. const {
  9635. deltaX,
  9636. deltaY
  9637. } = touch;
  9638. const moveX = deltaX.value + startMoveX;
  9639. const moveY = deltaY.value + startMoveY;
  9640. state.moveX = clamp(moveX, -maxMoveX.value, maxMoveX.value);
  9641. state.moveY = clamp(moveY, -maxMoveY.value, maxMoveY.value);
  9642. }
  9643. if (state.zooming && touches.length === 2) {
  9644. const distance = getDistance(touches);
  9645. const scale = startScale * distance / startDistance;
  9646. setScale(scale);
  9647. }
  9648. };
  9649. const checkTap = () => {
  9650. if (fingerNum > 1) {
  9651. return;
  9652. }
  9653. const {
  9654. offsetX,
  9655. offsetY
  9656. } = touch;
  9657. const deltaTime = Date.now() - touchStartTime;
  9658. const TAP_TIME = 250;
  9659. const TAP_OFFSET = 5;
  9660. if (offsetX.value < TAP_OFFSET && offsetY.value < TAP_OFFSET) {
  9661. if (deltaTime < TAP_TIME) {
  9662. if (doubleTapTimer) {
  9663. clearTimeout(doubleTapTimer);
  9664. doubleTapTimer = null;
  9665. toggleScale();
  9666. } else {
  9667. doubleTapTimer = setTimeout(() => {
  9668. emit("close");
  9669. doubleTapTimer = null;
  9670. }, TAP_TIME);
  9671. }
  9672. } else if (deltaTime > LONG_PRESS_START_TIME) {
  9673. emit("longPress");
  9674. }
  9675. }
  9676. };
  9677. const onTouchEnd = (event) => {
  9678. let stopPropagation2 = false;
  9679. if (state.moving || state.zooming) {
  9680. stopPropagation2 = true;
  9681. if (state.moving && startMoveX === state.moveX && startMoveY === state.moveY) {
  9682. stopPropagation2 = false;
  9683. }
  9684. if (!event.touches.length) {
  9685. if (state.zooming) {
  9686. state.moveX = clamp(state.moveX, -maxMoveX.value, maxMoveX.value);
  9687. state.moveY = clamp(state.moveY, -maxMoveY.value, maxMoveY.value);
  9688. state.zooming = false;
  9689. }
  9690. state.moving = false;
  9691. startMoveX = 0;
  9692. startMoveY = 0;
  9693. startScale = 1;
  9694. if (state.scale < 1) {
  9695. resetScale();
  9696. }
  9697. if (state.scale > props.maxZoom) {
  9698. state.scale = +props.maxZoom;
  9699. }
  9700. }
  9701. }
  9702. preventDefault(event, stopPropagation2);
  9703. checkTap();
  9704. touch.reset();
  9705. };
  9706. const onLoad = (event) => {
  9707. const {
  9708. naturalWidth,
  9709. naturalHeight
  9710. } = event.target;
  9711. state.imageRatio = naturalHeight / naturalWidth;
  9712. };
  9713. vue.watch(() => props.active, resetScale);
  9714. vue.watch(() => props.show, (value) => {
  9715. if (!value) {
  9716. resetScale();
  9717. }
  9718. });
  9719. use.useEventListener("touchmove", onTouchMove, {
  9720. target: vue.computed(() => {
  9721. var _a;
  9722. return (_a = swipeItem.value) == null ? void 0 : _a.$el;
  9723. })
  9724. });
  9725. return () => {
  9726. const imageSlots = {
  9727. loading: () => vue.createVNode(Loading, {
  9728. "type": "spinner"
  9729. }, null)
  9730. };
  9731. return vue.createVNode(SwipeItem, {
  9732. "ref": swipeItem,
  9733. "class": bem$z("swipe-item"),
  9734. "onTouchstartPassive": onTouchStart,
  9735. "onTouchend": onTouchEnd,
  9736. "onTouchcancel": onTouchEnd
  9737. }, {
  9738. default: () => [slots.image ? vue.createVNode("div", {
  9739. "class": bem$z("image-wrap")
  9740. }, [slots.image({
  9741. src: props.src
  9742. })]) : vue.createVNode(Image$1, {
  9743. "src": props.src,
  9744. "fit": "contain",
  9745. "class": bem$z("image", {
  9746. vertical: vertical.value
  9747. }),
  9748. "style": imageStyle.value,
  9749. "onLoad": onLoad
  9750. }, imageSlots)]
  9751. });
  9752. };
  9753. }
  9754. });
  9755. const [name$z, bem$y] = createNamespace("image-preview");
  9756. const popupProps$1 = ["show", "transition", "overlayStyle", "closeOnPopstate"];
  9757. const imagePreviewProps = {
  9758. show: Boolean,
  9759. loop: truthProp,
  9760. images: makeArrayProp(),
  9761. minZoom: makeNumericProp(1 / 3),
  9762. maxZoom: makeNumericProp(3),
  9763. overlay: truthProp,
  9764. closeable: Boolean,
  9765. showIndex: truthProp,
  9766. className: unknownProp,
  9767. closeIcon: makeStringProp("clear"),
  9768. transition: String,
  9769. beforeClose: Function,
  9770. overlayClass: unknownProp,
  9771. overlayStyle: Object,
  9772. swipeDuration: makeNumericProp(300),
  9773. startPosition: makeNumericProp(0),
  9774. showIndicators: Boolean,
  9775. closeOnPopstate: truthProp,
  9776. closeIconPosition: makeStringProp("top-right")
  9777. };
  9778. var stdin_default$E = vue.defineComponent({
  9779. name: name$z,
  9780. props: imagePreviewProps,
  9781. emits: ["scale", "close", "closed", "change", "longPress", "update:show"],
  9782. setup(props, {
  9783. emit,
  9784. slots
  9785. }) {
  9786. const swipeRef = vue.ref();
  9787. const state = vue.reactive({
  9788. active: 0,
  9789. rootWidth: 0,
  9790. rootHeight: 0
  9791. });
  9792. const resize = () => {
  9793. if (swipeRef.value) {
  9794. const rect = use.useRect(swipeRef.value.$el);
  9795. state.rootWidth = rect.width;
  9796. state.rootHeight = rect.height;
  9797. swipeRef.value.resize();
  9798. }
  9799. };
  9800. const emitScale = (args) => emit("scale", args);
  9801. const updateShow = (show) => emit("update:show", show);
  9802. const emitClose = () => {
  9803. callInterceptor(props.beforeClose, {
  9804. args: [state.active],
  9805. done: () => updateShow(false)
  9806. });
  9807. };
  9808. const setActive = (active) => {
  9809. if (active !== state.active) {
  9810. state.active = active;
  9811. emit("change", active);
  9812. }
  9813. };
  9814. const renderIndex = () => {
  9815. if (props.showIndex) {
  9816. return vue.createVNode("div", {
  9817. "class": bem$y("index")
  9818. }, [slots.index ? slots.index({
  9819. index: state.active
  9820. }) : `${state.active + 1} / ${props.images.length}`]);
  9821. }
  9822. };
  9823. const renderCover = () => {
  9824. if (slots.cover) {
  9825. return vue.createVNode("div", {
  9826. "class": bem$y("cover")
  9827. }, [slots.cover()]);
  9828. }
  9829. };
  9830. const renderImages = () => vue.createVNode(Swipe, {
  9831. "ref": swipeRef,
  9832. "lazyRender": true,
  9833. "loop": props.loop,
  9834. "class": bem$y("swipe"),
  9835. "duration": props.swipeDuration,
  9836. "initialSwipe": props.startPosition,
  9837. "showIndicators": props.showIndicators,
  9838. "indicatorColor": "white",
  9839. "onChange": setActive
  9840. }, {
  9841. default: () => [props.images.map((image, index) => vue.createVNode(stdin_default$F, {
  9842. "src": image,
  9843. "show": props.show,
  9844. "active": state.active,
  9845. "maxZoom": props.maxZoom,
  9846. "minZoom": props.minZoom,
  9847. "rootWidth": state.rootWidth,
  9848. "rootHeight": state.rootHeight,
  9849. "onScale": emitScale,
  9850. "onClose": emitClose,
  9851. "onLongPress": () => emit("longPress", {
  9852. index
  9853. })
  9854. }, {
  9855. image: slots.image
  9856. }))]
  9857. });
  9858. const renderClose = () => {
  9859. if (props.closeable) {
  9860. return vue.createVNode(Icon, {
  9861. "role": "button",
  9862. "name": props.closeIcon,
  9863. "class": [bem$y("close-icon", props.closeIconPosition), HAPTICS_FEEDBACK],
  9864. "onClick": emitClose
  9865. }, null);
  9866. }
  9867. };
  9868. const onClosed = () => emit("closed");
  9869. const swipeTo = (index, options) => {
  9870. var _a;
  9871. return (_a = swipeRef.value) == null ? void 0 : _a.swipeTo(index, options);
  9872. };
  9873. useExpose({
  9874. swipeTo
  9875. });
  9876. vue.onMounted(resize);
  9877. vue.watch([windowWidth, windowHeight], resize);
  9878. vue.watch(() => props.startPosition, (value) => setActive(+value));
  9879. vue.watch(() => props.show, (value) => {
  9880. const {
  9881. images,
  9882. startPosition
  9883. } = props;
  9884. if (value) {
  9885. setActive(+startPosition);
  9886. vue.nextTick(() => {
  9887. resize();
  9888. swipeTo(+startPosition, {
  9889. immediate: true
  9890. });
  9891. });
  9892. } else {
  9893. emit("close", {
  9894. index: state.active,
  9895. url: images[state.active]
  9896. });
  9897. }
  9898. });
  9899. return () => vue.createVNode(Popup, vue.mergeProps({
  9900. "class": [bem$y(), props.className],
  9901. "overlayClass": [bem$y("overlay"), props.overlayClass],
  9902. "onClosed": onClosed,
  9903. "onUpdate:show": updateShow
  9904. }, pick(props, popupProps$1)), {
  9905. default: () => [renderClose(), renderImages(), renderIndex(), renderCover()]
  9906. });
  9907. }
  9908. });
  9909. let instance$1;
  9910. const defaultConfig = {
  9911. loop: true,
  9912. images: [],
  9913. maxZoom: 3,
  9914. minZoom: 1 / 3,
  9915. onScale: void 0,
  9916. onClose: void 0,
  9917. onChange: void 0,
  9918. teleport: "body",
  9919. className: "",
  9920. showIndex: true,
  9921. closeable: false,
  9922. closeIcon: "clear",
  9923. transition: void 0,
  9924. beforeClose: void 0,
  9925. overlayStyle: void 0,
  9926. overlayClass: void 0,
  9927. startPosition: 0,
  9928. swipeDuration: 300,
  9929. showIndicators: false,
  9930. closeOnPopstate: true,
  9931. closeIconPosition: "top-right"
  9932. };
  9933. function initInstance$1() {
  9934. ({
  9935. instance: instance$1
  9936. } = mountComponent({
  9937. setup() {
  9938. const {
  9939. state,
  9940. toggle
  9941. } = usePopupState();
  9942. const onClosed = () => {
  9943. state.images = [];
  9944. };
  9945. return () => vue.createVNode(stdin_default$E, vue.mergeProps(state, {
  9946. "onClosed": onClosed,
  9947. "onUpdate:show": toggle
  9948. }), null);
  9949. }
  9950. }));
  9951. }
  9952. const showImagePreview = (options, startPosition = 0) => {
  9953. if (!inBrowser) {
  9954. return;
  9955. }
  9956. if (!instance$1) {
  9957. initInstance$1();
  9958. }
  9959. options = Array.isArray(options) ? {
  9960. images: options,
  9961. startPosition
  9962. } : options;
  9963. instance$1.open(extend({}, defaultConfig, options));
  9964. return instance$1;
  9965. };
  9966. const ImagePreview = withInstall(stdin_default$E);
  9967. function genAlphabet() {
  9968. const charCodeOfA = "A".charCodeAt(0);
  9969. const indexList = Array(26).fill("").map((_, i) => String.fromCharCode(charCodeOfA + i));
  9970. return indexList;
  9971. }
  9972. const [name$y, bem$x] = createNamespace("index-bar");
  9973. const indexBarProps = {
  9974. sticky: truthProp,
  9975. zIndex: numericProp,
  9976. teleport: [String, Object],
  9977. highlightColor: String,
  9978. stickyOffsetTop: makeNumberProp(0),
  9979. indexList: {
  9980. type: Array,
  9981. default: genAlphabet
  9982. }
  9983. };
  9984. const INDEX_BAR_KEY = Symbol(name$y);
  9985. var stdin_default$D = vue.defineComponent({
  9986. name: name$y,
  9987. props: indexBarProps,
  9988. emits: ["select", "change"],
  9989. setup(props, {
  9990. emit,
  9991. slots
  9992. }) {
  9993. const root = vue.ref();
  9994. const sidebar = vue.ref();
  9995. const activeAnchor = vue.ref("");
  9996. const touch = useTouch();
  9997. const scrollParent = use.useScrollParent(root);
  9998. const {
  9999. children,
  10000. linkChildren
  10001. } = use.useChildren(INDEX_BAR_KEY);
  10002. let selectActiveIndex;
  10003. linkChildren({
  10004. props
  10005. });
  10006. const sidebarStyle = vue.computed(() => {
  10007. if (isDef(props.zIndex)) {
  10008. return {
  10009. zIndex: +props.zIndex + 1
  10010. };
  10011. }
  10012. });
  10013. const highlightStyle = vue.computed(() => {
  10014. if (props.highlightColor) {
  10015. return {
  10016. color: props.highlightColor
  10017. };
  10018. }
  10019. });
  10020. const getActiveAnchor = (scrollTop, rects) => {
  10021. for (let i = children.length - 1; i >= 0; i--) {
  10022. const prevHeight = i > 0 ? rects[i - 1].height : 0;
  10023. const reachTop = props.sticky ? prevHeight + props.stickyOffsetTop : 0;
  10024. if (scrollTop + reachTop >= rects[i].top) {
  10025. return i;
  10026. }
  10027. }
  10028. return -1;
  10029. };
  10030. const getMatchAnchor = (index) => children.find((item) => String(item.index) === index);
  10031. const onScroll = () => {
  10032. if (isHidden(root)) {
  10033. return;
  10034. }
  10035. const {
  10036. sticky,
  10037. indexList
  10038. } = props;
  10039. const scrollTop = getScrollTop(scrollParent.value);
  10040. const scrollParentRect = use.useRect(scrollParent);
  10041. const rects = children.map((item) => item.getRect(scrollParent.value, scrollParentRect));
  10042. let active = -1;
  10043. if (selectActiveIndex) {
  10044. const match = getMatchAnchor(selectActiveIndex);
  10045. if (match) {
  10046. const rect = match.getRect(scrollParent.value, scrollParentRect);
  10047. active = getActiveAnchor(rect.top, rects);
  10048. }
  10049. } else {
  10050. active = getActiveAnchor(scrollTop, rects);
  10051. }
  10052. activeAnchor.value = indexList[active];
  10053. if (sticky) {
  10054. children.forEach((item, index) => {
  10055. const {
  10056. state,
  10057. $el
  10058. } = item;
  10059. if (index === active || index === active - 1) {
  10060. const rect = $el.getBoundingClientRect();
  10061. state.left = rect.left;
  10062. state.width = rect.width;
  10063. } else {
  10064. state.left = null;
  10065. state.width = null;
  10066. }
  10067. if (index === active) {
  10068. state.active = true;
  10069. state.top = Math.max(props.stickyOffsetTop, rects[index].top - scrollTop) + scrollParentRect.top;
  10070. } else if (index === active - 1 && selectActiveIndex === "") {
  10071. const activeItemTop = rects[active].top - scrollTop;
  10072. state.active = activeItemTop > 0;
  10073. state.top = activeItemTop + scrollParentRect.top - rects[index].height;
  10074. } else {
  10075. state.active = false;
  10076. }
  10077. });
  10078. }
  10079. selectActiveIndex = "";
  10080. };
  10081. const init = () => {
  10082. vue.nextTick(onScroll);
  10083. };
  10084. use.useEventListener("scroll", onScroll, {
  10085. target: scrollParent,
  10086. passive: true
  10087. });
  10088. vue.onMounted(init);
  10089. vue.watch(() => props.indexList, init);
  10090. vue.watch(activeAnchor, (value) => {
  10091. if (value) {
  10092. emit("change", value);
  10093. }
  10094. });
  10095. const renderIndexes = () => props.indexList.map((index) => {
  10096. const active = index === activeAnchor.value;
  10097. return vue.createVNode("span", {
  10098. "class": bem$x("index", {
  10099. active
  10100. }),
  10101. "style": active ? highlightStyle.value : void 0,
  10102. "data-index": index
  10103. }, [index]);
  10104. });
  10105. const scrollTo = (index) => {
  10106. selectActiveIndex = String(index);
  10107. const match = getMatchAnchor(selectActiveIndex);
  10108. if (match) {
  10109. const scrollTop = getScrollTop(scrollParent.value);
  10110. const scrollParentRect = use.useRect(scrollParent);
  10111. const {
  10112. offsetHeight
  10113. } = document.documentElement;
  10114. match.$el.scrollIntoView();
  10115. if (scrollTop === offsetHeight - scrollParentRect.height) {
  10116. onScroll();
  10117. return;
  10118. }
  10119. if (props.sticky && props.stickyOffsetTop) {
  10120. setRootScrollTop(getRootScrollTop() - props.stickyOffsetTop);
  10121. }
  10122. emit("select", match.index);
  10123. }
  10124. };
  10125. const scrollToElement = (element) => {
  10126. const {
  10127. index
  10128. } = element.dataset;
  10129. if (index) {
  10130. scrollTo(index);
  10131. }
  10132. };
  10133. const onClickSidebar = (event) => {
  10134. scrollToElement(event.target);
  10135. };
  10136. let touchActiveIndex;
  10137. const onTouchMove = (event) => {
  10138. touch.move(event);
  10139. if (touch.isVertical()) {
  10140. preventDefault(event);
  10141. const {
  10142. clientX,
  10143. clientY
  10144. } = event.touches[0];
  10145. const target = document.elementFromPoint(clientX, clientY);
  10146. if (target) {
  10147. const {
  10148. index
  10149. } = target.dataset;
  10150. if (index && touchActiveIndex !== index) {
  10151. touchActiveIndex = index;
  10152. scrollToElement(target);
  10153. }
  10154. }
  10155. }
  10156. };
  10157. const renderSidebar = () => vue.createVNode("div", {
  10158. "ref": sidebar,
  10159. "class": bem$x("sidebar"),
  10160. "style": sidebarStyle.value,
  10161. "onClick": onClickSidebar,
  10162. "onTouchstartPassive": touch.start
  10163. }, [renderIndexes()]);
  10164. useExpose({
  10165. scrollTo
  10166. });
  10167. use.useEventListener("touchmove", onTouchMove, {
  10168. target: sidebar
  10169. });
  10170. return () => {
  10171. var _a;
  10172. return vue.createVNode("div", {
  10173. "ref": root,
  10174. "class": bem$x()
  10175. }, [props.teleport ? vue.createVNode(vue.Teleport, {
  10176. "to": props.teleport
  10177. }, {
  10178. default: () => [renderSidebar()]
  10179. }) : renderSidebar(), (_a = slots.default) == null ? void 0 : _a.call(slots)]);
  10180. };
  10181. }
  10182. });
  10183. const [name$x, bem$w] = createNamespace("index-anchor");
  10184. const indexAnchorProps = {
  10185. index: numericProp
  10186. };
  10187. var stdin_default$C = vue.defineComponent({
  10188. name: name$x,
  10189. props: indexAnchorProps,
  10190. setup(props, {
  10191. slots
  10192. }) {
  10193. const state = vue.reactive({
  10194. top: 0,
  10195. left: null,
  10196. rect: {
  10197. top: 0,
  10198. height: 0
  10199. },
  10200. width: null,
  10201. active: false
  10202. });
  10203. const root = vue.ref();
  10204. const {
  10205. parent
  10206. } = use.useParent(INDEX_BAR_KEY);
  10207. if (!parent) {
  10208. if (process.env.NODE_ENV !== "production") {
  10209. console.error("[Vant] <IndexAnchor> must be a child component of <IndexBar>.");
  10210. }
  10211. return;
  10212. }
  10213. const isSticky = () => state.active && parent.props.sticky;
  10214. const anchorStyle = vue.computed(() => {
  10215. const {
  10216. zIndex,
  10217. highlightColor
  10218. } = parent.props;
  10219. if (isSticky()) {
  10220. return extend(getZIndexStyle(zIndex), {
  10221. left: state.left ? `${state.left}px` : void 0,
  10222. width: state.width ? `${state.width}px` : void 0,
  10223. transform: state.top ? `translate3d(0, ${state.top}px, 0)` : void 0,
  10224. color: highlightColor
  10225. });
  10226. }
  10227. });
  10228. const getRect = (scrollParent, scrollParentRect) => {
  10229. const rootRect = use.useRect(root);
  10230. state.rect.height = rootRect.height;
  10231. if (scrollParent === window || scrollParent === document.body) {
  10232. state.rect.top = rootRect.top + getRootScrollTop();
  10233. } else {
  10234. state.rect.top = rootRect.top + getScrollTop(scrollParent) - scrollParentRect.top;
  10235. }
  10236. return state.rect;
  10237. };
  10238. useExpose({
  10239. state,
  10240. getRect
  10241. });
  10242. return () => {
  10243. const sticky = isSticky();
  10244. return vue.createVNode("div", {
  10245. "ref": root,
  10246. "style": {
  10247. height: sticky ? `${state.rect.height}px` : void 0
  10248. }
  10249. }, [vue.createVNode("div", {
  10250. "style": anchorStyle.value,
  10251. "class": [bem$w({
  10252. sticky
  10253. }), {
  10254. [BORDER_BOTTOM]: sticky
  10255. }]
  10256. }, [slots.default ? slots.default() : props.index])]);
  10257. };
  10258. }
  10259. });
  10260. const IndexAnchor = withInstall(stdin_default$C);
  10261. const IndexBar = withInstall(stdin_default$D);
  10262. const [name$w, bem$v, t$6] = createNamespace("list");
  10263. const listProps = {
  10264. error: Boolean,
  10265. offset: makeNumericProp(300),
  10266. loading: Boolean,
  10267. disabled: Boolean,
  10268. finished: Boolean,
  10269. errorText: String,
  10270. direction: makeStringProp("down"),
  10271. loadingText: String,
  10272. finishedText: String,
  10273. immediateCheck: truthProp
  10274. };
  10275. var stdin_default$B = vue.defineComponent({
  10276. name: name$w,
  10277. props: listProps,
  10278. emits: ["load", "update:error", "update:loading"],
  10279. setup(props, {
  10280. emit,
  10281. slots
  10282. }) {
  10283. const loading = vue.ref(props.loading);
  10284. const root = vue.ref();
  10285. const placeholder = vue.ref();
  10286. const tabStatus = useTabStatus();
  10287. const scrollParent = use.useScrollParent(root);
  10288. const check = () => {
  10289. vue.nextTick(() => {
  10290. if (loading.value || props.finished || props.disabled || props.error || (tabStatus == null ? void 0 : tabStatus.value) === false) {
  10291. return;
  10292. }
  10293. const {
  10294. offset,
  10295. direction
  10296. } = props;
  10297. const scrollParentRect = use.useRect(scrollParent);
  10298. if (!scrollParentRect.height || isHidden(root)) {
  10299. return;
  10300. }
  10301. let isReachEdge = false;
  10302. const placeholderRect = use.useRect(placeholder);
  10303. if (direction === "up") {
  10304. isReachEdge = scrollParentRect.top - placeholderRect.top <= offset;
  10305. } else {
  10306. isReachEdge = placeholderRect.bottom - scrollParentRect.bottom <= offset;
  10307. }
  10308. if (isReachEdge) {
  10309. loading.value = true;
  10310. emit("update:loading", true);
  10311. emit("load");
  10312. }
  10313. });
  10314. };
  10315. const renderFinishedText = () => {
  10316. if (props.finished) {
  10317. const text = slots.finished ? slots.finished() : props.finishedText;
  10318. if (text) {
  10319. return vue.createVNode("div", {
  10320. "class": bem$v("finished-text")
  10321. }, [text]);
  10322. }
  10323. }
  10324. };
  10325. const clickErrorText = () => {
  10326. emit("update:error", false);
  10327. check();
  10328. };
  10329. const renderErrorText = () => {
  10330. if (props.error) {
  10331. const text = slots.error ? slots.error() : props.errorText;
  10332. if (text) {
  10333. return vue.createVNode("div", {
  10334. "role": "button",
  10335. "class": bem$v("error-text"),
  10336. "tabindex": 0,
  10337. "onClick": clickErrorText
  10338. }, [text]);
  10339. }
  10340. }
  10341. };
  10342. const renderLoading = () => {
  10343. if (loading.value && !props.finished && !props.disabled) {
  10344. return vue.createVNode("div", {
  10345. "class": bem$v("loading")
  10346. }, [slots.loading ? slots.loading() : vue.createVNode(Loading, {
  10347. "class": bem$v("loading-icon")
  10348. }, {
  10349. default: () => [props.loadingText || t$6("loading")]
  10350. })]);
  10351. }
  10352. };
  10353. vue.watch(() => [props.loading, props.finished, props.error], check);
  10354. if (tabStatus) {
  10355. vue.watch(tabStatus, (tabActive) => {
  10356. if (tabActive) {
  10357. check();
  10358. }
  10359. });
  10360. }
  10361. vue.onUpdated(() => {
  10362. loading.value = props.loading;
  10363. });
  10364. vue.onMounted(() => {
  10365. if (props.immediateCheck) {
  10366. check();
  10367. }
  10368. });
  10369. useExpose({
  10370. check
  10371. });
  10372. use.useEventListener("scroll", check, {
  10373. target: scrollParent,
  10374. passive: true
  10375. });
  10376. return () => {
  10377. var _a;
  10378. const Content = (_a = slots.default) == null ? void 0 : _a.call(slots);
  10379. const Placeholder = vue.createVNode("div", {
  10380. "ref": placeholder,
  10381. "class": bem$v("placeholder")
  10382. }, null);
  10383. return vue.createVNode("div", {
  10384. "ref": root,
  10385. "role": "feed",
  10386. "class": bem$v(),
  10387. "aria-busy": loading.value
  10388. }, [props.direction === "down" ? Content : Placeholder, renderLoading(), renderFinishedText(), renderErrorText(), props.direction === "up" ? Content : Placeholder]);
  10389. };
  10390. }
  10391. });
  10392. const List = withInstall(stdin_default$B);
  10393. const [name$v, bem$u] = createNamespace("nav-bar");
  10394. const navBarProps = {
  10395. title: String,
  10396. fixed: Boolean,
  10397. zIndex: numericProp,
  10398. border: truthProp,
  10399. leftText: String,
  10400. rightText: String,
  10401. leftArrow: Boolean,
  10402. placeholder: Boolean,
  10403. safeAreaInsetTop: Boolean,
  10404. clickable: truthProp
  10405. };
  10406. var stdin_default$A = vue.defineComponent({
  10407. name: name$v,
  10408. props: navBarProps,
  10409. emits: ["clickLeft", "clickRight"],
  10410. setup(props, {
  10411. emit,
  10412. slots
  10413. }) {
  10414. const navBarRef = vue.ref();
  10415. const renderPlaceholder = usePlaceholder(navBarRef, bem$u);
  10416. const onClickLeft = (event) => emit("clickLeft", event);
  10417. const onClickRight = (event) => emit("clickRight", event);
  10418. const renderLeft = () => {
  10419. if (slots.left) {
  10420. return slots.left();
  10421. }
  10422. return [props.leftArrow && vue.createVNode(Icon, {
  10423. "class": bem$u("arrow"),
  10424. "name": "arrow-left"
  10425. }, null), props.leftText && vue.createVNode("span", {
  10426. "class": bem$u("text")
  10427. }, [props.leftText])];
  10428. };
  10429. const renderRight = () => {
  10430. if (slots.right) {
  10431. return slots.right();
  10432. }
  10433. return vue.createVNode("span", {
  10434. "class": bem$u("text")
  10435. }, [props.rightText]);
  10436. };
  10437. const renderNavBar = () => {
  10438. const {
  10439. title,
  10440. fixed,
  10441. border,
  10442. zIndex
  10443. } = props;
  10444. const style = getZIndexStyle(zIndex);
  10445. const hasLeft = props.leftArrow || props.leftText || slots.left;
  10446. const hasRight = props.rightText || slots.right;
  10447. return vue.createVNode("div", {
  10448. "ref": navBarRef,
  10449. "style": style,
  10450. "class": [bem$u({
  10451. fixed
  10452. }), {
  10453. [BORDER_BOTTOM]: border,
  10454. "van-safe-area-top": props.safeAreaInsetTop
  10455. }]
  10456. }, [vue.createVNode("div", {
  10457. "class": bem$u("content")
  10458. }, [hasLeft && vue.createVNode("div", {
  10459. "class": [bem$u("left"), props.clickable ? HAPTICS_FEEDBACK : ""],
  10460. "onClick": onClickLeft
  10461. }, [renderLeft()]), vue.createVNode("div", {
  10462. "class": [bem$u("title"), "van-ellipsis"]
  10463. }, [slots.title ? slots.title() : title]), hasRight && vue.createVNode("div", {
  10464. "class": [bem$u("right"), props.clickable ? HAPTICS_FEEDBACK : ""],
  10465. "onClick": onClickRight
  10466. }, [renderRight()])])]);
  10467. };
  10468. return () => {
  10469. if (props.fixed && props.placeholder) {
  10470. return renderPlaceholder(renderNavBar);
  10471. }
  10472. return renderNavBar();
  10473. };
  10474. }
  10475. });
  10476. const NavBar = withInstall(stdin_default$A);
  10477. const [name$u, bem$t] = createNamespace("notice-bar");
  10478. const noticeBarProps = {
  10479. text: String,
  10480. mode: String,
  10481. color: String,
  10482. delay: makeNumericProp(1),
  10483. speed: makeNumericProp(60),
  10484. leftIcon: String,
  10485. wrapable: Boolean,
  10486. background: String,
  10487. scrollable: {
  10488. type: Boolean,
  10489. default: null
  10490. }
  10491. };
  10492. var stdin_default$z = vue.defineComponent({
  10493. name: name$u,
  10494. props: noticeBarProps,
  10495. emits: ["close", "replay"],
  10496. setup(props, {
  10497. emit,
  10498. slots
  10499. }) {
  10500. let wrapWidth = 0;
  10501. let contentWidth = 0;
  10502. let startTimer;
  10503. const wrapRef = vue.ref();
  10504. const contentRef = vue.ref();
  10505. const state = vue.reactive({
  10506. show: true,
  10507. offset: 0,
  10508. duration: 0
  10509. });
  10510. const renderLeftIcon = () => {
  10511. if (slots["left-icon"]) {
  10512. return slots["left-icon"]();
  10513. }
  10514. if (props.leftIcon) {
  10515. return vue.createVNode(Icon, {
  10516. "class": bem$t("left-icon"),
  10517. "name": props.leftIcon
  10518. }, null);
  10519. }
  10520. };
  10521. const getRightIconName = () => {
  10522. if (props.mode === "closeable") {
  10523. return "cross";
  10524. }
  10525. if (props.mode === "link") {
  10526. return "arrow";
  10527. }
  10528. };
  10529. const onClickRightIcon = (event) => {
  10530. if (props.mode === "closeable") {
  10531. state.show = false;
  10532. emit("close", event);
  10533. }
  10534. };
  10535. const renderRightIcon = () => {
  10536. if (slots["right-icon"]) {
  10537. return slots["right-icon"]();
  10538. }
  10539. const name2 = getRightIconName();
  10540. if (name2) {
  10541. return vue.createVNode(Icon, {
  10542. "name": name2,
  10543. "class": bem$t("right-icon"),
  10544. "onClick": onClickRightIcon
  10545. }, null);
  10546. }
  10547. };
  10548. const onTransitionEnd = () => {
  10549. state.offset = wrapWidth;
  10550. state.duration = 0;
  10551. use.raf(() => {
  10552. use.doubleRaf(() => {
  10553. state.offset = -contentWidth;
  10554. state.duration = (contentWidth + wrapWidth) / +props.speed;
  10555. emit("replay");
  10556. });
  10557. });
  10558. };
  10559. const renderMarquee = () => {
  10560. const ellipsis = props.scrollable === false && !props.wrapable;
  10561. const style = {
  10562. transform: state.offset ? `translateX(${state.offset}px)` : "",
  10563. transitionDuration: `${state.duration}s`
  10564. };
  10565. return vue.createVNode("div", {
  10566. "ref": wrapRef,
  10567. "role": "marquee",
  10568. "class": bem$t("wrap")
  10569. }, [vue.createVNode("div", {
  10570. "ref": contentRef,
  10571. "style": style,
  10572. "class": [bem$t("content"), {
  10573. "van-ellipsis": ellipsis
  10574. }],
  10575. "onTransitionend": onTransitionEnd
  10576. }, [slots.default ? slots.default() : props.text])]);
  10577. };
  10578. const reset = () => {
  10579. const {
  10580. delay,
  10581. speed,
  10582. scrollable
  10583. } = props;
  10584. const ms = isDef(delay) ? +delay * 1e3 : 0;
  10585. wrapWidth = 0;
  10586. contentWidth = 0;
  10587. state.offset = 0;
  10588. state.duration = 0;
  10589. clearTimeout(startTimer);
  10590. startTimer = setTimeout(() => {
  10591. if (!wrapRef.value || !contentRef.value || scrollable === false) {
  10592. return;
  10593. }
  10594. const wrapRefWidth = use.useRect(wrapRef).width;
  10595. const contentRefWidth = use.useRect(contentRef).width;
  10596. if (scrollable || contentRefWidth > wrapRefWidth) {
  10597. use.doubleRaf(() => {
  10598. wrapWidth = wrapRefWidth;
  10599. contentWidth = contentRefWidth;
  10600. state.offset = -contentWidth;
  10601. state.duration = contentWidth / +speed;
  10602. });
  10603. }
  10604. }, ms);
  10605. };
  10606. onPopupReopen(reset);
  10607. use.onMountedOrActivated(reset);
  10608. use.useEventListener("pageshow", reset);
  10609. useExpose({
  10610. reset
  10611. });
  10612. vue.watch(() => [props.text, props.scrollable], reset);
  10613. return () => {
  10614. const {
  10615. color,
  10616. wrapable,
  10617. background
  10618. } = props;
  10619. return vue.withDirectives(vue.createVNode("div", {
  10620. "role": "alert",
  10621. "class": bem$t({
  10622. wrapable
  10623. }),
  10624. "style": {
  10625. color,
  10626. background
  10627. }
  10628. }, [renderLeftIcon(), renderMarquee(), renderRightIcon()]), [[vue.vShow, state.show]]);
  10629. };
  10630. }
  10631. });
  10632. const NoticeBar = withInstall(stdin_default$z);
  10633. const [name$t, bem$s] = createNamespace("notify");
  10634. const notifyProps = extend({}, popupSharedProps, {
  10635. type: makeStringProp("danger"),
  10636. color: String,
  10637. message: numericProp,
  10638. position: makeStringProp("top"),
  10639. className: unknownProp,
  10640. background: String,
  10641. lockScroll: Boolean
  10642. });
  10643. var stdin_default$y = vue.defineComponent({
  10644. name: name$t,
  10645. props: notifyProps,
  10646. emits: ["update:show"],
  10647. setup(props, {
  10648. emit,
  10649. slots
  10650. }) {
  10651. const updateShow = (show) => emit("update:show", show);
  10652. return () => vue.createVNode(Popup, {
  10653. "show": props.show,
  10654. "class": [bem$s([props.type]), props.className],
  10655. "style": {
  10656. color: props.color,
  10657. background: props.background
  10658. },
  10659. "overlay": false,
  10660. "zIndex": props.zIndex,
  10661. "position": props.position,
  10662. "duration": 0.2,
  10663. "lockScroll": props.lockScroll,
  10664. "onUpdate:show": updateShow
  10665. }, {
  10666. default: () => [slots.default ? slots.default() : props.message]
  10667. });
  10668. }
  10669. });
  10670. let timer;
  10671. let instance;
  10672. const parseOptions = (message) => isObject(message) ? message : {
  10673. message
  10674. };
  10675. function initInstance() {
  10676. ({
  10677. instance
  10678. } = mountComponent({
  10679. setup() {
  10680. const {
  10681. state,
  10682. toggle
  10683. } = usePopupState();
  10684. return () => vue.createVNode(stdin_default$y, vue.mergeProps(state, {
  10685. "onUpdate:show": toggle
  10686. }), null);
  10687. }
  10688. }));
  10689. }
  10690. const getDefaultOptions = () => ({
  10691. type: "danger",
  10692. color: void 0,
  10693. message: "",
  10694. onClose: void 0,
  10695. onClick: void 0,
  10696. onOpened: void 0,
  10697. duration: 3e3,
  10698. position: void 0,
  10699. className: "",
  10700. lockScroll: false,
  10701. background: void 0
  10702. });
  10703. let currentOptions = getDefaultOptions();
  10704. const closeNotify = () => {
  10705. if (instance) {
  10706. instance.toggle(false);
  10707. }
  10708. };
  10709. function showNotify(options) {
  10710. if (!inBrowser) {
  10711. return;
  10712. }
  10713. if (!instance) {
  10714. initInstance();
  10715. }
  10716. options = extend({}, currentOptions, parseOptions(options));
  10717. instance.open(options);
  10718. clearTimeout(timer);
  10719. if (options.duration > 0) {
  10720. timer = setTimeout(closeNotify, options.duration);
  10721. }
  10722. return instance;
  10723. }
  10724. const setNotifyDefaultOptions = (options) => extend(currentOptions, options);
  10725. const resetNotifyDefaultOptions = () => {
  10726. currentOptions = getDefaultOptions();
  10727. };
  10728. const Notify = withInstall(stdin_default$y);
  10729. const [name$s, bem$r] = createNamespace("key");
  10730. const CollapseIcon = vue.createVNode("svg", {
  10731. "class": bem$r("collapse-icon"),
  10732. "viewBox": "0 0 30 24"
  10733. }, [vue.createVNode("path", {
  10734. "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",
  10735. "fill": "currentColor"
  10736. }, null)]);
  10737. const DeleteIcon = vue.createVNode("svg", {
  10738. "class": bem$r("delete-icon"),
  10739. "viewBox": "0 0 32 22"
  10740. }, [vue.createVNode("path", {
  10741. "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",
  10742. "fill": "currentColor"
  10743. }, null)]);
  10744. var stdin_default$x = vue.defineComponent({
  10745. name: name$s,
  10746. props: {
  10747. type: String,
  10748. text: numericProp,
  10749. color: String,
  10750. wider: Boolean,
  10751. large: Boolean,
  10752. loading: Boolean
  10753. },
  10754. emits: ["press"],
  10755. setup(props, {
  10756. emit,
  10757. slots
  10758. }) {
  10759. const active = vue.ref(false);
  10760. const touch = useTouch();
  10761. const onTouchStart = (event) => {
  10762. touch.start(event);
  10763. active.value = true;
  10764. };
  10765. const onTouchMove = (event) => {
  10766. touch.move(event);
  10767. if (touch.direction.value) {
  10768. active.value = false;
  10769. }
  10770. };
  10771. const onTouchEnd = (event) => {
  10772. if (active.value) {
  10773. if (!slots.default) {
  10774. preventDefault(event);
  10775. }
  10776. active.value = false;
  10777. emit("press", props.text, props.type);
  10778. }
  10779. };
  10780. const renderContent = () => {
  10781. if (props.loading) {
  10782. return vue.createVNode(Loading, {
  10783. "class": bem$r("loading-icon")
  10784. }, null);
  10785. }
  10786. const text = slots.default ? slots.default() : props.text;
  10787. switch (props.type) {
  10788. case "delete":
  10789. return text || DeleteIcon;
  10790. case "extra":
  10791. return text || CollapseIcon;
  10792. default:
  10793. return text;
  10794. }
  10795. };
  10796. return () => vue.createVNode("div", {
  10797. "class": bem$r("wrapper", {
  10798. wider: props.wider
  10799. }),
  10800. "onTouchstartPassive": onTouchStart,
  10801. "onTouchmovePassive": onTouchMove,
  10802. "onTouchend": onTouchEnd,
  10803. "onTouchcancel": onTouchEnd
  10804. }, [vue.createVNode("div", {
  10805. "role": "button",
  10806. "tabindex": 0,
  10807. "class": bem$r([props.color, {
  10808. large: props.large,
  10809. active: active.value,
  10810. delete: props.type === "delete"
  10811. }])
  10812. }, [renderContent()])]);
  10813. }
  10814. });
  10815. const [name$r, bem$q] = createNamespace("number-keyboard");
  10816. const numberKeyboardProps = {
  10817. show: Boolean,
  10818. title: String,
  10819. theme: makeStringProp("default"),
  10820. zIndex: numericProp,
  10821. teleport: [String, Object],
  10822. maxlength: makeNumericProp(Infinity),
  10823. modelValue: makeStringProp(""),
  10824. transition: truthProp,
  10825. blurOnClose: truthProp,
  10826. showDeleteKey: truthProp,
  10827. randomKeyOrder: Boolean,
  10828. closeButtonText: String,
  10829. deleteButtonText: String,
  10830. closeButtonLoading: Boolean,
  10831. hideOnClickOutside: truthProp,
  10832. safeAreaInsetBottom: truthProp,
  10833. extraKey: {
  10834. type: [String, Array],
  10835. default: ""
  10836. }
  10837. };
  10838. function shuffle(array) {
  10839. for (let i = array.length - 1; i > 0; i--) {
  10840. const j = Math.floor(Math.random() * (i + 1));
  10841. const temp = array[i];
  10842. array[i] = array[j];
  10843. array[j] = temp;
  10844. }
  10845. return array;
  10846. }
  10847. var stdin_default$w = vue.defineComponent({
  10848. name: name$r,
  10849. inheritAttrs: false,
  10850. props: numberKeyboardProps,
  10851. emits: ["show", "hide", "blur", "input", "close", "delete", "update:modelValue"],
  10852. setup(props, {
  10853. emit,
  10854. slots,
  10855. attrs
  10856. }) {
  10857. const root = vue.ref();
  10858. const genBasicKeys = () => {
  10859. const keys2 = Array(9).fill("").map((_, i) => ({
  10860. text: i + 1
  10861. }));
  10862. if (props.randomKeyOrder) {
  10863. shuffle(keys2);
  10864. }
  10865. return keys2;
  10866. };
  10867. const genDefaultKeys = () => [...genBasicKeys(), {
  10868. text: props.extraKey,
  10869. type: "extra"
  10870. }, {
  10871. text: 0
  10872. }, {
  10873. text: props.showDeleteKey ? props.deleteButtonText : "",
  10874. type: props.showDeleteKey ? "delete" : ""
  10875. }];
  10876. const genCustomKeys = () => {
  10877. const keys2 = genBasicKeys();
  10878. const {
  10879. extraKey
  10880. } = props;
  10881. const extraKeys = Array.isArray(extraKey) ? extraKey : [extraKey];
  10882. if (extraKeys.length === 1) {
  10883. keys2.push({
  10884. text: 0,
  10885. wider: true
  10886. }, {
  10887. text: extraKeys[0],
  10888. type: "extra"
  10889. });
  10890. } else if (extraKeys.length === 2) {
  10891. keys2.push({
  10892. text: extraKeys[0],
  10893. type: "extra"
  10894. }, {
  10895. text: 0
  10896. }, {
  10897. text: extraKeys[1],
  10898. type: "extra"
  10899. });
  10900. }
  10901. return keys2;
  10902. };
  10903. const keys = vue.computed(() => props.theme === "custom" ? genCustomKeys() : genDefaultKeys());
  10904. const onBlur = () => {
  10905. if (props.show) {
  10906. emit("blur");
  10907. }
  10908. };
  10909. const onClose = () => {
  10910. emit("close");
  10911. if (props.blurOnClose) {
  10912. onBlur();
  10913. }
  10914. };
  10915. const onAnimationEnd = () => emit(props.show ? "show" : "hide");
  10916. const onPress = (text, type) => {
  10917. if (text === "") {
  10918. if (type === "extra") {
  10919. onBlur();
  10920. }
  10921. return;
  10922. }
  10923. const value = props.modelValue;
  10924. if (type === "delete") {
  10925. emit("delete");
  10926. emit("update:modelValue", value.slice(0, value.length - 1));
  10927. } else if (type === "close") {
  10928. onClose();
  10929. } else if (value.length < props.maxlength) {
  10930. emit("input", text);
  10931. emit("update:modelValue", value + text);
  10932. }
  10933. };
  10934. const renderTitle = () => {
  10935. const {
  10936. title,
  10937. theme,
  10938. closeButtonText
  10939. } = props;
  10940. const leftSlot = slots["title-left"];
  10941. const showClose = closeButtonText && theme === "default";
  10942. const showTitle = title || showClose || leftSlot;
  10943. if (!showTitle) {
  10944. return;
  10945. }
  10946. return vue.createVNode("div", {
  10947. "class": bem$q("header")
  10948. }, [leftSlot && vue.createVNode("span", {
  10949. "class": bem$q("title-left")
  10950. }, [leftSlot()]), title && vue.createVNode("h2", {
  10951. "class": bem$q("title")
  10952. }, [title]), showClose && vue.createVNode("button", {
  10953. "type": "button",
  10954. "class": [bem$q("close"), HAPTICS_FEEDBACK],
  10955. "onClick": onClose
  10956. }, [closeButtonText])]);
  10957. };
  10958. const renderKeys = () => keys.value.map((key) => {
  10959. const keySlots = {};
  10960. if (key.type === "delete") {
  10961. keySlots.default = slots.delete;
  10962. }
  10963. if (key.type === "extra") {
  10964. keySlots.default = slots["extra-key"];
  10965. }
  10966. return vue.createVNode(stdin_default$x, {
  10967. "key": key.text,
  10968. "text": key.text,
  10969. "type": key.type,
  10970. "wider": key.wider,
  10971. "color": key.color,
  10972. "onPress": onPress
  10973. }, keySlots);
  10974. });
  10975. const renderSidebar = () => {
  10976. if (props.theme === "custom") {
  10977. return vue.createVNode("div", {
  10978. "class": bem$q("sidebar")
  10979. }, [props.showDeleteKey && vue.createVNode(stdin_default$x, {
  10980. "large": true,
  10981. "text": props.deleteButtonText,
  10982. "type": "delete",
  10983. "onPress": onPress
  10984. }, {
  10985. delete: slots.delete
  10986. }), vue.createVNode(stdin_default$x, {
  10987. "large": true,
  10988. "text": props.closeButtonText,
  10989. "type": "close",
  10990. "color": "blue",
  10991. "loading": props.closeButtonLoading,
  10992. "onPress": onPress
  10993. }, null)]);
  10994. }
  10995. };
  10996. vue.watch(() => props.show, (value) => {
  10997. if (!props.transition) {
  10998. emit(value ? "show" : "hide");
  10999. }
  11000. });
  11001. if (props.hideOnClickOutside) {
  11002. use.useClickAway(root, onBlur, {
  11003. eventName: "touchstart"
  11004. });
  11005. }
  11006. return () => {
  11007. const Title = renderTitle();
  11008. const Content = vue.createVNode(vue.Transition, {
  11009. "name": props.transition ? "van-slide-up" : ""
  11010. }, {
  11011. default: () => [vue.withDirectives(vue.createVNode("div", vue.mergeProps({
  11012. "ref": root,
  11013. "style": getZIndexStyle(props.zIndex),
  11014. "class": bem$q({
  11015. unfit: !props.safeAreaInsetBottom,
  11016. "with-title": !!Title
  11017. }),
  11018. "onAnimationend": onAnimationEnd,
  11019. "onTouchstartPassive": stopPropagation
  11020. }, attrs), [Title, vue.createVNode("div", {
  11021. "class": bem$q("body")
  11022. }, [vue.createVNode("div", {
  11023. "class": bem$q("keys")
  11024. }, [renderKeys()]), renderSidebar()])]), [[vue.vShow, props.show]])]
  11025. });
  11026. if (props.teleport) {
  11027. return vue.createVNode(vue.Teleport, {
  11028. "to": props.teleport
  11029. }, {
  11030. default: () => [Content]
  11031. });
  11032. }
  11033. return Content;
  11034. };
  11035. }
  11036. });
  11037. const NumberKeyboard = withInstall(stdin_default$w);
  11038. const [name$q, bem$p, t$5] = createNamespace("pagination");
  11039. const makePage = (number, text, active) => ({
  11040. number,
  11041. text,
  11042. active
  11043. });
  11044. const paginationProps = {
  11045. mode: makeStringProp("multi"),
  11046. prevText: String,
  11047. nextText: String,
  11048. pageCount: makeNumericProp(0),
  11049. modelValue: makeNumberProp(0),
  11050. totalItems: makeNumericProp(0),
  11051. showPageSize: makeNumericProp(5),
  11052. itemsPerPage: makeNumericProp(10),
  11053. forceEllipses: Boolean
  11054. };
  11055. var stdin_default$v = vue.defineComponent({
  11056. name: name$q,
  11057. props: paginationProps,
  11058. emits: ["change", "update:modelValue"],
  11059. setup(props, {
  11060. emit,
  11061. slots
  11062. }) {
  11063. const count = vue.computed(() => {
  11064. const {
  11065. pageCount,
  11066. totalItems,
  11067. itemsPerPage
  11068. } = props;
  11069. const count2 = +pageCount || Math.ceil(+totalItems / +itemsPerPage);
  11070. return Math.max(1, count2);
  11071. });
  11072. const pages = vue.computed(() => {
  11073. const items = [];
  11074. const pageCount = count.value;
  11075. const showPageSize = +props.showPageSize;
  11076. const {
  11077. modelValue,
  11078. forceEllipses
  11079. } = props;
  11080. let startPage = 1;
  11081. let endPage = pageCount;
  11082. const isMaxSized = showPageSize < pageCount;
  11083. if (isMaxSized) {
  11084. startPage = Math.max(modelValue - Math.floor(showPageSize / 2), 1);
  11085. endPage = startPage + showPageSize - 1;
  11086. if (endPage > pageCount) {
  11087. endPage = pageCount;
  11088. startPage = endPage - showPageSize + 1;
  11089. }
  11090. }
  11091. for (let number = startPage; number <= endPage; number++) {
  11092. const page = makePage(number, number, number === modelValue);
  11093. items.push(page);
  11094. }
  11095. if (isMaxSized && showPageSize > 0 && forceEllipses) {
  11096. if (startPage > 1) {
  11097. const prevPages = makePage(startPage - 1, "...");
  11098. items.unshift(prevPages);
  11099. }
  11100. if (endPage < pageCount) {
  11101. const nextPages = makePage(endPage + 1, "...");
  11102. items.push(nextPages);
  11103. }
  11104. }
  11105. return items;
  11106. });
  11107. const updateModelValue = (value, emitChange) => {
  11108. value = clamp(value, 1, count.value);
  11109. if (props.modelValue !== value) {
  11110. emit("update:modelValue", value);
  11111. if (emitChange) {
  11112. emit("change", value);
  11113. }
  11114. }
  11115. };
  11116. vue.watchEffect(() => updateModelValue(props.modelValue));
  11117. const renderDesc = () => vue.createVNode("li", {
  11118. "class": bem$p("page-desc")
  11119. }, [slots.pageDesc ? slots.pageDesc() : `${props.modelValue}/${count.value}`]);
  11120. const renderPrevButton = () => {
  11121. const {
  11122. mode,
  11123. modelValue
  11124. } = props;
  11125. const slot = slots["prev-text"];
  11126. const disabled = modelValue === 1;
  11127. return vue.createVNode("li", {
  11128. "class": [bem$p("item", {
  11129. disabled,
  11130. border: mode === "simple",
  11131. prev: true
  11132. }), BORDER_SURROUND]
  11133. }, [vue.createVNode("button", {
  11134. "type": "button",
  11135. "disabled": disabled,
  11136. "onClick": () => updateModelValue(modelValue - 1, true)
  11137. }, [slot ? slot() : props.prevText || t$5("prev")])]);
  11138. };
  11139. const renderNextButton = () => {
  11140. const {
  11141. mode,
  11142. modelValue
  11143. } = props;
  11144. const slot = slots["next-text"];
  11145. const disabled = modelValue === count.value;
  11146. return vue.createVNode("li", {
  11147. "class": [bem$p("item", {
  11148. disabled,
  11149. border: mode === "simple",
  11150. next: true
  11151. }), BORDER_SURROUND]
  11152. }, [vue.createVNode("button", {
  11153. "type": "button",
  11154. "disabled": disabled,
  11155. "onClick": () => updateModelValue(modelValue + 1, true)
  11156. }, [slot ? slot() : props.nextText || t$5("next")])]);
  11157. };
  11158. const renderPages = () => pages.value.map((page) => vue.createVNode("li", {
  11159. "class": [bem$p("item", {
  11160. active: page.active,
  11161. page: true
  11162. }), BORDER_SURROUND]
  11163. }, [vue.createVNode("button", {
  11164. "type": "button",
  11165. "aria-current": page.active || void 0,
  11166. "onClick": () => updateModelValue(page.number, true)
  11167. }, [slots.page ? slots.page(page) : page.text])]));
  11168. return () => vue.createVNode("nav", {
  11169. "role": "navigation",
  11170. "class": bem$p()
  11171. }, [vue.createVNode("ul", {
  11172. "class": bem$p("items")
  11173. }, [renderPrevButton(), props.mode === "simple" ? renderDesc() : renderPages(), renderNextButton()])]);
  11174. }
  11175. });
  11176. const Pagination = withInstall(stdin_default$v);
  11177. const [name$p, bem$o] = createNamespace("password-input");
  11178. const passwordInputProps = {
  11179. info: String,
  11180. mask: truthProp,
  11181. value: makeStringProp(""),
  11182. gutter: numericProp,
  11183. length: makeNumericProp(6),
  11184. focused: Boolean,
  11185. errorInfo: String
  11186. };
  11187. var stdin_default$u = vue.defineComponent({
  11188. name: name$p,
  11189. props: passwordInputProps,
  11190. emits: ["focus"],
  11191. setup(props, {
  11192. emit
  11193. }) {
  11194. const onTouchStart = (event) => {
  11195. event.stopPropagation();
  11196. emit("focus", event);
  11197. };
  11198. const renderPoints = () => {
  11199. const Points = [];
  11200. const {
  11201. mask,
  11202. value,
  11203. length,
  11204. gutter,
  11205. focused
  11206. } = props;
  11207. for (let i = 0; i < length; i++) {
  11208. const char = value[i];
  11209. const showBorder = i !== 0 && !gutter;
  11210. const showCursor = focused && i === value.length;
  11211. let style;
  11212. if (i !== 0 && gutter) {
  11213. style = {
  11214. marginLeft: addUnit(gutter)
  11215. };
  11216. }
  11217. Points.push(vue.createVNode("li", {
  11218. "class": [{
  11219. [BORDER_LEFT]: showBorder
  11220. }, bem$o("item", {
  11221. focus: showCursor
  11222. })],
  11223. "style": style
  11224. }, [mask ? vue.createVNode("i", {
  11225. "style": {
  11226. visibility: char ? "visible" : "hidden"
  11227. }
  11228. }, null) : char, showCursor && vue.createVNode("div", {
  11229. "class": bem$o("cursor")
  11230. }, null)]));
  11231. }
  11232. return Points;
  11233. };
  11234. return () => {
  11235. const info = props.errorInfo || props.info;
  11236. return vue.createVNode("div", {
  11237. "class": bem$o()
  11238. }, [vue.createVNode("ul", {
  11239. "class": [bem$o("security"), {
  11240. [BORDER_SURROUND]: !props.gutter
  11241. }],
  11242. "onTouchstartPassive": onTouchStart
  11243. }, [renderPoints()]), info && vue.createVNode("div", {
  11244. "class": bem$o(props.errorInfo ? "error-info" : "info")
  11245. }, [info])]);
  11246. };
  11247. }
  11248. });
  11249. const PasswordInput = withInstall(stdin_default$u);
  11250. const PickerGroup = withInstall(stdin_default$1o);
  11251. const useSyncPropRef = (getProp, setProp) => {
  11252. const propRef = vue.ref(getProp());
  11253. vue.watch(getProp, (value) => {
  11254. if (value !== propRef.value) {
  11255. propRef.value = value;
  11256. }
  11257. });
  11258. vue.watch(propRef, (value) => {
  11259. if (value !== getProp()) {
  11260. setProp(value);
  11261. }
  11262. });
  11263. return propRef;
  11264. };
  11265. const [name$o, bem$n] = createNamespace("popover");
  11266. const popupProps = ["overlay", "duration", "teleport", "overlayStyle", "overlayClass", "closeOnClickOverlay"];
  11267. const popoverProps = {
  11268. show: Boolean,
  11269. theme: makeStringProp("light"),
  11270. overlay: Boolean,
  11271. actions: makeArrayProp(),
  11272. trigger: makeStringProp("click"),
  11273. duration: numericProp,
  11274. showArrow: truthProp,
  11275. placement: makeStringProp("bottom"),
  11276. iconPrefix: String,
  11277. overlayClass: unknownProp,
  11278. overlayStyle: Object,
  11279. closeOnClickAction: truthProp,
  11280. closeOnClickOverlay: truthProp,
  11281. closeOnClickOutside: truthProp,
  11282. offset: {
  11283. type: Array,
  11284. default: () => [0, 8]
  11285. },
  11286. teleport: {
  11287. type: [String, Object],
  11288. default: "body"
  11289. }
  11290. };
  11291. var stdin_default$t = vue.defineComponent({
  11292. name: name$o,
  11293. props: popoverProps,
  11294. emits: ["select", "touchstart", "update:show"],
  11295. setup(props, {
  11296. emit,
  11297. slots,
  11298. attrs
  11299. }) {
  11300. let popper;
  11301. const popupRef = vue.ref();
  11302. const wrapperRef = vue.ref();
  11303. const popoverRef = vue.ref();
  11304. const show = useSyncPropRef(() => props.show, (value) => emit("update:show", value));
  11305. const getPopoverOptions = () => ({
  11306. placement: props.placement,
  11307. modifiers: [{
  11308. name: "computeStyles",
  11309. options: {
  11310. adaptive: false,
  11311. gpuAcceleration: false
  11312. }
  11313. }, extend({}, popperjs.offsetModifier, {
  11314. options: {
  11315. offset: props.offset
  11316. }
  11317. })]
  11318. });
  11319. const createPopperInstance = () => {
  11320. if (wrapperRef.value && popoverRef.value) {
  11321. return popperjs.createPopper(wrapperRef.value, popoverRef.value.popupRef.value, getPopoverOptions());
  11322. }
  11323. return null;
  11324. };
  11325. const updateLocation = () => {
  11326. vue.nextTick(() => {
  11327. if (!show.value) {
  11328. return;
  11329. }
  11330. if (!popper) {
  11331. popper = createPopperInstance();
  11332. } else {
  11333. popper.setOptions(getPopoverOptions());
  11334. }
  11335. });
  11336. };
  11337. const updateShow = (value) => {
  11338. show.value = value;
  11339. };
  11340. const onClickWrapper = () => {
  11341. if (props.trigger === "click") {
  11342. show.value = !show.value;
  11343. }
  11344. };
  11345. const onClickAction = (action, index) => {
  11346. if (action.disabled) {
  11347. return;
  11348. }
  11349. emit("select", action, index);
  11350. if (props.closeOnClickAction) {
  11351. show.value = false;
  11352. }
  11353. };
  11354. const onClickAway = () => {
  11355. if (show.value && props.closeOnClickOutside && (!props.overlay || props.closeOnClickOverlay)) {
  11356. show.value = false;
  11357. }
  11358. };
  11359. const renderActionContent = (action, index) => {
  11360. if (slots.action) {
  11361. return slots.action({
  11362. action,
  11363. index
  11364. });
  11365. }
  11366. return [action.icon && vue.createVNode(Icon, {
  11367. "name": action.icon,
  11368. "classPrefix": props.iconPrefix,
  11369. "class": bem$n("action-icon")
  11370. }, null), vue.createVNode("div", {
  11371. "class": [bem$n("action-text"), BORDER_BOTTOM]
  11372. }, [action.text])];
  11373. };
  11374. const renderAction = (action, index) => {
  11375. const {
  11376. icon,
  11377. color,
  11378. disabled,
  11379. className
  11380. } = action;
  11381. return vue.createVNode("div", {
  11382. "role": "menuitem",
  11383. "class": [bem$n("action", {
  11384. disabled,
  11385. "with-icon": icon
  11386. }), className],
  11387. "style": {
  11388. color
  11389. },
  11390. "tabindex": disabled ? void 0 : 0,
  11391. "aria-disabled": disabled || void 0,
  11392. "onClick": () => onClickAction(action, index)
  11393. }, [renderActionContent(action, index)]);
  11394. };
  11395. vue.onMounted(() => {
  11396. updateLocation();
  11397. vue.watchEffect(() => {
  11398. var _a;
  11399. popupRef.value = (_a = popoverRef.value) == null ? void 0 : _a.popupRef.value;
  11400. });
  11401. });
  11402. vue.onBeforeUnmount(() => {
  11403. if (popper) {
  11404. popper.destroy();
  11405. popper = null;
  11406. }
  11407. });
  11408. vue.watch(() => [show.value, props.offset, props.placement], updateLocation);
  11409. use.useClickAway([wrapperRef, popupRef], onClickAway, {
  11410. eventName: "touchstart"
  11411. });
  11412. return () => {
  11413. var _a;
  11414. return vue.createVNode(vue.Fragment, null, [vue.createVNode("span", {
  11415. "ref": wrapperRef,
  11416. "class": bem$n("wrapper"),
  11417. "onClick": onClickWrapper
  11418. }, [(_a = slots.reference) == null ? void 0 : _a.call(slots)]), vue.createVNode(Popup, vue.mergeProps({
  11419. "ref": popoverRef,
  11420. "show": show.value,
  11421. "class": bem$n([props.theme]),
  11422. "position": "",
  11423. "transition": "van-popover-zoom",
  11424. "lockScroll": false,
  11425. "onUpdate:show": updateShow
  11426. }, attrs, pick(props, popupProps)), {
  11427. default: () => [props.showArrow && vue.createVNode("div", {
  11428. "class": bem$n("arrow")
  11429. }, null), vue.createVNode("div", {
  11430. "role": "menu",
  11431. "class": bem$n("content")
  11432. }, [slots.default ? slots.default() : props.actions.map(renderAction)])]
  11433. })]);
  11434. };
  11435. }
  11436. });
  11437. const Popover = withInstall(stdin_default$t);
  11438. const [name$n, bem$m] = createNamespace("progress");
  11439. const progressProps = {
  11440. color: String,
  11441. inactive: Boolean,
  11442. pivotText: String,
  11443. textColor: String,
  11444. showPivot: truthProp,
  11445. pivotColor: String,
  11446. trackColor: String,
  11447. strokeWidth: numericProp,
  11448. percentage: {
  11449. type: numericProp,
  11450. default: 0,
  11451. validator: (value) => value >= 0 && value <= 100
  11452. }
  11453. };
  11454. var stdin_default$s = vue.defineComponent({
  11455. name: name$n,
  11456. props: progressProps,
  11457. setup(props) {
  11458. const background = vue.computed(() => props.inactive ? void 0 : props.color);
  11459. const renderPivot = () => {
  11460. const {
  11461. textColor,
  11462. pivotText,
  11463. pivotColor,
  11464. percentage
  11465. } = props;
  11466. const text = pivotText != null ? pivotText : `${percentage}%`;
  11467. if (props.showPivot && text) {
  11468. const style = {
  11469. color: textColor,
  11470. left: `${+percentage}%`,
  11471. transform: `translate(-${+percentage}%,-50%)`,
  11472. background: pivotColor || background.value
  11473. };
  11474. return vue.createVNode("span", {
  11475. "style": style,
  11476. "class": bem$m("pivot", {
  11477. inactive: props.inactive
  11478. })
  11479. }, [text]);
  11480. }
  11481. };
  11482. return () => {
  11483. const {
  11484. trackColor,
  11485. percentage,
  11486. strokeWidth
  11487. } = props;
  11488. const rootStyle = {
  11489. background: trackColor,
  11490. height: addUnit(strokeWidth)
  11491. };
  11492. const portionStyle = {
  11493. width: `${percentage}%`,
  11494. background: background.value
  11495. };
  11496. return vue.createVNode("div", {
  11497. "class": bem$m(),
  11498. "style": rootStyle
  11499. }, [vue.createVNode("span", {
  11500. "class": bem$m("portion", {
  11501. inactive: props.inactive
  11502. }),
  11503. "style": portionStyle
  11504. }, null), renderPivot()]);
  11505. };
  11506. }
  11507. });
  11508. const Progress = withInstall(stdin_default$s);
  11509. const [name$m, bem$l, t$4] = createNamespace("pull-refresh");
  11510. const DEFAULT_HEAD_HEIGHT = 50;
  11511. const TEXT_STATUS = ["pulling", "loosing", "success"];
  11512. const pullRefreshProps = {
  11513. disabled: Boolean,
  11514. modelValue: Boolean,
  11515. headHeight: makeNumericProp(DEFAULT_HEAD_HEIGHT),
  11516. successText: String,
  11517. pullingText: String,
  11518. loosingText: String,
  11519. loadingText: String,
  11520. pullDistance: numericProp,
  11521. successDuration: makeNumericProp(500),
  11522. animationDuration: makeNumericProp(300)
  11523. };
  11524. var stdin_default$r = vue.defineComponent({
  11525. name: name$m,
  11526. props: pullRefreshProps,
  11527. emits: ["change", "refresh", "update:modelValue"],
  11528. setup(props, {
  11529. emit,
  11530. slots
  11531. }) {
  11532. let reachTop;
  11533. const root = vue.ref();
  11534. const track = vue.ref();
  11535. const scrollParent = use.useScrollParent(root);
  11536. const state = vue.reactive({
  11537. status: "normal",
  11538. distance: 0,
  11539. duration: 0
  11540. });
  11541. const touch = useTouch();
  11542. const getHeadStyle = () => {
  11543. if (props.headHeight !== DEFAULT_HEAD_HEIGHT) {
  11544. return {
  11545. height: `${props.headHeight}px`
  11546. };
  11547. }
  11548. };
  11549. const isTouchable = () => state.status !== "loading" && state.status !== "success" && !props.disabled;
  11550. const ease = (distance) => {
  11551. const pullDistance = +(props.pullDistance || props.headHeight);
  11552. if (distance > pullDistance) {
  11553. if (distance < pullDistance * 2) {
  11554. distance = pullDistance + (distance - pullDistance) / 2;
  11555. } else {
  11556. distance = pullDistance * 1.5 + (distance - pullDistance * 2) / 4;
  11557. }
  11558. }
  11559. return Math.round(distance);
  11560. };
  11561. const setStatus = (distance, isLoading) => {
  11562. const pullDistance = +(props.pullDistance || props.headHeight);
  11563. state.distance = distance;
  11564. if (isLoading) {
  11565. state.status = "loading";
  11566. } else if (distance === 0) {
  11567. state.status = "normal";
  11568. } else if (distance < pullDistance) {
  11569. state.status = "pulling";
  11570. } else {
  11571. state.status = "loosing";
  11572. }
  11573. emit("change", {
  11574. status: state.status,
  11575. distance
  11576. });
  11577. };
  11578. const getStatusText = () => {
  11579. const {
  11580. status
  11581. } = state;
  11582. if (status === "normal") {
  11583. return "";
  11584. }
  11585. return props[`${status}Text`] || t$4(status);
  11586. };
  11587. const renderStatus = () => {
  11588. const {
  11589. status,
  11590. distance
  11591. } = state;
  11592. if (slots[status]) {
  11593. return slots[status]({
  11594. distance
  11595. });
  11596. }
  11597. const nodes = [];
  11598. if (TEXT_STATUS.includes(status)) {
  11599. nodes.push(vue.createVNode("div", {
  11600. "class": bem$l("text")
  11601. }, [getStatusText()]));
  11602. }
  11603. if (status === "loading") {
  11604. nodes.push(vue.createVNode(Loading, {
  11605. "class": bem$l("loading")
  11606. }, {
  11607. default: getStatusText
  11608. }));
  11609. }
  11610. return nodes;
  11611. };
  11612. const showSuccessTip = () => {
  11613. state.status = "success";
  11614. setTimeout(() => {
  11615. setStatus(0);
  11616. }, +props.successDuration);
  11617. };
  11618. const checkPosition = (event) => {
  11619. reachTop = getScrollTop(scrollParent.value) === 0;
  11620. if (reachTop) {
  11621. state.duration = 0;
  11622. touch.start(event);
  11623. }
  11624. };
  11625. const onTouchStart = (event) => {
  11626. if (isTouchable()) {
  11627. checkPosition(event);
  11628. }
  11629. };
  11630. const onTouchMove = (event) => {
  11631. if (isTouchable()) {
  11632. if (!reachTop) {
  11633. checkPosition(event);
  11634. }
  11635. const {
  11636. deltaY
  11637. } = touch;
  11638. touch.move(event);
  11639. if (reachTop && deltaY.value >= 0 && touch.isVertical()) {
  11640. preventDefault(event);
  11641. setStatus(ease(deltaY.value));
  11642. }
  11643. }
  11644. };
  11645. const onTouchEnd = () => {
  11646. if (reachTop && touch.deltaY.value && isTouchable()) {
  11647. state.duration = +props.animationDuration;
  11648. if (state.status === "loosing") {
  11649. setStatus(+props.headHeight, true);
  11650. emit("update:modelValue", true);
  11651. vue.nextTick(() => emit("refresh"));
  11652. } else {
  11653. setStatus(0);
  11654. }
  11655. }
  11656. };
  11657. vue.watch(() => props.modelValue, (value) => {
  11658. state.duration = +props.animationDuration;
  11659. if (value) {
  11660. setStatus(+props.headHeight, true);
  11661. } else if (slots.success || props.successText) {
  11662. showSuccessTip();
  11663. } else {
  11664. setStatus(0, false);
  11665. }
  11666. });
  11667. use.useEventListener("touchmove", onTouchMove, {
  11668. target: track
  11669. });
  11670. return () => {
  11671. var _a;
  11672. const trackStyle = {
  11673. transitionDuration: `${state.duration}ms`,
  11674. transform: state.distance ? `translate3d(0,${state.distance}px, 0)` : ""
  11675. };
  11676. return vue.createVNode("div", {
  11677. "ref": root,
  11678. "class": bem$l()
  11679. }, [vue.createVNode("div", {
  11680. "ref": track,
  11681. "class": bem$l("track"),
  11682. "style": trackStyle,
  11683. "onTouchstartPassive": onTouchStart,
  11684. "onTouchend": onTouchEnd,
  11685. "onTouchcancel": onTouchEnd
  11686. }, [vue.createVNode("div", {
  11687. "class": bem$l("head"),
  11688. "style": getHeadStyle()
  11689. }, [renderStatus()]), (_a = slots.default) == null ? void 0 : _a.call(slots)])]);
  11690. };
  11691. }
  11692. });
  11693. const PullRefresh = withInstall(stdin_default$r);
  11694. const [name$l, bem$k] = createNamespace("rate");
  11695. function getRateStatus(value, index, allowHalf, readonly) {
  11696. if (value >= index) {
  11697. return {
  11698. status: "full",
  11699. value: 1
  11700. };
  11701. }
  11702. if (value + 0.5 >= index && allowHalf && !readonly) {
  11703. return {
  11704. status: "half",
  11705. value: 0.5
  11706. };
  11707. }
  11708. if (value + 1 >= index && allowHalf && readonly) {
  11709. const cardinal = 10 ** 10;
  11710. return {
  11711. status: "half",
  11712. value: Math.round((value - index + 1) * cardinal) / cardinal
  11713. };
  11714. }
  11715. return {
  11716. status: "void",
  11717. value: 0
  11718. };
  11719. }
  11720. const rateProps = {
  11721. size: numericProp,
  11722. icon: makeStringProp("star"),
  11723. color: String,
  11724. count: makeNumericProp(5),
  11725. gutter: numericProp,
  11726. readonly: Boolean,
  11727. disabled: Boolean,
  11728. voidIcon: makeStringProp("star-o"),
  11729. allowHalf: Boolean,
  11730. voidColor: String,
  11731. touchable: truthProp,
  11732. iconPrefix: String,
  11733. modelValue: makeNumberProp(0),
  11734. disabledColor: String
  11735. };
  11736. var stdin_default$q = vue.defineComponent({
  11737. name: name$l,
  11738. props: rateProps,
  11739. emits: ["change", "update:modelValue"],
  11740. setup(props, {
  11741. emit
  11742. }) {
  11743. const touch = useTouch();
  11744. const [itemRefs, setItemRefs] = useRefs();
  11745. const groupRef = vue.ref();
  11746. const untouchable = () => props.readonly || props.disabled || !props.touchable;
  11747. const list = vue.computed(() => Array(+props.count).fill("").map((_, i) => getRateStatus(props.modelValue, i + 1, props.allowHalf, props.readonly)));
  11748. let ranges;
  11749. let groupRefRect;
  11750. let minRectTop = Number.MAX_SAFE_INTEGER;
  11751. let maxRectTop = Number.MIN_SAFE_INTEGER;
  11752. const updateRanges = () => {
  11753. groupRefRect = use.useRect(groupRef);
  11754. const rects = itemRefs.value.map(use.useRect);
  11755. ranges = [];
  11756. rects.forEach((rect, index) => {
  11757. minRectTop = Math.min(rect.top, minRectTop);
  11758. maxRectTop = Math.max(rect.top, maxRectTop);
  11759. if (props.allowHalf) {
  11760. ranges.push({
  11761. score: index + 0.5,
  11762. left: rect.left,
  11763. top: rect.top,
  11764. height: rect.height
  11765. }, {
  11766. score: index + 1,
  11767. left: rect.left + rect.width / 2,
  11768. top: rect.top,
  11769. height: rect.height
  11770. });
  11771. } else {
  11772. ranges.push({
  11773. score: index + 1,
  11774. left: rect.left,
  11775. top: rect.top,
  11776. height: rect.height
  11777. });
  11778. }
  11779. });
  11780. };
  11781. const getScoreByPosition = (x, y) => {
  11782. for (let i = ranges.length - 1; i > 0; i--) {
  11783. if (y >= groupRefRect.top && y <= groupRefRect.bottom) {
  11784. if (x > ranges[i].left && y >= ranges[i].top && y <= ranges[i].top + ranges[i].height) {
  11785. return ranges[i].score;
  11786. }
  11787. } else {
  11788. const curTop = y < groupRefRect.top ? minRectTop : maxRectTop;
  11789. if (x > ranges[i].left && ranges[i].top === curTop) {
  11790. return ranges[i].score;
  11791. }
  11792. }
  11793. }
  11794. return props.allowHalf ? 0.5 : 1;
  11795. };
  11796. const select = (index) => {
  11797. if (!props.disabled && !props.readonly && index !== props.modelValue) {
  11798. emit("update:modelValue", index);
  11799. emit("change", index);
  11800. }
  11801. };
  11802. const onTouchStart = (event) => {
  11803. if (untouchable()) {
  11804. return;
  11805. }
  11806. touch.start(event);
  11807. updateRanges();
  11808. };
  11809. const onTouchMove = (event) => {
  11810. if (untouchable()) {
  11811. return;
  11812. }
  11813. touch.move(event);
  11814. if (touch.isHorizontal()) {
  11815. const {
  11816. clientX,
  11817. clientY
  11818. } = event.touches[0];
  11819. preventDefault(event);
  11820. select(getScoreByPosition(clientX, clientY));
  11821. }
  11822. };
  11823. const renderStar = (item, index) => {
  11824. const {
  11825. icon,
  11826. size,
  11827. color,
  11828. count,
  11829. gutter,
  11830. voidIcon,
  11831. disabled,
  11832. voidColor,
  11833. allowHalf,
  11834. iconPrefix,
  11835. disabledColor
  11836. } = props;
  11837. const score = index + 1;
  11838. const isFull = item.status === "full";
  11839. const isVoid = item.status === "void";
  11840. const renderHalf = allowHalf && item.value > 0 && item.value < 1;
  11841. let style;
  11842. if (gutter && score !== +count) {
  11843. style = {
  11844. paddingRight: addUnit(gutter)
  11845. };
  11846. }
  11847. const onClickItem = (event) => {
  11848. updateRanges();
  11849. select(allowHalf ? getScoreByPosition(event.clientX, event.clientY) : score);
  11850. };
  11851. return vue.createVNode("div", {
  11852. "key": index,
  11853. "ref": setItemRefs(index),
  11854. "role": "radio",
  11855. "style": style,
  11856. "class": bem$k("item"),
  11857. "tabindex": disabled ? void 0 : 0,
  11858. "aria-setsize": count,
  11859. "aria-posinset": score,
  11860. "aria-checked": !isVoid,
  11861. "onClick": onClickItem
  11862. }, [vue.createVNode(Icon, {
  11863. "size": size,
  11864. "name": isFull ? icon : voidIcon,
  11865. "class": bem$k("icon", {
  11866. disabled,
  11867. full: isFull
  11868. }),
  11869. "color": disabled ? disabledColor : isFull ? color : voidColor,
  11870. "classPrefix": iconPrefix
  11871. }, null), renderHalf && vue.createVNode(Icon, {
  11872. "size": size,
  11873. "style": {
  11874. width: item.value + "em"
  11875. },
  11876. "name": isVoid ? voidIcon : icon,
  11877. "class": bem$k("icon", ["half", {
  11878. disabled,
  11879. full: !isVoid
  11880. }]),
  11881. "color": disabled ? disabledColor : isVoid ? voidColor : color,
  11882. "classPrefix": iconPrefix
  11883. }, null)]);
  11884. };
  11885. use.useCustomFieldValue(() => props.modelValue);
  11886. use.useEventListener("touchmove", onTouchMove, {
  11887. target: groupRef
  11888. });
  11889. return () => vue.createVNode("div", {
  11890. "ref": groupRef,
  11891. "role": "radiogroup",
  11892. "class": bem$k({
  11893. readonly: props.readonly,
  11894. disabled: props.disabled
  11895. }),
  11896. "tabindex": props.disabled ? void 0 : 0,
  11897. "aria-disabled": props.disabled,
  11898. "aria-readonly": props.readonly,
  11899. "onTouchstartPassive": onTouchStart
  11900. }, [list.value.map(renderStar)]);
  11901. }
  11902. });
  11903. const Rate = withInstall(stdin_default$q);
  11904. const Row = withInstall(stdin_default$Y);
  11905. const [name$k, bem$j, t$3] = createNamespace("search");
  11906. const searchProps = extend({}, fieldSharedProps, {
  11907. label: String,
  11908. shape: makeStringProp("square"),
  11909. leftIcon: makeStringProp("search"),
  11910. clearable: truthProp,
  11911. actionText: String,
  11912. background: String,
  11913. showAction: Boolean
  11914. });
  11915. var stdin_default$p = vue.defineComponent({
  11916. name: name$k,
  11917. props: searchProps,
  11918. emits: ["blur", "focus", "clear", "search", "cancel", "clickInput", "clickLeftIcon", "clickRightIcon", "update:modelValue"],
  11919. setup(props, {
  11920. emit,
  11921. slots,
  11922. attrs
  11923. }) {
  11924. const id = useId();
  11925. const filedRef = vue.ref();
  11926. const onCancel = () => {
  11927. if (!slots.action) {
  11928. emit("update:modelValue", "");
  11929. emit("cancel");
  11930. }
  11931. };
  11932. const onKeypress = (event) => {
  11933. const ENTER_CODE = 13;
  11934. if (event.keyCode === ENTER_CODE) {
  11935. preventDefault(event);
  11936. emit("search", props.modelValue);
  11937. }
  11938. };
  11939. const getInputId = () => props.id || `${id}-input`;
  11940. const renderLabel = () => {
  11941. if (slots.label || props.label) {
  11942. return vue.createVNode("label", {
  11943. "class": bem$j("label"),
  11944. "for": getInputId()
  11945. }, [slots.label ? slots.label() : props.label]);
  11946. }
  11947. };
  11948. const renderAction = () => {
  11949. if (props.showAction) {
  11950. const text = props.actionText || t$3("cancel");
  11951. return vue.createVNode("div", {
  11952. "class": bem$j("action"),
  11953. "role": "button",
  11954. "tabindex": 0,
  11955. "onClick": onCancel
  11956. }, [slots.action ? slots.action() : text]);
  11957. }
  11958. };
  11959. const blur = () => {
  11960. var _a;
  11961. return (_a = filedRef.value) == null ? void 0 : _a.blur();
  11962. };
  11963. const focus = () => {
  11964. var _a;
  11965. return (_a = filedRef.value) == null ? void 0 : _a.focus();
  11966. };
  11967. const onBlur = (event) => emit("blur", event);
  11968. const onFocus = (event) => emit("focus", event);
  11969. const onClear = (event) => emit("clear", event);
  11970. const onClickInput = (event) => emit("clickInput", event);
  11971. const onClickLeftIcon = (event) => emit("clickLeftIcon", event);
  11972. const onClickRightIcon = (event) => emit("clickRightIcon", event);
  11973. const fieldPropNames = Object.keys(fieldSharedProps);
  11974. const renderField = () => {
  11975. const fieldAttrs = extend({}, attrs, pick(props, fieldPropNames), {
  11976. id: getInputId()
  11977. });
  11978. const onInput = (value) => emit("update:modelValue", value);
  11979. return vue.createVNode(Field, vue.mergeProps({
  11980. "ref": filedRef,
  11981. "type": "search",
  11982. "class": bem$j("field"),
  11983. "border": false,
  11984. "onBlur": onBlur,
  11985. "onFocus": onFocus,
  11986. "onClear": onClear,
  11987. "onKeypress": onKeypress,
  11988. "onClickInput": onClickInput,
  11989. "onClickLeftIcon": onClickLeftIcon,
  11990. "onClickRightIcon": onClickRightIcon,
  11991. "onUpdate:modelValue": onInput
  11992. }, fieldAttrs), pick(slots, ["left-icon", "right-icon"]));
  11993. };
  11994. useExpose({
  11995. focus,
  11996. blur
  11997. });
  11998. return () => {
  11999. var _a;
  12000. return vue.createVNode("div", {
  12001. "class": bem$j({
  12002. "show-action": props.showAction
  12003. }),
  12004. "style": {
  12005. background: props.background
  12006. }
  12007. }, [(_a = slots.left) == null ? void 0 : _a.call(slots), vue.createVNode("div", {
  12008. "class": bem$j("content", props.shape)
  12009. }, [renderLabel(), renderField()]), renderAction()]);
  12010. };
  12011. }
  12012. });
  12013. const Search = withInstall(stdin_default$p);
  12014. const popupInheritKeys = [...popupSharedPropKeys, "round", "closeOnPopstate", "safeAreaInsetBottom"];
  12015. const iconMap = {
  12016. qq: "qq",
  12017. link: "link-o",
  12018. weibo: "weibo",
  12019. qrcode: "qr",
  12020. poster: "photo-o",
  12021. wechat: "wechat",
  12022. "weapp-qrcode": "miniprogram-o",
  12023. "wechat-moments": "wechat-moments"
  12024. };
  12025. const [name$j, bem$i, t$2] = createNamespace("share-sheet");
  12026. const shareSheetProps = extend({}, popupSharedProps, {
  12027. title: String,
  12028. round: truthProp,
  12029. options: makeArrayProp(),
  12030. cancelText: String,
  12031. description: String,
  12032. closeOnPopstate: truthProp,
  12033. safeAreaInsetBottom: truthProp
  12034. });
  12035. var stdin_default$o = vue.defineComponent({
  12036. name: name$j,
  12037. props: shareSheetProps,
  12038. emits: ["cancel", "select", "update:show"],
  12039. setup(props, {
  12040. emit,
  12041. slots
  12042. }) {
  12043. const updateShow = (value) => emit("update:show", value);
  12044. const onCancel = () => {
  12045. updateShow(false);
  12046. emit("cancel");
  12047. };
  12048. const onSelect = (option, index) => emit("select", option, index);
  12049. const renderHeader = () => {
  12050. const title = slots.title ? slots.title() : props.title;
  12051. const description = slots.description ? slots.description() : props.description;
  12052. if (title || description) {
  12053. return vue.createVNode("div", {
  12054. "class": bem$i("header")
  12055. }, [title && vue.createVNode("h2", {
  12056. "class": bem$i("title")
  12057. }, [title]), description && vue.createVNode("span", {
  12058. "class": bem$i("description")
  12059. }, [description])]);
  12060. }
  12061. };
  12062. const renderIcon = (icon) => {
  12063. if (iconMap[icon]) {
  12064. return vue.createVNode("div", {
  12065. "class": bem$i("icon", [icon])
  12066. }, [vue.createVNode(Icon, {
  12067. "name": iconMap[icon] || icon
  12068. }, null)]);
  12069. }
  12070. return vue.createVNode("img", {
  12071. "src": icon,
  12072. "class": bem$i("image-icon")
  12073. }, null);
  12074. };
  12075. const renderOption = (option, index) => {
  12076. const {
  12077. name: name2,
  12078. icon,
  12079. className,
  12080. description
  12081. } = option;
  12082. return vue.createVNode("div", {
  12083. "role": "button",
  12084. "tabindex": 0,
  12085. "class": [bem$i("option"), className, HAPTICS_FEEDBACK],
  12086. "onClick": () => onSelect(option, index)
  12087. }, [renderIcon(icon), name2 && vue.createVNode("span", {
  12088. "class": bem$i("name")
  12089. }, [name2]), description && vue.createVNode("span", {
  12090. "class": bem$i("option-description")
  12091. }, [description])]);
  12092. };
  12093. const renderOptions = (options, border) => vue.createVNode("div", {
  12094. "class": bem$i("options", {
  12095. border
  12096. })
  12097. }, [options.map(renderOption)]);
  12098. const renderRows = () => {
  12099. const {
  12100. options
  12101. } = props;
  12102. if (Array.isArray(options[0])) {
  12103. return options.map((item, index) => renderOptions(item, index !== 0));
  12104. }
  12105. return renderOptions(options);
  12106. };
  12107. const renderCancelButton = () => {
  12108. var _a;
  12109. const cancelText = (_a = props.cancelText) != null ? _a : t$2("cancel");
  12110. if (slots.cancel || cancelText) {
  12111. return vue.createVNode("button", {
  12112. "type": "button",
  12113. "class": bem$i("cancel"),
  12114. "onClick": onCancel
  12115. }, [slots.cancel ? slots.cancel() : cancelText]);
  12116. }
  12117. };
  12118. return () => vue.createVNode(Popup, vue.mergeProps({
  12119. "class": bem$i(),
  12120. "position": "bottom",
  12121. "onUpdate:show": updateShow
  12122. }, pick(props, popupInheritKeys)), {
  12123. default: () => [renderHeader(), renderRows(), renderCancelButton()]
  12124. });
  12125. }
  12126. });
  12127. const ShareSheet = withInstall(stdin_default$o);
  12128. const [name$i, bem$h] = createNamespace("sidebar");
  12129. const SIDEBAR_KEY = Symbol(name$i);
  12130. const sidebarProps = {
  12131. modelValue: makeNumericProp(0)
  12132. };
  12133. var stdin_default$n = vue.defineComponent({
  12134. name: name$i,
  12135. props: sidebarProps,
  12136. emits: ["change", "update:modelValue"],
  12137. setup(props, {
  12138. emit,
  12139. slots
  12140. }) {
  12141. const {
  12142. linkChildren
  12143. } = use.useChildren(SIDEBAR_KEY);
  12144. const getActive = () => +props.modelValue;
  12145. const setActive = (value) => {
  12146. if (value !== getActive()) {
  12147. emit("update:modelValue", value);
  12148. emit("change", value);
  12149. }
  12150. };
  12151. linkChildren({
  12152. getActive,
  12153. setActive
  12154. });
  12155. return () => {
  12156. var _a;
  12157. return vue.createVNode("div", {
  12158. "role": "tablist",
  12159. "class": bem$h()
  12160. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
  12161. };
  12162. }
  12163. });
  12164. const Sidebar = withInstall(stdin_default$n);
  12165. const [name$h, bem$g] = createNamespace("sidebar-item");
  12166. const sidebarItemProps = extend({}, routeProps, {
  12167. dot: Boolean,
  12168. title: String,
  12169. badge: numericProp,
  12170. disabled: Boolean,
  12171. badgeProps: Object
  12172. });
  12173. var stdin_default$m = vue.defineComponent({
  12174. name: name$h,
  12175. props: sidebarItemProps,
  12176. emits: ["click"],
  12177. setup(props, {
  12178. emit,
  12179. slots
  12180. }) {
  12181. const route2 = useRoute();
  12182. const {
  12183. parent,
  12184. index
  12185. } = use.useParent(SIDEBAR_KEY);
  12186. if (!parent) {
  12187. if (process.env.NODE_ENV !== "production") {
  12188. console.error("[Vant] <SidebarItem> must be a child component of <Sidebar>.");
  12189. }
  12190. return;
  12191. }
  12192. const onClick = () => {
  12193. if (props.disabled) {
  12194. return;
  12195. }
  12196. emit("click", index.value);
  12197. parent.setActive(index.value);
  12198. route2();
  12199. };
  12200. return () => {
  12201. const {
  12202. dot,
  12203. badge,
  12204. title,
  12205. disabled
  12206. } = props;
  12207. const selected = index.value === parent.getActive();
  12208. return vue.createVNode("div", {
  12209. "role": "tab",
  12210. "class": bem$g({
  12211. select: selected,
  12212. disabled
  12213. }),
  12214. "tabindex": disabled ? void 0 : 0,
  12215. "aria-selected": selected,
  12216. "onClick": onClick
  12217. }, [vue.createVNode(Badge, vue.mergeProps({
  12218. "dot": dot,
  12219. "class": bem$g("text"),
  12220. "content": badge
  12221. }, props.badgeProps), {
  12222. default: () => [slots.title ? slots.title() : title]
  12223. })]);
  12224. };
  12225. }
  12226. });
  12227. const SidebarItem = withInstall(stdin_default$m);
  12228. const [name$g, bem$f] = createNamespace("skeleton-title");
  12229. const skeletonTitleProps = {
  12230. round: Boolean,
  12231. titleWidth: numericProp
  12232. };
  12233. var stdin_default$l = vue.defineComponent({
  12234. name: name$g,
  12235. props: skeletonTitleProps,
  12236. setup(props) {
  12237. return () => vue.createVNode("h3", {
  12238. "class": bem$f([{
  12239. round: props.round
  12240. }]),
  12241. "style": {
  12242. width: addUnit(props.titleWidth)
  12243. }
  12244. }, null);
  12245. }
  12246. });
  12247. const [name$f, bem$e] = createNamespace("skeleton-avatar");
  12248. const skeletonAvatarProps = {
  12249. avatarSize: numericProp,
  12250. avatarShape: makeStringProp("round")
  12251. };
  12252. var stdin_default$k = vue.defineComponent({
  12253. name: name$f,
  12254. props: skeletonAvatarProps,
  12255. setup(props) {
  12256. return () => vue.createVNode("div", {
  12257. "class": bem$e([props.avatarShape]),
  12258. "style": getSizeStyle(props.avatarSize)
  12259. }, null);
  12260. }
  12261. });
  12262. const DEFAULT_ROW_WIDTH = "100%";
  12263. const skeletonParagraphProps = {
  12264. round: Boolean,
  12265. rowWidth: {
  12266. type: numericProp,
  12267. default: DEFAULT_ROW_WIDTH
  12268. }
  12269. };
  12270. const [name$e, bem$d] = createNamespace("skeleton-paragraph");
  12271. var stdin_default$j = vue.defineComponent({
  12272. name: name$e,
  12273. props: skeletonParagraphProps,
  12274. setup(props) {
  12275. return () => vue.createVNode("div", {
  12276. "class": bem$d([{
  12277. round: props.round
  12278. }]),
  12279. "style": {
  12280. width: props.rowWidth
  12281. }
  12282. }, null);
  12283. }
  12284. });
  12285. const [name$d, bem$c] = createNamespace("skeleton");
  12286. const DEFAULT_LAST_ROW_WIDTH = "60%";
  12287. const skeletonProps = {
  12288. row: makeNumericProp(0),
  12289. round: Boolean,
  12290. title: Boolean,
  12291. titleWidth: numericProp,
  12292. avatar: Boolean,
  12293. avatarSize: numericProp,
  12294. avatarShape: makeStringProp("round"),
  12295. loading: truthProp,
  12296. animate: truthProp,
  12297. rowWidth: {
  12298. type: [Number, String, Array],
  12299. default: DEFAULT_ROW_WIDTH
  12300. }
  12301. };
  12302. var stdin_default$i = vue.defineComponent({
  12303. name: name$d,
  12304. inheritAttrs: false,
  12305. props: skeletonProps,
  12306. setup(props, {
  12307. slots,
  12308. attrs
  12309. }) {
  12310. const renderAvatar = () => {
  12311. if (props.avatar) {
  12312. return vue.createVNode(stdin_default$k, {
  12313. "avatarShape": props.avatarShape,
  12314. "avatarSize": props.avatarSize
  12315. }, null);
  12316. }
  12317. };
  12318. const renderTitle = () => {
  12319. if (props.title) {
  12320. return vue.createVNode(stdin_default$l, {
  12321. "round": props.round,
  12322. "titleWidth": props.titleWidth
  12323. }, null);
  12324. }
  12325. };
  12326. const getRowWidth = (index) => {
  12327. const {
  12328. rowWidth
  12329. } = props;
  12330. if (rowWidth === DEFAULT_ROW_WIDTH && index === +props.row - 1) {
  12331. return DEFAULT_LAST_ROW_WIDTH;
  12332. }
  12333. if (Array.isArray(rowWidth)) {
  12334. return rowWidth[index];
  12335. }
  12336. return rowWidth;
  12337. };
  12338. const renderRows = () => Array(+props.row).fill("").map((_, i) => vue.createVNode(stdin_default$j, {
  12339. "key": i,
  12340. "round": props.round,
  12341. "rowWidth": addUnit(getRowWidth(i))
  12342. }, null));
  12343. const renderContents = () => {
  12344. if (slots.template) {
  12345. return slots.template();
  12346. }
  12347. return vue.createVNode(vue.Fragment, null, [renderAvatar(), vue.createVNode("div", {
  12348. "class": bem$c("content")
  12349. }, [renderTitle(), renderRows()])]);
  12350. };
  12351. return () => {
  12352. var _a;
  12353. if (!props.loading) {
  12354. return (_a = slots.default) == null ? void 0 : _a.call(slots);
  12355. }
  12356. return vue.createVNode("div", vue.mergeProps({
  12357. "class": bem$c({
  12358. animate: props.animate,
  12359. round: props.round
  12360. })
  12361. }, attrs), [renderContents()]);
  12362. };
  12363. }
  12364. });
  12365. const [name$c, bem$b] = createNamespace("skeleton-image");
  12366. const skeletonImageProps = {
  12367. imageSize: numericProp,
  12368. imageShape: makeStringProp("square")
  12369. };
  12370. var stdin_default$h = vue.defineComponent({
  12371. name: name$c,
  12372. props: skeletonImageProps,
  12373. setup(props) {
  12374. return () => vue.createVNode("div", {
  12375. "class": bem$b([props.imageShape]),
  12376. "style": getSizeStyle(props.imageSize)
  12377. }, [vue.createVNode(Icon, {
  12378. "name": "photo",
  12379. "class": bem$b("icon")
  12380. }, null)]);
  12381. }
  12382. });
  12383. const SkeletonImage = withInstall(stdin_default$h);
  12384. const SkeletonTitle = withInstall(stdin_default$l);
  12385. const SkeletonAvatar = withInstall(stdin_default$k);
  12386. const SkeletonParagraph = withInstall(stdin_default$j);
  12387. const Skeleton = withInstall(stdin_default$i);
  12388. const [name$b, bem$a] = createNamespace("slider");
  12389. const sliderProps = {
  12390. min: makeNumericProp(0),
  12391. max: makeNumericProp(100),
  12392. step: makeNumericProp(1),
  12393. range: Boolean,
  12394. reverse: Boolean,
  12395. disabled: Boolean,
  12396. readonly: Boolean,
  12397. vertical: Boolean,
  12398. barHeight: numericProp,
  12399. buttonSize: numericProp,
  12400. activeColor: String,
  12401. inactiveColor: String,
  12402. modelValue: {
  12403. type: [Number, Array],
  12404. default: 0
  12405. }
  12406. };
  12407. var stdin_default$g = vue.defineComponent({
  12408. name: name$b,
  12409. props: sliderProps,
  12410. emits: ["change", "dragEnd", "dragStart", "update:modelValue"],
  12411. setup(props, {
  12412. emit,
  12413. slots
  12414. }) {
  12415. let buttonIndex;
  12416. let current2;
  12417. let startValue;
  12418. const root = vue.ref();
  12419. const slider = vue.ref();
  12420. const dragStatus = vue.ref();
  12421. const touch = useTouch();
  12422. const scope = vue.computed(() => Number(props.max) - Number(props.min));
  12423. const wrapperStyle = vue.computed(() => {
  12424. const crossAxis = props.vertical ? "width" : "height";
  12425. return {
  12426. background: props.inactiveColor,
  12427. [crossAxis]: addUnit(props.barHeight)
  12428. };
  12429. });
  12430. const isRange = (val) => props.range && Array.isArray(val);
  12431. const calcMainAxis = () => {
  12432. const {
  12433. modelValue,
  12434. min
  12435. } = props;
  12436. if (isRange(modelValue)) {
  12437. return `${(modelValue[1] - modelValue[0]) * 100 / scope.value}%`;
  12438. }
  12439. return `${(modelValue - Number(min)) * 100 / scope.value}%`;
  12440. };
  12441. const calcOffset = () => {
  12442. const {
  12443. modelValue,
  12444. min
  12445. } = props;
  12446. if (isRange(modelValue)) {
  12447. return `${(modelValue[0] - Number(min)) * 100 / scope.value}%`;
  12448. }
  12449. return "0%";
  12450. };
  12451. const barStyle = vue.computed(() => {
  12452. const mainAxis = props.vertical ? "height" : "width";
  12453. const style = {
  12454. [mainAxis]: calcMainAxis(),
  12455. background: props.activeColor
  12456. };
  12457. if (dragStatus.value) {
  12458. style.transition = "none";
  12459. }
  12460. const getPositionKey = () => {
  12461. if (props.vertical) {
  12462. return props.reverse ? "bottom" : "top";
  12463. }
  12464. return props.reverse ? "right" : "left";
  12465. };
  12466. style[getPositionKey()] = calcOffset();
  12467. return style;
  12468. });
  12469. const format2 = (value) => {
  12470. const min = +props.min;
  12471. const max = +props.max;
  12472. const step = +props.step;
  12473. value = clamp(value, min, max);
  12474. const diff = Math.round((value - min) / step) * step;
  12475. return addNumber(min, diff);
  12476. };
  12477. const handleRangeValue = (value) => {
  12478. var _a, _b;
  12479. const left = (_a = value[0]) != null ? _a : Number(props.min);
  12480. const right = (_b = value[1]) != null ? _b : Number(props.max);
  12481. return left > right ? [right, left] : [left, right];
  12482. };
  12483. const updateValue = (value, end) => {
  12484. if (isRange(value)) {
  12485. value = handleRangeValue(value).map(format2);
  12486. } else {
  12487. value = format2(value);
  12488. }
  12489. if (!isSameValue(value, props.modelValue)) {
  12490. emit("update:modelValue", value);
  12491. }
  12492. if (end && !isSameValue(value, startValue)) {
  12493. emit("change", value);
  12494. }
  12495. };
  12496. const onClick = (event) => {
  12497. event.stopPropagation();
  12498. if (props.disabled || props.readonly) {
  12499. return;
  12500. }
  12501. const {
  12502. min,
  12503. reverse,
  12504. vertical,
  12505. modelValue
  12506. } = props;
  12507. const rect = use.useRect(root);
  12508. const getDelta = () => {
  12509. if (vertical) {
  12510. if (reverse) {
  12511. return rect.bottom - event.clientY;
  12512. }
  12513. return event.clientY - rect.top;
  12514. }
  12515. if (reverse) {
  12516. return rect.right - event.clientX;
  12517. }
  12518. return event.clientX - rect.left;
  12519. };
  12520. const total = vertical ? rect.height : rect.width;
  12521. const value = Number(min) + getDelta() / total * scope.value;
  12522. if (isRange(modelValue)) {
  12523. const [left, right] = modelValue;
  12524. const middle = (left + right) / 2;
  12525. if (value <= middle) {
  12526. updateValue([value, right], true);
  12527. } else {
  12528. updateValue([left, value], true);
  12529. }
  12530. } else {
  12531. updateValue(value, true);
  12532. }
  12533. };
  12534. const onTouchStart = (event) => {
  12535. if (props.disabled || props.readonly) {
  12536. return;
  12537. }
  12538. touch.start(event);
  12539. current2 = props.modelValue;
  12540. if (isRange(current2)) {
  12541. startValue = current2.map(format2);
  12542. } else {
  12543. startValue = format2(current2);
  12544. }
  12545. dragStatus.value = "start";
  12546. };
  12547. const onTouchMove = (event) => {
  12548. if (props.disabled || props.readonly) {
  12549. return;
  12550. }
  12551. if (dragStatus.value === "start") {
  12552. emit("dragStart", event);
  12553. }
  12554. preventDefault(event, true);
  12555. touch.move(event);
  12556. dragStatus.value = "dragging";
  12557. const rect = use.useRect(root);
  12558. const delta = props.vertical ? touch.deltaY.value : touch.deltaX.value;
  12559. const total = props.vertical ? rect.height : rect.width;
  12560. let diff = delta / total * scope.value;
  12561. if (props.reverse) {
  12562. diff = -diff;
  12563. }
  12564. if (isRange(startValue)) {
  12565. const index = props.reverse ? 1 - buttonIndex : buttonIndex;
  12566. current2[index] = startValue[index] + diff;
  12567. } else {
  12568. current2 = startValue + diff;
  12569. }
  12570. updateValue(current2);
  12571. };
  12572. const onTouchEnd = (event) => {
  12573. if (props.disabled || props.readonly) {
  12574. return;
  12575. }
  12576. if (dragStatus.value === "dragging") {
  12577. updateValue(current2, true);
  12578. emit("dragEnd", event);
  12579. }
  12580. dragStatus.value = "";
  12581. };
  12582. const getButtonClassName = (index) => {
  12583. if (typeof index === "number") {
  12584. const position = ["left", "right"];
  12585. return bem$a(`button-wrapper`, position[index]);
  12586. }
  12587. return bem$a("button-wrapper", props.reverse ? "left" : "right");
  12588. };
  12589. const renderButtonContent = (value, index) => {
  12590. if (typeof index === "number") {
  12591. const slot = slots[index === 0 ? "left-button" : "right-button"];
  12592. if (slot) {
  12593. return slot({
  12594. value
  12595. });
  12596. }
  12597. }
  12598. if (slots.button) {
  12599. return slots.button({
  12600. value
  12601. });
  12602. }
  12603. return vue.createVNode("div", {
  12604. "class": bem$a("button"),
  12605. "style": getSizeStyle(props.buttonSize)
  12606. }, null);
  12607. };
  12608. const renderButton = (index) => {
  12609. const current22 = typeof index === "number" ? props.modelValue[index] : props.modelValue;
  12610. return vue.createVNode("div", {
  12611. "ref": slider,
  12612. "role": "slider",
  12613. "class": getButtonClassName(index),
  12614. "tabindex": props.disabled ? void 0 : 0,
  12615. "aria-valuemin": props.min,
  12616. "aria-valuenow": current22,
  12617. "aria-valuemax": props.max,
  12618. "aria-disabled": props.disabled || void 0,
  12619. "aria-readonly": props.readonly || void 0,
  12620. "aria-orientation": props.vertical ? "vertical" : "horizontal",
  12621. "onTouchstartPassive": (event) => {
  12622. if (typeof index === "number") {
  12623. buttonIndex = index;
  12624. }
  12625. onTouchStart(event);
  12626. },
  12627. "onTouchend": onTouchEnd,
  12628. "onTouchcancel": onTouchEnd,
  12629. "onClick": stopPropagation
  12630. }, [renderButtonContent(current22, index)]);
  12631. };
  12632. updateValue(props.modelValue);
  12633. use.useCustomFieldValue(() => props.modelValue);
  12634. use.useEventListener("touchmove", onTouchMove, {
  12635. target: slider
  12636. });
  12637. return () => vue.createVNode("div", {
  12638. "ref": root,
  12639. "style": wrapperStyle.value,
  12640. "class": bem$a({
  12641. vertical: props.vertical,
  12642. disabled: props.disabled
  12643. }),
  12644. "onClick": onClick
  12645. }, [vue.createVNode("div", {
  12646. "class": bem$a("bar"),
  12647. "style": barStyle.value
  12648. }, [props.range ? [renderButton(0), renderButton(1)] : renderButton()])]);
  12649. }
  12650. });
  12651. const Slider = withInstall(stdin_default$g);
  12652. const [name$a, bem$9] = createNamespace("space");
  12653. const spaceProps = {
  12654. align: String,
  12655. direction: {
  12656. type: String,
  12657. default: "horizontal"
  12658. },
  12659. size: {
  12660. type: [Number, String, Array],
  12661. default: 8
  12662. },
  12663. wrap: Boolean,
  12664. fill: Boolean
  12665. };
  12666. function filterEmpty(children = []) {
  12667. const nodes = [];
  12668. children.forEach((child) => {
  12669. if (Array.isArray(child)) {
  12670. nodes.push(...child);
  12671. } else if (child.type === vue.Fragment) {
  12672. nodes.push(...filterEmpty(child.children));
  12673. } else {
  12674. nodes.push(child);
  12675. }
  12676. });
  12677. return nodes.filter((c) => {
  12678. var _a;
  12679. 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() === ""));
  12680. });
  12681. }
  12682. var stdin_default$f = vue.defineComponent({
  12683. name: name$a,
  12684. props: spaceProps,
  12685. setup(props, {
  12686. slots
  12687. }) {
  12688. const mergedAlign = vue.computed(() => {
  12689. var _a;
  12690. return (_a = props.align) != null ? _a : props.direction === "horizontal" ? "center" : "";
  12691. });
  12692. const getMargin = (size) => {
  12693. if (typeof size === "number") {
  12694. return size + "px";
  12695. }
  12696. return size;
  12697. };
  12698. const getMarginStyle = (isLast) => {
  12699. const style = {};
  12700. const marginRight = `${getMargin(Array.isArray(props.size) ? props.size[0] : props.size)}`;
  12701. const marginBottom = `${getMargin(Array.isArray(props.size) ? props.size[1] : props.size)}`;
  12702. if (isLast) {
  12703. return props.wrap ? {
  12704. marginBottom
  12705. } : {};
  12706. }
  12707. if (props.direction === "horizontal") {
  12708. style.marginRight = marginRight;
  12709. }
  12710. if (props.direction === "vertical" || props.wrap) {
  12711. style.marginBottom = marginBottom;
  12712. }
  12713. return style;
  12714. };
  12715. return () => {
  12716. var _a;
  12717. const children = filterEmpty((_a = slots.default) == null ? void 0 : _a.call(slots));
  12718. return vue.createVNode("div", {
  12719. "class": [bem$9({
  12720. [props.direction]: props.direction,
  12721. [`align-${mergedAlign.value}`]: mergedAlign.value,
  12722. wrap: props.wrap,
  12723. fill: props.fill
  12724. })]
  12725. }, [children.map((c, i) => vue.createVNode("div", {
  12726. "key": `item-${i}`,
  12727. "class": `${name$a}-item`,
  12728. "style": getMarginStyle(i === children.length - 1)
  12729. }, [c]))]);
  12730. };
  12731. }
  12732. });
  12733. const Space = withInstall(stdin_default$f);
  12734. const [name$9, bem$8] = createNamespace("steps");
  12735. const stepsProps = {
  12736. active: makeNumericProp(0),
  12737. direction: makeStringProp("horizontal"),
  12738. activeIcon: makeStringProp("checked"),
  12739. iconPrefix: String,
  12740. finishIcon: String,
  12741. activeColor: String,
  12742. inactiveIcon: String,
  12743. inactiveColor: String
  12744. };
  12745. const STEPS_KEY = Symbol(name$9);
  12746. var stdin_default$e = vue.defineComponent({
  12747. name: name$9,
  12748. props: stepsProps,
  12749. emits: ["clickStep"],
  12750. setup(props, {
  12751. emit,
  12752. slots
  12753. }) {
  12754. const {
  12755. linkChildren
  12756. } = use.useChildren(STEPS_KEY);
  12757. const onClickStep = (index) => emit("clickStep", index);
  12758. linkChildren({
  12759. props,
  12760. onClickStep
  12761. });
  12762. return () => {
  12763. var _a;
  12764. return vue.createVNode("div", {
  12765. "class": bem$8([props.direction])
  12766. }, [vue.createVNode("div", {
  12767. "class": bem$8("items")
  12768. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)])]);
  12769. };
  12770. }
  12771. });
  12772. const [name$8, bem$7] = createNamespace("step");
  12773. var stdin_default$d = vue.defineComponent({
  12774. name: name$8,
  12775. setup(props, {
  12776. slots
  12777. }) {
  12778. const {
  12779. parent,
  12780. index
  12781. } = use.useParent(STEPS_KEY);
  12782. if (!parent) {
  12783. if (process.env.NODE_ENV !== "production") {
  12784. console.error("[Vant] <Step> must be a child component of <Steps>.");
  12785. }
  12786. return;
  12787. }
  12788. const parentProps = parent.props;
  12789. const getStatus = () => {
  12790. const active = +parentProps.active;
  12791. if (index.value < active) {
  12792. return "finish";
  12793. }
  12794. return index.value === active ? "process" : "waiting";
  12795. };
  12796. const isActive = () => getStatus() === "process";
  12797. const lineStyle = vue.computed(() => ({
  12798. background: getStatus() === "finish" ? parentProps.activeColor : parentProps.inactiveColor
  12799. }));
  12800. const titleStyle = vue.computed(() => {
  12801. if (isActive()) {
  12802. return {
  12803. color: parentProps.activeColor
  12804. };
  12805. }
  12806. if (getStatus() === "waiting") {
  12807. return {
  12808. color: parentProps.inactiveColor
  12809. };
  12810. }
  12811. });
  12812. const onClickStep = () => parent.onClickStep(index.value);
  12813. const renderCircle = () => {
  12814. const {
  12815. iconPrefix,
  12816. finishIcon,
  12817. activeIcon,
  12818. activeColor,
  12819. inactiveIcon
  12820. } = parentProps;
  12821. if (isActive()) {
  12822. if (slots["active-icon"]) {
  12823. return slots["active-icon"]();
  12824. }
  12825. return vue.createVNode(Icon, {
  12826. "class": bem$7("icon", "active"),
  12827. "name": activeIcon,
  12828. "color": activeColor,
  12829. "classPrefix": iconPrefix
  12830. }, null);
  12831. }
  12832. if (getStatus() === "finish" && (finishIcon || slots["finish-icon"])) {
  12833. if (slots["finish-icon"]) {
  12834. return slots["finish-icon"]();
  12835. }
  12836. return vue.createVNode(Icon, {
  12837. "class": bem$7("icon", "finish"),
  12838. "name": finishIcon,
  12839. "color": activeColor,
  12840. "classPrefix": iconPrefix
  12841. }, null);
  12842. }
  12843. if (slots["inactive-icon"]) {
  12844. return slots["inactive-icon"]();
  12845. }
  12846. if (inactiveIcon) {
  12847. return vue.createVNode(Icon, {
  12848. "class": bem$7("icon"),
  12849. "name": inactiveIcon,
  12850. "classPrefix": iconPrefix
  12851. }, null);
  12852. }
  12853. return vue.createVNode("i", {
  12854. "class": bem$7("circle"),
  12855. "style": lineStyle.value
  12856. }, null);
  12857. };
  12858. return () => {
  12859. var _a;
  12860. const status = getStatus();
  12861. return vue.createVNode("div", {
  12862. "class": [BORDER, bem$7([parentProps.direction, {
  12863. [status]: status
  12864. }])]
  12865. }, [vue.createVNode("div", {
  12866. "class": bem$7("title", {
  12867. active: isActive()
  12868. }),
  12869. "style": titleStyle.value,
  12870. "onClick": onClickStep
  12871. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]), vue.createVNode("div", {
  12872. "class": bem$7("circle-container"),
  12873. "onClick": onClickStep
  12874. }, [renderCircle()]), vue.createVNode("div", {
  12875. "class": bem$7("line"),
  12876. "style": lineStyle.value
  12877. }, null)]);
  12878. };
  12879. }
  12880. });
  12881. const Step = withInstall(stdin_default$d);
  12882. const [name$7, bem$6] = createNamespace("stepper");
  12883. const LONG_PRESS_INTERVAL = 200;
  12884. const isEqual = (value1, value2) => String(value1) === String(value2);
  12885. const stepperProps = {
  12886. min: makeNumericProp(1),
  12887. max: makeNumericProp(Infinity),
  12888. name: makeNumericProp(""),
  12889. step: makeNumericProp(1),
  12890. theme: String,
  12891. integer: Boolean,
  12892. disabled: Boolean,
  12893. showPlus: truthProp,
  12894. showMinus: truthProp,
  12895. showInput: truthProp,
  12896. longPress: truthProp,
  12897. autoFixed: truthProp,
  12898. allowEmpty: Boolean,
  12899. modelValue: numericProp,
  12900. inputWidth: numericProp,
  12901. buttonSize: numericProp,
  12902. placeholder: String,
  12903. disablePlus: Boolean,
  12904. disableMinus: Boolean,
  12905. disableInput: Boolean,
  12906. beforeChange: Function,
  12907. defaultValue: makeNumericProp(1),
  12908. decimalLength: numericProp
  12909. };
  12910. var stdin_default$c = vue.defineComponent({
  12911. name: name$7,
  12912. props: stepperProps,
  12913. emits: ["plus", "blur", "minus", "focus", "change", "overlimit", "update:modelValue"],
  12914. setup(props, {
  12915. emit
  12916. }) {
  12917. const format2 = (value, autoFixed = true) => {
  12918. const {
  12919. min,
  12920. max,
  12921. allowEmpty,
  12922. decimalLength
  12923. } = props;
  12924. if (allowEmpty && value === "") {
  12925. return value;
  12926. }
  12927. value = formatNumber(String(value), !props.integer);
  12928. value = value === "" ? 0 : +value;
  12929. value = Number.isNaN(value) ? +min : value;
  12930. value = autoFixed ? Math.max(Math.min(+max, value), +min) : value;
  12931. if (isDef(decimalLength)) {
  12932. value = value.toFixed(+decimalLength);
  12933. }
  12934. return value;
  12935. };
  12936. const getInitialValue = () => {
  12937. var _a;
  12938. const defaultValue = (_a = props.modelValue) != null ? _a : props.defaultValue;
  12939. const value = format2(defaultValue);
  12940. if (!isEqual(value, props.modelValue)) {
  12941. emit("update:modelValue", value);
  12942. }
  12943. return value;
  12944. };
  12945. let actionType;
  12946. const inputRef = vue.ref();
  12947. const current2 = vue.ref(getInitialValue());
  12948. const minusDisabled = vue.computed(() => props.disabled || props.disableMinus || current2.value <= +props.min);
  12949. const plusDisabled = vue.computed(() => props.disabled || props.disablePlus || current2.value >= +props.max);
  12950. const inputStyle = vue.computed(() => ({
  12951. width: addUnit(props.inputWidth),
  12952. height: addUnit(props.buttonSize)
  12953. }));
  12954. const buttonStyle = vue.computed(() => getSizeStyle(props.buttonSize));
  12955. const check = () => {
  12956. const value = format2(current2.value);
  12957. if (!isEqual(value, current2.value)) {
  12958. current2.value = value;
  12959. }
  12960. };
  12961. const setValue = (value) => {
  12962. if (props.beforeChange) {
  12963. callInterceptor(props.beforeChange, {
  12964. args: [value],
  12965. done() {
  12966. current2.value = value;
  12967. }
  12968. });
  12969. } else {
  12970. current2.value = value;
  12971. }
  12972. };
  12973. const onChange = () => {
  12974. if (actionType === "plus" && plusDisabled.value || actionType === "minus" && minusDisabled.value) {
  12975. emit("overlimit", actionType);
  12976. return;
  12977. }
  12978. const diff = actionType === "minus" ? -props.step : +props.step;
  12979. const value = format2(addNumber(+current2.value, diff));
  12980. setValue(value);
  12981. emit(actionType);
  12982. };
  12983. const onInput = (event) => {
  12984. const input = event.target;
  12985. const {
  12986. value
  12987. } = input;
  12988. const {
  12989. decimalLength
  12990. } = props;
  12991. let formatted = formatNumber(String(value), !props.integer);
  12992. if (isDef(decimalLength) && formatted.includes(".")) {
  12993. const pair = formatted.split(".");
  12994. formatted = `${pair[0]}.${pair[1].slice(0, +decimalLength)}`;
  12995. }
  12996. if (props.beforeChange) {
  12997. input.value = String(current2.value);
  12998. } else if (!isEqual(value, formatted)) {
  12999. input.value = formatted;
  13000. }
  13001. const isNumeric2 = formatted === String(+formatted);
  13002. setValue(isNumeric2 ? +formatted : formatted);
  13003. };
  13004. const onFocus = (event) => {
  13005. var _a;
  13006. if (props.disableInput) {
  13007. (_a = inputRef.value) == null ? void 0 : _a.blur();
  13008. } else {
  13009. emit("focus", event);
  13010. }
  13011. };
  13012. const onBlur = (event) => {
  13013. const input = event.target;
  13014. const value = format2(input.value, props.autoFixed);
  13015. input.value = String(value);
  13016. current2.value = value;
  13017. vue.nextTick(() => {
  13018. emit("blur", event);
  13019. resetScroll();
  13020. });
  13021. };
  13022. let isLongPress;
  13023. let longPressTimer;
  13024. const longPressStep = () => {
  13025. longPressTimer = setTimeout(() => {
  13026. onChange();
  13027. longPressStep();
  13028. }, LONG_PRESS_INTERVAL);
  13029. };
  13030. const onTouchStart = () => {
  13031. if (props.longPress) {
  13032. isLongPress = false;
  13033. clearTimeout(longPressTimer);
  13034. longPressTimer = setTimeout(() => {
  13035. isLongPress = true;
  13036. onChange();
  13037. longPressStep();
  13038. }, LONG_PRESS_START_TIME);
  13039. }
  13040. };
  13041. const onTouchEnd = (event) => {
  13042. if (props.longPress) {
  13043. clearTimeout(longPressTimer);
  13044. if (isLongPress) {
  13045. preventDefault(event);
  13046. }
  13047. }
  13048. };
  13049. const onMousedown = (event) => {
  13050. if (props.disableInput) {
  13051. preventDefault(event);
  13052. }
  13053. };
  13054. const createListeners = (type) => ({
  13055. onClick: (event) => {
  13056. preventDefault(event);
  13057. actionType = type;
  13058. onChange();
  13059. },
  13060. onTouchstartPassive: () => {
  13061. actionType = type;
  13062. onTouchStart();
  13063. },
  13064. onTouchend: onTouchEnd,
  13065. onTouchcancel: onTouchEnd
  13066. });
  13067. vue.watch(() => [props.max, props.min, props.integer, props.decimalLength], check);
  13068. vue.watch(() => props.modelValue, (value) => {
  13069. if (!isEqual(value, current2.value)) {
  13070. current2.value = format2(value);
  13071. }
  13072. });
  13073. vue.watch(current2, (value) => {
  13074. emit("update:modelValue", value);
  13075. emit("change", value, {
  13076. name: props.name
  13077. });
  13078. });
  13079. use.useCustomFieldValue(() => props.modelValue);
  13080. return () => vue.createVNode("div", {
  13081. "role": "group",
  13082. "class": bem$6([props.theme])
  13083. }, [vue.withDirectives(vue.createVNode("button", vue.mergeProps({
  13084. "type": "button",
  13085. "style": buttonStyle.value,
  13086. "class": [bem$6("minus", {
  13087. disabled: minusDisabled.value
  13088. }), {
  13089. [HAPTICS_FEEDBACK]: !minusDisabled.value
  13090. }],
  13091. "aria-disabled": minusDisabled.value || void 0
  13092. }, createListeners("minus")), null), [[vue.vShow, props.showMinus]]), vue.withDirectives(vue.createVNode("input", {
  13093. "ref": inputRef,
  13094. "type": props.integer ? "tel" : "text",
  13095. "role": "spinbutton",
  13096. "class": bem$6("input"),
  13097. "value": current2.value,
  13098. "style": inputStyle.value,
  13099. "disabled": props.disabled,
  13100. "readonly": props.disableInput,
  13101. "inputmode": props.integer ? "numeric" : "decimal",
  13102. "placeholder": props.placeholder,
  13103. "aria-valuemax": props.max,
  13104. "aria-valuemin": props.min,
  13105. "aria-valuenow": current2.value,
  13106. "onBlur": onBlur,
  13107. "onInput": onInput,
  13108. "onFocus": onFocus,
  13109. "onMousedown": onMousedown
  13110. }, null), [[vue.vShow, props.showInput]]), vue.withDirectives(vue.createVNode("button", vue.mergeProps({
  13111. "type": "button",
  13112. "style": buttonStyle.value,
  13113. "class": [bem$6("plus", {
  13114. disabled: plusDisabled.value
  13115. }), {
  13116. [HAPTICS_FEEDBACK]: !plusDisabled.value
  13117. }],
  13118. "aria-disabled": plusDisabled.value || void 0
  13119. }, createListeners("plus")), null), [[vue.vShow, props.showPlus]])]);
  13120. }
  13121. });
  13122. const Stepper = withInstall(stdin_default$c);
  13123. const Steps = withInstall(stdin_default$e);
  13124. const [name$6, bem$5, t$1] = createNamespace("submit-bar");
  13125. const submitBarProps = {
  13126. tip: String,
  13127. label: String,
  13128. price: Number,
  13129. tipIcon: String,
  13130. loading: Boolean,
  13131. currency: makeStringProp("\xA5"),
  13132. disabled: Boolean,
  13133. textAlign: String,
  13134. buttonText: String,
  13135. buttonType: makeStringProp("danger"),
  13136. buttonColor: String,
  13137. suffixLabel: String,
  13138. placeholder: Boolean,
  13139. decimalLength: makeNumericProp(2),
  13140. safeAreaInsetBottom: truthProp
  13141. };
  13142. var stdin_default$b = vue.defineComponent({
  13143. name: name$6,
  13144. props: submitBarProps,
  13145. emits: ["submit"],
  13146. setup(props, {
  13147. emit,
  13148. slots
  13149. }) {
  13150. const root = vue.ref();
  13151. const renderPlaceholder = usePlaceholder(root, bem$5);
  13152. const renderText = () => {
  13153. const {
  13154. price,
  13155. label,
  13156. currency,
  13157. textAlign,
  13158. suffixLabel,
  13159. decimalLength
  13160. } = props;
  13161. if (typeof price === "number") {
  13162. const pricePair = (price / 100).toFixed(+decimalLength).split(".");
  13163. const decimal = decimalLength ? `.${pricePair[1]}` : "";
  13164. return vue.createVNode("div", {
  13165. "class": bem$5("text"),
  13166. "style": {
  13167. textAlign
  13168. }
  13169. }, [vue.createVNode("span", null, [label || t$1("label")]), vue.createVNode("span", {
  13170. "class": bem$5("price")
  13171. }, [currency, vue.createVNode("span", {
  13172. "class": bem$5("price-integer")
  13173. }, [pricePair[0]]), decimal]), suffixLabel && vue.createVNode("span", {
  13174. "class": bem$5("suffix-label")
  13175. }, [suffixLabel])]);
  13176. }
  13177. };
  13178. const renderTip = () => {
  13179. var _a;
  13180. const {
  13181. tip,
  13182. tipIcon
  13183. } = props;
  13184. if (slots.tip || tip) {
  13185. return vue.createVNode("div", {
  13186. "class": bem$5("tip")
  13187. }, [tipIcon && vue.createVNode(Icon, {
  13188. "class": bem$5("tip-icon"),
  13189. "name": tipIcon
  13190. }, null), tip && vue.createVNode("span", {
  13191. "class": bem$5("tip-text")
  13192. }, [tip]), (_a = slots.tip) == null ? void 0 : _a.call(slots)]);
  13193. }
  13194. };
  13195. const onClickButton = () => emit("submit");
  13196. const renderButton = () => {
  13197. if (slots.button) {
  13198. return slots.button();
  13199. }
  13200. return vue.createVNode(Button, {
  13201. "round": true,
  13202. "type": props.buttonType,
  13203. "text": props.buttonText,
  13204. "class": bem$5("button", props.buttonType),
  13205. "color": props.buttonColor,
  13206. "loading": props.loading,
  13207. "disabled": props.disabled,
  13208. "onClick": onClickButton
  13209. }, null);
  13210. };
  13211. const renderSubmitBar = () => {
  13212. var _a, _b;
  13213. return vue.createVNode("div", {
  13214. "ref": root,
  13215. "class": [bem$5(), {
  13216. "van-safe-area-bottom": props.safeAreaInsetBottom
  13217. }]
  13218. }, [(_a = slots.top) == null ? void 0 : _a.call(slots), renderTip(), vue.createVNode("div", {
  13219. "class": bem$5("bar")
  13220. }, [(_b = slots.default) == null ? void 0 : _b.call(slots), renderText(), renderButton()])]);
  13221. };
  13222. return () => {
  13223. if (props.placeholder) {
  13224. return renderPlaceholder(renderSubmitBar);
  13225. }
  13226. return renderSubmitBar();
  13227. };
  13228. }
  13229. });
  13230. const SubmitBar = withInstall(stdin_default$b);
  13231. const [name$5, bem$4] = createNamespace("swipe-cell");
  13232. const swipeCellProps = {
  13233. name: makeNumericProp(""),
  13234. disabled: Boolean,
  13235. leftWidth: numericProp,
  13236. rightWidth: numericProp,
  13237. beforeClose: Function,
  13238. stopPropagation: Boolean
  13239. };
  13240. var stdin_default$a = vue.defineComponent({
  13241. name: name$5,
  13242. props: swipeCellProps,
  13243. emits: ["open", "close", "click"],
  13244. setup(props, {
  13245. emit,
  13246. slots
  13247. }) {
  13248. let opened;
  13249. let lockClick2;
  13250. let startOffset;
  13251. const root = vue.ref();
  13252. const leftRef = vue.ref();
  13253. const rightRef = vue.ref();
  13254. const state = vue.reactive({
  13255. offset: 0,
  13256. dragging: false
  13257. });
  13258. const touch = useTouch();
  13259. const getWidthByRef = (ref2) => ref2.value ? use.useRect(ref2).width : 0;
  13260. const leftWidth = vue.computed(() => isDef(props.leftWidth) ? +props.leftWidth : getWidthByRef(leftRef));
  13261. const rightWidth = vue.computed(() => isDef(props.rightWidth) ? +props.rightWidth : getWidthByRef(rightRef));
  13262. const open = (side) => {
  13263. state.offset = side === "left" ? leftWidth.value : -rightWidth.value;
  13264. if (!opened) {
  13265. opened = true;
  13266. emit("open", {
  13267. name: props.name,
  13268. position: side
  13269. });
  13270. }
  13271. };
  13272. const close = (position) => {
  13273. state.offset = 0;
  13274. if (opened) {
  13275. opened = false;
  13276. emit("close", {
  13277. name: props.name,
  13278. position
  13279. });
  13280. }
  13281. };
  13282. const toggle = (side) => {
  13283. const offset = Math.abs(state.offset);
  13284. const THRESHOLD = 0.15;
  13285. const threshold = opened ? 1 - THRESHOLD : THRESHOLD;
  13286. const width = side === "left" ? leftWidth.value : rightWidth.value;
  13287. if (width && offset > width * threshold) {
  13288. open(side);
  13289. } else {
  13290. close(side);
  13291. }
  13292. };
  13293. const onTouchStart = (event) => {
  13294. if (!props.disabled) {
  13295. startOffset = state.offset;
  13296. touch.start(event);
  13297. }
  13298. };
  13299. const onTouchMove = (event) => {
  13300. if (props.disabled) {
  13301. return;
  13302. }
  13303. const {
  13304. deltaX
  13305. } = touch;
  13306. touch.move(event);
  13307. if (touch.isHorizontal()) {
  13308. lockClick2 = true;
  13309. state.dragging = true;
  13310. const isEdge = !opened || deltaX.value * startOffset < 0;
  13311. if (isEdge) {
  13312. preventDefault(event, props.stopPropagation);
  13313. }
  13314. state.offset = clamp(deltaX.value + startOffset, -rightWidth.value, leftWidth.value);
  13315. }
  13316. };
  13317. const onTouchEnd = () => {
  13318. if (state.dragging) {
  13319. state.dragging = false;
  13320. toggle(state.offset > 0 ? "left" : "right");
  13321. setTimeout(() => {
  13322. lockClick2 = false;
  13323. }, 0);
  13324. }
  13325. };
  13326. const onClick = (position = "outside") => {
  13327. emit("click", position);
  13328. if (opened && !lockClick2) {
  13329. callInterceptor(props.beforeClose, {
  13330. args: [{
  13331. name: props.name,
  13332. position
  13333. }],
  13334. done: () => close(position)
  13335. });
  13336. }
  13337. };
  13338. const getClickHandler = (position, stop) => (event) => {
  13339. if (stop) {
  13340. event.stopPropagation();
  13341. }
  13342. onClick(position);
  13343. };
  13344. const renderSideContent = (side, ref2) => {
  13345. const contentSlot = slots[side];
  13346. if (contentSlot) {
  13347. return vue.createVNode("div", {
  13348. "ref": ref2,
  13349. "class": bem$4(side),
  13350. "onClick": getClickHandler(side, true)
  13351. }, [contentSlot()]);
  13352. }
  13353. };
  13354. useExpose({
  13355. open,
  13356. close
  13357. });
  13358. use.useClickAway(root, () => onClick("outside"), {
  13359. eventName: "touchstart"
  13360. });
  13361. use.useEventListener("touchmove", onTouchMove, {
  13362. target: root
  13363. });
  13364. return () => {
  13365. var _a;
  13366. const wrapperStyle = {
  13367. transform: `translate3d(${state.offset}px, 0, 0)`,
  13368. transitionDuration: state.dragging ? "0s" : ".6s"
  13369. };
  13370. return vue.createVNode("div", {
  13371. "ref": root,
  13372. "class": bem$4(),
  13373. "onClick": getClickHandler("cell", lockClick2),
  13374. "onTouchstartPassive": onTouchStart,
  13375. "onTouchend": onTouchEnd,
  13376. "onTouchcancel": onTouchEnd
  13377. }, [vue.createVNode("div", {
  13378. "class": bem$4("wrapper"),
  13379. "style": wrapperStyle
  13380. }, [renderSideContent("left", leftRef), (_a = slots.default) == null ? void 0 : _a.call(slots), renderSideContent("right", rightRef)])]);
  13381. };
  13382. }
  13383. });
  13384. const SwipeCell = withInstall(stdin_default$a);
  13385. const [name$4, bem$3] = createNamespace("tabbar");
  13386. const tabbarProps = {
  13387. route: Boolean,
  13388. fixed: truthProp,
  13389. border: truthProp,
  13390. zIndex: numericProp,
  13391. placeholder: Boolean,
  13392. activeColor: String,
  13393. beforeChange: Function,
  13394. inactiveColor: String,
  13395. modelValue: makeNumericProp(0),
  13396. safeAreaInsetBottom: {
  13397. type: Boolean,
  13398. default: null
  13399. }
  13400. };
  13401. const TABBAR_KEY = Symbol(name$4);
  13402. var stdin_default$9 = vue.defineComponent({
  13403. name: name$4,
  13404. props: tabbarProps,
  13405. emits: ["change", "update:modelValue"],
  13406. setup(props, {
  13407. emit,
  13408. slots
  13409. }) {
  13410. const root = vue.ref();
  13411. const {
  13412. linkChildren
  13413. } = use.useChildren(TABBAR_KEY);
  13414. const renderPlaceholder = usePlaceholder(root, bem$3);
  13415. const enableSafeArea = () => {
  13416. var _a;
  13417. return (_a = props.safeAreaInsetBottom) != null ? _a : props.fixed;
  13418. };
  13419. const renderTabbar = () => {
  13420. var _a;
  13421. const {
  13422. fixed,
  13423. zIndex,
  13424. border
  13425. } = props;
  13426. return vue.createVNode("div", {
  13427. "ref": root,
  13428. "role": "tablist",
  13429. "style": getZIndexStyle(zIndex),
  13430. "class": [bem$3({
  13431. fixed
  13432. }), {
  13433. [BORDER_TOP_BOTTOM]: border,
  13434. "van-safe-area-bottom": enableSafeArea()
  13435. }]
  13436. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
  13437. };
  13438. const setActive = (active, afterChange) => {
  13439. callInterceptor(props.beforeChange, {
  13440. args: [active],
  13441. done() {
  13442. emit("update:modelValue", active);
  13443. emit("change", active);
  13444. afterChange();
  13445. }
  13446. });
  13447. };
  13448. linkChildren({
  13449. props,
  13450. setActive
  13451. });
  13452. return () => {
  13453. if (props.fixed && props.placeholder) {
  13454. return renderPlaceholder(renderTabbar);
  13455. }
  13456. return renderTabbar();
  13457. };
  13458. }
  13459. });
  13460. const Tabbar = withInstall(stdin_default$9);
  13461. const [name$3, bem$2] = createNamespace("tabbar-item");
  13462. const tabbarItemProps = extend({}, routeProps, {
  13463. dot: Boolean,
  13464. icon: String,
  13465. name: numericProp,
  13466. badge: numericProp,
  13467. badgeProps: Object,
  13468. iconPrefix: String
  13469. });
  13470. var stdin_default$8 = vue.defineComponent({
  13471. name: name$3,
  13472. props: tabbarItemProps,
  13473. emits: ["click"],
  13474. setup(props, {
  13475. emit,
  13476. slots
  13477. }) {
  13478. const route2 = useRoute();
  13479. const vm = vue.getCurrentInstance().proxy;
  13480. const {
  13481. parent,
  13482. index
  13483. } = use.useParent(TABBAR_KEY);
  13484. if (!parent) {
  13485. if (process.env.NODE_ENV !== "production") {
  13486. console.error("[Vant] <TabbarItem> must be a child component of <Tabbar>.");
  13487. }
  13488. return;
  13489. }
  13490. const active = vue.computed(() => {
  13491. var _a;
  13492. const {
  13493. route: route22,
  13494. modelValue
  13495. } = parent.props;
  13496. if (route22 && "$route" in vm) {
  13497. const {
  13498. $route
  13499. } = vm;
  13500. const {
  13501. to
  13502. } = props;
  13503. const config = isObject(to) ? to : {
  13504. path: to
  13505. };
  13506. return !!$route.matched.find((val) => {
  13507. const pathMatched = "path" in config && config.path === val.path;
  13508. const nameMatched = "name" in config && config.name === val.name;
  13509. return pathMatched || nameMatched;
  13510. });
  13511. }
  13512. return ((_a = props.name) != null ? _a : index.value) === modelValue;
  13513. });
  13514. const onClick = (event) => {
  13515. var _a;
  13516. if (!active.value) {
  13517. parent.setActive((_a = props.name) != null ? _a : index.value, route2);
  13518. }
  13519. emit("click", event);
  13520. };
  13521. const renderIcon = () => {
  13522. if (slots.icon) {
  13523. return slots.icon({
  13524. active: active.value
  13525. });
  13526. }
  13527. if (props.icon) {
  13528. return vue.createVNode(Icon, {
  13529. "name": props.icon,
  13530. "classPrefix": props.iconPrefix
  13531. }, null);
  13532. }
  13533. };
  13534. return () => {
  13535. var _a;
  13536. const {
  13537. dot,
  13538. badge
  13539. } = props;
  13540. const {
  13541. activeColor,
  13542. inactiveColor
  13543. } = parent.props;
  13544. const color = active.value ? activeColor : inactiveColor;
  13545. return vue.createVNode("div", {
  13546. "role": "tab",
  13547. "class": bem$2({
  13548. active: active.value
  13549. }),
  13550. "style": {
  13551. color
  13552. },
  13553. "tabindex": 0,
  13554. "aria-selected": active.value,
  13555. "onClick": onClick
  13556. }, [vue.createVNode(Badge, vue.mergeProps({
  13557. "dot": dot,
  13558. "class": bem$2("icon"),
  13559. "content": badge
  13560. }, props.badgeProps), {
  13561. default: renderIcon
  13562. }), vue.createVNode("div", {
  13563. "class": bem$2("text")
  13564. }, [(_a = slots.default) == null ? void 0 : _a.call(slots, {
  13565. active: active.value
  13566. })])]);
  13567. };
  13568. }
  13569. });
  13570. const TabbarItem = withInstall(stdin_default$8);
  13571. const [name$2] = createNamespace("time-picker");
  13572. const timePickerProps = extend({}, sharedProps, {
  13573. minHour: makeNumericProp(0),
  13574. maxHour: makeNumericProp(23),
  13575. minMinute: makeNumericProp(0),
  13576. maxMinute: makeNumericProp(59),
  13577. minSecond: makeNumericProp(0),
  13578. maxSecond: makeNumericProp(59),
  13579. columnsType: {
  13580. type: Array,
  13581. default: () => ["hour", "minute"]
  13582. }
  13583. });
  13584. var stdin_default$7 = vue.defineComponent({
  13585. name: name$2,
  13586. props: timePickerProps,
  13587. emits: ["confirm", "cancel", "change", "update:modelValue"],
  13588. setup(props, {
  13589. emit,
  13590. slots
  13591. }) {
  13592. const currentValues = vue.ref(props.modelValue);
  13593. const columns = vue.computed(() => props.columnsType.map((type) => {
  13594. const {
  13595. filter,
  13596. formatter
  13597. } = props;
  13598. switch (type) {
  13599. case "hour":
  13600. return genOptions(+props.minHour, +props.maxHour, type, formatter, filter);
  13601. case "minute":
  13602. return genOptions(+props.minMinute, +props.maxMinute, type, formatter, filter);
  13603. case "second":
  13604. return genOptions(+props.minSecond, +props.maxSecond, type, formatter, filter);
  13605. default:
  13606. if (process.env.NODE_ENV !== "production") {
  13607. throw new Error(`[Vant] DatePicker: unsupported columns type: ${type}`);
  13608. }
  13609. return [];
  13610. }
  13611. }));
  13612. vue.watch(currentValues, (newValues) => {
  13613. if (!isSameValue(newValues, props.modelValue)) {
  13614. emit("update:modelValue", newValues);
  13615. }
  13616. });
  13617. vue.watch(() => props.modelValue, (newValues) => {
  13618. newValues = formatValueRange(newValues, columns.value);
  13619. if (!isSameValue(newValues, currentValues.value)) {
  13620. currentValues.value = newValues;
  13621. }
  13622. }, {
  13623. immediate: true
  13624. });
  13625. const onChange = (...args) => emit("change", ...args);
  13626. const onCancel = (...args) => emit("cancel", ...args);
  13627. const onConfirm = (...args) => emit("confirm", ...args);
  13628. return () => vue.createVNode(Picker, vue.mergeProps({
  13629. "modelValue": currentValues.value,
  13630. "onUpdate:modelValue": ($event) => currentValues.value = $event,
  13631. "columns": columns.value,
  13632. "onChange": onChange,
  13633. "onCancel": onCancel,
  13634. "onConfirm": onConfirm
  13635. }, pick(props, pickerInheritKeys)), slots);
  13636. }
  13637. });
  13638. const TimePicker = withInstall(stdin_default$7);
  13639. const [name$1, bem$1] = createNamespace("tree-select");
  13640. const treeSelectProps = {
  13641. max: makeNumericProp(Infinity),
  13642. items: makeArrayProp(),
  13643. height: makeNumericProp(300),
  13644. selectedIcon: makeStringProp("success"),
  13645. mainActiveIndex: makeNumericProp(0),
  13646. activeId: {
  13647. type: [Number, String, Array],
  13648. default: 0
  13649. }
  13650. };
  13651. var stdin_default$6 = vue.defineComponent({
  13652. name: name$1,
  13653. props: treeSelectProps,
  13654. emits: ["clickNav", "clickItem", "update:activeId", "update:mainActiveIndex"],
  13655. setup(props, {
  13656. emit,
  13657. slots
  13658. }) {
  13659. const isActiveItem = (id) => Array.isArray(props.activeId) ? props.activeId.includes(id) : props.activeId === id;
  13660. const renderSubItem = (item) => {
  13661. const onClick = () => {
  13662. if (item.disabled) {
  13663. return;
  13664. }
  13665. let activeId;
  13666. if (Array.isArray(props.activeId)) {
  13667. activeId = props.activeId.slice();
  13668. const index = activeId.indexOf(item.id);
  13669. if (index !== -1) {
  13670. activeId.splice(index, 1);
  13671. } else if (activeId.length < props.max) {
  13672. activeId.push(item.id);
  13673. }
  13674. } else {
  13675. activeId = item.id;
  13676. }
  13677. emit("update:activeId", activeId);
  13678. emit("clickItem", item);
  13679. };
  13680. return vue.createVNode("div", {
  13681. "key": item.id,
  13682. "class": ["van-ellipsis", bem$1("item", {
  13683. active: isActiveItem(item.id),
  13684. disabled: item.disabled
  13685. })],
  13686. "onClick": onClick
  13687. }, [item.text, isActiveItem(item.id) && vue.createVNode(Icon, {
  13688. "name": props.selectedIcon,
  13689. "class": bem$1("selected")
  13690. }, null)]);
  13691. };
  13692. const onSidebarChange = (index) => {
  13693. emit("update:mainActiveIndex", index);
  13694. };
  13695. const onClickSidebarItem = (index) => emit("clickNav", index);
  13696. const renderSidebar = () => {
  13697. const Items = props.items.map((item) => vue.createVNode(SidebarItem, {
  13698. "dot": item.dot,
  13699. "title": item.text,
  13700. "badge": item.badge,
  13701. "class": [bem$1("nav-item"), item.className],
  13702. "disabled": item.disabled,
  13703. "onClick": onClickSidebarItem
  13704. }, null));
  13705. return vue.createVNode(Sidebar, {
  13706. "class": bem$1("nav"),
  13707. "modelValue": props.mainActiveIndex,
  13708. "onChange": onSidebarChange
  13709. }, {
  13710. default: () => [Items]
  13711. });
  13712. };
  13713. const renderContent = () => {
  13714. if (slots.content) {
  13715. return slots.content();
  13716. }
  13717. const selected = props.items[+props.mainActiveIndex] || {};
  13718. if (selected.children) {
  13719. return selected.children.map(renderSubItem);
  13720. }
  13721. };
  13722. return () => vue.createVNode("div", {
  13723. "class": bem$1(),
  13724. "style": {
  13725. height: addUnit(props.height)
  13726. }
  13727. }, [renderSidebar(), vue.createVNode("div", {
  13728. "class": bem$1("content")
  13729. }, [renderContent()])]);
  13730. }
  13731. });
  13732. const TreeSelect = withInstall(stdin_default$6);
  13733. const [name, bem, t] = createNamespace("uploader");
  13734. function readFileContent(file, resultType) {
  13735. return new Promise((resolve) => {
  13736. if (resultType === "file") {
  13737. resolve();
  13738. return;
  13739. }
  13740. const reader = new FileReader();
  13741. reader.onload = (event) => {
  13742. resolve(event.target.result);
  13743. };
  13744. if (resultType === "dataUrl") {
  13745. reader.readAsDataURL(file);
  13746. } else if (resultType === "text") {
  13747. reader.readAsText(file);
  13748. }
  13749. });
  13750. }
  13751. function isOversize(items, maxSize) {
  13752. return toArray(items).some((item) => {
  13753. if (item.file) {
  13754. if (isFunction(maxSize)) {
  13755. return maxSize(item.file);
  13756. }
  13757. return item.file.size > maxSize;
  13758. }
  13759. return false;
  13760. });
  13761. }
  13762. function filterFiles(items, maxSize) {
  13763. const valid = [];
  13764. const invalid = [];
  13765. items.forEach((item) => {
  13766. if (isOversize(item, maxSize)) {
  13767. invalid.push(item);
  13768. } else {
  13769. valid.push(item);
  13770. }
  13771. });
  13772. return { valid, invalid };
  13773. }
  13774. const IMAGE_REGEXP = /\.(jpeg|jpg|gif|png|svg|webp|jfif|bmp|dpg)/i;
  13775. const isImageUrl = (url) => IMAGE_REGEXP.test(url);
  13776. function isImageFile(item) {
  13777. if (item.isImage) {
  13778. return true;
  13779. }
  13780. if (item.file && item.file.type) {
  13781. return item.file.type.indexOf("image") === 0;
  13782. }
  13783. if (item.url) {
  13784. return isImageUrl(item.url);
  13785. }
  13786. if (typeof item.content === "string") {
  13787. return item.content.indexOf("data:image") === 0;
  13788. }
  13789. return false;
  13790. }
  13791. var stdin_default$5 = vue.defineComponent({
  13792. props: {
  13793. name: numericProp,
  13794. item: makeRequiredProp(Object),
  13795. index: Number,
  13796. imageFit: String,
  13797. lazyLoad: Boolean,
  13798. deletable: Boolean,
  13799. previewSize: [Number, String, Array],
  13800. beforeDelete: Function
  13801. },
  13802. emits: ["delete", "preview"],
  13803. setup(props, {
  13804. emit,
  13805. slots
  13806. }) {
  13807. const renderMask = () => {
  13808. const {
  13809. status,
  13810. message
  13811. } = props.item;
  13812. if (status === "uploading" || status === "failed") {
  13813. const MaskIcon = status === "failed" ? vue.createVNode(Icon, {
  13814. "name": "close",
  13815. "class": bem("mask-icon")
  13816. }, null) : vue.createVNode(Loading, {
  13817. "class": bem("loading")
  13818. }, null);
  13819. const showMessage = isDef(message) && message !== "";
  13820. return vue.createVNode("div", {
  13821. "class": bem("mask")
  13822. }, [MaskIcon, showMessage && vue.createVNode("div", {
  13823. "class": bem("mask-message")
  13824. }, [message])]);
  13825. }
  13826. };
  13827. const onDelete = (event) => {
  13828. const {
  13829. name: name2,
  13830. item,
  13831. index,
  13832. beforeDelete
  13833. } = props;
  13834. event.stopPropagation();
  13835. callInterceptor(beforeDelete, {
  13836. args: [item, {
  13837. name: name2,
  13838. index
  13839. }],
  13840. done: () => emit("delete")
  13841. });
  13842. };
  13843. const onPreview = () => emit("preview");
  13844. const renderDeleteIcon = () => {
  13845. if (props.deletable && props.item.status !== "uploading") {
  13846. const slot = slots["preview-delete"];
  13847. return vue.createVNode("div", {
  13848. "role": "button",
  13849. "class": bem("preview-delete", {
  13850. shadow: !slot
  13851. }),
  13852. "tabindex": 0,
  13853. "aria-label": t("delete"),
  13854. "onClick": onDelete
  13855. }, [slot ? slot() : vue.createVNode(Icon, {
  13856. "name": "cross",
  13857. "class": bem("preview-delete-icon")
  13858. }, null)]);
  13859. }
  13860. };
  13861. const renderCover = () => {
  13862. if (slots["preview-cover"]) {
  13863. const {
  13864. index,
  13865. item
  13866. } = props;
  13867. return vue.createVNode("div", {
  13868. "class": bem("preview-cover")
  13869. }, [slots["preview-cover"](extend({
  13870. index
  13871. }, item))]);
  13872. }
  13873. };
  13874. const renderPreview = () => {
  13875. const {
  13876. item,
  13877. lazyLoad,
  13878. imageFit,
  13879. previewSize
  13880. } = props;
  13881. if (isImageFile(item)) {
  13882. return vue.createVNode(Image$1, {
  13883. "fit": imageFit,
  13884. "src": item.content || item.url,
  13885. "class": bem("preview-image"),
  13886. "width": Array.isArray(previewSize) ? previewSize[0] : previewSize,
  13887. "height": Array.isArray(previewSize) ? previewSize[1] : previewSize,
  13888. "lazyLoad": lazyLoad,
  13889. "onClick": onPreview
  13890. }, {
  13891. default: renderCover
  13892. });
  13893. }
  13894. return vue.createVNode("div", {
  13895. "class": bem("file"),
  13896. "style": getSizeStyle(props.previewSize)
  13897. }, [vue.createVNode(Icon, {
  13898. "class": bem("file-icon"),
  13899. "name": "description"
  13900. }, null), vue.createVNode("div", {
  13901. "class": [bem("file-name"), "van-ellipsis"]
  13902. }, [item.file ? item.file.name : item.url]), renderCover()]);
  13903. };
  13904. return () => vue.createVNode("div", {
  13905. "class": bem("preview")
  13906. }, [renderPreview(), renderMask(), renderDeleteIcon()]);
  13907. }
  13908. });
  13909. const uploaderProps = {
  13910. name: makeNumericProp(""),
  13911. accept: makeStringProp("image/*"),
  13912. capture: String,
  13913. multiple: Boolean,
  13914. disabled: Boolean,
  13915. readonly: Boolean,
  13916. lazyLoad: Boolean,
  13917. maxCount: makeNumericProp(Infinity),
  13918. imageFit: makeStringProp("cover"),
  13919. resultType: makeStringProp("dataUrl"),
  13920. uploadIcon: makeStringProp("photograph"),
  13921. uploadText: String,
  13922. deletable: truthProp,
  13923. afterRead: Function,
  13924. showUpload: truthProp,
  13925. modelValue: makeArrayProp(),
  13926. beforeRead: Function,
  13927. beforeDelete: Function,
  13928. previewSize: [Number, String, Array],
  13929. previewImage: truthProp,
  13930. previewOptions: Object,
  13931. previewFullImage: truthProp,
  13932. maxSize: {
  13933. type: [Number, String, Function],
  13934. default: Infinity
  13935. }
  13936. };
  13937. var stdin_default$4 = vue.defineComponent({
  13938. name,
  13939. props: uploaderProps,
  13940. emits: ["delete", "oversize", "clickUpload", "closePreview", "clickPreview", "update:modelValue"],
  13941. setup(props, {
  13942. emit,
  13943. slots
  13944. }) {
  13945. const inputRef = vue.ref();
  13946. const urls = [];
  13947. const getDetail = (index = props.modelValue.length) => ({
  13948. name: props.name,
  13949. index
  13950. });
  13951. const resetInput = () => {
  13952. if (inputRef.value) {
  13953. inputRef.value.value = "";
  13954. }
  13955. };
  13956. const onAfterRead = (items) => {
  13957. resetInput();
  13958. if (isOversize(items, props.maxSize)) {
  13959. if (Array.isArray(items)) {
  13960. const result = filterFiles(items, props.maxSize);
  13961. items = result.valid;
  13962. emit("oversize", result.invalid, getDetail());
  13963. if (!items.length) {
  13964. return;
  13965. }
  13966. } else {
  13967. emit("oversize", items, getDetail());
  13968. return;
  13969. }
  13970. }
  13971. items = vue.reactive(items);
  13972. emit("update:modelValue", [...props.modelValue, ...toArray(items)]);
  13973. if (props.afterRead) {
  13974. props.afterRead(items, getDetail());
  13975. }
  13976. };
  13977. const readFile = (files) => {
  13978. const {
  13979. maxCount,
  13980. modelValue,
  13981. resultType
  13982. } = props;
  13983. if (Array.isArray(files)) {
  13984. const remainCount = +maxCount - modelValue.length;
  13985. if (files.length > remainCount) {
  13986. files = files.slice(0, remainCount);
  13987. }
  13988. Promise.all(files.map((file) => readFileContent(file, resultType))).then((contents) => {
  13989. const fileList = files.map((file, index) => {
  13990. const result = {
  13991. file,
  13992. status: "",
  13993. message: ""
  13994. };
  13995. if (contents[index]) {
  13996. result.content = contents[index];
  13997. }
  13998. return result;
  13999. });
  14000. onAfterRead(fileList);
  14001. });
  14002. } else {
  14003. readFileContent(files, resultType).then((content) => {
  14004. const result = {
  14005. file: files,
  14006. status: "",
  14007. message: ""
  14008. };
  14009. if (content) {
  14010. result.content = content;
  14011. }
  14012. onAfterRead(result);
  14013. });
  14014. }
  14015. };
  14016. const onChange = (event) => {
  14017. const {
  14018. files
  14019. } = event.target;
  14020. if (props.disabled || !files || !files.length) {
  14021. return;
  14022. }
  14023. const file = files.length === 1 ? files[0] : [].slice.call(files);
  14024. if (props.beforeRead) {
  14025. const response = props.beforeRead(file, getDetail());
  14026. if (!response) {
  14027. resetInput();
  14028. return;
  14029. }
  14030. if (isPromise(response)) {
  14031. response.then((data) => {
  14032. if (data) {
  14033. readFile(data);
  14034. } else {
  14035. readFile(file);
  14036. }
  14037. }).catch(resetInput);
  14038. return;
  14039. }
  14040. }
  14041. readFile(file);
  14042. };
  14043. let imagePreview;
  14044. const onClosePreview = () => emit("closePreview");
  14045. const previewImage = (item) => {
  14046. if (props.previewFullImage) {
  14047. const imageFiles = props.modelValue.filter(isImageFile);
  14048. const images = imageFiles.map((item2) => {
  14049. if (item2.file && !item2.url && item2.status !== "failed") {
  14050. item2.url = URL.createObjectURL(item2.file);
  14051. urls.push(item2.url);
  14052. }
  14053. return item2.url;
  14054. }).filter(Boolean);
  14055. imagePreview = showImagePreview(extend({
  14056. images,
  14057. startPosition: imageFiles.indexOf(item),
  14058. onClose: onClosePreview
  14059. }, props.previewOptions));
  14060. }
  14061. };
  14062. const closeImagePreview = () => {
  14063. if (imagePreview) {
  14064. imagePreview.close();
  14065. }
  14066. };
  14067. const deleteFile = (item, index) => {
  14068. const fileList = props.modelValue.slice(0);
  14069. fileList.splice(index, 1);
  14070. emit("update:modelValue", fileList);
  14071. emit("delete", item, getDetail(index));
  14072. };
  14073. const renderPreviewItem = (item, index) => {
  14074. const needPickData = ["imageFit", "deletable", "previewSize", "beforeDelete"];
  14075. const previewData = extend(pick(props, needPickData), pick(item, needPickData, true));
  14076. return vue.createVNode(stdin_default$5, vue.mergeProps({
  14077. "item": item,
  14078. "index": index,
  14079. "onClick": () => emit("clickPreview", item, getDetail(index)),
  14080. "onDelete": () => deleteFile(item, index),
  14081. "onPreview": () => previewImage(item)
  14082. }, pick(props, ["name", "lazyLoad"]), previewData), pick(slots, ["preview-cover", "preview-delete"]));
  14083. };
  14084. const renderPreviewList = () => {
  14085. if (props.previewImage) {
  14086. return props.modelValue.map(renderPreviewItem);
  14087. }
  14088. };
  14089. const onClickUpload = (event) => emit("clickUpload", event);
  14090. const renderUpload = () => {
  14091. if (props.modelValue.length >= props.maxCount) {
  14092. return;
  14093. }
  14094. const Input = props.readonly ? null : vue.createVNode("input", {
  14095. "ref": inputRef,
  14096. "type": "file",
  14097. "class": bem("input"),
  14098. "accept": props.accept,
  14099. "capture": props.capture,
  14100. "multiple": props.multiple,
  14101. "disabled": props.disabled,
  14102. "onChange": onChange
  14103. }, null);
  14104. if (slots.default) {
  14105. return vue.createVNode("div", {
  14106. "class": bem("input-wrapper"),
  14107. "onClick": onClickUpload
  14108. }, [slots.default(), Input]);
  14109. }
  14110. return vue.withDirectives(vue.createVNode("div", {
  14111. "class": bem("upload", {
  14112. readonly: props.readonly
  14113. }),
  14114. "style": getSizeStyle(props.previewSize),
  14115. "onClick": onClickUpload
  14116. }, [vue.createVNode(Icon, {
  14117. "name": props.uploadIcon,
  14118. "class": bem("upload-icon")
  14119. }, null), props.uploadText && vue.createVNode("span", {
  14120. "class": bem("upload-text")
  14121. }, [props.uploadText]), Input]), [[vue.vShow, props.showUpload]]);
  14122. };
  14123. const chooseFile = () => {
  14124. if (inputRef.value && !props.disabled) {
  14125. inputRef.value.click();
  14126. }
  14127. };
  14128. vue.onBeforeUnmount(() => {
  14129. urls.forEach((url) => URL.revokeObjectURL(url));
  14130. });
  14131. useExpose({
  14132. chooseFile,
  14133. closeImagePreview
  14134. });
  14135. use.useCustomFieldValue(() => props.modelValue);
  14136. return () => vue.createVNode("div", {
  14137. "class": bem()
  14138. }, [vue.createVNode("div", {
  14139. "class": bem("wrapper", {
  14140. disabled: props.disabled
  14141. })
  14142. }, [renderPreviewList(), renderUpload()])]);
  14143. }
  14144. });
  14145. const Uploader = withInstall(stdin_default$4);
  14146. class ReactiveListener {
  14147. constructor({
  14148. el,
  14149. src,
  14150. error,
  14151. loading,
  14152. bindType,
  14153. $parent,
  14154. options,
  14155. cors,
  14156. elRenderer,
  14157. imageCache
  14158. }) {
  14159. this.el = el;
  14160. this.src = src;
  14161. this.error = error;
  14162. this.loading = loading;
  14163. this.bindType = bindType;
  14164. this.attempt = 0;
  14165. this.cors = cors;
  14166. this.naturalHeight = 0;
  14167. this.naturalWidth = 0;
  14168. this.options = options;
  14169. this.$parent = $parent;
  14170. this.elRenderer = elRenderer;
  14171. this.imageCache = imageCache;
  14172. this.performanceData = {
  14173. loadStart: 0,
  14174. loadEnd: 0
  14175. };
  14176. this.filter();
  14177. this.initState();
  14178. this.render("loading", false);
  14179. }
  14180. initState() {
  14181. if ("dataset" in this.el) {
  14182. this.el.dataset.src = this.src;
  14183. } else {
  14184. this.el.setAttribute("data-src", this.src);
  14185. }
  14186. this.state = {
  14187. loading: false,
  14188. error: false,
  14189. loaded: false,
  14190. rendered: false
  14191. };
  14192. }
  14193. record(event) {
  14194. this.performanceData[event] = Date.now();
  14195. }
  14196. update({ src, loading, error }) {
  14197. const oldSrc = this.src;
  14198. this.src = src;
  14199. this.loading = loading;
  14200. this.error = error;
  14201. this.filter();
  14202. if (oldSrc !== this.src) {
  14203. this.attempt = 0;
  14204. this.initState();
  14205. }
  14206. }
  14207. checkInView() {
  14208. const rect = use.useRect(this.el);
  14209. return rect.top < window.innerHeight * this.options.preLoad && rect.bottom > this.options.preLoadTop && rect.left < window.innerWidth * this.options.preLoad && rect.right > 0;
  14210. }
  14211. filter() {
  14212. Object.keys(this.options.filter).forEach((key) => {
  14213. this.options.filter[key](this, this.options);
  14214. });
  14215. }
  14216. renderLoading(cb) {
  14217. this.state.loading = true;
  14218. loadImageAsync(
  14219. {
  14220. src: this.loading,
  14221. cors: this.cors
  14222. },
  14223. () => {
  14224. this.render("loading", false);
  14225. this.state.loading = false;
  14226. cb();
  14227. },
  14228. () => {
  14229. cb();
  14230. this.state.loading = false;
  14231. if (process.env.NODE_ENV !== "production" && !this.options.silent)
  14232. console.warn(
  14233. `[@vant/lazyload] load failed with loading image(${this.loading})`
  14234. );
  14235. }
  14236. );
  14237. }
  14238. load(onFinish = noop) {
  14239. if (this.attempt > this.options.attempt - 1 && this.state.error) {
  14240. if (process.env.NODE_ENV !== "production" && !this.options.silent) {
  14241. console.log(
  14242. `[@vant/lazyload] ${this.src} tried too more than ${this.options.attempt} times`
  14243. );
  14244. }
  14245. onFinish();
  14246. return;
  14247. }
  14248. if (this.state.rendered && this.state.loaded)
  14249. return;
  14250. if (this.imageCache.has(this.src)) {
  14251. this.state.loaded = true;
  14252. this.render("loaded", true);
  14253. this.state.rendered = true;
  14254. return onFinish();
  14255. }
  14256. this.renderLoading(() => {
  14257. var _a, _b;
  14258. this.attempt++;
  14259. (_b = (_a = this.options.adapter).beforeLoad) == null ? void 0 : _b.call(_a, this, this.options);
  14260. this.record("loadStart");
  14261. loadImageAsync(
  14262. {
  14263. src: this.src,
  14264. cors: this.cors
  14265. },
  14266. (data) => {
  14267. this.naturalHeight = data.naturalHeight;
  14268. this.naturalWidth = data.naturalWidth;
  14269. this.state.loaded = true;
  14270. this.state.error = false;
  14271. this.record("loadEnd");
  14272. this.render("loaded", false);
  14273. this.state.rendered = true;
  14274. this.imageCache.add(this.src);
  14275. onFinish();
  14276. },
  14277. (err) => {
  14278. !this.options.silent && console.error(err);
  14279. this.state.error = true;
  14280. this.state.loaded = false;
  14281. this.render("error", false);
  14282. }
  14283. );
  14284. });
  14285. }
  14286. render(state, cache) {
  14287. this.elRenderer(this, state, cache);
  14288. }
  14289. performance() {
  14290. let state = "loading";
  14291. let time = 0;
  14292. if (this.state.loaded) {
  14293. state = "loaded";
  14294. time = (this.performanceData.loadEnd - this.performanceData.loadStart) / 1e3;
  14295. }
  14296. if (this.state.error)
  14297. state = "error";
  14298. return {
  14299. src: this.src,
  14300. state,
  14301. time
  14302. };
  14303. }
  14304. $destroy() {
  14305. this.el = null;
  14306. this.src = null;
  14307. this.error = null;
  14308. this.loading = null;
  14309. this.bindType = null;
  14310. this.attempt = 0;
  14311. }
  14312. }
  14313. const DEFAULT_URL = "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7";
  14314. const DEFAULT_EVENTS = [
  14315. "scroll",
  14316. "wheel",
  14317. "mousewheel",
  14318. "resize",
  14319. "animationend",
  14320. "transitionend",
  14321. "touchmove"
  14322. ];
  14323. const DEFAULT_OBSERVER_OPTIONS = {
  14324. rootMargin: "0px",
  14325. threshold: 0
  14326. };
  14327. function stdin_default$3() {
  14328. return class Lazy {
  14329. constructor({
  14330. preLoad,
  14331. error,
  14332. throttleWait,
  14333. preLoadTop,
  14334. dispatchEvent,
  14335. loading,
  14336. attempt,
  14337. silent = true,
  14338. scale,
  14339. listenEvents,
  14340. filter,
  14341. adapter,
  14342. observer,
  14343. observerOptions
  14344. }) {
  14345. this.mode = modeType.event;
  14346. this.listeners = [];
  14347. this.targetIndex = 0;
  14348. this.targets = [];
  14349. this.options = {
  14350. silent,
  14351. dispatchEvent: !!dispatchEvent,
  14352. throttleWait: throttleWait || 200,
  14353. preLoad: preLoad || 1.3,
  14354. preLoadTop: preLoadTop || 0,
  14355. error: error || DEFAULT_URL,
  14356. loading: loading || DEFAULT_URL,
  14357. attempt: attempt || 3,
  14358. scale: scale || getDPR(scale),
  14359. ListenEvents: listenEvents || DEFAULT_EVENTS,
  14360. supportWebp: supportWebp(),
  14361. filter: filter || {},
  14362. adapter: adapter || {},
  14363. observer: !!observer,
  14364. observerOptions: observerOptions || DEFAULT_OBSERVER_OPTIONS
  14365. };
  14366. this.initEvent();
  14367. this.imageCache = new ImageCache({ max: 200 });
  14368. this.lazyLoadHandler = throttle(
  14369. this.lazyLoadHandler.bind(this),
  14370. this.options.throttleWait
  14371. );
  14372. this.setMode(this.options.observer ? modeType.observer : modeType.event);
  14373. }
  14374. config(options = {}) {
  14375. Object.assign(this.options, options);
  14376. }
  14377. performance() {
  14378. return this.listeners.map((item) => item.performance());
  14379. }
  14380. addLazyBox(vm) {
  14381. this.listeners.push(vm);
  14382. if (use.inBrowser) {
  14383. this.addListenerTarget(window);
  14384. this.observer && this.observer.observe(vm.el);
  14385. if (vm.$el && vm.$el.parentNode) {
  14386. this.addListenerTarget(vm.$el.parentNode);
  14387. }
  14388. }
  14389. }
  14390. add(el, binding, vnode) {
  14391. if (this.listeners.some((item) => item.el === el)) {
  14392. this.update(el, binding);
  14393. return vue.nextTick(this.lazyLoadHandler);
  14394. }
  14395. const value = this.valueFormatter(binding.value);
  14396. let { src } = value;
  14397. vue.nextTick(() => {
  14398. src = getBestSelectionFromSrcset(el, this.options.scale) || src;
  14399. this.observer && this.observer.observe(el);
  14400. const container = Object.keys(binding.modifiers)[0];
  14401. let $parent;
  14402. if (container) {
  14403. $parent = vnode.context.$refs[container];
  14404. $parent = $parent ? $parent.$el || $parent : document.getElementById(container);
  14405. }
  14406. if (!$parent) {
  14407. $parent = use.getScrollParent(el);
  14408. }
  14409. const newListener = new ReactiveListener({
  14410. bindType: binding.arg,
  14411. $parent,
  14412. el,
  14413. src,
  14414. loading: value.loading,
  14415. error: value.error,
  14416. cors: value.cors,
  14417. elRenderer: this.elRenderer.bind(this),
  14418. options: this.options,
  14419. imageCache: this.imageCache
  14420. });
  14421. this.listeners.push(newListener);
  14422. if (use.inBrowser) {
  14423. this.addListenerTarget(window);
  14424. this.addListenerTarget($parent);
  14425. }
  14426. this.lazyLoadHandler();
  14427. vue.nextTick(() => this.lazyLoadHandler());
  14428. });
  14429. }
  14430. update(el, binding, vnode) {
  14431. const value = this.valueFormatter(binding.value);
  14432. let { src } = value;
  14433. src = getBestSelectionFromSrcset(el, this.options.scale) || src;
  14434. const exist = this.listeners.find((item) => item.el === el);
  14435. if (!exist) {
  14436. this.add(el, binding, vnode);
  14437. } else {
  14438. exist.update({
  14439. src,
  14440. error: value.error,
  14441. loading: value.loading
  14442. });
  14443. }
  14444. if (this.observer) {
  14445. this.observer.unobserve(el);
  14446. this.observer.observe(el);
  14447. }
  14448. this.lazyLoadHandler();
  14449. vue.nextTick(() => this.lazyLoadHandler());
  14450. }
  14451. remove(el) {
  14452. if (!el)
  14453. return;
  14454. this.observer && this.observer.unobserve(el);
  14455. const existItem = this.listeners.find((item) => item.el === el);
  14456. if (existItem) {
  14457. this.removeListenerTarget(existItem.$parent);
  14458. this.removeListenerTarget(window);
  14459. remove(this.listeners, existItem);
  14460. existItem.$destroy();
  14461. }
  14462. }
  14463. removeComponent(vm) {
  14464. if (!vm)
  14465. return;
  14466. remove(this.listeners, vm);
  14467. this.observer && this.observer.unobserve(vm.el);
  14468. if (vm.$parent && vm.$el.parentNode) {
  14469. this.removeListenerTarget(vm.$el.parentNode);
  14470. }
  14471. this.removeListenerTarget(window);
  14472. }
  14473. setMode(mode) {
  14474. if (!hasIntersectionObserver && mode === modeType.observer) {
  14475. mode = modeType.event;
  14476. }
  14477. this.mode = mode;
  14478. if (mode === modeType.event) {
  14479. if (this.observer) {
  14480. this.listeners.forEach((listener) => {
  14481. this.observer.unobserve(listener.el);
  14482. });
  14483. this.observer = null;
  14484. }
  14485. this.targets.forEach((target) => {
  14486. this.initListen(target.el, true);
  14487. });
  14488. } else {
  14489. this.targets.forEach((target) => {
  14490. this.initListen(target.el, false);
  14491. });
  14492. this.initIntersectionObserver();
  14493. }
  14494. }
  14495. addListenerTarget(el) {
  14496. if (!el)
  14497. return;
  14498. let target = this.targets.find((target2) => target2.el === el);
  14499. if (!target) {
  14500. target = {
  14501. el,
  14502. id: ++this.targetIndex,
  14503. childrenCount: 1,
  14504. listened: true
  14505. };
  14506. this.mode === modeType.event && this.initListen(target.el, true);
  14507. this.targets.push(target);
  14508. } else {
  14509. target.childrenCount++;
  14510. }
  14511. return this.targetIndex;
  14512. }
  14513. removeListenerTarget(el) {
  14514. this.targets.forEach((target, index) => {
  14515. if (target.el === el) {
  14516. target.childrenCount--;
  14517. if (!target.childrenCount) {
  14518. this.initListen(target.el, false);
  14519. this.targets.splice(index, 1);
  14520. target = null;
  14521. }
  14522. }
  14523. });
  14524. }
  14525. initListen(el, start) {
  14526. this.options.ListenEvents.forEach(
  14527. (evt) => (start ? on : off)(el, evt, this.lazyLoadHandler)
  14528. );
  14529. }
  14530. initEvent() {
  14531. this.Event = {
  14532. listeners: {
  14533. loading: [],
  14534. loaded: [],
  14535. error: []
  14536. }
  14537. };
  14538. this.$on = (event, func) => {
  14539. if (!this.Event.listeners[event])
  14540. this.Event.listeners[event] = [];
  14541. this.Event.listeners[event].push(func);
  14542. };
  14543. this.$once = (event, func) => {
  14544. const on2 = (...args) => {
  14545. this.$off(event, on2);
  14546. func.apply(this, args);
  14547. };
  14548. this.$on(event, on2);
  14549. };
  14550. this.$off = (event, func) => {
  14551. if (!func) {
  14552. if (!this.Event.listeners[event])
  14553. return;
  14554. this.Event.listeners[event].length = 0;
  14555. return;
  14556. }
  14557. remove(this.Event.listeners[event], func);
  14558. };
  14559. this.$emit = (event, context, inCache) => {
  14560. if (!this.Event.listeners[event])
  14561. return;
  14562. this.Event.listeners[event].forEach((func) => func(context, inCache));
  14563. };
  14564. }
  14565. lazyLoadHandler() {
  14566. const freeList = [];
  14567. this.listeners.forEach((listener) => {
  14568. if (!listener.el || !listener.el.parentNode) {
  14569. freeList.push(listener);
  14570. }
  14571. const catIn = listener.checkInView();
  14572. if (!catIn)
  14573. return;
  14574. listener.load();
  14575. });
  14576. freeList.forEach((item) => {
  14577. remove(this.listeners, item);
  14578. item.$destroy();
  14579. });
  14580. }
  14581. initIntersectionObserver() {
  14582. if (!hasIntersectionObserver) {
  14583. return;
  14584. }
  14585. this.observer = new IntersectionObserver(
  14586. this.observerHandler.bind(this),
  14587. this.options.observerOptions
  14588. );
  14589. if (this.listeners.length) {
  14590. this.listeners.forEach((listener) => {
  14591. this.observer.observe(listener.el);
  14592. });
  14593. }
  14594. }
  14595. observerHandler(entries) {
  14596. entries.forEach((entry) => {
  14597. if (entry.isIntersecting) {
  14598. this.listeners.forEach((listener) => {
  14599. if (listener.el === entry.target) {
  14600. if (listener.state.loaded)
  14601. return this.observer.unobserve(listener.el);
  14602. listener.load();
  14603. }
  14604. });
  14605. }
  14606. });
  14607. }
  14608. elRenderer(listener, state, cache) {
  14609. if (!listener.el)
  14610. return;
  14611. const { el, bindType } = listener;
  14612. let src;
  14613. switch (state) {
  14614. case "loading":
  14615. src = listener.loading;
  14616. break;
  14617. case "error":
  14618. src = listener.error;
  14619. break;
  14620. default:
  14621. ({ src } = listener);
  14622. break;
  14623. }
  14624. if (bindType) {
  14625. el.style[bindType] = 'url("' + src + '")';
  14626. } else if (el.getAttribute("src") !== src) {
  14627. el.setAttribute("src", src);
  14628. }
  14629. el.setAttribute("lazy", state);
  14630. this.$emit(state, listener, cache);
  14631. this.options.adapter[state] && this.options.adapter[state](listener, this.options);
  14632. if (this.options.dispatchEvent) {
  14633. const event = new CustomEvent(state, {
  14634. detail: listener
  14635. });
  14636. el.dispatchEvent(event);
  14637. }
  14638. }
  14639. valueFormatter(value) {
  14640. let src = value;
  14641. let { loading, error } = this.options;
  14642. if (isObject(value)) {
  14643. if (process.env.NODE_ENV !== "production" && !value.src && !this.options.silent) {
  14644. console.error("[@vant/lazyload] miss src with " + value);
  14645. }
  14646. ({ src } = value);
  14647. loading = value.loading || this.options.loading;
  14648. error = value.error || this.options.error;
  14649. }
  14650. return {
  14651. src,
  14652. loading,
  14653. error
  14654. };
  14655. }
  14656. };
  14657. }
  14658. var stdin_default$2 = (lazy) => ({
  14659. props: {
  14660. tag: {
  14661. type: String,
  14662. default: "div"
  14663. }
  14664. },
  14665. emits: ["show"],
  14666. render() {
  14667. return vue.h(
  14668. this.tag,
  14669. this.show && this.$slots.default ? this.$slots.default() : null
  14670. );
  14671. },
  14672. data() {
  14673. return {
  14674. el: null,
  14675. state: {
  14676. loaded: false
  14677. },
  14678. show: false
  14679. };
  14680. },
  14681. mounted() {
  14682. this.el = this.$el;
  14683. lazy.addLazyBox(this);
  14684. lazy.lazyLoadHandler();
  14685. },
  14686. beforeUnmount() {
  14687. lazy.removeComponent(this);
  14688. },
  14689. methods: {
  14690. checkInView() {
  14691. const rect = use.useRect(this.$el);
  14692. return use.inBrowser && rect.top < window.innerHeight * lazy.options.preLoad && rect.bottom > 0 && rect.left < window.innerWidth * lazy.options.preLoad && rect.right > 0;
  14693. },
  14694. load() {
  14695. this.show = true;
  14696. this.state.loaded = true;
  14697. this.$emit("show", this);
  14698. },
  14699. destroy() {
  14700. return this.$destroy;
  14701. }
  14702. }
  14703. });
  14704. const defaultOptions = {
  14705. selector: "img"
  14706. };
  14707. class LazyContainer {
  14708. constructor({ el, binding, vnode, lazy }) {
  14709. this.el = null;
  14710. this.vnode = vnode;
  14711. this.binding = binding;
  14712. this.options = {};
  14713. this.lazy = lazy;
  14714. this.queue = [];
  14715. this.update({ el, binding });
  14716. }
  14717. update({ el, binding }) {
  14718. this.el = el;
  14719. this.options = Object.assign({}, defaultOptions, binding.value);
  14720. const imgs = this.getImgs();
  14721. imgs.forEach((el2) => {
  14722. this.lazy.add(
  14723. el2,
  14724. Object.assign({}, this.binding, {
  14725. value: {
  14726. src: "dataset" in el2 ? el2.dataset.src : el2.getAttribute("data-src"),
  14727. error: ("dataset" in el2 ? el2.dataset.error : el2.getAttribute("data-error")) || this.options.error,
  14728. loading: ("dataset" in el2 ? el2.dataset.loading : el2.getAttribute("data-loading")) || this.options.loading
  14729. }
  14730. }),
  14731. this.vnode
  14732. );
  14733. });
  14734. }
  14735. getImgs() {
  14736. return Array.from(this.el.querySelectorAll(this.options.selector));
  14737. }
  14738. clear() {
  14739. const imgs = this.getImgs();
  14740. imgs.forEach((el) => this.lazy.remove(el));
  14741. this.vnode = null;
  14742. this.binding = null;
  14743. this.lazy = null;
  14744. }
  14745. }
  14746. class LazyContainerManager {
  14747. constructor({ lazy }) {
  14748. this.lazy = lazy;
  14749. this.queue = [];
  14750. }
  14751. bind(el, binding, vnode) {
  14752. const container = new LazyContainer({
  14753. el,
  14754. binding,
  14755. vnode,
  14756. lazy: this.lazy
  14757. });
  14758. this.queue.push(container);
  14759. }
  14760. update(el, binding, vnode) {
  14761. const container = this.queue.find((item) => item.el === el);
  14762. if (!container)
  14763. return;
  14764. container.update({ el, binding, vnode });
  14765. }
  14766. unbind(el) {
  14767. const container = this.queue.find((item) => item.el === el);
  14768. if (!container)
  14769. return;
  14770. container.clear();
  14771. remove(this.queue, container);
  14772. }
  14773. }
  14774. var stdin_default$1 = (lazyManager) => ({
  14775. props: {
  14776. src: [String, Object],
  14777. tag: {
  14778. type: String,
  14779. default: "img"
  14780. }
  14781. },
  14782. render() {
  14783. var _a, _b;
  14784. return vue.h(
  14785. this.tag,
  14786. {
  14787. src: this.renderSrc
  14788. },
  14789. (_b = (_a = this.$slots).default) == null ? void 0 : _b.call(_a)
  14790. );
  14791. },
  14792. data() {
  14793. return {
  14794. el: null,
  14795. options: {
  14796. src: "",
  14797. error: "",
  14798. loading: "",
  14799. attempt: lazyManager.options.attempt
  14800. },
  14801. state: {
  14802. loaded: false,
  14803. error: false,
  14804. attempt: 0
  14805. },
  14806. renderSrc: ""
  14807. };
  14808. },
  14809. watch: {
  14810. src() {
  14811. this.init();
  14812. lazyManager.addLazyBox(this);
  14813. lazyManager.lazyLoadHandler();
  14814. }
  14815. },
  14816. created() {
  14817. this.init();
  14818. this.renderSrc = this.options.loading;
  14819. },
  14820. mounted() {
  14821. this.el = this.$el;
  14822. lazyManager.addLazyBox(this);
  14823. lazyManager.lazyLoadHandler();
  14824. },
  14825. beforeUnmount() {
  14826. lazyManager.removeComponent(this);
  14827. },
  14828. methods: {
  14829. init() {
  14830. const { src, loading, error } = lazyManager.valueFormatter(this.src);
  14831. this.state.loaded = false;
  14832. this.options.src = src;
  14833. this.options.error = error;
  14834. this.options.loading = loading;
  14835. this.renderSrc = this.options.loading;
  14836. },
  14837. checkInView() {
  14838. const rect = use.useRect(this.$el);
  14839. return rect.top < window.innerHeight * lazyManager.options.preLoad && rect.bottom > 0 && rect.left < window.innerWidth * lazyManager.options.preLoad && rect.right > 0;
  14840. },
  14841. load(onFinish = noop) {
  14842. if (this.state.attempt > this.options.attempt - 1 && this.state.error) {
  14843. if (process.env.NODE_ENV !== "production" && !lazyManager.options.silent) {
  14844. console.log(
  14845. `[@vant/lazyload] ${this.options.src} tried too more than ${this.options.attempt} times`
  14846. );
  14847. }
  14848. onFinish();
  14849. return;
  14850. }
  14851. const { src } = this.options;
  14852. loadImageAsync(
  14853. { src },
  14854. ({ src: src2 }) => {
  14855. this.renderSrc = src2;
  14856. this.state.loaded = true;
  14857. },
  14858. () => {
  14859. this.state.attempt++;
  14860. this.renderSrc = this.options.error;
  14861. this.state.error = true;
  14862. }
  14863. );
  14864. }
  14865. }
  14866. });
  14867. const Lazyload = {
  14868. install(app, options = {}) {
  14869. const LazyClass = stdin_default$3();
  14870. const lazy = new LazyClass(options);
  14871. const lazyContainer = new LazyContainerManager({ lazy });
  14872. app.config.globalProperties.$Lazyload = lazy;
  14873. if (options.lazyComponent) {
  14874. app.component("LazyComponent", stdin_default$2(lazy));
  14875. }
  14876. if (options.lazyImage) {
  14877. app.component("LazyImage", stdin_default$1(lazy));
  14878. }
  14879. app.directive("lazy", {
  14880. beforeMount: lazy.add.bind(lazy),
  14881. updated: lazy.update.bind(lazy),
  14882. unmounted: lazy.remove.bind(lazy)
  14883. });
  14884. app.directive("lazy-container", {
  14885. beforeMount: lazyContainer.bind.bind(lazyContainer),
  14886. updated: lazyContainer.update.bind(lazyContainer),
  14887. unmounted: lazyContainer.unbind.bind(lazyContainer)
  14888. });
  14889. }
  14890. };
  14891. const version = "4.0.4";
  14892. function install(app) {
  14893. const components = [
  14894. ActionBar,
  14895. ActionBarButton,
  14896. ActionBarIcon,
  14897. ActionSheet,
  14898. AddressEdit,
  14899. AddressList,
  14900. Area,
  14901. BackTop,
  14902. Badge,
  14903. Button,
  14904. Calendar,
  14905. Card,
  14906. Cascader,
  14907. Cell,
  14908. CellGroup,
  14909. Checkbox,
  14910. CheckboxGroup,
  14911. Circle,
  14912. Col,
  14913. Collapse,
  14914. CollapseItem,
  14915. ConfigProvider,
  14916. ContactCard,
  14917. ContactEdit,
  14918. ContactList,
  14919. CountDown,
  14920. Coupon,
  14921. CouponCell,
  14922. CouponList,
  14923. DatePicker,
  14924. Dialog,
  14925. Divider,
  14926. DropdownItem,
  14927. DropdownMenu,
  14928. Empty,
  14929. Field,
  14930. Form,
  14931. Grid,
  14932. GridItem,
  14933. Icon,
  14934. Image$1,
  14935. ImagePreview,
  14936. IndexAnchor,
  14937. IndexBar,
  14938. List,
  14939. Loading,
  14940. Locale,
  14941. NavBar,
  14942. NoticeBar,
  14943. Notify,
  14944. NumberKeyboard,
  14945. Overlay,
  14946. Pagination,
  14947. PasswordInput,
  14948. Picker,
  14949. PickerGroup,
  14950. Popover,
  14951. Popup,
  14952. Progress,
  14953. PullRefresh,
  14954. Radio,
  14955. RadioGroup,
  14956. Rate,
  14957. Row,
  14958. Search,
  14959. ShareSheet,
  14960. Sidebar,
  14961. SidebarItem,
  14962. Skeleton,
  14963. Slider,
  14964. Space,
  14965. Step,
  14966. Stepper,
  14967. Steps,
  14968. Sticky,
  14969. SubmitBar,
  14970. Swipe,
  14971. SwipeCell,
  14972. SwipeItem,
  14973. Switch,
  14974. Tab,
  14975. Tabbar,
  14976. TabbarItem,
  14977. Tabs,
  14978. Tag,
  14979. TimePicker,
  14980. Toast,
  14981. TreeSelect,
  14982. Uploader
  14983. ];
  14984. components.forEach((item) => {
  14985. if (item.install) {
  14986. app.use(item);
  14987. } else if (item.name) {
  14988. app.component(item.name, item);
  14989. }
  14990. });
  14991. }
  14992. var stdin_default = {
  14993. install,
  14994. version
  14995. };
  14996. exports.ActionBar = ActionBar;
  14997. exports.ActionBarButton = ActionBarButton;
  14998. exports.ActionBarIcon = ActionBarIcon;
  14999. exports.ActionSheet = ActionSheet;
  15000. exports.AddressEdit = AddressEdit;
  15001. exports.AddressList = AddressList;
  15002. exports.Area = Area;
  15003. exports.BackTop = BackTop;
  15004. exports.Badge = Badge;
  15005. exports.Button = Button;
  15006. exports.Calendar = Calendar;
  15007. exports.Card = Card;
  15008. exports.Cascader = Cascader;
  15009. exports.Cell = Cell;
  15010. exports.CellGroup = CellGroup;
  15011. exports.Checkbox = Checkbox;
  15012. exports.CheckboxGroup = CheckboxGroup;
  15013. exports.Circle = Circle;
  15014. exports.Col = Col;
  15015. exports.Collapse = Collapse;
  15016. exports.CollapseItem = CollapseItem;
  15017. exports.ConfigProvider = ConfigProvider;
  15018. exports.ContactCard = ContactCard;
  15019. exports.ContactEdit = ContactEdit;
  15020. exports.ContactList = ContactList;
  15021. exports.CountDown = CountDown;
  15022. exports.Coupon = Coupon;
  15023. exports.CouponCell = CouponCell;
  15024. exports.CouponList = CouponList;
  15025. exports.DatePicker = DatePicker;
  15026. exports.Dialog = Dialog;
  15027. exports.Divider = Divider;
  15028. exports.DropdownItem = DropdownItem;
  15029. exports.DropdownMenu = DropdownMenu;
  15030. exports.Empty = Empty;
  15031. exports.Field = Field;
  15032. exports.Form = Form;
  15033. exports.Grid = Grid;
  15034. exports.GridItem = GridItem;
  15035. exports.Icon = Icon;
  15036. exports.Image = Image$1;
  15037. exports.ImagePreview = ImagePreview;
  15038. exports.IndexAnchor = IndexAnchor;
  15039. exports.IndexBar = IndexBar;
  15040. exports.Lazyload = Lazyload;
  15041. exports.List = List;
  15042. exports.Loading = Loading;
  15043. exports.Locale = Locale;
  15044. exports.NavBar = NavBar;
  15045. exports.NoticeBar = NoticeBar;
  15046. exports.Notify = Notify;
  15047. exports.NumberKeyboard = NumberKeyboard;
  15048. exports.Overlay = Overlay;
  15049. exports.Pagination = Pagination;
  15050. exports.PasswordInput = PasswordInput;
  15051. exports.Picker = Picker;
  15052. exports.PickerGroup = PickerGroup;
  15053. exports.Popover = Popover;
  15054. exports.Popup = Popup;
  15055. exports.Progress = Progress;
  15056. exports.PullRefresh = PullRefresh;
  15057. exports.Radio = Radio;
  15058. exports.RadioGroup = RadioGroup;
  15059. exports.Rate = Rate;
  15060. exports.Row = Row;
  15061. exports.Search = Search;
  15062. exports.ShareSheet = ShareSheet;
  15063. exports.Sidebar = Sidebar;
  15064. exports.SidebarItem = SidebarItem;
  15065. exports.Skeleton = Skeleton;
  15066. exports.SkeletonAvatar = SkeletonAvatar;
  15067. exports.SkeletonImage = SkeletonImage;
  15068. exports.SkeletonParagraph = SkeletonParagraph;
  15069. exports.SkeletonTitle = SkeletonTitle;
  15070. exports.Slider = Slider;
  15071. exports.Space = Space;
  15072. exports.Step = Step;
  15073. exports.Stepper = Stepper;
  15074. exports.Steps = Steps;
  15075. exports.Sticky = Sticky;
  15076. exports.SubmitBar = SubmitBar;
  15077. exports.Swipe = Swipe;
  15078. exports.SwipeCell = SwipeCell;
  15079. exports.SwipeItem = SwipeItem;
  15080. exports.Switch = Switch;
  15081. exports.Tab = Tab;
  15082. exports.Tabbar = Tabbar;
  15083. exports.TabbarItem = TabbarItem;
  15084. exports.Tabs = Tabs;
  15085. exports.Tag = Tag;
  15086. exports.TimePicker = TimePicker;
  15087. exports.Toast = Toast;
  15088. exports.TreeSelect = TreeSelect;
  15089. exports.Uploader = Uploader;
  15090. exports.actionBarButtonProps = actionBarButtonProps;
  15091. exports.actionBarIconProps = actionBarIconProps;
  15092. exports.actionBarProps = actionBarProps;
  15093. exports.actionSheetProps = actionSheetProps;
  15094. exports.addressEditProps = addressEditProps;
  15095. exports.addressListProps = addressListProps;
  15096. exports.allowMultipleToast = allowMultipleToast;
  15097. exports.areaProps = areaProps;
  15098. exports.backTopProps = backTopProps;
  15099. exports.badgeProps = badgeProps;
  15100. exports.buttonProps = buttonProps;
  15101. exports.calendarProps = calendarProps;
  15102. exports.cardProps = cardProps;
  15103. exports.cascaderProps = cascaderProps;
  15104. exports.cellGroupProps = cellGroupProps;
  15105. exports.cellProps = cellProps;
  15106. exports.checkboxGroupProps = checkboxGroupProps;
  15107. exports.checkboxProps = checkboxProps;
  15108. exports.circleProps = circleProps;
  15109. exports.closeDialog = closeDialog;
  15110. exports.closeNotify = closeNotify;
  15111. exports.closeToast = closeToast;
  15112. exports.colProps = colProps;
  15113. exports.collapseItemProps = collapseItemProps;
  15114. exports.collapseProps = collapseProps;
  15115. exports.configProviderProps = configProviderProps;
  15116. exports.contactCardProps = contactCardProps;
  15117. exports.contactEditProps = contactEditProps;
  15118. exports.contactListProps = contactListProps;
  15119. exports.countDownProps = countDownProps;
  15120. exports.couponCellProps = couponCellProps;
  15121. exports.couponListProps = couponListProps;
  15122. exports.datePickerProps = datePickerProps;
  15123. exports.default = stdin_default;
  15124. exports.dialogProps = dialogProps;
  15125. exports.dividerProps = dividerProps;
  15126. exports.dropdownItemProps = dropdownItemProps;
  15127. exports.dropdownMenuProps = dropdownMenuProps;
  15128. exports.emptyProps = emptyProps;
  15129. exports.fieldProps = fieldProps;
  15130. exports.formProps = formProps;
  15131. exports.gridItemProps = gridItemProps;
  15132. exports.gridProps = gridProps;
  15133. exports.iconProps = iconProps;
  15134. exports.imagePreviewProps = imagePreviewProps;
  15135. exports.imageProps = imageProps;
  15136. exports.indexAnchorProps = indexAnchorProps;
  15137. exports.indexBarProps = indexBarProps;
  15138. exports.install = install;
  15139. exports.listProps = listProps;
  15140. exports.loadingProps = loadingProps;
  15141. exports.navBarProps = navBarProps;
  15142. exports.noticeBarProps = noticeBarProps;
  15143. exports.notifyProps = notifyProps;
  15144. exports.numberKeyboardProps = numberKeyboardProps;
  15145. exports.overlayProps = overlayProps;
  15146. exports.paginationProps = paginationProps;
  15147. exports.passwordInputProps = passwordInputProps;
  15148. exports.pickerGroupProps = pickerGroupProps;
  15149. exports.pickerProps = pickerProps;
  15150. exports.popoverProps = popoverProps;
  15151. exports.popupProps = popupProps$2;
  15152. exports.progressProps = progressProps;
  15153. exports.pullRefreshProps = pullRefreshProps;
  15154. exports.radioGroupProps = radioGroupProps;
  15155. exports.radioProps = radioProps;
  15156. exports.rateProps = rateProps;
  15157. exports.resetDialogDefaultOptions = resetDialogDefaultOptions;
  15158. exports.resetNotifyDefaultOptions = resetNotifyDefaultOptions;
  15159. exports.resetToastDefaultOptions = resetToastDefaultOptions;
  15160. exports.rowProps = rowProps;
  15161. exports.searchProps = searchProps;
  15162. exports.setDialogDefaultOptions = setDialogDefaultOptions;
  15163. exports.setNotifyDefaultOptions = setNotifyDefaultOptions;
  15164. exports.setToastDefaultOptions = setToastDefaultOptions;
  15165. exports.shareSheetProps = shareSheetProps;
  15166. exports.showConfirmDialog = showConfirmDialog;
  15167. exports.showDialog = showDialog;
  15168. exports.showFailToast = showFailToast;
  15169. exports.showImagePreview = showImagePreview;
  15170. exports.showLoadingToast = showLoadingToast;
  15171. exports.showNotify = showNotify;
  15172. exports.showSuccessToast = showSuccessToast;
  15173. exports.showToast = showToast;
  15174. exports.sidebarItemProps = sidebarItemProps;
  15175. exports.sidebarProps = sidebarProps;
  15176. exports.skeletonAvatarProps = skeletonAvatarProps;
  15177. exports.skeletonImageProps = skeletonImageProps;
  15178. exports.skeletonParagraphProps = skeletonParagraphProps;
  15179. exports.skeletonProps = skeletonProps;
  15180. exports.skeletonTitleProps = skeletonTitleProps;
  15181. exports.sliderProps = sliderProps;
  15182. exports.spaceProps = spaceProps;
  15183. exports.stepperProps = stepperProps;
  15184. exports.stepsProps = stepsProps;
  15185. exports.stickyProps = stickyProps;
  15186. exports.submitBarProps = submitBarProps;
  15187. exports.swipeCellProps = swipeCellProps;
  15188. exports.swipeProps = swipeProps;
  15189. exports.switchProps = switchProps;
  15190. exports.tabProps = tabProps;
  15191. exports.tabbarItemProps = tabbarItemProps;
  15192. exports.tabbarProps = tabbarProps;
  15193. exports.tabsProps = tabsProps;
  15194. exports.tagProps = tagProps;
  15195. exports.timePickerProps = timePickerProps;
  15196. exports.toastProps = toastProps;
  15197. exports.treeSelectProps = treeSelectProps;
  15198. exports.uploaderProps = uploaderProps;
  15199. exports.version = version;